/* 字型自己托管（SIL OFL，授權見 /assets/fonts/）；中文用系統字型，避免下載幾 MB 嘅中文字型 */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url(/assets/fonts/inter-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url(/assets/fonts/inter-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url(/assets/fonts/inter-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url(/assets/fonts/inter-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url(/assets/fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url(/assets/fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2"); }

:root {
  --bg: #fafafa;
  --side: #ececec;
  --card: #ffffff;
  --line: #e4e4e4;
  --line-strong: #cfcfcf;
  --text: #121212;
  --muted: #8c8c8c;
  --soft: #f3f3f3;
  --pos: #1f9d55;
  --neg: #d64545;
  --accent: #121212;
  --accent-ink: #ffffff;
  --link: #2f6fde;
  --warn: #b7791f;
  --row-hover: #f7f7f7;
  --bar: #6b6b6b;
  --shadow: 0 8px 30px rgba(0,0,0,.12);
  --c1:#4f7cac; --c2:#f0a35e; --c3:#e8899e; --c4:#6bbf8a; --c5:#9b7fd1; --c6:#4fb3bf; --c7:#c9b458; --c8:#8d99ae;
  --font: "Inter", -apple-system, "PingFang HK", "PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "PingFang HK", "PingFang TC", "Microsoft JhengHei", monospace;
  --banner-h: 28px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#121212; --side:#1b1b1b; --card:#191919; --line:#2a2a2a; --line-strong:#3a3a3a;
    --text:#ececec; --muted:#8a8a8a; --soft:#222; --accent:#ececec; --accent-ink:#111;
    --row-hover:#1f1f1f; --bar:#3a3a3a; --link:#78a4f5; --shadow: 0 8px 30px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg:#121212; --side:#1b1b1b; --card:#191919; --line:#2a2a2a; --line-strong:#3a3a3a;
  --text:#ececec; --muted:#8a8a8a; --soft:#222; --accent:#ececec; --accent-ink:#111;
  --row-hover:#1f1f1f; --bar:#3a3a3a; --link:#78a4f5; --shadow: 0 8px 30px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; padding-top: var(--banner-h); }
.demo-banner { position: fixed; top: 0; left: 0; right: 0; height: var(--banner-h); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 0 16px; background: var(--accent); color: var(--accent-ink); font-size: 12px; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.label { font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.link { color: var(--link); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - var(--banner-h)); }
.sidebar { background: var(--side); padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: var(--banner-h); height: calc(100vh - var(--banner-h)); overflow-y: auto; }
.brand { white-space: nowrap; font-weight: 700; letter-spacing: .12em; font-size: 13px; padding: 0 8px 22px; display: flex; gap: 8px; align-items: center; }
.brand-mark { width: 18px; height: 18px; border: 1.5px solid var(--text); display: grid; place-items: center; font-size: 10px; letter-spacing: 0; }
.brand-zh { font-weight: 500; letter-spacing: .2em; color: var(--muted); }
.nav-item { display: flex; justify-content: space-between; align-items: baseline; padding: 8px; border-radius: 6px; cursor: pointer; color: var(--text); text-decoration: none; }
.nav-item:hover { background: rgba(0,0,0,.05); }
.nav-item.active { font-weight: 600; background: rgba(0,0,0,.06); }
.nav-item .nav-sub { font-size: 11px; color: var(--muted); display: block; font-weight: 400; }
.nav-item .nav-val { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.nav-sep { height: 1px; background: var(--line-strong); margin: 10px 8px; opacity: .6; }
.side-foot { margin-top: auto; font-size: 11.5px; color: var(--muted); padding: 8px; line-height: 1.5; }
.side-foot b { color: var(--text); font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding: 16px 24px; position: sticky; top: var(--banner-h); background: var(--bg); z-index: 5; }
.topbar .icon-btn { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.topbar .icon-btn:hover { background: var(--soft); color: var(--text); }
.topbar .pill { white-space: nowrap; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-radius: 6px; }
.topbar .pill:hover { background: var(--soft); color: var(--text); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.mobile-nav { display: none; }
.view { width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 24px 80px; }
.view.wide { max-width: 980px; }

/* ---------- cards ---------- */
.greet { font-family: var(--mono); font-size: 20px; letter-spacing: .02em; margin: 6px 0 12px; text-transform: uppercase; }
.grid { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.card { background: var(--card); padding: 16px 18px; min-width: 0; }
.card h4 { margin: 0 0 4px; font-size: 12px; font-weight: 600; }
.big { font-size: 26px; font-weight: 500; letter-spacing: -.01em; }
.big sup, .mid sup { font-size: .5em; vertical-align: super; margin-right: 1px; }
.mid { font-size: 20px; font-weight: 500; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 16px; margin-top: 12px; }
.kv .label { display: block; margin-bottom: 2px; }
.kv span:not(.label) { font-family: var(--mono); font-size: 12px; }
.dash-top { grid-template-columns: 1.15fr 1fr 1fr; }
.dash-top .nw-card { grid-row: span 2; display: flex; flex-direction: column; }
.section-card { background: var(--card); border: 1px solid var(--line); margin-top: 16px; }
.section-card .head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 0; }
.chart-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.chart-card { background: var(--card); border: 1px solid var(--line); padding: 16px 18px; min-width: 0; }
.chart-card .head { display: flex; justify-content: space-between; align-items: flex-start; }
.donut-wrap { display: flex; gap: 16px; align-items: center; margin-top: 10px; }
.legend { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.legend-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; }
.legend-row .sw { width: 10px; height: 10px; border-radius: 2px; }
.legend-row .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-row .vl { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.empty-note { color: var(--muted); font-size: 12.5px; padding: 18px 0; text-align: center; }
.range-tabs { display: flex; gap: 2px; }
.range-tabs button { font-family: var(--mono); font-size: 11px; padding: 4px 8px; border-radius: 4px; color: var(--muted); }
.range-tabs button.on { background: var(--accent); color: var(--accent-ink); }
.chart-svg { width: 100%; display: block; overflow: visible; }
.tooltip { position: fixed; z-index: 100; background: var(--accent); color: var(--accent-ink); font-size: 12px; padding: 6px 9px; border-radius: 6px; pointer-events: none; white-space: nowrap; font-family: var(--mono); }

/* ---------- sheets ---------- */
.sheet-total { font-size: 30px; font-weight: 500; margin: 6px 0 14px; }
.sheet-tabs { display: flex; gap: 22px; align-items: flex-end; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.sheet-tab { padding: 0 0 10px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.sheet-tab .nm { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.sheet-tab .vl { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.sheet-tab.on { border-color: var(--text); }
.sheet-tab.on .nm { color: var(--text); font-weight: 600; }
.sheet-tab-add { color: var(--muted); padding: 0 4px 10px; font-size: 18px; line-height: 1; }
.section { background: var(--card); border: 1px solid var(--line); margin-bottom: 18px; }
.section-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px 6px; }
.section-head input { border: 0; background: transparent; font-weight: 600; font-size: 13px; flex: 1; padding: 2px 0; outline: none; }
.section-head input::placeholder { color: var(--muted); font-weight: 400; }
.col-head { display: grid; grid-template-columns: 1fr 140px 56px; padding: 6px 14px; border-bottom: 1px solid var(--line); }
.col-head .label:nth-child(2) { text-align: right; }
.row { display: grid; grid-template-columns: 1fr 140px 56px; align-items: center; padding: 0 14px; border-bottom: 1px solid var(--line); min-height: 46px; }
.row:hover { background: var(--row-hover); }
.row.dragging { opacity: .4; }
.row.drop-target { box-shadow: inset 0 2px 0 var(--link); }
.row .nm-in { border: 0; background: transparent; width: 100%; padding: 12px 0; outline: none; font-size: 13.5px; }
.row .sub { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-top: -10px; padding-bottom: 8px; }
.row .val { text-align: right; }
.row .val input { border: 0; background: transparent; text-align: right; width: 100%; font-size: 13.5px; outline: none; padding: 6px 0; font-family: var(--font); }
.row .val input:focus { background: var(--soft); border-radius: 4px; padding: 6px 6px; }
.row .val .orig { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.row .val .fixed { cursor: pointer; padding: 6px 0; display: block; }
.row .acts { display: flex; justify-content: flex-end; gap: 2px; opacity: .35; }
.row:hover .acts { opacity: 1; }
.dot-btn { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 4px; color: var(--muted); }
.dot-btn:hover { background: var(--soft); color: var(--text); }
.add-row { display: flex; justify-content: space-between; align-items: center; background: var(--bar); color: #fff; padding: 10px 14px; font-family: var(--mono); font-size: 11px; letter-spacing: .05em; }
.add-row button { color: #fff; }
.add-row .tot { font-family: var(--font); font-size: 13px; font-weight: 600; letter-spacing: 0; }
.new-section { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .05em; }
.new-section:hover { color: var(--text); }

/* ---------- empty debts ---------- */
.hero-title { font-size: 26px; font-weight: 700; line-height: 1.15; margin: 10px 0 14px; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tile { background: var(--soft); border: 1px solid var(--line); padding: 12px; min-height: 92px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; text-align: left; position: relative; }
.tile:hover { border-color: var(--text); }
.tile .t { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; line-height: 1.35; }
.tile .d { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.tile .ic { position: absolute; right: 10px; top: 10px; font-size: 22px; opacity: .85; }
.tile-group { margin: 16px 0 8px; }
.tile-group:first-of-type { margin-top: 4px; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(250,250,250,.75); backdrop-filter: blur(2px); z-index: 40; display: flex; justify-content: center; align-items: flex-start; padding: 48px 16px; overflow-y: auto; }
:root[data-theme="dark"] .modal-bg { background: rgba(0,0,0,.6); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .modal-bg { background: rgba(0,0,0,.6); } }
.modal { background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); width: 100%; max-width: 640px; padding: 26px 30px 30px; position: relative; }
.modal.sm { max-width: 440px; }
.modal.lg { max-width: 760px; }
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.modal-close { position: absolute; right: 14px; top: 12px; width: 30px; height: 30px; font-size: 20px; color: var(--muted); border-radius: 50%; }
.modal-close:hover { background: var(--soft); color: var(--text); }
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin: 14px 0 18px; overflow-x: auto; scrollbar-width: none; }
.tabs button { font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; color: var(--muted); padding: 0 0 8px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--text); border-color: var(--text); }
.field { margin-bottom: 16px; }
.field > .label { display: block; margin-bottom: 4px; color: var(--text); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.input, .select, .textarea { width: 100%; border: 1px solid var(--line-strong); background: var(--card); padding: 10px 12px; font-size: 13.5px; border-radius: 0; outline: none; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--text); }
.textarea { min-height: 160px; resize: vertical; line-height: 1.5; }
.underline-input { border: 0; border-bottom: 1px solid var(--line-strong); background: transparent; width: 100%; padding: 8px 0; font-size: 14px; outline: none; }
.underline-input:focus { border-color: var(--text); }
.desc-input { border: 0; background: transparent; color: var(--muted); font-size: 12.5px; width: 100%; outline: none; padding: 2px 0; }
.title-input { border: 0; background: transparent; font-size: 13px; font-weight: 600; width: 100%; outline: none; padding: 2px 0; }
.radio-list { display: flex; flex-direction: column; gap: 8px; }
.radio-list label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.btn { background: var(--accent); color: var(--accent-ink); padding: 10px 16px; font-size: 12px; font-family: var(--mono); letter-spacing: .05em; text-transform: uppercase; }
.btn:hover { opacity: .88; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line-strong); }
.btn.danger { background: var(--neg); color: #fff; }
.btn-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.quote-box { background: var(--soft); padding: 14px 16px; display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.stat-row { display: flex; gap: 28px; margin-bottom: 16px; }
.stat-row .v { font-family: var(--mono); font-size: 15px; margin-top: 2px; }
.tbl { width: 100%; border-collapse: collapse; border: 1px solid var(--line); }
.tbl th { font-family: var(--mono); font-size: 10.5px; font-weight: 400; letter-spacing: .06em; color: var(--muted); text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); text-transform: uppercase; }
.tbl td { border-bottom: 1px solid var(--line); padding: 0; font-size: 13px; }
.tbl td input { border: 0; background: transparent; width: 100%; padding: 10px; outline: none; }
.tbl td.num, .tbl th.num { text-align: right; }
.tbl td.num input { text-align: right; }
.tbl td.txt { padding: 10px; }
.doc-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.doc { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--line); padding: 8px 12px; font-size: 13px; }

/* ---------- menus ---------- */
.menu { position: fixed; z-index: 60; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); min-width: 200px; padding: 6px 0; }
.menu button { display: block; width: 100%; text-align: left; padding: 9px 16px; font-size: 13px; }
.menu button:hover { background: var(--soft); }
.menu button small { display: block; color: var(--muted); font-size: 11px; }
.menu .sep { height: 1px; background: var(--line); margin: 4px 0; }
.menu button.danger { color: var(--neg); }
.menu .menu-title { padding: 6px 16px; }

/* ---------- recap ---------- */
.recap-head { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 14px; flex-wrap: wrap; gap: 10px; }
.recap-sel { display: flex; gap: 16px; flex-wrap: wrap; }
.dd { font-size: 17px; font-weight: 700; text-decoration: underline; text-underline-offset: 4px; display: inline-flex; align-items: center; gap: 4px; }
.dd::after { content: "⌄"; font-size: 12px; color: var(--muted); text-decoration: none; }
.recap-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--card); }
.recap { border-collapse: collapse; min-width: 100%; }
.recap th { font-family: var(--mono); font-size: 10.5px; font-weight: 600; text-align: right; padding: 10px 12px; white-space: nowrap; border-bottom: 1px solid var(--line); }
.recap th:first-child { text-align: left; position: sticky; left: 0; background: var(--card); }
.recap td { padding: 10px 12px; text-align: right; font-family: var(--mono); font-size: 12px; white-space: nowrap; border-bottom: 1px solid var(--line); }
.recap td:first-child { text-align: left; font-family: var(--font); font-size: 13px; position: sticky; left: 0; background: var(--card); max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.recap tr.lvl0 td { font-weight: 700; border-bottom: 2px solid var(--text); }
.recap tr.lvl1 td { font-weight: 600; }
.recap tr.lvl1 td:first-child { padding-left: 20px; }
.recap tr.lvl2 td:first-child { padding-left: 36px; }
.recap tr.lvl3 td:first-child { padding-left: 52px; color: var(--muted); }
.recap .chg { display: block; font-size: 10.5px; }
.toggle-btn { font-family: var(--mono); font-size: 10.5px; letter-spacing: .05em; border: 1px solid var(--line-strong); padding: 6px 10px; }
.toggle-btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- fast forward ---------- */
.ff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ff-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
.ff-card { background: var(--card); border: 1px solid var(--line); padding: 16px; }
.ff-when { font-family: var(--mono); font-size: 22px; font-weight: 300; margin-bottom: 4px; }
.ff-when small { font-size: 10px; color: var(--muted); margin-left: 4px; }
.scen-tabs { display: flex; gap: 22px; margin: 22px 0 10px; }
.scen-tab { border-left: 3px solid var(--line-strong); padding-left: 8px; text-align: left; opacity: .5; }
.scen-tab.on { opacity: 1; }
.scen-tab b { display: block; font-size: 12.5px; }
.scen-tab span { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.rules { background: var(--card); border: 1px solid var(--line); }
.rule { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 2; }
.rule select, .rule input { border: 0; border-bottom: 1px dashed var(--link); background: transparent; color: var(--link); padding: 0 2px; outline: none; font-size: 13px; }
.rule input { width: 90px; }
.rule input[type=date] { width: 130px; }
.rule input.w-s { width: 52px; }
.rule input.w-l { width: 140px; color: var(--text); border-bottom-color: var(--line-strong); }
.rule .grow { flex: 1; }

/* ---------- ownership ---------- */
.own-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.own-card { background: var(--card); border: 1px solid var(--line); padding: 16px 18px; }
.own-name { font-family: var(--mono); font-size: 18px; text-transform: uppercase; margin: 18px 0 6px; display: flex; justify-content: space-between; align-items: center; }
.bar-split { display: flex; height: 22px; margin: 10px 0; overflow: hidden; }
.bar-split div { display: grid; place-items: center; font-size: 10px; color: #fff; font-family: var(--mono); min-width: 0; overflow: hidden; }
.own-pct { display: grid; grid-template-columns: 1fr 80px 30px; gap: 8px; align-items: center; margin-bottom: 6px; }

/* ---------- portfolios / search ---------- */
.pf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.pf { border: 1.5px solid var(--text); aspect-ratio: 1.3; padding: 12px; display: flex; flex-direction: column; justify-content: flex-end; cursor: pointer; position: relative; text-align: left; }
.pf.on { background: var(--soft); box-shadow: 3px 3px 0 var(--text); }
.pf b { font-size: 13px; }
.pf span { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.pf.new { border-style: dashed; color: var(--muted); font-family: var(--mono); font-size: 11px; justify-content: center; align-items: center; }
.search-res { margin-top: 12px; max-height: 50vh; overflow-y: auto; }
.search-res button { display: flex; justify-content: space-between; width: 100%; padding: 10px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.search-res button:hover { background: var(--soft); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--accent); color: var(--accent-ink); padding: 10px 16px; font-size: 13px; z-index: 120; box-shadow: var(--shadow); }
.banner { background: var(--soft); border: 1px solid var(--line); padding: 10px 14px; font-size: 12.5px; margin-bottom: 14px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-nav { display: flex; gap: 4px; overflow-x: auto; padding: 0 16px 8px; scrollbar-width: none; position: sticky; top: calc(62px + var(--banner-h)); z-index: 4; background: var(--bg); }
  .mobile-nav a { white-space: nowrap; padding: 6px 10px; border-radius: 999px; background: var(--soft); color: var(--text); text-decoration: none; font-size: 12.5px; }
  .mobile-nav a.active { background: var(--accent); color: var(--accent-ink); }
  .topbar { padding: 14px 16px; justify-content: space-between; }
  .topbar .brand { padding: 0; }
  .topbar .brand-zh { display: none; }
  .view { padding: 8px 16px 80px; }
  .dash-top { grid-template-columns: 1fr 1fr; }
  .dash-top .nw-card { grid-column: span 2; grid-row: auto; }
  .chart-cards, .own-grid, .ff-grid { grid-template-columns: 1fr; }
  .ff-grid3 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .row, .col-head { grid-template-columns: 1fr 110px 50px; }
  .modal { padding: 22px 18px 24px; }
  .row2, .row3 { grid-template-columns: 1fr; }
}
@media (min-width: 861px) { .topbar .brand { display: none; } }
.legend .tgt { font-size: 10.5px; color: var(--muted); margin: -3px 0 2px 18px; font-family: var(--mono); }
.broker-tag { display: inline-block; font-family: var(--font); font-size: 10.5px; color: var(--text); background: var(--soft); border: 1px solid var(--line); border-radius: 3px; padding: 0 6px; line-height: 16px; }
.broker-line { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.broker-head { font-weight: 600; font-size: 13px; flex: 1; padding: 2px 0; }
.sheet-tools { display: flex; justify-content: flex-end; margin: -8px 0 12px; }
.sync { font-family: var(--mono); font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.sync.ok { color: var(--pos); }
.sync.saving { color: var(--muted); }
.sync.err { color: var(--neg); }

/* ---------- 示範版新功能 ---------- */
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--neg); color: #fff; font-size: 10.5px; line-height: 18px; text-align: center; font-family: var(--mono); }
.icon-btn.on { background: var(--accent); color: var(--accent-ink); }
.icon-btn svg { display: block; }
.btn.sm { padding: 6px 10px; font-size: 10.5px; }
.link.plain { color: inherit; text-decoration: none; font: inherit; }
.link.plain:hover { text-decoration: underline; }
.sub { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.sub.warn, .warn { color: var(--warn); }
button.sub { display: block; margin-left: auto; }

/* 總覽：收入及每月更新 */
.dash-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); margin-top: 16px; }
.strip-card { background: var(--card); padding: 14px 18px; display: flex; flex-direction: column; gap: 4px; color: var(--text); text-decoration: none; }
.strip-card:hover { background: var(--row-hover); }
.strip-card b { font-size: 20px; font-weight: 500; }
.strip-card b sup { font-size: .5em; vertical-align: super; }
.strip-card .muted { font-size: 12px; }

/* 收入日曆 */
.inc-top { grid-template-columns: repeat(3, 1fr); margin-bottom: 14px; }
.inc-row { display: grid; grid-template-columns: 78px 1fr auto 110px; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.inc-row.due { background: color-mix(in srgb, var(--warn) 7%, transparent); }
.inc-row.confirmed .inc-amt, .inc-row.skipped .inc-main, .inc-row.skipped .inc-amt { color: var(--muted); }
.inc-row.skipped .inc-amt { text-decoration: line-through; }
.inc-date b { display: block; font-size: 13px; font-weight: 600; }
.inc-date span { font-size: 11px; color: var(--muted); }
.inc-main { min-width: 0; font-size: 13px; }
.inc-ic { margin-right: 6px; }
.inc-amt { text-align: right; font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.inc-act { text-align: right; font-size: 12px; }

/* 每月更新 */
.upd-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 4px 0 10px; }
.upd-prog { text-align: right; white-space: nowrap; }
.upd-prog b { display: block; font-size: 24px; font-weight: 500; font-family: var(--mono); }
.upd-prog span { font-size: 11px; color: var(--muted); }
.prog-bar { height: 4px; background: var(--line); margin-bottom: 18px; }
.prog-bar div { height: 100%; background: var(--pos); transition: width .3s; }
.upd-row { display: grid; grid-template-columns: 1fr auto 90px; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.upd-row.done { opacity: .6; }
.upd-name { min-width: 0; font-size: 13.5px; }
.upd-fields { display: flex; gap: 8px; }
.upd-in { display: flex; flex-direction: column; gap: 2px; width: 150px; }
.upd-in .input { padding: 6px 8px; text-align: right; }
.upd-fields > .input { width: 150px; }
.upd-act { text-align: right; font-size: 12px; }

/* 總回報分拆 */
.rb-total { font-family: var(--mono); font-size: 14px; }
.rb-row { display: grid; grid-template-columns: 170px 1fr 130px; gap: 12px; align-items: center; padding: 7px 0; font-size: 13px; }
.rb-row.muted { color: var(--muted); }
.rb-l small { display: block; font-size: 11px; color: var(--muted); }
.rb-bar { height: 8px; background: var(--soft); position: relative; }
.rb-bar span { position: absolute; top: 0; bottom: 0; left: 0; }
.rb-bar .up { background: var(--pos); }
.rb-bar .down { background: var(--neg); }
.rb-row.muted .rb-bar span { opacity: .4; }
.rb-v { text-align: right; font-family: var(--mono); font-size: 12.5px; }

/* 提示橫額同標籤 */
.banner small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.warn-banner { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, var(--card)); }
.rough-banner { flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--card); }
.chip:hover { border-color: var(--text); }
.risk-tag, .rough-tag { display: inline-block; font-family: var(--font); font-size: 10.5px; border-radius: 3px; padding: 0 6px; line-height: 16px; }
.risk-tag { color: #fff; background: var(--warn); }
.rough-tag { color: var(--muted); border: 1px dashed var(--line-strong); }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

@media (max-width: 860px) {
  .topbar > div { gap: 4px !important; }
  .topbar [data-act="share"] { display: none; }
  .topbar .pill[data-act="portfolios"] { max-width: 84px; overflow: hidden; text-overflow: ellipsis; display: block; }
  .inc-top { grid-template-columns: 1fr 1fr; }
  .inc-top .card:first-child { grid-column: 1 / 3; }
  .inc-top .big { font-size: 20px; }
  .inc-row { grid-template-columns: 62px 1fr auto; }
  .inc-act { grid-column: 2 / 4; display: flex; gap: 12px; justify-content: flex-end; align-items: center; }
  .inc-act button.sub { margin-left: 0; }
  .upd-row { grid-template-columns: 1fr auto; }
  .upd-fields { grid-column: 1 / 3; order: 3; }
  .upd-in, .upd-fields > .input { width: auto; flex: 1; }
  .rb-row { grid-template-columns: 110px 1fr 100px; }
  .dash-strip { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: 1fr; }
  .upd-head { flex-direction: column; align-items: flex-start; }
}
