:root {
  color-scheme: light;
  --red-950: #2c1514;
  --red-900: #4f1918;
  --red-800: #762421;
  --ink: #202423;
  --muted: #68716f;
  --paper: #f7f2e8;
  --white: #ffffff;
  --jade: #2f7667;
  --jade-dark: #24584f;
  --gold: #c79a45;
  --line: rgba(32, 36, 35, 0.14);
  --danger: #a33a31;
  --shadow: 0 18px 60px rgba(32, 36, 35, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(rgba(247, 242, 232, 0.92), rgba(247, 242, 232, 0.98)),
    url("assets/hero-table.jpg") center / cover fixed;
  font-family:
    "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px clamp(16px, 4vw, 42px);
  color: var(--white);
  background: rgba(32, 24, 24, 0.88);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand img {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.42);
}

.brand span {
  display: grid;
  min-width: 0;
}

.brand strong,
.brand small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand small {
  color: rgba(255, 255, 255, 0.68);
}

.header-actions,
.tools,
.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.app-shell {
  display: grid;
  gap: 22px;
  padding: clamp(18px, 4vw, 42px);
}

.mode-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  color: var(--white);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(79, 25, 24, 0.96), rgba(47, 118, 103, 0.92));
  box-shadow: var(--shadow);
}

.mode-banner div {
  display: grid;
  gap: 2px;
}

.mode-banner span,
.guest-hero > span,
.qr-copy > span {
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.mode-banner strong {
  font-size: 1.35rem;
}

.mode-banner p {
  max-width: 520px;
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  text-align: right;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.dashboard article,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.dashboard article {
  min-height: 128px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 22px;
}

.dashboard span,
.panel-title span,
.menu-label {
  color: var(--jade);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.dashboard strong {
  font-size: 2.25rem;
  line-height: 1.05;
}

.dashboard small {
  color: var(--muted);
}

.work-area {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 24px;
}

.entry-form {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 16px;
}

.panel-title h1,
.panel-title h2 {
  margin: 4px 0 0;
  font-size: 1.7rem;
  line-height: 1.15;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--jade);
  box-shadow: 0 0 0 3px rgba(47, 118, 103, 0.14);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.item-actions button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  color: var(--white);
  background: var(--jade);
}

.primary-button:hover {
  background: var(--jade-dark);
}

.secondary-button,
.ghost-button {
  color: var(--ink);
  background: var(--white);
  border-color: var(--line);
}

.ghost-button {
  color: var(--white);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.28);
}

.danger-button {
  color: var(--white);
  background: var(--danger);
}

.queue-panel {
  min-height: 580px;
}

.queue-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.tools {
  justify-content: flex-end;
}

.tools input {
  width: min(360px, 42vw);
}

.tools select {
  width: 140px;
}

.queue-list {
  display: grid;
  gap: 12px;
}

.queue-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: stretch;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.queue-item.called {
  border-color: rgba(199, 154, 69, 0.65);
  background: #fffaf0;
}

.queue-item.seated,
.queue-item.cancelled {
  opacity: 0.66;
}

.ticket {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  color: var(--white);
  border-radius: 8px;
  background: var(--red-800);
}

.ticket-number {
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1;
}

.ticket-status {
  color: rgba(255, 255, 255, 0.78);
  font-weight: 900;
}

.party {
  min-width: 0;
}

.party-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.party-main h3 {
  margin: 0;
  font-size: 1.25rem;
}

.party-size {
  color: var(--jade);
  font-weight: 900;
}

.party-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.party-meta div {
  min-width: 0;
}

.party-meta dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.party-meta dd {
  margin: 2px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.party-note {
  margin: 12px 0 0;
  color: var(--muted);
}

.party-note:empty {
  display: none;
}

.item-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(84px, 1fr));
  gap: 8px;
  align-content: center;
}

.item-actions button {
  color: var(--ink);
  background: var(--paper);
  border-color: var(--line);
}

.item-actions button[data-action="call"] {
  color: var(--white);
  background: var(--gold);
}

.item-actions button[data-action="seat"] {
  color: var(--white);
  background: var(--jade);
}

.item-actions button[data-action="cancel"] {
  color: var(--white);
  background: var(--danger);
}

.item-actions button[hidden] {
  display: none;
}

.empty-state {
  min-height: 340px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.empty-state strong {
  color: var(--ink);
  font-size: 1.3rem;
}

.history-actions {
  justify-content: flex-end;
}

.qr-panel {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(32, 24, 24, 0.68);
}

.qr-card {
  width: min(880px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  padding: 24px;
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.28);
}

.qr-copy {
  display: grid;
  align-content: center;
  gap: 14px;
}

.qr-copy > span {
  color: var(--jade);
}

.qr-copy h2 {
  margin: 0;
  font-size: 2rem;
}

.qr-copy p {
  margin: 0;
  color: var(--muted);
}

.qr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.qr-code-box {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  text-align: center;
}

.qr-code-box img {
  width: min(260px, 100%);
  aspect-ratio: 1;
  object-fit: contain;
  background: var(--white);
}

.qr-code-box small {
  color: var(--muted);
}

.guest-page {
  background:
    linear-gradient(rgba(247, 242, 232, 0.88), rgba(247, 242, 232, 0.98)),
    url("assets/dumplings-pancake.jpg") center / cover fixed;
}

.guest-header {
  position: relative;
}

.guest-shell {
  width: min(980px, 100%);
  display: grid;
  gap: 18px;
  margin: 0 auto;
  padding: clamp(18px, 5vw, 42px);
}

.guest-hero {
  display: grid;
  gap: 14px;
  padding: clamp(24px, 6vw, 42px);
  color: var(--white);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(44, 21, 20, 0.94), rgba(47, 118, 103, 0.9)),
    url("assets/hero-table.jpg") center / cover;
  box-shadow: var(--shadow);
}

.guest-hero > span {
  color: rgba(255, 255, 255, 0.72);
}

.guest-hero h1 {
  margin: 0;
  font-size: clamp(2.2rem, 9vw, 4.2rem);
  line-height: 1;
}

.guest-hero p {
  max-width: 620px;
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
}

.guest-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.guest-summary article {
  display: grid;
  gap: 2px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}

.guest-summary small,
.guest-summary span {
  color: rgba(255, 255, 255, 0.72);
}

.guest-summary strong {
  font-size: 2.2rem;
  line-height: 1;
}

.sync-note {
  font-size: 0.92rem;
}

.guest-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.86fr);
  gap: 18px;
  align-items: start;
}

.guest-form {
  display: grid;
  gap: 16px;
}

.guest-ticket {
  display: grid;
  gap: 16px;
}

.guest-ticket-number {
  display: grid;
  place-items: center;
  min-height: 130px;
  color: var(--white);
  border-radius: 8px;
  background: var(--red-800);
  font-size: clamp(3rem, 14vw, 5.2rem);
  font-weight: 900;
  line-height: 1;
}

.guest-ticket > strong {
  font-size: 1.7rem;
  color: var(--jade);
}

.guest-ticket > p {
  margin: 0;
  color: var(--muted);
}

.guest-ticket-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.guest-ticket-meta div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.guest-ticket-meta dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.guest-ticket-meta dd {
  margin: 4px 0 0;
  font-weight: 900;
}

.guest-ticket-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 980px) {
  .dashboard,
  .work-area,
  .guest-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .queue-panel {
    grid-column: 1 / -1;
  }

  .entry-form {
    position: static;
  }

  .guest-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions,
  .history-actions {
    align-self: stretch;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    width: auto;
  }

  .header-actions > *,
  .history-actions > * {
    min-width: 0;
    width: 100%;
  }

  .mode-banner,
  .dashboard,
  .work-area,
  .form-grid,
  .guest-summary,
  .guest-ticket-meta {
    grid-template-columns: 1fr;
  }

  .mode-banner {
    align-items: start;
    display: grid;
  }

  .mode-banner p {
    text-align: left;
  }

  .panel {
    padding: 18px;
  }

  .queue-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .tools input,
  .tools select {
    width: 100%;
  }

  .queue-item {
    grid-template-columns: 1fr;
  }

  .ticket {
    min-height: 82px;
    grid-template-columns: auto auto;
    justify-content: center;
    gap: 10px;
  }

  .party-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .item-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guest-ticket-actions,
  .qr-actions {
    grid-template-columns: 1fr;
  }

  .qr-card {
    max-height: 92vh;
    overflow: auto;
  }
}
