/* ── Reset & Root ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #060810;
  --surface:     #0c1021;
  --surface2:    #111827;
  --surface3:    #1a2235;
  --border:      #1e2d45;
  --border-soft: #131e30;
  --accent:      #f59e0b;
  --accent-dim:  rgba(245,158,11,0.10);
  --accent-line: rgba(245,158,11,0.22);
  --green:       #10b981;
  --green-dim:   rgba(16,185,129,0.12);
  --green-line:  rgba(16,185,129,0.28);
  --red:         #ef4444;
  --red-dim:     rgba(239,68,68,0.12);
  --red-line:    rgba(239,68,68,0.28);
  --blue:        #3b82f6;
  --blue-dim:    rgba(59,130,246,0.10);
  --purple:      #8b5cf6;
  --text:        #e2e8f0;
  --text-dim:    #94a3b8;
  --text-muted:  #475569;
  --font:        'Inter', sans-serif;
  --mono:        'JetBrains Mono', monospace;
  --r:           14px;
  --r-sm:        8px;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

.hidden { display: none !important; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 22px; height: 56px;
  background: rgba(6,8,16,0.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.header-left  { display: flex; align-items: center; gap: 14px; }
.header-right { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }

.wordmark {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; font-weight: 700; letter-spacing: 0.14em;
  color: var(--accent); text-decoration: none; flex-shrink: 0;
}
.wordmark svg { width: 16px; height: 16px; flex-shrink: 0; }
.wordmark:hover { opacity: 0.85; }

/* Status orbs */
.status-orbs {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 10px;
}
.orb {
  display: block; width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0; cursor: default; transition: box-shadow 0.3s;
}
.orb.green { background: var(--green); box-shadow: 0 0 6px rgba(16,185,129,0.55); }
.orb.amber { background: var(--accent); box-shadow: 0 0 6px rgba(245,158,11,0.55); }
.orb.red   { background: var(--red);   box-shadow: 0 0 6px rgba(239,68,68,0.55); animation: blink 1.5s infinite; }
.orb.grey  { background: var(--text-muted); }
.orb-sep   { width: 1px; height: 10px; background: var(--border); flex-shrink: 0; }

/* P&L center */
.header-pnl {
  display: flex; align-items: baseline; gap: 10px; justify-content: center;
}
.hdr-portfolio {
  font-family: var(--mono); font-size: 1.3rem; font-weight: 600;
  color: var(--text); letter-spacing: -0.02em;
}
.hdr-delta {
  font-family: var(--mono); font-size: 0.78rem; font-weight: 500;
  padding: 2px 9px; border-radius: 6px; white-space: nowrap;
}
.hdr-delta.pos  { color: var(--green); background: var(--green-dim); border: 1px solid var(--green-line); }
.hdr-delta.neg  { color: var(--red);   background: var(--red-dim);   border: 1px solid var(--red-line); }
.hdr-delta.zero { color: var(--text-muted); background: var(--surface2); border: 1px solid var(--border); }

/* Stream indicator */
.stream-indicator { display: flex; align-items: center; gap: 6px; }
.stream-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 5px rgba(16,185,129,0.5);
  animation: breathe 2.5s ease-in-out infinite;
}
.stream-dot.dead { background: var(--text-muted); box-shadow: none; animation: none; }
.stream-time { font-family: var(--mono); font-size: 0.65rem; color: var(--text-muted); }

/* Kill switch */
.kill-btn {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 0.65rem; font-weight: 600; letter-spacing: 0.08em;
  padding: 5px 10px; border-radius: 6px; border: 1px solid; cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  background: none;
}
.kill-btn.active {
  color: var(--green); border-color: var(--green-line); background: var(--green-dim);
}
.kill-btn.halted {
  color: var(--red); border-color: var(--red-line); background: var(--red-dim);
  animation: blink 1.8s infinite;
}
.kill-btn:disabled { opacity: 0.5; cursor: wait; animation: none; }
.kill-dot {
  width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; background: currentColor;
}

.logout-btn {
  color: var(--text-muted); text-decoration: none; font-size: 0.85rem;
  padding: 4px 8px; border-radius: 6px; transition: color 0.2s;
}
.logout-btn:hover { color: var(--red); }

/* ── Page ────────────────────────────────────────────────────────────────── */
.page {
  max-width: 1060px; margin: 0 auto;
  padding: 28px 20px 60px;
  display: flex; flex-direction: column; gap: 24px;
}

.section-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.section-title {
  font-size: 0.63rem; font-weight: 700; letter-spacing: 0.15em;
  color: var(--text-muted); text-transform: uppercase;
}
.section-meta { font-family: var(--mono); font-size: 0.62rem; color: var(--text-muted); }

/* ── Active Mission ──────────────────────────────────────────────────────── */
.mission-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden;
}

/* Waiting state */
.mission-waiting {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 52px 24px; gap: 14px;
}
.waiting-icon { font-size: 1.6rem; opacity: 0.2; }
.waiting-text { font-size: 0.84rem; color: var(--text-muted); }
.waiting-pulse {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 0.68rem; color: var(--text-muted);
  background: var(--surface2); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 20px;
}
.pulse-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); animation: breathe 1.8s ease-in-out infinite;
}

/* Active state */
.mission-inner { padding: 22px 24px; }

.mission-name {
  font-size: 1.55rem; font-weight: 700; color: var(--text);
  letter-spacing: -0.025em; line-height: 1.15; margin-bottom: 10px;
}

.mission-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.m-tag {
  font-size: 0.63rem; font-weight: 600; padding: 3px 9px;
  border-radius: 20px; letter-spacing: 0.04em; white-space: nowrap;
}
.m-tag-agent { background: var(--surface3); color: var(--text-dim); border: 1px solid var(--border); }
.m-tag-paper { background: var(--blue-dim,rgba(59,130,246,0.10)); color: var(--blue); border: 1px solid rgba(59,130,246,0.22); }
.m-tag-live  { background: var(--green-dim); color: var(--green); border: 1px solid var(--green-line); letter-spacing: 0.08em; }
.m-tag-since { background: transparent; color: var(--text-muted); border: none; padding-left: 0; font-size: 0.65rem; font-family: var(--mono); }

.mission-reasoning {
  padding: 13px 16px; margin-bottom: 20px;
  background: var(--surface2); border-left: 2px solid var(--accent);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 0.82rem; color: var(--text-dim); line-height: 1.65; font-style: italic;
}

.mission-kpis {
  display: grid; grid-template-columns: repeat(4,1fr);
  border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden;
}
.kpi {
  padding: 14px 18px; display: flex; flex-direction: column; gap: 3px;
  border-right: 1px solid var(--border);
}
.kpi:last-child { border-right: none; }
.kpi-label { font-size: 0.6rem; font-weight: 600; letter-spacing: 0.09em; color: var(--text-muted); text-transform: uppercase; }
.kpi-value {
  font-family: var(--mono); font-size: 1.18rem; font-weight: 600;
  color: var(--text); letter-spacing: -0.01em; line-height: 1.15;
}
.kpi-value.pos { color: var(--green); }
.kpi-value.neg { color: var(--red); }
.kpi-sub { font-family: var(--mono); font-size: 0.68rem; color: var(--text-muted); }
.kpi-sub.pos { color: var(--green); opacity: 0.85; }
.kpi-sub.neg { color: var(--red);   opacity: 0.85; }

/* ── Research Dispatch ───────────────────────────────────────────────────── */
.research-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden;
}
.research-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.research-header-left { display: flex; align-items: center; gap: 10px; }
.research-label { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.09em; color: var(--text-dim); }
.research-badge {
  font-size: 0.6rem; font-family: var(--mono);
  color: var(--purple); background: rgba(139,92,246,0.10);
  border: 1px solid rgba(139,92,246,0.22);
  padding: 2px 7px; border-radius: 4px;
}

/* AI Briefing */
.briefing-box {
  margin: 16px 20px 8px;
  padding: 15px 18px;
  background: var(--accent-dim); border: 1px solid var(--accent-line);
  border-radius: var(--r-sm);
  animation: fadeUp 0.3s ease;
}
.briefing-top {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.briefing-label { font-size: 0.63rem; font-weight: 700; letter-spacing: 0.1em; color: var(--accent); }
.briefing-gen   { font-family: var(--mono); font-size: 0.6rem; color: var(--text-muted); }
.briefing-body  { font-size: 0.79rem; color: var(--text-dim); line-height: 1.65; }
.briefing-body strong {
  color: var(--accent); font-weight: 600;
  display: block; margin-top: 8px; margin-bottom: 2px;
}
.briefing-body strong:first-child { margin-top: 0; }
.briefing-body ul { margin-left: 15px; }
.briefing-body li { margin: 3px 0; }

/* Relevance legend */
.relevance-legend {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 20px 6px; justify-content: flex-end;
}
.rl-label { font-size: 0.58rem; color: var(--text-muted); font-family: var(--mono); }
.rl-item  { display: flex; align-items: center; gap: 4px; font-size: 0.58rem; color: var(--text-muted); font-family: var(--mono); }
.rl-dot   { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* Research items */
.research-list { padding: 2px 0 4px; }

.research-empty {
  padding: 36px 20px; text-align: center;
  font-size: 0.78rem; color: var(--text-muted); font-style: italic;
}

.ri {
  display: grid;
  grid-template-columns: 82px 1fr 52px 52px;
  align-items: start; gap: 12px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.13s;
  animation: fadeUp 0.25s ease;
}
.ri:last-child { border-bottom: none; }
.ri:hover { background: var(--surface2); }

.ri-badge {
  font-size: 0.57rem; font-weight: 700; letter-spacing: 0.07em;
  padding: 3px 7px; border-radius: 4px; text-transform: uppercase;
  white-space: nowrap; text-align: center; margin-top: 2px;
}
.ri-badge.academic { background: rgba(236,72,153,0.14); color: #f472b6; border: 1px solid rgba(236,72,153,0.20); }
.ri-badge.market   { background: rgba(16,185,129,0.14);  color: #34d399; border: 1px solid rgba(16,185,129,0.20); }
.ri-badge.onchain  { background: rgba(245,158,11,0.14);  color: #fbbf24; border: 1px solid rgba(245,158,11,0.20); }
.ri-badge.web      { background: rgba(14,165,233,0.14);  color: #38bdf8; border: 1px solid rgba(14,165,233,0.20); }
.ri-badge.dex      { background: rgba(59,130,246,0.14);  color: #60a5fa; border: 1px solid rgba(59,130,246,0.20); }
.ri-badge.research { background: rgba(139,92,246,0.14);  color: #c4b5fd; border: 1px solid rgba(139,92,246,0.20); }

.ri-body   { min-width: 0; }
.ri-title  { font-size: 0.81rem; color: var(--text); line-height: 1.35; font-weight: 500; }
.ri-action {
  display: flex; align-items: flex-start; gap: 4px;
  margin-top: 4px; font-size: 0.7rem; color: var(--green); font-weight: 500; line-height: 1.3;
}
.ri-action::before { content: '→'; opacity: 0.7; flex-shrink: 0; }

.ri-score { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; padding-top: 3px; }
.ri-score-num { font-family: var(--mono); font-size: 0.68rem; font-weight: 600; }
.ri-score-num.high { color: var(--green); }
.ri-score-num.mid  { color: var(--accent); }
.ri-score-num.low  { color: var(--text-muted); }
.ri-score-bar  { width: 36px; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.ri-score-fill { height: 100%; border-radius: 2px; }
.ri-score-fill.high { background: var(--green); }
.ri-score-fill.mid  { background: var(--accent); }
.ri-score-fill.low  { background: var(--text-muted); }

.ri-time { font-family: var(--mono); font-size: 0.62rem; color: var(--text-muted); padding-top: 4px; text-align: right; white-space: nowrap; }

/* ── Animations ──────────────────────────────────────────────────────────── */
@keyframes breathe { 0%,100%{opacity:1} 50%{opacity:0.4} }
@keyframes blink   { 0%,100%{opacity:1} 50%{opacity:0.25} }
@keyframes fadeUp  { from{opacity:0;transform:translateY(5px)} to{opacity:1;transform:none} }
