:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-alt: #0b1120;
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #10b981;
  --amber: #f59e0b;
  --purple: #a855f7;
  --red: #ef4444;
  --topbar-bg: rgba(11, 17, 32, 0.88);
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  --chart-grid: #1e293b;
  --chart-text: #94a3b8;
  --chart-primary-text: #f8fafc;
  --chart-secondary-text: #cbd5e1;
}

[data-theme="light"] {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #d8e0ea;
  --text: #0f172a;
  --muted: #475569;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --green: #059669;
  --amber: #d97706;
  --purple: #7c3aed;
  --red: #dc2626;
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --card-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 6px 16px -4px rgba(15, 23, 42, 0.05);
  --chart-grid: #e2e8f0;
  --chart-text: #475569;
  --chart-primary-text: #0f172a;
  --chart-secondary-text: #334155;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0;
  margin-bottom: 1.25rem;
}

.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.topbar h1 {
  font-size: 1.28rem;
  font-weight: 700;
}

.nav-and-status {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.tab-nav {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  flex-wrap: wrap;
  gap: 2px;
}

.tab-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
}

.badge {
  background: rgba(16, 185, 129, 0.15);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

/* Beginner Intro Banner */
.intro-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 900px) {
  .intro-grid {
    grid-template-columns: 1fr;
  }
}

.intro-card {
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

.intro-card h3 {
  font-size: 0.92rem;
  color: var(--accent);
  margin-bottom: 0.3rem;
}

.intro-card p {
  font-size: 0.82rem;
  color: var(--muted);
}

.intro-card strong {
  color: var(--text);
}

.main-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.5rem;
  padding-bottom: 3rem;
  align-items: start;
}

@media (max-width: 960px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

.countries-container {
  padding-bottom: 3rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.controls-panel h2 {
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.8rem;
}

.controls-panel hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.05rem 0;
}

.preset-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-bottom: 0.95rem;
}

.preset-btn {
  background: var(--surface-alt);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.preset-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.preset-btn.active {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--accent);
  color: var(--text);
}

.control-group {
  margin-bottom: 0.9rem;
}

.control-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.15rem 0.5rem;
  font-size: 0.84rem;
  margin-bottom: 0.25rem;
}

.control-header label {
  flex: 1 1 auto;
}

.control-header .val {
  font-weight: 700;
  color: var(--accent);
  text-align: right;
  flex-shrink: 0;
  margin-left: auto;
  white-space: nowrap;
}

.inline-money-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.12rem;
  margin-left: auto;
  padding: 0.14rem 0.45rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}

.inline-money-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.18);
}

.inline-money-prefix {
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--accent);
  user-select: none;
}

.inline-money-input {
  width: 4.8rem;
  border: none;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding: 0;
  outline: none;
  -moz-appearance: textfield;
}

.inline-money-input::-webkit-outer-spin-button,
.inline-money-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.helper-text {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 32px; /* Touch target area */
  background: transparent;
}

input[type="range"]::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
}

.select-input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
}

.date-range-inline {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.3rem;
}

.date-reset-btn {
  background: var(--surface-alt);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.2;
}

.date-reset-btn:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent);
  color: var(--text);
}

.date-inline-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.date-number-input {
  width: 5.2rem;
  max-width: 80px;
  text-align: center;
  padding: 0.35rem 0.4rem;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.86rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

.date-number-input::-webkit-outer-spin-button,
.date-number-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.date-hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.35rem;
  font-style: italic;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.83rem;
  margin-bottom: 0.6rem;
  cursor: pointer;
}

.guardrail-subpanel {
  margin: 0.45rem 0 0.85rem 0;
  transition: opacity 0.2s ease;
}

.guardrail-subpanel.disabled-state {
  opacity: 0.45;
  pointer-events: none;
  user-select: none;
}

.guardrail-mode-option {
  padding: 0.25rem 0.35rem;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.guardrail-mode-option:hover {
  background: rgba(59, 130, 246, 0.08);
}

.guardrail-mode-option input[type="radio"] {
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.65rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.results-top-area {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

@media (max-width: 780px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.kpi-card.highlight {
  border-color: var(--accent);
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.14), var(--surface));
}

.kpi-label {
  font-size: 0.76rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 1.38rem;
  margin: 0.2rem 0;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--green);
}

.muted-sub {
  color: var(--muted);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.scale-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--surface-alt);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.chart-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.copy-chart-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-alt);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
}

.copy-chart-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.copy-chart-btn.copied {
  background: #10b981 !important;
  color: #fff !important;
  border-color: #10b981 !important;
}

.currency-toggle-group {
  display: flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.curr-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.curr-btn.active {
  background: var(--accent);
  color: #fff;
}

.currency-callout {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(59, 130, 246, 0.1);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font-size: 0.83rem;
  color: var(--muted);
}

.currency-callout strong {
  color: var(--text);
}

.chart-card h3 {
  font-size: 1.05rem;
  margin-bottom: 0.2rem;
}

.card-desc {
  font-size: 0.83rem;
  color: var(--muted);
  margin-bottom: 0.9rem;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
}

#bootstrapCanvas {
  cursor: crosshair;
  touch-action: pan-y;
}

.table-wrap {
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 1rem;
}

table th,
table td,
.kpi-value,
.metric-val,
.val,
.badge-pill,
.winner-badge {
  font-variant-numeric: tabular-nums;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

th, td {
  padding: 0.6rem 0.65rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

th:first-child, td:first-child {
  text-align: left;
  padding-left: 0.35rem;
}

.strategy-name-short {
  display: none;
}

.strategy-name-full {
  display: inline;
}

.strategy-desc {
  font-size: 0.73rem;
  color: var(--muted);
  font-weight: normal;
  margin-top: 2px;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.sortable-table th {
  cursor: pointer;
  user-select: none;
}

.sortable-table th:hover {
  color: var(--text);
}

#countriesTable {
  font-size: 0.81rem;
}

#countriesTable th,
#countriesTable td {
  padding: 0.42rem 0.5rem;
  white-space: nowrap;
}

#countriesTable th:first-child,
#countriesTable td:first-child {
  padding-left: 0.28rem;
}

.pos { color: var(--green); }
.neg { color: var(--red); }
.info { color: var(--accent); }
.amber { color: var(--amber); }

.depleted-sub {
  font-size: 0.68rem;
  color: var(--red);
  font-weight: normal;
}

.legend-row {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.legend-row strong {
  color: var(--text);
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.35rem;
}

.dot.p90 { background: var(--green); }
.dot.bench-p90 { background: #34d399; }
.dot.p50 { background: var(--accent); }
.dot.bench-p50 { background: var(--purple); }
.dot.bench { background: var(--purple); }
.dot.p10 { background: var(--red); }
.dot.bench-p10 { background: var(--amber); }

.legend-row-compare {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
  margin-top: 0.95rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 820px) {
  .legend-row-compare {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .legend-items {
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
  }
}

.legend-group {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
}

.legend-group-title {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.legend-items {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.79rem;
  color: var(--muted);
}

.legend-items strong {
  color: var(--text);
}

/* Research & Why It Matters Tab and Key Takeaways Tab */
.research-container,
.takeaways-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-bottom: 3.5rem;
}

/* Key Research Papers, Video & Primary Data Sources (Bottom Section) */
.research-resources-section {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.research-section-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.section-sub {
  font-size: 0.84rem;
  color: var(--muted);
}

.research-resources-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (max-width: 860px) {
  .research-resources-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
  }
}

.resource-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.2s, transform 0.2s;
}

.resource-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.resource-card.card-video {
  border-top: 3px solid #ef4444;
}

.resource-card.card-paper {
  border-top: 3px solid var(--purple);
}

.resource-card.card-institutional {
  border-top: 3px solid #6366f1;
}

.resource-card.card-data {
  border-top: 3px solid #10b981;
}

.resource-card-badge {
  margin-bottom: 0.65rem;
}

.resource-card h4 {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.45rem;
  line-height: 1.35;
}

.resource-desc {
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 1.15rem;
  flex-grow: 1;
}

.research-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
  width: fit-content;
}

.btn-youtube {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-youtube:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

.btn-pdf {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
}

.btn-pdf:hover {
  background: var(--purple);
  color: #fff;
  border-color: var(--purple);
}

.btn-secondary {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.btn-secondary:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.badge-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
}

.badge-tag.red {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.badge-tag.purple {
  background: rgba(168, 85, 247, 0.18);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
}

.badge-tag.indigo {
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.badge-tag.green {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-tag.warning {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-tag.blue {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.badge-tag.teal {
  background: rgba(20, 184, 166, 0.18);
  color: #2dd4bf;
  border: 1px solid rgba(20, 184, 166, 0.4);
}

.takeaway-badge-row {
  margin-bottom: 0.5rem;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.15rem 1rem;
  text-align: center;
  transition: transform 0.15s, border-color 0.15s;
}

.stat-box:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.stat-box .stat-num {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  margin-bottom: 0.35rem;
}

.stat-box .stat-num.highlight {
  color: var(--green);
}

.stat-box .stat-num.warning {
  color: var(--amber);
}

.stat-box .stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.card-stat-grid-2x3 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 0.9rem;
}

@media (max-width: 580px) {
  .card-stat-grid-2x3 {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.55rem;
  }
}

.card-stat-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.9rem 0.85rem;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, border-color 0.15s;
}

.card-stat-box:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card-stat-box .stat-num {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  margin-bottom: 0.3rem;
}

.card-stat-box .stat-num.highlight {
  color: var(--green);
}

.card-stat-box .stat-num.warning {
  color: var(--amber);
}

.card-stat-box .stat-num.lime {
  color: #a3e635;
}

[data-theme="light"] .card-stat-box .stat-num.lime {
  color: #65a30d;
}

.card-stat-box .stat-num.purple {
  color: var(--purple);
}

.card-stat-box .stat-num.danger {
  color: var(--red);
}

.card-stat-box .stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

[data-theme="light"] .card-stat-box {
  background: #f8fafc;
  border-color: var(--border);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.research-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 960px) {
  .research-card-grid {
    grid-template-columns: 1fr;
  }
}

.research-card-flex {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.research-card-body {
  flex-grow: 1;
}

.card-2-body p {
  line-height: 1.65;
  margin-bottom: 0.95rem;
}

.card-2-body ul li {
  line-height: 1.68;
  margin-bottom: 0.85rem;
}

.research-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.4rem;
}

.research-card h2 {
  font-size: 1.18rem;
  margin-bottom: 0.65rem;
  color: var(--text);
}

.research-card h3 {
  font-size: 0.98rem;
  margin: 1rem 0 0.4rem 0;
  color: var(--accent);
}

.research-card p {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 0.85rem;
}

.research-card p strong {
  color: var(--text);
}

.research-card ul {
  list-style: none;
  padding: 0;
  margin: 0.6rem 0 1rem 0;
}

.research-card ul li {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 0.55rem;
  padding-left: 1.3rem;
  position: relative;
}

.research-card ul li::before {
  content: "•";
  color: var(--accent);
  font-weight: bold;
  font-size: 1.1rem;
  position: absolute;
  left: 0.25rem;
  top: -1px;
}

.research-card ul li strong {
  color: var(--text);
}

.highlight-banner {
  background: rgba(59, 130, 246, 0.1);
  border-left: 4px solid var(--accent);
  padding: 0.85rem 1.1rem;
  border-radius: 6px;
  font-size: 0.84rem;
  color: var(--text);
  margin-top: 0.9rem;
}

.warning-banner {
  background: rgba(245, 158, 11, 0.12);
  border-left: 4px solid var(--amber);
  padding: 0.85rem 1.1rem;
  border-radius: 6px;
  font-size: 0.84rem;
  color: var(--text);
  margin-top: 0.9rem;
}

.success-banner {
  background: rgba(16, 185, 129, 0.12);
  border-left: 4px solid var(--green);
  padding: 0.85rem 1.1rem;
  border-radius: 6px;
  font-size: 0.84rem;
  color: var(--text);
  margin-top: 0.9rem;
}

/* ==================== ALLOCATION VIEW (U.S. VS. INTERNATIONAL) ==================== */
.allocation-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-bottom: 3.5rem;
}

/* Lifecycle Stress-Test Winner Summary */
.winner-summary-container {
  margin-top: 1rem;
}

.winner-header h3 {
  font-size: 1.15rem;
  margin-bottom: 0.25rem;
}

.winner-row-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(51, 65, 85, 0.6);
}

.winner-row-header h4 {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text);
}

.winner-row-sub {
  font-size: 0.76rem;
  color: var(--muted);
}

.fair-test-disclaimer {
  margin-top: 1.25rem;
  padding: 0.95rem 1.15rem;
  background: rgba(245, 158, 11, 0.1);
  border-left: 4px solid var(--amber);
  border-radius: 8px;
}

details.methodology-details {
  margin-top: 1.25rem;
  padding: 0.85rem 1.15rem;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

details.methodology-details[open] {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.5);
}

details.methodology-details summary {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--amber);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
}

details.methodology-details summary::-webkit-details-marker {
  display: none;
}

details.methodology-details summary::before {
  content: "▸";
  font-size: 0.85rem;
  color: var(--amber);
  transition: transform 0.2s ease;
  display: inline-block;
}

details.methodology-details[open] summary::before {
  transform: rotate(90deg);
}

details.methodology-details .details-content {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(245, 158, 11, 0.2);
  font-size: 0.84rem;
  color: #ffffff;
  line-height: 1.6;
}

details.methodology-details .details-content strong {
  color: #ffffff;
}

.winner-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

@media (max-width: 1040px) {
  .winner-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 620px) {
  .winner-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.55rem;
  }
}

.winner-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s, border-color 0.15s;
}

.winner-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card-blue {
  border-color: rgba(59, 130, 246, 0.4);
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.12), var(--surface-alt));
}
.card-blue:hover {
  border-color: var(--accent);
}

.card-purple {
  border-color: rgba(168, 85, 247, 0.4);
  background: linear-gradient(145deg, rgba(168, 85, 247, 0.12), var(--surface-alt));
}
.card-purple:hover {
  border-color: var(--purple);
}

.card-amber {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(145deg, rgba(245, 158, 11, 0.12), var(--surface-alt));
}
.card-amber:hover {
  border-color: var(--amber);
}

.card-green {
  border-color: rgba(16, 185, 129, 0.4);
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.12), var(--surface-alt));
}
.card-green:hover {
  border-color: var(--green);
}

.card-indigo {
  border-color: rgba(99, 102, 241, 0.45);
  background: linear-gradient(145deg, rgba(99, 102, 241, 0.14), var(--surface-alt));
}
.card-indigo:hover {
  border-color: #6366f1;
}

.card-coral {
  border-color: rgba(249, 115, 22, 0.45);
  background: linear-gradient(145deg, rgba(249, 115, 22, 0.14), var(--surface-alt));
}
.card-coral:hover {
  border-color: #f97316;
}

.card-red {
  border-color: rgba(239, 68, 68, 0.45);
  background: linear-gradient(145deg, rgba(239, 68, 68, 0.14), var(--surface-alt));
}
.card-red:hover {
  border-color: #ef4444;
}

.winner-card.highlight {
  border-color: var(--green);
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.14), var(--surface-alt));
}

.winner-card-top {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.winner-category {
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.winner-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.88rem;
  font-weight: 800;
  padding: 0.22rem 0.65rem;
  border-radius: 6px;
}

.badge-blue {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.45);
}

.badge-purple {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.45);
}

.badge-green {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.45);
}

.badge-amber {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.badge-indigo {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.45);
}

.badge-coral {
  background: rgba(249, 115, 22, 0.2);
  color: #fb923c;
  border: 1px solid rgba(249, 115, 22, 0.45);
}

.badge-red {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.card-blue .winner-metrics {
  background: rgba(30, 58, 138, 0.45);
  border-color: rgba(59, 130, 246, 0.45);
}

.card-purple .winner-metrics {
  background: rgba(88, 28, 135, 0.45);
  border-color: rgba(168, 85, 247, 0.45);
}

.card-amber .winner-metrics {
  background: rgba(120, 53, 15, 0.45);
  border-color: rgba(245, 158, 11, 0.45);
}

.card-green .winner-metrics,
.winner-card.highlight .winner-metrics {
  background: rgba(6, 78, 59, 0.45);
  border-color: rgba(16, 185, 129, 0.45);
}

.card-indigo .winner-metrics {
  background: rgba(49, 46, 129, 0.45);
  border-color: rgba(99, 102, 241, 0.45);
}

.card-coral .winner-metrics {
  background: rgba(124, 45, 18, 0.45);
  border-color: rgba(249, 115, 22, 0.45);
}

.card-red .winner-metrics {
  background: rgba(127, 29, 29, 0.45);
  border-color: rgba(239, 68, 68, 0.45);
}

/* Light Mode: shaded diagonal gradients, colored inner metric wells, and soft ambient glow matching Dark Mode */
[data-theme="light"] .winner-metrics-row {
  border-top-color: rgba(15, 23, 42, 0.12);
}

[data-theme="light"] .card-blue {
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.14) 0%, rgba(37, 99, 235, 0.04) 55%, #ffffff 100%);
  border-color: rgba(37, 99, 235, 0.34);
  box-shadow: 0 6px 18px -6px rgba(37, 99, 235, 0.22), 0 2px 6px rgba(15, 23, 42, 0.05);
}
[data-theme="light"] .card-blue:hover {
  border-color: #2563eb;
  box-shadow: 0 10px 24px -6px rgba(37, 99, 235, 0.3), 0 4px 10px rgba(15, 23, 42, 0.06);
}
[data-theme="light"] .card-blue .winner-metrics {
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.16), rgba(37, 99, 235, 0.07));
  border-color: rgba(37, 99, 235, 0.28);
  box-shadow: inset 0 1px 2px rgba(37, 99, 235, 0.08);
}

[data-theme="light"] .card-purple {
  background: linear-gradient(145deg, rgba(124, 58, 237, 0.14) 0%, rgba(124, 58, 237, 0.04) 55%, #ffffff 100%);
  border-color: rgba(124, 58, 237, 0.34);
  box-shadow: 0 6px 18px -6px rgba(124, 58, 237, 0.22), 0 2px 6px rgba(15, 23, 42, 0.05);
}
[data-theme="light"] .card-purple:hover {
  border-color: #7c3aed;
  box-shadow: 0 10px 24px -6px rgba(124, 58, 237, 0.3), 0 4px 10px rgba(15, 23, 42, 0.06);
}
[data-theme="light"] .card-purple .winner-metrics {
  background: linear-gradient(145deg, rgba(124, 58, 237, 0.16), rgba(124, 58, 237, 0.07));
  border-color: rgba(124, 58, 237, 0.28);
  box-shadow: inset 0 1px 2px rgba(124, 58, 237, 0.08);
}

[data-theme="light"] .card-amber {
  background: linear-gradient(145deg, rgba(217, 119, 6, 0.15) 0%, rgba(217, 119, 6, 0.04) 55%, #ffffff 100%);
  border-color: rgba(217, 119, 6, 0.36);
  box-shadow: 0 6px 18px -6px rgba(217, 119, 6, 0.22), 0 2px 6px rgba(15, 23, 42, 0.05);
}
[data-theme="light"] .card-amber:hover {
  border-color: #d97706;
  box-shadow: 0 10px 24px -6px rgba(217, 119, 6, 0.3), 0 4px 10px rgba(15, 23, 42, 0.06);
}
[data-theme="light"] .card-amber .winner-metrics {
  background: linear-gradient(145deg, rgba(217, 119, 6, 0.17), rgba(217, 119, 6, 0.07));
  border-color: rgba(217, 119, 6, 0.28);
  box-shadow: inset 0 1px 2px rgba(217, 119, 6, 0.08);
}

[data-theme="light"] .card-green,
[data-theme="light"] .winner-card.highlight {
  background: linear-gradient(145deg, rgba(5, 150, 105, 0.14) 0%, rgba(5, 150, 105, 0.04) 55%, #ffffff 100%);
  border-color: rgba(5, 150, 105, 0.35);
  box-shadow: 0 6px 18px -6px rgba(5, 150, 105, 0.22), 0 2px 6px rgba(15, 23, 42, 0.05);
}
[data-theme="light"] .card-green:hover,
[data-theme="light"] .winner-card.highlight:hover {
  border-color: #059669;
  box-shadow: 0 10px 24px -6px rgba(5, 150, 105, 0.3), 0 4px 10px rgba(15, 23, 42, 0.06);
}
[data-theme="light"] .card-green .winner-metrics,
[data-theme="light"] .winner-card.highlight .winner-metrics {
  background: linear-gradient(145deg, rgba(5, 150, 105, 0.16), rgba(5, 150, 105, 0.07));
  border-color: rgba(5, 150, 105, 0.28);
  box-shadow: inset 0 1px 2px rgba(5, 150, 105, 0.08);
}

[data-theme="light"] .card-indigo {
  background: linear-gradient(145deg, rgba(79, 70, 229, 0.14) 0%, rgba(79, 70, 229, 0.04) 55%, #ffffff 100%);
  border-color: rgba(79, 70, 229, 0.34);
  box-shadow: 0 6px 18px -6px rgba(79, 70, 229, 0.22), 0 2px 6px rgba(15, 23, 42, 0.05);
}
[data-theme="light"] .card-indigo:hover {
  border-color: #4f46e5;
  box-shadow: 0 10px 24px -6px rgba(79, 70, 229, 0.3), 0 4px 10px rgba(15, 23, 42, 0.06);
}
[data-theme="light"] .card-indigo .winner-metrics {
  background: linear-gradient(145deg, rgba(79, 70, 229, 0.16), rgba(79, 70, 229, 0.07));
  border-color: rgba(79, 70, 229, 0.28);
  box-shadow: inset 0 1px 2px rgba(79, 70, 229, 0.08);
}

[data-theme="light"] .card-coral {
  background: linear-gradient(145deg, rgba(234, 88, 12, 0.14) 0%, rgba(234, 88, 12, 0.04) 55%, #ffffff 100%);
  border-color: rgba(234, 88, 12, 0.34);
  box-shadow: 0 6px 18px -6px rgba(234, 88, 12, 0.22), 0 2px 6px rgba(15, 23, 42, 0.05);
}
[data-theme="light"] .card-coral:hover {
  border-color: #ea580c;
  box-shadow: 0 10px 24px -6px rgba(234, 88, 12, 0.3), 0 4px 10px rgba(15, 23, 42, 0.06);
}
[data-theme="light"] .card-coral .winner-metrics {
  background: linear-gradient(145deg, rgba(234, 88, 12, 0.16), rgba(234, 88, 12, 0.07));
  border-color: rgba(234, 88, 12, 0.28);
  box-shadow: inset 0 1px 2px rgba(234, 88, 12, 0.08);
}

[data-theme="light"] .card-red {
  background: linear-gradient(145deg, rgba(220, 38, 38, 0.14) 0%, rgba(220, 38, 38, 0.04) 55%, #ffffff 100%);
  border-color: rgba(220, 38, 38, 0.34);
  box-shadow: 0 6px 18px -6px rgba(220, 38, 38, 0.22), 0 2px 6px rgba(15, 23, 42, 0.05);
}
[data-theme="light"] .card-red:hover {
  border-color: #dc2626;
  box-shadow: 0 10px 24px -6px rgba(220, 38, 38, 0.3), 0 4px 10px rgba(15, 23, 42, 0.06);
}
[data-theme="light"] .card-red .winner-metrics {
  background: linear-gradient(145deg, rgba(220, 38, 38, 0.16), rgba(220, 38, 38, 0.07));
  border-color: rgba(220, 38, 38, 0.28);
  box-shadow: inset 0 1px 2px rgba(220, 38, 38, 0.08);
}

.winner-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(51, 65, 85, 0.6);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
}

.winner-metric {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.2;
}

.metric-val {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 0.15rem;
}

.metric-sub {
  font-size: 0.69rem;
  color: var(--muted);
  line-height: 1.25;
  margin-top: 0.15rem;
}

.winner-metrics-row {
  grid-column: span 2;
  border-top: 1px solid rgba(51, 65, 85, 0.5);
  padding-top: 0.45rem;
  margin-top: 0.1rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.winner-caption {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
  margin: 0;
}

.winner-takeaway-banner {
  margin-top: 1.1rem;
  padding: 0.85rem 1.15rem;
  background: rgba(59, 130, 246, 0.1);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  font-size: 0.86rem;
  color: var(--text);
  line-height: 1.5;
}

.winner-takeaway-banner strong {
  color: var(--text);
}

.allocation-table th,
.allocation-table td {
  padding: 0.65rem 0.85rem;
  white-space: nowrap;
}

.allocation-table th:first-child,
.allocation-table td:first-child {
  padding-left: 0.35rem;
}

.row-winner-6040 {
  background: rgba(59, 130, 246, 0.14) !important;
  border-left: 3px solid var(--accent);
}

.row-winner-6040:hover {
  background: rgba(59, 130, 246, 0.22) !important;
}

.row-winner-8020 {
  background: rgba(168, 85, 247, 0.14) !important;
  border-left: 3px solid var(--purple);
}

.row-winner-8020:hover {
  background: rgba(168, 85, 247, 0.22) !important;
}

.row-winner-100 {
  background: rgba(245, 158, 11, 0.08) !important;
  border-left: 3px solid rgba(245, 158, 11, 0.5);
}

.row-winner-100:hover {
  background: rgba(245, 158, 11, 0.15) !important;
}

.badge-pill {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: 0.35rem;
  vertical-align: middle;
  line-height: 1.2;
}

.badge-blue {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.badge-purple {
  background: rgba(168, 85, 247, 0.18);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
}

.badge-green {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-red {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.badge-amber {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

/* Fund Choice Cards (VTI+VXUS vs VT) */
.fund-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 1rem;
}

@media (max-width: 800px) {
  .fund-choice-grid {
    grid-template-columns: 1fr;
  }
}

.fund-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  position: relative;
}

.fund-card h4 {
  font-size: 1.05rem;
  color: var(--text);
  margin-bottom: 0.45rem;
}

.fund-badge {
  display: inline-block;
  background: rgba(16, 185, 129, 0.15);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.fund-card p {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 0.65rem;
}

.fund-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.fund-card ul li {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 0.45rem;
  padding-left: 1.25rem;
  position: relative;
}

.fund-card ul li::before {
  content: "\2713";
  color: var(--green);
  font-weight: bold;
  font-size: 0.95rem;
  position: absolute;
  left: 0.15rem;
  top: -1px;
}

.fund-card ul li strong {
  color: var(--text);
}

.penalty-table {
  width: 100%;
  table-layout: auto;
}

.penalty-table th,
.penalty-table td {
  padding: 0.6rem 0.65rem;
  white-space: normal;
  vertical-align: middle;
}

.penalty-table th:first-child,
.penalty-table td:first-child {
  padding-left: 0.15rem;
  min-width: 100px;
  max-width: 115px;
  width: 108px;
  font-size: 0.77rem;
  line-height: 1.2;
}

.penalty-table th:nth-child(2),
.penalty-table td:nth-child(2) {
  white-space: nowrap;
  min-width: 120px;
}

.penalty-table th:nth-child(3),
.penalty-table td:nth-child(3) {
  white-space: nowrap;
  min-width: 145px;
}

.penalty-table th:nth-child(4),
.penalty-table td:nth-child(4) {
  white-space: nowrap;
  min-width: 155px;
}

.penalty-table th:nth-child(5),
.penalty-table td:nth-child(5) {
  min-width: 280px;
  line-height: 1.55;
  font-size: 0.835rem;
  color: var(--muted);
}

.penalty-table td:nth-child(5) strong {
  color: var(--text);
}

.penalty-table .sublabel {
  display: block;
  font-size: 0.67rem;
  font-weight: 400;
  color: var(--muted);
  margin-top: 0.15rem;
  line-height: 1.2;
}

.badge-pill.best {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

[data-theme="light"] .badge-pill.best {
  background: rgba(5, 150, 105, 0.14);
  color: #047857;
  border: 1px solid rgba(5, 150, 105, 0.35);
}

.penalty-table .pos-bonus {
  color: var(--green);
  font-weight: 700;
  display: inline-block;
  padding: 0.12rem 0.5rem;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 999px;
  font-size: 0.78rem;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

[data-theme="light"] .penalty-table .pos-bonus {
  background: rgba(5, 150, 105, 0.12);
  border: 1px solid rgba(5, 150, 105, 0.35);
  color: #047857;
}

.table-wrap.no-slider {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.theme-toggle-btn:hover {
  border-color: var(--accent);
  background: var(--surface-alt);
  transform: translateY(-1px);
}

.theme-icon {
  font-size: 0.95rem;
  line-height: 1;
}

/* Light theme overrides for high contrast & legibility */
[data-theme="light"] .topbar {
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

[data-theme="light"] .tab-nav {
  background: #eef2f6;
  border-color: var(--border);
}

[data-theme="light"] .tab-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .badge {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

[data-theme="light"] .preset-btn {
  background: #f8fafc;
  color: #334155;
}

[data-theme="light"] .preset-btn.active {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1d4ed8;
}

[data-theme="light"] .currency-toggle-group {
  background: #eef2f6;
}

[data-theme="light"] .card,
[data-theme="light"] .stat-box,
[data-theme="light"] .card-stat-box,
[data-theme="light"] .resource-card,
[data-theme="light"] .fund-card {
  background: #ffffff;
  box-shadow: var(--card-shadow);
}

[data-theme="light"] .intro-card {
  background: #ffffff;
  box-shadow: var(--card-shadow);
}

[data-theme="light"] .canvas-wrap {
  background: #ffffff;
  border-color: var(--border);
}

[data-theme="light"] .legend-group {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .dot.p90 { background: #047857; }
[data-theme="light"] .dot.bench-p90 { background: #10b981; }
[data-theme="light"] .dot.p50 { background: #2563eb; }
[data-theme="light"] .dot.bench-p50,
[data-theme="light"] .dot.bench { background: #7c3aed; }
[data-theme="light"] .dot.p10 { background: #dc2626; }
[data-theme="light"] .dot.bench-p10 { background: #d97706; }

[data-theme="light"] table thead th {
  background: #f8fafc;
  color: #334155;
  border-bottom-color: #cbd5e1;
}

[data-theme="light"] .row-winner-6040 {
  background: rgba(37, 99, 235, 0.05) !important;
}
[data-theme="light"] .row-winner-6040:hover {
  background: rgba(37, 99, 235, 0.09) !important;
}
[data-theme="light"] .row-winner-8020 {
  background: rgba(124, 58, 237, 0.05) !important;
}
[data-theme="light"] .row-winner-8020:hover {
  background: rgba(124, 58, 237, 0.09) !important;
}
[data-theme="light"] .row-winner-100 {
  background: rgba(217, 119, 6, 0.06) !important;
}
[data-theme="light"] .row-winner-100:hover {
  background: rgba(217, 119, 6, 0.1) !important;
}

[data-theme="light"] details.methodology-details .details-content {
  color: #1e293b;
}

[data-theme="light"] details.methodology-details .details-content strong {
  color: #0f172a;
}

[data-theme="light"] .highlight-banner {
  background: #eff6ff;
  border-left-color: #2563eb;
  color: #1e3a8a;
}

[data-theme="light"] .highlight-banner strong {
  color: #172554;
}

[data-theme="light"] .warning-banner {
  background: #fefce8;
  border-left-color: #ca8a04;
  color: #713f12;
}

[data-theme="light"] .warning-banner strong {
  color: #422006;
}

[data-theme="light"] .success-banner {
  background: #f0fdf4;
  border-left-color: #16a34a;
  color: #14532d;
}

[data-theme="light"] .success-banner strong {
  color: #052e16;
}

[data-theme="light"] .currency-callout {
  background: #eff6ff;
  border-left-color: #2563eb;
  color: #1e3a8a;
}

[data-theme="light"] .currency-callout strong {
  color: #172554;
}

[data-theme="light"] .badge-blue {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #93c5fd;
}

[data-theme="light"] .badge-purple {
  background: #f3e8ff;
  color: #7e22ce;
  border-color: #d8b4fe;
}

[data-theme="light"] .badge-green {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

[data-theme="light"] .badge-red {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

[data-theme="light"] .badge-amber {
  background: #fef3c7;
  color: #b45309;
  border-color: #fcd34d;
}

[data-theme="light"] .badge-coral {
  background: #ffedd5;
  color: #c2410c;
  border-color: #fdba74;
}

[data-theme="light"] .badge-indigo {
  background: #e0e7ff;
  color: #4338ca;
  border-color: #a5b4fc;
}

[data-theme="light"] .badge-tag.red {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

[data-theme="light"] .badge-tag.purple {
  background: #f3e8ff;
  color: #7e22ce;
  border-color: #d8b4fe;
}

[data-theme="light"] .badge-tag.indigo {
  background: #e0e7ff;
  color: #4338ca;
  border-color: #a5b4fc;
}

[data-theme="light"] .badge-tag.green {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

[data-theme="light"] .badge-tag.warning {
  background: #fef3c7;
  color: #b45309;
  border-color: #fcd34d;
}

[data-theme="light"] .badge-tag.blue {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #93c5fd;
}

[data-theme="light"] .badge-tag.teal {
  background: #ccfbf1;
  color: #0f766e;
  border-color: #99f6e4;
}

[data-theme="light"] .kpi-card {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: var(--card-shadow);
}

[data-theme="light"] .kpi-card.highlight {
  background: #ffffff;
  border-color: #93c5fd;
  border-top: 3px solid #2563eb;
}

[data-theme="light"] .kpi-card.highlight .kpi-value {
  color: #1d4ed8;
}

[data-theme="light"] .btn-secondary {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

[data-theme="light"] .btn-secondary:hover {
  background: #2563eb;
  color: #ffffff;
}

[data-theme="light"] .fund-badge {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

[data-theme="light"] table tbody tr:hover {
  background: #f1f5f9;
}

/* ==========================================================================
   MOBILE & TABLET RESPONSIVE SYSTEM
   Optimized for phones (<=480px), large phones/tablets (481px–768px),
   and small desktops/landscape tablets (769px–960px).
   ========================================================================== */

@media (max-width: 960px) {
  .badge-card-winner {
    display: none !important;
  }

  .strategy-name-full {
    display: none !important;
  }

  .strategy-name-short {
    display: inline !important;
  }

  .strategy-desc {
    display: none !important;
  }
}

/* Tablet & Mobile Layout (max-width: 960px) */
@media (max-width: 960px) {
  .container {
    padding: 0 1rem;
  }

  .main-grid {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    gap: 1.15rem;
  }

  .main-grid > * {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }

  .research-card-grid {
    grid-template-columns: 1fr;
  }
}

/* Phones & Medium Tablets (max-width: 768px) */
@media (max-width: 768px) {
  /* Prevent iOS Safari font auto-zoom on input focus */
  input[type="number"],
  input[type="text"],
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Prevent side-to-side page sway while keeping content zoomed out */
  html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .container {
    padding: 0 0.5rem;
    width: 100%;
    box-sizing: border-box;
  }

  .intro-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 0.85rem;
    box-sizing: border-box;
  }

  /* Standard Cards have identical safe padding and matching widths on mobile */
  .intro-card,
  .controls-panel,
  .assumptions-card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 0.85rem 0.75rem;
    border-radius: 10px;
  }

  /* Full-Bleed Edge-to-Edge Cards on Mobile:
     1. 4-Strategy Retirement Income Comparison (.chart-card)
     2. 16-Country Synchronized Stress Test (.stress-test-card)
     3. 16 Developed Countries Historical Returns (.countries-card)
     4. Opportunity Cost Tax Table (.penalty-card)
  */
  .main-grid > .results-top-area > .chart-card,
  .chart-card,
  .main-grid > .stress-test-card,
  .stress-test-card,
  .countries-container > .card,
  .countries-card,
  .penalty-card {
    margin-left: -0.5rem !important;
    margin-right: -0.5rem !important;
    width: calc(100% + 1rem) !important;
    max-width: calc(100% + 1rem) !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 0.85rem 0 0.85rem 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-radius: 0 !important;
  }

  .penalty-card > h2,
  .penalty-card > p {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  .penalty-card > .highlight-banner {
    margin-left: 0.75rem !important;
    margin-right: 0.75rem !important;
  }

  .chart-card .card-header,
  .stress-test-card .card-header,
  .countries-container > .card .card-header,
  .countries-card .card-header {
    padding: 0 0.75rem 0.45rem 0.75rem !important;
  }

  .chart-card .canvas-wrap,
  .stress-test-card .canvas-wrap,
  .countries-container > .card .canvas-wrap,
  .countries-card .canvas-wrap {
    margin: 0 !important;
    padding: 0.35rem 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    border-left: none !important;
    border-right: none !important;
    border-radius: 0 !important;
    background: var(--surface-alt);
    overflow-x: hidden !important;
  }

  /* Full-bleed responsive canvases with auto height preserving exact aspect ratio */
  .chart-card #scenarioCanvas {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    aspect-ratio: 820 / 310 !important;
    display: block !important;
  }

  .stress-test-card #bootstrapCanvas {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    aspect-ratio: 820 / 320 !important;
    display: block !important;
  }

  .countries-container #countriesCanvas,
  .countries-card #countriesCanvas {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    aspect-ratio: 1180 / 390 !important;
    display: block !important;
  }

  .countries-container > .card .currency-callout,
  .countries-card .currency-callout {
    margin: 0.65rem 0.75rem !important;
  }

  .countries-container > .card .legend-row,
  .countries-card .legend-row {
    padding: 0.5rem 0.75rem 0.25rem 0.75rem !important;
    margin: 0 !important;
  }

  /* Table wraps inside edge-to-edge cards swipe across 100% width cleanly */
  .chart-card .table-wrap,
  .countries-container > .card .table-wrap,
  .countries-card .table-wrap,
  .penalty-card .table-wrap {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 0 !important;
  }

  .results-top-area {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
  }

  /* Prevent CSS Grid track auto-expansion from child tables */
  .main-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    gap: 1.15rem;
  }

  .main-grid > * {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .topbar {
    position: sticky;
    top: 0;
    padding: 0.45rem 0 0.55rem 0;
    margin-bottom: 0.85rem;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .topbar-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    width: 100%;
  }

  .topbar-brand {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
  }

  .topbar h1 {
    font-size: clamp(1rem, 4vw, 1.25rem);
    line-height: 1.22;
    text-align: center;
    width: 100%;
    margin: 0 auto;
  }

  /* Full-width 5-tab grid matching the exact width of the card below */
  .nav-and-status {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
  }

  .tab-nav {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    width: 100% !important;
    box-sizing: border-box;
    padding: 2px;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: visible;
  }

  .tab-btn {
    width: 100% !important;
    min-height: 38px;
    padding: 0.35rem 0.1rem;
    font-size: clamp(0.65rem, 2.25vw, 0.78rem);
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: normal;
    word-break: normal;
    border-radius: 6px;
    box-sizing: border-box;
    touch-action: manipulation;
  }

  .topbar-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0.5rem;
  }

  .badge {
    font-size: 0.72rem;
    padding: 0.25rem 0.55rem;
    max-width: calc(100% - 95px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .theme-toggle-btn {
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
    min-height: 32px;
    min-width: 75px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
  }

  /* Canvas elements zoomed out by default to fit screen width with 0 horizontal scroll */
  canvas {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    display: block !important;
  }

  /* Touch-friendly controls & form elements */
  .control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.15rem 0.4rem;
    font-size: 0.82rem;
    margin-bottom: 0.25rem;
  }

  .control-header label {
    flex: 1 1 auto;
    font-size: 0.8rem;
  }

  .control-header .val {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--accent);
    text-align: right;
    flex-shrink: 0;
    margin-left: auto;
    white-space: nowrap;
  }

  .inline-money-wrap {
    padding: 0.18rem 0.4rem;
  }

  .inline-money-input {
    width: 4.8rem;
    line-height: 1.15;
  }

  .preset-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
  }

  .preset-btn {
    min-height: 38px;
    font-size: 0.79rem;
    padding: 0.45rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    touch-action: manipulation;
  }

  .toggle-row {
    min-height: 40px;
    padding: 0.25rem 0;
    gap: 0.65rem;
  }

  .toggle-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
    cursor: pointer;
  }

  .btn-primary {
    min-height: 44px;
    font-size: 0.92rem;
    touch-action: manipulation;
  }

  /* KPI Cards: 2x2 grid squished to fit screen without horizontal overflow */
  .kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .kpi-card {
    padding: 0.65rem 0.5rem !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden;
  }

  .kpi-value {
    font-size: clamp(1.02rem, 3.8vw, 1.25rem) !important;
    line-height: 1.15;
    margin: 0.15rem 0 !important;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .kpi-label {
    font-size: 0.7rem !important;
    line-height: 1.25 !important;
    margin-bottom: 0.2rem;
    white-space: normal !important;
    word-break: normal;
  }

  .kpi-sub {
    font-size: 0.68rem !important;
    line-height: 1.25 !important;
    margin-top: 0.2rem;
    white-space: normal !important;
  }

  /* Wide tables maintain horizontal scroll without affecting page width */
  .table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    position: relative;
    border-radius: 8px;
    margin-left: -0.45rem !important;
    margin-right: -0.45rem !important;
    width: calc(100% + 0.9rem) !important;
    max-width: calc(100% + 0.9rem) !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  /* Sticky First Columns on Mobile — moved tight to the left edge to maximize visible data area */
  .sortable-table th:first-child,
  .sortable-table td:first-child,
  .allocation-table th:first-child,
  .allocation-table td:first-child,
  #comparisonTable th:first-child,
  #comparisonTable td:first-child,
  .penalty-table th:first-child,
  .penalty-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
    box-shadow: 2px 0 5px -1px rgba(0, 0, 0, 0.25);
    padding-left: 0.12rem !important;
    padding-right: 0.25rem !important;
    text-align: left !important;
  }

  [data-theme="light"] .sortable-table th:first-child,
  [data-theme="light"] .sortable-table td:first-child,
  [data-theme="light"] .allocation-table th:first-child,
  [data-theme="light"] .allocation-table td:first-child,
  [data-theme="light"] #comparisonTable th:first-child,
  [data-theme="light"] #comparisonTable td:first-child,
  [data-theme="light"] .penalty-table th:first-child,
  [data-theme="light"] .penalty-table td:first-child {
    background: #ffffff;
    box-shadow: 2px 0 5px -1px rgba(15, 23, 42, 0.08);
  }

  /* 1. Simulator: Strategy column moved tight to left */
  #comparisonTable th:first-child,
  #comparisonTable td:first-child {
    min-width: 82px !important;
    max-width: 96px !important;
    width: 90px !important;
    font-size: 0.74rem !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
  }

  #comparisonTable th,
  #comparisonTable td {
    padding: 0.45rem 0.35rem !important;
    font-size: 0.75rem !important;
    white-space: nowrap !important;
  }

  /* 2. 16 Country Data: Country column moved tight to left */
  #countriesTable th:first-child,
  #countriesTable td:first-child {
    min-width: 72px !important;
    max-width: 86px !important;
    width: 80px !important;
    font-size: 0.73rem !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
  }

  #countriesTable th,
  #countriesTable td {
    padding: 0.38rem 0.32rem !important;
    font-size: 0.74rem !important;
    white-space: nowrap !important;
  }

  /* 3. U.S. vs Int'l: Portfolio Allocation moved tight to left, card winner badges hidden */
  .allocation-table th:first-child,
  .allocation-table td:first-child {
    min-width: 90px !important;
    max-width: 104px !important;
    width: 96px !important;
    font-size: 0.72rem !important;
    line-height: 1.2 !important;
  }

  .allocation-table th:first-child {
    white-space: normal !important;
    word-break: normal;
  }

  .allocation-table td:first-child {
    white-space: nowrap !important;
  }

  .allocation-table th,
  .allocation-table td {
    padding: 0.45rem 0.35rem !important;
    font-size: 0.75rem !important;
    white-space: nowrap !important;
  }

  /* On mobile, remove card-winner row colors on 60/40, 80/20, and 100/0 and make sticky cells 100% solid/opaque */
  .row-winner-6040,
  .row-winner-8020,
  .row-winner-100 {
    background: transparent !important;
    border-left: none !important;
  }

  .row-winner-6040 td:first-child,
  .row-winner-8020 td:first-child,
  .row-winner-100 td:first-child {
    background: var(--surface) !important;
  }

  .penalty-table {
    table-layout: fixed !important;
    width: calc(456px + 100vw) !important;
  }

  .penalty-table th:first-child,
  .penalty-table td:first-child {
    min-width: 94px !important;
    max-width: 94px !important;
    width: 94px !important;
    font-size: 0.73rem !important;
    line-height: 1.2 !important;
    padding-left: 0.12rem !important;
    padding-right: 0.25rem !important;
    white-space: normal !important;
  }

  .penalty-table .sublabel {
    font-size: 0.65rem !important;
    line-height: 1.18 !important;
    margin-top: 0.12rem;
    white-space: normal !important;
  }

  .penalty-table th:nth-child(2),
  .penalty-table td:nth-child(2) {
    width: 118px !important;
    padding: 0.4rem 0.35rem !important;
    font-size: 0.74rem !important;
  }

  .penalty-table th:nth-child(3),
  .penalty-table td:nth-child(3) {
    width: 158px !important;
    padding: 0.4rem 0.35rem !important;
    font-size: 0.74rem !important;
  }

  .penalty-table th:nth-child(4),
  .penalty-table td:nth-child(4) {
    width: 190px !important;
    padding: 0.4rem 0.35rem !important;
    font-size: 0.74rem !important;
  }

  .penalty-table th:nth-child(2),
  .penalty-table th:nth-child(3),
  .penalty-table th:nth-child(4) {
    white-space: normal !important;
  }

  .penalty-table th:nth-child(5),
  .penalty-table td:nth-child(5) {
    min-width: calc(100vw - 104px) !important;
    width: calc(100vw - 104px) !important;
    max-width: calc(100vw - 104px) !important;
    font-size: 0.75rem !important;
    line-height: 1.4 !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    padding: 0.5rem 0.55rem !important;
    vertical-align: top !important;
  }

  /* Currency switch in 16-Country view */
  .currency-toggle-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }

  .currency-toggle-group .curr-btn {
    width: 100%;
    min-height: 38px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  /* Legend wrapping on mobile */
  .legend-row {
    flex-wrap: wrap;
    gap: 0.45rem 0.75rem;
    font-size: 0.78rem;
  }

  /* 2x3 Grid below 16-Country Stress Test: Best 10%, Typical, Worst 10% comparing Your Mix and TDF */
  .legend-row-compare,
  #bootstrapLegend {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 0.2rem !important;
    margin-top: 0.75rem !important;
    padding: 0.75rem 0 0.35rem 0 !important;
    border-top: 1px solid var(--border);
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .legend-group {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 0.65rem 0.25rem !important;
    min-width: 0 !important;
    min-height: 86px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    align-items: center !important;
    box-sizing: border-box !important;
    text-align: center;
  }

  #bootstrapLegend .legend-group:first-child {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
  }

  #bootstrapLegend .legend-group:last-child {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
  }

  .desktop-only-paren {
    display: none !important;
  }

  .legend-group-title {
    display: block;
    font-size: clamp(0.64rem, 2.5vw, 0.74rem) !important;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text) !important;
    font-weight: 700;
    margin-bottom: 0.35rem;
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.2 !important;
  }

  .legend-items {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.32rem !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
  }

  .legend-items span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    white-space: nowrap;
    font-size: 0.82rem !important;
    color: var(--muted);
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .legend-items span strong {
    color: var(--text);
    font-weight: 800;
    font-size: 0.86rem !important;
  }

  .dot {
    width: 8px !important;
    height: 8px !important;
    min-width: 8px !important;
    border-radius: 50%;
    margin-right: 0.15rem !important;
    flex-shrink: 0;
  }

  /* U.S. vs Int'l Winner Summary: 2x6 Grid of 12 Cards shifted flush against the card borders */
  .winner-kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.38rem !important;
    margin-left: -0.75rem !important;
    margin-right: -0.75rem !important;
    width: calc(100% + 1.5rem) !important;
    max-width: calc(100% + 1.5rem) !important;
    box-sizing: border-box !important;
  }

  .winner-card {
    padding: 0.55rem 0.42rem !important;
    border-radius: 9px;
    min-width: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  .winner-card-top {
    gap: 0.2rem !important;
    margin-bottom: 0.35rem !important;
    min-width: 0 !important;
  }

  .winner-category {
    font-size: 0.62rem !important;
    line-height: 1.2 !important;
    white-space: normal !important;
    word-break: break-word !important;
  }

  .winner-badge {
    font-size: clamp(0.66rem, 2.2vw, 0.74rem) !important;
    padding: 0.12rem 0.32rem !important;
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.2 !important;
    display: inline-block;
  }

  .winner-metrics {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    padding: 0.32rem 0.32rem !important;
    gap: 0.22rem !important;
    margin-bottom: 0.32rem !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .winner-metric {
    min-width: 0 !important;
    overflow: hidden;
  }

  .metric-label {
    font-size: 0.58rem !important;
    line-height: 1.15 !important;
    white-space: normal !important;
    word-break: break-word !important;
  }

  .metric-val {
    font-size: clamp(0.70rem, 2.4vw, 0.80rem) !important;
    font-weight: 700;
    line-height: 1.2 !important;
    word-break: break-word !important;
  }

  .metric-sub {
    font-size: 0.58rem !important;
    line-height: 1.15 !important;
    word-break: break-word !important;
  }

  .winner-metrics-row {
    grid-column: span 2 !important;
    padding-top: 0.25rem !important;
    margin-top: 0.08rem !important;
    min-width: 0 !important;
    font-size: 0.62rem !important;
  }

  .winner-caption {
    font-size: 0.65rem !important;
    line-height: 1.28 !important;
    margin-top: 0.3rem !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
  }

  /* Research & Data: 2x3 Grid of 6 Cards */
  .card-stat-grid-2x3 {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.55rem;
    margin-top: 0.75rem;
  }

  .card-stat-box {
    padding: 0.65rem 0.55rem;
  }

  .card-stat-box .stat-num {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 0.2rem;
  }

  .card-stat-box .stat-label {
    font-size: 0.72rem;
    line-height: 1.3;
  }

  /* Resource cards: 2x2 grid */
  .research-resources-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.55rem;
  }

  .resource-card {
    padding: 0.75rem 0.65rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  .resource-card h4 {
    font-size: 0.82rem;
    line-height: 1.25;
    margin-bottom: 0.35rem;
  }

  .resource-card .resource-desc {
    font-size: 0.71rem;
    line-height: 1.35;
    margin-bottom: 0.55rem;
  }

  .resource-card .research-btn {
    font-size: 0.74rem;
    padding: 0.38rem 0.5rem;
    width: 100%;
    justify-content: center;
  }

  .fund-choice-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
}

/* Small Phones (max-width: 540px) */
@media (max-width: 540px) {
  .topbar h1 {
    font-size: 0.98rem;
    text-align: center;
  }

  /* Date range input row */
  .date-range-inline {
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .date-number-input {
    width: 4.5rem;
    max-width: 72px;
    padding: 0.35rem 0.2rem;
  }

  .date-reset-btn {
    padding: 0.35rem 0.65rem;
    min-height: 34px;
  }

  .research-btn {
    width: 100%;
    justify-content: center;
  }
}
