/* ==========================================================================
   Yields — Official U.S. Interest Rates Dashboard
   Responsive, accessible financial UI with Light & Dark themes
   ========================================================================== */

:root,
[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --bg-header: #ffffff;
  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --accent-primary: #0284c7;
  --accent-primary-hover: #0369a1;
  --accent-subtle: #e0f2fe;
  --accent-text: #075985;

  --positive-bg: #dcfce7;
  --positive-text: #166534;
  --negative-bg: #fee2e2;
  --negative-text: #991b1b;
  --neutral-bg: #f1f5f9;
  --neutral-text: #475569;

  --warning-bg: #fef9c3;
  --warning-border: #fde047;
  --warning-text: #854d0e;

  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --error-text: #991b1b;

  --info-bg: #f0f9ff;
  --info-border: #bae6fd;
  --info-text: #0c4a6e;

  --chart-grid: #e2e8f0;
  --chart-axis: #94a3b8;
  --chart-zero: #64748b;

  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  --focus-ring: 0 0 0 3px rgba(2, 132, 199, 0.35);
}

[data-theme="dark"] {
  --bg-page: #0b1120;
  --bg-surface: #111827;
  --bg-surface-subtle: #1e293b;
  --bg-header: #0f172a;
  --border-color: #1e293b;
  --border-strong: #334155;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --accent-primary: #38bdf8;
  --accent-primary-hover: #7dd3fc;
  --accent-subtle: rgba(56, 189, 248, 0.14);
  --accent-text: #7dd3fc;

  --positive-bg: rgba(34, 197, 94, 0.16);
  --positive-text: #86efac;
  --negative-bg: rgba(239, 68, 68, 0.16);
  --negative-text: #fca5a5;
  --neutral-bg: #1e293b;
  --neutral-text: #cbd5e1;

  --warning-bg: rgba(234, 179, 8, 0.14);
  --warning-border: rgba(234, 179, 8, 0.4);
  --warning-text: #fde047;

  --error-bg: rgba(239, 68, 68, 0.15);
  --error-border: rgba(239, 68, 68, 0.45);
  --error-text: #fca5a5;

  --info-bg: rgba(56, 189, 248, 0.12);
  --info-border: rgba(56, 189, 248, 0.35);
  --info-text: #bae6fd;

  --chart-grid: #1e293b;
  --chart-axis: #64748b;
  --chart-zero: #94a3b8;

  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 16px -3px rgba(0, 0, 0, 0.5);
  --focus-ring: 0 0 0 3px rgba(56, 189, 248, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
}

code,
.num-col,
.tabular-nums {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875em;
  background: var(--bg-surface-subtle);
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
}

/* Skip link for keyboard accessibility */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 1000;
  background: var(--accent-primary);
  color: #ffffff;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 0.75rem;
  outline: none;
  box-shadow: var(--focus-ring);
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header & Metadata Bar */
.site-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.15rem;
  padding-bottom: 0.9rem;
}

.brand-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
}

.site-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.pub-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent-subtle);
  color: var(--accent-text);
  border: 1px solid var(--border-color);
}

.site-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.header-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.staleness-control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.control-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.select-input {
  appearance: auto;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
}

.select-input:focus-visible,
.btn:focus-visible,
.chart-svg:focus-visible,
.curve-point:focus-visible,
summary:focus-visible,
input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.curve-point:focus-visible {
  r: 7px;
  stroke-width: 3.5px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.8rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  background: var(--bg-surface-subtle);
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

[data-theme="dark"] .btn-primary {
  color: #0b1120;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
}

.theme-icon-dark {
  display: none;
}

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

[data-theme="dark"] .theme-icon-dark {
  display: inline;
}

.meta-bar {
  border-top: 1px solid var(--border-color);
  padding-top: 0.65rem;
  padding-bottom: 0.75rem;
  font-size: 0.8125rem;
}

.meta-items {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.meta-label {
  color: var(--text-muted);
}

.meta-value {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.meta-divider {
  color: var(--border-strong);
}

.status-pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.48rem;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
}

.status-pill-ok {
  background: var(--positive-bg);
  color: var(--positive-text);
}

.status-pill-error {
  background: var(--error-bg);
  color: var(--error-text);
}

.reload-note {
  margin: 0.4rem 0 0;
  color: var(--text-muted);
  font-size: 0.76rem;
}

/* Main Content & Alerts */
.main-content {
  padding-top: 1.5rem;
  padding-bottom: 3rem;
}

.alerts-container {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.alert-banner {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.alert-warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning-text);
}

.alert-error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

.alert-info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-text);
}

/* Sections */
.section {
  margin-bottom: 2.5rem;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.section-desc {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Benchmark Rate Cards */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 0.9rem;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.55rem;
}

.skeleton-card {
  min-height: 140px;
  color: var(--text-muted);
  font-size: 0.875rem;
  align-items: center;
  justify-content: center;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.4rem;
}

.card-series-label {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.card-source-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--bg-surface-subtle);
  color: var(--text-muted);
}

.card-rate-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.15rem 0;
}

.card-rate-value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}

.bps-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.775rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bps-up {
  background: var(--positive-bg);
  color: var(--positive-text);
}

.bps-down {
  background: var(--negative-bg);
  color: var(--negative-text);
}

.bps-flat {
  background: var(--neutral-bg);
  color: var(--neutral-text);
}

.card-meta {
  border-top: 1px solid var(--border-color);
  padding-top: 0.45rem;
  font-size: 0.76rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

/* Callout Row (FOMC Target Range & 10Y-2Y Spread) */
.callout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.callout-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.callout-eyebrow {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-primary);
}

.callout-title {
  margin: 0.15rem 0 0.65rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.callout-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.callout-metric-group {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
}

.callout-primary-value {
  font-size: 1.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.callout-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.callout-explanation {
  margin: 0;
  font-size: 0.825rem;
  color: var(--text-secondary);
}

/* Panels & SVG Charts */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.15rem;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.panel-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.panel-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1.25rem;
  margin-bottom: 0.65rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
}

.legend-swatch {
  width: 14px;
  height: 4px;
  border-radius: 2px;
  display: inline-block;
}

.legend-swatch-dashed {
  height: 0;
  border-top: 2.5px dashed currentColor;
  background: transparent;
}

.svg-chart-wrapper {
  position: relative;
  width: 100%;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
  border-radius: 6px;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 20;
  background: var(--bg-header);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-size: 0.78rem;
  box-shadow: var(--shadow-md);
  min-width: 165px;
  max-width: 280px;
}

.tooltip-title {
  font-weight: 700;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.2rem;
}

.tooltip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.1rem 0;
  font-variant-numeric: tabular-nums;
}

/* Data Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th,
.data-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-surface-subtle);
}

.data-table th.num-col,
.data-table td.num-col {
  text-align: right;
}

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

/* Historical Explorer Controls */
.range-btn-group {
  display: inline-flex;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
}

.range-btn {
  border: none;
  border-right: 1px solid var(--border-strong);
  border-radius: 0;
  padding: 0.4rem 0.75rem;
}

.range-btn:last-child {
  border-right: none;
}

.range-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
}

[data-theme="dark"] .range-btn.active {
  color: #0b1120;
}

.series-selector-fieldset {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  margin: 0 0 0.9rem;
}

.series-selector-legend {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 0 0.35rem;
}

.series-checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.series-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  user-select: none;
}

.series-checkbox-label:hover {
  background: var(--bg-surface-subtle);
}

.series-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.history-table-details {
  margin-top: 0.85rem;
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
}

.history-table-summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-primary);
  padding: 0.25rem 0;
}

.history-table-scroll {
  max-height: 360px;
  overflow-y: auto;
  margin-top: 0.65rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

/* Rate Definitions & Attribution */
.definitions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1rem;
}

.info-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.info-card-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
}

.info-card-text {
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.info-links {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.825rem;
}

.info-links li {
  margin-bottom: 0.25rem;
}

a {
  color: var(--accent-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-primary-hover);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-color);
  background: var(--bg-header);
  padding: 1.5rem 0;
  font-size: 0.825rem;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.footer-text,
.footer-links {
  margin: 0;
}

@media (max-width: 720px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  }
}
