/* Portfolio Live — styles ported from reference/portfolio-widget.html (lines 8–264).
   Changes against the widget (review findings, "fix issues, keep the look"):
   - UX-03 contrast: same hues, small lightness shifts (--ink-3, light --gain/--loss/--warn/--accent), plus
     --accent-ink (accent text on --accent-soft) and --accent-strong (filled buttons, active chip/segment).
   - UX-21 --field-border for inputs/selects/segments; UX-16 color-scheme per theme.
   - BUG-4: the thead "position:sticky;top:0" rule never stuck (the .tablewrap scroller has no height) and is removed.
   - Sold rows: opacity on the row (.9) instead of each cell (.78), so the sticky first column stays opaque.
   App-specific additions are in the block before the shared block at the end. */
:root{
  --bg:#0e1320; --panel:#151b2b; --panel-2:#1b2333; --border:#28324a;
  --ink:#e8ecf6; --ink-2:#9aa7bd; --ink-3:#7c8aa3;
  --accent:#5b8def; --accent-soft:#20304f; --accent-ink:#6997f0; --accent-strong:#3170eb;
  --gain:#2ed58a; --gain-soft:#123527;
  --loss:#ff5f6e; --loss-soft:#3a1620;
  --warn:#ffb020;
  --field-border:#64728e; --danger-strong:#c92737;
  --shadow:0 10px 30px rgba(0,0,0,.45);
  --radius:14px;
  --mono:'SF Mono',ui-monospace,'Cascadia Code','JetBrains Mono',Menlo,Consolas,monospace;
  --sans:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,system-ui,sans-serif;
  color-scheme:dark;
}
:root[data-theme="light"]{
  --bg:#f3f5fa; --panel:#ffffff; --panel-2:#f5f7fc; --border:#dfe4ee;
  --ink:#1a2232; --ink-2:#54617a; --ink-3:#62718a;
  --accent:#1e5eea; --accent-soft:#e2ebff; --accent-ink:#1e5eea; --accent-strong:#1e5eea;
  --gain:#0c7c46; --gain-soft:#dff5e9;
  --loss:#c92737; --loss-soft:#fbe3e6;
  --warn:#9d6209;
  --field-border:#808ca1;
  --shadow:0 8px 24px rgba(30,50,90,.12);
  color-scheme:light;
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{background:var(--bg);color:var(--ink);font-family:var(--sans);-webkit-font-smoothing:antialiased;font-size:14px;line-height:1.45;padding:14px;min-height:100vh}
.app{max-width:1180px;margin:0 auto;display:flex;flex-direction:column;gap:14px}
.topbar{display:flex;align-items:center;gap:12px;flex-wrap:wrap;background:var(--panel);border:1px solid var(--border);border-radius:var(--radius);padding:12px 16px;box-shadow:var(--shadow)}
.brand{display:flex;align-items:center;gap:10px;font-weight:700;font-size:16px;letter-spacing:.2px}
.brand .logo{width:30px;height:30px;border-radius:9px;flex:0 0 auto;background:linear-gradient(135deg,var(--accent),#8a5bef);display:grid;place-items:center;color:#fff;font-size:15px}
.status{display:flex;align-items:center;gap:7px;color:var(--ink-2);font-size:12.5px}
.dot{width:8px;height:8px;border-radius:50%;background:var(--ink-3);flex:0 0 auto}
.dot.live{background:var(--gain);box-shadow:0 0 0 3px var(--gain-soft)}
.dot.err{background:var(--loss);box-shadow:0 0 0 3px var(--loss-soft)}
.dot.load{background:var(--warn);box-shadow:0 0 0 3px rgba(255,176,32,.18);animation:pulse 1s infinite}
@keyframes pulse{50%{opacity:.35}}
.spacer{flex:1 1 auto}
.countdown{font-family:var(--mono);font-size:12px;color:var(--ink-2);min-width:80px;text-align:right}
.iconbtn{background:var(--panel-2);border:1px solid var(--border);color:var(--ink);width:34px;height:34px;border-radius:9px;cursor:pointer;display:grid;place-items:center;font-size:15px;transition:.15s}
.iconbtn:hover{border-color:var(--accent);color:var(--accent)}
.btn{background:var(--accent-strong);color:#fff;border:none;border-radius:9px;padding:8px 14px;font-weight:600;cursor:pointer;font-size:13px;transition:.15s;white-space:nowrap}
.btn:hover{filter:brightness(1.08)}
.btn.ghost{background:var(--panel-2);color:var(--ink);border:1px solid var(--border)}
.btn.ghost:hover{border-color:var(--accent)}
.kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:12px}
.kpi{background:var(--panel);border:1px solid var(--border);border-radius:var(--radius);padding:14px 16px;box-shadow:var(--shadow);position:relative;overflow:hidden}
.kpi .label{color:var(--ink-2);font-size:11.5px;text-transform:uppercase;letter-spacing:.7px;font-weight:600}
.kpi .val{font-family:var(--mono);font-size:23px;font-weight:600;margin-top:6px;letter-spacing:-.3px}
.kpi .sub{font-size:12.5px;margin-top:3px;font-family:var(--mono)}
.kpi .accentbar{position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--accent)}
.pos{color:var(--gain)} .neg{color:var(--loss)} .flat{color:var(--ink-2)}
.accentbar.pos{background:var(--gain)} .accentbar.neg{background:var(--loss)}
.panel{background:var(--panel);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow);overflow:hidden}
.panel-head{display:flex;align-items:center;gap:10px;padding:13px 16px;border-bottom:1px solid var(--border);flex-wrap:wrap}
.tabs{flex-wrap:wrap}
.panel-head h2{font-size:14px;font-weight:700}
.panel-head .muted{color:var(--ink-3);font-size:12px;font-weight:500}
.tabs{display:flex;gap:4px}
.tab{background:transparent;border:none;color:var(--ink-2);font-weight:700;font-size:13px;padding:5px 11px;border-radius:8px;cursor:pointer;transition:.12s}
.tab:hover{color:var(--ink)}
.tab.on{background:var(--panel-2);color:var(--ink)}
.divsum{display:flex;gap:22px;flex-wrap:wrap;padding:13px 16px;border-bottom:1px solid var(--border);background:var(--panel-2)}
.divsum .it{display:flex;flex-direction:column}
.divsum .k{font-size:10.5px;text-transform:uppercase;letter-spacing:.5px;color:var(--ink-3);font-weight:600}
.divsum .v{font-family:var(--mono);font-size:17px;font-weight:600;margin-top:3px}
.divsum .it .sub2{margin-top:2px}
.yrwrap{padding:12px 16px 14px;border-bottom:1px solid var(--border)}
.yrhead{font-size:10.5px;text-transform:uppercase;letter-spacing:.5px;color:var(--ink-3);font-weight:700;margin-bottom:6px}
.yrtbl{width:auto;min-width:460px;font-size:12.5px}
.yrtbl thead th{position:static;cursor:default;background:transparent;padding:4px 22px 6px 0;text-align:right}
.yrtbl thead th:first-child,.yrtbl tbody td:first-child,.yrtbl tfoot td:first-child{text-align:left}
.yrtbl tbody td{padding:5px 22px 5px 0;border-bottom:1px solid var(--border);text-align:right}
.yrtbl tbody tr:hover{background:transparent}
.yrtbl tfoot td{padding:6px 22px 6px 0;background:transparent;border-top:1px solid var(--border);text-align:right}
.yrwrap .note{margin-top:8px}
.tablewrap{overflow-x:auto}
table{width:100%;border-collapse:collapse;font-size:13px}
thead th{text-align:right;padding:9px 12px;color:var(--ink-2);font-weight:600;font-size:11px;text-transform:uppercase;letter-spacing:.5px;border-bottom:1px solid var(--border);white-space:nowrap;cursor:pointer;user-select:none;background:var(--panel)}
thead th:first-child{text-align:left}
thead th .arw{opacity:.4;font-size:9px}
thead th.sorted .arw{opacity:1;color:var(--accent)}
tbody td{padding:11px 12px;text-align:right;border-bottom:1px solid var(--border);white-space:nowrap;vertical-align:middle}
tbody td:first-child{text-align:left}
tbody tr:last-child td{border-bottom:none}
tbody tr:hover{background:var(--panel-2)}
.num{font-family:var(--mono);letter-spacing:-.2px}
.asset{display:flex;align-items:center;gap:10px}
.sym{font-weight:700;font-size:14px}
.sub2{color:var(--ink-3);font-size:11px;margin-top:1px}
.badge{font-size:9.5px;font-weight:700;letter-spacing:.5px;padding:2px 6px;border-radius:5px;background:var(--accent-soft);color:var(--accent-ink);text-transform:uppercase;flex:0 0 auto}
.badge.cx{background:#3a2a12;color:#f4a63a}
:root[data-theme="light"] .badge.cx{background:#fdeccb;color:#936209}
.badge.sd{background:#2a3242;color:var(--ink-2)}
:root[data-theme="light"] .badge.sd{background:#e6eaf2;color:var(--ink-2)}
.chg{display:inline-flex;align-items:center;gap:3px;justify-content:flex-end;font-size:12px}
.plcell{font-weight:600}
.wbar{height:6px;border-radius:4px;background:var(--panel-2);overflow:hidden;width:64px;display:inline-block;vertical-align:middle}
.wbar>i{display:block;height:100%;background:var(--accent);border-radius:4px}
.rowbtns{display:inline-flex;gap:4px}
.rowbtns button{background:transparent;border:1px solid transparent;color:var(--ink-3);width:26px;height:26px;border-radius:7px;cursor:pointer;font-size:13px;transition:.12s}
.rowbtns button:hover{background:var(--panel-2);color:var(--ink);border-color:var(--border)}
.chev{display:inline-flex;align-items:center;justify-content:center;width:14px;color:var(--ink-3);font-size:10px;flex:0 0 auto}
tr.grp.clickable{cursor:pointer}
tr.grp.clickable:hover{background:var(--panel-2)}
tr.lot td{background:rgba(0,0,0,.16)}
:root[data-theme="light"] tr.lot td{background:rgba(30,50,90,.035)}
tr.lot td:first-child{padding-left:12px}
tr.lot:hover td{background:rgba(0,0,0,.22)}
:root[data-theme="light"] tr.lot:hover td{background:rgba(30,50,90,.05)}
tfoot td{padding:11px 12px;text-align:right;font-family:var(--mono);font-weight:700;border-top:2px solid var(--border);background:var(--panel-2)}
tfoot td:first-child{text-align:left;font-family:var(--sans)}
.empty{padding:40px 20px;text-align:center;color:var(--ink-2)}
.empty .big{font-size:34px;margin-bottom:8px}
.empty h3{color:var(--ink);font-size:15px;margin-bottom:5px}
.empty p{font-size:13px;max-width:440px;margin:0 auto 14px}
.banner{display:none;align-items:center;gap:10px;padding:10px 16px;font-size:13px;background:var(--loss-soft);color:var(--loss);border-bottom:1px solid var(--border)}
.banner.show{display:flex}
.banner.warn{background:rgba(255,176,32,.12);color:var(--warn)}
.banner.info{background:var(--accent-soft);color:var(--accent-ink)}
.overlay{position:fixed;inset:0;background:rgba(4,8,16,.62);display:none;align-items:flex-start;justify-content:center;padding:28px 14px;z-index:50;overflow-y:auto;backdrop-filter:blur(2px)}
.overlay.show{display:flex}
.modal{background:var(--panel);border:1px solid var(--border);border-radius:16px;width:100%;max-width:440px;box-shadow:var(--shadow);margin:auto 0}
.modal-head{display:flex;align-items:center;justify-content:space-between;padding:16px 18px;border-bottom:1px solid var(--border)}
.modal-head h3{font-size:15px}
.modal-body{padding:18px}
.field{margin-bottom:14px}
.field label{display:block;font-size:12px;color:var(--ink-2);font-weight:600;margin-bottom:6px}
.field .hint{font-size:11px;color:var(--ink-3);margin-top:5px;line-height:1.4}
input,select{width:100%;background:var(--panel-2);border:1px solid var(--field-border);border-radius:9px;color:var(--ink);padding:9px 11px;font-size:13.5px;font-family:var(--sans);transition:.15s}
input:focus,select:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
input.num,select{font-family:var(--mono)}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.seg{display:flex;background:var(--panel-2);border:1px solid var(--field-border);border-radius:9px;padding:3px;gap:3px}
.seg button{flex:1;background:transparent;border:none;color:var(--ink-2);padding:7px;border-radius:6px;cursor:pointer;font-weight:600;font-size:12.5px;transition:.12s}
.seg button.on{background:var(--accent-strong);color:#fff}
.modal-foot{display:flex;gap:10px;justify-content:flex-end;padding:14px 18px;border-top:1px solid var(--border)}
.keyrow{display:flex;gap:8px}
.keyrow input{flex:1}
.link{color:var(--accent);cursor:pointer;text-decoration:none}
.link:hover{text-decoration:underline}
.note{font-size:11.5px;color:var(--ink-3);line-height:1.5}
.foot-note{text-align:center;color:var(--ink-3);font-size:11.5px;padding:2px 0 6px}
.foot-note a{color:var(--ink-2)}
/* ---------- Dashboard ---------- */
.dash{padding:14px 16px 18px;display:flex;flex-direction:column;gap:14px}
.dbar{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.dbar .lbl{font-size:11px;text-transform:uppercase;letter-spacing:.6px;color:var(--ink-3);font-weight:700}
.pchips{display:flex;gap:3px;background:var(--panel-2);border:1px solid var(--border);border-radius:9px;padding:3px;flex-wrap:wrap}
.pchip{background:transparent;border:none;color:var(--ink-2);font-weight:700;font-size:12px;padding:5px 10px;border-radius:6px;cursor:pointer;font-family:var(--mono);transition:.12s}
.pchip:hover{color:var(--ink)}
.pchip.on{background:var(--accent-strong);color:#fff}
.dbar .hint2{font-size:11.5px;color:var(--ink-3)}
.dnote{font-size:12px;padding:9px 12px;border-radius:9px;background:var(--accent-soft);color:var(--accent-ink);line-height:1.45}
.dnote.err{background:var(--loss-soft);color:var(--loss)}
.dtiles{display:grid;grid-template-columns:1.25fr 1fr 1fr 1fr;gap:12px}
.dtile{background:var(--panel-2);border:1px solid var(--border);border-radius:12px;padding:12px 14px;min-width:0}
.dtile .k{font-size:10.5px;text-transform:uppercase;letter-spacing:.6px;color:var(--ink-3);font-weight:700}
.dtile .v{font-size:22px;font-weight:700;margin-top:4px;letter-spacing:-.3px;white-space:nowrap}
.dtile.hero .v{font-size:28px}
.dtile .s{font-size:11.5px;color:var(--ink-2);margin-top:3px}
.dtile .s2{font-size:11px;color:var(--ink-3);margin-top:5px;line-height:1.5}
.dtile .s2 b{font-family:var(--mono);font-weight:600;color:var(--ink-2)}
.dgrid2{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.dgrid2.wide-l{grid-template-columns:1.35fr 1fr}
.dcard{border:1px solid var(--border);border-radius:12px;padding:12px 14px 12px;min-width:0;background:var(--panel)}
.dcard .dh{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap;margin-bottom:8px}
.dcard .dh h3{font-size:13.5px;font-weight:700}
.dcard .dh .muted{color:var(--ink-3);font-size:11.5px}
.dcard .dh .lg{margin-left:auto;display:flex;gap:12px;font-size:11.5px;color:var(--ink-2)}
.lg .sw{display:inline-block;width:14px;height:2px;border-radius:2px;vertical-align:middle;margin-right:5px}
.lg .dt{display:inline-block;width:9px;height:9px;border-radius:50%;vertical-align:middle;margin-right:5px}
.lg .dt.hollow{background:transparent!important;border:2px solid var(--ink-2)}
.dcard .foot{font-size:11px;color:var(--ink-3);margin-top:6px;line-height:1.45}
.chart{width:100%;position:relative}
.chart svg{display:block;overflow:visible}
.chart .wait{height:200px;display:grid;place-items:center;color:var(--ink-3);font-size:12.5px;text-align:center;padding:0 20px}
svg .grid{stroke:var(--border);stroke-width:1;shape-rendering:crispEdges}
svg .base{stroke:var(--ink-3);stroke-width:1;shape-rendering:crispEdges}
svg .axt{fill:var(--ink-3);font-size:10.5px;font-family:var(--mono)}
svg .ln{fill:none;stroke-width:2;stroke-linejoin:round;stroke-linecap:round}
svg .ln.val{stroke:var(--accent)} svg .ln.inv{stroke:var(--ink-3)}
svg .ln.gain{stroke:var(--gain)} svg .ln.loss{stroke:var(--loss)}
svg .ar.gain{fill:var(--gain);opacity:.12} svg .ar.loss{fill:var(--loss);opacity:.12} svg .ar.val{fill:var(--accent);opacity:.08}
svg .xh{stroke:var(--ink-2);stroke-width:1;shape-rendering:crispEdges}
svg .hd{stroke:var(--panel);stroke-width:2}
svg .hd.val{fill:var(--accent)} svg .hd.inv{fill:var(--ink-3)} svg .hd.gain{fill:var(--gain)} svg .hd.loss{fill:var(--loss)}
svg .dot{stroke:var(--panel);stroke-width:2;transition:opacity .12s;pointer-events:none}
svg .dlbl,svg .axt{pointer-events:none}
svg .dot.gain{fill:var(--gain)} svg .dot.loss{fill:var(--loss)}
svg .dot.hollow{fill:var(--panel);stroke-width:2.5}
svg .dot.hollow.gain{stroke:var(--gain)} svg .dot.hollow.loss{stroke:var(--loss)}
svg .hit{fill:transparent;cursor:pointer;outline:none}
svg .hit:hover+.dot,svg .hit:focus+.dot{opacity:.75}
svg .dlbl{fill:var(--ink-2);font-size:10.5px;font-weight:700;font-family:var(--sans)}
.dtip{position:fixed;z-index:80;display:none;pointer-events:none;background:var(--panel);border:1px solid var(--border);border-radius:9px;box-shadow:var(--shadow);padding:8px 10px;font-size:12px;min-width:150px;max-width:280px}
.dtip .tt{color:var(--ink-2);font-size:11px;margin-bottom:5px;font-weight:600}
.dtip .tr{display:flex;align-items:center;gap:7px;margin-top:3px;white-space:nowrap}
.dtip .tr b{font-family:var(--mono);font-weight:700;color:var(--ink)}
.dtip .tr b.pos{color:var(--gain)} .dtip .tr b.neg{color:var(--loss)}
.dtip .tl{color:var(--ink-3);font-size:11px}
.dtip .lk{display:inline-block;width:12px;height:2px;border-radius:2px;flex:0 0 auto}
.lk.val,.sw.val{background:var(--accent)} .lk.inv,.sw.inv{background:var(--ink-3)} .lk.gain,.sw.gain,.dt.gain{background:var(--gain)} .lk.loss,.sw.loss,.dt.loss{background:var(--loss)}
/* performance matrix */
.mtx{font-size:12.5px}
.mtx thead th{cursor:pointer;text-align:right;padding:8px 10px}
.mtx thead th:first-child{cursor:default}
.mtx thead th.sel{color:var(--accent)}
.mtx thead th.na{cursor:default}
.mtx tbody td{padding:6px 10px;text-align:right}
.mtx thead th:first-child,.mtx tbody td:first-child{text-align:left}
.mtx td.c{font-family:var(--mono);line-height:1.25}
.mtx td.c .p{font-weight:700;color:var(--ink)}
.mtx td.c .d{font-size:10.5px;color:var(--ink-2)}
.mtx td.c.sel{box-shadow:inset 1px 0 0 var(--accent),inset -1px 0 0 var(--accent)}
.mtx tr.tot td{font-weight:700;border-bottom:2px solid var(--border)}
.mtx tr.tot td.c .p{font-size:13px}
.mtx tr.sold{opacity:.9}
/* allocation */
.alloc{display:flex;flex-direction:column;gap:7px}
.arow{display:grid;grid-template-columns:52px 1fr 92px;align-items:center;gap:10px;font-size:12px}
.arow .t{font-weight:700}
.arow .bar{height:10px;background:var(--panel-2);border-radius:2px 5px 5px 2px;overflow:hidden}
.arow .bar i{display:block;height:100%;background:var(--accent);border-radius:2px 5px 5px 2px}
.arow .bar i.big{background:var(--warn)}
.arow .n{text-align:right;font-family:var(--mono);color:var(--ink)}
.arow .n small{display:block;color:var(--ink-3);font-size:10.5px}
.tag{display:inline-flex;align-items:center;gap:4px;font-size:10px;font-weight:700;letter-spacing:.3px;padding:2px 6px;border-radius:5px;text-transform:uppercase}
.tag.warn{background:rgba(255,176,32,.14);color:var(--warn)}
.tag.good{background:var(--gain-soft);color:var(--gain)}
.tag.ok{background:var(--accent-soft);color:var(--accent-ink)}
.tag.meh{background:var(--panel-2);color:var(--ink-2);border:1px solid var(--border)}
.tag.bad{background:var(--loss-soft);color:var(--loss)}
.asum{display:flex;gap:16px;flex-wrap:wrap;font-size:11.5px;color:var(--ink-2);margin-bottom:10px}
.asum b{font-family:var(--mono);color:var(--ink)}
/* purchases */
.ptbl{font-size:12.5px}
.ptbl thead th{cursor:default;padding:8px 10px}
.ptbl tbody td{padding:8px 10px}
.rk{display:inline-grid;place-items:center;min-width:20px;height:20px;border-radius:6px;background:var(--panel-2);color:var(--ink-2);font-size:10.5px;font-weight:700;font-family:var(--mono);margin-right:8px}
.rng{display:inline-flex;align-items:center;gap:8px;justify-content:flex-end}
.rng .trk{position:relative;width:70px;height:6px;border-radius:4px;background:linear-gradient(90deg,var(--gain-soft),var(--panel-2) 50%,var(--loss-soft));border:1px solid var(--border)}
.rng .trk i{position:absolute;top:50%;width:10px;height:10px;margin:-5px 0 0 -5px;border-radius:50%;background:var(--ink);border:2px solid var(--panel)}
.morebtn{margin-top:8px}
/* monthly heatmap */
.hm{border-collapse:separate;border-spacing:3px;width:100%;font-size:11.5px}
.hm th{font-size:10.5px;color:var(--ink-3);font-weight:700;text-transform:uppercase;letter-spacing:.4px;padding:2px 4px;text-align:center;position:static;background:transparent;border:none;cursor:default}
.hm th:first-child{text-align:left}
.hm td{height:38px;border-radius:6px;text-align:center;font-family:var(--mono);font-weight:600;color:var(--ink);padding:0 2px;border:none;cursor:default}
.hm td.y{text-align:left;font-family:var(--sans);font-weight:700;color:var(--ink-2);padding-left:2px}
.hm td.e{background:transparent;color:var(--ink-3);font-weight:400}
.hm td.mtd{box-shadow:inset 0 0 0 1px var(--accent)}
.hm td.tot{font-weight:700;box-shadow:inset 0 0 0 1px var(--border)}
.hm td small{display:block;font-size:9.5px;font-weight:500;color:var(--ink-2)}
.hm tbody tr:hover{background:transparent}
.hmwrap{overflow-x:auto}
@media(max-width:980px){.dtiles{grid-template-columns:1fr 1fr}.dgrid2,.dgrid2.wide-l{grid-template-columns:1fr}}
@media(max-width:520px){.dtiles{grid-template-columns:1fr}}
@media(max-width:760px){.kpis{grid-template-columns:1fr 1fr}.kpi .val{font-size:20px}}
@media(max-width:460px){body{padding:10px}.grid2{grid-template-columns:1fr}}

/* ---------- App page (public/app.html) additions ---------- */
[hidden]{display:none!important}
.main{display:flex;flex-direction:column;gap:14px}
.skip-link{position:absolute;left:12px;top:-60px;z-index:100;background:var(--panel);color:var(--ink);border:1px solid var(--accent);border-radius:9px;padding:8px 12px;font-weight:600;text-decoration:none}
.skip-link:focus{top:12px}
/* keyboard focus (UX-02/05/12): a visible ring on every control; inputs keep their own focus ring */
button:focus-visible,a:focus-visible,[tabindex]:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.chev:focus-visible,.thsort:focus-visible{outline-offset:1px}
input[type=file]{padding:7px 9px;font-size:12.5px;cursor:pointer}
/* topbar: status + price freshness (UX-10); desktop keeps the widget order, phones get two rows (UX-14) */
.statusline{display:contents}
.spacer.ph{display:none}
.fresh{white-space:nowrap}
.dot.warn{background:var(--warn);box-shadow:0 0 0 3px rgba(255,176,32,.18)}
/* "Editing Anna's portfolio" (NEW-05): the banner itself is .managebar in components.css */
body.managing{box-shadow:inset 0 3px 0 var(--warn)}
/* buttons that look like the widget's text (UX-02: expand chevrons, sort headers) */
button.chev{background:none;border:0;padding:0;margin:0;height:18px;cursor:pointer;border-radius:4px;font-family:inherit}
button.chev:hover{color:var(--ink)}
.thsort{background:none;border:0;padding:0;margin:0;font:inherit;color:inherit;letter-spacing:inherit;text-transform:inherit;cursor:pointer;white-space:nowrap;border-radius:4px}
.btn.danger{background:var(--danger-strong)}
.btn:disabled,.rowbtns button:disabled{opacity:.5;cursor:default;filter:none}
.tab.on{box-shadow:inset 0 -2px 0 var(--accent)}
.flabel{display:block;font-size:12px;color:var(--ink-2);font-weight:600;margin-bottom:6px}
.daterow{display:flex;gap:10px;align-items:center}
.daterow input{flex:1;min-width:0}
.modal-body p.setline{font-size:13.5px;color:var(--ink);margin-bottom:2px}
.modal-body p.hint,.modal-body p.confirm-text{margin-bottom:0}
.setfield-last{margin-bottom:0}
.confirm-text{font-size:13.5px;line-height:1.5}
.modal-body .dnote{margin-bottom:14px}
.dnote.discard{display:flex;flex-wrap:wrap;gap:6px;align-items:center;background:rgba(255,176,32,.12);color:var(--warn)}
.dnote.discard .linkbtn{color:var(--ink)}
.skiplist{margin:8px 0 0 18px;font-size:12.5px;line-height:1.5;max-height:240px;overflow:auto}
.skiplist li{margin-bottom:3px}
.import-summary{font-size:13.5px;font-weight:600}
/* charts: dashed "Invested" line (UX-22), keyboard focus on charts and dots (UX-13), touch drags scrub the chart */
svg .ln.inv{stroke-dasharray:4 3}
.lg .sw.inv{background:repeating-linear-gradient(90deg,var(--ink-3) 0 4px,transparent 4px 7px)}
svg .cap{touch-action:pan-y}
svg .cap:focus{outline:none}
svg .cap:focus-visible{stroke:var(--accent);stroke-width:2}
svg .hit:focus-visible{outline:none}
svg .hit:focus-visible+.dot{opacity:1;stroke:var(--accent);stroke-width:3}
.arow .n.big{font-weight:700}
/* small numbers on strong heat tints use --ink (UX-03) */
.mtx td.c.hi .d,.hm td.hi small{color:var(--ink)}
/* heatmap row labels are row headers now (UX-13), with the look of the widget's td.y */
.hm th.y{text-align:left;font-family:var(--sans);font-size:11.5px;font-weight:700;color:var(--ink-2);padding:0 0 0 2px;height:38px;text-transform:none;letter-spacing:0}
/* sticky first column in wide tables (visual finding 3, UX-14): the ticker stays visible while scrolling sideways */
.tablewrap>table:not(.yrtbl)>*>tr>:first-child{position:sticky;left:0;z-index:1;background-color:var(--panel)}
.tablewrap>table:not(.yrtbl)>tfoot>tr>:first-child{background-color:var(--panel-2)}
.tablewrap>table:not(.yrtbl)>tbody>tr:hover>:first-child{background-color:var(--panel-2)}
.tablewrap>table:not(.yrtbl)>tbody>tr.lot>:first-child{background-image:linear-gradient(rgba(0,0,0,.16),rgba(0,0,0,.16))}
.tablewrap>table:not(.yrtbl)>tbody>tr.lot:hover>:first-child{background-color:var(--panel);background-image:linear-gradient(rgba(0,0,0,.22),rgba(0,0,0,.22))}
:root[data-theme="light"] .tablewrap>table:not(.yrtbl)>tbody>tr.lot>:first-child{background-image:linear-gradient(rgba(30,50,90,.035),rgba(30,50,90,.035))}
:root[data-theme="light"] .tablewrap>table:not(.yrtbl)>tbody>tr.lot:hover>:first-child{background-image:linear-gradient(rgba(30,50,90,.05),rgba(30,50,90,.05))}
.hmwrap .hm thead th:first-child,.hmwrap .hm th.y{position:sticky;left:0;z-index:1;background:var(--panel);box-shadow:3px 0 0 var(--panel)}
tr.soldrow{opacity:.9}
/* faded sold rows: small grey text uses --ink-2 so it still reaches 4.5:1 through the .9 opacity (light lot hover: .05) */
.mtx tr.sold .sub2,tr.soldrow .sub2{color:var(--ink-2)}
#importResult:empty{display:none}
/* the dashboard's "Loading…" placeholders outside a chart (matrix, purchases, heatmap) */
.dcard>.wait{padding:28px 12px;text-align:center;color:var(--ink-3);font-size:12.5px}
.usermenu-slot{display:flex;align-items:center}
.usermenu-slot:empty{display:none}
/* fallback toasts, only used when usermenu.js (shared toasts in components.css) is missing */
#toasts{position:fixed;left:50%;bottom:16px;transform:translateX(-50%);z-index:90;display:flex;flex-direction:column;gap:8px;width:calc(100% - 32px);max-width:440px;pointer-events:none}
#toasts .toast{pointer-events:auto;display:flex;align-items:flex-start;gap:10px;padding:10px 10px 10px 14px;border-radius:12px;font-size:13px;line-height:1.45;box-shadow:var(--shadow);border:1px solid var(--border);background:var(--panel);color:var(--ink)}
#toasts .toast::before{content:none}
#toasts .toast.err{background:var(--loss-soft);color:var(--loss);border-color:var(--loss)}
#toasts .tmsg{flex:1;padding-top:3px}
#toasts .iconbtn{width:28px;height:28px;font-size:13px;flex:0 0 auto}
/* screen-reader-only text inside a scroller must not escape it (it would widen the page on phones) */
.tablewrap,.hmwrap{position:relative}
/* KPI values never clip silently (UX-25) */
.kpi .val{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
@media(min-width:761px) and (max-width:900px){.kpi .val{font-size:19px}}
@media(max-width:760px){.kpi .val{font-size:clamp(17px,5.4vw,20px)}}
/* Dividends "By year" fits a phone (UX-04); it also scrolls inside its card when it must */
@media(max-width:520px){
  .yrtbl{min-width:0;width:100%}
  .yrtbl thead th,.yrtbl tbody td,.yrtbl tfoot td{padding-right:12px}
  .yrtbl thead th{white-space:normal;vertical-align:bottom}
}
/* phones: the topbar in two rows (UX-14) */
@media(max-width:520px){
  .topbar{gap:8px;padding:10px 12px}
  .spacer.ph{display:block}
  .statusline{display:flex;align-items:center;gap:8px;order:10;flex:1 0 100%;min-width:0}
  .statusline .status{flex:0 0 auto}
  .statusline .fresh{min-width:0;overflow:hidden;text-overflow:ellipsis;text-align:right}
  .topbar.has-usermenu #themeBtn,.topbar.has-usermenu #settingsBtn{display:none}
  /* the frozen first column of wide tables stays narrow (about 45% of the scroller): the symbol line wraps and the
     badge goes under it, so every column (and the row buttons) can be scrolled into view; focus stops clear of it */
  .tablewrap>table:not(.yrtbl)>*>tr>:first-child{white-space:normal}
  .tablewrap>table:not(.yrtbl) td:first-child .asset{display:grid;grid-template-columns:auto minmax(0,1fr);gap:2px 8px;width:118px}
  .tablewrap>table.mtx td:first-child .asset,.tablewrap>table.ptbl td:first-child .asset{width:104px}
  .tablewrap>table:not(.yrtbl) td:first-child .asset>.chev~.badge{grid-column:2}
  .tablewrap>table:not(.yrtbl) td:first-child .asset>.badge{justify-self:start}
  .tablewrap>table:not(.yrtbl) td:first-child .sub2{overflow-wrap:anywhere}
  .tablewrap{scroll-padding-left:150px}
}
@media(max-width:420px){
  .panel-head{padding:12px}
  .tabs{flex-wrap:nowrap;gap:2px;overflow-x:auto}
  .tab{padding:5px 8px;font-size:12.5px;flex:0 0 auto}
  .dash{padding:12px 12px 16px}
  .dbar .lbl{display:none}
  .pchips{flex-wrap:nowrap;overflow-x:auto;max-width:100%}
  .pchip{padding:5px 7px;flex:0 0 auto}
  .fresh .fr-int{display:none}
  /* these rows scroll sideways, which clips anything drawn outside a button: the focus ring goes inside */
  .tab:focus-visible,.pchip:focus-visible{outline-offset:-2px}
}
@media(max-width:400px){.brand .brand-name{display:none}}
/* touch screens: bigger targets (UX-19) and text floors (UX-18); mouse screens keep the widget sizes */
@media(pointer:coarse){
  .pchip,.tab{min-height:32px}
  .rowbtns{gap:8px}
  .rowbtns button{width:32px;height:32px}
  .badge,.tag{font-size:11px}
  .dtile .k,.divsum .k,.yrhead,.dbar .lbl,thead th,.hm th{font-size:11px}
  .sub2,.field .hint,.dtile .s2,.dcard .foot,.note,.dtip .tl,.dcard .dh .muted,.hm td small,.mtx td.c .d,.arow .n small{font-size:11.5px}
  svg .axt,svg .dlbl{font-size:11px}
  /* iOS Safari zooms the page into any focused field under 16 px (pinch zoom stays allowed) */
  input,select,textarea{font-size:16px}
}
@media(pointer:coarse) and (min-width:421px){.pchip,.tab{padding-left:12px;padding-right:12px}}
/* reduced motion (UX-20) */
@media(prefers-reduced-motion:reduce){
  .dot.load{animation:none}
  *,*::before,*::after{transition:none!important;scroll-behavior:auto!important}
}

/* ---------- Shared additions for the multi-user app (used by app.html, admin.html, login.html) ---------- */
/* Native <dialog class="modal"> with the same look as the widget's .overlay + .modal pair. */
dialog.modal{padding:0;border:1px solid var(--border);background:var(--panel);color:var(--ink);border-radius:16px;width:calc(100% - 28px);max-width:440px;box-shadow:var(--shadow);margin:auto;max-height:calc(100% - 28px);overflow:auto}
dialog.modal::backdrop{background:rgba(4,8,16,.62);backdrop-filter:blur(2px)}
dialog.modal.wide{max-width:560px}
/* Visually hidden but read by screen readers. */
.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
/* Inline field errors (never colour only: prefixed with a warning sign). */
.field .err{display:none;font-size:12px;color:var(--loss);margin-top:5px;line-height:1.4}
.field .err.show{display:block}
.field .err::before{content:"\26A0\FE0E  "}
input[aria-invalid="true"],select[aria-invalid="true"]{border-color:var(--loss)}

/* ---------- Right to left (Hebrew: theme-boot.js sets <html lang="he" dir="rtl">) ----------
   Every rule here is scoped to [dir="rtl"], so English (dir="ltr") renders exactly as before; the admin panel
   (<html data-i18n-off>) is always ltr. The layout is a mirror image: the first table column, sticky columns, the KPI
   accent bar, paddings and margins swap sides. Physical left/right values (not start/end) on purpose: they inherit
   unchanged into the ltr islands below. Kept left to right: the SVG charts (time runs left to right), the purchase
   range track (its marker is placed with an inline left:N%) and number cells, so "+$1,475.93" and "−0.79%" keep their
   sign in front (I.num() does the same for numbers inside sentences; both together are harmless). */
/* Hebrew letters in the monospace number font: Consolas / SF Mono have none, and the browser's Hebrew "fixed" fallback
   is Courier New. This face only covers the Hebrew block (unicode-range), so digits and Latin stay monospace. */
@font-face{font-family:"PL Hebrew";font-weight:100 550;unicode-range:U+0590-05FF,U+FB1D-FB4F;
  src:local("Segoe UI"),local("SegoeUI"),local("Arial Hebrew"),local("ArialHebrew"),local("Arial"),local("ArialMT"),local("Noto Sans Hebrew"),local("NotoSansHebrew-Regular")}
@font-face{font-family:"PL Hebrew";font-weight:551 650;unicode-range:U+0590-05FF,U+FB1D-FB4F;
  src:local("Segoe UI Semibold"),local("SegoeUI-Semibold"),local("Arial Hebrew Bold"),local("ArialHebrew-Bold"),local("Arial Bold"),local("Arial-BoldMT"),local("Noto Sans Hebrew SemiBold"),local("NotoSansHebrew-SemiBold"),local("Noto Sans Hebrew Bold"),local("NotoSansHebrew-Bold")}
@font-face{font-family:"PL Hebrew";font-weight:651 1000;unicode-range:U+0590-05FF,U+FB1D-FB4F;
  src:local("Segoe UI Bold"),local("SegoeUI-Bold"),local("Arial Hebrew Bold"),local("ArialHebrew-Bold"),local("Arial Bold"),local("Arial-BoldMT"),local("Noto Sans Hebrew Bold"),local("NotoSansHebrew-Bold")}
:root[dir="rtl"]{--mono:"PL Hebrew",'SF Mono',ui-monospace,'Cascadia Code','JetBrains Mono',Menlo,Consolas,monospace}
/* default alignment is the right edge, also inside the ltr islands (number cells, inputs) */
[dir="rtl"] body{text-align:right}
/* Hebrew labels: no letter-spacing (it breaks the joined look of Hebrew) and no uppercase */
[dir="rtl"] .kpi .label,[dir="rtl"] .divsum .k,[dir="rtl"] .yrhead,[dir="rtl"] thead th,[dir="rtl"] .badge,[dir="rtl"] .dbar .lbl,
[dir="rtl"] .dtile .k,[dir="rtl"] .tag,[dir="rtl"] .hm th{letter-spacing:0;text-transform:none}
/* topbar, KPIs */
[dir="rtl"] .countdown{text-align:left;font-family:var(--sans);font-variant-numeric:tabular-nums}
/* Hebrew sentences and labels in the number font get Consolas-wide word gaps: the text font for these (numbers stay mono) */
[dir="rtl"] #kpiValueSub,[dir="rtl"] .pchip{font-family:var(--sans)}
[dir="rtl"] .skip-link{left:auto;right:12px}
[dir="rtl"] .kpi .accentbar{left:auto;right:0}
[dir="rtl"] .kpi .val{direction:ltr;text-align:right}
/* a lone number ("+2.31%") lays out left to right, a Hebrew sentence right to left; the edge stays right */
[dir="rtl"] .kpi .sub,[dir="rtl"] .divsum .v,[dir="rtl"] .dtile .v,[dir="rtl"] .dtile .s{unicode-bidi:plaintext;text-align:right}
/* tables: first column on the right, number columns aligned to the left edge */
[dir="rtl"] thead th,[dir="rtl"] tbody td,[dir="rtl"] tfoot td{text-align:left}
[dir="rtl"] thead th:first-child,[dir="rtl"] tbody td:first-child,[dir="rtl"] tfoot td:first-child{text-align:right}
[dir="rtl"] td[style*="text-align:left"],[dir="rtl"] .foot-note[style*="text-align:left"]{text-align:right!important}
[dir="rtl"] .yrtbl thead th{padding:4px 0 6px 22px}
[dir="rtl"] .yrtbl tbody td{padding:5px 0 5px 22px}
[dir="rtl"] .yrtbl tfoot td{padding:6px 0 6px 22px}
[dir="rtl"] .tablewrap>table:not(.yrtbl)>*>tr>:first-child{left:auto;right:0}
/* number cells and number inputs stay left to right (Hebrew notes inside them go back to right to left) */
[dir="rtl"] .num,[dir="rtl"] .chg,[dir="rtl"] .mtx td.c,[dir="rtl"] .hm td{direction:ltr;unicode-bidi:isolate}
[dir="rtl"] .num .sub2{direction:rtl;unicode-bidi:isolate}
[dir="rtl"] .asum b,[dir="rtl"] .dtile .s2 b{direction:ltr;unicode-bidi:isolate}
/* tooltip values follow the reading direction ("+1.70% לשנה": number on the right); their numbers are isolated by I.num */
[dir="rtl"] .dtip .tr b{unicode-bidi:isolate}
[dir="rtl"] input.num,[dir="rtl"] input[data-date]{direction:ltr;text-align:right}
[dir="rtl"] input#sellSym{direction:rtl}
/* expand chevrons: app.js already writes ◂ (closed) in Hebrew, so no CSS mirroring here (it would flip it back) */
/* dashboard */
[dir="rtl"] .dcard .dh .lg{margin-left:0;margin-right:auto}
[dir="rtl"] .lg .sw,[dir="rtl"] .lg .dt{margin-right:0;margin-left:5px}
[dir="rtl"] .chart{direction:ltr}
[dir="rtl"] .chart .wait{direction:rtl}
[dir="rtl"] .arow .bar,[dir="rtl"] .arow .bar i{border-radius:5px 2px 2px 5px}
[dir="rtl"] .arow .n{text-align:left}
[dir="rtl"] .rk{margin-right:0;margin-left:8px}
[dir="rtl"] .rng .trk{direction:ltr}
[dir="rtl"] .hm th,[dir="rtl"] .hm td{text-align:center}
[dir="rtl"] .hm th:first-child,[dir="rtl"] .hm th.y,[dir="rtl"] .hm td.y{text-align:right}
[dir="rtl"] .hm th.y{padding:0 2px 0 0}
[dir="rtl"] .hm td.y{padding-left:0;padding-right:2px}
[dir="rtl"] .hmwrap .hm thead th:first-child,[dir="rtl"] .hmwrap .hm th.y{left:auto;right:0;box-shadow:-3px 0 0 var(--panel)}
/* dialogs, fallback toasts */
[dir="rtl"] .skiplist{margin:8px 18px 0 0}
[dir="rtl"] #toasts .toast{padding:10px 14px 10px 10px}
@media(max-width:520px){
  [dir="rtl"] .yrtbl thead th,[dir="rtl"] .yrtbl tbody td,[dir="rtl"] .yrtbl tfoot td{padding-left:12px}
  [dir="rtl"] .statusline .fresh{text-align:left}
  [dir="rtl"] .tablewrap{scroll-padding-left:0;scroll-padding-right:150px}
}

/* Hebrew: hidden until the static text is translated (theme-boot.js adds the class, i18n.js removes it) */
html.i18n-wait body{visibility:hidden}

/* stock splits, purchase dates, last-close prices (Holdings, Sold, "Your purchases", dialogs) */
.splitnote{color:var(--ink-3);font-size:10.5px;margin-top:2px;line-height:1.35;max-width:260px;white-space:normal}
.splitnote[title]{cursor:help;text-decoration:underline dotted;text-underline-offset:2px}
.splitnote.warnnote,.linkbtn.nodate{color:var(--warn)}
.linkbtn.nodate{padding:2px 0;font-size:11px;margin-top:1px;text-align:start}
.dnote .linkbtn{padding:0 4px;font-size:12px}
.modal-body>.dnote.splithint{margin:0 0 14px}

/* v3: fees, dividend tax withheld, totals in shekels */
.cursw{flex:0 0 auto;padding:2px;gap:2px;border-radius:9px}
.cursw button{flex:0 0 auto;min-width:30px;padding:6px 8px;font-size:13.5px;line-height:1}
.kpi .sub .fxline{font-family:var(--sans);font-size:11.5px;color:var(--ink-3)}
.kpi .sub .infobtn{vertical-align:0}
.taxline{display:flex;flex-wrap:wrap;align-items:center;gap:2px 6px;padding:8px 16px;font-size:12.5px;color:var(--ink-2);border-bottom:1px solid var(--border)}
.taxline .linkbtn{padding:2px 4px}
.taxpct{display:flex;align-items:center;gap:10px}
.taxpct label{margin:0;flex:1 1 auto}
.taxpct input{width:92px;flex:0 0 92px}
.flabel.taxown{margin-top:12px}
.taxlist{display:flex;flex-direction:column;gap:6px;margin-bottom:4px}
.taxrow{display:grid;grid-template-columns:minmax(0,1fr) 76px auto 34px;gap:6px;align-items:center}
.taxrow .taxunit{color:var(--ink-3);font-size:12.5px}
.taxrow .err{grid-column:1/-1;margin-top:0}
.taxrow .err.show{display:block}
.linkbtn.taxadd{padding:4px 0}
.checkrow{display:flex!important;align-items:center;gap:8px;margin:12px 0 0!important;font-size:13px!important;color:var(--ink)!important;font-weight:500!important;cursor:pointer}
.checkrow input[type=checkbox]{width:16px;height:16px;flex:0 0 auto;margin:0;accent-color:var(--accent-strong)}
.modal-body>.dnote.curnote{margin:0 0 14px}
@media(max-width:520px){.topbar.has-usermenu #curSeg{display:none}}
[dir="rtl"] .taxrow .taxunit{direction:ltr}
