/* Fendure Finance app styles. Tokens: docs/PRD.md §7.2 (light) and §7.6 (dark). Derived from docs/mockup/mockup.css; grows slice by slice. */
:root {
  color-scheme:light dark;
  --blue:#4772FA; --accent:#4772FA; --on-blue:#FFFFFF; --ink:rgba(0,0,0,.85); --sub:rgba(0,0,0,.55);
  --line:rgba(0,0,0,.07); --bg:#FFFFFF; --raise:#FFFFFF; --soft:#F7F7F7; --thumb:#FFFFFF;
  --up:#1E7E34; --down:#D92D20; --stale-bg:#FEF6E0; --stale-ink:#B54708;
  --chev:rgba(0,0,0,.2); --inp:rgba(0,0,0,.14); --ring:rgba(71,114,250,.18); --nav-on:rgba(71,114,250,.08);
  --area:rgba(71,114,250,.08); --dim:rgba(0,0,0,.35); --thumb-shadow:0 1px 2px rgba(0,0,0,.08); --sheet-edge:none;
}
/* dark: follows the system only, no in-app switch (PRD §7.6) */
@media (prefers-color-scheme:dark) {
  :root {
    --blue:#4772FA; --accent:#A9C2FF; --on-blue:#FFFFFF; --ink:#F5F5F7; --sub:#8E8E96;
    --line:rgba(255,255,255,.09); --bg:#101012; --raise:#17171B; --soft:#222228; --thumb:#3A3A42;
    --up:#7BD88F; --down:#FF9D94; --stale-bg:rgba(232,147,12,.22); --stale-ink:#FFC95C;
    --chev:rgba(255,255,255,.28); --inp:rgba(255,255,255,.34); --ring:rgba(71,114,250,.35); --nav-on:rgba(71,114,250,.20);
    --area:rgba(71,114,250,.16); --dim:rgba(0,0,0,.6); --thumb-shadow:none; --sheet-edge:inset 0 0 0 1px rgba(255,255,255,.09);
  }
}
* { box-sizing:border-box; margin:0; padding:0; -webkit-tap-highlight-color:transparent; }
/* S5: .card's display:block would otherwise override the hidden attribute (cards stayed visible). */
[hidden] { display:none !important; }
html, body { overflow-x:hidden; }
body { background:var(--bg); color:var(--ink); font-family:-apple-system,"PingFang SC","Microsoft YaHei","Noto Sans CJK SC",sans-serif; font-size:15px; line-height:1.45; }
a { color:inherit; text-decoration:none; }
.num { font-variant-numeric:tabular-nums; white-space:nowrap; }
.up { color:var(--up); } .down { color:var(--down); } .sub { color:var(--sub); }

/* shell */
.side { display:none; }
.tabs { position:fixed; left:0; right:0; bottom:0; background:var(--raise); border-top:1px solid var(--line); display:flex; padding-bottom:env(safe-area-inset-bottom); z-index:5; }
.tabs a { flex:1; padding:7px 0 6px; font-size:11px; color:var(--sub); display:flex; flex-direction:column; align-items:center; gap:2px; }
.tabs a.on, .side a.on { color:var(--accent); }
main { padding:0 0 calc(76px + env(safe-area-inset-bottom)); max-width:1080px; }
.top { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:16px 16px 6px; }
.top h1 { font-size:20px; font-weight:600; }
.top .back { color:var(--sub); font-size:14px; display:flex; align-items:center; gap:2px; }
.btn { border:none; background:var(--blue); color:var(--on-blue); border-radius:10px; padding:9px 14px; font-size:14px; font-family:inherit; cursor:pointer; white-space:nowrap; }
.btn.ghost { background:none; color:var(--accent); padding:9px 0; }
.demo { margin:8px 16px 0; padding:7px 10px; background:var(--soft); border-radius:8px; color:var(--sub); font-size:12px; }

/* overview */
.hero { padding:18px 16px 6px; }
.hero .lbl { color:var(--sub); font-size:13px; }
.hero .nw { font-size:34px; font-weight:600; letter-spacing:-.5px; line-height:1.2; margin-top:2px; }
.hero .al { margin-top:6px; font-size:13px; color:var(--sub); display:flex; gap:14px; flex-wrap:wrap; }
.card { margin:12px 16px 0; border:1px solid var(--line); border-radius:12px; overflow:hidden; display:block; }
.card h2 { font-size:13px; font-weight:400; color:var(--sub); padding:12px 14px 2px; display:flex; justify-content:space-between; gap:8px; }
.kv { display:flex; justify-content:space-between; align-items:baseline; gap:12px; padding:10px 14px; border-top:1px solid var(--line); }
.card h2 + .kv { border-top:none; }
.kv .k { min-width:0; }
.kv .k small, .kv .v small { display:block; color:var(--sub); font-size:12px; }
.kv .v { text-align:right; font-weight:600; }
.kv .v small { font-weight:400; }
.stock .big { padding:4px 14px 2px; font-size:22px; font-weight:600; }
.stock .line { padding:0 14px 12px; font-size:13px; color:var(--sub); }
/* quote status (PRD §7.3): last successful fetch time; refusal notice reuses the stale-tag pair, no new colour */
.stock .line.q { margin-top:-6px; font-size:12px; }
.stock .refused { margin:6px 14px 4px; padding:6px 10px; border-radius:8px; background:var(--stale-bg); color:var(--stale-ink); font-size:12px; }
/* day-end job unfinished (PRD §7.3): same stale-tag pair, sits under the net-worth block */
.dayend { margin:8px 16px 0; padding:6px 10px; border-radius:8px; background:var(--stale-bg); color:var(--stale-ink); font-size:12px; line-height:1.5; }
.foot { margin:14px 16px 0; color:var(--sub); font-size:12px; line-height:1.6; }

/* accounts */
.grp { margin-top:10px; }
.grp-h { display:flex; align-items:baseline; justify-content:space-between; gap:8px; padding:12px 16px 4px; }
.grp-h h2 { font-size:16px; font-weight:600; }
.grp-h span { font-size:13px; color:var(--sub); }
.row { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:11px 16px; border-bottom:1px solid var(--line); }
.row .l { min-width:0; flex:1; }
.row .nm { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.row .meta { color:var(--sub); font-size:12px; margin-top:2px; display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.row .amt { font-weight:600; text-align:right; }
.row .chev { color:var(--chev); flex:none; }
.stale { background:var(--stale-bg); color:var(--stale-ink); border-radius:9px; padding:1px 7px; font-size:11px; }

/* stocks */
.sum { padding:14px 16px 4px; }
.sum .tot { font-size:28px; font-weight:600; letter-spacing:-.3px; }
.sum .two { display:flex; gap:20px; margin-top:6px; font-size:13px; flex-wrap:wrap; }
.sum .two b { font-weight:600; }
.sum .asof { margin-top:6px; color:var(--sub); font-size:12px; }
.hold { display:block; padding:12px 16px; border-bottom:1px solid var(--line); }
.hold .r1 { display:flex; justify-content:space-between; gap:12px; font-weight:600; }
.hold .r2 { margin-top:3px; font-size:12px; color:var(--sub); }
.hold .r2 .pl { display:flex; justify-content:space-between; gap:12px; margin-top:5px; font-size:13px; }
.thead { display:none; }
/* S3: split hint note under a holding row (PRD §5.1) */
.holdnote { padding:2px 16px 10px; color:var(--stale-ink); font-size:12px; }

/* sheet / dialog */
.dim { position:fixed; inset:0; background:var(--dim); z-index:30; display:flex; align-items:flex-end; justify-content:center; }
.sheet { background:var(--raise); box-shadow:var(--sheet-edge); width:100%; border-radius:16px 16px 0 0; padding:18px 20px calc(18px + env(safe-area-inset-bottom)); }
.sheet h3 { font-size:17px; font-weight:600; }
.sheet .hint { color:var(--sub); font-size:12px; margin-top:4px; }
.fld { margin-top:14px; }
.fld label { display:block; font-size:12px; color:var(--sub); margin-bottom:5px; }
.inp { display:flex; align-items:center; border:1px solid var(--inp); border-radius:10px; padding:0 12px; height:46px; gap:8px; }
.inp.focus { border-color:var(--blue); box-shadow:0 0 0 2px var(--ring); }
.inp .pre { color:var(--sub); }
.inp .val { flex:1; font-size:17px; font-variant-numeric:tabular-nums; }
.inp .suf { color:var(--sub); font-size:13px; }
.seg { display:flex; background:var(--soft); border-radius:10px; padding:3px; gap:3px; }
.seg span { flex:1; text-align:center; padding:8px 0; border-radius:8px; font-size:14px; color:var(--sub); }
.seg span.on { background:var(--thumb); color:var(--ink); font-weight:600; box-shadow:var(--thumb-shadow); }
.acts { display:flex; gap:10px; margin-top:20px; }
.acts .btn { flex:1; padding:13px; font-size:15px; }
.acts .btn.sec { background:var(--soft); color:var(--ink); }
.danger { display:block; text-align:center; margin-top:14px; color:var(--down); font-size:13px; }

/* desktop */
@media (min-width:900px) {
  body { display:flex; }
  .tabs { display:none; }
  .side { display:flex; flex-direction:column; gap:4px; width:200px; flex:none; min-height:100vh; border-right:1px solid var(--line); padding:20px 12px; position:sticky; top:0; align-self:flex-start; }
  .side .brand { font-size:16px; font-weight:600; padding:4px 10px 16px; }
  .side a { display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:8px; color:var(--sub); font-size:14px; }
  .side a.on { background:var(--nav-on); }
  main { flex:1; padding:8px 24px 48px; }
  .hero .nw { font-size:40px; }
  .cols { display:grid; grid-template-columns:1fr 1fr; gap:0 8px; align-items:start; }
  .row:hover, .hold:hover { background:var(--soft); }
  .thead { display:grid; padding:8px 16px; color:var(--sub); font-size:12px; border-bottom:1px solid var(--line); }
  .thead, .hold { grid-template-columns:1.1fr .7fr 1fr 1.2fr 1.5fr 1.5fr; gap:12px; text-align:right; }
  .thead span:first-child, .hold .c1 { text-align:left; }
  .hold { display:grid; align-items:center; }
  .hold .r1, .hold .r2, .hold .r2 .pl { display:contents; }
  .hold .r2 { font-size:15px; color:var(--ink); }
  .hold .m-only { display:none; }
  .hold .mv { font-weight:600; }
  .dim { align-items:center; }
  .sheet { width:440px; border-radius:16px; padding:24px; }
}
@media (max-width:899px) { .d-only { display:none; } }
.hold .l2 { display:flex; gap:5px; }
@media (min-width:900px) {
  .hold .l2 { display:contents; }
  .hold .c1 { order:1; } .hold .sh { order:2; } .hold .px { order:3; } .hold .mv { order:4; } .hold .dy { order:5; } .hold .cu { order:6; }
}

/* net-worth trend (PRD §5.4) */
.trend h2 { align-items:center; }
.trend .rng { display:flex; gap:2px; background:var(--soft); border-radius:8px; padding:2px; font-size:12px; }
.trend .rng span { padding:3px 9px; border-radius:6px; white-space:nowrap; }
.trend .rng span.on { background:var(--thumb); color:var(--ink); font-weight:600; box-shadow:var(--thumb-shadow); }
.trend .cv { position:relative; margin:10px 14px 0; height:120px; }
.trend .curve { display:block; width:100%; height:120px; }
.trend .curve polyline { stroke:var(--blue); }
.trend .curve polygon { fill:var(--area); }
.trend .dot { position:absolute; right:-4px; top:4px; width:8px; height:8px; border-radius:50%; background:var(--blue); box-shadow:0 0 0 3px var(--ring); }
.trend .ax { display:flex; justify-content:space-between; gap:12px; padding:6px 14px 0; font-size:12px; color:var(--sub); }
.trend .ax small { display:block; font-size:12px; color:var(--ink); }
.trend .line { padding:8px 14px 12px; font-size:12px; color:var(--sub); }

/* settings */
.set { max-width:560px; }
.set .pad { padding:8px 14px 14px; }
.set .hint { color:var(--sub); font-size:12px; margin-top:8px; }
.set .card .row:last-child { border-bottom:none; }

/* login (PRD §3.2, §6.2): one password field, one button, no nav */
body.login { display:block; }
body.login main { max-width:none; padding:0 0 48px; }
.lg { max-width:360px; margin:18vh auto 0; padding:0 20px; }
.lg .brand { font-size:20px; font-weight:600; text-align:center; margin-bottom:22px; }
.lg .inp .val { letter-spacing:2px; }
.lg .btn { display:block; text-align:center; margin-top:16px; padding:13px; font-size:15px; }
.lg .hint { color:var(--sub); font-size:12px; text-align:center; margin-top:12px; }

/* S5: overview loading placeholders (grey blocks, no spinner, PRD §7.3), long-amount shrink,
   the no-FX sentence size, the no-quote note under the net worth, real <button>s in the range
   switch (mockup used <span>s), chart end-dot drawn inside the SVG, settings error colour. */
.skel { background:var(--soft); border-radius:8px; height:14px; margin-top:10px; }
.skel.big { height:40px; margin-top:6px; }
.hero .nw.long { font-size:28px; }
.hero .nw.nofx { font-size:20px; line-height:1.35; }
.hero .note { margin-top:6px; font-size:12px; color:var(--sub); }
@media (min-width:900px) { .hero .nw.long { font-size:34px; } .hero .nw.nofx { font-size:24px; } }
.trend .rng button { border:none; background:none; font-family:inherit; font-size:12px; padding:3px 9px; border-radius:6px; white-space:nowrap; color:var(--sub); cursor:pointer; }
.trend .rng button.on { background:var(--thumb); color:var(--ink); font-weight:600; box-shadow:var(--thumb-shadow); }
.trend .curve circle.halo { fill:var(--ring); }
.trend .curve circle.dotc { fill:var(--blue); }
#base-error, #password-error { color:var(--down); }

/* S1: the real login page uses a <button> (the mockup used an <a>); keep it full-width like the mockup. */
.lg button.btn { width:100%; }
.lg #error { color:var(--down); }

/* S2: segment controls are real <button>s (the mockup used <span>s); same look as .seg span. */
.seg button { flex:1; text-align:center; padding:8px 0; border:none; background:none; border-radius:8px; font-size:14px; font-family:inherit; color:var(--sub); cursor:pointer; }
.seg button.on { background:var(--thumb); color:var(--ink); font-weight:600; box-shadow:var(--thumb-shadow); }
.seg button:disabled { cursor:default; }
/* S2: the form pages (new-account, edit-balance) reuse the sheet look as a standalone page. */
.formpage { max-width:440px; margin:0 auto; }
.formpage .sheet { border:1px solid var(--line); border-radius:16px; margin:16px 16px 0; }
@media (max-width:899px) { .formpage .sheet { margin:0; border:none; border-radius:0; } }
.sheet #error { color:var(--down); }
