/* 蝦貨通 ShrimpFlow — 蝦紅 × 海洋藍主題, mobile-first PWA
   [claude code] 2026-08-10 建檔
   [claude code] 2026-08-11 v1.2 長輩友善改版:
     🔴 字級系統 —— 全站字體改用 rem, html 的 font-size = 16px × var(--sc),
        --sc 由 <html data-fs="norm|big|xl"> 決定 (預設 big)。改一個變數整個 App 跟著放大,
        包含按鈕高度 / 圖示 / 間距, 不會只有字變大版面卻擠在一起。
     其餘:提高文字對比 (--muted 加深)、按鈕最小高度 ~3rem 好按、清單列加大、圖示放大。
   配色慣例:台灣紅賺綠賠 —— 收入與正淨額用紅, 負數用綠, 成本用中性灰藍 */

:root {
  --sc: 1.14;        /* 字級倍率 (預設 = 大);下面依 data-fs 覆寫 */
  --shrimp: #ff6b35;
  --shrimp-d: #d94a12;
  --shrimp-l: #fff1e9;
  --ocean: #0e7490;
  --ocean-l: #ecfeff;
  --ink: #0f172a;
  --muted: #475569;  /* 比原本的 #64748b 深, 長輩看得清楚 */
  --line: #d8dee7;
  --bg1: #fff7ed;
  --bg2: #ecfeff;
  --card: #ffffff;
  --gain: #dc2626;   /* 紅 = 賺 / 收入 (台灣慣例) */
  --gain-l: #fef2f2;
  --loss: #047857;   /* 綠 = 賠 / 負數 */
  --loss-l: #ecfdf5;
  --cost: #334155;
  --amber: #d97706;
  --shadow: 0 6px 20px rgba(15, 23, 42, .1);
  --radius: 1rem;
  --nav-h: 4.4rem;
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
}
html[data-fs="norm"] { --sc: 1; }
html[data-fs="big"]  { --sc: 1.14; }
html[data-fs="xl"]   { --sc: 1.32; }

html { font-size: calc(16px * var(--sc)); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  min-height: 100vh;
  overscroll-behavior-y: none;
  font-size: 1rem;
  line-height: 1.5;
}
#app { min-height: 100vh; }

.boot {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: var(--shrimp-d); font-weight: 700;
}

/* ───────── layout ───────── */
.screen {
  max-width: 34rem; margin: 0 auto;
  padding: 0 1rem calc(var(--nav-h) + 1.8rem);
  min-height: 100vh;
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--shrimp), #f97316 60%, #fb923c);
  color: #fff; margin: 0 -1rem 1rem;
  padding: calc(env(safe-area-inset-top) + .9rem) 1.1rem 1rem;
  border-radius: 0 0 1.4rem 1.4rem; box-shadow: var(--shadow);
  display: flex; align-items: flex-end; gap: .6rem;
}
.topbar .tb-main { flex: 1; min-width: 0; }
.topbar h1 { margin: 0; font-size: 1.4rem; font-weight: 800; letter-spacing: .5px; }
.topbar .sub { margin-top: .2rem; font-size: .88rem; opacity: .95; }
.topbar .tb-act {
  flex: 0 0 auto; background: rgba(255,255,255,.24); border: 2px solid rgba(255,255,255,.5);
  color: #fff; border-radius: .8rem; padding: .55rem .8rem; font-size: .95rem; font-weight: 700;
  font-family: inherit; cursor: pointer; min-height: 2.7rem;
}
.topbar .tb-act:active { transform: scale(.95); }

/* ───────── card ───────── */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem; margin-bottom: .9rem;
}
.card h2 { margin: 0 0 .75rem; font-size: 1.12rem; display: flex; align-items: center; gap: .5rem; }
.card h2 .ico { font-size: 1.4rem; }
.card h2 .h2-right { margin-left: auto; font-size: .85rem; font-weight: 600; color: var(--muted); }
.section-title { font-size: .9rem; color: var(--muted); font-weight: 700; margin: 1.1rem .25rem .5rem; }

/* 首頁主卡的期間切換 (今天 / 近 7 天 / 本月) —— v2.5 */
.range-chips { justify-content: center; margin-bottom: .7rem; }
.range-chips .chip { flex: 1; justify-content: center; font-weight: 700; }

/* ───────── 今日結算 (主打卡) ───────── */
.net-card { text-align: center; background: linear-gradient(140deg, #fff, #fff7ed); border: 2px solid #fed7aa; }
.net-card .nc-lab { font-size: 1rem; color: var(--muted); font-weight: 700; }
.net-card .nc-amt { font-size: 3rem; font-weight: 900; line-height: 1.15; margin: .1rem 0 .25rem; font-variant-numeric: tabular-nums; }
.net-card .nc-amt.gain { color: var(--gain); }
.net-card .nc-amt.loss { color: var(--loss); }
.net-card .nc-amt.zero { color: var(--muted); }
.net-card .nc-sub { font-size: .9rem; color: var(--muted); }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; margin-top: .8rem; }
.stat-grid.g2 { grid-template-columns: 1fr 1fr; }
.stat {
  background: #f8fafc; border: 2px solid var(--line); border-radius: .8rem;
  padding: .7rem .4rem; text-align: center;
}
.stat .v { font-size: 1.25rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: .8rem; font-weight: 700; color: var(--muted); }
.stat .l { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.stat.rev { background: var(--gain-l); border-color: #fca5a5; }
.stat.rev .v { color: var(--gain); }
.stat.buy .v, .stat.exp .v { color: var(--cost); }
.v.gain { color: var(--gain); } .v.loss { color: var(--loss); }

/* ───────── 快速記帳 ───────── */
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
/* 四顆時排 2×2 (每顆更大更好按) */
.quick-grid.q4 { grid-template-columns: 1fr 1fr; }
.q-cash { background: linear-gradient(140deg, #15803d, #22c55e); }
/* v2.7 下排兩顆 = 客戶欠的 / 我欠的。沒有欠款時用淡色(不搶眼), 有欠款才亮起來 */
.q-owe-in, .q-owe-out { background: linear-gradient(140deg, #94a3b8, #cbd5e1); color: #1f2937; }
.q-owe-in.hot { background: linear-gradient(140deg, #dc2626, #f97316); color: #fff; }
.q-owe-out.hot { background: linear-gradient(140deg, #b45309, #f59e0b); color: #fff; }
.quick .qv { font-weight: 900; font-size: 1.15rem; font-variant-numeric: tabular-nums; margin-top: .1rem; }
.quick {
  border-radius: var(--radius); padding: 1rem .4rem; color: #fff; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .12s; text-align: center; border: none;
  font-family: inherit; min-height: 5.2rem;
}
.quick:active { transform: scale(.96); }
.quick .qe { font-size: 2rem; display: block; line-height: 1.2; }
.quick .qt { font-weight: 800; font-size: 1.05rem; margin-top: .25rem; }
.q-sale { background: linear-gradient(140deg, #ef4444, #f97316); }
.q-buy  { background: linear-gradient(140deg, #0e7490, #0ea5e9); }
.q-exp  { background: linear-gradient(140deg, #475569, #94a3b8); }

/* ───────── 今天實際收到的錢 (核帳用) ───────── */
.cash-row {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  margin-top: .7rem; padding: .7rem .9rem; border-radius: .8rem;
  background: var(--gain-l); border: 2px solid #fca5a5; font-size: .95rem;
}
.cash-row .cash-v { font-size: 1.4rem; font-weight: 900; color: var(--gain); font-variant-numeric: tabular-nums; }

/* 收款單:綠底跟賣貨分開, 一眼看出「這是有人拿錢來」 */
.item.receipt-row { background: #f0fdf4; border-radius: .7rem; padding-left: .5rem; padding-right: .3rem; }

/* 記帳表單裡「選填」的那一段 (貨品) */
.opt-sec {
  border: 2px dashed var(--line); border-radius: .9rem; padding: .8rem .7rem .6rem;
  margin-bottom: .8rem; background: #fbfdff;
}
.opt-sec .opt-head { font-size: .95rem; font-weight: 700; color: var(--muted); margin-bottom: .5rem; }
.opt-sec .opt-head b { color: var(--ocean); }

/* 遊客時的帳號警示卡 */
.card.acct-warn { border: 2px solid var(--amber); background: #fffbeb; }
.card.acct-warn h2 { color: #92400e; }

/* ───────── 🧪 測試模式 (v2.3) ───────── */
.demo-box {
  margin: 1.2rem .1rem .5rem; padding: .8rem .9rem; border-radius: .9rem;
  background: #f8fafc; border: 2px dashed var(--line);
}
.demo-toggle { display: flex; align-items: center; gap: .6rem; font-size: .95rem; font-weight: 700; color: var(--muted); }
.demo-toggle input { width: 1.5rem; height: 1.5rem; min-height: 0; flex: 0 0 auto; }
.demo-box.demo-toggle { cursor: pointer; }

/* 金額快捷鈕 (長輩打字慢, 一按就加) */
.amt-quick { display: flex; gap: .4rem; margin: -.4rem 0 .9rem; }
.amt-quick .btn { flex: 1; padding: .5rem .3rem; font-size: 1rem; min-height: 2.7rem; }

/* 存檔成功的大確認 */
.toast.ok {
  background: #15803d; font-size: 1.15rem; font-weight: 800; padding: 1rem 1.5rem;
  box-shadow: 0 8px 24px rgba(21,128,61,.4);
}

/* 第一次開啟:選字級 */
.fs-pick { display: flex; flex-direction: column; gap: .7rem; }
.fs-opt {
  width: 100%; padding: 1.1rem; border-radius: 1rem; border: 2px solid var(--line);
  background: #fff; font-family: inherit; font-weight: 800; color: var(--ink); cursor: pointer;
}
.fs-opt small { display: block; font-size: .8em; font-weight: 600; color: var(--muted); margin-top: .2rem; }
.fs-opt:active { background: var(--shrimp-l); border-color: var(--shrimp); }

/* ───────── 事業 / 項目 (v2.0) ───────── */
.proj-row {
  display: flex; align-items: center; gap: .7rem; padding: .75rem .5rem;
  border-bottom: 1px solid var(--line);
}
.proj-row:last-child { border-bottom: none; }
.proj-row .pe { font-size: 1.8rem; width: 2.4rem; text-align: center; flex: 0 0 auto; }
.proj-row .pm { flex: 1; min-width: 0; }
.proj-row .pm .p1 { font-weight: 800; font-size: 1.08rem; }
.proj-row .pm .p2 { font-size: .88rem; color: var(--muted); margin-top: .1rem; }
.proj-row .pv { font-weight: 900; font-size: 1.25rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* 明細列上的小標籤 */
.proj-tag {
  display: inline-block; margin-left: .3rem; padding: .05rem .5rem; border-radius: 999px;
  background: #eef2ff; color: #4338ca; font-size: .78rem; font-weight: 700; vertical-align: middle;
}
.chip.proj-chip.on { background: #4f46e5; border-color: #4f46e5; }
/* 收入來源的小標籤 (清單上顯示「市場 / 批發…」) */
.cat-tag {
  display: inline-block; margin-left: .3rem; padding: .05rem .5rem; border-radius: 999px;
  background: var(--gain-l); color: #b91c1c; font-size: .78rem; font-weight: 700; vertical-align: middle;
}
/* 🧪 測試資料標記 (v2.6) —— 要排在 .cat-tag 後面才蓋得過它的底色 */
.cat-tag.demo-tag { background: #f1f5f9; color: #475569; }
.chip.emo-chip { font-size: 1.4rem; padding: .35rem .7rem; }
.stat.g2-wide { grid-column: 1 / -1; }
.q-rep { background: linear-gradient(140deg, #7c3aed, #a78bfa); }

/* ───────── 未收帳款 ───────── */
.owe-row {
  display: flex; align-items: center; gap: .7rem; padding: .8rem;
  border-radius: .8rem; margin-bottom: .55rem; background: #f8fafc;
  border: 2px solid var(--line); cursor: pointer;
}
.owe-row:active { transform: scale(.99); }
.owe-row.hot { background: var(--gain-l); border-color: #fca5a5; }
.owe-row .oe { font-size: 1.7rem; width: 2.4rem; text-align: center; }
.owe-row .om { flex: 1; min-width: 0; }
.owe-row .om .o1 { font-weight: 700; font-size: 1.05rem; }
.owe-row .om .o2 { font-size: .82rem; color: var(--muted); margin-top: .1rem; }
.owe-row .ov { font-weight: 800; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.owe-row.hot .ov { color: var(--gain); }

/* ───────── 走勢圖 ───────── */
.bars { width: 100%; height: 9.5rem; display: block; }
.bars .b-pos { fill: var(--gain); }
.bars .b-neg { fill: var(--loss); }
.bars .b-zero { fill: var(--line); }
.bars .b-lbl { fill: var(--muted); font-size: 10px; text-anchor: middle; }
.bars .b-axis { stroke: var(--line); stroke-width: 1; }

/* ───────── buttons ───────── */
.btn {
  appearance: none; border: none; border-radius: .85rem; cursor: pointer;
  font-family: inherit; font-size: 1.08rem; font-weight: 700; padding: .85rem 1.1rem;
  background: linear-gradient(135deg, var(--shrimp), #f97316); color: #fff;
  transition: transform .12s, opacity .15s; width: 100%; min-height: 3.1rem;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; }
.btn.ghost { background: #fff; color: var(--shrimp-d); border: 2px solid #fdba74; }
.btn.gray { background: #eef2f7; color: var(--ink); border: 2px solid var(--line); }
.btn.ocean { background: linear-gradient(135deg, var(--ocean), #0ea5e9); }
.btn.danger { background: #fef2f2; color: var(--gain); border: 2px solid #fca5a5; }
.btn.sm { padding: .55rem .8rem; font-size: .95rem; width: auto; min-height: 2.6rem; }
.btn-row { display: flex; gap: .6rem; }
.btn-row .btn { flex: 1; }

/* ───────── forms ───────── */
label.fld { display: block; margin-bottom: .8rem; }
label.fld .lab { font-size: .92rem; color: var(--muted); font-weight: 700; margin-bottom: .3rem; display: block; }
input, select, textarea {
  font-family: inherit; font-size: 1.1rem; width: 100%; padding: .75rem .8rem;
  border: 2px solid var(--line); border-radius: .75rem; background: #fff; color: var(--ink);
  min-height: 3.1rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--shrimp); }
textarea { resize: vertical; min-height: 4rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; }
.row3 input, .row3 select { padding: .7rem .5rem; }

/* 金額試算列 (數量 × 單價 = 金額) */
.calc-box {
  background: var(--shrimp-l); border: 2px solid #fdba74; border-radius: .85rem;
  padding: .75rem .9rem; margin-bottom: .8rem; display: flex; align-items: center; gap: .6rem;
}
.calc-box .cb-l { font-size: .95rem; color: #9a3412; font-weight: 700; flex: 1; }
.calc-box .cb-v { font-size: 1.7rem; font-weight: 900; color: var(--shrimp-d); font-variant-numeric: tabular-nums; }
.calc-box .cb-v small { font-size: .9rem; }
.calc-box input { flex: 0 0 8.5rem; font-size: 1.35rem; font-weight: 800; text-align: right; }

.chips { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip {
  padding: .6rem 1rem; border-radius: 999px; border: 2px solid var(--line);
  background: #fff; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all .12s;
  min-height: 2.8rem; display: inline-flex; align-items: center;
}
.chip.on { background: var(--shrimp); color: #fff; border-color: var(--shrimp); }
.chip:active { transform: scale(.95); }
.chip.sm { padding: .45rem .8rem; font-size: .92rem; min-height: 2.4rem; }
.chip.ocean.on { background: var(--ocean); border-color: var(--ocean); }
.chip.paid.on { background: var(--gain); border-color: var(--gain); }
.chip.unpaid.on { background: var(--amber); border-color: var(--amber); }
.chip .cp { font-size: .78rem; opacity: .75; margin-left: .25rem; }
.chip.on .cp { opacity: .95; }
/* 字體大小選擇:字級本身就是預覽 */
.fs-chips .fs-chip { padding: .6rem 1.1rem; }

/* 日期切換列 */
.dnav { display: flex; align-items: center; gap: .5rem; margin-bottom: .8rem; }
.dnav button {
  flex: 0 0 3.2rem; min-height: 3.2rem; border-radius: .8rem; border: 2px solid var(--line);
  background: #fff; font-size: 1.5rem; cursor: pointer; font-family: inherit; color: var(--ink);
}
.dnav button:active { background: var(--shrimp-l); }
.dnav .dlab {
  flex: 1; text-align: center; font-weight: 800; font-size: 1.1rem; padding: .55rem .4rem;
  background: #fff; border: 2px solid var(--line); border-radius: .8rem; cursor: pointer;
  min-height: 3.2rem; display: flex; flex-direction: column; justify-content: center;
}
.dnav .dlab small { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; }

/* ───────── list items ───────── */
.item {
  display: flex; align-items: center; gap: .65rem; padding: .75rem .15rem;
  border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: none; }
.item .ib { font-size: 1.5rem; width: 2.1rem; text-align: center; flex: 0 0 auto; }
.item .im { flex: 1; min-width: 0; }
.item .im .i1 { font-weight: 700; font-size: 1.05rem; }
.item .im .i2 { font-size: .88rem; color: var(--muted); margin-top: .15rem; word-break: break-word; }
.item .iright { text-align: right; flex: 0 0 auto; }
.item .iv { font-weight: 800; font-size: 1.15rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item .iv.gain { color: var(--gain); }
.item .iv.cost { color: var(--cost); }
.item .del { color: var(--gain); background: none; border: none; font-size: 1.25rem; padding: .5rem .3rem; cursor: pointer; opacity: .7; }
.item.tap { cursor: pointer; }
.item.tap:active { background: #f8fafc; }
.empty { text-align: center; color: var(--muted); padding: 1.6rem .6rem; font-size: 1rem; line-height: 1.7; }
.tot-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem .9rem; border-radius: .8rem; background: #f8fafc; border: 2px solid var(--line);
  margin-bottom: .8rem; font-weight: 700; font-size: 1.02rem;
}
.tot-row .tv { font-size: 1.4rem; font-weight: 900; font-variant-numeric: tabular-nums; }

/* ───────── 客戶 ───────── */
.cust-row {
  display: flex; align-items: center; gap: .6rem; padding: .8rem .6rem;
  border-radius: .85rem; margin-bottom: .55rem; background: #fff;
  border: 2px solid var(--line); box-shadow: 0 2px 8px rgba(15,23,42,.04);
}
.cust-row .cm { flex: 1; min-width: 0; cursor: pointer; }
.cust-row .cn { font-weight: 800; font-size: 1.15rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.cust-row .cp2 { font-size: 1rem; color: var(--ink); margin-top: .15rem; font-variant-numeric: tabular-nums; }
.cust-row .cstat { font-size: .85rem; color: var(--muted); margin-top: .2rem; }
.cust-row .cstat b { color: var(--gain); }
.call-btn {
  flex: 0 0 auto; width: 3.7rem; height: 3.7rem; border-radius: 1rem; text-decoration: none;
  background: linear-gradient(140deg, #15803d, #22c55e); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 1.5rem; box-shadow: 0 3px 10px rgba(22,163,74,.32);
}
.call-btn small { font-size: .68rem; font-weight: 700; margin-top: -.15rem; }
.call-btn:active { transform: scale(.94); }
.call-btn.off { background: #e2e8f0; color: #94a3b8; box-shadow: none; pointer-events: none; }
/* 撥打 + LINE 兩顆並排 (v1.5) */
.contact-btns { display: flex; flex-direction: column; gap: .4rem; flex: 0 0 auto; }
.call-btn.line { background: linear-gradient(140deg, #06c755, #4ade80); box-shadow: 0 3px 10px rgba(6,199,85,.3); }
/* 還沒設 LINE:淡綠虛線, 但**可以按** → 直接跳去補設定 */
.call-btn.set-line {
  background: #f0fdf4; color: #15803d; border: 2px dashed #86efac; box-shadow: none;
  font-family: inherit; cursor: pointer;
}
.call-btn.set-line:active { transform: scale(.94); background: #dcfce7; }
.searchbar { display: flex; gap: .5rem; margin-bottom: .8rem; }
.searchbar input { flex: 1; }

/* ───────── 量 / 庫存 ───────── */
.qty-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
  margin: -.4rem 0 .8rem; padding: .6rem .8rem; border-radius: .8rem;
  background: var(--ocean-l); border: 2px solid #a5f3fc; font-size: .95rem;
}
.qty-line b { color: #0e7490; font-size: .9rem; }
.qty-tag {
  background: #fff; border: 1px solid #a5f3fc; border-radius: 999px;
  padding: .15rem .65rem; font-weight: 700; color: #0e7490; font-variant-numeric: tabular-nums;
}
.chip.stock-chip { background: var(--ocean-l); border-color: #a5f3fc; color: #0e7490; }
.chip.stock-chip b { color: #164e63; }
.stk-btns { display: flex; gap: .35rem; margin-top: .3rem; }
.stk-btns .btn { padding: .35rem .6rem; font-size: .85rem; min-height: 2.2rem; }

/* 選人 + 新增 (銷貨選客戶 / 收購選貨主) */
.pick-row { display: flex; gap: .5rem; align-items: stretch; }
.pick-row select { flex: 1; min-width: 0; }
.pick-row .btn { flex: 0 0 auto; }
.badge.kind-customer { background: #fee2e2; color: #b91c1c; }
.badge.kind-supplier { background: #cffafe; color: #0e7490; }
.badge.kind-both { background: #ede9fe; color: #6d28d9; }

/* 付貨款 */
.paygroup { border: 2px solid var(--line); border-radius: .85rem; margin-bottom: .6rem; overflow: hidden; }
.pg-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem .8rem; background: #f8fafc; border-bottom: 1px solid var(--line);
}
.pg-all { display: flex; align-items: center; gap: .5rem; font-size: 1.05rem; }
.pg-all input { width: 1.5rem; height: 1.5rem; min-height: 0; }
.pg-sum { font-weight: 800; color: var(--cost); font-variant-numeric: tabular-nums; }
.pg-row {
  display: flex; align-items: center; gap: .6rem; padding: .65rem .8rem;
  border-bottom: 1px solid var(--line);
}
.pg-row:last-child { border-bottom: none; }
.pg-row input { width: 1.5rem; height: 1.5rem; flex: 0 0 auto; min-height: 0; }
.pg-m { flex: 1; min-width: 0; font-size: 1rem; }
.pg-m small { display: block; color: var(--muted); font-size: .82rem; }
.pg-v { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ───────── 報表 table ───────── */
.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th, .tbl td { padding: .55rem .35rem; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.tbl th { color: var(--muted); font-size: .85rem; font-weight: 700; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td.gain { color: var(--gain); font-weight: 700; }
.tbl td.loss { color: var(--loss); font-weight: 700; }
.tbl-wrap { overflow-x: auto; }
.rank-row { display: flex; align-items: center; gap: .6rem; padding: .6rem .15rem; border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: none; }
.rank-row .rn {
  width: 1.7rem; height: 1.7rem; border-radius: .5rem; background: var(--shrimp-l); color: var(--shrimp-d);
  font-size: .85rem; font-weight: 800; display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.rank-row .rm { flex: 1; min-width: 0; font-weight: 700; font-size: 1rem; }
.rank-row .rm small { display: block; color: var(--muted); font-weight: 500; font-size: .85rem; }
.rank-row .rv { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ───────── bottom nav ───────── */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: rgba(255,255,255,.97); backdrop-filter: blur(10px);
  border-top: 2px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 14px rgba(15,23,42,.08);
}
.nav button {
  flex: 1; background: none; border: none; cursor: pointer; font-family: inherit;
  padding: .4rem 0 .5rem; color: var(--muted); display: flex; flex-direction: column;
  align-items: center; gap: .15rem; height: var(--nav-h);
}
.nav button .ne { font-size: 1.6rem; transition: transform .15s; }
.nav button .nl { font-size: .8rem; font-weight: 700; }
.nav button.on { color: var(--shrimp-d); }
.nav button.on .ne { transform: translateY(-2px) scale(1.12); }

/* ───────── modal / sheet ───────── */
.mask {
  position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  background: #fff; width: 100%; max-width: 34rem;
  border-radius: 1.4rem 1.4rem 0 0; padding: 1.2rem 1.1rem calc(1.2rem + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto; animation: slideup .24s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes slideup { from { transform: translateY(100%); } }
.sheet h3 { margin: 0 0 .9rem; font-size: 1.25rem; display: flex; align-items: center; gap: .5rem; }
.sheet h3 .h3r { margin-left: auto; font-size: .9rem; color: var(--muted); font-weight: 600; }

/* ───────── misc ───────── */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 1.1rem); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .75rem 1.3rem; border-radius: 999px;
  font-size: 1.02rem; font-weight: 600; z-index: 80; box-shadow: var(--shadow); max-width: 92%;
  animation: toastin .2s ease; text-align: center;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } }
.spinner {
  width: 2rem; height: 2rem; border: 3px solid var(--line); border-top-color: var(--shrimp);
  border-radius: 50%; animation: spin .7s linear infinite; margin: 1.9rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.badge.guest { background: #fef3c7; color: #92400e; }
.badge.bound { background: #d1fae5; color: #065f46; }
.badge.paid { background: #dcfce7; color: #15803d; }
.badge.unpaid { background: #fef3c7; color: #92400e; }
.foot { text-align: center; color: var(--muted); font-size: .82rem; padding: .9rem 0 .25rem; line-height: 1.8; }
.hint { font-size: .9rem; color: var(--muted); margin-top: .4rem; line-height: 1.6; }
.linkcard {
  display: flex; align-items: center; gap: .7rem; padding: .9rem; border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow); margin-bottom: .75rem; cursor: pointer;
}
.linkcard:active { transform: scale(.99); }
.linkcard .le { font-size: 1.8rem; }
.linkcard .lm { flex: 1; }
.linkcard .lm .l1 { font-weight: 800; font-size: 1.08rem; }
.linkcard .lm .l2 { font-size: .88rem; color: var(--muted); margin-top: .1rem; }
.linkcard .lgo { color: var(--muted); font-size: 1.5rem; }

/* ───────── auth gate ───────── */
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem 1.1rem; }
.gate-card {
  background: var(--card); border-radius: 1.4rem; box-shadow: var(--shadow);
  padding: 1.9rem 1.3rem 1.3rem; width: 100%; max-width: 25rem; text-align: center; position: relative;
}
.gate-back {
  position: absolute; top: .9rem; left: .9rem; background: none; border: none;
  color: var(--muted); font-family: inherit; font-size: .95rem; font-weight: 600; cursor: pointer; padding: .3rem .4rem;
}
.gate-back:active { color: var(--shrimp-d); }
.gate-logo { font-size: 3.4rem; line-height: 1; }
.gate-title { margin: .5rem 0 .2rem; font-size: 1.6rem; font-weight: 800; }
.gate-sub { margin: 0 0 1.2rem; color: var(--muted); font-size: .95rem; line-height: 1.6; }
.gate-seg { display: flex; background: #eef2f7; border-radius: .8rem; padding: .25rem; margin-bottom: 1.1rem; }
.gate-seg button {
  flex: 1; border: none; background: none; padding: .7rem; border-radius: .6rem;
  font-family: inherit; font-size: 1.05rem; font-weight: 700; color: var(--muted); cursor: pointer;
  min-height: 2.9rem;
}
.gate-seg button.on { background: #fff; color: var(--shrimp-d); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.gate-card .fld { text-align: left; }
.gate-ver { margin-top: 1.1rem; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.ver-upd {
  display: inline-block; margin-left: .4rem; padding: .2rem .7rem; border-radius: 999px;
  background: var(--amber); color: #fff; border: none; font-size: .8rem; font-weight: 700;
  cursor: pointer; vertical-align: middle;
}
.ver-upd:active { transform: scale(.95); }
