/* =============================
   THEME: LIGHT (default)
============================= */
:root,
[data-theme="light"] {
  --bg: #ffffff;
  --panel: #f8f8fa;
  --panel2: #f0f0f2;
  --text: rgba(0, 0, 0, 0.88);
  --muted: rgba(0, 0, 0, 0.50);
  --border: rgba(0, 0, 0, 0.08);
  --hover: rgba(0, 0, 0, 0.04);
  --green: #1B9E3E;
  --red: #D62839;
  --accent: #0A84FF;
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial;

  --chart-line: rgba(0, 0, 0, 0.80);
  --chart-line-raw: rgba(0, 0, 0, 0.10);
  --chart-dot: rgba(0, 0, 0, 0.40);
  --chart-dot-dim: rgba(0, 0, 0, 0.03);
  --chart-grid: rgba(0, 0, 0, 0.05);
  --chart-tick: rgba(0, 0, 0, 0.45);
  --chart-vline: rgba(0, 0, 0, 0.10);
  --chart-now: #000000;
  --chart-median: rgba(0, 0, 0, 0.18);
  --chart-ref: rgba(0, 0, 0, 0.06);
  --chart-diamond: rgba(0, 0, 0, 0.85);
  --chart-annotation-bg: rgba(255, 255, 255, 0.80);
  --chart-annotation-border: rgba(0, 0, 0, 0.08);
}

/* =============================
   THEME: DARK
============================= */
[data-theme="dark"] {
  --bg: #141414;
  --panel: #1a1a1a;
  --panel2: #101010;
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.62);
  --border: rgba(255, 255, 255, 0.08);
  --hover: rgba(255, 255, 255, 0.06);
  --green: #7CFF9B;
  --red: #FF6B6B;
  --accent: #0A84FF;

  --chart-line: rgba(255, 255, 255, 0.85);
  --chart-line-raw: rgba(255, 255, 255, 0.10);
  --chart-dot: rgba(255, 255, 255, 0.40);
  --chart-dot-dim: rgba(255, 255, 255, 0.03);
  --chart-grid: rgba(255, 255, 255, 0.04);
  --chart-tick: rgba(255, 255, 255, 0.55);
  --chart-vline: rgba(255, 255, 255, 0.12);
  --chart-now: #ffffff;
  --chart-median: rgba(255, 255, 255, 0.20);
  --chart-ref: rgba(255, 255, 255, 0.06);
  --chart-diamond: rgba(255, 255, 255, 0.90);
  --chart-annotation-bg: rgba(0, 0, 0, 0.55);
  --chart-annotation-border: rgba(255, 255, 255, 0.08);
}

/* =============================
   SYSTEM PREFERENCE (auto)
============================= */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141414;
    --panel: #1a1a1a;
    --panel2: #101010;
    --text: rgba(255, 255, 255, 0.92);
    --muted: rgba(255, 255, 255, 0.62);
    --border: rgba(255, 255, 255, 0.08);
    --hover: rgba(255, 255, 255, 0.06);
    --green: #7CFF9B;
    --red: #FF6B6B;

    --chart-line: rgba(255, 255, 255, 0.85);
    --chart-line-raw: rgba(255, 255, 255, 0.10);
    --chart-dot: rgba(255, 255, 255, 0.40);
    --chart-dot-dim: rgba(255, 255, 255, 0.03);
    --chart-grid: rgba(255, 255, 255, 0.04);
    --chart-tick: rgba(255, 255, 255, 0.55);
    --chart-vline: rgba(255, 255, 255, 0.12);
    --chart-now: #ffffff;
    --chart-median: rgba(255, 255, 255, 0.20);
    --chart-ref: rgba(255, 255, 255, 0.06);
    --chart-diamond: rgba(255, 255, 255, 0.90);
    --chart-annotation-bg: rgba(0, 0, 0, 0.55);
    --chart-annotation-border: rgba(255, 255, 255, 0.08);
  }
}

/* =============================
   RESET & BASE
============================= */
* { box-sizing: border-box; }

html, body {
  overflow-x: hidden;
  width: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow-y: auto;
}

/* =============================
   GLOBAL TRANSITIONS
============================= */
body,
.sidebar-primary,
.sidebar-secondary,
.content,
.panel,
.kpi,
.signal-card,
.sym-item {
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease;
}

/* =============================
   APP FRAME
============================= */
.app-shell {
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* =============================
   PRIMARY SIDEBAR (70px)
============================= */
.sidebar-primary {
  width: 70px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 10px;
  gap: 12px;
}

.brand {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  background: transparent;
}

.pnav {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.pnav a {
  width: 100%;
  text-decoration: none;
  color: var(--muted);
  border-radius: 12px;
  padding: 10px 0;
  display: grid;
  place-items: center;
  transition: 120ms ease;
  border: 1px solid transparent;
}

.pnav a:hover {
  background: var(--hover);
  color: var(--text);
  border-color: var(--border);
}

.pnav a.active {
  background: var(--hover);
  color: var(--text);
  border-color: var(--border);
}

.pnav span {
  font-size: 11px;
  margin-top: 6px;
  font-weight: 700;
}

/* =============================
   THEME TOGGLE
============================= */
.theme-toggle {
  width: 100%;
  padding: 10px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  transition: all 120ms;
  display: grid;
  place-items: center;
}

.theme-toggle:hover {
  background: var(--hover);
  color: var(--text);
}

/* =============================
   SECONDARY SIDEBAR
============================= */
.sidebar-secondary {
  width: 320px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  gap: 12px;
}

.section-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.search {
  width: 100%;
  padding: 14px 12px;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  outline: none;
  font-size: 14px;
  line-height: 20px;
}

.search::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: visible;
  padding-right: 2px;
}

/* =============================
   STOCK ITEM
============================= */
.sym-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.sym-item {
  background: var(--panel);
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 10px;
  transition: 120ms ease;
}

.sym-item:hover {
  background: var(--hover);
  border-color: var(--border);
}

.sym-item.active {
  background: var(--hover);
  border-color: var(--border);
}

.sym-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sym-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sym-badge {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--panel2);
  border: 1px solid var(--border);
  font-weight: 900;
  font-size: 13px;
  flex: 0 0 auto;
  color: var(--text);
}

.sym-name {
  font-weight: 900;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.sym-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.sym-arrow {
  font-size: 14px;
  font-weight: 900;
  line-height: 14px;
}

.sym-pct { font-weight: 900; font-size: 13px; }
.sym-pct.pos, .sym-arrow.pos { color: var(--green); }
.sym-pct.neg, .sym-arrow.neg { color: var(--red); }
.sym-pct.flat, .sym-arrow.flat { color: var(--muted); }

.sym-meta {
  margin-top: 6px;
  padding-left: 38px;
}

.sym-company {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =============================
   MARKET RANKING ITEM
============================= */
.rank-item {
  background: var(--panel);
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 10px;
  transition: 120ms ease;
}

.rank-item:hover {
  background: var(--hover);
  border-color: var(--border);
}

.rank-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.rank-name { font-weight: 900; color: var(--text); }
.rank-pct { font-weight: 900; font-size: 13px; }
.rank-pct.pos { color: var(--green); }
.rank-pct.neg { color: var(--red); }

.divbar {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--panel2);
  border: 1px solid var(--border);
  overflow: hidden;
}

.divbar .mid {
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 1px;
  background: var(--border);
}

.divbar .pos {
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  background: var(--green);
}

.divbar .neg {
  position: absolute;
  right: 50%; top: 0; bottom: 0;
  background: var(--red);
}

/* =============================
   CONTENT
============================= */
.content {
  flex: 1;
  overflow: visible;
  padding: 18px 18px 24px;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 14px;
}

.h2 {
  font-size: 20px;
  margin: 0;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text);
}

.sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

/* =============================
   KPIs
============================= */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

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

.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-label { font-size: 12px; color: var(--muted); }

.kpi-val {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text);
}

.kpi-val.pos { color: var(--green); }
.kpi-val.neg { color: var(--red); }

.kpi-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-live {
  font-size: 8px;
  color: var(--green);
  animation: pulse-live 2s infinite;
}

@keyframes pulse-live {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

.kpi-delta { font-size: 13px; font-weight: 800; }
.kpi-delta.pos { color: var(--green); }
.kpi-delta.neg { color: var(--red); }
.kpi-delta.flat { color: var(--muted); }

/* =============================
   GENERIC PANEL
============================= */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-top: 12px;
}

.js-plotly-plot,
.plot-container,
.svg-container {
  width: 100% !important;
  max-width: 100vw !important;
}

/* =============================
   SECTIONS
============================= */
.section { margin-top: 14px; }

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

.section-title {
  font-weight: 900;
  letter-spacing: -0.02em;
  font-size: 14px;
  color: var(--text);
}

.section-note {
  font-size: 12px;
  color: var(--muted);
}

.section-link {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  text-decoration: none;
  transition: opacity 120ms;
}

.section-link:hover { opacity: 0.75; }

/* =============================
   DASHBOARD GRID
============================= */
.dash-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

/* =============================
   SIGNAL ROWS (Home)
============================= */
.sig-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sig-link {
  text-decoration: none;
  color: inherit;
  display: block;
  border-radius: 10px;
  transition: background 120ms;
}

.sig-link:hover { background: var(--hover); }

.sig-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
}

.sig-rank { font-size: 12px; font-weight: 800; color: var(--muted); text-align: center; }

.sig-info {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.sig-sym { font-weight: 900; font-size: 14px; letter-spacing: -0.02em; flex: 0 0 auto; color: var(--text); }

.sig-name {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sig-right { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.sig-pct { font-weight: 900; font-size: 13px; }
.sig-pct.pos { color: var(--green); }
.sig-pct.neg { color: var(--red); }
.sig-pct.flat { color: var(--muted); }

.sig-arrow { font-size: 11px; }
.sig-arrow.pos { color: var(--green); }
.sig-arrow.neg { color: var(--red); }
.sig-arrow.flat { color: var(--muted); }

/* =============================
   HEATMAP
============================= */
.heatmap-graph { width: 100%; }

.heatmap-graph .js-plotly-plot {
  border-radius: 10px;
  overflow: hidden;
}

/* =============================
   HOME: EVENT CARDS
============================= */
.ecard-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ecard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 120ms ease;
}

.ecard:hover {
  border-color: rgba(128, 128, 128, 0.15);
}

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

.ecard-date {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.ecard-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.4;
}

.ecard-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.ecard-sentiment { font-weight: 800; }
.ecard-sentiment.pos { color: var(--green); }
.ecard-sentiment.neg { color: var(--red); }
.ecard-sentiment.flat { color: var(--muted); }

.ecard-sep { opacity: 0.4; }
.ecard-articles { color: var(--muted); }

.ecard-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.echip-link {
  text-decoration: none;
  color: inherit;
}

.echip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel2);
  transition: all 120ms ease;
  cursor: pointer;
}

.echip:hover {
  border-color: rgba(128, 128, 128, 0.20);
  background: var(--hover);
}

.echip-sym {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text);
}

.echip-pct { font-size: 11px; font-weight: 800; }
.echip-pct.pos { color: var(--green); }
.echip-pct.neg { color: var(--red); }
.echip-pct.flat { color: var(--muted); }

/* =============================
   BADGES
============================= */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--muted);
  white-space: nowrap;
}

.badge.high {
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.12);
  color: var(--red);
}

.badge.med {
  border-color: rgba(255, 210, 107, 0.28);
  background: rgba(255, 210, 107, 0.12);
  color: var(--muted);
}

.badge.low {
  border-color: rgba(124, 255, 155, 0.25);
  background: rgba(124, 255, 155, 0.10);
  color: var(--green);
}

.badge.pos { color: var(--green); border-color: rgba(124, 255, 155, 0.25); background: rgba(124, 255, 155, 0.10); }
.badge.neg { color: var(--red); border-color: rgba(255, 107, 107, 0.30); background: rgba(255, 107, 107, 0.12); }
.badge.neu { color: var(--muted); }

/* =============================
   STOCK DETAIL: TOPBAR
============================= */
.stock-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 13px;
}

.stock-company { color: var(--muted); }
.stock-sep { color: var(--muted); opacity: 0.4; }

.stock-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stock-price-group { text-align: right; }

.stock-price {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text);
}

.stock-pct { font-size: 14px; font-weight: 800; margin-top: 2px; }
.stock-pct.pos { color: var(--green); }
.stock-pct.neg { color: var(--red); }
.stock-pct.flat { color: var(--muted); }

/* =============================
   STOCK DETAIL: GRID
============================= */
.stock-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.stock-grid .section-head { margin-bottom: 8px; }

/* =============================
   METRICS TABLE
============================= */
.metrics-table {
  width: 100%;
  border-collapse: collapse;
}

.metrics-table tr { border-bottom: 1px solid var(--border); }

.metrics-table td {
  padding: 10px 6px;
  font-size: 13px;
  vertical-align: top;
}

.metrics-label { color: var(--muted); font-weight: 600; }
.metrics-value { text-align: right; font-weight: 800; color: var(--text); }

/* =============================
   RISK TAGS
============================= */
.risk-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.risk-tag {
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--muted);
  white-space: nowrap;
}

/* =============================
   EVENTS TABLE (Stock Detail)
============================= */
.events-table thead th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}

.events-table tbody td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 13px;
  color: var(--text);
}

.events-title { font-weight: 900; color: var(--text); }
.events-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.events-date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.events-num { font-weight: 900; text-align: right; color: var(--text); }

/* =============================
   SIGNAL CARD (Feed)
============================= */
.feed-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.signal-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.signal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  transition: all 120ms ease;
  cursor: pointer;
}

.signal-card.pos { border-left-color: var(--green); }
.signal-card.neg { border-left-color: var(--red); }

.signal-card:hover {
  background: var(--hover);
  border-color: rgba(128, 128, 128, 0.15);
  transform: translateY(-1px);
}

.signal-card.pos:hover { border-left-color: var(--green); }
.signal-card.neg:hover { border-left-color: var(--red); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.card-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.card-badge {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--panel2);
  border: 1px solid var(--border);
  font-weight: 900;
  font-size: 14px;
  flex: 0 0 auto;
  color: var(--text);
}

.card-info {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.card-sym {
  font-weight: 900;
  font-size: 15px;
  letter-spacing: -0.02em;
  flex: 0 0 auto;
  color: var(--text);
}

.card-name {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.card-pct { font-weight: 900; font-size: 15px; }
.card-pct.pos { color: var(--green); }
.card-pct.neg { color: var(--red); }
.card-pct.flat { color: var(--muted); }

.card-arrow { font-size: 12px; }
.card-arrow.pos { color: var(--green); }
.card-arrow.neg { color: var(--red); }

.card-headline {
  font-size: 13px;
  color: var(--text);
  opacity: 0.82;
  line-height: 1.45;
  margin-bottom: 10px;
}

.card-conf {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.conf-bar {
  flex: 1;
  height: 6px;
  background: var(--panel2);
  border-radius: 999px;
  overflow: hidden;
}

.conf-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--accent));
  transition: width 300ms ease;
}

.conf-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex: 0 0 auto;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.card-meta-sep { opacity: 0.4; }

/* =============================
   FILTER SIDEBAR
============================= */
.filter-group { margin-top: 16px; }

.filter-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-radio,
.filter-check {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-radio-label,
.filter-check-label {
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background 120ms;
}

.filter-radio-label:hover,
.filter-check-label:hover {
  background: var(--hover);
}

.filter-radio-input,
.filter-check-input {
  margin-right: 8px;
  accent-color: var(--accent);
}

.range-group { display: flex; gap: 4px; }

.range-btn {
  flex: 1;
  padding: 8px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all 120ms;
}

.range-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.range-btn.active {
  background: var(--hover);
  color: var(--text);
  border-color: var(--border);
}

.filter-reset {
  width: 100%;
  margin-top: 20px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all 120ms;
}

.filter-reset:hover {
  background: var(--hover);
  color: var(--text);
}

/* =============================
   LOAD MORE
============================= */
.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 20px 0;
}

.load-more-btn {
  padding: 12px 32px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: all 120ms ease;
}

.load-more-btn:hover {
  background: var(--hover);
  border-color: rgba(128, 128, 128, 0.15);
}

.load-more-btn:active { transform: scale(0.98); }

/* =============================
   STOCKS LANDING: MOVERS
============================= */
.movers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.movers-panel { padding: 14px; }

.movers-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.movers-icon { font-size: 14px; font-weight: 900; }
.movers-icon.pos { color: var(--green); }
.movers-icon.neg { color: var(--red); }

.movers-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mover-link {
  text-decoration: none;
  color: inherit;
  display: block;
  border-radius: 10px;
  transition: background 120ms;
}

.mover-link:hover { background: var(--hover); }

.mover-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  gap: 10px;
}

/* =============================
   STOCKS LANDING: PROMPT
============================= */
.stocks-prompt {
  align-items: center;
  gap: 14px;
  margin-top: 24px;
  padding: 16px 20px;
  border-radius: 14px;
  border: 1px dashed var(--border);
  background: var(--panel);
}

.prompt-arrow {
  font-size: 20px;
  color: var(--muted);
  animation: nudge 2s infinite;
}

@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(-4px); }
}

.prompt-title { font-weight: 800; font-size: 14px; color: var(--text); }
.prompt-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* =============================
   EMPTY STATE
============================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  min-height: 200px;
}

.empty-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.5; }
.empty-title { font-weight: 900; font-size: 15px; margin-bottom: 6px; color: var(--text); }
.empty-desc { font-size: 13px; color: var(--muted); max-width: 320px; line-height: 1.5; }

.empty-cta {
  margin-top: 16px;
  padding: 10px 20px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  text-decoration: none;
  transition: opacity 120ms;
}

.empty-cta:hover { opacity: 0.85; }

/* =============================
   ERROR BANNER
============================= */
.error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.20);
}

.error-icon { font-size: 18px; flex: 0 0 auto; }
.error-msg { font-weight: 800; font-size: 13px; color: var(--red); }
.error-detail { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* =============================
   SKELETON LOADERS
============================= */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--panel2) 25%,
    var(--hover) 50%,
    var(--panel2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-kpi  { height: 80px; }
.skeleton-row  { height: 48px; margin-bottom: 8px; }
.skeleton-heat { height: 240px; }

/* =============================
   RESPONSIVE VISIBILITY
============================= */
.mobile-only { display: none; }
.desktop-only { display: flex; }

/* =============================
   MOBILE BOTTOM NAV
============================= */
.mobile-nav { display: none; }

/* =============================
   MOBILE STOCKS PANEL
============================= */
.mobile-stocks-panel { margin-bottom: 14px; }
.mobile-stocks-panel .search { margin-bottom: 10px; }

.mobile-stocks-panel .list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 50vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* =============================
   RESPONSIVE: TABLET (768–1024)
============================= */
@media (min-width: 768px) and (max-width: 1024px) {
  .sidebar-secondary { width: 240px; }
  .stock-grid { grid-template-columns: 1fr; }
}

/* =============================
   RESPONSIVE: MOBILE (<768)
============================= */
@media (max-width: 768px) {

  /* Layout */
  .app-shell { flex-direction: column; }

  .sidebar-primary { display: none !important; }

  .sidebar-secondary {
    display: none !important;
    width: 0 !important;
  }

  .content {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    overflow-x: hidden;
    padding: 14px 12px 100px;
  }

  /* Bottom nav */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: var(--panel);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 6px 0 0;
    padding-bottom: calc(env(safe-area-inset-bottom, 8px) + 6px);
  }

  .mnav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    transition: color 120ms;
  }

  .mnav-tab.active { color: var(--accent); }
  .mnav-icon { font-size: 20px; line-height: 20px; }

  /* Visibility */
  .mobile-only { display: block; }
  .desktop-only { display: none !important; }

  /* Grids → single column */
  .dash-grid { grid-template-columns: 1fr; }
  .stock-grid { grid-template-columns: 1fr; }
  .movers-grid { grid-template-columns: 1fr; }

  /* KPIs: 2 cols */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpis-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Topbar stack */
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .stock-topbar-right { flex-direction: row; gap: 10px; }

  /* Tables scroll */
  .events-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .metrics-table { font-size: 12px; }
  .panel { overflow-x: auto; max-width: 100%; }

  /* Feed cards */
  .card-header { flex-wrap: wrap; gap: 6px; }

  /* Compact type */
  .h2 { font-size: 18px; }
  .stock-price { font-size: 16px; }
  .kpi-val { font-size: 16px; word-break: break-all; }

  /* Event cards mobile */
  .ecard { padding: 12px; gap: 8px; }
  .ecard-title { font-size: 13px; }
  .ecard-chips { gap: 5px; }
  .echip { padding: 4px 8px; gap: 4px; }
  .echip-sym { font-size: 11px; }
  .echip-pct { font-size: 10px; }

  /* Plotly charts */
  .js-plotly-plot,
  .plot-container,
  .svg-container {
    width: 100% !important;
    max-width: 100vw !important;
    .metrics-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  }
  /* ── Fix: Metrics table no desborde ── */
  .metrics-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .metrics-label {
    white-space: nowrap;
  }

  .risk-tags {
    justify-content: flex-start;
  }

  .section {
    max-width: 100%;
    overflow: hidden;
  }
  /* ── Fix: Chart + Events no desbordan ── */
  .stock-grid {
    min-width: 0;
  }

  .stock-grid > * {
    min-width: 0;
    overflow: hidden;
  }

  .panel {
    min-width: 0;
  }

  .events-scroll {
    max-width: 100%;
    overflow-x: auto;
  }

  .events-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    min-width: 500px;
  }
}

@media (max-width: 900px) {
  .movers-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1200px) {
  .dash-grid { grid-template-columns: 1fr; }
  .stock-grid { grid-template-columns: 1fr; }
}

/* =============================
   NAV ICONS (geometric, theme-aware)
============================= */
.nav-icon {
  width: 20px;
  height: 20px;
  background: currentColor;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  flex: 0 0 auto;
}

/* Home: triangle roof + square body */
.icon-home {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12l8-8 8 8'/%3E%3Crect x='6' y='12' width='12' height='9' rx='1.5'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12l8-8 8 8'/%3E%3Crect x='6' y='12' width='12' height='9' rx='1.5'/%3E%3C/svg%3E");
}

/* Feed: three horizontal rectangles */
.icon-feed {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Crect x='3' y='4' width='18' height='4' rx='1'/%3E%3Crect x='3' y='10' width='18' height='4' rx='1'/%3E%3Crect x='3' y='16' width='12' height='4' rx='1'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Crect x='3' y='4' width='18' height='4' rx='1'/%3E%3Crect x='3' y='10' width='18' height='4' rx='1'/%3E%3Crect x='3' y='16' width='12' height='4' rx='1'/%3E%3C/svg%3E");
}

/* Stocks: triangle pointing up */
.icon-stocks {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linejoin='round'%3E%3Cpolygon points='12,3 3,21 21,21'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linejoin='round'%3E%3Cpolygon points='12,3 3,21 21,21'/%3E%3C/svg%3E");
}

/* Signals: three concentric circles */
.icon-signals {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Ccircle cx='12' cy='12' r='7'/%3E%3Ccircle cx='12' cy='12' r='10.5'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Ccircle cx='12' cy='12' r='7'/%3E%3Ccircle cx='12' cy='12' r='10.5'/%3E%3C/svg%3E");
}

/* Portfolio: 2×2 grid of squares */
.icon-portfolio {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='8' height='8' rx='1.5'/%3E%3Crect x='13' y='3' width='8' height='8' rx='1.5'/%3E%3Crect x='3' y='13' width='8' height='8' rx='1.5'/%3E%3Crect x='13' y='13' width='8' height='8' rx='1.5'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='8' height='8' rx='1.5'/%3E%3Crect x='13' y='3' width='8' height='8' rx='1.5'/%3E%3Crect x='3' y='13' width='8' height='8' rx='1.5'/%3E%3Crect x='13' y='13' width='8' height='8' rx='1.5'/%3E%3C/svg%3E");
}

/* Alerts: triangle with dot inside */
.icon-alerts {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linejoin='round'%3E%3Cpolygon points='12,3 2,21 22,21'/%3E%3Ccircle cx='12' cy='17' r='1' fill='black'/%3E%3Crect x='11.25' y='10' width='1.5' height='4.5' rx='0.75' fill='black'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linejoin='round'%3E%3Cpolygon points='12,3 2,21 22,21'/%3E%3Ccircle cx='12' cy='17' r='1' fill='black'/%3E%3Crect x='11.25' y='10' width='1.5' height='4.5' rx='0.75' fill='black'/%3E%3C/svg%3E");
}

/* Settings: circle with 4 satellite circles */
.icon-settings {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Ccircle cx='12' cy='2.5' r='1.5'/%3E%3Ccircle cx='12' cy='21.5' r='1.5'/%3E%3Ccircle cx='2.5' cy='12' r='1.5'/%3E%3Ccircle cx='21.5' cy='12' r='1.5'/%3E%3Ccircle cx='5.4' cy='5.4' r='1.2'/%3E%3Ccircle cx='18.6' cy='5.4' r='1.2'/%3E%3Ccircle cx='5.4' cy='18.6' r='1.2'/%3E%3Ccircle cx='18.6' cy='18.6' r='1.2'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Ccircle cx='12' cy='2.5' r='1.5'/%3E%3Ccircle cx='12' cy='21.5' r='1.5'/%3E%3Ccircle cx='2.5' cy='12' r='1.5'/%3E%3Ccircle cx='21.5' cy='12' r='1.5'/%3E%3Ccircle cx='5.4' cy='5.4' r='1.2'/%3E%3Ccircle cx='18.6' cy='5.4' r='1.2'/%3E%3Ccircle cx='5.4' cy='18.6' r='1.2'/%3E%3Ccircle cx='18.6' cy='18.6' r='1.2'/%3E%3C/svg%3E");
}

/* Mobile nav icon size */
.mnav-tab .nav-icon {
  width: 22px;
  height: 22px;
}

.risk-tag.high {
  border-color: rgba(255, 107, 107, 0.25);
  background: rgba(255, 107, 107, 0.08);
  color: var(--red);
}

.risk-tag.med {
  border-color: var(--border);
  background: var(--panel2);
  color: var(--muted);
}

.risk-tag.low {
  border-color: rgba(124, 255, 155, 0.20);
  background: rgba(124, 255, 155, 0.06);
  color: var(--green);
}

/* =============================
   EVENT CHIPS WITH FORECAST
============================= */
.echip-vals {
  display: flex;
  align-items: center;
  gap: 4px;
}

.echip-arrow {
  font-size: 10px;
  color: var(--muted);
  opacity: 0.5;
}

.echip-fc {
  font-size: 11px;
  font-weight: 800;
}

.echip-fc.pos { color: var(--green); }
.echip-fc.neg { color: var(--red); }
.echip-fc.flat { color: var(--muted); }

.echip.has-fc {
  gap: 8px;
  padding: 5px 10px;
}

/* Legend mini */
.ecard-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}

.echip-legend {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  opacity: 0.6;
}

.ecard-legend .echip-arrow {
  font-size: 9px;
}

@media (max-width: 768px) {
  .echip.has-fc {
    padding: 4px 8px;
    gap: 5px;
  }

  .echip-fc { font-size: 10px; }
  .ecard-legend { display: none; }
}

/* =============================
   FEED: TWO COLUMN LAYOUT
============================= */
.feed-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.feed-col {
  display: flex;
  flex-direction: column;
  gap: 0;
}

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

.feed-col .movers-header {
  margin-bottom: 10px;
}

@media (max-width: 900px) {
  .feed-grid {
    grid-template-columns: 1fr;
  }
}

/* =============================
   STOCK DETAIL: EVENTS SCROLL
============================= */
.events-scroll {
  max-height: 560px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.events-scroll::-webkit-scrollbar {
  width: 4px;
}

.events-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}