:root{
  --teal:#0d5561; --teal-d:#0a444e; --bg:#f7f6fb; --surface:#fff; --surface2:#f1eef7;
  --text:#1a1d21; --muted:#667085; --line:#e4e1ec; --up:#0a7d3a; --down:#c02626;
  --chip:#ece8f5;
}
@media (prefers-color-scheme: dark){
  :root{ --bg:#14161a; --surface:#1c1f24; --surface2:#23272e; --text:#e6e8ea; --muted:#9aa4b2;
    --line:#2c313a; --chip:#262b33; --teal:#12707f; }
}
*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{ font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; background:var(--bg);
  color:var(--text); font-size:15px; -webkit-text-size-adjust:100%; }
[x-cloak]{ display:none !important; }
a{ color:inherit; text-decoration:none; }
.muted{ color:var(--muted); font-size:13px; }
.err{ color:var(--down); font-size:13px; }
.ok{ color:var(--up); font-size:13px; }
.pad{ padding:16px; }
.pwform{ display:flex; flex-direction:column; gap:10px; margin-top:12px; }
.pwform input{ padding:11px; border:1px solid var(--line); border-radius:10px; font-size:16px;
  background:var(--surface); color:var(--text); }

/* top bar + nav */
.topbar{ position:sticky; top:0; z-index:10; display:flex; align-items:center; gap:12px;
  background:var(--teal); color:#fff; padding:10px 14px; }
.brand a{ font-weight:800; font-size:18px; white-space:nowrap; }
.nav{ display:flex; gap:4px; overflow-x:auto; flex:1; scrollbar-width:none; }
.nav::-webkit-scrollbar{ display:none; }
.nav a{ padding:6px 10px; border-radius:8px; white-space:nowrap; font-size:14px; opacity:.85; }
.nav a.on{ background:rgba(255,255,255,.18); opacity:1; font-weight:600; }
.logout{ font-size:13px; opacity:.9; white-space:nowrap; border:1px solid rgba(255,255,255,.35);
  padding:5px 10px; border-radius:8px; }

.content{ max-width:1200px; margin:0 auto; padding:16px; }
.page-title{ margin:6px 0 2px; font-size:26px; color:var(--teal); font-weight:800; }
.page-head{ display:flex; align-items:baseline; justify-content:space-between; flex-wrap:wrap; gap:8px; }

/* home / cards */
.cards{ display:grid; gap:14px; grid-template-columns:1fr; margin-top:16px; }
@media (min-width:720px){ .cards{ grid-template-columns:1fr 1fr; } }
.card{ display:block; background:var(--surface2); border-radius:14px; padding:18px 20px;
  border:1px solid var(--line); }
.card h2{ margin:0 0 6px; color:var(--teal); font-size:20px; }
.card p{ margin:2px 0; color:var(--muted); font-size:14px; }
.card .stamp{ color:var(--text); font-size:12px; font-weight:600; margin-top:8px; }

/* toolbar / chips */
.toolbar{ display:flex; align-items:center; justify-content:space-between; gap:10px;
  flex-wrap:wrap; margin:12px 0; }
.chips{ display:flex; gap:8px; flex-wrap:wrap; }
.chip{ border:1px solid var(--line); background:var(--surface); color:var(--text);
  padding:7px 14px; border-radius:20px; font-size:14px; cursor:pointer; }
.chip.on{ background:var(--chip); border-color:var(--teal); font-weight:600; }
.tools{ display:flex; align-items:center; gap:10px; }
.btn{ background:var(--teal); color:#fff; border:none; padding:8px 16px; border-radius:20px;
  font-size:14px; cursor:pointer; }
.btn.ghost{ background:transparent; color:var(--teal); border:1px solid var(--line); }
.btn:disabled{ opacity:.5; }

/* table */
.tablewrap{ overflow-x:auto; border:1px solid var(--line); border-radius:12px; background:var(--surface); }
.tablewrap.short{ max-height:60vh; overflow-y:auto; }
table.grid{ border-collapse:collapse; width:100%; font-size:13px; }
.grid th,.grid td{ padding:9px 12px; text-align:left; white-space:nowrap; border-bottom:1px solid var(--line); }
.grid th{ position:sticky; top:0; background:var(--surface2); cursor:pointer; font-size:12px;
  font-weight:700; user-select:none; }
.grid td.num,.grid th.num{ text-align:right; font-variant-numeric:tabular-nums; font-family:ui-monospace,monospace; }
.grid td.sym{ font-weight:700; }
.grid tbody tr:nth-child(even){ background:rgba(0,0,0,.02); }
.grid tr.baserow{ background:var(--chip) !important; font-weight:600; }

/* trend */
.tabs{ display:flex; gap:4px; border-bottom:2px solid var(--line); margin:8px 0; }
.tab{ background:none; border:none; padding:10px 16px; font-size:15px; color:var(--muted);
  cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-2px; }
.tab.on{ color:var(--teal); font-weight:700; border-bottom-color:var(--teal); }
.criteria{ display:flex; flex-direction:column; gap:8px; margin:12px 0; }
.crit{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.crit-label{ font-weight:600; }
.crit-band{ display:flex; align-items:center; gap:6px; }
.crit-band input{ width:84px; padding:8px; border:1px solid var(--line); border-radius:8px;
  background:var(--surface); color:var(--text); font-size:15px; }
.crit-inner{ display:flex; align-items:center; justify-content:space-between; gap:10px; width:100%; }
.crit-cmp{ display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.crit-cmp select{ padding:8px; border:1px solid var(--line); border-radius:8px; background:var(--surface);
  color:var(--text); font-size:14px; max-width:44vw; }
.crit-cmp select.op{ min-width:56px; }
.add-row{ display:flex; gap:8px; flex-wrap:wrap; }
.x{ background:none; border:none; color:var(--muted); font-size:16px; cursor:pointer; }
.refresh-row{ display:flex; align-items:center; gap:12px; margin:8px 0 12px; flex-wrap:wrap; }

/* modal */
.modal{ position:fixed; inset:0; background:rgba(0,0,0,.4); display:flex; align-items:center;
  justify-content:center; z-index:50; padding:16px; }
.sheet{ background:var(--surface); border-radius:16px; padding:20px; width:100%; max-width:420px;
  max-height:80vh; overflow:auto; }
.sheet.wide{ max-width:900px; }
.sheet h3{ margin:0 0 12px; }
.colgrid{ display:flex; flex-direction:column; }
.colrow{ display:flex; align-items:center; gap:10px; padding:10px 4px; border-bottom:1px solid var(--line);
  cursor:pointer; font-size:15px; }
.sheet-actions{ display:flex; justify-content:flex-end; margin-top:14px; }

/* watch lists */
.wl-card{ display:flex; align-items:center; justify-content:space-between; gap:8px; padding:14px 16px; }
.wl-main{ flex:1; cursor:pointer; }
.wl-main h2{ margin:0 0 2px; }
.wl-actions{ display:flex; gap:4px; }
.x.back{ font-size:22px; vertical-align:middle; }
.wl-chips{ margin:10px 0; }
.wl-chips .chip{ display:inline-flex; align-items:center; gap:6px; }
.addsym{ display:flex; gap:8px; }
.addsym input{ flex:1; padding:10px 12px; border:1px solid var(--line); border-radius:10px;
  background:var(--surface); color:var(--text); font-size:15px; }

/* login */
.login-body{ display:flex; min-height:100vh; align-items:center; justify-content:center; padding:20px; }
.login-card{ background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:28px;
  width:100%; max-width:360px; display:flex; flex-direction:column; gap:12px; }
.login-card h1{ margin:0; color:var(--teal); }
.login-card input{ padding:12px; border:1px solid var(--line); border-radius:10px; font-size:16px;
  background:var(--surface); color:var(--text); }
.login-card button{ background:var(--teal); color:#fff; border:none; padding:12px; border-radius:10px;
  font-size:16px; cursor:pointer; margin-top:4px; }
