:root {
  color-scheme: light;
  --bg: #f3f5f1;
  --surface: #ffffff;
  --surface-soft: #eef5f1;
  --ink: #142129;
  --muted: #5e6d73;
  --line: rgba(20, 33, 41, .12);
  --brand: #17334a;
  --brand-2: #1f7469;
  --accent: #c0692d;
  --ok: #168057;
  --warn: #b97418;
  --bad: #bd3f44;
  --cream: #fff8ea;
  --shadow: 0 22px 58px rgba(22, 38, 45, .14);
  --soft-shadow: 0 12px 30px rgba(22, 38, 45, .1);
  font-family: "Noto Sans TC", "Microsoft JhengHei UI", system-ui, sans-serif;
  font-size: 17px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #fcfbf6 0%, var(--bg) 52%, #e7eee9 100%);
  text-rendering: optimizeLegibility;
}

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

button {
  border: 0;
  touch-action: manipulation;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 28px rgba(22, 38, 45, .07);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.brand img {
  width: 124px;
  height: 42px;
  object-fit: contain;
  border-radius: 8px;
  background: #171013;
  padding: 5px 9px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.3;
}

.top-actions,
.button-row,
.segmented,
.hero-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.top-actions button,
.tabs button,
.segmented button,
.ghost,
.primary {
  min-height: 52px;
  border-radius: 8px;
  padding: 0 18px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 900;
}

.top-actions button,
.tabs button,
.segmented button,
.ghost {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, .8);
}

.primary,
.tabs button.is-active,
.segmented button.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), #23506f);
  box-shadow: 0 10px 22px rgba(23, 51, 74, .18);
}

.ghost:hover,
.top-actions button:hover,
.tabs button:hover,
.segmented button:hover {
  border-color: rgba(47, 111, 115, .5);
  background: #f5fbfb;
}

.danger {
  color: var(--bad);
}

main {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 60px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(340px, .98fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 20px;
}

.hero-copy,
.hero-visual,
.workspace {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .95);
  box-shadow: var(--shadow);
}

.hero-copy {
  position: relative;
  overflow: hidden;
  padding: clamp(28px, 5vw, 52px);
  background:
    linear-gradient(135deg, rgba(31, 116, 105, .09), transparent 58%),
    rgba(255, 255, 255, .96);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand-2);
  font-size: .82rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 12.5em;
  margin-bottom: 16px;
  font-size: clamp(2.35rem, 6vw, 4.15rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  line-height: 1.18;
}

p {
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.72;
}

.hero-actions {
  margin-top: 22px;
}

.hero-visual {
  position: relative;
  overflow: hidden;
  min-height: 360px;
  background: #101923;
}

.hero-visual img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  filter: saturate(1.08) contrast(1.02);
}

.hero-ticket {
  position: absolute;
  right: 20px;
  bottom: 20px;
  min-width: 190px;
  padding: 18px;
  border-radius: 8px;
  color: #fff;
  background: rgba(16, 25, 35, .9);
  box-shadow: 0 18px 46px rgba(0, 0, 0, .32);
  backdrop-filter: blur(12px);
}

.hero-ticket span,
.hero-ticket strong,
.hero-ticket small {
  display: block;
}

.hero-ticket span {
  color: #a6e1dc;
  font-size: .9rem;
  font-weight: 850;
}

.hero-ticket strong {
  margin-top: 4px;
  font-size: 2.15rem;
  line-height: 1;
}

.hero-ticket small {
  margin-top: 6px;
  color: rgba(255, 255, 255, .75);
}

.tabs {
  display: flex;
  gap: 12px;
  margin: 20px 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
  overflow-x: auto;
  box-shadow: var(--soft-shadow);
}

.workspace {
  padding: clamp(22px, 3.5vw, 34px);
}

.sync-mode {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.sync-mode strong,
.sync-mode span {
  display: block;
}

.sync-mode span {
  color: var(--muted);
  font-size: .92rem;
}

.sync-mode::after {
  content: "同步";
  min-width: 58px;
  border-radius: 999px;
  padding: 5px 9px;
  color: #fff;
  background: var(--ok);
  font-size: .78rem;
  font-weight: 900;
  text-align: center;
}

.sync-mode.is-local::after {
  content: "本機";
  background: var(--warn);
}

.message {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 8px;
  color: #155345;
  background: #e9f5ef;
  font-weight: 800;
}

.message.is-warn {
  color: #6b3b12;
  background: #fff0db;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.metric,
.compact-stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.metric {
  min-height: 130px;
  padding: 18px;
  border-left: 5px solid var(--brand-2);
}

.metric strong,
.metric span,
.metric small {
  display: block;
}

.metric strong {
  font-size: clamp(2rem, 4vw, 2.7rem);
  line-height: 1;
  color: var(--brand);
}

.metric span {
  margin-top: 8px;
  color: var(--ink);
  font-weight: 900;
}

.metric small {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

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

.panel-head p {
  max-width: 36rem;
  margin-bottom: 0;
}

fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

legend {
  grid-column: 1 / -1;
  margin-bottom: 8px;
  font-weight: 900;
}

.choice-card {
  display: flex;
  gap: 12px;
  min-height: 104px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.choice-card input {
  width: 22px;
  min-width: 22px;
}

.choice-card strong,
.choice-card small {
  display: block;
}

.choice-card small {
  margin-top: 4px;
  color: var(--muted);
}

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

label {
  display: grid;
  gap: 8px;
  font-size: 1.02rem;
  font-weight: 900;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 15px;
  color: var(--ink);
  background: #fff;
  font-size: 1.03rem;
  box-shadow: inset 0 1px 0 rgba(20, 33, 41, .03);
}

textarea {
  resize: vertical;
}

.ticket-result,
.owner-todo,
.boundary-note {
  border: 1px solid rgba(47, 111, 115, .22);
  border-radius: 8px;
  background: #f4fbfa;
  box-shadow: var(--soft-shadow);
}

.ticket-result {
  margin-top: 18px;
  padding: 20px;
}

.ticket-result strong {
  color: var(--brand);
  font-size: 2.2rem;
}

.staff-overview {
  position: sticky;
  top: 78px;
  z-index: 8;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr);
  gap: 16px;
  margin-bottom: 20px;
  padding: 12px;
  border: 1px solid rgba(23, 33, 43, .09);
  border-radius: 12px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 16px 38px rgba(24, 38, 51, .12);
}

.owner-todo {
  padding: 20px;
  border-left: 5px solid var(--accent);
}

.owner-todo strong {
  display: block;
  margin-bottom: 12px;
  color: var(--brand);
  font-size: 1.18rem;
}

.owner-todo ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.owner-todo li {
  color: var(--ink);
  line-height: 1.6;
  font-weight: 750;
}

.board-stats {
  display: grid;
  gap: 10px;
}

.board-stat-title {
  margin: 0;
  color: var(--brand);
  font-size: 1.16rem;
}

.board-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px;
}

.board-alert {
  min-height: 58px;
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(166, 95, 29, .24);
  border-radius: 8px;
  color: #442407;
  background: #ffe08c;
  font-size: 1.04rem;
  font-weight: 950;
  animation: boardAlertPulse 1.8s ease-in-out infinite;
}

.board-alert.is-calm {
  color: #102119;
  border-color: rgba(35, 143, 90, .24);
  background: #c8f1df;
  animation: none;
}

@keyframes boardAlertPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 224, 140, 0); }
  50% { box-shadow: 0 0 0 6px rgba(255, 224, 140, .22); }
}

.compact-stat {
  min-height: 132px;
  padding: 16px;
  border: 1px solid rgba(23, 33, 43, .1);
  border-radius: 8px;
  background: #ffffff;
  border-left: 5px solid rgba(31, 116, 105, .55);
}

.compact-stat strong,
.compact-stat span,
.compact-stat small {
  display: block;
}

.compact-stat strong {
  color: var(--brand);
  font-size: clamp(1.8rem, 3.4vw, 2.45rem);
  line-height: 1;
}

.compact-stat span {
  margin-top: 8px;
  color: var(--muted);
  font-weight: 850;
}

.compact-stat small {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.35;
}

.staff-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .82);
}

.entry-list {
  display: grid;
  gap: 16px;
}

.entry-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 22px;
  border: 2px solid var(--line);
  border-left: 8px solid var(--brand-2);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.entry-card.is-long-wait {
  border-color: rgba(179, 65, 69, .62);
  border-left-color: var(--bad);
  box-shadow: inset 0 0 0 1px rgba(179, 65, 69, .12);
}

.entry-card.is-called {
  border-left-color: var(--warn);
  background: #fff9f0;
}

.entry-card.is-done {
  border-left-color: var(--ok);
  opacity: .82;
}

.entry-card.is-canceled {
  border-left-color: var(--bad);
  opacity: .76;
}

.entry-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.entry-title h3 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1.2;
}

.badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 11px;
  font-size: .86rem;
  font-weight: 900;
}

.badge {
  color: #fff;
  background: var(--brand);
}

.badge.waitlist {
  background: var(--accent);
}

.badge.reservation {
  background: var(--brand-2);
}

.status-pill {
  color: var(--brand);
  background: var(--surface-soft);
}

.wait-badge {
  width: fit-content;
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  margin-top: 12px;
  padding: 0 16px;
  border-radius: 8px;
  color: #102119;
  background: #c8f1df;
  font-size: 1.18rem;
  font-weight: 950;
}

.wait-badge.is-long {
  color: #fff;
  background: var(--bad);
}

.entry-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: .98rem;
}

.entry-meta span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #f3f6f5;
  font-weight: 750;
}

.entry-suggestion {
  margin: 11px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--ink);
  background: #fff4d4;
  font-size: 1.02rem;
  font-weight: 900;
}

.entry-note {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: .98rem;
}

.entry-actions {
  display: grid;
  gap: 10px;
  min-width: 184px;
}

.entry-actions button {
  min-height: 58px;
  width: 100%;
  font-size: 1.06rem;
  font-weight: 950;
}

.entry-actions button:disabled {
  cursor: wait;
  opacity: .72;
}

.entry-actions .action-seat {
  color: #fff;
  background: var(--ok);
}

.entry-actions .action-noshow {
  color: var(--ink);
  background: #e8edf0;
}

.empty {
  padding: 34px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, .72);
  text-align: center;
  font-weight: 850;
}

.settings-form {
  max-width: 840px;
}

.boundary-note {
  margin-top: 18px;
  padding: 16px;
}

.reason-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 24, 32, .58);
  backdrop-filter: blur(8px);
}

.reason-modal {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 24px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .26);
}

.reason-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 1.2rem;
}

.reason-modal h3 {
  margin: 0 44px 8px 0;
  font-size: 1.58rem;
}

.reason-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.reason-options button,
.reason-modal .button-row button {
  min-height: 56px;
  font-size: 1.04rem;
  font-weight: 950;
}

.reason-error {
  min-height: 24px;
  color: var(--bad);
  font-weight: 900;
}

@media (max-width: 900px) {
  .topbar,
  .panel-head,
  .staff-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-panel,
  .status-strip,
  .form-grid,
  fieldset,
  .staff-overview,
  .board-stat-grid,
  .reason-options {
    grid-template-columns: 1fr;
  }

  .staff-overview {
    position: static;
  }

  .sync-mode {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }

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

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

@media (max-width: 540px) {
  :root {
    font-size: 16px;
  }

  main {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .top-actions {
    display: none;
  }

  .brand img {
    width: 96px;
  }

  .hero-copy,
  .workspace {
    padding: 18px;
  }

  .hero-visual {
    min-height: 240px;
  }

  .hero-ticket {
    right: 12px;
    bottom: 12px;
    left: 12px;
    min-width: 0;
  }

  .tabs {
    gap: 8px;
    padding: 6px;
  }

  .tabs button,
  .segmented button,
  .ghost,
  .primary {
    min-height: 54px;
    padding-inline: 13px;
  }

  .board-stats {
    grid-template-columns: 1fr;
  }

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

  .staff-toolbar {
    align-items: stretch;
  }

  .segmented,
  .button-row {
    width: 100%;
  }

  .segmented button,
  .button-row button {
    flex: 1 1 100%;
  }
}
