/* Moneymaker v2 — Full Theme (dark-first, responsive) */

/* ============================================================
 * CSS Variables
 * ============================================================ */
:root {
  --bg: #0f1117;
  --card: #1a1d28;
  --border: #2a2d3a;
  --text: #e1e4ed;
  --text2: #8b8fa3;
  --text3: #6b6f82;
  --accent: #6366f1;
  --accent2: #4f46e5;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --hover: #212433;
  --header: #151824;
  --sidebar-w: 220px;
  --topbar-h: 52px;
  --bottomnav-h: 64px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --shadow-lg: 0 4px 20px rgba(0,0,0,.4);
  --transition: .2s ease;
  --font: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Segoe UI', sans-serif;
}
[data-theme="light"] {
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text2: #718096;
  --text3: #a0aec0;
  --accent: #6366f1;
  --accent2: #4f46e5;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #ca8a04;
  --hover: #edf2f7;
  --header: #f0f4f8;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --shadow-lg: 0 4px 20px rgba(0,0,0,.06);
}

/* ============================================================
 * Reset & Base
 * ============================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
img { max-width: 100%; }
code { font-family: 'SF Mono', 'Fira Code', monospace; }
::selection { background: rgba(99,102,241,.3); color: #fff; }

/* ============================================================
 * Scrollbar
 * ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ============================================================
 * Layout: Sidebar (Desktop), Topbar (Mobile), Content
 * ============================================================ */

/* Sidebar */
.sidebar {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--card);
  border-right: 1px solid var(--border);
  flex-direction: column;
  z-index: 100;
  padding: 0;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #fff;
}
.sidebar-name {
  font-size: 15px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-links {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  position: relative;
}
.sidebar-link:hover {
  background: var(--hover);
  color: var(--text);
  text-decoration: none;
}
.sidebar-link.active {
  background: rgba(99,102,241,.12);
  color: var(--accent);
  font-weight: 600;
}
.sidebar-link .sl-icon { font-size: 18px; }
.sidebar-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

/* Topbar (mobile) */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--topbar-h);
  padding: 0 12px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-menu {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text);
  padding: 4px;
  line-height: 1;
}
.topbar-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
}
.topbar-actions {
  display: flex;
  gap: 6px;
}
.topbar-refresh {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text2);
  padding: 4px;
  line-height: 1;
}
.topbar-refresh:hover { color: var(--text); }

/* Main Content */
.main-content {
  padding: 12px;
  padding-bottom: calc(var(--bottomnav-h) + 12px);
  min-height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
  transition: padding-left var(--transition);
}

/* ============================================================
 * Bottom Navigation (Mobile)
 * ============================================================ */
.bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: var(--card);
  border-top: 1px solid var(--border);
  justify-content: space-around;
  align-items: center;
  padding: 4px 0;
  padding-bottom: max(4px, env(safe-area-inset-bottom, 4px));
  backdrop-filter: blur(10px);
}
.bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 4px;
  flex: 1;
  min-width: 0;
  min-height: 48px;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text2);
  font-size: 10px;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  text-decoration: none;
}
.bottom-nav .nav-item:active { transform: scale(.92); }
.bottom-nav .nav-item.active { color: var(--accent); font-weight: 600; }
.bottom-nav .nav-icon { font-size: 20px; line-height: 1; }

/* Mobile overlay + panel */
.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 60;
}
.mobile-panel {
  position: fixed;
  top: 0; left: 0;
  width: 280px;
  height: 100vh;
  background: var(--card);
  z-index: 70;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.mp-header {
  padding: 18px 16px;
  font-size: 16px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.mp-links {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mp-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
  transition: background var(--transition);
}
.mp-link:hover { background: var(--hover); text-decoration: none; }

/* ============================================================
 * Card System
 * ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), background var(--transition);
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--header);
  gap: 8px;
}
.card-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.card-body {
  padding: 14px;
}
.card-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.card-tab {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  transition: all var(--transition);
}
.card-tab.active {
  background: var(--accent);
  color: #fff;
}
.card-tab:hover:not(.active) { color: var(--text); }

/* ============================================================
 * KPI Grid
 * ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.kpi-up::before { background: var(--green); }
.kpi-down::before { background: var(--red); }
.kpi-label {
  font-size: 10px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .3px;
  margin-bottom: 4px;
}
.kpi-value {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 2px;
}
.kpi-change {
  font-size: 11px;
  font-weight: 600;
}
.kpi-subtitle {
  font-size: 11px;
  color: var(--text2);
}
.risk-score { font-size: 22px; }
.risk-max { font-size: 12px; color: var(--text3); }

/* ============================================================
 * Dashboard Grid
 * ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

/* ============================================================
 * Donut Chart
 * ============================================================ */
.donut-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}
.donut-svg { width: 180px; height: 180px; }
.donut-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text2);
}
.donut-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.donut-label { color: var(--text); }
.donut-pct { font-weight: 600; color: var(--text2); }

/* ============================================================
 * Briefing Card
 * ============================================================ */
.briefing-card .card-body { padding: 12px; }
.briefing-risk {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.br-label { font-size: 10px; color: var(--text2); }
.br-score { font-weight: 700; font-size: 16px; }
.br-bar { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.br-bar-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.br-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 11px;
  gap: 8px;
}
.br-row:last-child { border-bottom: none; }
.br-key { color: var(--text2); flex-shrink: 0; }
.br-val { text-align: right; font-weight: 500; word-break: break-word; }
.br-val.pos { color: var(--green); }
.br-val.neg { color: var(--red); }
.br-val.warn { color: var(--yellow); }
.br-exposures {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.br-chat-link {
  display: block;
  margin-top: 10px;
  padding: 8px;
  text-align: center;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.br-chat-link:hover { background: var(--accent2); text-decoration: none; }

/* ============================================================
 * Exposure Pill
 * ============================================================ */
.exp-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 10px;
}
.exp-label { color: var(--text2); }
.exp-value { font-weight: 600; color: var(--accent); }

/* ============================================================
 * Tables
 * ============================================================ */
.table-wrap { padding: 0; overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table thead { background: var(--header); }
.data-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 10px;
  color: var(--text2);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
}
.data-table th:hover { color: var(--text); background: var(--hover); }
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.data-table tbody tr { cursor: pointer; transition: background .15s; }
.data-table tbody tr:hover { background: var(--hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

.sort-arrow { font-size: 9px; margin-left: 2px; opacity: .5; }

/* Position row */
.p-col-symbol { display: flex; align-items: center; gap: 6px; }
.p-symbol { font-weight: 600; font-size: 13px; }
.p-market { font-size: 9px; }
.p-col-price { font-weight: 600; }
.p-col-value { font-weight: 600; }
.weight-bar-wrap {
  display: inline-block;
  width: 50px;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  vertical-align: middle;
  overflow: hidden;
}
.weight-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  min-width: 2px;
}
.weight-pct { font-size: 10px; color: var(--text2); margin-left: 3px; }
.chart-link { text-decoration: none; font-size: 16px; }
.chart-link:hover { text-decoration: none; filter: brightness(1.2); }

/* ============================================================
 * Timeline / Chart Container
 * ============================================================ */
.timeline-card .card-body { padding: 0; }
.chart-container { position: relative; width: 100%; min-height: 400px; }
.chart-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text2);
  font-size: 13px;
}
.tl-stats {
  display: flex;
  gap: 10px;
  font-size: 10px;
  color: var(--text2);
  flex-wrap: wrap;
}
.tl-stats b { color: var(--text); font-weight: 600; }
.tl-stats .up { color: var(--green); }
.tl-stats .dn { color: var(--red); }

/* ============================================================
 * Chart Page
 * ============================================================ */
.chart-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ch-left { display: flex; align-items: center; gap: 8px; }
.ch-symbol { font-size: 20px; font-weight: 700; }
.ch-name { font-size: 12px; color: var(--text2); }
.ch-center { text-align: center; flex: 1; }
.ch-price { font-size: 22px; font-weight: 700; }
.ch-change { font-size: 13px; font-weight: 600; }
.ch-right { display: flex; align-items: center; gap: 6px; }
.ch-back {
  background: var(--hover);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

/* Timeframe buttons */
.tf { display: flex; gap: 3px; }
.tf-btn {
  background: var(--border);
  color: var(--text2);
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: all var(--transition);
}
.tf-btn:hover { background: var(--text3); color: var(--text); }
.tf-btn.on { background: var(--accent); color: #fff; }

/* Indicator bar */
.indicator-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}
.indicator-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text2);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 4px;
  transition: background var(--transition);
}
.indicator-toggle:hover { background: var(--hover); color: var(--text); }
.indicator-toggle input { accent-color: var(--accent); }
.indicator-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.indicator-panels { margin-top: 8px; }

/* Chart layout */
.chart-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* AI sidebar */
.ai-brief-card .card-body { max-height: 400px; overflow-y: auto; font-size: 12px; }
.ab-loading, .ab-empty { color: var(--text2); padding: 16px; text-align: center; }
.ab-text { line-height: 1.7; color: var(--text); white-space: pre-wrap; }

/* ============================================================
 * Signals Page
 * ============================================================ */
.signal-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label {
  font-size: 10px;
  color: var(--text2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.filter-chips { display: flex; gap: 3px; }
.chip {
  background: var(--border);
  color: var(--text2);
  border: none;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  transition: all var(--transition);
}
.chip.active { background: var(--accent); color: #fff; }
.chip:hover:not(.active) { background: var(--hover); color: var(--text); }
.filter-select {
  background: var(--border);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: inherit;
}
.filter-clear {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  margin-left: auto;
}
.filter-clear:hover { background: var(--hover); color: var(--text); }

.signal-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  transition: border-color var(--transition);
}
.signal-card:hover { border-color: var(--accent); }
.sc-left { display: flex; gap: 10px; flex: 1; }
.sc-icon { font-size: 22px; line-height: 1; }
.sc-info { flex: 1; }
.sc-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.sc-meta {
  display: flex;
  gap: 6px;
  font-size: 10px;
  color: var(--text2);
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.sc-reason { font-size: 11px; color: var(--text3); line-height: 1.5; }
.sc-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.sc-score { font-size: 12px; }
.sc-score-val { font-size: 18px; font-weight: 700; }
.sc-score-max { font-size: 10px; color: var(--text3); }
.sc-ack-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
}
.sc-ack-btn:hover { background: var(--accent2); }
.sc-acked { font-size: 11px; color: var(--green); font-weight: 600; }

/* ============================================================
 * Risk Page
 * ============================================================ */
.risk-hero {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
}
.rh-score { text-align: center; flex-shrink: 0; }
.rh-number { font-size: 48px; font-weight: 800; line-height: 1; }
.rh-label { font-size: 11px; color: var(--text2); margin-top: 4px; }
.rh-bar-wrap { flex: 1; }
.rh-bar { height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; }
.rh-bar-fill { height: 100%; border-radius: 5px; transition: width .5s ease; }
.rh-status { font-size: 12px; color: var(--text2); margin-top: 8px; }

.risk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.risk-factor-card .card-body { padding: 12px; font-size: 12px; }
.risk-badge {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
}
.rf-bar { height: 5px; background: var(--border); border-radius: 3px; margin-bottom: 8px; overflow: hidden; }
.rf-bar-fill { height: 100%; border-radius: 3px; }
.rf-desc { font-size: 11px; color: var(--text); margin-bottom: 4px; }
.rf-detail { font-size: 10px; color: var(--text2); }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.metric-item { text-align: center; }
.metric-label { font-size: 10px; color: var(--text2); margin-bottom: 4px; }
.metric-value { font-size: 24px; font-weight: 700; }

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 6px;
}
.heatmap-cell {
  background: rgba(99,102,241,var(--heat-opacity, 0.1));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}
.hm-label { font-size: 10px; color: var(--text2); margin-bottom: 4px; }
.hm-value { font-size: 14px; font-weight: 700; }

/* ============================================================
 * Chat Page
 * ============================================================ */
.page-chat { height: calc(100vh - var(--topbar-h) - var(--bottomnav-h) - 24px); display: flex; }
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--header), var(--hover));
  border-bottom: 1px solid var(--border);
}
.ch-status { display: flex; align-items: center; gap: 8px; }
.ch-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text3);
}
.ch-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.ch-dot.offline { background: var(--yellow); }
.ch-model { font-weight: 600; font-size: 13px; }
.ch-sub { font-size: 11px; color: var(--text2); }
.ch-sub.blink { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.ch-clear {
  background: var(--border);
  border: none;
  color: var(--text2);
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.ch-clear:hover { background: var(--hover); color: var(--text); }

/* Chat briefing */
.chat-briefing {
  padding: 10px 12px;
  background: linear-gradient(180deg, var(--header), var(--card));
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}
.cb-loading { color: var(--text2); text-align: center; padding: 8px; }
.cb-risk { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cb-label { color: var(--text2); font-size: 10px; }
.cb-score { font-weight: 700; font-size: 14px; }
.cb-bar { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.cb-bar-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.cb-row { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed var(--hover); gap: 8px; }
.cb-row:last-child { border-bottom: none; }
.cb-key { color: var(--text2); flex-shrink: 0; }
.cb-val { text-align: right; font-weight: 500; }
.cb-val.pos { color: var(--green); }
.cb-val.neg { color: var(--red); }
.cb-exposures { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.cb-exp-pill { background: var(--hover); border: 1px solid var(--border); border-radius: 10px; padding: 2px 8px; font-size: 10px; }
.cb-exp-pill strong { color: var(--accent); }

/* Chat messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.msg { max-width: 88%; padding: 8px 12px; border-radius: 12px; line-height: 1.5; word-break: break-word; }
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--hover);
  color: var(--text);
  border-bottom-left-radius: 3px;
  border: 1px solid var(--border);
}
.msg.streaming {
  align-self: flex-start;
  background: var(--hover);
  color: var(--text);
  border-bottom-left-radius: 3px;
  border: 1px solid var(--accent);
}
.msg.error {
  align-self: flex-start;
  color: var(--red);
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.2);
  border-radius: 10px;
  font-size: 12px;
}
.msg.thinking {
  align-self: flex-start;
  color: var(--text2);
  font-size: 12px;
  padding: 4px 8px;
}
.msg-time { font-size: 9px; color: var(--text3); margin-top: 3px; text-align: right; }
.msg.user .msg-time { color: rgba(255,255,255,.5); }
.inline-code {
  background: rgba(99,102,241,.1);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  font-family: monospace;
}

/* Thinking dots */
.thinking-dots { display: flex; gap: 4px; padding: 4px 0; }
.thinking-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text3);
  animation: dot-pulse 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: .2s; }
.thinking-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes dot-pulse { 0%,80%,100% { opacity: .3; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }

/* Chat quick actions */
.chat-quick {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--header);
}
.chat-quick button {
  background: var(--hover);
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: all .15s;
}
.chat-quick button:hover { background: var(--border); border-color: var(--accent); color: var(--text); }

/* Chat input */
.chat-input-bar {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--header);
}
.ci-textarea {
  flex: 1;
  background: var(--hover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  resize: none;
  font-family: inherit;
  min-height: 38px;
  max-height: 120px;
  line-height: 1.4;
}
.ci-textarea:focus { outline: none; border-color: var(--accent); }
.ci-send {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  min-width: 56px;
  transition: background var(--transition);
}
.ci-send:disabled { background: var(--border); color: var(--text3); cursor: not-allowed; }
.ci-send:hover:not(:disabled) { background: var(--accent2); }
.send-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
 * Badges
 * ============================================================ */
.badge {
  font-size: 9px;
  color: var(--text2);
  background: var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 500;
}
.badge-us { background: rgba(99,102,241,.2); color: var(--accent); }
.badge-kr { background: rgba(34,197,94,.2); color: var(--green); }
.badge-coin { background: rgba(234,179,8,.2); color: var(--yellow); }
.badge-live { background: rgba(34,197,94,.2); color: var(--green); }
.badge-ai { background: rgba(168,85,247,.2); color: #a855f7; }
.badge-high { background: rgba(239,68,68,.2); color: var(--red); }
.badge-medium { background: rgba(234,179,8,.2); color: var(--yellow); }
.badge-low { background: rgba(34,197,94,.2); color: var(--green); }

/* ============================================================
 * State & Utility
 * ============================================================ */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text2);
  font-size: 13px;
}
.green { color: var(--green); }
.red { color: var(--red); }
.yellow { color: var(--yellow); }

.refresh-indicator {
  font-size: 10px;
  color: var(--text3);
  text-align: right;
  margin-bottom: 8px;
}

[x-cloak] { display: none !important; }

/* ============================================================
 * Theme Toggle
 * ============================================================ */
.theme-toggle {
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--hover); border-color: var(--accent); }
.mobile-only { display: flex; }
@media (min-width: 1024px) { .mobile-only { display: none; } }

/* ============================================================
 * Responsive: Tablet (600px+)
 * ============================================================ */
@media (min-width: 600px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .risk-grid { grid-template-columns: repeat(3, 1fr); }
  .chart-layout { grid-template-columns: 1fr 280px; }
  .signal-filters { flex-wrap: nowrap; }
}

/* ============================================================
 * Responsive: Desktop (1024px+)
 * ============================================================ */
@media (min-width: 1024px) {
  .sidebar { display: flex; }
  .topbar { display: none; }
  .main-content {
    margin-left: var(--sidebar-w);
    padding: 20px;
    padding-bottom: 20px;
  }
  .bottom-nav { display: none; }
  .kpi-grid { grid-template-columns: repeat(6, 1fr); }
  .risk-grid { grid-template-columns: repeat(5, 1fr); }
  .mobile-only { display: none; }
}

/* ============================================================
 * Animations
 * ============================================================ */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.kpi-card { animation: fadeIn .4s ease-out; }
.kpi-card:nth-child(2) { animation-delay: .05s; }
.kpi-card:nth-child(3) { animation-delay: .1s; }
.kpi-card:nth-child(4) { animation-delay: .15s; }
.kpi-card:nth-child(5) { animation-delay: .2s; }
.kpi-card:nth-child(6) { animation-delay: .25s; }

/* Skeleton loader */
@keyframes skeleton-shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}
.skeleton {
  background: var(--border);
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

/* Flash highlight for HTMX updates */
@keyframes flash-update {
  0% { background-color: rgba(99,102,241,.15); transform: scale(1.02); }
  100% { background-color: transparent; transform: scale(1); }
}
.htmx-swapping { animation: flash-update .6s ease-out; }

/* ============================================================
 * PWA Install Banner
 * ============================================================ */
.pwa-banner {
  display: none;
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  background: var(--accent);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(99,102,241,.4);
  cursor: pointer;
  white-space: nowrap;
}
