/* Layout: a single ledger column — summary figures, then allocation and trend side by side, then the holdings register. */
:root {
  --bg: #f3f5f4;
  --panel: #ffffff;
  --ink: #15211d;
  --ink-2: #44544e;
  --muted: #6c7b75;
  --line: #dde3e0;
  --soft: #e9eeec;
  --jade: #1f6f5c;          /* accent */
  --jade-soft: #d7ebe4;
  --gold: #b8892f;
  --up: #1d8a55;
  --down: #c8443a;
  --scrim: rgba(10, 20, 17, .5);
  --shadow: 0 1px 2px rgba(21, 33, 29, .05), 0 8px 24px -14px rgba(21, 33, 29, .18);
  --f-display: "Noto Serif TC", "Songti TC", serif;
  --f-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1513; --panel: #15201d; --ink: #e6eeeb; --ink-2: #bccbc5; --muted: #8b9c96;
    --line: #26342f; --soft: #1c2925; --jade: #5fc2a5; --jade-soft: #1d3a32; --gold: #d9ae5c;
    --up: #4cc38a; --down: #ef7a6f; --scrim: rgba(0, 0, 0, .6);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -14px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.6; }
.wrap { max-width: 1120px; margin: 0 auto; padding-block: 28px 56px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 20px; }
h1, h2, h3, p { margin: 0; }
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--jade); outline-offset: 2px; }

/* header */
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; }
.head h1 { font-family: var(--f-display); font-size: clamp(26px, 4vw, 34px); line-height: 1.2; text-wrap: balance; }
.head p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.ctl { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
.ctl select, .ctl input { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 14px; min-width: 0; }
.ctl input { width: 96px; font-family: var(--f-num); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 10px; border-radius: 999px; background: var(--soft); color: var(--ink-2); white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.chip.ok::before { background: var(--up); }
.chip.warn::before { background: var(--gold); }

/* example banner */
.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 12px 16px; border-radius: 10px; background: var(--jade-soft); color: var(--ink); font-size: 14px; }
.banner b { font-weight: 700; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.stat { padding: 18px 20px; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 500; letter-spacing: .04em; }
.stat-val { font-size: clamp(19px, 2.4vw, 26px); font-weight: 500; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-sub { font-size: 12.5px; color: var(--muted); }
.stat.lead .stat-val { color: var(--jade); }
.up { color: var(--up); } .down { color: var(--down); }

/* panels */
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; min-width: 0; }
.panel h2 { font-size: 13px; font-weight: 700; letter-spacing: .08em; color: var(--ink-2); margin-bottom: 14px; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
.alloc { list-style: none; margin: 0; padding: 0; display: grid; gap: 11px; }
.alloc li { display: grid; grid-template-columns: 92px minmax(0, 1fr) 120px; gap: 12px; align-items: center; font-size: 14px; }
.track { height: 10px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.fill { display: block; height: 100%; background: var(--jade); border-radius: 4px; }
.alloc .v { text-align: right; line-height: 1.25; }
.alloc .v b { display: block; font-weight: 500; }
.alloc .v small { color: var(--muted); font-size: 12px; }
.hist-head { font-size: 13.5px; color: var(--muted); margin-bottom: 6px; }
.hist-head .num { font-size: 18px; color: var(--ink); }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.c-grid { stroke: var(--line); stroke-width: 1; }
.c-area { fill: var(--jade-soft); }
.c-line { fill: none; stroke: var(--jade); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.c-dot { fill: var(--jade); stroke: var(--panel); stroke-width: 2; }
.c-tick { fill: var(--muted); font-size: 11px; font-family: var(--f-num); }
.c-cross { stroke: var(--muted); stroke-dasharray: 3 3; }
.c-cross, .c-hover { visibility: hidden; }
.chart.on .c-cross, .chart.on .c-hover { visibility: visible; }
.c-hit { fill: transparent; cursor: crosshair; }
.tip { position: absolute; top: 0; transform: translate(-50%, -100%); background: var(--ink); color: var(--bg); padding: 5px 9px; border-radius: 7px; font-size: 12.5px; white-space: nowrap; pointer-events: none; line-height: 1.35; }
.tip small { display: block; opacity: .75; font-size: 11px; }

/* holdings */
.reg-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.reg-head h2 { font-family: var(--f-display); font-size: 21px; letter-spacing: 0; color: var(--ink); margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 9px; font-size: 14px; font-weight: 500; cursor: pointer; }
.btn:hover { border-color: var(--jade); color: var(--jade); }
.btn.primary { background: var(--jade); border-color: var(--jade); color: var(--panel); }
.btn.primary:hover { filter: brightness(1.08); color: var(--panel); }
.btn.danger:hover { border-color: var(--down); color: var(--down); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: default; pointer-events: none; }
.tbl-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; font-size: 14px; }
th, td { padding: 11px 14px; text-align: left; vertical-align: top; }
thead th { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: .04em; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr + tr td, tbody tr + tr th { border-top: 1px solid var(--line); }
tbody tr.group th { background: var(--soft); font-size: 12.5px; font-weight: 700; color: var(--ink-2); padding: 6px 14px; }
tbody th { font-weight: 400; }
.nm b { display: block; font-weight: 500; }
td small, .nm small { display: block; font-size: 12px; color: var(--muted); }
.r { text-align: right; white-space: nowrap; }
.row-act { white-space: nowrap; text-align: right; }
.row-act .btn + .btn { margin-left: 6px; }
.stale { color: var(--gold); }
.msg { font-size: 13.5px; color: var(--ink-2); min-height: 1.4em; }
.note { font-size: 12.5px; color: var(--muted); max-width: 72ch; }

/* dialogs */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--panel); color: var(--ink); width: min(600px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: var(--shadow); }
dialog::backdrop { background: var(--scrim); }
.form { display: grid; gap: 14px; padding: 22px; }
.form h3 { font-family: var(--f-display); font-size: 20px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.f { display: grid; gap: 5px; min-width: 0; }
.f label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.f input, .f select { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 15px; }
.f input[type="number"] { font-family: var(--f-num); }
.hint { font-size: 13px; color: var(--muted); }
.form-act { display: flex; gap: 8px; flex-wrap: wrap; }
.err { color: var(--down); font-size: 13px; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .alloc li { grid-template-columns: 76px minmax(0, 1fr) 104px; gap: 8px; }
  .row { grid-template-columns: minmax(0, 1fr); }
  .stat { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

[hidden] { display: none !important; }
body { margin: 0; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--panel); }
.lang button { border: 0; background: none; padding: 5px 11px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--jade); color: var(--panel); }
.prices { font-size: 13px; color: var(--muted); margin-top: -8px; }
.prices .stale { color: var(--gold); }
.register { display: grid; gap: 12px; }
.live { display: inline-block; font-size: 11px; font-weight: 500; padding: 0 6px; border-radius: 4px; background: var(--jade-soft); color: var(--jade); margin-left: 4px; vertical-align: 1px; }
.about { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; padding-top: 8px; border-top: 1px solid var(--line); }
.about h2 { font-size: 13px; font-weight: 700; letter-spacing: .06em; color: var(--ink-2); margin-bottom: 6px; }
.about p { font-size: 13.5px; color: var(--muted); line-height: 1.7; }
.foot { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); }
.foot a { color: var(--jade); text-decoration: none; border-bottom: 1px solid currentColor; }
@media (max-width: 760px) { .about { grid-template-columns: minmax(0, 1fr); } }
.tbl-wrap { position: relative; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
