/* kf-dark.css — Karst Firewall 5.0 dark-theme patch layer
   ─────────────────────────────────────────────────────────────────────
   Metronic 8 ships a complete dark theme keyed on [data-bs-theme="dark"]
   (set on <html> by layouts/main.php). That already re-themes every
   standard Bootstrap / Metronic component: page background, cards,
   tables, forms, dropdowns, modals, buttons, the header and grayscale
   text utilities (.text-gray-900 → light, etc.).

   This file only patches the *custom* kf-* / page-specific surfaces that
   hardcode light colours and so would not flip on their own. Strategy:

     1. Re-map each subsystem's scoped design tokens to dark values — one
        block re-themes a whole screen (pyrowise, fwi-history, cockpit,
        incident form, redesign screens, …).
     2. Targeted overrides for the few structural surfaces that bypass
        those tokens with literal #fff / dark text.

   Loaded LAST in KfNavAsset so it wins over the page CSS it patches.
   Palette is aligned to Metronic's dark grayscale
   (--bs-gray-100 #1B1C22 surface, --bs-gray-200 #26272F border,
    --bs-gray-600/700 muted, --bs-gray-900 #F5F5F5 text). */

[data-bs-theme="dark"] {
  --kf-dark-surface:     #1b1c22;   /* elevated panel (= --bs-gray-100)   */
  --kf-dark-surface-alt: #22232b;   /* secondary fill                     */
  --kf-dark-border:      #2b2d37;   /* hairline (≈ --bs-gray-200)         */
  --kf-dark-ink:         #e8eaef;   /* primary text                       */
  --kf-dark-ink-soft:    #9a9cae;   /* muted text (= --bs-gray-700)       */
  --kf-dark-ink-fade:    #6b6e7c;   /* faint text                         */
}

/* ── PyroWISE simulation dashboard (.pw-dashboard) ──────────────────── */
[data-bs-theme="dark"] .pw-dashboard {
  --pw-surface:     var(--kf-dark-surface);
  --pw-surface-alt: var(--kf-dark-surface-alt);
  --pw-border:      var(--kf-dark-border);
  --pw-muted:       var(--kf-dark-ink-soft);
  color: var(--kf-dark-ink);
}
/* Form controls + buttons that hardcode white fills / dark text. */
[data-bs-theme="dark"] .pw-dashboard input,
[data-bs-theme="dark"] .pw-dashboard select,
[data-bs-theme="dark"] .pw-dashboard textarea,
[data-bs-theme="dark"] .pw-dashboard .pw-advanced-field input[type="number"],
[data-bs-theme="dark"] .pw-dashboard .pw-historical-modal__filters input[type="search"] {
  background: var(--kf-dark-surface-alt);
  color: var(--kf-dark-ink);
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pw-dashboard .pw-advanced__plus,
[data-bs-theme="dark"] .pw-dashboard .pw-location-search button,
[data-bs-theme="dark"] .pw-dashboard .pw-fullscreen-btn,
[data-bs-theme="dark"] .pw-dashboard .pw-overflow__menu,
[data-bs-theme="dark"] .pw-dashboard .pw-run-metadata,
[data-bs-theme="dark"] .pw-dashboard .pw-timeline,
[data-bs-theme="dark"] .pw-dashboard .pw-sticky-header,
[data-bs-theme="dark"] .pw-dashboard .pw-historical-modal__card,
[data-bs-theme="dark"] .pw-bookmark-modal__card,
[data-bs-theme="dark"] .pw-aoi-label {
  background: var(--kf-dark-surface);
  color: var(--kf-dark-ink);
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pw-dashboard .pw-head__metric-value,
[data-bs-theme="dark"] .pw-kbd-overlay__card h2 {
  color: var(--kf-dark-ink);
}

/* ── FWI history heatmap (.fwi-page) — invert the ink scale ─────────── */
[data-bs-theme="dark"] .fwi-page {
  --fwi-ink-900: #f5f5f5;
  --fwi-ink-700: #d5d7df;
  --fwi-ink-500: #9a9cae;
  --fwi-ink-300: #6b6e7c;
  --fwi-ink-200: #2b2d37;
  --fwi-ink-100: #22232b;
  --fwi-ink-50:  #1b1c22;
  --fwi-paper:   #1b1c22;
  --fwi-grid:        #2b2d37;
  --fwi-grid-strong: #363843;
}

/* ── Statistics/index FWI heatmap promoted into the cockpit ─────────── */
[data-bs-theme="dark"] .kf50-fwi-history {
  --kf-fwi-ink-900: #f5f5f5;
  --kf-fwi-ink-700: #d5d7df;
  --kf-fwi-ink-500: #9a9cae;
  --kf-fwi-ink-200: #2b2d37;
  --kf-fwi-ink-100: #22232b;
  --kf-fwi-ink-50:  #1b1c22;
}

/* ── Cockpit (.kf50-cockpit) — paper/page/ink already track --bs-* ──── */
[data-bs-theme="dark"] .kf50-cockpit {
  --kf-c-ink-soft:    var(--kf-dark-ink-soft);
  --kf-c-ink-fade:    var(--kf-dark-ink-fade);
  --kf-c-line:        rgba(255, 255, 255, 0.10);
  --kf-c-line-strong: rgba(255, 255, 255, 0.18);
  --kf-sk-bg:         rgba(255, 255, 255, 0.06);
  --kf-sk-shine:      rgba(255, 255, 255, 0.12);
}

/* Cockpit header chrome — the row of admin-only controls
   (language picker pill, Vista come role selector, Nascondi/Mostra
   "Widget senza dati" segmented control). All hardcoded light surfaces
   that vanished against the dark page; the operator reported "razni
   načini pogleda" (Vista come) unreadable. */
[data-bs-theme="dark"] .kf50-cockpit__lang {
    background: rgba(255, 255, 255, 0.08);
}
[data-bs-theme="dark"] .kf50-cockpit__lang-btn {
    color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .kf50-cockpit__lang-btn:hover {
    color: var(--kf-dark-ink);
    background: rgba(255, 255, 255, 0.12);
}
[data-bs-theme="dark"] .kf50-cockpit__lang-btn.is-current {
    background: var(--kf-dark-surface-alt);
    color: var(--kf-dark-ink);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
[data-bs-theme="dark"] .kf50-cockpit__viewas {
    background: var(--kf-dark-surface);
    border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .kf50-cockpit__viewas-label {
    color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .kf50-cockpit__viewas-select {
    color: var(--kf-dark-ink);
    background: transparent;
}
/* Native <option> elements inherit the page's color scheme via the
   select's color-scheme; force the dark variant so the open dropdown
   list itself uses the dark theme instead of the OS default white. */
[data-bs-theme="dark"] .kf50-cockpit__viewas-select,
[data-bs-theme="dark"] .kf50-cockpit__viewas-select option {
    color-scheme: dark;
    background-color: var(--kf-dark-surface);
}
[data-bs-theme="dark"] .kf50-cockpit__viewas-reset {
    color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .kf50-cockpit__empty-toggle {
    color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .kf50-empty-seg {
    background: var(--kf-dark-surface-alt);
    border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .kf50-empty-seg button {
    color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .kf50-empty-seg button.is-active {
    background: var(--kf-dark-surface);
    color: var(--kf-dark-ink);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

/* ── Incident report form (.wildfire-form-v2) ──────────────────────── */
[data-bs-theme="dark"] .wildfire-form-v2 {
  --color-surface:     var(--kf-dark-surface);
  --color-surface-alt: var(--kf-dark-surface-alt);
  --color-border:      rgba(255, 255, 255, 0.12);
  --color-muted:       var(--kf-dark-ink-soft);
  color: var(--kf-dark-ink);
}

/* ── Operator redesign shell + screens (.kf-redesign) ──────────────── */
[data-bs-theme="dark"] .kf-redesign {
  --ink:    var(--kf-dark-ink);
  --ink-2:  #c2c8c4;
  --muted:  var(--kf-dark-ink-soft);
  --faint:  var(--kf-dark-ink-fade);
  --line:   var(--kf-dark-border);
  --line-2: var(--kf-dark-surface-alt);
  --bg:     #15171c;
  --card:   var(--kf-dark-surface);
}
/* Command palette + explorer surfaces that hardcode #fff. */
[data-bs-theme="dark"] .kf-redesign .ql-pop,
[data-bs-theme="dark"] .kf-redesign .ql-recent-chip,
[data-bs-theme="dark"] .kf-redesign .wf-search input,
[data-bs-theme="dark"] .kf-redesign .wf-counter,
[data-bs-theme="dark"] .kf-redesign .map-legend,
[data-bs-theme="dark"] .kf-redesign .filter-chip {
  background: var(--kf-dark-surface);
  color: var(--kf-dark-ink);
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .kf-redesign .ql-kbd,
[data-bs-theme="dark"] .kf-redesign .wf-table th {
  background: var(--kf-dark-surface-alt);
  color: var(--kf-dark-ink-soft);
}

/* ── Weather statistics (.kf50-kpi / freshness chip / spinner) ─────── */
[data-bs-theme="dark"] .kf50-kpi,
[data-bs-theme="dark"] .kf50-ws-freshness {
  background: var(--kf-dark-surface);
  color: var(--kf-dark-ink);
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .chart-spinner {
  background: rgba(27, 28, 34, 0.72);
}

/* ── Weather statistics (full coverage) — KPI labels / values / sub / chart frames */
[data-bs-theme="dark"] .kf50-fwi-cell {
  color: var(--kf-dark-ink);
}
[data-bs-theme="dark"] .kf50-kpi__label,
[data-bs-theme="dark"] .kf50-kpi__sub {
  color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .kf50-kpi__value {
  color: var(--kf-dark-ink);
}
[data-bs-theme="dark"] .kf50-chart-skeleton,
[data-bs-theme="dark"] .kf50-chart-empty {
  background: var(--kf-dark-surface-alt);
  color: var(--kf-dark-ink-soft);
}

/* ── Observation layers (/observation-layers/index) — popup + cluster ink */
[data-bs-theme="dark"] .pw-obs-popup,
[data-bs-theme="dark"] .pw-obs-popup th,
[data-bs-theme="dark"] .pw-obs-popup td,
[data-bs-theme="dark"] .pw-obs-popup__refresh {
  color: var(--kf-dark-ink);
}
[data-bs-theme="dark"] .pw-obs-popup th {
  color: var(--kf-dark-ink-soft);
}
/* Marker rings/dots/halos use white borders to read on a satellite basemap;
   that still reads on a dark UI shell so we don't invert them. */

/* ── Simulation live-weather card (.pw-weather) — the "Stazione meteo più
   vicina" card sat above the map with hardcoded white fallbacks because
   --pw-surface didn't cascade in time. */
[data-bs-theme="dark"] .pw-weather {
  background: var(--kf-dark-surface);
  color: var(--kf-dark-ink);
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pw-weather__title,
[data-bs-theme="dark"] .pw-weather__label,
[data-bs-theme="dark"] .pw-weather__age,
[data-bs-theme="dark"] .pw-weather__value small {
  color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .pw-weather__value {
  color: var(--kf-dark-ink);
}
[data-bs-theme="dark"] .pw-weather__kfr {
  background: rgba(255, 255, 255, 0.08);
}

/* ── Electronic-nose sensor layer (/sensor-layer/index) — drawer + node list */
[data-bs-theme="dark"] .sl-drawer,
[data-bs-theme="dark"] .sl-map {
  background: var(--kf-dark-surface);
  color: var(--kf-dark-ink);
}
[data-bs-theme="dark"] .sl-node__id {
  color: var(--kf-dark-ink);
}
[data-bs-theme="dark"] .sl-node__meta {
  color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .sl-win {
  background: var(--kf-dark-surface-alt);
  color: var(--kf-dark-ink);
}
[data-bs-theme="dark"] .sl-tabs {
  border-bottom-color: var(--kf-dark-border);
}

/* ── Public cameras (/monitoring/cameras) — remap the scoped --pcam-* tokens */
[data-bs-theme="dark"] .public-cameras-page {
  --pcam-ink:    var(--kf-dark-ink);
  --pcam-muted:  var(--kf-dark-ink-soft);
  --pcam-panel:  var(--kf-dark-surface);
  --pcam-soft:   var(--kf-dark-surface-alt);
  --pcam-border: var(--kf-dark-border);
  --pcam-line:   var(--kf-dark-border);   /* the token public-cameras.css actually uses */
}
[data-bs-theme="dark"] .pcam-filters input,
[data-bs-theme="dark"] .pcam-filters select {
  background: var(--kf-dark-surface-alt);
  color: var(--kf-dark-ink);
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pcam-filters input::placeholder {
  color: var(--kf-dark-ink-fade);
}

/* ── Scenario composer (/scenario/compose) — sidebar / panels / palette */
[data-bs-theme="dark"] .pw-scn-sidebar,
[data-bs-theme="dark"] .pw-scn-ignition-panel,
[data-bs-theme="dark"] .pw-scn-form {   /* was .pw-scn-editor-main (dead class); .pw-scn-form is the white drop-target column */
  background: var(--kf-dark-surface);
  color: var(--kf-dark-ink);
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pw-scn-sidebar {
  border-right-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pw-scn-ignition-coords,
[data-bs-theme="dark"] .pw-scn-palette-title,
[data-bs-theme="dark"] .pw-scn-inventory-picker label {
  color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .pw-scn-inventory-picker,
[data-bs-theme="dark"] .pw-scn-palette-item {
  background: var(--kf-dark-surface-alt);
  color: var(--kf-dark-ink);
  border-color: var(--kf-dark-border);
}

/* ── Feedback form (/feedback/index) — labels were inheriting an
   invisible color in BOTH modes. Force Bootstrap form-label to the body
   ink so they read on light AND dark. */
.feedback-page .form-label,
.feedback-page label.form-label {
  color: var(--bs-body-color, #181c32);
}
[data-bs-theme="dark"] .feedback-page .form-label,
[data-bs-theme="dark"] .feedback-page label.form-label {
  color: var(--kf-dark-ink);
}

/* ── Operational registry (/operational-registry/index) — KPI tiles +
   map panel header. .or-kpi__value had no explicit color and inherited
   #111827 from its parent <a>, which Bootstrap utilities sometimes
   re-painted in both modes → blank tiles. .or-map-panel__title had no
   color at all and went white-on-white in dark mode. */
.or-kpi__value {
    color: #111827;       /* explicit instead of relying on inheritance */
}
.or-map-panel__title {
    color: #111827;
}
[data-bs-theme="dark"] .or-kpi {
    color: var(--kf-dark-ink);
    background-color: var(--kf-dark-surface-alt);
}
[data-bs-theme="dark"] .or-kpi__label {
    color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .or-kpi__value {
    color: var(--kf-dark-ink);
}
[data-bs-theme="dark"] .or-map-panel,
[data-bs-theme="dark"] .or-map-panel__bar {
    background: var(--kf-dark-surface);
    border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .or-map-panel__title {
    color: var(--kf-dark-ink);
}
[data-bs-theme="dark"] .or-map-panel__meta {
    color: var(--kf-dark-ink-soft);
}

/* ── 2D risk map (/2d-map) — opacity panel + legend control ink. */
[data-bs-theme="dark"] .opacity-panel,
[data-bs-theme="dark"] .leaflet-control.legend-control {
    background: var(--kf-dark-surface);
    color: var(--kf-dark-ink);
    border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .opacity-panel label,
[data-bs-theme="dark"] .leaflet-control.legend-control * {
    color: var(--kf-dark-ink);
}

/* ── Benchmark dashboard (/benchmark/dashboard) — bench-* surfaces.
   The view registers inline CSS from _nav.php with hardcoded grays;
   patch every relevant selector. */
[data-bs-theme="dark"] .bench-nav a {
    color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .bench-nav a:hover,
[data-bs-theme="dark"] .bench-nav a.active {
    color: var(--kf-dark-ink);
}
[data-bs-theme="dark"] .bench-card,
[data-bs-theme="dark"] .bench-aoi {
    background: var(--kf-dark-surface);
    color: var(--kf-dark-ink);
    border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .bench-aoi__meta {
    color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .bench-pill--muted {
    background: var(--kf-dark-surface-alt);
    color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .bench-pill--info {
    background: #173041;
    color: #9ec6ff;
}
[data-bs-theme="dark"] .bench-empty {
    color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .bench-caveat {
    background: #2a2410;
    color: #f0d49a;
}

/* ── Operator help (/help/index) — remap scoped tokens + alert-light. */
[data-bs-theme="dark"] .help-index {
    --hi-c-ink: var(--kf-dark-ink);
    --hi-c-ink-soft: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .help-index__empty {
    background: var(--kf-dark-surface-alt);
    color: var(--kf-dark-ink-soft);
}

/* ── Feedback follow-up (PR #663 wrap was not enough).
   .alert alert-light keeps a near-white background in Bootstrap dark
   mode, which makes the disclaimer text unreadable; the two
   <p class="text-muted"> paragraphs also drop below contrast threshold.
   Also fix the LIGHT-mode case: when the alert sits on a white card,
   alert-light's near-white background swallows the white border and
   reads as no panel at all — pin a soft surface + explicit ink. */
.feedback-page .alert-light {
    background: #f3f6fa;
    color: #1f2937;
    border-color: #d8dee7;
}
.feedback-page .text-muted {
    color: #4b5563 !important;
}
[data-bs-theme="dark"] .feedback-page .alert-light {
    background: var(--kf-dark-surface-alt);
    color: var(--kf-dark-ink);
    border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .feedback-page .text-muted {
    color: var(--kf-dark-ink-soft) !important;
}

/* ── Theme toggle button (header) — clean icon swap ────────────────── */
.kf-theme-toggle .kf-theme-toggle__sun  { display: none; }
.kf-theme-toggle .kf-theme-toggle__moon { display: inline-block; }
[data-bs-theme="dark"] .kf-theme-toggle .kf-theme-toggle__sun  { display: inline-block; }
[data-bs-theme="dark"] .kf-theme-toggle .kf-theme-toggle__moon { display: none; }

/* ════════════════════════════════════════════════════════════════════
   QA pass 2026-06-17 (karst_itaslo_v1 operator review) — extra dark-mode
   coverage for surfaces that still hardcode light colours and so render
   dark-on-dark / light-on-white at night.
   ════════════════════════════════════════════════════════════════════ */

/* ── /simulation — Leaflet basemap/layer control ("nastavitve zemljevida").
   Leaflet ships a white control; pyrowise-ux.css colours its labels with
   the (undefined) --pw-text → light ink on a white control = unreadable.
   Darken the control surface so the light label text reads. ──────────── */
[data-bs-theme="dark"] .pw-dashboard .leaflet-control-layers,
[data-bs-theme="dark"] .pw-dashboard .leaflet-control-layers-expanded,
[data-bs-theme="dark"] .pw-dashboard .leaflet-control-layers-toggle {
  background: var(--kf-dark-surface);
  color: var(--kf-dark-ink);
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pw-dashboard .leaflet-control-layers label,
[data-bs-theme="dark"] .pw-dashboard .leaflet-control-layers-base label,
[data-bs-theme="dark"] .pw-dashboard .leaflet-control-layers-overlays label {
  color: var(--kf-dark-ink);
}
[data-bs-theme="dark"] .pw-dashboard .leaflet-control-layers-separator {
  border-top-color: var(--kf-dark-border);
}

/* ── GIS layer panel (#pw-layer-panel) on /simulation + /observation-layers.
   layer-panel.css colours text with var(--pw-text,#1a1a1a) /
   var(--pw-text-muted,…) — both tokens are undefined repo-wide, so at night
   the text keeps the dark light-mode fallback (dark-on-dark). Define the
   tokens on the panel + patch the few hardcoded light fills. ─────────── */
[data-bs-theme="dark"] .pw-dashboard .pw-layer-panel,
[data-bs-theme="dark"] .pw-layer-panel {
  --pw-text:       var(--kf-dark-ink);
  --pw-text-muted: var(--kf-dark-ink-soft);
  --pw-surface:    var(--kf-dark-surface);
  --pw-border:     var(--kf-dark-border);
  background: var(--kf-dark-surface);
  color: var(--kf-dark-ink);
}
[data-bs-theme="dark"] .pw-layer-panel__header {
  border-bottom-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pw-firebreak-copernicus {
  background: var(--kf-dark-surface-alt);
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pw-feature-modal {
  background: var(--kf-dark-surface);
  color: var(--kf-dark-ink);
  border-color: var(--kf-dark-border);
}

/* ── /sensor-layer node rail — node text is themed already, but the hover
   and selected backgrounds stayed light and hid the (light) node text. ── */
[data-bs-theme="dark"] .sl-node:hover { background: var(--kf-dark-surface-alt); }
[data-bs-theme="dark"] .sl-node--sel,
[data-bs-theme="dark"] .sl-node[aria-current="true"] { background: #1d2a3a; }
[data-bs-theme="dark"] .sl-node { border-bottom-color: var(--kf-dark-border); }
[data-bs-theme="dark"] .sl-list-head,
[data-bs-theme="dark"] .sl-legend__item { color: var(--kf-dark-ink-soft); }
[data-bs-theme="dark"] .sl-chip {
  background: var(--kf-dark-surface-alt);
  color: var(--kf-dark-ink-soft);
  border-color: var(--kf-dark-border);
}

/* ── /scenario/compose — the brick-form column (.pw-scn-form, re-themed in
   the sidebar block above once the dead .pw-scn-editor-main selector was
   corrected) plus its cards/fields hardcode white/near-white fills. ───── */
[data-bs-theme="dark"] .pw-scn-card {
  background: var(--kf-dark-surface-alt);
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pw-scn-card-header {
  background: var(--kf-dark-surface);
  border-bottom-color: var(--kf-dark-border);
  color: var(--kf-dark-ink);
}
[data-bs-theme="dark"] .pw-scn-field label,
[data-bs-theme="dark"] .pw-scn-inventory-status,
[data-bs-theme="dark"] .pw-scn-palette-divider,
[data-bs-theme="dark"] .pw-scn-empty { color: var(--kf-dark-ink-soft); }
[data-bs-theme="dark"] .pw-scn-field input,
[data-bs-theme="dark"] .pw-scn-field select {
  background: var(--kf-dark-surface-alt);
  color: var(--kf-dark-ink);
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pw-scn-ignition-panel h2,
[data-bs-theme="dark"] .pw-scn-inventory-picker h2 { color: var(--kf-dark-ink); }
[data-bs-theme="dark"] .pw-scn-banner {
  background: var(--kf-dark-surface-alt);
  color: var(--kf-dark-ink);
}

/* ── /2d-map — JS-injected #karstFirePanel sidebar hardcodes a white
   surface + light scoped tokens and never sets a text colour, so its value
   text inherits the light page ink → light-on-white at night. Remap the
   scoped vars + root colour (ID-scoped attr selector beats the injected
   <style>); hover states also paint light, so patch those too. ───────── */
[data-bs-theme="dark"] #karstFirePanel {
  background: var(--kf-dark-surface);
  border-right-color: var(--kf-dark-border);
  color: var(--kf-dark-ink);
  --bg:      var(--kf-dark-surface-alt);
  --surface: var(--kf-dark-surface);
  --border:  var(--kf-dark-border);
  --text:    var(--kf-dark-ink);
  --muted:   var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] #karstFirePanel .kf-stat-card:hover,
[data-bs-theme="dark"] #karstFirePanel .kf-sitem:hover {
  border-color: var(--kf-dark-ink-soft);
  background: rgba(255, 255, 255, 0.06);
}
[data-bs-theme="dark"] #karstFirePanel .kf-stoggle button:not(.on):hover {
  color: var(--kf-dark-ink);
}

/* ── Contextual help "?" (pw-help-*, from HelpHelper fieldTooltip /
   aboutPage / popover). help.css ships only light surfaces with zero dark
   rules; the control appears site-wide on operator pages. ────────────── */
[data-bs-theme="dark"] .pw-help-field { color: var(--kf-dark-ink-soft); }
[data-bs-theme="dark"] .pw-help-field:hover,
[data-bs-theme="dark"] .pw-help-field:focus-visible { color: var(--kf-dark-ink); }
[data-bs-theme="dark"] .pw-help-about {
  background: var(--kf-dark-surface-alt);
  color: var(--kf-dark-ink);
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pw-help-about__summary { color: #7ee2b8; }
[data-bs-theme="dark"] .pw-help-about__title { color: var(--kf-dark-ink); }
[data-bs-theme="dark"] .pw-help-popover {
  background: var(--kf-dark-surface);
  color: var(--kf-dark-ink);
  border-color: var(--kf-dark-border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
[data-bs-theme="dark"] .pw-help-popover::before {
  background: var(--kf-dark-surface);
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pw-help-popover__close { color: var(--kf-dark-ink-soft); }

/* ════════════════════════════════════════════════════════════════════
   QA pass 2026-06-17 (round 2, karst_itaslo_v1) — leftover hardcoded
   light fills inside already-themed panels that the scoped-token remaps
   above don't reach (they bypass --pw-* with literal #fff / inherit the
   panel's light ink over a white background → light-on-white = invisible).
   ════════════════════════════════════════════════════════════════════ */

/* ── /simulation map-settings panel — Copernicus firebreak sub-panel.
   layer-panel.css hardcodes white fills on its filter/button and on the
   data table; the panel's dark ink then sits on white = unreadable. ──── */
[data-bs-theme="dark"] .pw-firebreak-copernicus__filter,
[data-bs-theme="dark"] .pw-firebreak-copernicus__button {
  background: var(--kf-dark-surface-alt);
  color: var(--kf-dark-ink);
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pw-firebreak-copernicus__table-wrap,
[data-bs-theme="dark"] .pw-firebreak-copernicus {
  background: var(--kf-dark-surface);
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pw-firebreak-copernicus__table th {
  background: var(--kf-dark-surface-alt);
  color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .pw-firebreak-copernicus__table th,
[data-bs-theme="dark"] .pw-firebreak-copernicus__table td {
  border-bottom-color: var(--kf-dark-border);
}

/* ── Shared GIS feature modal (/simulation + /observation-layers) — the
   inner card hardcodes #fff and renders as a white slab on the dark page.
   (The earlier patch themed the .pw-feature-modal overlay, not the card.) */
[data-bs-theme="dark"] .pw-feature-modal__card {
  background: var(--kf-dark-surface);
  color: var(--kf-dark-ink);
}
[data-bs-theme="dark"] .pw-feature-modal__row {
  border-top-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pw-feature-modal__x {
  background: var(--kf-dark-surface-alt);
  color: var(--kf-dark-ink-soft);
}

/* ── /scenario/compose — sensor-evidence opt-in block (light border + a
   muted note that drops below contrast) and the palette item hover/drop
   states that keep a light-blue fill hiding the now-light item text. ──── */
[data-bs-theme="dark"] .pw-scn-sensor-evidence {
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .pw-scn-sensor-evidence__note {
  color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .pw-scn-palette-item:hover:not([disabled]):not(.pw-scn-palette-already-added) {
  background: var(--kf-dark-surface);
  border-color: var(--kf-dark-ink-soft);
}
[data-bs-theme="dark"] .pw-scn-form-drop-target {
  background: rgba(255, 255, 255, 0.05);
}

/* ── Operator QA round 3 — composer controls that keep their light-theme
   dark ink on the now-dark surfaces, dropping to ~1.1:1 ("besedilo ni vidno").
   Verified live (WCAG scan, observation-layers + scenario/compose):
     • #1F2937 ink → light: language pills, horizon options, map-legend label,
       weather-source radio labels.
     • --pw-accent-dark #085041 (ghost-button text) → a lighter accent: the
       toolbar action links (Simula/Scenari/Condividi/Analizza), "Adesso",
       "Modifica coordinate", the 2D/3D/Sim mode toggle.
   The chips that retain a *light* fill (pw-status, pw-freshness-chip,
   pw-layer-row__pill, the Karst-Firewall-Index button) stay dark-on-light and
   ARE readable, so they are deliberately left untouched — and --pw-accent-dark
   is NOT remapped wholesale (that would break pw-status--ok's teal-on-mint). */
[data-bs-theme="dark"] .pw-dashboard {
  --pw-text:       var(--kf-dark-ink);
  --pw-text-muted: var(--kf-dark-ink-soft);
}
/* :not(.is-active) — the active toggle keeps its accent fill + white text;
   only the inactive (transparent/dark-fill) options carry the dark ink. */
[data-bs-theme="dark"] .pw-dashboard .pw-horizon__opt:not(.is-active),
[data-bs-theme="dark"] .pw-dashboard .pw-map-legend__label,
[data-bs-theme="dark"] .pw-dashboard .pw-weather-source__opt {
  color: var(--kf-dark-ink);
}
[data-bs-theme="dark"] .pw-dashboard .pw-btn-now,
[data-bs-theme="dark"] .pw-dashboard .pw-share,
[data-bs-theme="dark"] .pw-dashboard .pw-overflow__label,
[data-bs-theme="dark"] .pw-dashboard .pw-coords-toggle {
  color: #4fd1ab;
}
/* The language pills + the 2D/3D/Sim map-mode toggle carry a *competing* color
   declaration the plain override can't outrank (lang via its base rule; the
   map-mode opt is also .kf50-map-switcher__opt, coloured from a separate
   stylesheet) — verified live that SI/EN/DE + 2D/3D stayed ~1.2:1 until forced.
   Their sibling controls win without this, so only these two need !important. */
html[data-bs-theme="dark"] .pw-dashboard a.pw-lang__btn:not(.is-active) {
  color: var(--kf-dark-ink) !important;
}
html[data-bs-theme="dark"] .pw-dashboard .pw-map-mode__opt:not(.is-active),
html[data-bs-theme="dark"] .pw-dashboard .kf50-map-switcher__opt:not(.is-active) {
  color: #4fd1ab !important;
}

/* #8 "tehnične podrobnosti" — the engineering drawer (Dettagli tecnici) and the
   run-narrative audit render their de-emphasised captions/codes at only ~3:1
   in dark, so operators read the technical block as "hidden". The body
   label/value pairs are already ≥4.5; lift just the faint bits to AA.
   !important on .text-muted to beat Bootstrap's own !important on that util. */
[data-bs-theme="dark"] .pw-drawer .text-muted,
[data-bs-theme="dark"] .pw-narrative__audit .text-muted,
[data-bs-theme="dark"] .pw-narrative__audit-code-row {
  color: var(--kf-dark-ink-soft) !important;
}
[data-bs-theme="dark"] .pw-narrative__audit-code {
  color: #e879c9 !important;
}

/* ── /scenario/compose — PyroWISE intervention-planner (PPR) panel labels
   hardcode rgba(0,0,0,.55), invisible (~1.1:1) on the dark panel. ───────── */
[data-bs-theme="dark"] .pw-ppr__subtitle,
[data-bs-theme="dark"] .pw-ppr__field-label,
[data-bs-theme="dark"] .pw-ppr__slider-value {
  color: var(--kf-dark-ink-soft);
}

/* ── /operational-registry — KPI tiles set a dark background-color in dark
   mode but the per-entity pastel *gradient* (background-image) still paints
   on top, so the near-white .or-kpi__value sat on a light fill and vanished
   ("števila niso berljiva v nočnem načinu"). Drop the gradient at night so
   the dark fill shows; the coloured accent bar/border keep the colour code. */
[data-bs-theme="dark"] .or-kpi {
  background-image: none;
}
/* Inactive entity-tab count badges use Bootstrap .text-secondary, which this
   Metronic build resolves to a near-background grey — invisible in BOTH
   themes (#363843 on #303031 at night). Force a readable pair. */
[data-bs-theme="dark"] .or-entity-tabs .nav-link:not(.active) .badge {
  /* !important to beat Bootstrap's .text-secondary / .bg-secondary-subtle
     utilities (they use !important). */
  color: var(--kf-dark-ink-soft) !important;
  background-color: var(--kf-dark-surface-alt) !important;
}

/* ── Dark-mode sweep (post-#713) — proactive audit of the wider operator UI.
   Most pages were already clean; these are the gaps found. ─────────────── */

/* The env-stats weather strip (.kf50-weather-strip) also renders on
   /incident/index, where it sits OUTSIDE .kf50-cockpit — so the --kf-c-*
   tokens kf-dark only remaps for the cockpit fall back to light there and the
   near-white value sat on a light tile (~1.1:1, invisible). Define the tokens
   on the strip itself so it's dark wherever it appears (the cockpit keeps the
   same dark values — no visible change there). */
[data-bs-theme="dark"] .kf50-weather-strip {
  --kf-c-paper:    var(--kf-dark-surface);
  --kf-c-ink:      var(--kf-dark-ink);
  --kf-c-ink-soft: var(--kf-dark-ink-soft);
  --kf-c-ink-fade: var(--kf-dark-ink-fade);
  --kf-c-line:     var(--kf-dark-border);
}
/* the warn/alert value tints hardcode dark amber/red — lift for the dark tile */
[data-bs-theme="dark"] .kf50-weather-strip__seg.is-warn .kf50-weather-strip__value  { color: #fbbf24; }
[data-bs-theme="dark"] .kf50-weather-strip__seg.is-alert .kf50-weather-strip__value { color: #f87171; }

/* /2d-map basemap submenu links use --pw-accent-dark (#085041) as text — fine
   on light, ~2:1 on the dark page. Lighten to the brand accent. */
[data-bs-theme="dark"] .kf50-map-submenu a {
  color: #4fd1ab;
}

/* Several CUSTOM monitoring pages are token-based but ship no dark override and
   sit OUTSIDE the scopes kf-dark already remaps (.kf50-cockpit / .pw-dashboard),
   so their tokens fall back to LIGHT — light panels/cards with the themed-white
   body ink on top = invisible text. Remap each page's tokens to the dark
   palette. Verified live (WCAG): the worst values went 1.0–1.1:1 → 14–16:1.

   /weather-station map controls (.ws-* use --pw-*; switcher label was 1.0:1) */
[data-bs-theme="dark"] .weather-stations-map-page {
  --pw-surface:     var(--kf-dark-surface);
  --pw-surface-alt: var(--kf-dark-surface-alt);
  --pw-border:      var(--kf-dark-border);
  --pw-text:        var(--kf-dark-ink);
  --pw-text-muted:  var(--kf-dark-ink-soft);
}
/* Air-quality UX (.aq-ux — ALSO reused by /iot-sensor): the dark-navy --aq-ink
   headings sat on the dark page (1.1:1) and the white --aq-paper cards stayed
   white. One remap fixes both pages. */
[data-bs-theme="dark"] .aq-ux {
  --aq-ink:      var(--kf-dark-ink);
  --aq-ink-soft: var(--kf-dark-ink-soft);
  --aq-ink-fade: var(--kf-dark-ink-fade);
  --aq-line:     var(--kf-dark-border);
  --aq-paper:    var(--kf-dark-surface);
  --aq-bg:       var(--kf-dark-surface-alt);
}
/* /pyrowise-readiness cards hardcode a white bg (inline view CSS); the value
   text has no own colour so it inherited the light body ink → white-on-white. */
[data-bs-theme="dark"] .readiness-card {
  background: var(--kf-dark-surface);
  border-color: var(--kf-dark-border);
}
[data-bs-theme="dark"] .readiness-value { color: var(--kf-dark-ink); }
[data-bs-theme="dark"] .readiness-label,
[data-bs-theme="dark"] .readiness-empty { color: var(--kf-dark-ink-soft); }
