:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #475569;
  --subtle: #64748b;
  --navy: #1b4f72;
  --purple: #6d28d9;
  --green: #059669;
  --green-bg: #ecfdf5;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.04);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: "JetBrains Mono", monospace; }

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--navy), var(--purple));
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.brand-text { display: flex; flex-direction: column; }
.brand-title { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11.5px; color: var(--subtle); }

.nav { display: flex; align-items: center; gap: 22px; }
.nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: color 0.15s;
}
.nav a:hover { color: var(--navy); }
.nav a.nav-ext {
  padding: 6px 11px;
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--navy);
  font-weight: 600;
}
.nav a.nav-ext:hover { background: #e2e8f0; }

/* Hero */
.hero {
  padding: 36px 0 24px;
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--purple);
  margin-bottom: 6px;
}

h1 {
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: 10px;
}

.v2-pill {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(109, 40, 217, 0.1);
  color: var(--purple);
  vertical-align: middle;
  margin-left: 4px;
}

.hero-lead {
  max-width: 720px;
  color: var(--muted);
  font-size: 15.5px;
}

.meta-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 18px;
  min-width: 215px;
  box-shadow: var(--shadow);
}
.meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--subtle); font-weight: 600; }
.meta-value { font-size: 16px; font-weight: 700; margin: 2px 0; color: var(--text); }
.meta-note { font-size: 11.5px; color: var(--subtle); }

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.kpi-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--subtle);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 6px;
}

.kpi-regime-title {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 8px;
}

.kpi-foot { font-size: 12px; color: var(--subtle); }

/* Badges */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.03em;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-blue  { background: var(--blue-bg); color: var(--blue); }
.badge-red   { background: var(--red-bg); color: var(--red); }
.badge-slate { background: var(--surface-alt); color: var(--muted); }

/* Sections & Cards */
.section { padding: 34px 0; }
.section-alt { background: #ffffff; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

.section-head { margin-bottom: 20px; }
.section-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 6px; }
.section-head p { color: var(--muted); font-size: 14.5px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.chart-card { padding: 22px 24px 18px; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-header h2 { font-size: 19px; font-weight: 750; letter-spacing: -0.015em; margin-bottom: 4px; }
.card-sub { font-size: 13.5px; color: var(--muted); }

/* Range Buttons */
.range-group {
  display: inline-flex;
  background: var(--surface-alt);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--border);
  gap: 2px;
}

.range-btn {
  border: none;
  background: transparent;
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.range-btn:hover { color: var(--text); }
.range-btn.active {
  background: #ffffff;
  color: var(--navy);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

/* Quadrant Layout */
.quad-layout {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 20px;
  align-items: stretch;
}

.chart-quadrant { width: 100%; height: 470px; }
.chart-timeseries { width: 100%; height: 690px; }

.chart-legend-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--surface-alt);
  font-size: 12px;
  color: var(--muted);
}
.chart-legend-bar .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.legend-hint { margin-left: auto; color: var(--subtle); font-style: italic; }

/* Side Recent Trajectory Card */
.trail-side-card {
  padding: 20px 20px 18px;
  display: flex;
  flex-direction: column;
}
.side-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.side-header h3 { font-size: 16px; font-weight: 700; }
.mono-pill {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
}
.side-sub { font-size: 12.5px; color: var(--subtle); margin-bottom: 12px; }

.trail-table-wrap { flex: 1; overflow-x: auto; }
.trail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.trail-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--subtle);
  padding: 7px 6px;
  border-bottom: 1px solid var(--border);
}
.trail-table td {
  padding: 7px 6px;
  border-bottom: 1px solid var(--surface-alt);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
}
.trail-table tr:first-child td { font-weight: 700; background: #f8fafc; }

.direction-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.45;
}

/* Matrix Table */
.matrix-card { padding: 8px 14px; }
.table-scroll { overflow-x: auto; }
.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.matrix-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--subtle);
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
}
.matrix-table td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--surface-alt);
}
.matrix-table tr:last-child td { border-bottom: none; }
.matrix-table tr.active-regime {
  background: rgba(109, 40, 217, 0.06);
  outline: 1.5px solid rgba(109, 40, 217, 0.35);
}
.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--red); font-weight: 600; }

/* Methodology */
.method-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.method-card { padding: 24px; }
.method-card h3 { font-size: 17px; font-weight: 750; margin: 10px 0 10px; }
.method-card p { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.method-card p:last-child { margin-bottom: 0; }
.method-card code {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  background: var(--surface-alt);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text);
}

.method-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: 999px;
}
.tag-purple { background: rgba(109, 40, 217, 0.1); color: var(--purple); }
.tag-blue   { background: rgba(27, 79, 114, 0.1); color: var(--navy); }

/* Footer */
.footer {
  padding: 26px 0;
  font-size: 12.5px;
  color: var(--subtle);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.footer-links { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.footer-links a { color: var(--navy); text-decoration: none; font-weight: 600; }

/* Responsive */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .quad-layout { grid-template-columns: 1fr; }
  .method-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .nav { display: none; }
  .chart-quadrant { height: 390px; }
  .chart-timeseries { height: 600px; }
}
