/* Mugen Dashboard — Minimal modern dark theme */

:root {
  --bg:           #0a0a0b;
  --card-bg:      #141416;
  --card-border:  #1e1e22;
  --text:         #e0e0e0;
  --text-muted:   #6b6b76;
  --accent:       #6b8afd;
  --success:      #4ade80;
  --warning:      #fbbf24;
  --error:        #f87171;
  --crash:        #f87171;
  --range:        #6b8afd;
  --trend:        #4ade80;
  --radius:       16px;
  --radius-sm:    8px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  padding: 28px 32px;
  width: 100%;
}

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

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

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

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

header h1 {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

header h1 .kanji {
  color: var(--text-muted);
  font-weight: 400;
}

.last-refresh {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Regime badge ───────────────────────────────────────────────────────── */

.regime-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(107,139,253,0.12);
  color: var(--accent);
}

.regime-crash { background: rgba(241,87,71,0.12); color: var(--crash); }
.regime-range  { background: rgba(107,139,253,0.12); color: var(--range); }
.regime-trend  { background: rgba(74,222,128,0.12); color: var(--trend); }

/* ── Pipeline phase chip (header) ──────────────────────────────────────── */

.pipeline-phase-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: rgba(107,139,253,0.1);
  color: var(--accent);
  text-transform: uppercase;
}

.pipeline-phase-chip.running {
  background: rgba(74,222,128,0.1);
  color: var(--success);
}

.pipeline-phase-chip.idle {
  background: rgba(107,107,118,0.12);
  color: var(--text-muted);
}

/* ── 9-panel grid ───────────────────────────────────────────────────────── */

.grid-9 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  align-items: stretch;
}

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

@media (max-width: 800px) {
  .grid-9 { grid-template-columns: 1fr; }
  body { padding: 16px; }
  header { flex-direction: column; align-items: flex-start; gap: 12px; }
}

/* ── Cards ──────────────────────────────────────────────────────────────── */

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0; /* prevent grid blowout */
}

.card > *:last-child {
  flex: 1;
  min-height: 0;
}

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

.card h2 {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ── Pulse dot ──────────────────────────────────────────────────────────── */

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
}

.pulse-dot.active {
  background: var(--success);
  animation: pulse-anim 2.5s ease-in-out infinite;
}

.pulse-dot.success-solid { background: var(--success); }
.pulse-dot.error         { background: var(--error); }

@keyframes pulse-anim {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

/* ── Empty / pending ────────────────────────────────────────────────────── */

.empty-msg {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 8px 0;
}

/* ── Data keys (DOM diffed) ─────────────────────────────────────────────── */

[data-key] {
  font-variant-numeric: tabular-nums;
  transition: opacity 0.3s, color 0.3s;
}

/* ── Stat blocks ────────────────────────────────────────────────────────── */

.stats-row {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Progress bar ───────────────────────────────────────────────────────── */

.progress-wrap {
  background: var(--card-border);
  border-radius: 4px;
  height: 5px;
  overflow: hidden;
  margin: 6px 0 14px;
}

.progress-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
  background: var(--accent);
}

.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.error   { background: var(--error); }

/* ── Tables ─────────────────────────────────────────────────────────────── */

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

/* Long panels — cap height so the card doesn't grow unbounded */
#proximity-body,
#portfolio-body,
#pipeline-history-body {
  max-height: 340px;
  overflow-y: auto;
  overflow-x: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 5px 8px 8px;
}

td {
  padding: 7px 8px;
  font-variant-numeric: tabular-nums;
  border-top: 1px solid var(--card-border);
}

tr:first-child td { border-top: none; }

.mono {
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
}

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

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-pass    { background: rgba(74,222,128,0.12); color: var(--success); }
.badge-fail    { background: rgba(248,113,113,0.12); color: var(--error); }
.badge-running { background: rgba(107,139,253,0.12); color: var(--accent); }
.badge-pending { background: rgba(107,107,118,0.1); color: var(--text-muted); }
.badge-warn    { background: rgba(251,191,36,0.12); color: var(--warning); }

/* ── Team colors ────────────────────────────────────────────────────────── */

.team-crash { color: var(--crash); font-size: 0.7rem; font-weight: 600; }
.team-range { color: var(--range); font-size: 0.7rem; font-weight: 600; }
.team-trend { color: var(--trend); font-size: 0.7rem; font-weight: 600; }

/* ── Factor / DD bars ───────────────────────────────────────────────────── */

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.bar-label {
  width: 60px;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
  flex-shrink: 0;
}

.bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--card-border);
  border-radius: 3px;
  overflow: hidden;
}

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

.bar-count {
  width: 24px;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
  flex-shrink: 0;
}

/* ── Exposure / leverage mini chart ─────────────────────────────────────── */

.mini-chart {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 36px;
  margin-top: 8px;
}

.mini-bar {
  flex: 1;
  border-radius: 2px 2px 0 0;
  min-width: 3px;
}

/* ── Phase timeline (pipeline) ──────────────────────────────────────────── */

.phase-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.phase-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
}

@keyframes phase-appear {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.phase-item.just-completed {
  animation: phase-appear 0.3s ease-out;
}

.phase-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--card-border);
  flex-shrink: 0;
}

.phase-dot.done    { background: var(--success); }
.phase-dot.active  { background: var(--accent); animation: pulse-anim 1.5s infinite; }
.phase-dot.pending { background: var(--card-border); }

/* ── Signal proximity ───────────────────────────────────────────────────── */

.near-firing td { color: var(--warning); }

/* ── Health grid ─────────────────────────────────────────────────────────── */

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

.health-item {
  background: rgba(30,30,34,0.6);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.health-item .label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.health-item .value {
  font-size: 0.9rem;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

/* ── Research grid ──────────────────────────────────────────────────────── */

.research-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.research-item {
  background: rgba(30,30,34,0.6);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.research-item .label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.research-item .value {
  font-size: 0.9rem;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

/* ── Section label ──────────────────────────────────────────────────────── */

.section-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 12px 0 6px;
}

/* Small muted title above each chart */
.chart-section-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  margin: 10px 0 2px;
  opacity: 0.65;
}

/* ── MC Projection chart elements ───────────────────────────────────────── */

.projection-band {
  /* SVG fill is set inline with rgba; this class is for JS selection */
  pointer-events: none;
}

.projection-line-realistic {
  /* solid muted purple, set inline */
  pointer-events: none;
}

.projection-line-optimistic {
  /* dashed muted green, set inline */
  pointer-events: none;
}

.chart-divider {
  /* vertical "Now" separator, set inline */
  pointer-events: none;
}

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

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  margin-bottom: 4px;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-line {
  width: 18px;
  height: 2px;
  border-radius: 1px;
  flex-shrink: 0;
}

.legend-line.legend-dashed {
  background: none !important;
  border-top: 2px dashed #34d399;
}

.legend-band {
  width: 14px;
  height: 10px;
  background: rgba(167,139,250,0.25);
  border-radius: 2px;
  flex-shrink: 0;
}
