/* stockcli — terminal dashboard
   Design: Bloomberg density × Linear restraint. Sidebar, full-width,
   one amber accent, color reserved for P&L semantics. */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #0b0d10;
  --bg-side: #0e1116;
  --bg-panel: #12151b;
  --bg-inset: #161a21;
  --bg-hover: #1a1f27;

  --line: #1f242c;
  --line-soft: #191e25;

  --ink: #dfe4ea;
  --ink-2: #8b929e;
  --ink-3: #5b6270;

  --accent: #e8b04b;        /* terminal amber */
  --accent-ink: #f2c063;
  --accent-dim: rgba(232, 176, 75, 0.09);

  --up: #34d17c;            /* P&L up */
  --up-dim: rgba(52, 209, 124, 0.09);
  --down: #ee5c6b;          /* P&L down */
  --down-dim: rgba(238, 92, 107, 0.09);
  --warn: #e8b04b;
  --warn-dim: rgba(232, 176, 75, 0.09);
  --info: #6ea8d8;
  --info-dim: rgba(110, 168, 216, 0.10);

  --sans: 'IBM Plex Sans', -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', 'SF Mono', Consolas, monospace;

  --r: 6px;
  --r-sm: 4px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scrollbar-color: #262c36 var(--bg); }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ── Shell: sidebar + full-width main ── */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.brand-mark {
  width: 30px; height: 30px;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex: none;
}

.brand-word { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-weight: 700; font-size: 14px; letter-spacing: -0.2px; color: var(--ink); }
.brand-ver { font-family: var(--mono); font-size: 10px; color: var(--ink-3); letter-spacing: 0.4px; }

.side-nav { padding: 10px 8px; flex: 1; }

.nav-group {
  display: block;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 14px 10px 5px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  margin: 1px 0;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 2px solid transparent;
}

.side-nav a svg { width: 15px; height: 15px; flex: none; opacity: 0.75; }

.side-nav a:hover { color: var(--ink); background: var(--bg-hover); }

.side-nav a.active {
  color: var(--accent-ink);
  background: var(--accent-dim);
  border-left-color: var(--accent);
}
.side-nav a.active svg { opacity: 1; }

.side-foot {
  border-top: 1px solid var(--line-soft);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.foot-row { display: flex; justify-content: space-between; align-items: center; }
.foot-key { font-size: 11px; color: var(--ink-3); }
.foot-val { font-family: var(--mono); font-size: 11px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.foot-val.up { color: var(--up); }
.foot-val.warn { color: var(--warn); }

/* ── Main column ── */
.main-col { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  height: 52px;
  background: var(--bg-side);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title h1 { font-size: 15px; font-weight: 600; letter-spacing: -0.1px; }

.topbar-tickers { display: flex; align-items: center; gap: 18px; }

.tick { font-family: var(--mono); font-size: 11.5px; color: var(--ink); white-space: nowrap; }
.tick b { color: var(--ink-3); font-weight: 500; margin-right: 5px; font-size: 10px; letter-spacing: 0.6px; text-transform: uppercase; }
.tick.tier { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.tick.tier.up { color: var(--up); }
.tick.tier.warn { color: var(--warn); }

.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex: none; }
.dot-up { background: var(--up); box-shadow: 0 0 0 3px var(--up-dim); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-dim); }
.dot-down { background: var(--down); box-shadow: 0 0 0 3px var(--down-dim); }

.content { padding: 24px 28px 40px; flex: 1; }

/* ── Page header ── */
.page-head { margin-bottom: 18px; }
.page-title { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
.page-sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; font-family: var(--mono); }

/* ── Grids — full width, fluid ── */
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

@media (max-width: 1280px) { .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px)  { .grid-5, .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ── Panels ── */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.card { composes: panel; }
.card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
}

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

.panel-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

/* keep old class names working */
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

/* ── Stat blocks — flat, tabular, no top bars ── */
.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
}
.stat-card:hover { border-color: #2a303a; }

.stat-label {
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 500;
  margin-bottom: 6px;
}

.stat-value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.5px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-value.positive, .stat-value.up { color: var(--up); }
.stat-value.negative, .stat-value.down { color: var(--down); }

.stat-sub {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 5px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ── Sections ── */
section { margin-bottom: 22px; }

.section-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }

.section-title {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding-left: 10px;
  border-left: 2px solid var(--accent);
}

/* ── Tables — dense, ruled, tabular nums ── */
.table-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }

thead { background: var(--bg-inset); }

th {
  text-align: left;
  padding: 8px 14px;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--ink-3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}

tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

td.num, th.num {
  font-family: var(--mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

td.symbol {
  font-weight: 600;
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2px;
}

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

/* ── Tags — square mono labels, no pills ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border: 1px solid;
  line-height: 1.5;
}

.badge-green  { background: var(--up-dim);   color: var(--up);   border-color: rgba(52,209,124,0.25); }
.badge-red    { background: var(--down-dim); color: var(--down); border-color: rgba(238,92,107,0.25); }
.badge-amber  { background: var(--warn-dim); color: var(--warn); border-color: rgba(232,176,75,0.25); }
.badge-blue   { background: var(--info-dim); color: var(--info); border-color: rgba(110,168,216,0.25); }
.badge-purple { background: var(--accent-dim); color: var(--accent-ink); border-color: rgba(232,176,75,0.25); }
.badge-neutral{ background: var(--bg-inset); color: var(--ink-2); border-color: var(--line); }

/* ── Tier strip (dashboard) ── */
.tier-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 18px;
  border-radius: var(--r);
  margin-bottom: 20px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
}
.tier-banner.green { border-left-color: var(--up); }
.tier-banner.amber { border-left-color: var(--warn); }

.tier-left { display: flex; align-items: center; gap: 16px; }
.tier-name { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.tier-note { font-size: 12px; color: var(--ink-2); font-family: var(--mono); }

.tier-right { display: flex; gap: 24px; }
.macro-item { display: flex; flex-direction: column; text-align: right; }
.macro-label { color: var(--ink-3); font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 1px; }
.macro-val { font-family: var(--mono); font-weight: 600; font-size: 13.5px; font-variant-numeric: tabular-nums; }

/* ── Chart ── */
.chart-container { position: relative; height: 260px; width: 100%; }

/* ── Empty states ── */
.empty-state { text-align: center; padding: 44px 20px; color: var(--ink-3); }
.empty-text { font-size: 13px; }
.empty-code {
  font-family: var(--mono);
  background: var(--bg-inset);
  border: 1px solid var(--line);
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 11.5px;
  color: var(--accent-ink);
}

/* ── Footer ── */
.foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  color: var(--ink-3);
  font-size: 11px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
}
.foot em { font-style: normal; opacity: 0.4; }

/* ── Links ── */
a { color: var(--accent-ink); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #262c36; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #333a46; }

/* ── Sparkline ── */
.spark-slot { display: inline-flex; align-items: center; }
.spark.up { color: var(--up); }
.spark.down { color: var(--down); }

/* ── Horizontal bars (sector exposure) ── */
.bar-row { display: grid; grid-template-columns: 118px minmax(0,1fr) 58px; align-items: center; gap: 10px; padding: 4px 0; }
.bar-name { font-size: 11.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 13px; background: var(--bg-inset); border-radius: 3px; overflow: hidden; display: block; }
.bar-fill { height: 100%; background: var(--accent); opacity: 0.65; border-radius: 3px; display: block; }
.bar-fill.fill-up { background: var(--up); opacity: 0.65; }
.bar-val { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }

/* ── Promotion gate ── */
.gate-row { display: flex; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.gate-row:last-child { border-bottom: none; }
.gate-key { font-size: 12px; color: var(--ink-2); width: 148px; flex: none; }
.gate-meter { flex: 1; margin: 0 14px; height: 6px; background: var(--bg-inset); border-radius: 3px; overflow: hidden; }
.gate-meter i { display: block; height: 100%; background: var(--up); border-radius: 3px; }
.gate-meter.warn i { background: var(--warn); }
.gate-val { font-family: var(--mono); font-size: 11.5px; min-width: 96px; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.gate-val small { color: var(--ink-3); font-size: 10px; }
.gate-val.positive { color: var(--up); }
.gate-val.negative { color: var(--down); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px;
  background: var(--accent-dim); color: var(--accent-ink);
  border: 1px solid rgba(232, 176, 75, 0.3); border-radius: 4px;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.5px; text-transform: uppercase; cursor: pointer;
  transition: all 0.15s; text-decoration: none;
}
.btn:hover { background: rgba(232, 176, 75, 0.16); border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover { color: var(--ink); border-color: #2a303a; background: var(--bg-hover); }

/* ── Run links ── */
.run-link { color: var(--accent-ink); text-decoration: none; font-family: var(--mono); font-size: 12px; }
.run-link:hover { text-decoration: underline; }

/* ── Chart legend ── */
.legend { display: flex; gap: 12px; align-items: center; }
.legend .lg { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 10px; color: var(--ink-2); }
.legend .lg i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* ── Utility (kept from old templates) ── */
.text-mono { font-family: var(--mono); }
.text-muted { color: var(--ink-3); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* ── Responsive: sidebar collapses to top row ── */
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .side-nav { display: flex; overflow-x: auto; padding: 6px 8px; }
  .nav-group { display: none; }
  .side-nav a { border-left: none; border-bottom: 2px solid transparent; white-space: nowrap; }
  .side-nav a.active { border-left: none; border-bottom-color: var(--accent); }
  .side-foot { display: none; }
  .topbar-tickers .tick:nth-child(-n+3) { display: none; }
  .content { padding: 16px 14px 32px; }
  .topbar { padding: 0 14px; }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: minmax(0, 1fr); }
  .tier-banner { flex-direction: column; align-items: flex-start; }
  .tier-right { width: 100%; justify-content: space-between; }
  .macro-item { text-align: left; }
}
