/* trading-dashboard — 3-column layout with prominent titles. */

:root {
  --bg:         #0b0d10;
  --panel-2:    #1b2026;
  --border:     #1f262f;
  --text:       #e7ebef;
  --muted:      #8a93a0;
  --accent:     #4ea2ff;
  --green:      #3fc97a;
  --red:        #e6605c;
  --amber:      #e8b956;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Top bar ──────────────────────────────────────────────────────── */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 18px;
  border-bottom: 1px solid var(--border);
  height: 42px;
}
.brand { font-weight: 600; letter-spacing: 0.5px; font-size: 15px; }
.status { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
#refresh {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  width: 26px; height: 26px; border-radius: 6px; font-size: 15px; cursor: pointer;
}
#refresh:active { background: var(--accent); color: var(--bg); }

/* ── Main grid: 3 columns ──────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: 300px 1fr 340px;
  gap: 0;
  height: calc(100vh - 43px);
  overflow: hidden;
}
.col {
  display: flex; flex-direction: column;
  padding: 0;
  overflow: hidden;
  min-height: 0;
}
.col-left   { border-right: 2px solid var(--border); }
.col-right  { border-left:  2px solid var(--border); }
.col > .sect { padding: 16px 18px; }

/* Middle column: 2 rows (top: gauges side by side, bot: session + summary) */
.col-mid {
  padding: 0;
  display: flex; flex-direction: column;
}
.mid-top {
  display: grid; grid-template-columns: 1fr 1fr;
  flex: 0 0 auto;
}
.mid-bot {
  display: grid; grid-template-columns: 240px 1fr;
  flex: 1 1 auto; min-height: 0;
}
.mid-top > .sect, .mid-bot > .sect { padding: 16px 18px; }

/* ── Section + title ──────────────────────────────────────────────── */
.sect { display: flex; flex-direction: column; min-height: 0; }
.sect h2 {
  margin: 0 0 12px;
  font-size: 14px; letter-spacing: 1.2px; font-weight: 700;
  color: var(--text); text-transform: uppercase;
  display: flex; align-items: baseline; gap: 10px;
  border-bottom: 1px solid var(--text);
  padding-bottom: 8px;
}

/* ── Separator lines between sections ─────────────────────────────── */
/* Sections own their padding, columns have zero padding/gap. That means
   every section spans the full column width, so border-top on each
   section after the first meets the column-edge dividers cleanly.
   Vertical lines (border-left on the second section in mid-top/mid-bot)
   span the full row height for the same reason. */
.col-left  > .sect + .sect,
.col-right > .sect + .sect {
  border-top: 2px solid var(--border);
}

.col-mid .mid-bot {
  border-top: 2px solid var(--border);
}

.mid-top > .sect + .sect,
.mid-bot > .sect + .sect {
  border-left: 2px solid var(--border);
}
.sect h2 .sub {
  font-size: 11px; letter-spacing: 0.5px; font-weight: 500;
  color: var(--muted); opacity: 0.85; text-transform: none;
}
.body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.loading { color: var(--muted); padding: 16px 0; text-align: center; font-size: 13px; }
.muted { color: var(--muted); }
.err {
  color: var(--red); font-size: 11px; padding: 8px 10px;
  background: rgba(230, 96, 92, 0.08); border-radius: 6px;
  word-break: break-word; line-height: 1.4;
}
code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--panel-2); padding: 1px 4px; border-radius: 4px; font-size: 12px;
}

/* ── Column-level section sizing ──────────────────────────────────── */
.col-left   .sect#card-correlation { flex: 0 0 auto; }
.col-left   .sect#card-calendar    { flex: 0 0 auto; max-height: 30%; }
.col-left   .sect#card-screener    { flex: 1 1 auto; min-height: 0; }

.col-right  .sect#card-alignment   { flex: 1 1 auto; min-height: 0; }

/* ── GAUGE ─────────────────────────────────────────────────────────── */
.gauge { display: flex; flex-direction: column; align-items: center; gap: 0; }
.gauge svg { width: 100%; max-width: 230px; height: auto; flex-shrink: 0; margin-top: -4px; }
.gauge .value { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; margin-top: -10px; }
.gauge .label { font-size: 11px; color: var(--muted); text-align: center; margin-top: 4px; }
.gauge .components {
  margin-top: 10px; width: 100%;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
  font-size: 10px;
}
.gauge .components div {
  text-align: center; padding: 5px 0;
  background: var(--panel-2); border-radius: 4px;
}
.gauge .components .k { color: var(--muted); font-size: 9px; }
.gauge .components .v { font-weight: 700; font-size: 11px; }

/* ── ALIGNMENT ─────────────────────────────────────────────────────── */
.align-list {
  display: flex; flex-direction: column; gap: 2px;
  height: 100%; flex: 1 1 auto; min-height: 0;
}
.align-row {
  display: grid; grid-template-columns: 58px 1fr 28px;
  align-items: center; gap: 10px; font-size: 12px;
  flex: 1 1 0; min-height: 0;     /* force equal-height distribution */
}
.align-row .asset { font-weight: 600; }
.align-row .bar {
  height: 8px; border-radius: 4px; background: var(--panel-2); overflow: hidden;
}
.align-row .bar > div { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.align-row .score { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ── SESSION ───────────────────────────────────────────────────────── */
.sess-list { display: flex; flex-direction: column; gap: 8px; }
.sess-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; background: var(--panel-2); border-radius: 8px;
  font-size: 13px;
}
.sess-row .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.sess-row.active { background: rgba(63, 201, 122, 0.10); border: 1px solid rgba(63, 201, 122, 0.30); }
.sess-row.active .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.sess-row.inactive .dot { background: #4a525c; }
.sess-row .next { color: var(--muted); font-size: 11px; }

/* ── SUMMARY ───────────────────────────────────────────────────────── */
.summary-phrase { font-size: 15px; line-height: 1.5; margin: 0 0 10px; }
.movers { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.mover {
  font-size: 11px; padding: 4px 9px; border-radius: 6px;
  background: var(--panel-2); font-variant-numeric: tabular-nums;
}
.mover.up { color: var(--green); }
.mover.down { color: var(--red); }
.headlines + .headlines { margin-top: 10px; }
.headlines h3 {
  font-size: 10px; letter-spacing: 1.5px; color: var(--muted);
  margin: 0 0 4px; font-weight: 600; text-transform: uppercase;
}
.headlines ul { list-style: none; padding: 0; margin: 0; }
.headlines li { font-size: 12px; padding: 2px 0; color: var(--text); opacity: 0.9; line-height: 1.35; }
.headlines li::before { content: "• "; color: var(--muted); }

/* ── CORRELATION ───────────────────────────────────────────────────── */
.corr-block { margin-bottom: 10px; }
.corr-block:last-child { margin-bottom: 0; }
.corr-block h3 {
  font-size: 10px; letter-spacing: 1.5px; color: var(--muted);
  margin: 0 0 4px; font-weight: 600; text-transform: uppercase;
}
.corr-row { font-size: 12px; padding: 2px 0; line-height: 1.3; }
.corr-row .v { font-variant-numeric: tabular-nums; font-weight: 600; margin-left: 6px; }
.corr-row .pos { color: var(--green); }
.corr-row .neg { color: var(--red); }

/* ── CALENDAR ──────────────────────────────────────────────────────── */
.cal-list { display: flex; flex-direction: column; gap: 4px; }
.cal-row {
  display: grid; grid-template-columns: 60px 28px 1fr; gap: 8px;
  font-size: 12px; padding: 3px 0; line-height: 1.3;
}
.cal-row .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-row .c { color: var(--accent); font-weight: 600; text-align: center; }

/* ── SCREENER ──────────────────────────────────────────────────────── */
.scr-list { display: flex; flex-direction: column; gap: 6px; }
.scr-row {
  display: grid; grid-template-columns: 1fr auto;
  padding: 9px 12px; background: var(--panel-2); border-radius: 6px;
  font-size: 13px; gap: 2px 12px;
}
.scr-row .a { font-weight: 700; }
.scr-row .dir.long  { color: var(--green); }
.scr-row .dir.short { color: var(--red); }
.scr-row .ts { color: var(--muted); font-size: 11px; }
.scr-row .note { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
.scr-empty { color: var(--muted); font-size: 13px; padding: 16px 0; text-align: center; }

/* ── Phone fallback ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  html, body { overflow: auto; }
  .grid {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .col { padding: 14px 16px; gap: 18px; overflow: visible; }
  .col-left { border-right: none; border-bottom: 1px solid var(--border); }
  .col-right { border-left: none; border-top: 1px solid var(--border); }
  .col-left .sect#card-calendar { max-height: none; }
  .mid-top, .mid-bot { grid-template-columns: 1fr; gap: 18px; }
}
