/* Loaded last. Explicit light leaves the existing Ströer light UI unchanged. */
[data-theme-cycle] [data-theme-icon] {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --color-text: #edf3ff;
  --color-brand-primary: #cbdfff;
  --color-text-muted: #b3c2d8;
  --color-muted: #b3c2d8;
  --color-text-disabled: #93a6c2;
  --color-disabled: #93a6c2;
  --surface-page: #0c1423;
  --surface-panel: #141f31;
  --surface-muted: #1b2a40;
  --surface-selected: #273d5c;
  --surface-hover: #203249;
  --surface-app: var(--surface-page);
  --surface-card: var(--surface-panel);
  --border-subtle: #34455e;
  --border-strong: #5a7193;
  --line: var(--border-subtle);
  --line-soft: #2a3a51;
  --focus-ring: #83b5ff;
  --color-action-primary-hover: #315f98;
  --status-available-bg: #17382e;
  --status-available-text: #b8e4cd;
  --status-available-border: #34634f;
  --status-limited-bg: #3c2d18;
  --status-limited-text: #ffdc9d;
  --status-limited-border: #795c31;
  --status-full-bg: #57391d;
  --status-full-text: #ffe0a8;
  --status-full-border: #a87435;
  --status-blocked-bg: repeating-linear-gradient(135deg,var(--surface-muted) 0 4px,var(--theme-blocked-stripe) 4px 5px);
  --status-unknown-bg: #1a2639;
  --status-unknown-text: #b6c8e2;
  --status-unknown-border: #536785;
  --theme-row-alternate: #172439;
  --theme-blocked-stripe: #283b54;
  --theme-skeleton-low: #223249;
  --theme-skeleton-high: #344962;
  color: var(--color-text);
  background: var(--surface-page);
}

:root[data-theme="dark"] body { color: var(--color-text); background: var(--surface-page); }
:root[data-theme="dark"] :is(button, input, select, textarea) { color: var(--color-text); }
:root[data-theme="dark"] :is(input, select, textarea) { accent-color: var(--focus-ring); }
:root[data-theme="dark"] :is(input, textarea)::placeholder { color: var(--color-text-disabled); opacity: 1; }
:root[data-theme="dark"] :focus-visible { outline-color: var(--focus-ring); box-shadow: 0 0 0 4px rgb(131 181 255 / .16); }
:root[data-theme="dark"] :is(.app-header, .topbar, .table-panel, .table-footer, .app-footer, .filter-panel, .cloud-access-card, .callback-panel) {
  background: var(--surface-panel);
  border-color: var(--border-subtle);
}
:root[data-theme="dark"] :is(.brand, .brand-lockup, .report-icon, .access-state, .cloud-access-card #access-state, .mobile-period-picker select) {
  color: var(--color-brand-primary);
}
:root[data-theme="dark"] :is(.brand img, .brand-logo, .auth-loading img) { filter: brightness(0) invert(1); }
:root[data-theme="dark"] :is(.secondary-button, .scenario-button, .search-control, .combo-field, .filter-control select, .matrix-mobile-tools select, .pagination-controls select, .availability-month select) {
  background: var(--surface-panel);
  border-color: var(--border-strong);
}
:root[data-theme="dark"] :is(.secondary-button:hover, .scenario-button:hover, .choice-row:hover) {
  background: var(--surface-hover);
  border-color: var(--focus-ring);
}
:root[data-theme="dark"] .primary-button { background: #234c7f; border-color: #4975a8; color: #fff; }
:root[data-theme="dark"] .primary-button:hover:not(:disabled) { background: var(--color-action-primary-hover); }
:root[data-theme="dark"] .primary-button:disabled { background: var(--surface-muted); border-color: var(--border-subtle); color: var(--color-text-disabled); }
:root[data-theme="dark"] :is(.icon-button:hover, .text-button:hover) { background: var(--surface-hover); }
:root[data-theme="dark"] .chip.is-active { color: var(--color-brand-primary); }
:root[data-theme="dark"] :is(.filter-count, .active-filter-count, .pagination-number.is-current) { background: #315f98; color: #fff; border-color: #4975a8; }
:root[data-theme="dark"] .search-control input { color: var(--color-text); }
:root[data-theme="dark"] [data-theme-select] { border-color: var(--border-strong); }

/* Opaque sticky cells prevent scrolled content bleeding through the dark head. */
:root[data-theme="dark"] .capacity-matrix :is(th, td) { border-color: var(--line-soft); }
:root[data-theme="dark"] .capacity-matrix td { background: var(--surface-panel); }
:root[data-theme="dark"] .capacity-matrix tbody tr:nth-child(even) td { background: var(--theme-row-alternate); }
:root[data-theme="dark"] .capacity-matrix tbody tr:hover td { background: var(--surface-hover); }
:root[data-theme="dark"] .capacity-matrix :is(thead th, th.site-col, .data-group-label, .year-group-label) {
  color: var(--color-brand-primary);
  background: var(--surface-muted);
}
:root[data-theme="dark"] .capacity-matrix .group-head th { color: var(--color-text-disabled); border-bottom-color: var(--border-subtle); }
:root[data-theme="dark"] .capacity-matrix th.month-col.is-active { background: var(--surface-selected); color: var(--color-brand-primary); }
:root[data-theme="dark"] .capacity-matrix .site-col { border-right-color: var(--border-strong); box-shadow: 4px 0 8px -5px rgb(0 0 0 / .7); }
:root[data-theme="dark"] .legend-swatch.blocked { background: repeating-linear-gradient(135deg,var(--surface-muted) 0 2px,var(--theme-blocked-stripe) 2px 4px); }
:root[data-theme="dark"] .slot-ratio span { opacity: .9; }
:root[data-theme="dark"] .cluster-a { color: #ffc0c6; background: #40282e; border-color: #87515a; }
:root[data-theme="dark"] .cluster-b { color: var(--status-limited-text); background: var(--status-limited-bg); border-color: var(--status-limited-border); }
:root[data-theme="dark"] .cluster-c { color: var(--status-available-text); background: var(--status-available-bg); border-color: var(--status-available-border); }
:root[data-theme="dark"] .cluster-other { color: #bddbff; background: #233b59; border-color: #476d9b; }
:root[data-theme="dark"] .mobile-switch button:is(.is-active, [aria-pressed="true"]) { color: var(--color-brand-primary); background: var(--surface-selected); }

/* Dialogs, popovers and the campaign sidecar retain their existing geometry. */
:root[data-theme="dark"] dialog { color: var(--color-text); background: var(--surface-page); border-color: var(--border-strong); box-shadow: 0 18px 70px rgb(0 0 0 / .5); }
:root[data-theme="dark"] dialog::backdrop { background: rgb(0 7 18 / .62); }
:root[data-theme="dark"] :is(.dialog-heading, .dialog-actions, .campaign-card, .location-facts dl, .choice-row, .empty-detail, .setup-panel) {
  color: var(--color-text);
  background: var(--surface-panel);
  border-color: var(--border-subtle);
}
:root[data-theme="dark"] .dialog-icon { color: var(--color-brand-primary); background: var(--surface-muted); border-color: var(--border-subtle); }
:root[data-theme="dark"] .dialog-heading::before { background: var(--border-strong); }
:root[data-theme="dark"] :is(.month-menu, .filter-options, .user-popover, .account-popover, .context-strip .quality-locations) {
  color: var(--color-text);
  background: var(--surface-panel);
  border-color: var(--border-strong);
  box-shadow: 0 8px 28px rgb(0 0 0 / .4);
}
:root[data-theme="dark"] .choice-row:hover { background: var(--surface-hover); }
:root[data-theme="dark"] .scenario-button.is-active { background: var(--surface-selected); }
:root[data-theme="dark"] .toast { color: #fff; background: #234c7f; border: 1px solid #4975a8; }
:root[data-theme="dark"] .export-error { color: #ffb8bd; }
:root[data-theme="dark"] .matrix-empty { background: rgb(12 20 35 / .92); }
:root[data-theme="dark"] .placeholder { background: var(--theme-skeleton-low); }
:root[data-theme="dark"] .placeholder.short { background: var(--theme-skeleton-high); }
:root[data-theme="dark"] .placeholder.slot { background: var(--surface-muted); border-color: var(--border-subtle); }
:root[data-theme="dark"] .skeleton-pulse { background-image: linear-gradient(100deg,var(--theme-skeleton-low) 10%,var(--theme-skeleton-high) 45%,var(--theme-skeleton-low) 75%); }

/* Icon choices keep the same persisted preference on every surface. */
.theme-control { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.theme-control > :is(label, span) { font-size: 11px; color: var(--color-text-muted,var(--color-muted)); }
.theme-choices { display: inline-flex; flex-shrink: 0; gap: 3px; padding: 3px; border: 1px solid var(--border-subtle); border-radius: 9px; background: var(--surface-muted); }
.theme-choices button { display: inline-grid; place-items: center; width: 40px; height: 36px; padding: 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--color-text-muted,var(--color-muted)); cursor: pointer; }
.theme-choices button:hover { color: var(--color-text); background: var(--surface-panel); }
.theme-choices button[aria-pressed="true"] { color: var(--color-text); background: var(--surface-panel); border-color: var(--border-strong); box-shadow: inset 0 -2px var(--brand-orange); }
.theme-choices svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
@media (pointer: coarse) { .theme-choices button { width: 44px; height: 40px; } }
@media (prefers-reduced-motion: reduce) {
  :root[data-theme="dark"] .skeleton-pulse { background: var(--theme-skeleton-low); }
}
