/* Layout: one centered column, cards in an auto-fit grid. Warm light palette from KaBao's orange bun. */
:root {
  --bg: #fffaf3;
  --panel: #ffffff;
  --ink: #3b2614;
  --muted: #8a6f58;
  --line: #f0e2d0;
  --accent: #f08a24;
  --accent-2: #5b8def;
  --muted-bar: #e9d7c2;
  --bad: #d9534f;
  --good: #2f9e62;
  --radius: 14px;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --display: "Zen Maru Gothic", "Noto Sans TC", "PingFang TC", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1712; --panel: #261e17; --ink: #f6eadc; --muted: #c2a98f; --line: #3a2e23;
    --accent: #ff9f45; --accent-2: #7ea6ff; --muted-bar: #4a3b2e; --bad: #ff7b72; --good: #4cc38a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 32px 48px; }
.wrap { max-width: 68rem; margin-inline: auto; display: flex; flex-direction: column; gap: 24px; }
h1 { font-family: var(--display); font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0; letter-spacing: .01em; text-wrap: balance; }
h2 { font-size: 1.1rem; margin: 0; font-weight: 700; text-wrap: balance; }
h3 { font-size: .95rem; margin: 0; font-weight: 600; }
p { margin: 0; line-height: 1.6; }
.muted { color: var(--muted); font-size: .85rem; }
.lede { max-width: 62ch; font-size: 1.02rem; }
.brand { display: flex; align-items: center; gap: 12px; }
.bun { width: 44px; height: 44px; flex: none; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile .big { font-family: var(--display); font-size: 1.9rem; font-variant-numeric: tabular-nums; line-height: 1.15; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.chart { position: relative; width: 100%; min-height: 120px; }
.rows { display: flex; flex-direction: column; gap: 8px; }
.brow { display: grid; grid-template-columns: minmax(7rem, 13rem) 1fr; gap: 10px; align-items: center; font-size: .85rem; }
.brow .lab { min-width: 0; overflow-wrap: anywhere; }
.brow .n { color: var(--muted); }
.bars { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bline { display: flex; align-items: center; gap: 6px; min-width: 0; }
.bar { height: 14px; border-radius: 4px; min-width: 2px; }
.bline .v { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .8rem; }
.loss { color: var(--bad); font-size: .8rem; white-space: nowrap; }
.loss.small { color: var(--muted); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; background: var(--sw); vertical-align: -1px; }
.tbl-wrap { overflow-x: auto; max-height: 28rem; overflow-y: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: .85rem; }
th { text-align: left; font-weight: 600; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); white-space: nowrap; }
td { padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.num { text-align: right; }
.tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.12); padding: 6px 10px; font-size: .8rem; white-space: nowrap; z-index: 2; }
.tip .t { color: var(--muted); }
svg text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.recs { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 8px; line-height: 1.6; max-width: 70ch; }
.state { color: var(--muted); font-size: .9rem; padding: 24px 0; text-align: center; }
.login { max-width: 22rem; margin: 10vh auto 0; }
.login form { display: flex; flex-direction: column; gap: 10px; }
input[type=password] { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
button { font: inherit; padding: 10px 14px; border-radius: 10px; border: 0; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 500; padding: 6px 10px; }
button:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; }
.err { color: var(--bad); font-size: .85rem; min-height: 1.2em; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
footer { color: var(--muted); font-size: .8rem; text-align: center; }
a { color: var(--accent); }
