/* ============================================
   Mortgage vs Income
   "The Analyst's Desk" — Premium Financial UI
   ============================================ */

/* --- Design Tokens --- */
:root {
  /* Surface palette — warm light mode */
  --bg-body: #f5f0eb;
  --bg-container: #ffffff;
  --bg-card: #faf8f5;
  --bg-card-est: #fffbeb;
  --bg-header: linear-gradient(135deg, #1e293b 0%, #0f172a 50%, #1a1a2e 100%);
  --bg-chart: #fdfcfa;

  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #5b6573;
  --text-on-dark: #f1f5f9;
  --text-on-dark-muted: #cbd5e1;

  /* Accents */
  --accent-amber: #d97706;
  --accent-amber-glow: rgba(217, 119, 6, 0.15);
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-emerald: #047857;
  --accent-rose: #e11d48;
  --accent-slate: #64748b;
  --accent-warning: #f59e0b;

  /* Borders & Shadows */
  --border-color: #e2e0dc;
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.04), 0 0 0 1px rgba(15, 23, 42, 0.02);

  /* Chart tooltip */
  --tooltip-bg: rgba(17, 24, 39, 0.95);
  --tooltip-text: #f1f5f9;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 100px;

  /* Typography */
  --font-display: 'Source Serif 4', Georgia, serif;
  --font-body: 'Outfit', -apple-system, sans-serif;
  --font-mono: 'DM Mono', 'SF Mono', monospace;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Dark Mode --- */
:root[data-theme="dark"] {
    --bg-body: #0c0f17;
    --bg-container: #141821;
    --bg-card: #1c2030;
    --bg-card-est: rgba(217, 119, 6, 0.08);
    --bg-header: linear-gradient(135deg, #0f172a 0%, #0a0e1a 50%, #111827 100%);
    --bg-chart: #181c28;

    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #7c8aa0;

    --accent-amber: #f59e0b;
    --accent-amber-glow: rgba(245, 158, 11, 0.1);
    --accent-blue: #60a5fa;
    --accent-purple: #a78bfa;
    --accent-emerald: #34d399;
    --accent-rose: #fb7185;
    --accent-slate: #94a3b8;

    --border-color: #2a2f3e;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.4);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.03);

    --tooltip-bg: rgba(241, 245, 249, 0.96);
    --tooltip-text: #0f172a;
}

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

.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--bg-container);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  z-index: 200;
}

.skip-link:focus {
  top: 8px;
  left: 8px;
  outline: 2px solid var(--accent-amber);
  outline-offset: 2px;
}

/* --- Keyboard shortcut dialog --- */
.shortcut-dialog {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-container);
  color: var(--text-primary);
  padding: 0;
  max-width: 420px;
  width: calc(100% - 32px);
  font-family: var(--font-body);
  box-shadow: var(--shadow-lg);
}

.shortcut-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.shortcut-dialog-inner {
  padding: 24px;
}

.shortcut-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.shortcut-dialog-header h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.shortcut-close {
  background: transparent;
  border: 0;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.shortcut-close:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.shortcut-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 18px;
  align-items: baseline;
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.shortcut-list dt {
  display: flex;
  gap: 4px;
}

.shortcut-list kbd {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg-card);
  color: var(--text-primary);
  min-width: 22px;
  text-align: center;
}

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

/* --- Container --- */
.container {
  max-width: 1360px;
  margin: 0 auto;
  background: var(--bg-container);
  min-height: 100vh;
  box-shadow: var(--shadow-lg);
  overflow-x: clip;
}

@media (min-width: 1400px) {
  body {
    padding: 24px;
  }
  .container {
    min-height: auto;
    border-radius: var(--radius-lg);
    overflow: hidden;
  }
}

/* --- Header --- */
header {
  background: var(--bg-header);
  padding: 56px 48px 48px;
  position: relative;
  overflow: hidden;
}

.header-inner {
  position: relative;
  z-index: 1;
}

.header-decoration {
  position: absolute;
  top: -20px;
  right: -20px;
  width: 240px;
  height: 240px;
  color: var(--accent-amber);
  opacity: 0.6;
  pointer-events: none;
}

.header-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-amber);
  margin-bottom: 16px;
  opacity: 0.9;
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-on-dark);
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

h1 .header-accent {
  color: var(--accent-amber);
}

.subtitle {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.update-info {
  margin-top: 16px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-on-dark-muted);
  letter-spacing: 0.02em;
}

/* --- Theme Toggle --- */
.theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
  color: #f1f5f9;
  transition: background 0.2s ease, border-color 0.2s ease;
  line-height: 0;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 2px;
}

.theme-icon {
  width: 18px;
  height: 18px;
}

[data-theme="light"] .theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-moon { display: none; }

/* --- Main Content --- */
.content {
  padding: 40px 48px 32px;
}

/* --- Loading & Errors --- */
.loading,
.error-message {
  text-align: center;
  padding: 60px 40px;
  font-size: 1rem;
  color: var(--text-muted);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 2.5px solid var(--border-color);
  border-top-color: var(--accent-amber);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-message {
  color: var(--accent-rose);
  font-weight: 500;
}

/* --- Estimation Warning --- */
.legend-info {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--accent-amber-glow);
  border: 1px solid rgba(217, 119, 6, 0.2);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.legend-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

/* --- Info Cards --- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.info-card {
  background: var(--bg-card);
  padding: 18px 18px 18px 22px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  position: relative;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
  border-left: 3px solid var(--accent-slate);
  overflow: hidden;
}

.info-card[data-accent="amber"]  { border-left-color: var(--accent-amber); }
.info-card[data-accent="blue"]   { border-left-color: var(--accent-blue); }
.info-card[data-accent="emerald"]{ border-left-color: var(--accent-emerald); }
.info-card[data-accent="rose"]   { border-left-color: var(--accent-rose); }
.info-card[data-accent="slate"]  { border-left-color: var(--accent-slate); }

.info-card.estimated {
  background: var(--bg-card-est);
  border-left-style: dashed;
}

.info-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.info-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.info-value {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.info-delta {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  min-height: 1em;
}

.info-delta.better {
  color: var(--accent-emerald);
}

.info-delta.worse {
  color: var(--accent-rose);
}

@media (prefers-reduced-motion: no-preference) {
  .info-value.value-flip,
  .info-delta.value-flip {
    animation: value-flip 180ms ease-out;
  }
}

@keyframes value-flip {
  0%   { opacity: 1; }
  40%  { opacity: 0.35; }
  100% { opacity: 1; }
}

.dual-value {
  display: block;
  line-height: 1.4;
  font-size: 1.15rem;
}

.dual-value.single {
  color: var(--accent-blue);
}

.dual-value.household {
  color: var(--accent-purple);
}

.estimated-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--accent-warning);
  color: #422006;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Market Select (inline in controls) --- */
.controls select {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 10px 30px 10px 20px;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.controls select:hover {
  background-color: var(--bg-card);
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.controls select:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 2px;
}

[data-theme="dark"] .controls select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.controls-divider {
  width: 1px;
  height: 18px;
  background: var(--border-color);
  flex-shrink: 0;
  opacity: 0.6;
}

/* --- Loading State (State Switch) --- */
.is-loading .info-grid {
  opacity: 0.4;
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .is-loading .info-grid {
    animation: loadPulse 1.2s ease-in-out infinite;
  }
}

.is-loading .chart-container {
  opacity: 0.3;
  pointer-events: none;
}

.is-loading .controls,
.is-loading .chart-toolbar {
  opacity: 0.4;
  pointer-events: none;
}

.is-loading .controls select {
  opacity: 0.5;
  pointer-events: none;
}

.info-grid,
.chart-container,
.controls,
.chart-toolbar {
  transition: opacity 0.3s var(--ease-out);
}

@keyframes loadPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.25; }
}

/* --- Controls (Dataset Toggle + Market Select) --- */
.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.controls-views {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-reset-filters[hidden] {
  display: none;
}

/* --- Buttons --- */
.btn {
  font-family: var(--font-body);
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 2px;
}

.btn-small {
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 500;
}

.btn-primary {
  background: #b45309;
  color: #fff;
  box-shadow: 0 1px 3px rgba(217, 119, 6, 0.25);
}

.btn-primary:hover {
  background: #92400e;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.3);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card);
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.btn.active {
  background: #b45309;
  color: #fff;
  border-color: #b45309;
  box-shadow: 0 1px 3px rgba(217, 119, 6, 0.25);
}

/* --- Chart Toolbar --- */
.chart-toolbar {
  margin-bottom: 16px;
}

.date-range-controls {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  border-radius: var(--radius-md);
}

.date-range-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.date-range-buttons,
.action-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.date-range-buttons .btn-small {
  min-width: 40px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.action-buttons .btn-small {
  font-family: var(--font-body);
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* --- Searchable state combobox (desktop only) --- */
.state-combobox {
  position: relative;
  display: none;
  font-family: var(--font-body);
}

.state-combobox-input {
  width: 240px;
  padding: 9px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-container);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
}

.state-combobox-input:focus {
  outline: 2px solid var(--accent-amber);
  outline-offset: 1px;
}

.state-combobox-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-container);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  list-style: none;
  padding: 4px 0;
  margin: 0;
  z-index: 20;
}

.state-combobox-list li {
  padding: 8px 14px;
  font-size: 0.9rem;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.state-combobox-list li.active,
.state-combobox-list li:hover {
  background: var(--bg-card);
}

.state-combobox-list .state-code {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
}

@media (min-width: 769px) {
  .state-combobox {
    display: block;
  }
  .state-native {
    display: none;
  }
}

/* --- Data table view --- */
.data-table-wrapper {
  max-height: 520px;
  overflow: auto;
  background: var(--bg-chart);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.data-table caption {
  text-align: left;
  padding: 16px 20px 8px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  caption-side: top;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  text-align: right;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.data-table thead th:first-child {
  text-align: left;
}

.data-table tbody td {
  padding: 8px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  white-space: nowrap;
}

.data-table tbody td:first-child {
  text-align: left;
  font-family: var(--font-body);
}

.data-table tbody tr:hover {
  background: var(--bg-card);
}

.data-table .quality-observed {
  color: var(--accent-emerald);
}

.data-table .quality-interpolated {
  color: var(--text-muted);
}

.data-table .quality-estimated {
  color: #b45309;
}

:root[data-theme="dark"] .data-table .quality-estimated {
  color: var(--accent-amber);
}

@media (max-width: 768px) {
  .data-table {
    font-size: 0.75rem;
  }
  .data-table thead th,
  .data-table tbody td {
    padding: 6px 8px;
  }
}

/* --- Embed mode (when URL has ?embed=1) --- */
body.is-embed header,
body.is-embed footer,
body.is-embed .methodology,
body.is-embed .state-grid-section,
body.is-embed .sticky-summary,
body.is-embed .skip-link {
  display: none !important;
}

body.is-embed {
  background: transparent;
}

body.is-embed .container {
  max-width: none;
  padding: 0;
}

body.is-embed .content {
  padding: 8px;
}

/* --- All-states ranking grid --- */
.state-grid-sub {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 12px;
}

.state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
}

.state-tile {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  cursor: pointer;
  font-family: var(--font-mono);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  text-align: center;
  color: var(--text-primary);
  transition: transform 0.12s var(--ease-out);
}

.state-tile:hover {
  transform: translateY(-2px);
}

.state-tile:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 1px;
}

.state-tile-code {
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.state-tile-ratio {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.state-tile[aria-current="true"] {
  outline: 2px solid var(--accent-amber);
  outline-offset: 1px;
}

@media (max-width: 768px) {
  .state-grid {
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  }
  .state-tile {
    padding: 6px 4px;
    min-height: 44px;
    justify-content: center;
  }
  .state-tile-ratio {
    font-size: 0.85rem;
  }
}

/* --- Sticky mobile summary --- */
.sticky-summary {
  display: none;
}

@media (max-width: 768px) {
  .sticky-summary {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--bg-container);
    border-bottom: 1px solid var(--border-color);
    padding: max(8px, env(safe-area-inset-top)) 16px 8px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-primary);
    transform: translateY(-100%);
    box-shadow: var(--shadow-md);
  }

  .sticky-summary.visible {
    transform: translateY(0);
  }

  .sticky-summary-sep {
    color: var(--text-muted);
  }

  .sticky-summary-ratio {
    color: var(--accent-amber);
    font-weight: 600;
  }
}

@media (max-width: 768px) and (prefers-reduced-motion: no-preference) {
  .sticky-summary {
    transition: transform 0.2s var(--ease-out);
  }
}

/* --- Chart Container --- */
.chart-container {
  position: relative;
  height: 520px;
  background: var(--bg-chart);
  border: 1px solid var(--border-color);
  padding: 24px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  transition: box-shadow 0.2s var(--ease-out);
}

.chart-container:focus {
  /* box-shadow is the normal-mode ring; the transparent outline is repainted as a visible
     ring in forced-colors / Windows High Contrast (where box-shadow is dropped). */
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--accent-amber), 0 0 0 4px var(--accent-amber-glow);
}

.active-point-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.active-point-marker {
  position: absolute;
  top: 0;
  left: 0;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  background: var(--accent-amber);
  border: 3px solid var(--bg-container);
  border-radius: 50%;
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent-amber) 40%, transparent);
  pointer-events: none;
  will-change: transform;
}

/* --- Zoom Tip --- */
.zoom-info {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  padding: 10px 0;
  letter-spacing: 0.03em;
  margin-bottom: 12px;
}

/* --- Collapsible sections (methodology + state-grid) --- */
.methodology,
.state-grid-section {
  border-top: 1px solid var(--border-color);
  padding-top: 0;
}

.methodology summary,
.state-grid-section summary {
  padding: 24px 0;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.methodology summary::-webkit-details-marker,
.state-grid-section summary::-webkit-details-marker {
  display: none;
}

.methodology summary::after,
.state-grid-section summary::after {
  content: '+';
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-left: auto;
  transition: transform 0.2s var(--ease-out);
}

.methodology[open] summary::after,
.state-grid-section[open] summary::after {
  content: '−';
}

.methodology summary:hover,
.state-grid-section summary:hover {
  color: var(--accent-amber);
}

.methodology summary h2,
.state-grid-section summary h2 {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0;
}

.methodology-content,
.state-grid-content {
  padding-bottom: 28px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.7;
}

.methodology-content p {
  margin-bottom: 14px;
}

.data-sources {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin: 16px 0;
}

.data-sources h3 {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.data-sources ul {
  list-style: none;
  padding: 0;
}

.data-sources li {
  padding: 6px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.data-sources li:last-child {
  border-bottom: none;
}

/* --- Footer --- */
footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 28px 48px;
}

.footer-inner {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.7;
}

footer a {
  color: var(--accent-amber);
  text-decoration: none;
  transition: color 0.15s ease;
}

footer a:hover {
  color: var(--accent-blue);
  text-decoration: underline;
}

.footer-meta {
  margin-top: 4px;
  opacity: 0.7;
  font-size: 0.75rem;
}

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

@media (max-width: 768px) {
  header {
    padding: 36px 24px 32px;
  }

  .header-decoration {
    width: 160px;
    height: 160px;
    top: -10px;
    right: -10px;
  }

  .content {
    padding: 24px 20px 20px;
  }

  h1 {
    font-size: 1.75rem;
  }

  .info-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .info-card {
    padding: 14px 14px 14px 18px;
  }

  .info-value {
    font-size: 1.15rem;
  }

  .info-label {
    font-size: 0.7rem;
  }

  .estimated-badge {
    font-size: 0.625rem;
  }

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

  .date-range-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .btn-action .btn-label {
    display: none;
  }

  .btn-action {
    padding: 8px 10px;
    min-height: 44px;
    min-width: 44px;
    justify-content: center;
  }

  .date-range-buttons .btn-small {
    min-height: 44px;
  }

  .theme-toggle {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .controls-views .btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  footer {
    padding: 24px 20px;
  }

  .controls {
    flex-direction: column;
  }

  .controls-divider {
    display: none;
  }

  .controls .btn {
    padding: 8px 16px;
    font-size: 0.8rem;
  }


  .controls select {
    padding: 7px 26px 7px 14px;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  header {
    padding: 28px 16px 24px;
  }

  .content {
    padding: 20px 16px 16px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .info-card:has(.estimated-badge) .info-label,
  .info-card:has(.estimated-badge) .info-value {
    padding-right: 56px;
  }

  h1 {
    font-size: 1.5rem;
  }

  .chart-container {
    height: clamp(300px, 45vh, 420px);
    padding: 8px;
  }

  footer {
    padding: 20px 16px;
  }
}

/* --- Animations --- */
@media (prefers-reduced-motion: no-preference) {
  .info-card {
    animation: fadeUp 0.4s var(--ease-out) both;
  }
  .info-card:nth-child(1) { animation-delay: 0.05s; }
  .info-card:nth-child(2) { animation-delay: 0.1s; }
  .info-card:nth-child(3) { animation-delay: 0.15s; }
  .info-card:nth-child(4) { animation-delay: 0.2s; }
  .info-card:nth-child(5) { animation-delay: 0.25s; }

  .chart-container {
    animation: fadeUp 0.5s var(--ease-out) 0.3s both;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Selection Color --- */
::selection {
  background: var(--accent-amber);
  color: #fff;
}

/* --- Scrollbar (Webkit) --- */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

/* --- Accessibility --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
