:root {
  color-scheme: dark;
  --page: #0a0b0d;
  --surface-1: #121418;
  --surface-2: #181b21;
  --line: #23262c;
  --text-primary: #e8e6e3;
  --text-secondary: #b8b5ad;
  --text-muted: #868883;
  --amber: #f5a524;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --pos: #199e70;
  --neg: #d95926;
  --mid: #383835;
  --grid: #23262a;
  --axis: #383835;
  --font: Consolas, "Cascadia Mono", "JetBrains Mono", "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--text-primary); font: 12px/1.35 var(--font); }
body { display: flex; flex-direction: column; min-height: 100vh; }
kbd { font: inherit; color: var(--amber); border: 1px solid #3a3122; border-radius: 2px; padding: 0 3px; background: #1a1610; }
.dim { color: var(--text-muted); }
.hint { color: var(--text-muted); font-weight: normal; font-size: 11px; margin-left: 8px; letter-spacing: 0; }

.hdr { display: flex; align-items: center; gap: 16px; padding: 6px 12px; background: #000; border-bottom: 1px solid #2a2a2a; }
.brand .logo { color: var(--amber); font-weight: bold; letter-spacing: 2px; font-size: 14px; }
.brand .sub { color: var(--text-secondary); margin-left: 10px; letter-spacing: 1px; }
.hdr-mid { flex: 1; text-align: center; color: var(--text-secondary); }
.hdr-mid.err { color: var(--series-2); }
.hdr-right { color: var(--text-primary); font-variant-numeric: tabular-nums; }

.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); min-width: 0; gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.tile { background: var(--surface-1); padding: 6px 10px; min-height: 52px; min-width: 0; overflow: hidden; }
.tile .k { color: var(--amber); font-size: 10px; letter-spacing: 1px; }
.tile .v { font-size: 17px; font-weight: bold; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile .v.small { font-size: 13px; margin-top: 5px; }
.tile .d { font-size: 11px; color: var(--text-secondary); }

.tabs { display: flex; align-items: center; gap: 4px; padding: 4px 8px; background: #0e0f12; border-bottom: 1px solid var(--line); }
.tab-btn, .win button, .refresh { font: inherit; background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--line); padding: 4px 10px; cursor: pointer; letter-spacing: 1px; }
.tab-btn.active, .win button.active { background: #2a2210; color: var(--amber); border-color: #5a4a20; }
.tab-btn:hover, .win button:hover, .refresh:hover { color: var(--text-primary); }
.win { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.win .dim { margin-right: 6px; }
.refresh { margin-left: 8px; }

main { flex: 1; padding: 8px; }
.tab { display: none; }
.tab.active { display: block; }
.split { display: flex; gap: 8px; align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.side { width: 330px; flex-shrink: 0; display: flex; flex-direction: column; gap: 8px; }
.side.wide { width: 480px; }
.panel.issuer { width: 420px; flex-shrink: 0; }
.panel { background: var(--surface-1); border: 1px solid var(--line); padding: 6px 8px 8px; margin-bottom: 8px; }
.panel h2 { margin: 0 0 6px; font-size: 12px; color: var(--amber); letter-spacing: 1px; font-weight: bold; }
.panel h3 { margin: 10px 0 4px; font-size: 11px; color: var(--amber); letter-spacing: 1px; }
.tbl-wrap { overflow: auto; max-height: calc(100vh - 230px); }
.tbl { border-collapse: collapse; width: 100%; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl th { position: sticky; top: 0; background: #0e0f12; color: var(--text-secondary); font-weight: normal; text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--axis); cursor: pointer; user-select: none; font-size: 11px; }
.tbl th.l, .tbl td.l { text-align: left; }
.tbl th.sorted { color: var(--amber); }
.tbl td { padding: 3px 6px; text-align: right; border-bottom: 1px solid #16181c; }
.tbl tbody tr:hover td { background: #1c1f26; }
.tbl tbody tr.sel td { background: #26210f; }
.tbl tr.clickable { cursor: pointer; }
.tbl td.name { color: var(--text-primary); font-weight: bold; }
.tbl td.idx { color: var(--text-muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.flat { color: var(--text-muted); }
.tbl.heat td { min-width: 78px; }
.tbl.heat td.name { min-width: 120px; }
.tbl tfoot td, .tbl tr.total td { border-top: 1px solid var(--axis); font-weight: bold; }

.leaders { display: flex; flex-direction: column; gap: 3px; }
.lead { display: grid; grid-template-columns: 110px 1fr 86px; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; cursor: pointer; }
.lead:hover .n { color: var(--amber); }
.lead .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead .bar { height: 10px; background: var(--surface-2); position: relative; }
.lead .bar i { position: absolute; top: 0; bottom: 0; display: block; }
.lead .bar i.pos { background: var(--pos); }
.lead .bar i.neg { background: var(--neg); }
.lead .v { text-align: right; }
.lead .v small { color: var(--text-muted); }

.note { color: var(--text-muted); font-size: 11px; margin-top: 6px; line-height: 1.5; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 8px; }
.stats .tile { min-height: 44px; }
.stats .tile .v { font-size: 14px; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chart { background: var(--surface-2); border: 1px solid var(--line); padding: 4px 6px 6px; }
.chart h3 { margin: 0 0 2px; }
.chart canvas { width: 100%; height: 200px; display: block; }
select { font: inherit; background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--line); padding: 2px 6px; }

.ftr { display: flex; gap: 16px; padding: 5px 12px; background: #000; border-top: 1px solid #2a2a2a; color: var(--text-secondary); font-size: 11px; }
.ftr .grow { flex: 1; }

@media (max-width: 1100px) {
  .split { flex-direction: column; align-items: stretch; }
  .side, .side.wide, .panel.issuer { width: auto; }
  .panel, .tbl-wrap, canvas { max-width: 100%; }
  .charts { grid-template-columns: 1fr; }
}

.flowmap { width: 100%; height: 420px; display: block; background: var(--surface-2); border: 1px solid var(--line); }
.tbl-wrap.short { max-height: 420px; }
.tbl td.cat { color: var(--text-muted); }

.stack { display: flex; height: 22px; background: var(--surface-2); margin: 4px 0 8px; overflow: hidden; }
.stack i { display: block; height: 100%; min-width: 1px; }
.stack i.rot { background: var(--series-3); }
.stack i.rwa { background: var(--series-1); }
.stack i.oth { background: #6b6e75; }
.stack i.exit { background: var(--series-2); }
.stack i.new { background: var(--series-4); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--text-secondary); margin-bottom: 6px; }
.legend b { display: inline-block; width: 9px; height: 9px; margin-right: 5px; vertical-align: -1px; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  html, body { font-size: 11px; }
  .hdr { padding: 5px 8px; gap: 8px; }
  .brand .logo { font-size: 13px; }
  .brand .sub { display: none; }
  .hdr-mid { font-size: 10px; }
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile .v.small { white-space: normal; }
  .hdr, .tabs, .ftr { min-width: 0; }
  .hdr-mid { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tile { min-height: 44px; padding: 5px 8px; }
  .tile .v { font-size: 14px; }
  .tile .v.small { font-size: 12px; }
  .tabs { flex-wrap: wrap; gap: 3px; padding: 4px; }
  .tab-btn { padding: 6px 6px; flex: 1 1 28%; text-align: center; letter-spacing: 0.5px; }
  .tab-btn kbd, .ftr kbd, .win .dim { display: none; }
  .win { margin-left: 0; flex: 1 1 auto; }
  .win button { flex: 1; padding: 6px 4px; }
  .refresh { margin-left: 0; padding: 6px 8px; }
  main { padding: 4px; }
  .split { flex-direction: column; align-items: stretch; gap: 4px; }
  main { overflow-x: hidden; }
  .side, .side.wide, .panel.issuer { width: auto; }
  .panel { padding: 5px 6px 6px; margin-bottom: 4px; }
  .panel h2 { font-size: 11px; line-height: 1.4; }
  .hint { display: block; margin-left: 0; font-size: 10px; }
  .tbl-wrap, .tbl-wrap.short { max-height: 62vh; -webkit-overflow-scrolling: touch; }
  .tbl th, .tbl td { padding: 4px 5px; }
  .lead { grid-template-columns: 86px 1fr 78px; }
  .charts { grid-template-columns: 1fr; gap: 4px; }
  .chart canvas { height: 170px; }
  .flowmap { height: 340px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .ftr { flex-wrap: wrap; gap: 8px; padding: 5px 8px; }
  .ftr .dim { display: none; }
  select { max-width: 48vw; }
}
@media (display-mode: standalone) {
  .hdr { padding-top: calc(5px + env(safe-area-inset-top)); }
  .ftr { padding-bottom: calc(5px + env(safe-area-inset-bottom)); }
}

/* MARKET window: plain-language layer */
.hl { display: flex; gap: 16px; align-items: flex-start; padding: 10px 12px; background: var(--surface-2); border-left: 4px solid var(--text-muted); margin: 0 0 8px; flex-wrap: wrap; }
.hl.good { border-color: var(--pos); } .hl.warn { border-color: var(--amber); } .hl.bad { border-color: var(--neg); }
.hl .lab { color: var(--amber); font-size: 10px; letter-spacing: 1px; }
.hl .state { font-size: 22px; font-weight: bold; letter-spacing: 2px; line-height: 1.2; }
.hl .state.good { color: var(--pos); } .hl .state.ok { color: var(--text-primary); } .hl .state.warn { color: var(--amber); } .hl .state.bad { color: var(--neg); }
.hl .say { flex: 1; min-width: 260px; color: var(--text-primary); line-height: 1.5; font-size: 12px; }
.hl .say ul { margin: 4px 0 0 16px; padding: 0; color: var(--text-secondary); }
.say { color: var(--text-primary); line-height: 1.5; margin: 0 0 8px; }
.pill { display: inline-block; padding: 0 6px; border-radius: 2px; font-size: 11px; line-height: 16px; background: #2a2d33; color: var(--text-primary); white-space: nowrap; }
.pill.good { background: #123b2c; color: #63d5a3; } .pill.ok { background: #2a2d33; color: var(--text-primary); } .pill.warn { background: #3d2d0a; color: var(--amber); } .pill.bad { background: #4a1f12; color: #ff9770; }
.tile .v.warn { color: var(--amber); }
.warn { color: var(--amber); }
.mini { font: inherit; font-size: 10px; letter-spacing: 1px; background: var(--surface-2); color: var(--amber); border: 1px solid var(--line); padding: 1px 7px; cursor: pointer; margin-left: 8px; vertical-align: 1px; }
.mini:hover { border-color: var(--amber); }
.ladder { display: grid; grid-template-columns: 54px 1fr 190px 110px 120px; gap: 3px 10px; align-items: center; font-variant-numeric: tabular-nums; margin-top: 4px; }
.ladder .hd { color: var(--text-secondary); font-size: 10px; letter-spacing: 1px; padding-bottom: 3px; border-bottom: 1px solid var(--axis); }
.ladder .row { display: contents; cursor: pointer; }
.ladder .row:hover > * { background: #1c1f26; }
.ladder .row.sel .a { color: var(--amber); }
.ladder .a { font-weight: bold; }
.bar { height: 16px; background: var(--surface-2); position: relative; min-width: 0; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--series-1); }
.bar i.good { background: var(--pos); } .bar i.ok { background: var(--series-1); } .bar i.warn { background: var(--amber); } .bar i.bad { background: var(--neg); }
.bar span { position: absolute; left: 6px; top: 0; line-height: 16px; font-size: 11px; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; white-space: nowrap; }
.vbars .row { display: grid; grid-template-columns: 80px 1fr 190px; gap: 8px; align-items: center; margin: 3px 0; }
.vbars .a { font-weight: bold; }
.vbars.dex .row { grid-template-columns: 90px 1fr 92px; }
details.howto { margin: 2px 0 10px; }
details.howto summary { cursor: pointer; color: var(--amber); font-size: 10px; letter-spacing: 1px; }
details.howto ul { margin: 6px 0 0 16px; padding: 0; color: var(--text-secondary); line-height: 1.55; }
details.howto li { margin-bottom: 3px; } details.howto b { color: var(--text-primary); }
@media (max-width: 760px) {
  .ladder { grid-template-columns: 42px 1fr 132px; gap: 3px 6px; }
  .ladder .c4, .ladder .c5 { display: none; }
  .ladder .c3 .pill { white-space: normal; line-height: 14px; padding: 1px 5px; }
  .hl .state { font-size: 17px; }
  .vbars .row { grid-template-columns: 64px 1fr 110px; }
  .vbars.dex .row { grid-template-columns: 70px 1fr 70px; }
}
/* backtest panel */
.vbars.bt .row { grid-template-columns: minmax(150px, 1.2fr) 1fr 150px; }
.vbars.bt .row .a { font-weight: normal; color: var(--text-secondary); font-size: 11px; line-height: 13px; }
.vbars.bt .row .v { font-variant-numeric: tabular-nums; font-size: 11px; }
.vbars.bt .row.hd { color: var(--text-muted); font-size: 10px; letter-spacing: 1px; border-bottom: 1px solid var(--axis); padding-bottom: 2px; }
.vbars.bt .bar.mid i { left: 50%; }
.vbars.bt .bar.mid i.neg { left: auto; right: 50%; }
.vbars.bt .bar.mid::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 1px solid var(--text-muted); }
.chart .vbars.bt { padding: 6px 4px 2px; }
.vbars.bt .bar { background: #1c1f26; }
#btYears { margin: 8px 0 4px; }
#btYears .tbl td, #btYears .tbl th { padding: 3px 8px; }
button.lnk { background: none; border: 0; color: var(--series-1); cursor: pointer; font: inherit; font-size: 11px; padding: 0; }
@media (max-width: 720px) { .vbars.bt .row { grid-template-columns: 1fr; gap: 2px; } .vbars.bt .row .v { text-align: left; } }

/* WHERE LIQUIDITY IS HEADING banner (shared by LIQUIDFLOW and TRADFLOW) */
.heading { display: flex; gap: 16px; align-items: flex-start; padding: 10px 12px; background: var(--surface-1); border-bottom: 1px solid var(--line); border-left: 4px solid var(--text-muted); min-height: 64px; }
.heading.good { border-left-color: var(--pos); } .heading.warn { border-left-color: var(--amber); } .heading.bad { border-left-color: var(--neg); }
.heading .hd-l { min-width: 240px; flex-shrink: 0; }
.heading .lab { color: var(--amber); font-size: 10px; letter-spacing: 1px; }
.heading .state { font-size: 22px; font-weight: bold; letter-spacing: 2px; line-height: 1.2; }
.heading .state.good { color: var(--pos); } .heading .state.ok { color: var(--text-primary); } .heading .state.warn { color: var(--amber); } .heading .state.bad { color: var(--neg); }
.heading .small { font-size: 10px; margin-top: 2px; }
.heading .hd-m { flex: 1; min-width: 280px; }
.heading .say { color: var(--text-primary); line-height: 1.5; margin: 0 0 6px; }
.heading .routes { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center; }
.heading .lane { display: inline-flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.heading .lane .lab { margin-right: 2px; }
.heading .rt { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 7px; font-size: 11px; white-space: nowrap; }
.heading .rt small { opacity: .85; }
.heading .hd-r { display: grid; grid-template-columns: repeat(2, minmax(190px, max-content)); gap: 3px 14px; flex-shrink: 0; max-width: 540px; font-size: 11px; }
.heading .sig { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary); }
.heading .sig b { color: var(--text-primary); font-weight: normal; font-variant-numeric: tabular-nums; }
.heading .other { grid-column: 1 / -1; margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); color: var(--text-secondary); text-decoration: none; }
.heading .other b { color: var(--text-primary); } .heading .other.good b { color: var(--pos); } .heading .other.warn b { color: var(--amber); } .heading .other.bad b { color: var(--neg); }
.heading .other:hover { color: var(--amber); }
@media (max-width: 1100px) { .heading { flex-wrap: wrap; } .heading .hd-r { max-width: none; width: 100%; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); } }
@media (max-width: 760px) { .heading { padding: 8px; gap: 8px; } .heading .hd-l { min-width: 0; width: 100%; } .heading .state { font-size: 17px; } .heading .hd-m { min-width: 0; } .heading .hd-r { grid-template-columns: 1fr; } .heading .sig { white-space: normal; } }

/* CRYPTO | TRADFI switch (FLOW CAPITAL hub) */
.switch { display: flex; border: 1px solid #2a2a2a; }
.switch a { padding: 3px 10px; color: var(--text-secondary); text-decoration: none; letter-spacing: 1px; font-size: 11px; }
.switch a:hover { color: var(--text-primary); }
.switch a.active { background: var(--amber); color: #000; font-weight: bold; }
@media (max-width: 640px) { .switch a { padding: 3px 7px; font-size: 10px; } }
@media (max-width: 640px) { .hdr { flex-wrap: wrap; row-gap: 4px; } .hdr-mid { order: 3; flex-basis: 100%; text-align: left; } .hdr-right { display: none; } .switch { margin-left: auto; } }
