/* 春和茶水攤 營運後台 ─ 三欄式：左選單／中內容／右詳細資訊 */
:root {
  /* 中性色：暖白紙感 */
  --bg: #f3f1ea; --surface: #ffffff; --surface-2: #faf8f3; --ink: #1e2a25; --muted: #6b7570; --line: #e6e2d8;
  /* 主色：茶綠；輔色：奶茶琥珀、天藍、紫、玫瑰、薄荷 */
  --primary: #2f6b57; --primary-dark: #1d4a3d; --primary-soft: #e3f0ea;
  --amber: #c27a23; --amber-soft: #fbefdc;
  --sky: #2f7db5; --sky-soft: #e2eff9;
  --violet: #6b58c0; --violet-soft: #ece8fa;
  --rose: #c8486a; --rose-soft: #fbe5ec;
  --mint: #23957a; --mint-soft: #ddf3ec;
  --ok: #23875f; --ok-soft: #e1f3ea; --warn: #9a6200; --warn-soft: #fdf2d9; --danger: #b8334f; --danger-soft: #fbe4ea;
  --radius: 14px; --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(30, 42, 37, .05), 0 6px 20px rgba(30, 42, 37, .06);
  /* 左欄選單 */
  --side-bg: linear-gradient(175deg, #163a30 0%, #1f4c40 55%, #27594a 100%);
  --side-ink: #dcebe4; --side-strong: #ffffff; --side-muted: #8dbcaa; --side-icon: #9fd0bd;
  --side-hover: rgba(255,255,255,.08); --side-active: rgba(255,255,255,.14); --side-accent: #f0b75f; --side-accent-icon: #f6c97f;
  --side-line: rgba(255,255,255,.12); --avatar-bg: #cfe9de; --avatar-ink: #1d4a3d;
  /* 其他表面 */
  --row-hover: #fbf7ee; --track: #eeebe3; --glass: rgba(250,248,243,.92); --field: #ffffff; --chip-off: #ececec; --chip-off-ink: #666;
  --heading-font: inherit;
  /* 圖表配色（依序使用） */
  --chart-palette: #2f6b57,#c27a23,#2f7db5,#6b58c0,#c8486a,#23957a,#e0a458,#5b8fd1,#9a7fd9,#e27d97,#7fb89e,#8c6d3f;
  --side-w: 236px; --detail-w: 348px;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55; }
a { color: var(--primary); }
h1 { font-size: 23px; margin: 0 0 4px; letter-spacing: .01em; font-family: var(--heading-font); }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ───────── 三欄版面 ───────── */
/* 三欄各自獨立捲動：整頁不捲，左選單、中內容、右明細各捲各的，互不連動 */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr) var(--detail-w); height: 100vh; height: 100dvh; overflow: hidden; }
.main { padding: 26px 30px 56px; min-width: 0; height: 100%; overflow-y: auto; overscroll-behavior: contain; }

/* 左欄 */
.sidebar { position: relative; height: 100%; min-height: 0; display: flex; flex-direction: column; color: var(--side-ink);
  background: var(--side-bg); }
.brand { display: flex; align-items: center; gap: 11px; padding: 20px 18px 14px; }
.brand-logo { width: 40px; height: 40px; flex: none; filter: drop-shadow(0 3px 6px rgba(0,0,0,.25)); }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .05em; color: var(--side-strong); font-family: var(--heading-font); }
.brand-sub { font-size: 12px; color: var(--side-muted); }
.nav { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 12px 12px; }
/* 每個分類一個有框線的區塊；分類標題加大、加粗、左邊色條，一眼分得出段落 */
.sidebar { border-right: 1px solid var(--side-line); box-shadow: inset -1px 0 0 rgba(255,255,255,.04); }
.nav-section { margin: 10px 0 0; padding: 4px 6px 6px; border: 1px solid var(--side-line); border-radius: 12px;
  background: rgba(255,255,255,.035); }
.nav-group { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; letter-spacing: .14em;
  color: var(--side-strong); padding: 9px 8px 7px; margin-bottom: 4px; border-bottom: 1px dashed var(--side-line); }
.nav-group::before { content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--side-accent); flex: none; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-ink); text-decoration: none; padding: 8px 10px; border-radius: 10px;
  font-size: 14px; position: relative; transition: background .15s, color .15s; }
.nav a .icon { color: var(--side-icon); }
.nav a:hover { background: var(--side-hover); color: var(--side-strong); }
.nav a.active { background: var(--side-active); color: var(--side-strong); font-weight: 600; }
.nav a.active::before { content: ""; position: absolute; left: -7px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--side-accent); }
.nav a.active .icon { color: var(--side-accent-icon); }
.me { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--side-line); font-size: 13px; }
.me-text { flex: 1; min-width: 0; line-height: 1.35; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: var(--avatar-ink); background: var(--avatar-bg); flex: none; }
.role { display: inline-block; font-size: 11px; padding: 0 7px; border-radius: 99px; margin-top: 2px; }
.role-owner { background: #f6d9a8; color: #6b4210; } .role-sysadmin { background: #d9d2fb; color: #3c2d86; }
.role-manager { background: #cde6f7; color: #1d5482; } .role-staff { background: #e5e5e5; color: #444; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 0; background: transparent; color: inherit; cursor: pointer; }
.icon-btn:hover { background: rgba(127,127,127,.15); }
.menu-toggle { display: none; margin-left: auto; color: var(--side-strong); }

/* 右欄 */
.detail { position: relative; height: 100%; overflow-y: auto; overscroll-behavior: contain; background: var(--surface-2); border-left: 1px solid var(--line); }
.detail-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 16px 18px;
  background: var(--glass); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.detail-title { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--primary-dark); }
.detail-close { color: var(--muted); }
.detail-body { padding: 16px 18px 40px; }
.detail-loading { color: var(--muted); padding: 30px 0; text-align: center; }
.detail-scrim { display: none; }

/* ───────── 中欄元件 ───────── */
.topbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; min-width: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid > .card { margin-bottom: 0; }

/* KPI 卡：色調 tone-* */
.kpi { position: relative; overflow: hidden; display: flex; gap: 14px; align-items: flex-start; }
.kpi-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.kpi-icon .icon { width: 22px; height: 22px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi { container-type: inline-size; }
.kpi > div:last-child { min-width: 0; }
/* 數字依卡片寬度縮放，三欄式右欄打開時「$163,405」也不會被切掉 */
.kpi .value { font-size: clamp(18px, 14cqi, 27px); font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.25; white-space: nowrap; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi > * { position: relative; z-index: 1; }
.kpi::after { content: ""; position: absolute; right: -34px; bottom: -34px; width: 86px; height: 86px; border-radius: 50%; opacity: .45; z-index: 0; }
.tone-green .kpi-icon, .tone-green::after { background: var(--primary-soft); color: var(--primary); }
.tone-amber .kpi-icon, .tone-amber::after { background: var(--amber-soft); color: var(--amber); }
.tone-sky .kpi-icon, .tone-sky::after { background: var(--sky-soft); color: var(--sky); }
.tone-violet .kpi-icon, .tone-violet::after { background: var(--violet-soft); color: var(--violet); }
.tone-rose .kpi-icon, .tone-rose::after { background: var(--rose-soft); color: var(--rose); }
.tone-mint .kpi-icon, .tone-mint::after { background: var(--mint-soft); color: var(--mint); }
/* 舊版 KPI（沒有圖示）也有色條 */
.grid-4 > .kpi:not([class*="tone-"]) { border-top: 3px solid var(--primary); }
.grid-4 > .kpi:not([class*="tone-"]):nth-child(2) { border-top-color: var(--amber); }
.grid-4 > .kpi:not([class*="tone-"]):nth-child(3) { border-top-color: var(--sky); }
.grid-4 > .kpi:not([class*="tone-"]):nth-child(4) { border-top-color: var(--violet); }

.live-bar { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin: -6px 0 10px; }
.live-bar .icon { width: 15px; height: 15px; }
.live-bar.off { color: var(--warn); }
.live-bar a { color: inherit; font-weight: 600; }
/* 手機：即時列縮成一行（只留綠點與台灣時間），不要折成三行 */
@media (max-width: 600px) {
  .live-bar { white-space: nowrap; overflow: hidden; }
  .live-bar.on .live-label, .live-bar.on .live-extra { display: none; }
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #2f9e6f; box-shadow: 0 0 0 0 rgba(47,158,111,.5); animation: live-pulse 2s infinite; }
@keyframes live-pulse { 70% { box-shadow: 0 0 0 6px rgba(47,158,111,0); } 100% { box-shadow: 0 0 0 0 rgba(47,158,111,0); } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.chart { width: 100%; height: 320px; }
.chart.chart-sm { height: 230px; }
.chart-pair { display: grid; gap: 6px; }
.chart-pair h3 { margin: 4px 0 0; font-size: 14px; color: var(--muted); font-weight: 600; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.chart-head h2 { margin: 0; }
.crumb { font-size: 13px; color: var(--muted); min-height: 20px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface-2); }
.seg button, .seg a { border: 0; background: transparent; padding: 5px 12px; font-size: 13px; cursor: pointer; color: var(--ink); text-decoration: none; font-family: inherit; }
.seg .on { background: var(--primary); color: #fff; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; background: var(--surface-2); letter-spacing: .02em; }
tbody tr:hover td { background: var(--row-hover); }
tr[data-detail] { cursor: pointer; }
tr[data-detail]:hover td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
tr.selected td { background: var(--amber-soft) !important; }
tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
tr.sub td { font-weight: 600; background: var(--surface-2); }
td.indent { padding-left: 28px; }
.table-wrap { overflow-x: auto; }
.click-hint { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.click-hint .icon { width: 14px; height: 14px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--field); color: var(--ink); padding: 8px 14px; border-radius: 10px;
  font-size: 14px; cursor: pointer; text-decoration: none; font-family: inherit; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #efc3cd; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-link { background: none; border: 0; color: var(--primary); text-decoration: underline; cursor: pointer; padding: 0; font: inherit; }

form.inline { display: inline; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
label { font-size: 13px; color: var(--muted); display: block; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=month], input[type=time], input[type=datetime-local], select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); color: var(--ink); min-width: 0; }
input:focus, select:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); }
.field { display: flex; flex-direction: column; gap: 4px; }
details summary { cursor: pointer; padding: 6px 0; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--mint-soft); color: var(--mint); white-space: nowrap; }
.badge.off { background: var(--chip-off); color: var(--chip-off-ink); }
.badge.draft { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--sky-soft); color: var(--sky); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.alert { padding: 11px 14px; border-radius: 11px; margin-bottom: 14px; font-size: 14px; border: 1px solid transparent; }
.alert.success { background: var(--ok-soft); color: var(--ok); border-color: #c4e6d4; }
.alert.error { background: var(--danger-soft); color: var(--danger); border-color: #f2c7d2; }
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: #f2dfae; }
.diff-new td { background: #eef8f2; } .diff-up td { background: #fff6e5; } .diff-err td { background: var(--danger-soft); }

/* ───────── 右欄內容（詳細資訊） ───────── */
.dp-hero { padding: 4px 0 14px; }
.dp-hero h3 { font-size: 20px; margin: 0 0 4px; }
.dp-hero .muted { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dp-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.dp-stat { border-radius: 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); }
.dp-stat .k { font-size: 12px; color: var(--muted); }
.dp-stat .v { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dp-stat.tone-green { background: var(--primary-soft); border-color: transparent; } .dp-stat.tone-green .v { color: var(--primary-dark); }
.dp-stat.tone-amber { background: var(--amber-soft); border-color: transparent; } .dp-stat.tone-amber .v { color: #8a5413; }
.dp-stat.tone-sky { background: var(--sky-soft); border-color: transparent; } .dp-stat.tone-sky .v { color: #1d5482; }
.dp-stat.tone-violet { background: var(--violet-soft); border-color: transparent; } .dp-stat.tone-violet .v { color: #45369a; }
.dp-stat.tone-rose { background: var(--rose-soft); border-color: transparent; } .dp-stat.tone-rose .v { color: #9b2a48; }
.dp-section { margin: 18px 0 8px; font-size: 12.5px; font-weight: 700; color: var(--muted); letter-spacing: .08em; display: flex; justify-content: space-between; align-items: center; }
.dp-list { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.dp-row { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.dp-row:last-child { border-bottom: 0; }
.dp-row .muted { font-size: 12px; }
.dp-alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; margin-bottom: 8px; font-size: 14px; }
.dp-alert .icon { margin-top: 2px; }
.dp-alert.warn { background: var(--warn-soft); color: var(--warn); }
.dp-alert.danger { background: var(--danger-soft); color: var(--danger); }
.dp-alert.ok { background: var(--ok-soft); color: var(--ok); }
.dp-alert a { color: inherit; font-weight: 600; }
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar { display: grid; grid-template-columns: 70px 1fr 54px; gap: 8px; align-items: center; font-size: 13px; }
.bar-track { height: 10px; border-radius: 99px; background: var(--track); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--primary); }
.bar:nth-child(5n+2) .bar-fill { background: var(--amber); } .bar:nth-child(5n+3) .bar-fill { background: var(--sky); }
.bar:nth-child(5n+4) .bar-fill { background: var(--violet); } .bar:nth-child(5n+5) .bar-fill { background: var(--rose); }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 70px; padding: 6px 2px 0; }
.spark span { flex: 1; background: linear-gradient(180deg, var(--sky), #7fb3da); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.spark span.today { background: linear-gradient(180deg, var(--amber), #e2ab64); }
.spark-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
/* 今日速覽：每小時杯數（每個小時都有刻度；滑鼠移到哪個時段就顯示那個時段的杯數） */
.hour-chart { display: flex; gap: 3px; height: 104px; padding-top: 26px; }
.hc-col { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; position: relative; cursor: default; outline: none; }
.hc-bar { display: block; min-height: 2px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, var(--sky), color-mix(in srgb, var(--sky) 55%, white)); }
.hc-label { display: block; text-align: center; font-size: 10.5px; line-height: 16px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hc-col:hover .hc-bar, .hc-col:focus .hc-bar { background: var(--primary); }
.hc-col:hover .hc-label, .hc-col:focus .hc-label { color: var(--ink); font-weight: 700; }
.hc-col::after { content: attr(data-tip); position: absolute; top: -26px; left: 0; white-space: nowrap; z-index: 3; pointer-events: none;
  font-size: 12px; font-weight: 600; color: #fff; background: var(--ink); padding: 2px 8px; border-radius: 6px; opacity: 0; transition: opacity .12s; }
.hc-col.r::after { left: auto; right: 0; }
.hc-col:hover::after, .hc-col:focus::after { opacity: 1; }

/* 三欄捲軸：平常隱藏，滑鼠移到該欄才淡淡出現 */
.nav, .main, .detail { scrollbar-width: thin; scrollbar-color: transparent transparent; }
.nav:hover, .main:hover, .detail:hover { scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
.nav { scrollbar-color: transparent transparent; }
.nav:hover { scrollbar-color: rgba(255,255,255,.28) transparent; }
.nav::-webkit-scrollbar, .main::-webkit-scrollbar, .detail::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-track, .main::-webkit-scrollbar-track, .detail::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb, .main::-webkit-scrollbar-thumb, .detail::-webkit-scrollbar-thumb { background: transparent; border-radius: 99px; }
.main:hover::-webkit-scrollbar-thumb, .detail:hover::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 45%, transparent); }
.nav:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,.28); }
.nav::-webkit-scrollbar-button, .main::-webkit-scrollbar-button, .detail::-webkit-scrollbar-button { display: none; }
.formula { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; }
.formula .dp-row { padding: 7px 0; }
.formula .dp-row.result { font-weight: 700; border-top: 2px solid var(--ink); }
pre.json { white-space: pre-wrap; word-break: break-all; font-size: 12.5px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 0; }
.dp-empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* ───────── 登入 ───────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(circle at 15% 15%, #f6dcb0 0, transparent 38%), radial-gradient(circle at 85% 80%, #bfe3d4 0, transparent 42%), var(--bg); }
.login-card { width: 100%; max-width: 370px; background: #fff; border-radius: 18px; box-shadow: 0 10px 40px rgba(30,42,37,.12); padding: 34px 30px; border: 1px solid var(--line); }
.login-card .brand-logo { display: block; margin: 0 auto 10px; width: 76px; height: 76px; filter: drop-shadow(0 6px 12px rgba(29,74,61,.18)); }
.login-card h1 { text-align: center; color: var(--primary-dark); }
.login-card p.sub { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.login-card .field { margin-bottom: 14px; }
.login-card input { width: 100%; padding: 11px 12px; }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; font-size: 16px; }

/* ───────── 響應式 ───────── */
@media (max-width: 1280px) {
  /* 右欄改為從右側滑出的抽屜 */
  .app { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .detail { position: fixed; right: 0; top: 0; bottom: 0; width: min(var(--detail-w), 92vw); z-index: 30; transform: translateX(105%);
    transition: transform .22s ease; box-shadow: -10px 0 30px rgba(0,0,0,.12); }
  .app.detail-open .detail { transform: none; }
  .app.detail-open .detail-scrim { display: block; position: fixed; inset: 0; background: rgba(20,30,26,.3); z-index: 25; }
}
@media (max-width: 900px) {
  /* 手機：改回整頁捲動 */
  .app { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .main { height: auto; overflow: visible; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .brand { padding: 12px 16px; }
  .sidebar .nav, .sidebar .me { display: none; }
  .sidebar.open .nav, .sidebar.open .me { display: flex; }
  .sidebar.open .nav { display: block; }
  .menu-toggle { display: inline-grid; }
  .main { padding: 16px; }
  .kpi { flex-direction: column; gap: 8px; }
  .kpi .value { font-size: 22px; }
  .detail { width: 100vw; }
}

@media print {
  .app { height: auto; overflow: visible; display: block; }
  .main { height: auto; overflow: visible; }
  .sidebar, .detail, .detail-scrim, .no-print, .topbar form { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; }
}


/* ═════════ 主題（系統設定 → 外觀主題）═════════
   dawn 晨曦金茶園（預設，見最上方 :root）／matcha 抹茶清新／night 夜茶墨金／retro 台式茶行復古／milktea 奶茶粉彩 */

/* ② 抹茶清新：大量留白、淺色選單、抹茶綠點綴 */
[data-ui-theme="matcha"] {
  --bg: #f6f8f4; --surface: #ffffff; --surface-2: #fbfcf9; --ink: #2b2f2a; --muted: #6f776d; --line: #e3e9dc;
  --primary: #5f8f34; --primary-dark: #3e6b2a; --primary-soft: #eaf2e0;
  --amber: #c08a2b; --amber-soft: #f8f0dc; --sky: #4a8bb8; --sky-soft: #e5f0f7; --violet: #7c6cc4; --violet-soft: #efedf9;
  --rose: #cc5c78; --rose-soft: #fbe9ee; --mint: #3f9c7f; --mint-soft: #e2f3ec;
  --side-bg: #eef3e8; --side-ink: #3a4436; --side-strong: #24301f; --side-muted: #7f8c78; --side-icon: #6a9a3b;
  --side-hover: rgba(95,143,52,.10); --side-active: #ffffff; --side-accent: #6a9a3b; --side-accent-icon: #5f8f34;
  --side-line: #dde6d4; --avatar-bg: #dbe9cc; --avatar-ink: #3e6b2a;
  --row-hover: #f4f8ef; --track: #edf1e8; --glass: rgba(251,252,249,.92);
  --shadow: 0 1px 2px rgba(43,47,42,.04), 0 4px 14px rgba(43,47,42,.04);
  --chart-palette: #6a9a3b,#c08a2b,#4a8bb8,#7c6cc4,#cc5c78,#3f9c7f,#a8c97f,#e0b45c,#8fb8d6,#b3a8e0,#e69aae,#7fbfa8;
}
[data-ui-theme="matcha"] .nav a.active { box-shadow: 0 1px 3px rgba(43,47,42,.08); }
[data-ui-theme="matcha"] .card { box-shadow: none; }

/* ③ 夜茶墨金：深色模式，晚班不刺眼 */
[data-ui-theme="night"] {
  color-scheme: dark;
  --bg: #101915; --surface: #18241f; --surface-2: #142019; --ink: #e8eee9; --muted: #93a39b; --line: #2a3a33;
  --primary: #4fb38a; --primary-dark: #8fd6b6; --primary-soft: #1d3a2f;
  --amber: #d9a441; --amber-soft: #3a2f1a; --sky: #6fb2e3; --sky-soft: #1b2e3c; --violet: #a796f0; --violet-soft: #2a2540;
  --rose: #e06b86; --rose-soft: #3d2029; --mint: #5cc7a4; --mint-soft: #193a30;
  --ok: #5cc79a; --ok-soft: #173327; --warn: #e3b45a; --warn-soft: #3a2f17; --danger: #ef7d95; --danger-soft: #3d1f27;
  --side-bg: linear-gradient(175deg, #0b120f 0%, #111c17 100%); --side-ink: #c9d6cf; --side-strong: #f4efe2; --side-muted: #7d8f86;
  --side-icon: #8aa99b; --side-hover: rgba(217,164,65,.08); --side-active: rgba(217,164,65,.14); --side-accent: #d9a441; --side-accent-icon: #e8bb63;
  --side-line: #1f2c26; --avatar-bg: #2a3a33; --avatar-ink: #e8bb63;
  --row-hover: #1d2b25; --track: #24332c; --glass: rgba(20,32,25,.92); --field: #142019; --chip-off: #2a3a33; --chip-off-ink: #b8c4bd;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  --chart-palette: #4fb38a,#d9a441,#6fb2e3,#a796f0,#e06b86,#5cc7a4,#e8c27a,#9cc8ec,#c3b8f5,#f0a0b2,#8fd6b6,#b9915a;
}
[data-ui-theme="night"] .kpi .value, [data-ui-theme="night"] .dp-stat .v { color: #f1d391; }

/* ④ 台式茶行復古：米紙底、紅磚、靛藍選單、標題用明體 */
[data-ui-theme="retro"] {
  --bg: #f4ebdd; --surface: #fffaf1; --surface-2: #fbf3e6; --ink: #2e2420; --muted: #7a6a5f; --line: #e6d8c3;
  --primary: #b3402e; --primary-dark: #7f2a1e; --primary-soft: #f7e1da;
  --amber: #c98b1f; --amber-soft: #f8ebcf; --sky: #24406b; --sky-soft: #e1e7f1; --violet: #6b4f8c; --violet-soft: #ece4f3;
  --rose: #b3402e; --rose-soft: #f7e1da; --mint: #3f7f6a; --mint-soft: #e0efe9;
  --side-bg: linear-gradient(175deg, #1a2d4b 0%, #1f3557 60%, #26406a 100%); --side-ink: #dfe4ee; --side-strong: #fff8ea;
  --side-muted: #9fb0cc; --side-icon: #c3cee2; --side-accent: #d49a2a; --side-accent-icon: #e8b450;
  --side-line: rgba(255,248,234,.14); --avatar-bg: #f4e3c3; --avatar-ink: #7f2a1e;
  --row-hover: #f8eedd; --track: #eadfcd; --glass: rgba(251,243,230,.94); --field: #fffaf1;
  --heading-font: "Noto Serif TC", "Songti TC", "PMingLiU", "MingLiU", serif;
  --radius: 10px; --radius-sm: 6px;
  --chart-palette: #b3402e,#24406b,#d49a2a,#3f7f6a,#6b4f8c,#8a5a3c,#d9735f,#5a77a6,#e6be6a,#74a896,#9a80b8,#b58a6a;
}
[data-ui-theme="retro"] h2 { font-family: var(--heading-font); }
[data-ui-theme="retro"] .card { border-top: 3px solid var(--primary); }

/* ⑤ 奶茶粉彩（目前預設）：奶茶米底、焦糖選單、粉彩底色；文字一律加深，對比 ≥ 4.5:1 */
[data-ui-theme="milktea"] {
  --bg: #f8f1ea; --surface: #ffffff; --surface-2: #fdf8f3; --ink: #2a1d16; --muted: #65503f; --line: #eaddd0;
  --primary: #94592a; --primary-dark: #6b4428; --primary-soft: #f6e8da;
  --amber: #8f6236; --amber-soft: #f7ece1; --sky: #2b6f9e; --sky-soft: #e4f1fa; --violet: #6a50a8; --violet-soft: #f0ebfa;
  --rose: #b0465f; --rose-soft: #fbe8ed; --mint: #287a5d; --mint-soft: #e5f5ee;
  --ok: #287a5d; --ok-soft: #e5f5ee; --warn: #8a5600; --warn-soft: #fbefd8; --danger: #a8364f; --danger-soft: #fbe6ec;
  --side-bg: linear-gradient(175deg, #5e3a21 0%, #6b4428 60%, #774b2b 100%); --side-ink: #fbf1e7; --side-strong: #ffffff;
  --side-muted: #e9d3be; --side-icon: #f6cfd7; --side-hover: rgba(255,255,255,.10); --side-active: rgba(255,255,255,.18);
  --side-accent: #f6cfd7; --side-accent-icon: #ffd9e0; --avatar-bg: #f6cfd7; --avatar-ink: #5e3a21;
  --row-hover: #fcf4ec; --track: #f0e4d8; --glass: rgba(253,248,243,.95);
  --radius: 20px; --radius-sm: 14px;
  --chart-palette: #a0652f,#3f86b8,#c85d78,#7e66b8,#3e9a78,#b8862f,#d08a9c,#7aaed4,#a493d6,#78bfa0,#d9a46c,#8c5a3a;
}
[data-ui-theme="milktea"] .muted, [data-ui-theme="milktea"] .kpi .label, [data-ui-theme="milktea"] .live-bar { font-weight: 500; }
[data-ui-theme="milktea"] .nav a { font-weight: 500; }
[data-ui-theme="milktea"] th { color: var(--muted); }
