/* ══════════════════════════════════════════════════════════════════════════════
   NewsTraders.AI — Dark trading dashboard
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Dark theme (default) ────────────────────────────────────────────────────── */

:root, [data-theme="dark"] {
  --bg-0: #06080d;
  --bg-1: #0c1017;
  --bg-2: #121825;
  --bg-3: #1a2235;
  --bg-4: #222d42;
  --border: #243049;
  --border-light: #2e3d5a;

  --text-0: #f1f5f9;
  --text-1: #cbd5e1;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --text-4: #475569;

  --accent: #22c55e;
  --accent-dim: rgba(34, 197, 94, 0.12);
  --accent-2: #16a34a;

  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --green-text: #4ade80;

  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --red-text: #f87171;

  --yellow: #eab308;
  --yellow-dim: rgba(234, 179, 8, 0.12);
  --yellow-text: #fbbf24;

  --purple: #a855f7;
  --purple-dim: rgba(168, 85, 247, 0.12);

  --orange: #f97316;
  --orange-dim: rgba(249, 115, 22, 0.12);

  --shadow: 0 2px 12px rgba(0,0,0,0.25);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);

  --chart-grid: #243049;
  --chart-zero: #475569;
  --chart-label: #64748b;
}

/* ── Light theme (PAI sim2 green design) ────────────────────────────────────── */

[data-theme="light"] {
  --bg-0: #f8faf8;
  --bg-1: #ffffff;
  --bg-2: #f0fdf4;
  --bg-3: #dcfce7;
  --bg-4: #bbf7d0;
  --border: #d4e8d4;
  --border-light: #86efac;

  --text-0: #1e293b;
  --text-1: #334155;
  --text-2: #475569;
  --text-3: #64748b;
  --text-4: #94a3b8;

  --accent: #16a34a;
  --accent-dim: rgba(22, 163, 74, 0.08);
  --accent-2: #15803d;

  --green: #15803d;
  --green-dim: rgba(21, 128, 61, 0.08);
  --green-text: #15803d;

  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.06);
  --red-text: #991b1b;

  --yellow: #b45309;
  --yellow-dim: rgba(180, 83, 9, 0.08);
  --yellow-text: #92400e;

  --purple: #7c3aed;
  --purple-dim: rgba(124, 58, 237, 0.06);

  --orange: #ea580c;
  --orange-dim: rgba(234, 88, 12, 0.06);

  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);

  --chart-grid: #d4e8d4;
  --chart-zero: #86efac;
  --chart-label: #64748b;
}

/* PAI sim2-style overrides for light theme */
[data-theme="light"] body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

[data-theme="light"] .header {
  background: #ffffff;
  border-bottom: 1px solid #d4e8d4;
}

[data-theme="light"] .logo {
  color: #1e293b;
  background: linear-gradient(135deg, #16a34a, #15803d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
[data-theme="light"] .logo span {
  background: linear-gradient(135deg, #16a34a, #15803d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .header-divider { background: #d4e8d4; }

[data-theme="light"] .tabs .tab { color: #64748b; }
[data-theme="light"] .tabs .tab:hover { color: #16a34a; background: #f0fdf4; }
[data-theme="light"] .tabs .tab.active { color: #fff; background: #16a34a; }

[data-theme="light"] .connection-status { color: #64748b; }
[data-theme="light"] #statusText { color: #64748b; }

[data-theme="light"] .theme-toggle {
  background: #fff;
  border-color: #d4e8d4;
  color: #64748b;
}
[data-theme="light"] .theme-toggle:hover {
  border-color: #16a34a;
  color: #16a34a;
  background: #f0fdf4;
}

[data-theme="light"] .btn-accent {
  border-color: #16a34a;
  background: #16a34a;
  color: #fff;
  font-weight: 700;
}
[data-theme="light"] .btn-accent:hover {
  background: #15803d;
  color: #fff;
}

[data-theme="light"] .badge-accent {
  background: #dcfce7;
  color: #15803d;
}

[data-theme="light"] .badge-yellow {
  background: #fef3c7;
  color: #92400e;
}

[data-theme="light"] .badge-green {
  background: #dcfce7;
  color: #15803d;
}

[data-theme="light"] .badge-red {
  background: #fee2e2;
  color: #991b1b;
}

[data-theme="light"] .badge-purple {
  background: #f3e8ff;
  color: #7c3aed;
}

[data-theme="light"] .stat-card {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

[data-theme="light"] .stat-highlight {
  background: #dcfce7;
  border-color: #86efac;
  border-width: 2px;
}

[data-theme="light"] .stat-value { color: #1e293b; }

[data-theme="light"] .panel {
  background: #ffffff;
  border-color: #d4e8d4;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

[data-theme="light"] .panel-title { color: #16a34a; }

[data-theme="light"] .sidebar-title { color: #16a34a; }

[data-theme="light"] .slider::-webkit-slider-thumb {
  background: #16a34a;
  box-shadow: 0 0 6px rgba(22, 163, 74, 0.4);
}

[data-theme="light"] .slider { background: #d4e8d4; }

[data-theme="light"] .drawer {
  background: #ffffff;
  border-right-color: #d4e8d4;
}

[data-theme="light"] .pos-card,
[data-theme="light"] .signal-card,
[data-theme="light"] .decision-card {
  background: #ffffff;
  border-color: #d4e8d4;
}

[data-theme="light"] .pos-card:hover,
[data-theme="light"] .signal-card:hover,
[data-theme="light"] .decision-card:hover {
  border-color: #86efac;
  background: #f0fdf4;
}

[data-theme="light"] .decision-card.action-open { border-left-color: #16a34a; }
[data-theme="light"] .decision-card.action-close { border-left-color: #3b82f6; }
[data-theme="light"] .decision-card.action-skip { border-left-color: #94a3b8; }

[data-theme="light"] .direction-tag.long { background: #dcfce7; color: #15803d; }
[data-theme="light"] .direction-tag.short { background: #fee2e2; color: #991b1b; }

[data-theme="light"] .phase-tag.rumor { background: #fef3c7; color: #92400e; }
[data-theme="light"] .phase-tag.confirmed { background: #dcfce7; color: #15803d; }

[data-theme="light"] .ticker-tag {
  background: #dcfce7;
  color: #15803d;
}

[data-theme="light"] .filter-btn { background: #fff; border-color: #d4e8d4; color: #64748b; }
[data-theme="light"] .filter-btn:hover { border-color: #16a34a; color: #16a34a; }
[data-theme="light"] .filter-btn.active { background: #dcfce7; color: #16a34a; border-color: #86efac; }

[data-theme="light"] .config-value { color: #16a34a; }

[data-theme="light"] .trade-table th { color: #64748b; border-bottom-color: #d4e8d4; }
[data-theme="light"] .trade-table td { border-bottom-color: #e2e8f0; }
[data-theme="light"] .trade-table tbody tr:hover td { background: #f0fdf4; }

[data-theme="light"] .btn-danger {
  border-color: #dc2626;
  background: rgba(220, 38, 38, 0.06);
  color: #dc2626;
}
[data-theme="light"] .btn-danger:hover {
  background: #dc2626;
  color: #fff;
}

:root {
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-width: 280px;
  --header-height: 56px;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-0);
  color: var(--text-1);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 20px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-0);
  white-space: nowrap;
}
.logo span { color: var(--accent); }

/* ── Theme toggle ───────────────────────────────────────────────────────────── */

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.header-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

/* ── Hamburger button ───────────────────────────────────────────────────────── */

.hamburger {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-2);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.hamburger:hover { border-color: var(--accent); background: var(--accent-dim); }

.hamburger span {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--text-2);
  border-radius: 1px;
  transition: all 0.3s;
}

.hamburger:hover span { background: var(--accent); }

.hamburger.active span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

/* ── Tabs ───────────────────────────────────────────────────────────────────── */

.tabs { display: flex; gap: 2px; }

.tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.tab:hover { color: var(--text-1); background: var(--bg-3); }
.tab.active { color: var(--accent); background: var(--accent-dim); }

/* ── Connection status ──────────────────────────────────────────────────────── */

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
  animation: pulse 2s ease-in-out infinite;
}
.status-dot.offline {
  background: var(--red);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */

.btn {
  padding: 7px 18px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.3px;
}

.btn-danger { border-color: var(--red); background: var(--red-dim); color: var(--red-text); }
.btn-danger:hover { background: var(--red); color: white; }

.btn-success { border-color: var(--green); background: var(--green-dim); color: var(--green-text); }
.btn-success:hover { background: var(--green); color: white; }

.btn-accent { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); font-weight: 700; }
.btn-accent:hover { background: var(--accent); color: #1a1a1a; }

.btn-full { width: 100%; margin-top: 10px; padding: 10px; }

.filter-btn {
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover { color: var(--text-1); border-color: var(--border-light); }
.filter-btn.active { color: var(--accent); background: var(--accent-dim); border-color: var(--accent); }

/* ── Layout ─────────────────────────────────────────────────────────────────── */

.layout {
  display: flex;
  min-height: calc(100vh - var(--header-height));
  overflow: hidden;
}

.content {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  min-width: 0;
  max-height: calc(100vh - var(--header-height));
}

.tab-content { display: none; }
.tab-content.active { display: flex; flex-direction: column; }
.tab-content > .panel { flex: 1; display: flex; flex-direction: column; }
.tab-content > .panel > .panel-body { flex: 1; }
.tab-content > .stats-grid,
.tab-content > .grid-2col { flex-shrink: 0; }

/* ── Slide-in Drawer ─────────────────────────────────────────────────────────── */

.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 300;
  backdrop-filter: blur(2px);
}

.drawer-overlay.open { display: block; }

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 340px;
  height: 100vh;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 301;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-0);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.drawer-section { margin-bottom: 24px; }

.sidebar-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

/* ── Config sliders ─────────────────────────────────────────────────────────── */

.config-group { margin-bottom: 16px; }

.config-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  font-size: 14px;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.15s;
}
.config-input:focus { border-color: var(--accent); }
.config-input::placeholder { color: var(--text-4); }

.config-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 6px;
}

.config-value {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-0);
  font-size: 12px;
}

.slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-4);
  border-radius: 2px;
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

/* ── System stats ───────────────────────────────────────────────────────────── */

/* ── Universe toggles ────────────────────────────────────────────────────────── */

.universe-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.universe-item:last-child { border-bottom: none; }

.universe-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.universe-toggle {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.universe-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.universe-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-4);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.universe-slider:before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.universe-toggle input:checked + .universe-slider {
  background: var(--accent);
}

.universe-toggle input:checked + .universe-slider:before {
  transform: translateX(16px);
}

.universe-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
}

.universe-meta {
  font-size: 10px;
  color: var(--text-4);
}

.universe-count {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-3);
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: 4px;
}

.sys-stat {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.sys-stat:last-child { border-bottom: none; }
.sys-stat span:first-child { color: var(--text-3); }
.sys-stat span:last-child { font-weight: 600; font-family: var(--font-mono); color: var(--text-1); }

/* ── Stats grid ─────────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

.stats-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 900px) {
  .stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s;
}

.stat-card:hover { border-color: var(--border-light); }

.stat-highlight { border-color: var(--accent); border-width: 1px; }

.stat-card .stat-icon { display: none; }

.stat-mini {
  padding: 16px 18px;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.stat-icon {
  width: 38px; height: 38px;
  border-radius: 8px;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.stat-body { min-width: 0; }

.stat-label {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -0.5px;
  color: var(--text-0);
  word-break: break-word;
}

.stat-mini .stat-value { font-size: 22px; word-break: break-all; }
.stat-mini .stat-icon { display: none; }
.stat-mini .stat-body { width: 100%; }

.positive { color: var(--green-text) !important; }
.negative { color: var(--red-text) !important; }

/* ── Panels ─────────────────────────────────────────────────────────────────── */

.panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

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

.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-0);
}

.panel-body {
  padding: 16px 18px;
}

.scroll-y { overflow-y: auto; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  font-family: var(--font-mono);
}

.badge-accent { background: var(--accent-dim); color: var(--accent); }
.badge-green { background: var(--green-dim); color: var(--green-text); }
.badge-red { background: var(--red-dim); color: var(--red-text); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow-text); }
.badge-purple { background: var(--purple-dim); color: var(--purple); }
.badge-orange { background: var(--orange-dim); color: var(--orange); }

/* ── Two-column grid ────────────────────────────────────────────────────────── */

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

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

/* ── Chart ──────────────────────────────────────────────────────────────────── */

.chart-container {
  height: 200px;
  position: relative;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ── Position cards ─────────────────────────────────────────────────────────── */

.pos-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
  animation: fadeSlideIn 0.3s ease-out;
}

.pos-card:hover { border-color: var(--accent); }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

.pos-ticker {
  font-size: 17px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-0);
}

.direction-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.direction-tag.long { background: var(--green-dim); color: var(--green-text); }
.direction-tag.short { background: var(--red-dim); color: var(--red-text); }

.phase-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.phase-tag.rumor { background: var(--yellow-dim); color: var(--yellow-text); }
.phase-tag.confirmed { background: var(--accent-dim); color: var(--accent); }
.phase-tag.repeat { background: var(--purple-dim); color: var(--purple); }

.pos-pnl {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.pos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  font-size: 12px;
}

.pos-grid-6 { grid-template-columns: repeat(6, 1fr); }

.pos-field-label {
  color: var(--text-4);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.pos-field-value {
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-0);
}

.pos-reasoning {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
  font-style: italic;
  line-height: 1.5;
}

.pos-meta {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-4);
}

/* ── Signal cards ───────────────────────────────────────────────────────────── */

.signal-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px 20px;
  margin-bottom: 10px;
  animation: fadeSlideIn 0.3s ease-out;
}

.signal-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.signal-ticker {
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-0);
}

.signal-time {
  font-size: 11px;
  color: var(--text-4);
  margin-left: auto;
  font-family: var(--font-mono);
}

.signal-headline {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.signal-metrics {
  display: flex;
  gap: 18px;
  font-size: 12px;
  margin-bottom: 6px;
}

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

.metric-label { color: var(--text-4); }

.metric-bar {
  width: 48px;
  height: 4px;
  background: var(--bg-4);
  border-radius: 2px;
  overflow: hidden;
}

.metric-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.metric-value {
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-1);
}

.signal-reasoning {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-4);
  font-style: italic;
}

/* ── Decision cards ─────────────────────────────────────────────────────────── */

.decision-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 6px;
  animation: fadeSlideIn 0.2s ease-out;
}

.decision-card.action-open { border-left: 3px solid var(--green); }
.decision-card.action-close { border-left: 3px solid var(--accent); }
.decision-card.action-skip { border-left: 3px solid var(--text-4); }

.decision-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.decision-action {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.decision-action.open { background: var(--green-dim); color: var(--green-text); }
.decision-action.close { background: var(--accent-dim); color: var(--accent); }
.decision-action.skip { background: var(--bg-4); color: var(--text-3); }

.decision-detail {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 4px;
}

.decision-reason {
  font-size: 11px;
  color: var(--text-4);
  font-style: italic;
}

/* ── News cards ─────────────────────────────────────────────────────────────── */

.news-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  animation: fadeSlideIn 0.3s ease-out;
}

.news-item:last-child { border-bottom: none; }

.news-time {
  font-size: 10px;
  color: var(--text-4);
  font-family: var(--font-mono);
  margin-bottom: 4px;
}

.news-headline {
  font-size: 13px;
  color: var(--text-1);
  line-height: 1.4;
  margin-bottom: 6px;
}

.news-tickers {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.ticker-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 4px;
  font-family: var(--font-mono);
}

[data-theme="light"] .ticker-tag {
  background: rgba(255, 204, 0, 0.2);
  color: #8a6d00;
}

/* ── Trade table ────────────────────────────────────────────────────────────── */

.trade-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.trade-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-4);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}

.trade-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 12px;
}

.trade-table tbody tr:hover td { background: var(--bg-3); }

/* ── Analytics breakdown ────────────────────────────────────────────────────── */

.breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.breakdown-row:last-child { border-bottom: none; }

.breakdown-label {
  font-weight: 600;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.breakdown-stats {
  display: flex;
  gap: 20px;
  font-size: 12px;
  font-family: var(--font-mono);
}

.breakdown-stats span { color: var(--text-2); }

.win-bar {
  width: 80px;
  height: 6px;
  background: var(--red-dim);
  border-radius: 3px;
  overflow: hidden;
}

.win-bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.5s;
}

/* ── Empty state ────────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-4);
  font-size: 13px;
}

/* ── Notification ───────────────────────────────────────────────────────────── */

.notification {
  position: fixed;
  top: 68px;
  right: 24px;
  z-index: 9999;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: white;
  box-shadow: var(--shadow-lg);
  animation: fadeSlideIn 0.3s ease-out;
  pointer-events: none;
}

.notification.green { background: var(--green); }
.notification.red { background: var(--red); }

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* ── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .tabs { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .drawer { width: 300px; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   Decision Detail Modal
   ══════════════════════════════════════════════════════════════════════════════ */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: flex-start;
  padding: 30px 20px;
  overflow-y: auto;
  backdrop-filter: blur(4px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 1100px;
  box-shadow: var(--shadow-lg);
  animation: modalSlideIn 0.25s ease-out;
}

@keyframes modalSlideIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-ticker {
  font-size: 24px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-0);
}

.modal-close {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.modal-close:hover { background: var(--red-dim); color: var(--red-text); border-color: var(--red); }

.modal-body {
  padding: 20px 24px;
}

.modal-section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}

.modal-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
}

.modal-headline {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-0);
  line-height: 1.4;
  margin-bottom: 10px;
}

.modal-news-body {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.modal-news-meta {
  font-size: 11px;
  color: var(--text-4);
  font-family: var(--font-mono);
}

.modal-text {
  font-size: 13px;
  color: var(--text-1);
  line-height: 1.6;
}

.modal-sub-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.modal-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.modal-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

/* KPI grid inside modal */
.modal-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.modal-kpi {
  padding: 10px 12px;
  background: var(--bg-3);
  border-radius: var(--radius-sm);
}

.modal-kpi-label {
  font-size: 10px;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 3px;
}

.modal-kpi-value {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-0);
}

/* Gauges */
.modal-gauge {
  padding: 12px;
  background: var(--bg-3);
  border-radius: var(--radius-sm);
  text-align: center;
}

.modal-gauge-label {
  font-size: 10px;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}

.modal-gauge-value {
  font-size: 22px;
  font-weight: 800;
  font-family: var(--font-mono);
}

.modal-gauge-bar {
  height: 5px;
  background: var(--bg-4);
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}

.modal-gauge-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s;
}

/* Sentiment badge */
.modal-sentiment-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-sentiment-badge.extreme_greed { background: var(--green-dim); color: var(--green-text); }
.modal-sentiment-badge.greed { background: var(--green-dim); color: var(--green-text); }
.modal-sentiment-badge.neutral { background: var(--bg-4); color: var(--text-2); }
.modal-sentiment-badge.fear { background: var(--red-dim); color: var(--red-text); }
.modal-sentiment-badge.extreme_fear { background: var(--red-dim); color: var(--red-text); }

/* Sources */
.modal-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal-source-tag {
  font-size: 11px;
  padding: 3px 10px;
  background: var(--bg-4);
  color: var(--text-1);
  border-radius: 4px;
  font-family: var(--font-mono);
}

/* Target chart bar */
.modal-target-bar-container {
  position: relative;
  height: 40px;
  background: var(--bg-4);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 6px;
}

.modal-target-bar-achieved {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  border-radius: var(--radius-sm);
  transition: width 0.5s;
}

.modal-target-bar-target {
  position: absolute;
  top: 0; bottom: 0;
  width: 3px;
  background: var(--text-0);
  z-index: 2;
}

.modal-target-bar-label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: white;
  padding: 0 12px;
  z-index: 3;
}

/* Time bar */
.modal-time-bar {
  height: 10px;
  background: var(--bg-4);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 6px;
}

.modal-time-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s;
}

/* Risk factors */
.modal-risk-list {
  list-style: none;
  padding: 0;
}

.modal-risk-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.modal-risk-item:last-child { border-bottom: none; }

.modal-risk-bullet {
  color: var(--red-text);
  font-size: 10px;
  margin-top: 4px;
  flex-shrink: 0;
}

/* Scores row */
.modal-scores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.modal-score-item {
  padding: 10px;
  background: var(--bg-3);
  border-radius: var(--radius-sm);
  text-align: center;
}

.modal-score-label {
  font-size: 9px;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.modal-score-value {
  font-size: 18px;
  font-weight: 800;
  font-family: var(--font-mono);
}

/* Loading state */
.modal-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}

.modal-loading-spinner {
  display: inline-block;
  width: 30px; height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
