:root {
  --bg: #0b0e13;
  --panel: #12161d;
  --panel-2: #171c25;
  --border: #232a35;
  --text: #e6edf3;
  --muted: #8b98a9;
  --up: #26a69a;
  --down: #ef5350;
  --accent: #4c8dff;
  --warn: #e3b341;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 600; }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 18px;
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }

.search-wrap { position: relative; flex: 1; max-width: 380px; }

#symbol-search {
  width: 100%;
  padding: 8px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
#symbol-search:focus { border-color: var(--accent); }

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  z-index: 60;
}

.search-results div {
  display: flex;
  justify-content: space-between;
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.search-results div:last-child { border-bottom: 0; }
.search-results div:hover { background: rgba(76, 141, 255, 0.12); }

.intervals { display: flex; gap: 4px; margin-left: auto; }

.intervals button {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.intervals button:hover { color: var(--text); background: var(--panel-2); }
.intervals button.active { color: var(--accent); background: rgba(76, 141, 255, 0.14); }

.live-dot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.live-dot span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--up);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.25; } }

/* ---------- layout ---------- */

.layout { display: flex; align-items: flex-start; }

.sidebar {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  height: calc(100vh - 56px);
  position: sticky;
  top: 56px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 14px 16px 10px;
}
.sidebar-head h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.sidebar-head span { font-size: 11px; }

.market-list { overflow-y: auto; flex: 1; }

.market-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  padding: 9px 16px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.market-row:hover { background: var(--panel-2); }
.market-row.active { background: rgba(76, 141, 255, 0.1); border-left-color: var(--accent); }
.market-row .sym { font-weight: 600; font-size: 13px; }
.market-row .px { font-family: var(--mono); font-size: 12px; text-align: right; }
.market-row .vol { font-size: 11px; color: var(--muted); }
.market-row .chg { font-family: var(--mono); font-size: 11px; text-align: right; }

.main { flex: 1; min-width: 0; padding: 16px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- price header ---------- */

.price-header {
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
  padding: 16px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.ph-symbol h1 { font-size: 22px; letter-spacing: -0.02em; }
.ph-symbol .muted { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }

.ph-price { display: flex; align-items: baseline; gap: 12px; }
.ph-price .big { font-family: var(--mono); font-size: 28px; font-weight: 600; }
.ph-price .change { font-family: var(--mono); font-size: 14px; font-weight: 600; }

.ph-stats { display: flex; gap: 28px; margin: 0 0 0 auto; }
.ph-stats dt { font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.ph-stats dd { margin: 2px 0 0; font-family: var(--mono); font-size: 13px; }

.up { color: var(--up); }
.down { color: var(--down); }

/* ---------- panels ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.panel-head h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.toggles { display: flex; gap: 14px; flex-wrap: wrap; }
.toggles label { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); cursor: pointer; }
.toggles input { accent-color: var(--accent); }

/* Heights scale with the viewport but stay within sane bounds, so the chart
   is usable on a laptop without swallowing a large monitor. */
.chart { width: 100%; height: clamp(300px, 46vh, 520px); }
/* The RSI pane owns the shared date axis, so it needs ~28px more than the
   plot alone would require. */
.chart.rsi { height: 148px; }
.chart.flow { height: clamp(280px, 40vh, 440px); }
/* The bottom pane owns the shared date axis, so it needs ~28px more than
   its plot alone would require. */
.chart.cum { height: 190px; }

/* ---------- regime banner ---------- */

.regime {
  border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 14px 0 4px;
  background: var(--panel-2);
}
.regime.buying { border-left-color: var(--up); }
.regime.selling { border-left-color: var(--down); }
/* A turn within the last couple of bars is the thing worth noticing. */
.regime.fresh { box-shadow: inset 0 0 0 1px rgba(76, 141, 255, 0.28); }

.regime-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.regime-head h3 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }

.regime-icon { font-size: 15px; }
.regime.buying .regime-icon { color: var(--up); }
.regime.selling .regime-icon { color: var(--down); }
.regime.balanced .regime-icon { color: var(--muted); }

.pill {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(139, 152, 169, 0.16);
  color: var(--muted);
}
.regime.buying .pill { background: rgba(38, 166, 154, 0.16); color: var(--up); }
.regime.selling .pill { background: rgba(239, 83, 80, 0.16); color: var(--down); }

.regime-bias {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.regime-line {
  margin-top: 9px;
  padding-left: 11px;
  border-left: 2px solid var(--border);
  font-size: 13px;
  line-height: 1.6;
}
.regime-line.signal { border-left-color: var(--accent); }
.regime-line.noise, .regime-line.muted-line { color: var(--muted); }
.regime-line.thin, .regime-line.none, .regime-line.warn { border-left-color: var(--warn); }

/* ---------- flow stats ---------- */

.flow-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}

.fstat {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.fstat .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.fstat .value { font-family: var(--mono); font-size: 17px; font-weight: 600; margin-top: 3px; }
.fstat .value .of { font-size: 12px; color: var(--muted); font-weight: 400; }
.fstat .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.flow-note {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  background: var(--panel-2);
  border-left: 3px solid var(--muted);
}
.flow-note.warn { border-left-color: var(--warn); }
.chart.equity { height: clamp(240px, 34vh, 360px); margin: 16px 0; }

.chart-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 10px 0 2px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ---------- strategy tester ---------- */

.controls { display: flex; gap: 8px; }

select, button.primary {
  padding: 7px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.1); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

.explainer {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--muted);
  max-width: 76ch;
  line-height: 1.6;
}

.status { padding: 14px 0; font-size: 13px; color: var(--muted); }

/* ---------- market read ---------- */

.read-summary {
  margin: 0 0 14px;
  padding: 10px 12px;
  background: var(--panel-2);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
}

.read-list { display: flex; flex-direction: column; gap: 10px; }

.reading {
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--panel-2);
}
.reading.signal { border-left-color: var(--accent); }
.reading.noise  { border-left-color: var(--muted); }
.reading.thin, .reading.none { border-left-color: var(--warn); }

.reading header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.reading h3 { margin: 0; font-size: 14px; font-weight: 600; }

.chip {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.chip.signal { background: rgba(76, 141, 255, 0.18); color: #7fb0ff; }
.chip.noise  { background: rgba(139, 152, 169, 0.16); color: var(--muted); }
.chip.thin, .chip.none { background: rgba(227, 179, 65, 0.15); color: var(--warn); }

.reading .textbook {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.reading .textbook b { color: #a9b6c7; font-weight: 600; }

.reading .actual { margin: 0; font-size: 13px; line-height: 1.6; }

/* Win rate against the coin's own base rate, as a pair of stacked bars. */
.horizons { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; }

.horizon { min-width: 132px; flex: 1; }
.horizon .h-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 5px;
}
.bar-row { display: flex; align-items: center; gap: 7px; margin-bottom: 3px; }
.bar-row .tag { font-size: 10px; color: var(--muted); width: 46px; flex-shrink: 0; }
.bar-track { flex: 1; height: 6px; background: #0d1117; border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; }
.bar-fill.cond { background: var(--accent); }
.bar-fill.base { background: #48566b; }
.bar-row .pct { font-family: var(--mono); font-size: 10px; width: 34px; text-align: right; }

/* ---------- who is trading ---------- */

.tiers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: 4px 0 14px;
}

.tier {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
}
.tier.quiet { opacity: 0.55; }

.tier-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tier-label { font-size: 12px; font-weight: 600; }
.tier-total { font-family: var(--mono); font-size: 13px; }

.tier-share { display: flex; align-items: center; gap: 7px; margin: 8px 0 9px; }
.share-track { flex: 1; height: 5px; background: #0d1117; border-radius: 3px; overflow: hidden; }
.share-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.share-pct { font-family: var(--mono); font-size: 10px; color: var(--muted); width: 36px; text-align: right; }

.split-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: #0d1117; }
.split-buy { background: var(--up); }
.split-sell { background: var(--down); }
.split-labels {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 10px;
}

.tier-empty { font-size: 11px; color: var(--muted); padding: 4px 0; }
.tier-count { font-size: 10px; color: var(--muted); margin-top: 7px; }

.participants-summary {
  margin: 0 0 4px;
  padding: 10px 12px;
  background: var(--panel-2);
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
}

.largest table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12px; }
.largest th, .largest td { text-align: right; padding: 5px 9px; border-bottom: 1px solid var(--border); }
.largest th:first-child, .largest td:first-child { text-align: left; }
.largest th { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.largest td { font-family: var(--mono); }

/* ---------- inline guide ---------- */

.guide { margin: 4px 0 14px; }
.guide summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  padding: 6px 0;
}
.guide summary:hover { filter: brightness(1.2); }

.guide-body {
  font-size: 13px;
  line-height: 1.65;
  color: #c4cfdc;
  max-width: 80ch;
  border-left: 2px solid var(--border);
  padding-left: 14px;
  margin-top: 6px;
}
.guide-body p { margin: 0 0 10px; }
.guide-body ol { margin: 0 0 10px; padding-left: 20px; }
.guide-body li { margin-bottom: 7px; }
.guide-body strong { color: var(--text); }
.mono { font-family: var(--mono); font-size: 12px; color: var(--warn); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.stat {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.stat .label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.stat .value { font-family: var(--mono); font-size: 17px; font-weight: 600; margin-top: 3px; }
.stat .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.verdict { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

.verdict .line {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  border-left: 3px solid var(--muted);
  background: var(--panel-2);
}
.verdict .line.good { border-left-color: var(--up); }
.verdict .line.warn { border-left-color: var(--warn); }
.verdict .line.bad { border-left-color: var(--down); }

.folds { margin-top: 14px; }
.folds summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.folds summary:hover { color: var(--text); }

/* Scoped to .folds on purpose. lightweight-charts lays its panes out with a
   real <table>, so a bare `table { margin-top }` here silently shifts the
   chart down and pushes its time axis out of the container. Keep every rule
   below inside .folds. */
.folds table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 12px; }
.folds th, .folds td { text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.folds th:first-child, .folds td:first-child { text-align: left; }
.folds th { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.folds td { font-family: var(--mono); }
.folds td.params { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: left; }

.loading { padding: 20px 16px; color: var(--muted); font-size: 13px; }

.foot {
  font-size: 11px;
  color: var(--muted);
  padding: 4px 2px 20px;
  max-width: 80ch;
  line-height: 1.6;
}
.foot p { margin: 0 0 6px; }
.foot a { color: var(--muted); text-decoration: underline; }
.foot a:hover { color: var(--text); }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .sidebar { width: 210px; }
  .ph-stats { gap: 18px; }
}

@media (max-width: 900px) {
  .sidebar { display: none; }
  .topbar { gap: 12px; padding: 0 12px; }
  .main { padding: 12px; gap: 12px; }
  .price-header { gap: 18px; padding: 14px 16px; }
  .ph-stats { margin-left: 0; width: 100%; justify-content: space-between; gap: 12px; }
  .chart { height: clamp(260px, 40vh, 380px); }
}

@media (max-width: 640px) {
  /* Below this the interval buttons and search cannot share a row. */
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 10px 12px;
    row-gap: 10px;
  }
  .search-wrap { order: 3; max-width: none; flex-basis: 100%; }
  .intervals { margin-left: auto; }
  .intervals button { padding: 6px 9px; }
  .live-dot { display: none; }

  .sidebar { top: 0; }
  .price-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .ph-price .big { font-size: 23px; }
  .ph-stats { gap: 10px; flex-wrap: wrap; }
  .ph-stats > div { min-width: 68px; }

  .panel { padding: 12px; }
  .panel-head { gap: 10px; }
  .toggles { gap: 10px; }
  .controls { width: 100%; }
  .controls select { flex: 1; }

  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
  .stat .value { font-size: 15px; }

  /* A four-column fold table cannot shrink below the width of its dates. */
  .folds { overflow-x: auto; }
  .folds table { min-width: 480px; }
}

/* footprint score tables */
.largest td.muted-cell { color: var(--muted); }
.tick { color: var(--accent); font-size: 11px; }
.reading header .muted { font-size: 11px; }

/* ---------- scanner page ---------- */

.scanner-sub { font-size: 12px; }
.scanner-main { max-width: 1400px; margin: 0 auto; width: 100%; }

.funnel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.scan-table-wrap { overflow-x: auto; margin-top: 12px; }

.scan-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 860px; }
.scan-table th {
  text-align: right;
  padding: 8px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
}
.scan-table th:first-child, .scan-table td:first-child { text-align: left; }
.scan-table td { text-align: right; padding: 9px 12px; font-family: var(--mono); }

.scan-row { border-bottom: 1px solid var(--border); }
.scan-row:hover { background: var(--panel-2); }
/* Only the highest-conviction rows get emphasis; everything else stays quiet
   so the eye lands on the two or three that matter. */
.scan-row.flagged { background: rgba(76, 141, 255, 0.06); }
.scan-row.flagged td:first-child { box-shadow: inset 2px 0 0 var(--accent); }

.scan-row .asset { cursor: pointer; font-family: inherit; }
.scan-row .asset:hover strong { color: var(--accent); text-decoration: underline; }

.why-row td { padding: 0 12px 8px; border-bottom: 1px solid var(--border); }
.why-row .guide { margin: 0; }
.why-row .guide-body ul { margin: 6px 0; padding-left: 18px; }
.why-row .guide-body li { margin-bottom: 5px; }
.why-row a { color: var(--accent); }

@media (max-width: 640px) {
  .scanner-sub { display: none; }
}

/* setup column */
.scan-table td.setup-cell { text-align: left; font-family: inherit; font-size: 12px; white-space: nowrap; }
.setup-light { margin-right: 6px; }
.conf {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  margin-left: 7px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.setup-reason { color: #c4cfdc; }
.evidence-head {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 10px 0 2px;
}

/* ---------- bitcoin bench ---------- */

.btc-main { max-width: 1600px; margin: 0 auto; width: 100%; }

.btc-price { display: flex; align-items: baseline; gap: 10px; margin-left: 22px; }
.btc-price .big { font-family: var(--mono); font-size: 19px; font-weight: 600; }
.btc-price .change { font-family: var(--mono); font-size: 12px; font-weight: 600; }

.nav-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
}
.nav-link:hover { background: var(--panel-2); }

.toggle-inline {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.toggle-inline input { accent-color: var(--accent); }

/* Two across on a wide screen so the 1D/4H pair and the 1H/15m pair sit on
   their own rows -- context above, execution below. */
.btc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.chart-card { display: flex; flex-direction: column; }
.chart-card .panel-head { margin-bottom: 8px; }
.btc-chart { height: clamp(300px, 38vh, 420px); }

@media (max-width: 1100px) {
  .btc-grid { grid-template-columns: minmax(0, 1fr); }
  .btc-chart { height: clamp(280px, 44vh, 380px); }
}

@media (max-width: 640px) {
  .btc-price { margin-left: 0; }
  .btc-price .big { font-size: 16px; }
}

/* ---------- companion verdict ---------- */

.verdict {
  border: 1px solid var(--border);
  border-left: 5px solid var(--muted);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 20px 22px;
}
.verdict.stand-aside { border-left-color: var(--warn); }
.verdict.setup { border-left-color: var(--up); }
.verdict.context { border-left-color: var(--muted); }

.verdict-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.verdict-head h1 { font-size: 21px; font-weight: 600; letter-spacing: -0.01em; }

.verdict-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 5px 11px;
  border-radius: 20px;
  background: rgba(139, 152, 169, 0.16);
  color: var(--muted);
  white-space: nowrap;
}
.verdict.stand-aside .verdict-badge { background: rgba(227, 179, 65, 0.16); color: var(--warn); }
.verdict.setup .verdict-badge { background: rgba(38, 166, 154, 0.16); color: var(--up); }

.verdict-reasons { margin: 14px 0 0; padding-left: 20px; }
.verdict-reasons li { margin-bottom: 8px; line-height: 1.6; color: #c4cfdc; }

/* ---------- sensors ---------- */

.sensor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.sensor {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 9px;
  padding: 13px 15px;
}
.sensor.bullish { border-left-color: var(--up); }
.sensor.bearish { border-left-color: var(--down); }
.sensor.risk { border-left-color: var(--warn); }
.sensor.down-state { border-left-color: var(--down); opacity: 0.7; }

.sensor header { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 8px; }
.sensor h3 { margin: 0; font-size: 13px; font-weight: 600; }
.sensor-icon { font-size: 13px; }
.warn-text { color: var(--warn); }

.sensor-headline { margin: 0 0 10px; font-size: 13px; line-height: 1.5; }

.strength { display: flex; align-items: center; gap: 8px; }
.strength-track { flex: 1; height: 5px; background: #0d1117; border-radius: 3px; overflow: hidden; }
/* Untested sensors get a muted bar so a strong-but-unproven reading never
   looks more important than a weak-but-measured one. */
.strength-fill { height: 100%; background: #48566b; border-radius: 3px; }
.strength-fill.weighted { background: var(--accent); }
.strength-num { font-family: var(--mono); font-size: 10px; color: var(--muted); }

.edge-note { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 8px; }

/* ---------- structure block ---------- */

.tf-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 14px; }

.setup-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 14px 16px;
}
.setup-title { font-size: 15px; margin-bottom: 6px; }
.setup-box .evidence { margin: 10px 0 0; padding-left: 20px; }
.setup-box .evidence li { margin-bottom: 5px; font-size: 13px; line-height: 1.55; color: #c4cfdc; }

.level-list { list-style: none; margin: 6px 0 0; padding: 0; }
.level-list li { display: flex; gap: 10px; align-items: baseline; padding: 5px 0; font-size: 13px; }
.level-list li span:first-child { width: 78px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.level-list strong { font-family: var(--mono); }

/* ---------- risk sizer ---------- */

.sizer {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.sizer label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.sizer input {
  width: 130px;
  padding: 7px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}
.sizer input:focus { outline: none; border-color: var(--accent); }
.sizer-out { flex: 1; min-width: 260px; font-size: 13px; line-height: 1.6; }
.sizer-out .muted { font-size: 12px; }

/* ---------- login ---------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px 28px;
}
.login-brand { font-size: 22px; margin-bottom: 4px; }
.login-sub { font-size: 12px; margin: 0 0 22px; }
.login-card label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 6px;
}
.login-card input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.login-card input[type="password"]:focus { border-color: var(--accent); }
.login-btn { width: 100%; margin-top: 14px; padding: 10px; }
.login-error {
  background: rgba(239, 83, 80, 0.12);
  border-left: 3px solid var(--down);
  border-radius: 7px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.login-foot { font-size: 11px; color: var(--muted); margin: 20px 0 0; line-height: 1.6; }
.nav-link.logout { color: var(--muted); }
.nav-link.logout:hover { color: var(--down); }

/* ---------- brand is a link now, not a div ---------- */
.brand { text-decoration: none; color: var(--text); }
.brand:hover { color: var(--text); }

/* ---------- mobile ---------- */

/* Toggle only exists on narrow screens, where the sidebar becomes a drawer. */
.drawer-toggle { display: none; }

@media (max-width: 900px) {
  /* One compact row: menu, brand, price. Everything else moves or shrinks —
     the old layout wrapped into four rows and ate 176px of an 812px screen. */
  .topbar {
    height: auto;
    padding: 8px 10px;
    gap: 8px;
    row-gap: 8px;
    flex-wrap: wrap;
  }

  .drawer-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
  }

  .brand { font-size: 15px; }
  .scanner-sub, .live-dot { display: none; }

  .btc-price { margin-left: auto; gap: 6px; }
  .btc-price .big { font-size: 15px; }
  .btc-price .change { font-size: 11px; }

  .topbar .controls { margin-left: 0 !important; gap: 6px; }
  .topbar .controls button { padding: 6px 10px; font-size: 12px; }
  .nav-link { padding: 5px 8px; font-size: 11px; }

  /* Search takes its own full-width row rather than competing for space. */
  .search-wrap { order: 10; flex-basis: 100%; max-width: none; }

  /* The sidebar becomes a drawer instead of vanishing. Hiding it entirely
     left no way to browse markets on a phone -- only search, which requires
     already knowing what you want. */
  .layout { display: block; }

  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(290px, 84vw);
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }
  .sidebar.open { transform: translateX(0); }

  .drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }
  .drawer-backdrop.open { opacity: 1; pointer-events: auto; }

  .main { padding: 12px; gap: 12px; }
  .verdict { padding: 16px; }
  .verdict-head h1 { font-size: 18px; }
  .verdict-reasons { padding-left: 18px; }
  .verdict-reasons li { font-size: 13px; }

  .sensor-grid, .funnel, .tf-row { grid-template-columns: minmax(0, 1fr); }
  .explainer { font-size: 12px; }

  .sizer { gap: 12px; }
  .sizer input { width: 100%; }
  .sizer label { flex: 1; min-width: 130px; }
}

@media (max-width: 480px) {
  .topbar .controls button { padding: 5px 8px; }
  .btc-price .big { font-size: 14px; }
  .panel { padding: 12px; }
}

/* Drawer footer nav: on a phone these links live in the drawer instead of
   the top bar, which otherwise wrapped to three rows and ate 163px. */
.drawer-nav { display: none; }

@media (max-width: 900px) {
  .drawer-nav {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
  }
  .drawer-nav a {
    flex: 1;
    text-align: center;
    padding: 9px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
  }
  .drawer-nav a.logout { color: var(--muted); }

  /* These now live in the drawer, so remove them from the crowded top row. */
  .topbar > .nav-link { display: none; }
}
