/* ================================================================
   MACRO REGIME — Clean Trust Design System
   ================================================================ */

:root {
  /* Brand */
  --navy: #1B2A4A;
  --navy-hover: #243459;
  --navy-pale: rgba(27, 42, 74, 0.05);
  --teal: #0D5E4C;
  --accent-green: #22C55E;

  /* Regime colors */
  --risk-on: #0D5E4C;
  --risk-on-bg: #F0FDF4;
  --neutral: #F59E0B;
  --neutral-bg: #FFFBEB;
  --risk-off: #FF6B6B;
  --risk-off-bg: #FEE2E2;

  /* Surfaces */
  --bg: #FAFBFC;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;

  /* Text */
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;
  --text-on-navy: #FFFFFF;
  --text-on-navy-muted: rgba(255, 255, 255, 0.6);

  /* Typography */
  --font-sans: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.08);

  /* Radii */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  color: var(--text-secondary);
  font-size: 15px;
  letter-spacing: 0.02em;
}

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--navy);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.topbar-logo {
  font-family: var(--font-sans);
  font-size: 20px;
  font-weight: 400;
  color: var(--text-on-navy);
  text-decoration: none;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.topbar-logo strong {
  font-weight: 700;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-on-navy-muted);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  border: none;
  background: none;
}
.topbar-nav-link:hover {
  color: var(--text-on-navy);
  background: rgba(255, 255, 255, 0.08);
}
.topbar-nav-link.active {
  color: var(--text-on-navy);
}
.topbar-nav-link .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transition: background 0.15s;
}
.topbar-nav-link.active .dot {
  background: var(--accent-green);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.topbar-cta {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-on-navy-muted);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  font-family: var(--font-sans);
}
.topbar-cta:hover {
  color: var(--text-on-navy);
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.06);
}

.topbar-asof {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-on-navy-muted);
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  white-space: nowrap;
}

/* ── View container ── */
.view {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* ── Hero (Overview) ── */
.hero {
  text-align: center;
  padding: 24px 0 0;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}

.hero-score {
  font-family: var(--font-mono);
  font-size: 120px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}
.hero-score.risk_on { color: var(--risk-on); }
.hero-score.neutral { color: var(--neutral); }
.hero-score.risk_off { color: var(--risk-off); }

.hero-label {
  font-size: 16px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* Regime bar */
.regime-bar-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}
.regime-bar-container {
  position: relative;
  width: 320px;
}
.regime-bar {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right,
    var(--risk-off) 0%, var(--neutral) 40%,
    var(--neutral) 60%, var(--risk-on) 100%);
}
.regime-bar-pointer {
  position: absolute;
  top: 12px;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 6px solid var(--navy);
}

/* Delta chips */
.delta-chips {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}
.delta-chip {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 4px;
  background: var(--navy-pale);
}
.delta-chip .label {
  color: var(--text-tertiary);
  font-size: 11px;
  margin-right: 4px;
}
.delta-chip .value.positive { color: var(--risk-on); }
.delta-chip .value.negative { color: var(--risk-off); }
.delta-chip .value.flat { color: var(--text-secondary); }

/* Divider */
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0 auto 40px;
  max-width: 200px;
}

/* Overlay section */
.overlay-section {
  text-align: center;
  margin-bottom: 48px;
}
.overlay-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.overlay-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 4px;
}
.overlay-status {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.overlay-caption {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Micro-narrative card */
.narrative-card {
  background: var(--navy-pale);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 48px;
  border: 1px solid var(--border);
}
.narrative-card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}
.narrative-card p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-primary);
}

/* Operating lines grid */
.op-lines-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  margin-bottom: 16px;
  text-align: center;
}
.op-lines-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.op-line-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.op-line-card-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.op-line-card-value {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
}

/* ── Historical View ── */
.view-header {
  margin-bottom: 32px;
}
.view-header h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}
.view-header p {
  font-size: 14px;
  color: var(--text-secondary);
}

.horizon-slider {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.horizon-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.horizon-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.horizon-btn.active {
  background: var(--navy);
  color: var(--text-on-navy);
  border-color: var(--navy);
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  display: none;
}
.breadcrumb.visible { display: block; }
.breadcrumb a {
  color: var(--teal);
  text-decoration: none;
  cursor: pointer;
}
.breadcrumb a:hover { text-decoration: underline; }

.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  min-height: 400px;
}
.chart-container .loading-chart {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 380px;
  color: var(--text-tertiary);
  font-size: 13px;
}

.chart-stats {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 32px;
  text-align: center;
}

/* Blocks grid */
.blocks-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.block-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}
.block-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
.block-card.selected {
  border-color: var(--navy);
  box-shadow: 0 0 0 1px var(--navy);
}
.block-card-name {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.block-card-score {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 6px;
}
.block-card-sparkline {
  margin-bottom: 6px;
  line-height: 0;
}
.block-card-status {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Sparkline SVG */
.sparkline { display: block; }
.sparkline.risk_on { color: var(--risk-on); }
.sparkline.neutral { color: var(--neutral); }
.sparkline.risk_off { color: var(--risk-off); }

/* Status colors (text) */
.status-risk_on { color: var(--risk-on); }
.status-neutral { color: var(--neutral); }
.status-risk_off { color: var(--risk-off); }

/* Status badge (pill) */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-badge.risk_on { background: var(--risk-on-bg); color: var(--risk-on); }
.status-badge.neutral { background: var(--neutral-bg); color: var(--neutral); }
.status-badge.risk_off { background: var(--risk-off-bg); color: var(--risk-off); }
.status-badge.n_a { background: #F3F4F6; color: var(--text-tertiary); }

/* ── All Indicators View ── */
.filter-chips {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.filter-chip {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
}
.filter-chip:hover {
  border-color: var(--border-strong);
}
.filter-chip.active {
  border-color: var(--teal);
  background: rgba(13, 94, 76, 0.06);
  color: var(--teal);
}

.indicator-group {
  margin-bottom: 24px;
}
.indicator-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--navy-pale);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
}
.indicator-group-name {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}
.indicator-group-score {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}

.indicator-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
}
.indicator-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.indicator-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.indicator-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.indicator-table tr:last-child td {
  border-bottom: none;
}
.indicator-table tr:hover {
  background: var(--navy-pale);
}
.indicator-name {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}
.indicator-value {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
}
.indicator-score {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
}
.indicator-trend {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
}
.indicator-trend.positive { color: var(--risk-on); }
.indicator-trend.negative { color: var(--risk-off); }

.info-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-tertiary);
  padding: 4px 8px;
  transition: color 0.15s;
  font-family: var(--font-sans);
}
.info-btn:hover {
  color: var(--navy);
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(8px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal {
  transform: translateY(0);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body {
  padding: 20px 24px 24px;
}
.modal-body p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.modal-body p:last-child { margin-bottom: 0; }
.modal-body .label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 4px;
  margin-top: 16px;
}
.modal-body .label:first-child { margin-top: 0; }
.modal-body .mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

/* Email form */
.email-form {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.email-form input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.15s;
}
.email-form input:focus {
  border-color: var(--teal);
}
.email-form button {
  padding: 10px 20px;
  background: var(--navy);
  color: var(--text-on-navy);
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.email-form button:hover {
  background: var(--navy-hover);
}
.email-success {
  color: var(--teal);
  font-size: 14px;
  font-weight: 500;
  margin-top: 12px;
  display: none;
}
.email-success.show { display: block; }

/* ── Error state ── */
.error-card {
  text-align: center;
  padding: 80px 24px;
}
.error-card h2 {
  font-size: 20px;
  margin-bottom: 8px;
}
.error-card p {
  color: var(--text-secondary);
  margin-bottom: 20px;
}
.error-card button {
  padding: 10px 24px;
  background: var(--navy);
  color: var(--text-on-navy);
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
}

/* ── Empty state (history) ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  padding: 40px;
  background: var(--navy-pale);
  border-radius: var(--radius);
  text-align: center;
}
.empty-state-title {
  font-weight: 600;
  font-size: 18px;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.empty-state-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.empty-state-body strong {
  color: var(--navy);
  font-family: var(--font-mono);
}

/* ── Sparkline placeholder ── */
.sparkline-placeholder {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 14px;
  text-align: center;
  padding: 4px 0;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Responsive ─��� */
@media (max-width: 768px) {
  .topbar { padding: 0 16px; }
  .topbar-nav { display: none; }
  .topbar-cta { display: none; }

  .mobile-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 8px 0;
    justify-content: space-around;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
  }
  .mobile-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-decoration: none;
    cursor: pointer;
    padding: 4px 12px;
    border: none;
    background: none;
    font-family: var(--font-sans);
  }
  .mobile-nav-link.active { color: var(--navy); }
  .mobile-nav-link .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-tertiary);
  }
  .mobile-nav-link.active .dot { background: var(--accent-green); }

  .view { padding: 32px 16px 100px; }

  .hero-score { font-size: 72px; }

  .regime-bar-container { width: 260px; }

  .op-lines-grid { grid-template-columns: repeat(2, 1fr); }

  .blocks-grid { grid-template-columns: repeat(2, 1fr); }

  .chart-container { min-height: 260px; padding: 12px; }

  .empty-state { min-height: 250px; padding: 24px; }

  /* Hide STATUS column on mobile, show colored dot on indicator name */
  .col-status { display: none; }
  .indicator-row .indicator-name::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
    background: var(--text-tertiary);
  }
  .indicator-row[data-status="risk_on"] .indicator-name::before { background: var(--risk-on); }
  .indicator-row[data-status="neutral"] .indicator-name::before { background: var(--neutral); }
  .indicator-row[data-status="risk_off"] .indicator-name::before { background: var(--risk-off); }

  .modal { max-width: 100%; margin: 0; border-radius: var(--radius) var(--radius) 0 0; align-self: flex-end; }
}

/* Desktop: hide mobile nav */
.mobile-nav { display: none; }
