/* Themes. Auto follows the device: Clean in light mode, Midnight in dark mode. */
:root, :root[data-theme="clean"] {
  color-scheme: light;
  --bg: #f3f5fa;
  --bg-image: none;
  --surface: #ffffff; --border: #e6e9f0; --grid: #eef0f5;
  --text: #0f172a; --text-2: #475569; --text-3: #64748b;
  --accent: #4f46e5; --accent-soft: #e0e7ff; --on-accent: #fff;
  --s1: #4f46e5; --s2: #ea580c; --s3: #0d9488;
  --good: #047857; --bad: #dc2626; --candle-up: #10b981; --candle-down: #ef4444;
  --warn-bg: #fef3c7; --warn-text: #78350f;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 6px 20px rgba(15,23,42,.06);
  --hero: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --blur: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #0a0e1a;
    --bg-image: radial-gradient(1200px 600px at 10% -10%, rgba(99,102,241,.20), transparent 60%);
    --surface: #111729; --border: #1f2740; --grid: #1a2136;
    --text: #e8ecf6; --text-2: #a9b3c9; --text-3: #7d88a3;
    --accent: #818cf8; --accent-soft: #252c5a; --on-accent: #0a0e1a;
    --s1: #818cf8; --s2: #fb923c; --s3: #2dd4bf;
    --good: #34d399; --bad: #f87171; --candle-up: #22c55e; --candle-down: #ef4444;
    --warn-bg: #3b2f0e; --warn-text: #fcd68a;
    --shadow: 0 8px 24px rgba(0,0,0,.35);
    --hero: linear-gradient(135deg, #4338ca 0%, #7c3aed 60%, #c026d3 120%);
    --blur: none;
  }
}
:root[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #0a0e1a;
  --bg-image: radial-gradient(1200px 600px at 10% -10%, rgba(99,102,241,.20), transparent 60%);
  --surface: #111729; --border: #1f2740; --grid: #1a2136;
  --text: #e8ecf6; --text-2: #a9b3c9; --text-3: #7d88a3;
  --accent: #818cf8; --accent-soft: #252c5a; --on-accent: #0a0e1a;
  --s1: #818cf8; --s2: #fb923c; --s3: #2dd4bf;
  --good: #34d399; --bad: #f87171; --candle-up: #22c55e; --candle-down: #ef4444;
  --warn-bg: #3b2f0e; --warn-text: #fcd68a;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
  --hero: linear-gradient(135deg, #4338ca 0%, #7c3aed 60%, #c026d3 120%);
  --blur: none;
}
:root[data-theme="glass"] {
  color-scheme: dark;
  --bg: #0b0820;
  --bg-image: radial-gradient(800px 500px at 0% 0%, #5b21b6 0%, transparent 60%), radial-gradient(700px 500px at 100% 10%, #0e7490 0%, transparent 55%), radial-gradient(900px 600px at 50% 110%, #9d174d 0%, transparent 60%);
  --surface: rgba(255,255,255,.06); --border: rgba(255,255,255,.12); --grid: rgba(255,255,255,.08);
  --text: #f5f3ff; --text-2: #d4cdef; --text-3: #a9a2c9;
  --accent: #c4b5fd; --accent-soft: rgba(196,181,253,.18); --on-accent: #1e1240;
  --s1: #c4b5fd; --s2: #fdba74; --s3: #5eead4;
  --good: #6ee7b7; --bad: #fda4af; --candle-up: #34d399; --candle-down: #fb7185;
  --warn-bg: rgba(250,204,21,.14); --warn-text: #fde68a;
  --shadow: 0 8px 32px rgba(0,0,0,.25);
  --hero: linear-gradient(135deg, rgba(255,255,255,.24), rgba(255,255,255,.06));
  --blur: blur(16px);
}
:root[data-theme="emerald"] {
  color-scheme: dark;
  --bg: #06110d;
  --bg-image: radial-gradient(1000px 500px at 90% -10%, rgba(16,185,129,.18), transparent 60%);
  --surface: #0c1a15; --border: #17302a; --grid: #132620;
  --text: #e6f4ee; --text-2: #a3c4b6; --text-3: #7a9c8e;
  --accent: #34d399; --accent-soft: #123d2f; --on-accent: #052e1f;
  --s1: #34d399; --s2: #fbbf24; --s3: #60a5fa;
  --good: #4ade80; --bad: #f87171; --candle-up: #22c55e; --candle-down: #ef4444;
  --warn-bg: #33290a; --warn-text: #fcd68a;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
  --hero: linear-gradient(135deg, #047857 0%, #0d9488 60%, #0e7490 100%);
  --blur: none;
}

.theme-wrap { position: relative; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 99px; vertical-align: -3px; margin-right: 6px; box-shadow: 0 0 0 1px var(--border); }
.theme-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; display: grid; gap: 4px; padding: 6px; min-width: 180px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.25);
}
.theme-menu button { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 8px 10px; border-radius: 8px; text-align: left; }
.theme-menu button:hover { background: var(--grid); }
.theme-menu button[aria-pressed="true"] { background: var(--accent-soft); }
.theme-menu .dot { width: 22px; height: 22px; border-radius: 99px; flex: none; box-shadow: 0 0 0 1px rgba(127,127,127,.3); }
@media (max-width: 600px) { .theme-menu { left: 0; right: auto; } }

* { box-sizing: border-box; }
body {
  margin: 0; color: var(--text); min-height: 100vh;
  background-color: var(--bg); background-image: var(--bg-image); background-attachment: fixed;
  font: 14px/1.45 "Inter", "Hind Siliguri", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.num { font-variant-numeric: tabular-nums; }
main { max-width: 1120px; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 16px 48px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -0.02em; }
.meta { color: var(--text-3); font-size: 12px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
button, select {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 14px; cursor: pointer; font-weight: 500;
}
button:hover, select:hover { border-color: var(--text-3); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button:disabled { opacity: .6; cursor: default; }
.icon-btn { padding: 6px 10px; }
input {
  font: inherit; font-size: 13px; padding: 7px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.tabs {
  display: inline-flex; max-width: 100%; gap: 4px; margin-bottom: 16px; padding: 4px; overflow-x: auto; scrollbar-width: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.tabs button { border: 0; border-radius: 9px; background: none; padding: 7px 14px; color: var(--text-2); white-space: nowrap; font-weight: 500; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--on-accent); background: var(--accent); font-weight: 600; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; min-width: 0;
  box-shadow: var(--shadow); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.card h2 { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 0 0 12px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.card-head h2 { margin-bottom: 8px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 12px; }
.kpi .label { color: var(--text-2); font-size: 12px; }
.kpi .value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.kpi.hero { background: var(--hero); border-color: transparent; color: #fff; }
.kpi.hero .label, .kpi.hero .sub { color: rgba(255,255,255,.8); }
.kpi.hero .value { font-size: 28px; }
.kpi .sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.kpis.three .kpi { padding: 12px; background: var(--grid); border-color: transparent; box-shadow: none; }
.kpis.three .kpi .value { font-size: 18px; }
.up { color: var(--good); } .down { color: var(--bad); }
.grid2 { display: grid; grid-template-columns: 3fr 2fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stack > * + * { margin-top: 12px; }
.small { font-size: 12px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; touch-action: pan-y; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--bg); z-index: 2;
  padding: 6px 8px; border-radius: 6px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%);
  opacity: 0; transition: opacity .1s; line-height: 1.5;
}
.tooltip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.alloc { display: flex; flex-direction: column; gap: 10px; }
.alloc-row { display: grid; grid-template-columns: 64px 1fr 56px; align-items: center; gap: 8px; font-size: 13px; }
.alloc-row .bar { height: 10px; background: var(--grid); border-radius: 4px; overflow: hidden; }
.alloc-row .bar > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.alloc-row .pct { text-align: right; color: var(--text-2); }
.wallets { display: flex; gap: 8px 16px; flex-wrap: wrap; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.wallets b { color: var(--text); font-weight: 600; }
.table-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.table-head h2 { margin: 0; }
.toggle { font-size: 12px; color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 8px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-3); font-weight: 500; font-size: 12px; }
#holdings th { cursor: pointer; user-select: none; }
th[aria-sort] { color: var(--text); }
td.asset { font-weight: 600; }
td.left, th.left { text-align: left; }
.icon-btn svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.tag { font-weight: 400; color: var(--text-3); font-size: 11px; margin-left: 6px; }
.pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 99px; background: var(--grid); color: var(--text-2); }
.pill.good { color: var(--good); } .pill.bad { color: var(--bad); }
tr.pick { cursor: pointer; }
tr.pick:hover td, .mover:hover { background: var(--grid); }
tr.pick.selected td { background: var(--grid); }
.remove { border: 0; background: none; padding: 0 4px; color: var(--text-3); font-size: 15px; line-height: 1; }
.inline-form { display: flex; gap: 6px; }
.inline-form input { width: 160px; text-transform: uppercase; }
.inline-form input::placeholder, .alert-form input::placeholder { text-transform: none; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-head .sym { font-size: 13px; font-weight: 600; color: var(--text-2); }
.chart-head .price { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.chart-head .sub { font-size: 12px; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; gap: 4px; }
.seg button { padding: 4px 10px; font-size: 12px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.compare-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.compare-row select { padding: 3px 8px; font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 4px 2px 8px; border-radius: 99px; border: 1px solid var(--border); margin-right: 4px; }
.legend { display: flex; gap: 6px 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend b { color: var(--text); font-weight: 600; margin-left: 4px; }
.spark { display: block; width: 96px; height: 28px; margin-left: auto; }
.movers { list-style: none; margin: 0; padding: 0; }
.mover {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; font-size: 13px;
  padding: 7px 6px; border-radius: 6px; cursor: pointer; border: 0; width: 100%; background: none; text-align: left;
}
.mover .a { font-weight: 600; }
.mover .p { color: var(--text-2); text-align: right; }
.mover .c { text-align: right; min-width: 72px; }
.fng { display: grid; grid-template-columns: minmax(200px, 1fr) 2fr; gap: 16px; align-items: center; }
.fng-now { display: flex; align-items: baseline; gap: 10px; }
.fng-value { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }
.points { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.points li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; font-size: 14px; line-height: 1.55; }
.points .ic { width: 26px; height: 26px; border-radius: 99px; display: grid; place-items: center; font-size: 11px; background: var(--grid); color: var(--text-2); }
.points .ic.up { color: var(--good); background: color-mix(in srgb, var(--good) 16%, transparent); }
.points .ic.down { color: var(--bad); background: color-mix(in srgb, var(--bad) 16%, transparent); }
.points b { font-weight: 600; }
.announce { list-style: none; margin: 0; padding: 0; display: grid; }
.announce li { padding: 9px 0; border-bottom: 1px solid var(--grid); font-size: 13px; line-height: 1.45; }
.announce li:last-child { border-bottom: 0; }
.announce .meta { margin-top: 3px; }
.kind { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 99px; margin-right: 6px; background: var(--grid); color: var(--text-2); }
.kind.listing { color: var(--good); background: color-mix(in srgb, var(--good) 16%, transparent); }
.kind.delisting { color: var(--bad); background: color-mix(in srgb, var(--bad) 16%, transparent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { padding: 4px 11px; font-size: 12px; border-radius: 99px; }
.chips button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.stories { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px; margin-top: 4px; }
.story-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; align-content: start; max-height: 680px; overflow-y: auto; }
.story { width: 100%; display: grid; grid-template-columns: 24px 1fr; gap: 4px 10px; text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid transparent; background: none; font-weight: 400; }
.story:hover { background: var(--grid); border-color: transparent; }
.story[aria-current="true"] { background: var(--accent-soft); border-color: var(--accent); }
.story .rank { grid-row: span 3; font-weight: 700; color: var(--text-3); font-size: 13px; padding-top: 1px; }
.story .ttl { font-weight: 600; font-size: 14px; line-height: 1.35; color: var(--text); }
.story .sum { font-size: 12.5px; color: var(--text-2); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.story .meta, .story-detail .meta { font-size: 11.5px; color: var(--text-3); }
.tagpill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 99px; background: var(--grid); color: var(--text-2); margin: 0 4px 2px 0; }
.story-detail { background: var(--grid); border-radius: 14px; padding: 20px; align-self: start; position: sticky; top: 12px; min-height: 200px; }
.story-detail h3 { font-size: 19px; line-height: 1.3; margin: 8px 0 6px; letter-spacing: -0.01em; }
.story-detail .brief { background: var(--surface); border-radius: 10px; padding: 12px 14px; margin: 14px 0; font-size: 14px; line-height: 1.6; }
.story-detail .brief b { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.story-detail p { font-size: 14px; line-height: 1.7; margin: 0 0 12px; }
.story-detail h4 { font-size: 12px; color: var(--text-2); margin: 16px 0 6px; font-weight: 600; }
.story-detail ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-2); display: grid; gap: 4px; }
.story-detail .related { gap: 10px; }
.story-detail .related b { color: var(--text); font-weight: 600; }
.story-detail .related div { margin-top: 3px; color: var(--text); font-size: 13.5px; line-height: 1.6; }
.link-row { border: 0; background: none; padding: 0; text-align: left; font-weight: 500; font-size: 13px; line-height: 1.45; color: var(--text); }
.link-row:hover { text-decoration: underline; }
.checklist { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; font-size: 13px; }
.checklist .ok { color: var(--good); } .checklist .no { color: var(--text-3); }
.steps { margin: 0 0 12px; padding-left: 20px; font-size: 13px; color: var(--text-2); display: grid; gap: 6px; }
.steps code, code { font-size: 12px; background: var(--grid); padding: 1px 5px; border-radius: 4px; color: var(--text); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.alert-form { display: flex; gap: 8px; flex-wrap: wrap; }
.alert-form input { width: 150px; }
.alert-form #al-asset { text-transform: uppercase; width: 130px; }
.foot { color: var(--text-3); font-size: 11px; margin-top: 8px; }
.small-btn { padding: 4px 10px; font-size: 12px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-size: 12px; }
.upper { text-transform: uppercase; }
.upper::placeholder { text-transform: none; }
.sub-head { margin-top: 16px; }
.tall-scroll { max-height: 420px; overflow-y: auto; }
.goal-bar { height: 12px; background: var(--grid); border-radius: 6px; overflow: hidden; margin: 8px 0 6px; }
.goal-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.goal-line { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 13px; }
#targets-form { margin-top: 12px; }
.target-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.target-grid label { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 13px; font-weight: 600; background: var(--grid); padding: 6px 8px; border-radius: 8px; }
.target-grid input { width: 72px; text-align: right; }
form .row-actions + .row-actions { margin-top: 10px; }
.smart-form { display: grid; gap: 10px; max-width: 560px; }
.field { display: grid; grid-template-columns: 1fr 120px; gap: 8px; align-items: center; font-size: 13px; color: var(--text-2); }
.toggle.big { font-size: 13px; color: var(--text); }
@media (max-width: 480px) { .field { grid-template-columns: 1fr; } }
.notice { background: var(--warn-bg); color: var(--warn-text); border-radius: 8px; padding: 10px 12px; font-size: 12px; margin-bottom: 12px; }
.notice ul { margin: 4px 0 0; padding-left: 18px; }
.center { min-height: 70vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 340px; }
.login h1 { margin-bottom: 4px; }
.login p { color: var(--text-2); margin: 0 0 16px; }
.login input { width: 100%; padding: 9px 12px; margin-bottom: 10px; }
.login button { width: 100%; padding: 9px; }
.error { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 8px; }
.muted { color: var(--text-3); }
.empty { color: var(--text-3); font-size: 13px; padding: 32px 0; text-align: center; white-space: normal; }
[hidden] { display: none !important; }
@media (max-width: 820px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis.three { grid-template-columns: 1fr 1fr 1fr; }
  .grid2, .grid3, .fng, .stories { grid-template-columns: 1fr; }
  .story-list { max-height: none; }
  .story-detail { position: static; }
  .kpi .value { font-size: 20px; }
}
@media (max-width: 480px) {
  .kpis.three { grid-template-columns: 1fr; }
  .alert-form input, .alert-form select, .alert-form button, .alert-form #al-asset { width: 100%; }
}
