:root {
  --bg: #0B0E11;
  --panel: #131820;
  --panel-2: #171D27;
  --border: #232B38;
  --text: #E8EAED;
  --text-dim: #8B96A5;
  --text-faint: #566073;
  --green: #3FB950;
  --green-dim: #1E4029;
  --red: #F0625F;
  --red-dim: #402022;
  --amber: #E8A33D;
  --blue: #5B9DF9;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --sans: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* ---------------- ticker tape ---------------- */
.tape {
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  white-space: nowrap;
  height: 34px;
  display: flex;
  align-items: center;
}
.tape-track {
  display: inline-flex;
  gap: 28px;
  padding: 0 20px;
  font-family: var(--mono);
  font-size: 12.5px;
}
.tape-item { color: var(--text-dim); }
.tape-item .sym { color: var(--text); font-weight: 600; margin-right: 6px; }
.tape-item.up { color: var(--green); }
.tape-item.down { color: var(--red); }
.tape-loading { color: var(--text-faint); font-style: italic; }

/* ---------------- header ---------------- */
.hdr {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 28px 32px 18px;
  border-bottom: 1px solid var(--border);
}
.hdr-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--amber);
  display: block;
  margin-bottom: 6px;
}
.hdr-title {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.hdr-right { display: flex; gap: 28px; }
.hdr-stat { display: flex; flex-direction: column; align-items: flex-end; }
.hdr-stat-label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.hdr-stat-value {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text);
  margin-top: 2px;
}

/* ---------------- sector tabs ---------------- */
.sectors {
  display: flex;
  gap: 4px;
  padding: 14px 32px 0;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.sector-tab {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 8px 12px 10px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.sector-tab:hover { color: var(--text); }
.sector-tab.active { color: var(--amber); border-bottom-color: var(--amber); }

/* ---------------- main ---------------- */
.main { padding: 22px 32px 40px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.btn-scan {
  background: var(--amber);
  color: #17130A;
  border: none;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.03em;
  padding: 10px 20px;
  border-radius: 3px;
  cursor: pointer;
  transition: filter .15s ease, transform .1s ease;
}
.btn-scan:hover { filter: brightness(1.08); }
.btn-scan:active { transform: translateY(1px); }
.btn-scan:disabled { opacity: 0.5; cursor: progress; }
.toolbar-hint {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-faint);
}

.banner {
  font-size: 13.5px;
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.banner code {
  font-family: var(--mono);
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 3px;
}
.banner-warn {
  background: rgba(232, 163, 61, 0.08);
  border: 1px solid rgba(232, 163, 61, 0.35);
  color: #F0D9A8;
}
.hidden { display: none !important; }

/* ---------------- view tabs ---------------- */
.view-tabs {
  display: flex;
  gap: 10px;
  padding: 16px 32px 0;
}
.view-tab {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 9px 16px;
  border-radius: 5px 5px 0 0;
  cursor: pointer;
}
.view-tab:hover { color: var(--text); }
.view-tab.active {
  color: var(--amber);
  border-color: var(--amber);
  border-bottom-color: var(--panel);
  background: var(--panel-2);
}

.pair-row { cursor: pointer; }
.notes-inline {
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--text-faint);
  margin-left: 6px;
}

/* Pairs table: fixed layout with explicit column widths so header and
   body cells can never drift out of alignment regardless of content. */
.pairs-table { table-layout: fixed; width: 100%; }
.pt-col-pair { width: 22%; text-align: left; }
.pt-col-num { width: 12%; text-align: right; }
.pt-col-signal { width: 30%; text-align: left; }
td.pt-col-num { text-align: right; }
td.pt-col-pair, td.pt-col-signal { text-align: left; }

.bt-empty-cell {
  color: var(--text-faint);
  font-style: italic;
  font-size: 11.5px;
}
.calib-table th, .calib-table td { text-align: right; }
.calib-table th:first-child, .calib-table td:first-child { text-align: left; }
.trade-table td { text-align: left; }
.trade-table th { text-align: left; }

/* ---------------- single-stock lookup ---------------- */
.lookup-toolbar { gap: 12px; }
.lookup-input {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  text-transform: uppercase;
  padding: 10px 14px;
  border-radius: 4px;
  width: 180px;
}
.lookup-input:focus { outline: none; border-color: var(--amber); }

.lookup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 20px;
}
.lookup-header-main { display: flex; align-items: baseline; gap: 14px; }
.lookup-symbol { font-family: var(--mono); font-size: 26px; font-weight: 600; }
.lookup-price { font-family: var(--mono); font-size: 18px; color: var(--text-dim); }
.lookup-score-row { gap: 14px; }

.lookup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 26px;
}
.lookup-h3 {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.lookup-notes { font-size: 13px; }
.lookup-details {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12.5px;
}
.lookup-details td { padding: 5px 0; }
.lookup-details td:last-child { text-align: right; color: var(--text); }

/* score label badge */
.lookup-score-block { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.score-label {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--panel-2);
  color: var(--text-dim);
}
.score-label.pos { background: var(--green-dim); color: var(--green); }
.score-label.neg { background: var(--red-dim); color: var(--red); }
.lookup-score-explainer {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.6;
  margin: -8px 0 22px;
}

/* plain-English story list */
.plain-list {
  list-style: none;
  margin: 0 0 26px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.plain-list li {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: 4px;
}

/* readout grid: plain sentence + small raw number */
.readout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 26px;
}
.readout-item {
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 5px;
}
.readout-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.readout-sentence {
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
}
.readout-raw {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 6px;
}

/* calibration / breakout-history cards (plain-English version) */
.calib-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}
.calib-card {
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 5px;
}
.calib-card-label {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--amber);
  margin-bottom: 6px;
}
.calib-n { font-family: var(--sans); font-weight: 400; font-size: 11.5px; }
.calib-n.ss-low { color: var(--red); }
.calib-n.ss-mid { color: var(--text-faint); }
.calib-n.ss-good { color: var(--green); }
.calib-n.ss-none { color: var(--text-faint); }
.calib-card-body {
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-dim);
}
.calib-card-body strong { color: var(--text); }
.calib-empty .calib-card-body { font-style: italic; color: var(--text-faint); }

/* "you are here" highlighting */
.you-are-here {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  background: rgba(232, 163, 61, 0.08);
  border: 1px solid rgba(232, 163, 61, 0.4);
  border-radius: 5px;
  padding: 12px 16px;
  margin-bottom: 14px;
}
.yah-marker {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--amber);
  margin-right: 8px;
}
.yah-inline { color: var(--amber); }
.calib-card.calib-current {
  border-color: var(--amber);
  border-left: 3px solid var(--amber);
  background: rgba(232, 163, 61, 0.05);
  position: relative;
}
.calib-current-tag {
  position: absolute;
  top: 12px;
  right: 14px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--amber);
  letter-spacing: 0.04em;
}
tr.calib-row-current {
  background: rgba(232, 163, 61, 0.06);
}
tr.calib-row-current td:first-child {
  border-left: 2px solid var(--amber);
}

@media (max-width: 720px) {
  .lookup-grid { grid-template-columns: 1fr; }
  .lookup-input { width: 120px; }
  .readout-grid { grid-template-columns: 1fr; }
}

/* ---------------- setup screen ---------------- */
.setup {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.setup-card {
  max-width: 620px;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 34px 38px 38px;
}
.setup-title {
  font-family: var(--mono);
  font-size: 26px;
  margin: 8px 0 14px;
}
.setup-copy {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 22px;
}
.setup-steps {
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.7;
  padding-left: 22px;
  margin-bottom: 26px;
}
.setup-steps li { margin-bottom: 10px; }
.setup-steps code, .setup-copy code {
  font-family: var(--mono);
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12.5px;
}
.setup-steps a, .setup-copy a { color: var(--blue); }
.setup-label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.setup-input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13.5px;
  padding: 11px 13px;
  border-radius: 4px;
  margin-bottom: 16px;
}
.setup-input:focus {
  outline: none;
  border-color: var(--amber);
}
.setup-save { width: 100%; padding: 12px; font-size: 13.5px; }
.setup-error {
  margin-top: 14px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--red);
  line-height: 1.5;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 4px;
  cursor: pointer;
  align-self: flex-end;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-faint); }
.hdr-right { display: flex; gap: 24px; align-items: flex-end; }

/* ---------------- results table ---------------- */
.results {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 13px;
}
.results thead th {
  text-align: left;
  color: var(--text-faint);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
}
.col-score { width: 220px; }
.col-price, .col-rsi { text-align: right; }

.results tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s ease;
  animation: rowIn .25s ease both;
}
.results tbody tr:hover { background: var(--panel); }
.results tbody tr.expanded { background: var(--panel); }
.results td { padding: 10px 12px; vertical-align: middle; }

@keyframes rowIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty-row td, .loading-row td, .error-row td {
  font-family: var(--sans);
  color: var(--text-dim);
  padding: 28px 12px;
  text-align: center;
}

.sym-cell { font-weight: 600; }
.sym-cell .sector-mini {
  display: block;
  font-family: var(--sans);
  font-size: 10.5px;
  color: var(--text-faint);
  font-weight: 400;
}
.sector-cell { color: var(--text-dim); font-family: var(--sans); font-size: 12.5px; }
.price-cell { text-align: right; color: var(--text); }
.rsi-cell { text-align: right; color: var(--text-dim); }

.trend-pill {
  font-family: var(--sans);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-block;
}
.trend-uptrend { background: var(--green-dim); color: var(--green); }
.trend-downtrend { background: var(--red-dim); color: var(--red); }
.trend-sideways, .trend-unknown { background: var(--panel-2); color: var(--text-faint); }

.setup-flags { display: flex; flex-wrap: wrap; gap: 5px; }
.flag {
  font-family: var(--sans);
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}
.flag-breakout { color: var(--green); border-color: rgba(63,185,80,0.35); }
.flag-breakdown { color: var(--red); border-color: rgba(240,98,95,0.35); }
.flag-bull { color: var(--green); }
.flag-bear { color: var(--red); }

/* signature signal bar: diverging gauge, -100..+100, centered */
.signal-bar {
  position: relative;
  height: 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
  width: 160px;
}
.signal-bar .zero-line {
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--text-faint);
  opacity: 0.6;
}
.signal-bar .fill {
  position: absolute;
  top: 1px; bottom: 1px;
  transition: width .3s ease;
}
.signal-bar .fill.pos { left: 50%; background: linear-gradient(90deg, rgba(63,185,80,0.35), var(--green)); }
.signal-bar .fill.neg { right: 50%; background: linear-gradient(270deg, rgba(240,98,95,0.35), var(--red)); }
.score-row { display: flex; align-items: center; gap: 10px; }
.score-num { font-weight: 600; width: 32px; text-align: right; }
.score-num.pos { color: var(--green); }
.score-num.neg { color: var(--red); }

/* ---------------- notes expand ---------------- */
.notes-row td {
  padding: 0 12px 14px 12px;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--text-dim);
}
.notes-list { margin: 0; padding-left: 18px; }
.notes-list li { margin-bottom: 3px; }
.view-backtest {
  margin-top: 10px;
  background: none;
  border: 1px solid var(--blue);
  color: var(--blue);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
}
.view-backtest:hover { background: rgba(91,157,249,0.1); }

/* ---------------- drawer ---------------- */
.scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
  z-index: 20;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(480px, 92vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform .25s ease;
  z-index: 21;
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-inner { padding: 26px 28px 40px; }
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.drawer-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--amber);
}
.drawer-title {
  font-family: var(--mono);
  font-size: 22px;
  margin: 4px 0 0;
}
.drawer-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 3px;
  cursor: pointer;
}
.drawer-loading, .drawer-empty, .drawer-error {
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.6;
}

.bt-pattern {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.bt-pattern-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.bt-pattern-name {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
  text-transform: uppercase;
}
.bt-pattern-name.breakout { color: var(--green); }
.bt-pattern-name.breakdown { color: var(--red); }
.bt-n { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); }

.bt-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12.5px;
}
.bt-table th {
  text-align: right;
  color: var(--text-faint);
  font-weight: 500;
  font-size: 10.5px;
  padding-bottom: 6px;
}
.bt-table th:first-child, .bt-table td:first-child { text-align: left; }
.bt-table td { text-align: right; padding: 3px 0; color: var(--text); }
.bt-row-label { color: var(--text-dim); }

.drawer-note {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.6;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ---------------- footer ---------------- */
.ftr {
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--text-faint);
  padding: 20px 32px 40px;
  max-width: 820px;
  line-height: 1.6;
}

@media (max-width: 720px) {
  .hdr { flex-direction: column; align-items: flex-start; gap: 12px; }
  .col-rsi, .col-trend { display: none; }
  .signal-bar { width: 100px; }
}
