:root {
  --font-scale: 1;
  --bg-canvas: #eef1f5;
  --surface: #ffffff;
  --surface-subtle: #f3f5f8;
  --ink-primary: #1d2430;
  --ink-muted: #7b8494;
  --line-soft: #e3e7ee;

  --emerald-main: #1b8a52;
  --emerald-deep: #114e2e;
  --ocean-main: #1d6fa3;
  --ocean-deep: #103e5e;
  --danger-main: #dc3545;

  --sheet-peek-h: 78px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-canvas);
  color: var(--ink-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

input {
  user-select: auto;
  -webkit-user-select: auto;
  font-family: inherit;
}

::-webkit-scrollbar {
  display: none;
}

.is-hidden {
  display: none !important;
}

/* ================= View Transitions ================= */
::view-transition-group(*) {
  animation-duration: 210ms;
  animation-timing-function: var(--ease-spring);
}

/* ================= 顶部胶囊轻提示 ================= */
.toast-banner {
  position: fixed;
  top: -72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  padding: 11px 22px;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  font-size: calc(14px * var(--font-scale));
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.24);
  backdrop-filter: blur(10px);
  pointer-events: none;
  white-space: nowrap;
  transition: top 0.36s var(--ease-spring);
}
.toast-banner.is-visible {
  top: calc(var(--safe-top) + 18px);
}
.toast-banner[data-tone="emerald"] { background: rgba(24, 138, 80, 0.96); }
.toast-banner[data-tone="ocean"] { background: rgba(20, 86, 128, 0.96); }
.toast-banner[data-tone="danger"] { background: rgba(214, 48, 65, 0.96); }

/* ================= 主舞台与牌桌卡片 ================= */
.app-shell {
  width: 100%;
  max-width: 500px;
  height: 100dvh;
  margin: 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-canvas);
}

.board-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: calc(var(--safe-top) + 14px) 14px calc(var(--sheet-peek-h) + var(--safe-bottom) + 24px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tables-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.table-card {
  display: flex;
  min-height: 148px;
  border-radius: 14px;
  color: #fff;
  overflow: hidden;
  box-shadow:
    0 10px 24px rgba(15, 28, 20, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.table-card.is-theme-1 {
  background: radial-gradient(circle at 38% 18%, #26965c 0%, #145634 72%, #0f4428 100%);
}
.table-card.is-theme-10 {
  background: radial-gradient(circle at 38% 18%, #2882b8 0%, #134b70 72%, #0e3a57 100%);
}
.table-card.is-drop-hover {
  box-shadow: 0 0 0 3px #fff inset, 0 12px 28px rgba(0, 0, 0, 0.28);
}

.table-seats {
  flex: 1;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.seat-slot {
  height: 56px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}
.seat-slot:active {
  transform: scale(0.97);
}
.seat-slot.is-empty {
  border: 2px dashed rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.85);
  font-size: calc(23px * var(--font-scale));
  font-weight: 600;
}
.seat-slot.is-occupied {
  background: linear-gradient(180deg, #ffffff 0%, #f4f6f9 100%);
  color: var(--ink-primary);
  font-size: calc(16px * var(--font-scale));
  font-weight: 800;
  box-shadow: 0 3px 0 rgba(16, 24, 40, 0.16), 0 5px 10px rgba(0, 0, 0, 0.14);
  touch-action: none;
}
.seat-slot.is-occupied .seat-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.seat-slot.is-occupied .seat-tier-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.seat-tier-dot.is-tier-1 { background: var(--emerald-main); }
.seat-tier-dot.is-tier-2 { background: var(--ocean-main); }

.seat-slot.is-drop-hover {
  background: rgba(255, 255, 255, 0.36);
  border-color: #ffffff;
  box-shadow: 0 0 0 2.5px #ffffff, 0 0 14px rgba(255, 255, 255, 0.75);
  transform: scale(1.03);
}
.seat-slot.is-occupied.is-drop-hover {
  background: #fff9db;
  box-shadow: 0 0 0 2.5px #ffd43b, 0 6px 16px rgba(0, 0, 0, 0.22);
}

.table-rail {
  width: 88px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.16);
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 8px 0;
}
.table-num {
  font-size: calc(13px * var(--font-scale));
  font-weight: 700;
  opacity: 0.92;
}
.denom-badge {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.86);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: calc(21px * var(--font-scale));
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.denom-badge:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.24);
}
.rail-reset-btn {
  width: 74%;
  padding: 5px 0;
  border-radius: 7px;
  border: 1.5px solid rgba(255, 255, 255, 0.48);
  background: transparent;
  color: #fff;
  font-size: calc(12px * var(--font-scale));
  font-weight: 700;
  cursor: pointer;
}
.rail-reset-btn:active {
  background: rgba(255, 255, 255, 0.18);
}

/* ================= 待排等候池与通用人员胶囊 ================= */
.waiting-zone {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  padding: 12px;
  min-height: 76px;
}
.waiting-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.waiting-label {
  font-size: calc(13px * var(--font-scale));
  font-weight: 700;
  color: #4b5565;
}
.waiting-hint {
  font-size: calc(12px * var(--font-scale));
  color: var(--ink-muted);
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.guest-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 10px 15px;
  border-radius: 9px;
  background: #edf0f5;
  color: var(--ink-primary);
  font-size: calc(15px * var(--font-scale));
  font-weight: 600;
  cursor: pointer;
  max-width: 100%;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.06), inset 0 -1px 0 rgba(15, 23, 42, 0.06);
  transition: transform 0.12s ease, opacity 0.18s ease, box-shadow 0.15s ease;
}
.guest-chip:active {
  transform: scale(0.95);
}
.guest-chip.is-draggable {
  touch-action: none;
}
.guest-chip.is-status-1 {
  background: linear-gradient(180deg, #249e60 0%, #19824c 100%);
  color: #fff;
}
.guest-chip.is-status-2 {
  background: linear-gradient(180deg, #237bb2 0%, #165b88 100%);
  color: #fff;
}
.guest-chip.is-seated {
  background: #e6ebf2;
  color: #6b7688;
  opacity: 0.72;
  box-shadow: none;
}
.chip-sub-badge {
  font-size: 0.78em;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(15, 23, 42, 0.1);
  font-weight: 700;
}
.guest-chip.is-status-1 .chip-sub-badge,
.guest-chip.is-status-2 .chip-sub-badge {
  background: rgba(255, 255, 255, 0.24);
  color: #fff;
}
.guest-chip.is-selected-danger {
  background: #23272f !important;
  color: #fff !important;
  opacity: 1 !important;
  box-shadow: 0 0 0 2.5px var(--danger-main);
}
.guest-chip.is-picker-picked {
  box-shadow: 0 0 0 2.5px #111827, 0 4px 10px rgba(0, 0, 0, 0.18);
  transform: scale(0.96);
  opacity: 0.88;
}

.empty-placeholder {
  width: 100%;
  text-align: center;
  padding: 10px 4px;
  color: var(--ink-muted);
  font-size: calc(13.5px * var(--font-scale));
}

/* ================= 拖拽克隆浮层 ================= */
.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  margin: 0 !important;
  z-index: 9999 !important;
  pointer-events: none !important;
  opacity: 0.96;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.36) !important;
  will-change: transform;
  transition: none !important;
}
.is-drag-source {
  opacity: 0.28 !important;
}

/* ================= 底部丝滑毛玻璃抽屉 ================= */
.guest-sheet {
  position: absolute;
  inset: 0;
  z-index: 200;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(18px);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(15, 23, 42, 0.15);
  display: flex;
  flex-direction: column;
  transform: translate3d(0, calc(100% - var(--sheet-peek-h) - var(--safe-bottom)), 0);
  transition: transform 0.32s var(--ease-spring);
  will-change: transform;
}
.guest-sheet.is-Immediate {
  transition: none !important;
}

.sheet-handle {
  height: calc(var(--sheet-peek-h) + var(--safe-bottom));
  padding: 10px 12px var(--safe-bottom);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex-shrink: 0;
  touch-action: none;
}
.sheet-grabber {
  width: 38px;
  height: 4.5px;
  border-radius: 99px;
  background: #d3d9e2;
  margin: 0 auto 8px;
}
.toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
}
.tool-group {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.tool-btn {
  border: none;
  background: var(--surface-subtle);
  color: var(--ocean-main);
  font-size: calc(13.5px * var(--font-scale));
  font-weight: 700;
  padding: 8px 11px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.1s ease, background-color 0.15s ease;
}
.tool-btn:active {
  transform: scale(0.94);
  background: #e4e8ef;
}
.tool-btn.is-ocean { color: var(--ocean-deep); }
.tool-btn.is-danger { color: var(--danger-main); background: #fff1f2; }

.sheet-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.wait-counter {
  font-size: calc(14px * var(--font-scale));
  color: #555f70;
  font-weight: 600;
}
.wait-counter strong {
  color: var(--ocean-main);
  font-size: calc(16px * var(--font-scale));
}
.conn-dot {
  width: 8.5px;
  height: 8.5px;
  border-radius: 50%;
  background: #cbd5e1;
  transition: background-color 0.25s, box-shadow 0.25s;
}
.conn-dot.is-online {
  background: #22c55e;
  box-shadow: 0 0 7px rgba(34, 197, 94, 0.7);
}
.conn-dot.is-offline {
  background: var(--danger-main);
  box-shadow: 0 0 7px rgba(220, 53, 69, 0.6);
}
.icon-toggle {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #555f70;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px calc(var(--safe-bottom) + 20px);
  touch-action: pan-y;
}
.search-bar {
  position: relative;
  margin-bottom: 12px;
}
.search-input {
  width: 100%;
  padding: 9px 34px 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line-soft);
  background: var(--surface-subtle);
  font-size: calc(14px * var(--font-scale));
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
}
.search-input:focus {
  background: #fff;
  border-color: var(--ocean-main);
}
.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--ink-muted);
  padding: 4px 6px;
  cursor: pointer;
}
.sheet-footer {
  text-align: center;
  padding: 18px 0 8px;
  font-size: calc(12px * var(--font-scale));
  color: var(--ink-muted);
  cursor: pointer;
}

/* ================= 原生 <dialog> 弹窗与全屏视图 ================= */
dialog {
  border: none;
  padding: 0;
  background: transparent;
  color: inherit;
}
dialog::backdrop {
  background: rgba(15, 23, 42, 0.46);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  margin: auto;
  width: min(88vw, 340px);
  border-radius: 16px;
  overflow: visible;
}
.modal-card {
  background: #fff;
  border-radius: 16px;
  padding: 22px 20px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.28);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-card.is-picker {
  max-height: 76dvh;
}
.picker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.picker-scroll {
  overflow-y: auto;
  padding: 4px 2px;
  max-height: 50dvh;
}
.modal-title {
  margin: 0;
  font-size: calc(16.5px * var(--font-scale));
  font-weight: 800;
  text-align: center;
}
.picker-head .modal-title {
  text-align: left;
}
.modal-desc {
  margin: 0;
  font-size: calc(14px * var(--font-scale));
  color: #555f70;
  text-align: center;
  line-height: 1.5;
  white-space: pre-line;
}
.modal-input {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid #d5dbe4;
  border-radius: 10px;
  font-size: calc(16px * var(--font-scale));
  outline: none;
}
.modal-input:focus {
  border-color: var(--ocean-main);
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.modal-btn {
  flex: 1;
  padding: 11px 14px;
  border: none;
  border-radius: 10px;
  font-size: calc(15px * var(--font-scale));
  font-weight: 700;
  cursor: pointer;
}
.modal-btn.is-compact {
  flex: none;
  padding: 7px 14px;
  font-size: calc(13.5px * var(--font-scale));
}
.modal-btn.is-full {
  width: 100%;
  flex: none;
}
.modal-btn.is-muted {
  background: var(--surface-subtle);
  color: #4b5565;
}
.modal-btn.is-primary {
  background: var(--ocean-main);
  color: #fff;
}
.modal-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px;
}
.slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--ocean-main);
}
.slider-mark-sm { font-size: 13px; color: var(--ink-muted); font-weight: 700; }
.slider-mark-lg { font-size: 21px; color: var(--ink-primary); font-weight: 800; }
.font-preview-wrap {
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

/* 全屏统计与记录页 */
.fullscreen-dialog {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
}
.sheet-page {
  width: 100%;
  max-width: 500px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg-canvas);
  display: flex;
  flex-direction: column;
}
.page-topbar {
  background: #fff;
  padding: calc(var(--safe-top) + 14px) 16px 14px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}
.page-topbar.is-split {
  justify-content: space-between;
}
.page-heading {
  margin: 0;
  font-size: calc(17px * var(--font-scale));
  font-weight: 800;
}
.summary-trigger {
  border: none;
  background: transparent;
  color: var(--ocean-main);
  font-size: calc(17.5px * var(--font-scale));
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.summary-chevron {
  opacity: 0.65;
  font-size: 1.1em;
}
.page-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}
.page-bottombar {
  background: #fff;
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.05);
  position: relative;
  flex-shrink: 0;
}
.longpress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--danger-main);
}
.longpress-bar.is-charging {
  width: 100%;
  transition: width 5s linear;
}
.bottom-back-btn {
  width: 100%;
  padding: 15px;
  border: none;
  background: #fff;
  color: var(--ocean-main);
  font-size: calc(16px * var(--font-scale));
  font-weight: 800;
  cursor: pointer;
}

/* 历史流水卡片与快照卡片 */
.day-card, .stat-card, .snap-card {
  background: #fff;
  border-radius: 13px;
  padding: 14px 15px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}
.day-title {
  font-size: calc(17px * var(--font-scale));
  font-weight: 800;
  color: var(--ocean-main);
  margin-bottom: 10px;
}
.slot-heading {
  font-size: calc(14.5px * var(--font-scale));
  font-weight: 700;
  color: #374151;
  margin: 12px 0 8px;
}
.hist-row {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border-radius: 8px;
  margin-bottom: 7px;
  color: #fff;
  font-size: calc(14.5px * var(--font-scale));
}
.hist-row.is-1 { background: #23864f; }
.hist-row.is-10 { background: #145075; }
.hist-row.is-wait { background: #e5e9f0; color: var(--ink-primary); }
.hist-tname { font-weight: 800; white-space: nowrap; }
.hist-sep { margin: 0 10px; opacity: 0.45; }
.hist-names { flex: 1; line-height: 1.4; }

.stat-card {
  font-size: calc(16px * var(--font-scale));
  font-weight: 800;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.stat-detail {
  font-weight: 600;
  color: #4b5565;
  font-size: 0.92em;
}

.snap-card {
  border-left: 4px solid #cbd5e1;
}
.snap-card.is-active {
  border-left-color: #16a34a;
}
.snap-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.snap-title {
  font-size: calc(15.5px * var(--font-scale));
  font-weight: 800;
}
.snap-time {
  font-size: 12px;
  color: var(--ink-muted);
}
.snap-notes {
  margin: 0 0 10px;
  font-size: calc(13.5px * var(--font-scale));
  color: #555f70;
  line-height: 1.5;
}
.snap-foot {
  display: flex;
  justify-content: flex-end;
}
.snap-active-pill {
  background: #dcfce7;
  color: #15803d;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
}
.snap-rollback-btn {
  border: 1.5px solid var(--ocean-main);
  background: #fff;
  color: var(--ocean-main);
  border-radius: 7px;
  padding: 5px 12px;
  font-size: calc(12.5px * var(--font-scale));
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 380px) {
  .board-scroll { padding-left: 10px; padding-right: 10px; }
  .tool-btn { padding: 7px 8px; font-size: calc(12.5px * var(--font-scale)); }
  .table-rail { width: 78px; }
}
