@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&family=DM+Mono:wght@400;500&display=swap');

:root {
  /* Core Palette */
  --black:       #080808;
  --void:        #050505;
  --surface-1:   #0e0e0f;
  --surface-2:   #131315;
  --surface-3:   #1a1a1d;
  --surface-4:   #222226;
  --border-1:    #2a2a2e;
  --border-2:    #333338;
  --border-3:    #424248;

  /* Text */
  --text-1:      #f2f0eb;
  --text-2:      #b8b4aa;
  --text-3:      #706c64;

  /* Accents */
  --gold:        #c9a84c;
  --gold-bright: #e8c46a;
  --gold-dim:    #8a6e2a;
  --gold-glow:   rgba(201,168,76,0.12);
  --gold-glow-2: rgba(201,168,76,0.06);

  /* Status */
  --green:       #2dbd78;
  --green-dim:   #1a3d2e;
  --red:         #e05252;
  --red-dim:     #3d1e1e;
  --amber:       #e8a030;
  --amber-dim:   #3d2c10;
  --blue-deep:   #1a3a7a;
  --blue-light:  #7eb8f5;
  --blue-pale:   #d8eaff;
  --yellow-pale: #fef9e0;

  /* Gradients */
  --grad-bg: radial-gradient(ellipse 120% 80% at 10% 0%, #141412 0%, #0a0a0b 55%, #070708 100%);
  --grad-panel: linear-gradient(160deg, #161618 0%, #0f0f11 100%);
  --grad-panel-hover: linear-gradient(160deg, #1c1c1f 0%, #141417 100%);
  --grad-gold: linear-gradient(135deg, var(--gold) 0%, #b8902e 100%);
  --grad-gold-text: linear-gradient(135deg, var(--gold-bright) 0%, var(--gold) 60%);

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.5);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.5);
  --shadow-gold: 0 0 20px rgba(201,168,76,0.15);

  /* Layout */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Type Scale */
  --text-xs:  0.72rem;
  --text-sm:  0.84rem;
  --text-md:  0.96rem;
  --text-lg:  1.14rem;
  --text-xl:  1.32rem;
  --text-2xl: clamp(1.5rem, 2vw, 1.9rem);
}

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

html {
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--grad-bg);
  background-attachment: fixed;
  color: var(--text-1);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(circle 600px at 80% 20%, rgba(201,168,76,0.03) 0%, transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23noise)' opacity='0.025'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

h1, h2, h3, h4 { letter-spacing: -0.02em; font-weight: 600; }

h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  font-size: var(--text-2xl);
  color: var(--text-1);
}

h2 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-1);
}

h3 {
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--text-1);
}

p { color: var(--text-2); }

/* ─── Topbar ─────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem clamp(1.2rem, 3vw, 2.4rem);
  background: rgba(8,8,8,0.92);
  backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border-1);
  box-shadow: 0 1px 0 rgba(201,168,76,0.06), var(--shadow-md);
}

.topbar-left { display: flex; flex-direction: column; gap: 0.15rem; }

.topbar-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--text-xs);
  font-family: 'DM Mono', monospace;
  color: var(--text-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-eyebrow::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse-dot 2.4s ease infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.topbar h1 { line-height: 1; }
.topbar h1 .version {
  font-family: 'DM Mono', monospace;
  font-size: var(--text-sm);
  color: var(--gold);
  font-weight: 400;
  margin-left: 0.5rem;
  letter-spacing: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ─── Status Legend ──────────────────────────────── */
.header-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem clamp(1.2rem, 3vw, 2.4rem);
  background: rgba(10,10,10,0.7);
  border-bottom: 1px solid var(--border-1);
  position: relative;
  z-index: 10;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  font-size: var(--text-xs);
  font-family: 'DM Mono', monospace;
  color: var(--text-3);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border-1);
  background: var(--surface-2);
  letter-spacing: 0.04em;
}

.legend-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.legend-dot.goal-on  { background: var(--green); box-shadow: 0 0 4px var(--green); }
.legend-dot.goal-off { background: var(--red); box-shadow: 0 0 4px var(--red); }
.legend-dot.warn     { background: var(--gold); box-shadow: 0 0 4px var(--gold); }
.legend-dot.p1       { background: #3b6fd4; box-shadow: 0 0 4px #3b6fd4; }

/* ─── Tab Navigation ─────────────────────────────── */
.tabs {
  display: flex;
  gap: 0.4rem;
  padding: 1rem clamp(1.2rem, 3vw, 2.4rem);
  background: rgba(8,8,8,0.6);
  border-bottom: 1px solid var(--border-1);
  position: sticky;
  top: 72px;
  z-index: 90;
  backdrop-filter: blur(12px);
}

.tab-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.01em;
  position: relative;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-2);
  background: var(--surface-3);
}

.tab-btn.active {
  color: var(--gold-bright);
  background: var(--gold-glow);
  border: 1px solid var(--gold-dim);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 1px;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
}

/* ─── Layout ─────────────────────────────────────── */
.layout {
  padding: 1.6rem clamp(1.2rem, 3vw, 2.4rem) 3rem;
  position: relative;
  z-index: 1;
}

.tab-view { display: none; }
.tab-view.active {
  display: grid;
  gap: 1.2rem;
  animation: fade-in 0.3s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Panels ─────────────────────────────────────── */
.panel {
  background: var(--grad-panel);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  box-shadow: var(--shadow-md);
  transition: border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(201,168,76,0.2) 50%, transparent 100%);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-1);
}

.panel-head h2 { font-size: var(--text-md); font-weight: 600; }
.panel-head .muted { font-size: var(--text-xs); color: var(--text-3); margin-top: 0.2rem; }

/* ─── Exec Grid ──────────────────────────────────── */
.exec-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, 1fr);
}

/* ─── KPI Grid ───────────────────────────────────── */
.kpi-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.kpi-card {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  padding: 1rem;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}

.kpi-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.kpi-card.good::after  { background: var(--green); box-shadow: 0 0 8px var(--green); }
.kpi-card.warn::after  { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.kpi-card.urgent::after { background: var(--red); box-shadow: 0 0 8px var(--red); }

.kpi-card:hover { border-color: var(--border-3); transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.kpi-label {
  font-size: var(--text-xs);
  color: var(--text-3);
  font-family: 'DM Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-top: 0.2rem;
}

/* ─── CEO Strip ──────────────────────────────────── */
.ceo-strip, .risk-grid, .capacity-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.risk-item {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  padding: 1rem;
  min-height: 100px;
}

.risk-item.urgent {
  border-color: rgba(224, 82, 82, 0.4);
  background: linear-gradient(160deg, rgba(61,30,30,0.5), var(--surface-2));
}

.risk-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-1);
  margin: 0.4rem 0;
}

/* ─── Two Column ─────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.subpanel {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.subpanel h3 {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-1);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: 'DM Mono', monospace;
  font-size: var(--text-xs);
}

/* ─── Tables ─────────────────────────────────────── */
.table-wrap {
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-1);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  min-width: 520px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-1);
  color: var(--text-3);
  padding: 0.65rem 0.75rem;
  font-family: 'DM Mono', monospace;
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border-2);
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-1);
  color: var(--text-2);
  vertical-align: top;
}

tbody tr { transition: background 0.15s ease; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }
tbody tr:last-child td { border-bottom: none; }

/* ─── Dependency ─────────────────────────────────── */
.dependency-list { display: grid; gap: 0.75rem; }

.dependency-chain {
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  background: var(--surface-2);
}

.dependency-path {
  color: var(--text-2);
  font-size: var(--text-sm);
  margin-top: 0.3rem;
  font-family: 'DM Mono', monospace;
  font-size: var(--text-xs);
}

/* ─── Capacity Meter ─────────────────────────────── */
.capacity-item {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  padding: 0.9rem;
}

.meter {
  width: 100%;
  height: 6px;
  background: var(--surface-4);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.meter > span {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: 999px;
  transition: width 0.6s ease;
}

.meter.warn > span  { background: var(--gold); }
.meter.urgent > span { background: var(--red); }

/* ─── Stat List ──────────────────────────────────── */
.stat-list { display: grid; gap: 0.5rem; }

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-1);
  font-size: var(--text-sm);
}

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

/* ─── Domain Grid ────────────────────────────────── */
.domain-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.domain-card {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  padding: 1rem;
  cursor: pointer;
  min-height: 120px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.domain-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--grad-gold);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.domain-card:hover {
  border-color: var(--border-3);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  background: var(--grad-panel-hover);
}

.domain-card:hover::before { opacity: 1; }
.domain-card:active { transform: translateY(0); }

.health.good   { color: var(--green); }
.health.warn   { color: var(--gold); }
.health.urgent { color: var(--red); }

/* ─── Tags ───────────────────────────────────────── */
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.tag {
  border: 1px solid var(--border-2);
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  font-size: var(--text-xs);
  color: var(--text-3);
  background: var(--surface-2);
  transition: all 0.15s ease;
}

.tag:hover { border-color: var(--border-3); color: var(--text-2); }

/* ─── Usage Panel ────────────────────────────────── */
.usage-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  align-items: end;
}

label {
  font-size: var(--text-xs);
  color: var(--text-3);
  font-family: 'DM Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: grid;
  gap: 0.4rem;
}

input {
  min-height: 40px;
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  color: var(--text-1);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: var(--text-md);
  font-family: 'DM Mono', monospace;
  transition: border-color 0.2s ease;
}

input:focus {
  outline: none;
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

/* ─── Buttons ────────────────────────────────────── */
.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-weight: 500;
  font-size: var(--text-sm);
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s ease;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--border-3);
  color: var(--text-1);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active { transform: translateY(0); }

.btn.primary {
  background: linear-gradient(160deg, #2a2010 0%, #1c1708 100%);
  border-color: var(--gold-dim);
  color: var(--gold-bright);
}

.btn.primary:hover {
  background: linear-gradient(160deg, #342810 0%, #241e0a 100%);
  border-color: var(--gold);
  box-shadow: var(--shadow-gold);
}

.btn.secondary {
  background: linear-gradient(160deg, #1a2540 0%, #131d33 100%);
  border-color: #2a4070;
  color: var(--blue-pale);
}

.btn.ghost {
  background: transparent;
  border-color: var(--border-2);
  color: var(--text-3);
}

/* ─── Chips ──────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: var(--text-xs);
  font-family: 'DM Mono', monospace;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}

.chip.good   { color: var(--green); border-color: #1d5c3e; background: var(--green-dim); }
.chip.warn   { color: var(--gold); border-color: var(--gold-dim); background: var(--amber-dim); }
.chip.urgent { color: #ffb0b0; border-color: #6e2424; background: var(--red-dim); }
.chip.p1     { color: var(--blue-pale); border-color: var(--blue-deep); background: rgba(26,58,122,0.3); }
.chip.p2     { color: #3a78c9; border-color: #7baee3; background: #d4e8ff; }
.chip.p3     { color: #7a6010; border-color: #c8b044; background: var(--yellow-pale); }

/* ─── Status Colors ──────────────────────────────── */
.good   { color: var(--green); }
.warn   { color: var(--gold); }
.urgent { color: var(--red); }
.muted  { color: var(--text-2); font-size: var(--text-sm); }

/* ─── Domain Detail ──────────────────────────────── */
.domain-detail { display: none; }
.domain-detail.open { display: block; }
.detail-content { display: grid; gap: 1rem; }
.detail-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }

.nfl-summary-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.nfl-guardrails { display: grid; gap: 0.5rem; }
.bankroll-kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 0.75rem; }

.bankroll-chart-wrap {
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  padding: 0.75rem;
}

.bankroll-chart { width: 100%; height: 220px; display: block; }
.chart-axis { stroke: var(--border-3); stroke-width: 1; }
.chart-line { fill: none; stroke: var(--gold); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.bankroll-chart-labels {
  margin-top: 0.4rem;
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  font-family: 'DM Mono', monospace;
  color: var(--text-3);
}

/* ─── Weekly Commitments ─────────────────────────── */
#weeklyCommitments { display: grid; gap: 0.5rem; }

/* ─── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-3); }

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1000px) {
  .exec-grid, .two-col, .domain-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .usage-fields { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 680px) {
  .topbar, .tabs { position: static; }
  .exec-grid, .two-col, .kpi-grid, .domain-grid, .detail-kpis, .usage-fields { grid-template-columns: 1fr; }
  .tabs { flex-wrap: wrap; gap: 0.3rem; }
  .tab-btn { min-height: 40px; }
}
