:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2933;
  background: #f5f7fa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid #b7c2d0;
  background: #fff;
  color: #172b4d;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
}

button:focus-visible,
.top-actions a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.38);
  outline-offset: 2px;
}

main button,
.table-row button {
  border-color: #93a4b8;
  background: linear-gradient(#ffffff, #f3f6fb);
  color: #172b4d;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

main button:hover,
.table-row button:hover {
  border-color: #2563eb;
  background: #eff6ff;
}

main button:active,
.table-row button:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.16);
}

.layout {
  display: grid;
  grid-template-columns: minmax(250px, 34%) minmax(0, 1fr);
  gap: 14px;
  max-width: 920px;
  margin: 0 auto;
  padding: 14px;
  align-items: start;
}

.app-alert {
  max-width: 920px;
}

.list-pane,
.editor-pane,
.qr-pane {
  background: #fff;
  border: 1px solid #d9e2ec;
  border-radius: 8px;
  padding: 16px;
}

.qr-pane {
  margin-top: 16px;
}

.pane-head,
.form-actions,
.qr-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

.status {
  min-height: 24px;
  color: #52606d;
}

.status.error {
  color: #b42318;
}

.table-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: calc(100dvh - 226px);
  min-height: 300px;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid #d9e2ec;
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}

.table-row.is-selected {
  border-color: #2563eb;
  background: #eff6ff;
}

.table-row.is-hidden {
  opacity: 0.55;
}

.table-select {
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  text-align: left;
}

.table-row .table-select {
  border: 0;
  background: transparent;
  box-shadow: none;
  font-weight: inherit;
}

.table-row-side {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-name {
  display: block;
  font-weight: 700;
}

.table-meta {
  display: block;
  color: #66788a;
  font-size: 13px;
  margin-top: 3px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  background: #edf2f7;
  color: #52606d;
  font-size: 12px;
}

.badge.test {
  background: #e0f2fe;
  color: #075985;
}

label {
  display: grid;
  gap: 6px;
  color: #334e68;
  font-size: 14px;
}

input:not([type="checkbox"]) {
  width: 100%;
  border: 1px solid #bcccdc;
  border-radius: 6px;
  padding: 9px 10px;
}

.hint {
  color: #7b8794;
  font-size: 12px;
  line-height: 1.35;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
}

.row-delete-btn,
#regenBtn {
  color: #b42318;
  border-color: #f4b4ad;
  background: linear-gradient(#fffafa, #fff0f0);
}

.row-delete-btn {
  padding: 6px 9px;
}

#createBtn,
#updateBtn {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.22);
}

#createBtn:hover,
#updateBtn:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

#updateBtn {
  background: #0f766e;
  border-color: #0f766e;
  box-shadow: 0 2px 4px rgba(15, 118, 110, 0.2);
}

#updateBtn:hover {
  background: #0d5f59;
  border-color: #0d5f59;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:disabled:hover {
  border-color: #93a4b8;
}

#copyUrlBtn,
#copyUrlEnBtn,
#openPreviewBtn,
#printBtn {
  border-color: #2563eb;
  color: #1d4ed8;
}

.qr-content {
  display: grid;
  gap: 12px;
}

.qr-print-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(320px, 100%);
  padding: 18px;
  border: 1px solid #d9e2ec;
  border-radius: 8px;
  background: #fff;
}

.qr-store-name,
.qr-table-name,
.qr-print-caption,
.qr-print-note {
  margin: 0;
  text-align: center;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.qr-store-name {
  color: #52606d;
  font-size: 14px;
}

.qr-table-name {
  color: #111827;
  font-size: 22px;
  font-weight: 800;
}

.qr-print-caption {
  color: #111827;
  font-size: 18px;
  font-weight: 700;
}

.qr-print-note {
  color: #52606d;
  font-size: 13px;
  line-height: 1.45;
}

.hidden {
  display: none;
}

.bulk-print-area {
  display: none;
}

.bulk-print-sheet {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.bulk-qr-card {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-height: 258px;
  padding: 12px;
  border: 1.5px solid #111827;
  border-radius: 8px;
  background: #fff;
  break-inside: avoid;
  page-break-inside: avoid;
}

.bulk-qr-store,
.bulk-qr-table,
.bulk-qr-caption,
.bulk-qr-note {
  margin: 0;
  text-align: center;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.bulk-qr-store {
  min-height: 18px;
  color: #52606d;
  font-size: 12px;
}

.bulk-qr-table {
  color: #111827;
  font-size: 18px;
  font-weight: 900;
}

.bulk-qr-card img {
  width: 140px;
  height: 140px;
}

.bulk-qr-caption {
  color: #111827;
  font-size: 16px;
  font-weight: 800;
}

.bulk-qr-note {
  color: #52606d;
  font-size: 11px;
}

#qrImage {
  width: min(240px, 100%);
  aspect-ratio: 1;
  border: 1px solid #d9e2ec;
}

@media print {
  @page {
    size: A4;
    margin: 10mm;
  }

  html,
  body {
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    background: #fff;
  }

  .topbar,
  main,
  .layout {
    display: none !important;
  }

  .bulk-print-area {
    display: block;
    width: 190mm;
    margin: 0 auto;
  }

  .bulk-print-sheet {
    display: grid;
    width: 190mm;
    max-width: 190mm;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2.5mm;
    height: 257mm;
    break-after: page;
    page-break-after: always;
  }

  .bulk-print-sheet:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .bulk-qr-card {
    min-height: 0;
    height: auto;
    padding: 2.5mm 2mm;
    border: 1.5pt solid #111827;
    box-shadow: none;
    overflow: visible;
    break-inside: avoid-page;
  }

  .bulk-qr-card img {
    width: 31mm;
    height: 31mm;
  }

  .bulk-qr-store {
    min-height: 3.5mm;
    color: #111827;
    font-size: 7.5pt;
    line-height: 1.15;
  }

  .bulk-qr-table {
    font-size: 12pt;
    line-height: 1.1;
  }

  .bulk-qr-caption {
    font-size: 10pt;
    line-height: 1.1;
  }

  .bulk-qr-note {
    color: #111827;
    font-size: 7.5pt;
    line-height: 1.15;
  }
}

@media (min-width: 641px) {
  .topbar {
    align-items: center;
    flex-direction: row;
    gap: 16px;
    min-height: 72px;
    padding: 16px 20px;
  }

  .top-actions,
  .app-nav {
    align-items: center;
    justify-content: flex-end;
    flex-direction: row;
    width: auto;
    flex-wrap: nowrap;
  }

  .topbar .app-nav a,
  .topbar .top-actions > button,
  .topbar .manu-settings-button {
    width: auto !important;
    min-height: 38px !important;
    padding: 8px 12px !important;
    border-radius: 6px;
    font-size: 16px !important;
    line-height: 1.2;
  }

  .topbar .manu-settings-button {
    width: 38px !important;
    min-width: 38px;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .list-pane,
  .editor-pane,
  .qr-pane {
    padding: 14px;
  }

  .pane-head,
  .form-actions,
  .qr-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .pane-head button,
  .form-actions button,
  .qr-actions button {
    min-height: 38px;
    padding: 7px 11px;
  }

  .qr-print-card {
    width: min(280px, 100%);
    padding: 14px;
  }

  #qrImage {
    width: min(220px, 100%);
  }
}

@media (max-width: 640px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  .table-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px;
  }

  .table-list {
    max-height: 220px;
    min-height: 0;
  }

  .table-row-side {
    align-items: center;
    flex-direction: row;
    gap: 6px;
  }

  .badges {
    justify-content: flex-start;
  }

  .pane-head button,
  .form-actions button,
  .qr-actions button {
    width: auto;
    text-align: center;
  }

  .list-pane,
  .editor-pane,
  .qr-pane {
    padding: 10px;
  }

  .pane-head,
  .form-actions,
  .qr-actions {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .pane-head button,
  .form-actions button,
  .qr-actions button {
    min-height: 32px;
    padding: 5px 9px;
    font-size: 13px;
  }

  .table-name {
    font-size: 14px;
  }

  .table-meta {
    font-size: 12px;
  }

  .badge {
    padding: 2px 6px;
    font-size: 11px;
  }

  .row-delete-btn {
    min-height: 30px;
    padding: 4px 7px;
    font-size: 12px;
  }

  input:not([type="checkbox"]) {
    font-size: 16px;
    line-height: 1.35;
  }

  .qr-print-card {
    width: min(260px, 100%);
    padding: 12px;
  }

  .qr-table-name {
    font-size: 18px;
  }

  .qr-print-caption {
    font-size: 15px;
  }

  #qrImage {
    width: min(200px, 100%);
  }
}

/* Seat QR management app-style layout */
body {
  background:
    linear-gradient(180deg, #ffffff 0, #f3f7ff 52%, #eef5ff 100%);
}

.topbar {
  max-width: 920px;
  margin: 0 auto;
  background: transparent;
  color: #0d2b68;
  border-bottom: 0;
  box-shadow: none;
}

.topbar h1 {
  font-size: clamp(28px, 5vw, 48px);
  letter-spacing: 0;
}

.eyebrow {
  color: #0b8f86;
  font-weight: 900;
}

.layout {
  grid-template-columns: minmax(420px, 500px) minmax(300px, 1fr);
  gap: 18px;
  max-width: 920px;
  padding: 8px 14px 84px;
}

.list-pane {
  position: relative;
  overflow: hidden;
  border: 10px solid #0d3478;
  border-radius: 38px;
  padding: 20px 18px 18px;
  background: #ffffff;
  box-shadow: 0 24px 54px rgba(13, 52, 120, 0.22);
}

.list-pane::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  width: 154px;
  height: 22px;
  border-radius: 0 0 18px 18px;
  background: #0d3478;
  transform: translateX(-50%);
}

.pane-head {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding-top: 14px;
}

.pane-head h2 {
  margin: 0;
  color: #0d2b68;
  font-size: 22px;
  font-weight: 900;
  text-align: center;
}

.add-table-btn {
  min-height: 40px;
  border-color: #0f9a91;
  border-radius: 999px;
  color: #0f8f86;
  padding: 7px 18px;
  background: #ffffff;
  font-weight: 900;
}

.qr-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 6px 0 16px;
}

.summary-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 6px 12px;
  min-height: 92px;
  padding: 14px;
  border: 1px solid #d9e4f1;
  border-radius: 10px;
  background: #fff;
}

.summary-icon {
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #e5f6f2;
  color: #0f8f86;
  font-size: 15px;
  font-weight: 900;
}

.summary-icon.shield {
  background: #eef4ff;
  color: #0d3478;
}

.summary-label {
  align-self: end;
  color: #0d2b68;
  font-weight: 900;
}

.summary-card strong {
  align-self: start;
  color: #0f9a91;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

.status {
  min-height: 0;
  margin: 0 0 10px;
  color: #63718a;
  font-size: 13px;
}

.table-list {
  gap: 12px;
  max-height: calc(100dvh - 340px);
  min-height: 360px;
  margin-top: 0;
  padding: 0 2px 4px;
}

.table-row {
  grid-template-columns: 102px minmax(0, 1fr) 126px;
  align-items: center;
  gap: 14px;
  min-height: 134px;
  border-color: #dbe6f2;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 6px 18px rgba(13, 52, 120, 0.07);
}

.table-row.is-selected {
  border-color: #0f9a91;
  background: #f2fffd;
}

.table-row.is-hidden {
  opacity: 1;
  background: #fbfcff;
}

.table-qr-box {
  display: grid;
  place-items: center;
  width: 102px;
  height: 102px;
  border: 1px solid #cbd8e8;
  border-radius: 8px;
  background: #ffffff;
}

.table-qr-thumb {
  width: 88px;
  height: 88px;
  image-rendering: crisp-edges;
}

.table-select {
  display: grid;
  gap: 4px;
  color: #0d2b68;
}

.table-name {
  color: #0d2b68;
  font-size: 22px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: 0;
}

.table-meta {
  color: #0d2b68;
  font-size: 13px;
  font-weight: 800;
}

.table-row-side {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: center;
}

.badges {
  justify-content: start;
}

.badge {
  border-radius: 999px;
  padding: 4px 9px;
  background: #e7f7f4;
  color: #0f8f86;
  font-size: 12px;
  font-weight: 900;
}

.badge.active {
  background: linear-gradient(135deg, #20aa9d, #0d8f86);
  color: #ffffff;
}

.badge.inactive {
  background: #ffe8ef;
  color: #d63357;
}

.table-view-btn,
.table-print-btn {
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  font-weight: 900;
}

.table-view-btn {
  border-color: #0f9a91;
  color: #0b7f78;
  background: #ffffff;
}

.table-print-btn {
  border-color: #0f9a91;
  background: linear-gradient(135deg, #18afa1, #068c83);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(6, 140, 131, 0.2);
}

.row-delete-btn {
  width: 100%;
  min-height: 30px;
  border: 0;
  background: transparent;
  color: #c13545;
  box-shadow: none;
  padding: 2px 4px;
  font-size: 12px;
}

.editor-pane,
.qr-pane {
  border-color: #d9e4f1;
  border-radius: 16px;
  box-shadow: 0 14px 34px rgba(13, 52, 120, 0.1);
}

.editor-pane {
  align-self: start;
}

.form-actions,
.qr-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.floating-print-btn {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 10;
  width: min(360px, calc(100% - 28px));
  min-height: 58px;
  transform: translateX(-50%);
  border-color: #0f9a91;
  border-radius: 18px;
  background: linear-gradient(135deg, #18afa1, #068c83);
  color: #ffffff;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 18px 34px rgba(6, 140, 131, 0.28);
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    max-width: 520px;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 12px 14px;
  }

  .topbar h1 {
    font-size: 26px;
  }

  .layout {
    padding: 8px 8px 84px;
  }

  .list-pane {
    border-width: 6px;
    border-radius: 28px;
    padding: 14px 10px 12px;
  }

  .list-pane::before {
    width: 118px;
    height: 18px;
  }

  .pane-head {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 56px;
    padding-top: 10px;
  }

  .pane-head h2 {
    font-size: 18px;
  }

  .add-table-btn {
    min-height: 34px;
    padding: 5px 12px;
    font-size: 13px;
  }

  .qr-summary {
    gap: 8px;
  }

  .summary-card {
    grid-template-columns: 44px minmax(0, 1fr);
    min-height: 74px;
    padding: 10px;
  }

  .summary-icon {
    width: 44px;
    height: 44px;
    font-size: 12px;
  }

  .summary-card strong {
    font-size: 22px;
  }

  .table-list {
    max-height: none;
    min-height: 0;
  }

  .table-row {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 10px;
    min-height: 0;
    padding: 10px;
  }

  .table-qr-box {
    width: 82px;
    height: 82px;
  }

  .table-qr-thumb {
    width: 70px;
    height: 70px;
  }

  .table-name {
    font-size: 19px;
  }

  .table-row-side {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
  }

  .badges {
    grid-column: 1 / -1;
  }

  .row-delete-btn {
    grid-column: 1 / -1;
  }
}

/* Usability refinements */
.list-pane {
  overflow: visible;
  border: 1px solid #d9e4f1;
  border-radius: 18px;
  padding: 16px;
}

.list-pane::before {
  content: none;
}

.table-list {
  max-height: none;
  min-height: 0;
  overflow: visible;
  padding: 0 0 8px;
}

.row-delete-btn,
#deleteTableBtn {
  border: 1px solid #f0b1b1;
  background: #fff4f4;
  color: #b4232a;
  box-shadow: none;
  font-weight: 900;
}

.row-delete-btn {
  min-height: 36px;
  border-radius: 8px;
}

.row-hard-delete-btn,
#deleteTableBtn {
  border-color: #dc2626;
  background: linear-gradient(#dc2626, #b91c1c);
  color: #ffffff;
}

.row-hard-delete-btn {
  width: 100%;
  min-height: 34px;
  border-radius: 8px;
  font-weight: 900;
}

.qr-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.qr-close-btn {
  display: none;
}

@media (max-width: 640px) {
  .list-pane {
    border-width: 1px;
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 10px 24px rgba(13, 52, 120, 0.12);
  }

  .table-row-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .row-delete-btn,
  .row-hard-delete-btn {
    grid-column: auto;
    font-size: 13px;
  }

  .editor-pane {
    box-shadow: none;
  }

  .qr-pane {
    position: fixed;
    left: 10px;
    right: 10px;
    top: 50%;
    z-index: 2000;
    max-height: calc(100dvh - 36px);
    overflow: auto;
    margin: 0;
    padding: 14px;
    border-radius: 18px;
    box-shadow: 0 22px 60px rgba(13, 52, 120, 0.32);
    transform: translateY(-50%) scale(0.98);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
  }

  .qr-pane.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-50%) scale(1);
  }

  .qr-pane.is-open::before {
    content: "";
    position: fixed;
    inset: -50vh -20px;
    z-index: -1;
    background: rgba(13, 43, 104, 0.38);
  }

  .qr-close-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid #d7dee9;
    border-radius: 999px;
    padding: 0;
    background: #f8fafc;
    color: #0d2b68;
    font-size: 24px;
    line-height: 1;
  }

  .qr-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* Prominent in-page title now that the shared header shows the store name. */
.list-pane > .pane-head h2 {
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.1;
  letter-spacing: 0;
}

@media (max-width: 640px) {
  .list-pane > .pane-head h2 {
    font-size: 26px;
  }
}
