/* Load after styles.css. Theme choices and palette remain independent of locale. */
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
#theme-select {
  font: inherit;
  font-size: 11px;
  min-width: 83px;
  height: 31px;
  padding: 5px 8px;
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
}
#theme-select:focus-visible { outline: 3px solid #46a58d; outline-offset: 3px; }

html[data-theme="dark"] {
  --ink: #e5f3eb;
  --text: #dce8e3;
  --muted: #a9beb2;
  --line: #32483f;
  --bg: #111c1b;
  --white: #172522;
  --green: #91d7ad;
  --mint: #355f48;
  --pale: #253d30;
  --navy: #c5e2dd;
  --amber: #e4bb79;
  --theme-surface-raised: #1f302c;
  --theme-accent: #a2dfb9;
  --theme-faint: #93aa9c;
  background: var(--bg);
  color: var(--text);
}
html[data-theme="dark"] body { background: var(--bg); }
html[data-theme="dark"] :is(.sidebar, .kpi, .period-kpis, .panel, .technical-details, .funding-card) {
  background: var(--white);
  border-color: var(--line);
}
html[data-theme="dark"] .topbar { background: #14211f; }
html[data-theme="dark"] .brand-icon { background: #c2e8cf; color: #1a3b29; }
html[data-theme="dark"] :is(.brand small, .workspace-label, .independent, .sidebar-note, .sidebar-note p, .sidebar-note a) { color: var(--muted); }
html[data-theme="dark"] .sidebar nav a { color: #b2c6bb; }
html[data-theme="dark"] .sidebar nav a:hover { background: #22362d; }
html[data-theme="dark"] .sidebar nav a.active { background: #2a4735; color: #c5f1d2; }
html[data-theme="dark"] :is(.breadcrumb, .breadcrumb span, .text-link, .eyebrow, .section-overline) { color: var(--muted); }
html[data-theme="dark"] .breadcrumb strong { color: #c6d9ce; }
html[data-theme="dark"] :is(.network-pill, .outline-pill, .button, .pagination button) {
  color: #badcc5;
  background: var(--white);
  border-color: #40594a;
}
html[data-theme="dark"] :is(.button:hover, .pagination button:not(:disabled):hover) { background: var(--pale); }
html[data-theme="dark"] .tiny-dot { background: #95c9a2; }
html[data-theme="dark"] .status-dot { background: #9cdaad; }
html[data-theme="dark"] .snapshot-status.partial { color: #e3be85; }
html[data-theme="dark"] .snapshot-status.partial .status-dot { background: #e3be85; }
html[data-theme="dark"] :is(.kpi-note, .panel-heading p, .chart-footer, .period-kpi-foot, .table-heading p, .section-title-row p, .subtle, .snapshot-status, .window-label, .table-footer, .distribution-row, .methodology dd, .provenance dt, .data-notice, .details-body p, .lifecycle-body p, .period-kpi-label, .legend, .empty-message, .rpc-note) { color: var(--muted); }
html[data-theme="dark"] .kpi:first-child { background: #213b2c; border-color: #3c5d46; }
html[data-theme="dark"] .kpi-top { color: #b2c9bb; }
html[data-theme="dark"] .kpi-info { color: #b6d0c0; border-color: #6b8976; }
html[data-theme="dark"] :is(.kpi-value, .period-kpi-value, .revenue-total) { color: #d0eed9; }
html[data-theme="dark"] :is(.kpi-note strong, .distribution-count, .lifecycle-line strong) { color: #b4d9bf; }
html[data-theme="dark"] .period-control { background: #14231c; border-color: var(--line); }
html[data-theme="dark"] .period-control button { color: #b5c9bb; }
html[data-theme="dark"] .period-control button.selected { background: #385b43; color: #e2f5e6; box-shadow: none; }
html[data-theme="dark"] .change { color: #b3e2b6; background: #29452e; }
html[data-theme="dark"] .change.negative { color: #f0c891; background: #433522; }
html[data-theme="dark"] .change.neutral { color: #becfc1; background: #2c3c31; }
html[data-theme="dark"] :is(.chart-footer, .lifecycle-line, th, td, .tier-registration-counts, .recipient-row) { border-color: var(--line); }
html[data-theme="dark"] .chart-host svg text { fill: #a9beb2; }
html[data-theme="dark"] .chart-host svg text[style] { fill: #a2dfb9 !important; }
html[data-theme="dark"] .gridline { stroke: #34483c; }
html[data-theme="dark"] .chart-bar { fill: #80b58e; }
html[data-theme="dark"] :is(.chart-bar:hover, .chart-bar:focus) { fill: #c3e9ca; }
html[data-theme="dark"] .chart-bar:focus-visible { stroke: #e1f8d5; stroke-width: 2; }
html[data-theme="dark"] .chart-host svg polyline { stroke: #a2dfb9; }
html[data-theme="dark"] .chart-host svg circle { fill: #a2dfb9; }
html[data-theme="dark"] #area-fill stop[offset="0"] { stop-color: #77b68b; stop-opacity: .3; }
html[data-theme="dark"] #area-fill stop[offset="1"] { stop-color: #77b68b; stop-opacity: .02; }
html[data-theme="dark"] .line-key { background: #a2dfb9; }
html[data-theme="dark"] .legend i { background: #80b58e; }
html[data-theme="dark"] .bar-track { background: #2a3e30; }
html[data-theme="dark"] .bar-fill { background: #80b58e; }
html[data-theme="dark"] .panel-icon { color: #b5cdb9; }
html[data-theme="dark"] .lifecycle-line { color: #b1c7b7; }
html[data-theme="dark"] .lifecycle-line .amber { background: #dfb679; }
html[data-theme="dark"] .lifecycle-line .gray { background: #a2afa6; }
html[data-theme="dark"] .search-box { color: var(--muted); background: #14211b; }
html[data-theme="dark"] .search-box input { color: #dce8e3; }
html[data-theme="dark"] .search-box input::placeholder { color: #a2b6a7; }
html[data-theme="dark"] .search-box:focus-within { border-color: #9ccaaa; box-shadow: 0 0 0 2px #45614c; }
html[data-theme="dark"] th { color: #b9ccbc; background: #1d2d24; }
html[data-theme="dark"] td { color: #b4cbb9; }
html[data-theme="dark"] td:first-child { color: #c3e5ca; }
html[data-theme="dark"] :is(.name-dot, .table-secondary) { color: #a6bfab; }
html[data-theme="dark"] .table-link { color: #a9d6b3; }
html[data-theme="dark"] :is(.methodology dt, .provenance dd, .technical-details summary, .details-body h4, .sources a, footer a) { color: #b3d6ba; }
html[data-theme="dark"] :is(.sources > span, footer, footer strong, .footer-divider) { color: #a4b9a9; }
html[data-theme="dark"] :is(.chart-tooltip, #toast) { color: #12291d; background: #d5efdb; box-shadow: 0 5px 22px #0005; }
html[data-theme="dark"] .error-state { color: #f1d5a7; background: #322b20; border-color: #826b42; }
html[data-theme="dark"] .skip { color: #13251b; background: #d5efdb; }
html[data-theme="dark"] .funding-card:hover { border-color: #7da78a; background: #21372a; }
html[data-theme="dark"] :is(.funding-label, .funding-label > span, .funding-distinct, .funding-description, .scope-note, .revenue-footnote, .revenue-heading > span, .revenue-total > span, .revenue-breakdown, .tier-registration-counts, .recipient-row p, .recipient-amount small, .recipient-evidence, .table-filters label, .filter-note) { color: var(--muted); }
html[data-theme="dark"] :is(.revenue-footnote strong, .revenue-breakdown dd, .tier-filter-link, .recipient-row strong, .recipient-amount, .recipient-evidence a) { color: #b3dbbb; }
html[data-theme="dark"] .recipient-address { color: #b9e1bf; background: #1d3024; border-color: #3c5542; }
html[data-theme="dark"] .recipient-address:hover { background: #2a4531; }
html[data-theme="dark"] .filter-chart-row:hover { background: #253c2c; }
html[data-theme="dark"] .filter-chart-row:hover .bar-fill { background: #c3e9ca; }
html[data-theme="dark"] .table-filters select { color: #c4ddca; background: #17271e; border-color: #49634e; }
html[data-theme="dark"] .filter-reset { color: #acc5b0; }
html[data-theme="dark"] .filter-reset:hover { color: #e0f2e3; }
html[data-theme="dark"] .payment-badge { color: #bae6b7; background: #2a432a; }
html[data-theme="dark"] .payment-badge.free { color: #d8ddba; background: #373e2a; }
html[data-theme="dark"] .payment-badge.unknown { color: #efcb91; background: #443620; }
html[data-theme="dark"] :is(button, a, input, select, summary, [tabindex]):focus-visible { outline-color: #b5edc7; }

@media (max-width: 480px) {
  #theme-select { min-width: 73px; font-size: 10px; padding: 5px 6px; }
}
@media print {
  #theme-select { display: none; }
}
