:root {
  color-scheme: dark;
  --bg: #212121;
  --panel: #282828;
  --panel-2: #303030;
  --sidebar: #181818;
  --surface-hover: #383838;
  --surface-inset: #1c1c1c;
  --line: #414141;
  --line-strong: #686868;
  --text: #ececec;
  --muted: #b4b4b4;
  --accent: #F9B98C;
  --accent-hover: #ffd0b0;
  --accent-ink: #211d1a;
  --accent-bg: rgba(249, 185, 140, 0.10);
  --chart-bg: #202020;
  --chart-grid: #333333;
  --chart-line: #484848;
  --zone-bg: #302c29;
  --zone-hover: #3c3530;
  --green: #4ade80;
  --green-bg: rgba(74, 222, 128, 0.12);
  --red: #fb7185;
  --red-bg: rgba(251, 113, 133, 0.14);
  --amber: #fbbf24;
  --amber-bg: rgba(251, 191, 36, 0.13);
  --blue: #60a5fa;
  --blue-bg: rgba(96, 165, 250, 0.12);
  --cyan: #22d3ee;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Segoe UI, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

html { scrollbar-color: var(--line-strong) var(--sidebar); }
::selection { background: var(--accent); color: var(--accent-ink); }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
button { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 4px; }
:where(button):hover:not(:disabled) { background: var(--surface-hover); }
input, select, textarea { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
summary::marker { color: var(--accent); }

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 14px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
}

h2 {
  font-size: 15px;
  font-weight: 700;
}

h3 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 8px;
  text-transform: uppercase;
}

#statusLine {
  color: var(--muted);
  margin-top: 3px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-email {
  color: var(--muted);
  font-size: 12px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button,
.segmented button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
  min-height: 34px;
}

.icon-button {
  padding: 0 12px;
}

.icon-button:hover,
.segmented button:hover {
  border-color: var(--accent);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  padding: 0 12px;
  color: var(--muted);
}

.segmented button.active {
  background: var(--accent-bg);
  color: var(--accent);
}

.page-tabs {
  align-self: center;
}

.page-tabs button {
  min-width: 96px;
}

.flow-toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
  padding: 2px 0 12px;
}

.compact-segmented button {
  min-height: 34px;
}

.range-fields {
  display: flex;
  align-items: end;
  gap: 8px;
}

.range-fields input {
  min-width: 132px;
}

.range-apply {
  white-space: nowrap;
}

.compact-field {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
}

.compact-field select,
.compact-field input {
  min-height: 34px;
  min-width: 138px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 9px;
}

.compact-field input:focus,
.compact-field select:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

.symbol-search-field input {
  min-width: 150px;
  text-transform: uppercase;
}

.symbol-select-field select {
  min-width: 150px;
}

.method-note {
  margin-left: auto;
  color: var(--amber);
  font-size: 12px;
  padding-bottom: 8px;
}

.flow-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  margin-bottom: 12px;
}

.flow-kpis > div {
  min-width: 0;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
}

.flow-kpis > div:last-child {
  border-right: 0;
}

.flow-kpis span,
.flow-kpis strong {
  display: block;
}

.flow-kpis span {
  color: var(--muted);
  font-size: 11px;
  white-space: normal;
}

.flow-kpis strong {
  margin-top: 4px;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.flow-workbench,
.flow-history-panel {
  margin-bottom: 12px;
}

.flow-chart-head {
  min-height: 48px;
}

.chart-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.flow-legend,
.flow-source-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 11px;
}

.flow-legend span::before,
.flow-source-legend span::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 5px;
  border-radius: 2px;
  background: var(--legend-color);
}

.legend-buy { --legend-color: #34d399; }
.legend-sell { --legend-color: #fb7185; }
.legend-neutral { --legend-color: #94a3b8; }
.source-total { --legend-color: #4ade80; }
.source-dark { --legend-color: #facc15; }
.source-dark-large { --legend-color: #ff981f; }
.source-sweep { --legend-color: #a63250; }
.source-lit { --legend-color: #4169e1; }
.source-delta { --legend-color: #f472b6; }

.trade-inspector { margin-top: 24px; padding: 20px 0; border-top: 1px solid var(--line); }
.trade-inspector h2 { font-size: 17px; margin: 0 0 16px; }
.trade-inspector h3 { font-size: 13px; margin: 16px 0; }
.inspect-form fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.inspect-form .compact-field { width: 170px; max-width: 100%; }
.inspect-form input:not([type="checkbox"]) { width: 100%; min-width: 0; }
.inspect-kinds, .inspect-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.inspect-kinds { min-height: 36px; font-size: 12px; }
.inspect-actions { margin-top: 14px; }
.inspect-note, #inspectStatus { font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; color: var(--muted); }
#inspectStatus { color: #facc15; }
.inspect-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-block: 1px solid var(--line); }
.inspect-summary > div { padding: 14px 10px; min-width: 0; }
.inspect-summary span { display: block; font-size: 11px; color: var(--muted); }
.inspect-summary strong { display: block; font-size: 18px; margin-top: 8px; overflow-wrap: anywhere; }
.inspect-analysis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.inspect-analysis > section { min-width: 0; }
.inspect-time-list { max-height: 510px; overflow-y: auto; }
.inspect-bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; padding: 8px 0; font-size: 12px; }
.inspect-bar-row span { overflow-wrap: anywhere; }
.inspect-bar-row meter { width: 100%; height: 12px; grid-column: 1 / -1; accent-color: #facc15; }
.inspect-bar-row meter::-webkit-meter-bar { background: var(--panel-2); border: 0; border-radius: 0; }
.inspect-bar-row meter::-webkit-meter-optimum-value { background: #facc15; }
.inspect-bar-row small { grid-column: 1 / -1; color: var(--muted); }
.inspect-table-wrap { overflow-x: auto; max-height: 460px; }
.inspect-table-wrap table { min-width: 830px; width: 100%; }
.inspect-table-wrap td, .inspect-table-wrap th { white-space: nowrap; }
.inspect-actions button:disabled { opacity: .45; cursor: default; }
@media (max-width: 700px) {
  .inspect-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inspect-analysis { grid-template-columns: minmax(0, 1fr); }
  .inspect-form .compact-field { flex: 1 1 140px; }
}

.market-chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  min-height: 520px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--chart-bg);
}

.flow-price-chart {
  min-width: 0;
  height: 520px;
}

.flow-price-stage {
  position: relative;
  min-width: 0;
  height: 520px;
}

.flow-oscillator-panel{border-top:1px solid var(--line)}
.flow-oscillator-panel>summary{min-height:44px;padding:10px 12px;box-sizing:border-box;cursor:pointer;color:var(--text);font-size:13px;font-weight:600;line-height:24px}
.flow-oscillator-panel>summary:hover{background:var(--panel-2)}
.flow-oscillator-panel>summary:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
.flow-oscillator-panel:not([open])>:not(summary){display:none}
.flow-oscillator-settings{display:flex;flex-wrap:wrap;align-items:end;gap:10px;padding:12px;border-bottom:1px solid var(--line)}
.flow-oscillator-settings label{display:grid;gap:4px;font-size:12px;color:var(--muted)}
.flow-oscillator-settings input{width:76px;min-height:34px;background:var(--panel-2);border:1px solid var(--line);color:var(--text);border-radius:4px;padding:4px 7px;box-sizing:border-box}
.flow-oscillator-settings button{min-height:36px;padding:6px 12px;background:var(--panel-2);color:var(--text);border:1px solid var(--line);border-radius:4px;cursor:pointer;white-space:nowrap}
.flow-oscillator-settings button:hover{border-color:var(--muted)}
.flow-oscillator-settings select{max-width:190px;min-height:34px;background:var(--panel-2);color:var(--text);border:1px solid var(--line);border-radius:4px;padding:4px 7px;}
.flow-oscillator-settings :disabled{opacity:.5}
.flow-oscillator-settings .osc-divergence,.flow-oscillator-settings .osc-visibility{display:flex;align-items:center;gap:6px;min-height:34px;}
.flow-oscillator-settings .osc-visibility{min-width:132px;align-self:center;white-space:nowrap}
.osc-visibility strong{font-size:13px;color:var(--text)}
.flow-oscillator-settings input[type=checkbox]{width:16px;height:16px;min-height:16px;margin:0;accent-color:var(--accent)}
.osc-actions{display:flex;gap:8px;align-items:center;}
.osc-error{color:#ef8395;font-size:12px;flex-basis:100%;}
.osc-error:empty{display:none}
@media(max-width:600px){
 .flow-workbench{--flow-price-height:360px;--flow-indicator-height:140px;}
 .flow-workbench .market-chart-grid{min-height:360px;}
 .flow-oscillator-settings{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));}
 .flow-oscillator-settings .osc-visibility,.flow-oscillator-settings .osc-actions,.flow-oscillator-settings .osc-error{grid-column:1/-1;}
 .flow-oscillator-settings select,.flow-oscillator-settings input:not([type=checkbox]){width:100%;min-width:0;max-width:100%;}
 .flow-oscillator-settings label{min-width:0;}
 .osc-actions button{flex:1;min-height:44px;}
}

.profile-column {
  position: relative;
  height: 520px;
  border-left: 1px solid var(--line);
}

.profile-title {
  position: absolute;
  z-index: 1;
  top: 7px;
  left: 9px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

#flowProfileChart {
  width: 100%;
  height: 520px;
}

.profile-price,
.svg-muted,
.history-label {
  fill: var(--muted);
  font-family: Segoe UI, sans-serif;
  font-size: 10px;
}

.zone-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 12px 4px;
  background: transparent;
}

.zone-item {
  min-width: 0;
  border: 0;
  border-top: 2px solid var(--zone-color, var(--accent));
  background: var(--zone-bg);
  padding: 12px;
  min-height: 44px;
  color: var(--text);
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.zone-item:hover:not(:disabled) { background: var(--zone-hover); }
.zone-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; background: var(--zone-hover); }

.flow-zone-heading { padding: 8px; color: var(--muted); font-size: 11px; }
.flow-focus { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; color: #ff981f; font-size: 12px; }
.flow-focus[hidden] { display: none; }
.history-hit { fill: transparent; cursor: pointer; }
.inspect-link { color: var(--accent); padding: 0; background: transparent; border: 0; text-align: left; font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.inspect-link:hover, .inspect-link:focus-visible { color: var(--accent-hover); }
.reaction-up { color: #4ade80; }
.reaction-down { color: #fb7185; }
#inspectPriceStatus { font-size: 12px; color: var(--muted); }
@media (max-width: 560px) { .zone-strip { grid-template-columns: 1fr; } }

.zone-item span,
.zone-item strong,
.zone-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zone-item span,
.zone-item small {
  color: var(--muted);
  font-size: 10px;
}

.zone-item strong {
  margin: 2px 0;
  color: var(--zone-color);
  font-variant-numeric: tabular-nums;
}

.tradingview-credit {
  padding: 5px 8px;
  color: var(--muted);
  font-size: 9px;
  text-align: right;
}

.tradingview-credit a {
  color: var(--accent);
}

.indicator-controls {
  position: absolute;
  z-index: 5;
  top: 8px;
  left: 10px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  max-width: calc(100% - 92px);
  min-height: 30px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
}

.indicator-controls label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  user-select: none;
}

.indicator-controls label:hover,
.indicator-controls label.active {
  border-color: var(--line);
  background: var(--surface-hover);
  color: var(--text);
}

.indicator-controls input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

.indicator-controls strong {
  font-size: 11px;
  font-weight: 600;
}

.indicator-controls small {
  min-width: 38px;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.indicator-swatch {
  width: 12px;
  height: 2px;
  background: var(--indicator-color);
}

.indicator-ohlc5 { --indicator-color: #e2e8f0; }
.indicator-ema5 { --indicator-color: #4ade80; }
.indicator-ema20 { --indicator-color: #fb923c; }
.inspect-table-wrap td.inspect-conditions { min-width: 170px; max-width: 240px; white-space: normal; overflow-wrap: anywhere; line-height: 1.5; }
.indicator-ema50 { --indicator-color: #3C0008; }
.indicator-sma60 { --indicator-color: #add8e6; }
.indicator-sma120 { --indicator-color: #818cf8; }

.flow-history-wrap {
  min-height: 330px;
  min-width: 0;
  overflow: hidden;
  background: var(--chart-bg);
}

.flow-history-grid {
  min-height: 330px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.history-profile-spacer {
  min-height: 330px;
  border-left: 1px solid var(--line);
  background: var(--chart-bg);
}

#flowHistoryChart {
  display: block;
  width: 100%;
  height: 330px;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
}

#flowHistoryChart.dragging { cursor: grabbing; }

.history-grid { stroke: var(--chart-grid); stroke-width: 1; }
.history-total { fill: rgba(74, 222, 128, .38); stroke: #4ade80; stroke-width: 1; }
.history-dark { fill: #facc15; }
.history-sweep { fill: #a63250; }
.history-lit { fill: #4169e1; }
.history-dark-large { stroke: #ff981f; stroke-width: 3; }
.history-zero { stroke: var(--chart-line); stroke-width: 1; }
.history-day-separator { stroke: rgba(251, 191, 36, .48); stroke-width: 1; stroke-dasharray: 4 4; }
.history-date-label { fill: #fbbf24; font-family: Segoe UI, sans-serif; font-size: 10px; }
.history-delta-buy { fill: #34d399; }
.history-delta-sell { fill: #fb7185; }

.flow-source-legend {
  padding: 9px 12px 2px;
}

@media (max-width: 900px) {
  .topbar {
    flex-wrap: wrap;
  }

  .page-tabs {
    order: 3;
    width: 100%;
  }

  .page-tabs button {
    flex: 1;
    min-width: 0;
    padding: 0 6px;
  }

  .flow-toolbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .range-fields {
    width: 100%;
  }

  .range-fields .compact-field,
  .range-fields input {
    flex: 1;
    min-width: 0;
  }

  .flow-chart-head,
  .chart-head-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .chart-head-actions .segmented,
  .flow-history-panel .segmented {
    overflow-x: auto;
  }

  .flow-history-panel .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .symbol-search-field,
  .symbol-search-field input {
    flex: 1;
    min-width: 140px;
  }

  .method-note {
    width: 100%;
    margin-left: 0;
    padding: 0;
  }

  .flow-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .flow-kpis > div:nth-child(3) {
    border-right: 0;
  }

  .flow-kpis > div:nth-child(-n+3) {
    border-bottom: 1px solid var(--line);
  }

  .market-chart-grid {
    grid-template-columns: minmax(0, 1fr) 150px;
  }

  .zone-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 8px;
  }

  .flow-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .flow-kpis > div,
  .flow-kpis > div:nth-child(3) {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .flow-kpis > div:nth-child(even) {
    border-right: 0;
  }

  .market-chart-grid {
    grid-template-columns: minmax(0, 1fr) 112px;
  }

  .zone-strip {
    grid-template-columns: 1fr;
  }

  .flow-legend {
    display: none;
  }
}

.alert {
  border: 1px solid rgba(251, 113, 133, 0.5);
  background: var(--red-bg);
  color: #ffd6de;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.hidden {
  display: none !important;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 12px;
  min-height: 74px;
}

.metric-panel span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.metric-panel strong {
  font-size: 28px;
  line-height: 1;
}

.metric-panel.danger strong {
  color: var(--red);
}

.metric-panel.warn strong,
.metric-panel.caution strong {
  color: var(--amber);
}

.metric-panel.good strong {
  color: var(--green);
}

.metric-panel.watch strong {
  color: var(--cyan);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(520px, 1fr);
  gap: 12px;
  align-items: start;
}

.watch-panel {
  grid-column: 1 / 2;
  grid-row: 1 / span 2;
}

.sector-panel {
  grid-column: 2 / -1;
}

.ranking-panel {
  grid-column: 2 / 3;
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  min-height: 120px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  min-height: 48px;
  padding: 10px 12px;
}

.rank-head {
  align-items: center;
}

.filters {
  display: flex;
  gap: 8px;
  min-width: 360px;
}

.filters input,
.filters select {
  border: 1px solid var(--line);
  background: var(--surface-inset);
  color: var(--text);
  border-radius: 6px;
  height: 34px;
  padding: 0 10px;
  min-width: 0;
}

.filters input {
  flex: 1;
}

.watch-list {
  display: grid;
  gap: 8px;
  padding: 10px;
  max-height: calc(100vh - 190px);
  overflow: auto;
}

.watch-item {
  border: 1px solid var(--line);
  background: var(--chart-bg);
  border-radius: 7px;
  padding: 9px;
}

.watch-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.watch-top strong {
  font-size: 15px;
}

.watch-item p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.sell-exit {
  background: var(--red-bg);
  color: var(--red);
}

.badge.sell-reduce,
.badge.sell-warn {
  background: var(--amber-bg);
  color: var(--amber);
}

.badge.buy-confirm {
  background: var(--green-bg);
  color: var(--green);
}

.badge.buy-watch {
  background: var(--blue-bg);
  color: var(--cyan);
}

.badge.none {
  background: var(--surface-hover);
  color: var(--muted);
}

.table-wrap {
  max-height: calc(100vh - 190px);
  overflow: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px 9px;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td {
  font-size: 13px;
}

tbody tr:hover {
  background: var(--surface-hover);
}

.symbol-cell {
  display: grid;
  gap: 2px;
}

.symbol-cell strong {
  font-size: 14px;
}

.symbol-cell span,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.score-bar {
  display: grid;
  gap: 4px;
  min-width: 78px;
}

.score-track {
  background: var(--surface-inset);
  border: 1px solid var(--line);
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  background: var(--blue);
}

.score-fill.sell {
  background: var(--red);
}

.score-fill.buy {
  background: var(--green);
}

.panel-subtitle {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.sector-summary {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  padding: 10px 12px;
}

.sector-chip {
  border: 1px solid var(--line);
  background: var(--chart-bg);
  border-radius: 7px;
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 8px 9px;
}

.sector-chip strong {
  font-size: 14px;
}

.sector-chip span,
.sector-chip small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sector-chip em {
  font-style: normal;
  font-weight: 750;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.neutral {
  color: var(--muted);
}

.sector-table-wrap {
  max-height: 315px;
}

.empty-state {
  color: var(--muted);
  padding: 18px 12px;
}

.flow-ranking-toolbar {
  align-items: flex-end;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 4px 0 12px;
}

.vp-toolbar {
  align-items: flex-end;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding: 4px 0 12px;
}

.vp-interval-control { margin-left: auto; }

.vp-summary {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 10px;
}

.vp-summary > div { border-right: 1px solid var(--line); min-width: 0; padding: 10px 12px; }
.vp-summary > div:last-child { border-right: 0; }
.vp-summary span, .vp-summary strong { display: block; }
.vp-summary span { color: var(--muted); font-size: 10px; margin-bottom: 3px; }
.vp-summary strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.positive { color: #34d399 !important; }
.negative { color: #fb7185 !important; }

.vp-workbench { margin-bottom: 10px; }
.vp-chart-head { align-items: flex-start; }
.vp-key { display: flex; flex-wrap: wrap; gap: 12px; }
.vp-key span { color: var(--muted); font-size: 10px; }
.vp-key span::before { content: ""; display: inline-block; height: 7px; margin-right: 5px; width: 14px; }
.vp-key-poc::before { background: #fbbf24; }
.vp-key-hvz::before { background: #60a5fa; }
.vp-key-buy::before { background: #34d399; }
.vp-key-sell::before { background: #fb7185; }
.vp-method-strip { border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 16px; padding: 8px 10px; }
.vp-method-strip span { color: var(--muted); font-size: 10px; }
.vp-confirm-panel { padding-bottom: 0; }
.vp-confirm-wrap { max-height: 360px; }
.vp-pressure-band { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); border-block: 1px solid var(--line); margin: 12px 0 0; }
.vp-pressure-band > div { padding: 12px; min-width: 0; }
.vp-pressure-band span, .vp-pressure-band small { display: block; color: var(--muted); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.vp-pressure-band strong { display:block; margin:4px 0; font-size:18px; }
.vp-quality { margin: 8px 0 14px; font-size:12px; line-height:1.7; color:var(--muted); overflow-wrap:anywhere; }
.vp-summary strong { white-space: normal; overflow-wrap: anywhere; text-overflow: clip; }
@media(max-width:560px) { .vp-pressure-band > div {padding:8px;} .vp-pressure-band strong {font-size:16px;} }
.vp-confirm-table th, .vp-confirm-table td { font-size: 11px; white-space: nowrap; }
.vp-confirm-table tbody tr:hover { background: var(--surface-hover); }

@media (max-width: 900px) {
  .vp-interval-control { margin-left: 0; width: 100%; }
  .vp-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .vp-summary > div:nth-child(3) { border-right: 0; }
  .vp-summary > div:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
}

.flow-ranking-toolbar h2 {
  font-size: 16px;
  margin: 0 0 3px;
}

.ranking-controls {
  align-items: flex-end;
  display: flex;
  gap: 10px;
}

.flow-ranking-summary {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 10px;
}

.flow-ranking-summary > div {
  border-right: 1px solid var(--line);
  min-width: 0;
  padding: 10px 12px;
}

.flow-ranking-summary > div:last-child {
  border-right: 0;
}

.flow-ranking-summary span,
.flow-ranking-summary strong {
  display: block;
}

.flow-ranking-summary span {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 3px;
}

.flow-ranking-summary strong {
  font-size: 17px;
}

.ranking-status {
  color: var(--muted);
  font-size: 11px;
  margin: 0 2px 8px;
}

.flow-ranking-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.flow-side {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  min-width: 0;
  overflow: hidden;
}

.flow-inflow-side {
  border-top: 2px solid rgba(74, 222, 128, .8);
}

.flow-outflow-side {
  border-top: 2px solid rgba(251, 113, 133, .8);
}

.flow-side-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 9px 12px;
}

.flow-side-head h3 {
  font-size: 13px;
  margin: 0;
}

.flow-side-head span {
  color: var(--muted);
  font-size: 11px;
}

.flow-rank-list {
  max-height: calc(100vh - 295px);
  min-height: 420px;
  overflow-y: auto;
}

.flow-rank-row {
  align-items: center;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  display: grid;
  font: inherit;
  gap: 8px;
  grid-template-columns: 48px minmax(80px, 1fr) 62px 70px;
  min-height: 34px;
  padding: 5px 10px;
  text-align: left;
  width: 100%;
}

.flow-rank-row:hover {
  background: var(--surface-hover);
}

.flow-rank-symbol {
  font-size: 12px;
  font-weight: 750;
}

.flow-rank-track {
  appearance: none;
  background: var(--surface-hover);
  border: 0;
  display: block;
  height: 12px;
  overflow: hidden;
  width: 100%;
}

.flow-rank-track::-webkit-progress-bar,
.mismatch-track progress::-webkit-progress-bar {
  background: var(--surface-hover);
}

.flow-rank-track.inflow {
  accent-color: #34d399;
}

.flow-rank-track.inflow::-webkit-progress-value {
  background: #34d399;
}

.flow-rank-track.inflow::-moz-progress-bar {
  background: #34d399;
}

.flow-rank-track.outflow {
  accent-color: #fb7185;
}

.flow-rank-track.outflow::-webkit-progress-value {
  background: #fb7185;
}

.flow-rank-track.outflow::-moz-progress-bar {
  background: #fb7185;
}

.flow-rank-row strong {
  font-size: 11px;
  text-align: right;
}

.flow-rank-row small {
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.flow-rank-row.is-missing {
  opacity: .52;
}

.mismatch-track {
  display: grid;
  gap: 3px;
  grid-template-rows: repeat(2, 5px);
}

.mismatch-track progress {
  appearance: none;
  background: var(--surface-hover);
  border: 0;
  display: block;
  height: 5px;
  width: 100%;
}

.mismatch-track .positive-bar {
  accent-color: #34d399;
}

.mismatch-track .positive-bar::-webkit-progress-value {
  background: #34d399;
}

.mismatch-track .positive-bar::-moz-progress-bar {
  background: #34d399;
}

.mismatch-track .negative-bar {
  accent-color: #fb7185;
}

.mismatch-track .negative-bar::-webkit-progress-value {
  background: #fb7185;
}

.mismatch-track .negative-bar::-moz-progress-bar {
  background: #fb7185;
}

.mismatch-row strong,
.mismatch-row small {
  white-space: nowrap;
}

.ranking-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 18px 12px;
}

.short-toolbar,
.short-controls {
  align-items: flex-end;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.short-toolbar {
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
  padding-bottom: 12px;
}

.short-toolbar h2 {
  font-size: 15px;
  margin: 0 0 3px;
}

.short-summary {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 8px;
}

.short-summary > div {
  border-right: 1px solid var(--line);
  display: grid;
  gap: 3px;
  padding: 10px 12px;
}

.short-summary > div:last-child {
  border-right: 0;
}

.short-summary span {
  color: var(--muted);
  font-size: 10px;
}

.short-summary strong {
  font-size: 17px;
}

.short-table-panel {
  overflow: hidden;
}

.short-table-wrap {
  max-height: calc(100vh - 265px);
}

.short-table th,
.short-table td {
  white-space: nowrap;
}

.short-table tbody tr {
  cursor: pointer;
}

.short-table tbody tr:hover {
  background: var(--surface-hover);
}

.dtc-cell {
  align-items: center;
  display: flex;
  gap: 8px;
}

.dtc-cell strong {
  min-width: 34px;
}

.dtc-meter {
  background: var(--surface-hover);
  display: block;
  height: 6px;
  width: 70px;
}

.dtc-meter i {
  background: #fbbf24;
  display: block;
  height: 100%;
}

.short-risk {
  border: 1px solid var(--line);
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
}

.short-risk.danger {
  border-color: rgba(251, 113, 133, .55);
  color: #fb7185;
}

.short-risk.warn {
  border-color: rgba(251, 191, 36, .55);
  color: #fbbf24;
}

.short-risk.quiet {
  color: var(--muted);
}

@media (max-width: 1180px) {
  .dashboard-grid {
    grid-template-columns: 280px 1fr;
  }

  .watch-panel {
    grid-column: 1 / 2;
    grid-row: 1 / span 2;
  }

  .sector-panel,
  .ranking-panel {
    grid-column: 2 / 3;
  }

  .sector-summary {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .rank-head {
    align-items: stretch;
    flex-direction: column;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .watch-panel,
  .sector-panel,
  .ranking-panel {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .filters {
    min-width: 0;
    width: 100%;
  }

  .watch-list,
  .table-wrap,
  .sector-table-wrap {
    max-height: none;
  }

  .sector-summary {
    grid-template-columns: 1fr;
  }

  .flow-ranking-toolbar,
  .ranking-controls,
  .short-toolbar,
  .short-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .short-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .short-summary > div:nth-child(2) {
    border-right: 0;
  }

  .short-summary > div:nth-child(-n+2) {
    border-bottom: 1px solid var(--line);
  }

  .short-table-wrap {
    max-height: none;
  }

  .flow-ranking-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .flow-ranking-summary > div:nth-child(2) {
    border-right: 0;
  }

  .flow-ranking-summary > div:nth-child(-n+2) {
    border-bottom: 1px solid var(--line);
  }

  .flow-ranking-grid {
    grid-template-columns: 1fr;
  }

  .flow-rank-list {
    max-height: none;
    min-height: 0;
  }

  .flow-rank-row {
    grid-template-columns: 44px minmax(70px, 1fr) 58px;
  }

  .flow-rank-row small {
    display: none;
  }
}

.macro-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 2px 14px;
}

.macro-controls,
.macro-legend {
  display: flex;
  align-items: center;
  gap: 10px;
}

.macro-summary {
  display: grid;
  grid-template-columns: repeat(7, minmax(118px, 1fr));
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  margin-bottom: 12px;
}

.macro-summary > div {
  min-width: 0;
  padding: 12px 14px;
  background: var(--panel-2);
  border-right: 1px solid var(--line);
}

.macro-summary > div:last-child {
  border-right: 0;
}

.macro-summary span,
.macro-summary small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.macro-summary strong {
  display: block;
  margin: 4px 0 2px;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.macro-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.macro-panel {
  min-width: 0;
  padding-bottom: 8px;
}

.macro-chart {
  display: block;
  width: 100%;
  height: 300px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.macro-legend {
  min-height: 34px;
  padding: 8px 12px 0;
  color: var(--muted);
  font-size: 11px;
  flex-wrap: wrap;
}

.macro-legend span::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 3px;
  margin-right: 5px;
  vertical-align: middle;
  background: currentColor;
}

.macro-current,
.macro-rate10,
.macro-cpi { color: var(--amber); }
.macro-previous,
.macro-rate2,
.macro-pce { color: var(--blue); }
.macro-rate-spread,
.macro-jobless { color: var(--green); }
.macro-target { color: var(--muted); }
.macro-expect { color: var(--cyan); }
.macro-sofr { color: var(--red); }

.macro-axis-label,
.macro-date-label,
.macro-point-label {
  fill: var(--muted);
  font-family: Segoe UI, system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0;
}

.macro-point-label {
  fill: var(--text);
  font-size: 10px;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 184px;
  padding: 22px 12px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  z-index: 20;
}
.app-sidebar summary { padding: 8px; font-size: 15px; font-weight: 600; cursor: pointer; }
.sidebar-nav { display: grid; gap: 4px; }
.sidebar-nav h2 { margin: 24px 10px 8px; font-size: 13px; font-weight: 700; color: var(--text); }
.flow-zone-note { margin: 8px 12px 12px; color: var(--muted); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.sidebar-nav button {
  min-height: 40px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 4px;
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.sidebar-nav button:hover { background: var(--panel-2); color: var(--text); }
.sidebar-nav button.active { background: var(--accent-bg); color: var(--accent); border-left-color: var(--accent); }
.app-shell { margin-left: 184px; padding: 14px 48px 32px 18px; min-width: 0; }
.vp-confirm-wrap { max-height: none; }
#flowHistoryChart { touch-action: pan-y; }
@media (min-width: 761px) {
  .app-sidebar summary { pointer-events: none; list-style: none; }
  .app-sidebar summary::-webkit-details-marker { display: none; }
}
@media (max-width: 760px) {
  .app-sidebar { position: static; width: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .app-shell { margin-left: 0; padding: 10px 18px 24px 8px; }
  .sidebar-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-nav h2 { grid-column: 1 / -1; margin-top: 12px; }
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .top-actions { flex-wrap: wrap; max-width: 100%; }
}

.macro-grid-line {
  stroke: var(--line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

@media (max-width: 1180px) {
  .macro-summary { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
  .macro-summary > div:nth-child(4) { border-right: 0; }
  .macro-summary > div:nth-child(n+5) { border-top: 1px solid var(--line); }
}

@media (max-width: 820px) {
  .macro-toolbar { align-items: stretch; flex-direction: column; }
  .macro-controls { justify-content: space-between; }
  .macro-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .macro-summary > div { border-top: 1px solid var(--line); }
  .macro-summary > div:nth-child(odd) { border-right: 1px solid var(--line); }
  .macro-summary > div:nth-child(even) { border-right: 0; }
  .macro-grid { grid-template-columns: 1fr; }
}
