:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef3f4;
  --ink: #17212b;
  --muted: #687583;
  --line: rgba(23, 33, 43, .13);
  --brand: #26384f;
  --brand-2: #2f6f73;
  --accent: #b65f32;
  --ok: #23775f;
  --warn: #a65f1d;
  --bad: #b34145;
  --shadow: 0 18px 46px rgba(24, 38, 51, .12);
  font-family: "Microsoft JhengHei UI", "Noto Sans TC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(47, 111, 115, .12), transparent 34rem),
    linear-gradient(180deg, #fbfcfd 0%, var(--bg) 48%, #e9eef1 100%);
}

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

button {
  border: 0;
}

.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: 14px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(18px);
}

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

.brand img {
  width: 118px;
  height: 38px;
  object-fit: contain;
  border-radius: 8px;
  background: #171013;
}

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

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: .82rem;
}

.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: 40px;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 850;
}

.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: var(--brand);
}

.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(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 54px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(320px, .94fr);
  gap: 22px;
  align-items: stretch;
  margin-bottom: 18px;
}

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

.hero-copy {
  padding: clamp(24px, 4vw, 44px);
}

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

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

h1 {
  max-width: 13em;
  margin-bottom: 16px;
  font-size: clamp(2rem, 6vw, 3.8rem);
  line-height: 1.06;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: clamp(1.35rem, 3vw, 1.95rem);
}

p {
  color: var(--muted);
  line-height: 1.65;
}

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

.hero-visual {
  position: relative;
  overflow: hidden;
  min-height: 320px;
}

.hero-visual img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.hero-ticket {
  position: absolute;
  right: 18px;
  bottom: 18px;
  min-width: 168px;
  padding: 16px;
  border-radius: 8px;
  color: #fff;
  background: rgba(23, 33, 43, .88);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .26);
}

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

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

.hero-ticket strong {
  margin-top: 4px;
  font-size: 1.75rem;
}

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

.tabs {
  display: flex;
  gap: 10px;
  margin: 18px 0;
  overflow-x: auto;
}

.workspace {
  padding: clamp(18px, 3vw, 28px);
}

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

.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: 14px;
  padding: 12px 14px;
  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: 12px;
  margin-bottom: 22px;
}

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

.metric {
  padding: 15px;
}

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

.metric strong {
  font-size: 1.7rem;
  line-height: 1;
}

.metric span {
  margin-top: 6px;
  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: 18px;
}

.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: 88px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.choice-card input {
  width: 18px;
}

.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: 14px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 850;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
}

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

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

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

.staff-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, .55fr);
  gap: 14px;
  margin-bottom: 16px;
}

.owner-todo {
  padding: 16px;
}

.owner-todo strong {
  display: block;
  margin-bottom: 10px;
  font-size: 1.05rem;
}

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

.owner-todo li {
  line-height: 1.55;
}

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

.compact-stat {
  padding: 14px;
}

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

.compact-stat strong {
  font-size: 1.65rem;
  line-height: 1;
}

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

.staff-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

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

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

.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: 1.16rem;
}

.badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: .78rem;
  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);
}

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

.entry-suggestion {
  margin: 11px 0 0;
  color: var(--ink);
  font-weight: 850;
}

.entry-note {
  margin: 8px 0 0;
  color: var(--muted);
}

.entry-actions {
  display: grid;
  gap: 8px;
  min-width: 158px;
}

.entry-actions button {
  width: 100%;
}

.empty {
  padding: 28px;
  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;
}

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

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

  .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) {
  main {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .top-actions {
    display: none;
  }

  .brand img {
    width: 96px;
  }

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

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

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

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