/* 憑證系統小助理 — design tokens
   Layout: phone = single column + bottom tab bar with a center camera button;
           desktop (>= 900px) = left sidebar + content; document review = image left, fields right. */
:root {
  --paper: #F3F5F9;
  --surface: #FFFFFF;
  --sunken: #E9EEF5;
  --ink: #16233A;
  --muted: #5A6679;
  --line: #D8DFE9;
  --navy: #1F3A68;
  --navy-ink: #FFFFFF;
  --navy-soft: #E4EAF5;
  --gold: #A87A22;
  --ok: #1E7F4F;
  --ok-soft: #E2F3EA;
  --warn: #A86A10;
  --warn-soft: #FBF0DC;
  --bad: #B42318;
  --bad-soft: #FCE6E3;
  --receipt: #FFFFFF;
  --shadow: 0 1px 2px rgba(22,35,58,.06), 0 10px 30px rgba(22,35,58,.08);
  --fog: 55%;
  --f-display: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --f-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --radius: 12px;
  --tabbar-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0C1220; --surface: #131B2C; --sunken: #1A2438; --ink: #E5EAF3; --muted: #95A1B5; --line: #26324A;
    --navy: #82A8E4; --navy-ink: #0B1730; --navy-soft: #172743; --gold: #E0B455;
    --ok: #4CC38A; --ok-soft: #12301F; --warn: #E3A64A; --warn-soft: #33270F; --bad: #F0705F; --bad-soft: #3A1714;
    --receipt: #F7F7F4; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0C1220; --surface: #131B2C; --sunken: #1A2438; --ink: #E5EAF3; --muted: #95A1B5; --line: #26324A;
  --navy: #82A8E4; --navy-ink: #0B1730; --navy-soft: #172743; --gold: #E0B455;
  --ok: #4CC38A; --ok-soft: #12301F; --warn: #E3A64A; --warn-soft: #33270F; --bad: #F0705F; --bad-soft: #3A1714;
  --receipt: #F7F7F4; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--f-body); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.35; text-wrap: balance; }
p { margin: 0; }
.num, .mono { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Background photo ---------- */
#bg { position: fixed; inset: 0; z-index: -1; background-size: cover; background-position: center; display: none; }
#bg::after { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--paper) var(--fog), transparent); backdrop-filter: blur(3px); }
body.has-bg #bg { display: block; }
body.has-bg { background: var(--paper); }
body.has-bg .card, body.has-bg .list, body.has-bg .tabbar, body.has-bg .sidebar, body.has-bg .panel {
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 14.5px; white-space: nowrap; transition: transform .08s, background .15s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--navy); color: var(--navy-ink); border-color: var(--navy); }
.btn.danger { color: var(--bad); }
.btn.warn { background: var(--warn); color: #fff; border-color: var(--warn); }
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); display: inline-grid; place-items: center; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.input, select.input { height: 42px; width: 100%; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 0 12px; font-size: 15px; min-width: 0; }
.input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-soft); }
.input.flag { border-color: var(--bad); background: var(--bad-soft); }
.input.num { text-align: right; font-family: var(--f-num); }
.hint { font-size: 12.5px; color: var(--muted); }
.error-text { font-size: 13px; color: var(--bad); font-weight: 500; }
.ok-text { font-size: 13px; color: var(--ok); font-weight: 500; background: var(--ok-soft); border-radius: 9px; padding: 10px 12px; line-height: 1.6; }
.link-btn { align-self: flex-start; border: 0; background: none; color: var(--navy); padding: 0; height: auto; }

/* ---------- Chips, dots, pills ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--sunken); color: var(--muted); font-weight: 500; white-space: nowrap; }
.chip.navy { background: var(--navy-soft); color: var(--navy); font-weight: 700; }
.chip.demo { background: var(--warn-soft); color: var(--warn); font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); } .dot.none { background: var(--line); }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.pill.posted { background: var(--ok-soft); color: var(--ok); }
.pill.review { background: var(--warn-soft); color: var(--warn); }
.pill.processing { background: var(--navy-soft); color: var(--navy); }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; grid-template-columns: 1fr; }
.login-brand { display: none; }
.login-main { display: flex; align-items: center; justify-content: center; padding: max(28px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
/* Brand mark = the app icon; the 憑 text stays for screen readers only. */
.mark { width: 54px; height: 54px; border-radius: 13px; background: url("icons/icon-192.png?v=2") center / cover; color: transparent; font-size: 0; flex: none; box-shadow: 0 2px 8px rgba(11,22,44,.25); }
.mark.sm { width: 32px; height: 32px; border-radius: 8px; }
.login-card h1 { font-family: var(--f-display); font-size: 28px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--sunken); border-radius: 10px; padding: 4px; }
.tabs button { border: 0; background: transparent; height: 36px; border-radius: 7px; font-weight: 700; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.g-dot { width: 16px; height: 16px; border-radius: 50%; background: conic-gradient(#EA4335 0 25%, #FBBC05 0 50%, #34A853 0 75%, #4285F4 0); }
.trial-note { font-size: 12.5px; color: var(--muted); background: var(--sunken); border-radius: 9px; padding: 10px 12px; line-height: 1.6; }
@media (min-width: 900px) {
  .login { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .login-brand { display: flex; flex-direction: column; justify-content: space-between; padding: 48px; background: linear-gradient(160deg, #1F3A68, #142849); color: #fff; position: relative; overflow: hidden; }
  .login-brand::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, transparent 0 31px, rgba(255,255,255,.06) 31px 32px); }
  .login-brand > * { position: relative; }
  .login-brand h2 { font-family: var(--f-display); font-size: 36px; max-width: 12em; }
  .login-brand ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; font-size: 15px; opacity: .92; }
  .login-brand li { display: flex; gap: 10px; align-items: center; }
  .login-brand li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #E0B455; }
}

/* ---------- App shell ---------- */
.shell { min-height: 100%; display: flex; flex-direction: column; }
.sidebar { display: none; }
.content { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--f-display); font-size: 24px; }
.page-head .sub { font-size: 13px; color: var(--muted); }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0 max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left)); background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; padding: 6px 0; position: relative; }
.tabbar a.on { color: var(--navy); font-weight: 700; }
.tabbar .badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 17px; height: 17px; border-radius: 9px; background: var(--warn); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; font-family: var(--f-num); }
.cam-btn { justify-self: center; width: 58px; height: 58px; margin-top: -26px; border-radius: 50%; border: 4px solid var(--paper); background: var(--navy); color: var(--navy-ink); display: grid; place-items: center; box-shadow: 0 8px 20px rgba(31,58,104,.35); }
.cam-btn svg.i { width: 26px; height: 26px; }
@media (min-width: 900px) {
  .shell { flex-direction: row; }
  .tabbar { display: none; }
  .sidebar { display: flex; flex-direction: column; gap: 4px; width: 228px; flex: none; position: sticky; top: 0; height: 100vh; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line); }
  .sidebar .brand { display: flex; align-items: center; gap: 10px; font-family: var(--f-display); font-weight: 700; font-size: 16px; padding: 0 6px 18px; line-height: 1.3; }
  .sidebar .upload { margin-bottom: 12px; }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; }
  .sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
  .sidebar nav a.on { background: var(--navy-soft); color: var(--navy); font-weight: 700; }
  .sidebar nav a .n { margin-left: auto; font-family: var(--f-num); font-size: 12px; font-weight: 600; background: var(--warn-soft); color: var(--warn); padding: 0 7px; border-radius: 999px; }
  .sidebar .foot { margin-top: auto; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding: 12px 6px 0; display: flex; flex-direction: column; gap: 6px; }
  .content { padding: 28px 32px 48px; }
}

/* ---------- Cards & lists ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h2 { font-size: 15px; font-weight: 700; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.card-head a { font-size: 13px; color: var(--navy); text-decoration: none; font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); } }

.hero { background: linear-gradient(135deg, #1F3A68, #172C52); color: #fff; border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, transparent 0 27px, rgba(255,255,255,.06) 27px 28px); pointer-events: none; }
.hero small { opacity: .82; font-size: 13px; }
.hero .big { font-family: var(--f-num); font-size: clamp(30px, 7vw, 40px); font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
.hero .stats { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 10px; font-size: 12.5px; opacity: .92; }
.hero .stats b { display: block; font-family: var(--f-num); font-size: 18px; font-weight: 600; }
.period-chip { align-self: flex-start; font-size: 12px; font-weight: 700; background: rgba(255,255,255,.16); padding: 2px 10px; border-radius: 999px; }

.alert-row { display: flex; align-items: center; gap: 10px; border-radius: 12px; padding: 12px 16px; background: var(--warn-soft); color: var(--warn); font-weight: 700; text-decoration: none; }
.alert-row span:last-child { margin-left: auto; }
.alert-row.okay { background: var(--ok-soft); color: var(--ok); }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.row:first-child { border-top: 0; }
.row:hover { background: var(--sunken); }
.row .title { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amt { font-family: var(--f-num); font-weight: 500; text-align: right; }
.row .amt small { display: block; font-size: 11.5px; color: var(--muted); font-family: var(--f-body); font-weight: 400; }
.row.processing .dot { background: var(--navy); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.empty { padding: 36px 20px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; color: var(--muted); }
.empty b { color: var(--ink); font-size: 16px; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) 88px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .track { height: 10px; border-radius: 5px; background: var(--sunken); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 5px; background: var(--navy); }
.bar-row .v { text-align: right; font-family: var(--f-num); font-size: 12.5px; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters .input { width: auto; height: 38px; font-size: 14px; }
.filters .search { flex: 1 1 220px; position: relative; }
.filters .search .input { width: 100%; padding-left: 36px; }
.filters .search svg { position: absolute; left: 10px; top: 9px; color: var(--muted); }
.seg { display: inline-flex; background: var(--sunken); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: transparent; height: 32px; padding: 0 12px; border-radius: 7px; font-size: 13.5px; font-weight: 500; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.summary-line { font-size: 13px; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }
.summary-line b { color: var(--ink); font-family: var(--f-num); }

/* ---------- Document review ---------- */
.doc { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 1000px) { .doc { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; } .doc .viewer { position: sticky; top: 20px; } }
.viewer { background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.viewer-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--surface); }
.viewer-bar .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-stage { height: min(68vh, 640px); overflow: auto; display: grid; place-items: center; background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 14px 14px; position: relative; }
.viewer-stage img { max-width: 92%; max-height: 92%; box-shadow: 0 4px 20px rgba(0,0,0,.18); transform-origin: center; transition: transform .15s; }
.viewer-stage.zoomed { place-items: start; }
.viewer-stage.zoomed img { max-width: none; max-height: none; }
.scanline { position: absolute; left: 0; right: 0; height: 3px; background: var(--navy); box-shadow: 0 0 16px 4px var(--navy); animation: scan 2.2s ease-in-out infinite; }
@keyframes scan { 0%, 100% { top: 8%; } 50% { top: 90%; } }
@media (prefers-reduced-motion: reduce) { .scanline, .row.processing .dot { animation: none; } .scanline { top: 50%; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; }
.panel-head { padding: 16px 18px 12px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.panel-head .top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel-head h2 { font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.form { padding: 12px 18px; display: flex; flex-direction: column; gap: 10px; }
.frow { display: grid; grid-template-columns: 84px minmax(0, 1fr) 12px; gap: 10px; align-items: center; }
.frow > label { font-size: 13px; color: var(--muted); }
.frow .input { height: 38px; font-size: 14.5px; }
.frow.total .input { font-weight: 700; }
.issues { padding: 0 18px 12px; display: flex; flex-direction: column; gap: 8px; }
.issue { border-radius: 9px; padding: 9px 12px; font-size: 13px; line-height: 1.55; background: var(--bad-soft); color: var(--bad); }
.issue b { display: block; font-size: 13.5px; }
.issue.warn { background: var(--warn-soft); color: var(--warn); }
.allgood { position: relative; margin: 0 18px 12px; border-radius: 10px; padding: 12px 14px; background: var(--ok-soft); color: var(--ok); font-size: 13px; font-weight: 500; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; padding-right: 72px; }
.allgood div::before { content: "✓ "; font-weight: 700; }
.stamp { position: absolute; right: 12px; top: 50%; translate: 0 -50%; rotate: -12deg; width: 52px; height: 52px; border: 2.5px solid var(--gold); border-radius: 7px; color: var(--gold); font-family: var(--f-display); font-weight: 700; font-size: 17px; display: grid; place-items: center; }
.stamp.pop { animation: stamp .35s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes stamp { from { scale: 1.8; opacity: 0; } to { scale: 1; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .stamp.pop { animation: none; } }
.items-tbl { margin: 0 18px 12px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; font-size: 13px; }
.items-tbl div { display: grid; grid-template-columns: minmax(0, 1fr) 52px 76px; gap: 8px; padding: 6px 10px; border-top: 1px solid var(--line); }
.items-tbl div:first-child { border-top: 0; background: var(--sunken); color: var(--muted); font-size: 12px; }
.items-tbl span:not(:first-child) { text-align: right; font-family: var(--f-num); }
.panel-foot { display: flex; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.panel-foot .btn.primary, .panel-foot .btn.warn { flex: 1; }
.confirm-note { width: 100%; font-size: 13px; color: var(--warn); font-weight: 500; }

/* ---------- Settings ---------- */
.settings { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .settings { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.card .stack { display: flex; flex-direction: column; gap: 14px; }
.card .desc { font-size: 13px; color: var(--muted); margin-top: -6px; }
.bg-preview { height: 140px; border-radius: 10px; border: 1px solid var(--line); background: var(--sunken) center/cover; position: relative; overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.bg-preview::after { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--paper) var(--fog), transparent); }
.bg-preview span { position: relative; z-index: 1; background: color-mix(in srgb, var(--surface) 85%, transparent); padding: 4px 12px; border-radius: 999px; color: var(--ink); font-weight: 500; }
.range-row { display: grid; grid-template-columns: minmax(0, 1fr) 52px; gap: 12px; align-items: center; }
.range-row input { width: 100%; accent-color: var(--navy); }
.range-row output { font-family: var(--f-num); text-align: right; font-size: 14px; }
.cat-list { display: flex; flex-wrap: wrap; gap: 8px; }
.cat { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--navy-soft); color: var(--navy); font-size: 13.5px; font-weight: 500; }
.cat button { border: 0; background: transparent; color: inherit; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; line-height: 1; }
.cat button:hover { background: rgba(0,0,0,.08); }
.inline { display: flex; gap: 8px; }
.inline .input { flex: 1; }

/* ---------- Export ---------- */
.export-opts { display: flex; flex-direction: column; gap: 14px; }
.export-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.preview-tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.preview-tbl table { border-collapse: collapse; width: 100%; min-width: 640px; font-size: 13px; }
.preview-tbl th, .preview-tbl td { padding: 8px 12px; border-top: 1px solid var(--line); text-align: left; white-space: nowrap; }
.preview-tbl th { border-top: 0; background: var(--sunken); color: var(--muted); font-weight: 700; font-size: 12px; }
.preview-tbl td.n { text-align: right; font-family: var(--f-num); }
.preview-tbl tfoot td { font-weight: 700; background: var(--sunken); }

/* ---------- Banner, sheet, drop, toast ---------- */
.banner { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.6; padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); }
.banner b { font-weight: 700; }
.sheet-back { position: fixed; inset: 0; z-index: 40; background: rgba(8,14,26,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 480px; background: var(--surface); border-radius: 18px 18px 0 0; padding: 18px max(18px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 10px; }
.sheet h2 { font-size: 16px; margin-bottom: 4px; }
.sheet .btn { justify-content: flex-start; height: 52px; cursor: pointer; }
.inapp-note { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.6; padding: 12px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-weight: 500; }
.sheet .inapp-note .btn, .login-card .inapp-note .btn { height: 38px; justify-content: center; }
.drop { position: fixed; inset: 0; z-index: 50; background: color-mix(in srgb, var(--navy) 18%, transparent); display: none; place-items: center; pointer-events: none; }
.drop div { background: var(--surface); border: 2px dashed var(--navy); border-radius: 16px; padding: 28px 36px; font-weight: 700; color: var(--navy); font-size: 17px; }
body.dragging .drop { display: grid; }
#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); translate: -50% 0; z-index: 60; background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; }
@media (min-width: 900px) { #toast { bottom: 28px; } }
