/* Dark theme: token overrides only. No component rules live here. */
@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --card-border: 1px solid var(--line);
    --selected-line: var(--line-strong);
    --bg: #11151b;
    --bg-sunken: #0d1116;
    --surface: #191f27;
    --surface-raised: #202731;
    --surface-muted: #222a35;
    --surface-inverse: #0d1116;
    --surface-inverse-2: #202731;
    --contrast-surface: #f2f4f7;
    --contrast-ink: #141922;
    --contrast-muted: #667085;
    --contrast-line: rgba(20,25,34,.14);
    --ink: #f2f4f7;
    --ink-2: #d5dae2;
    --muted: #98a2b3;
    --faint: #788394;
    --line: rgba(255,255,255,.12);
    --line-subtle: rgba(255,255,255,.08);
    --line-strong: #485264;
    --accent: #f2f4f7;
    --accent-hover: #ffffff;
    --accent-active: #d9dde4;
    --accent-soft: #252d38;
    --accent-soft-strong: #323c49;
    --accent-ink: #f2f4f7;
    --accent-on-dark: #141922;
    --success: #5bbf8a;
    --success-hover: #79cca1;
    --success-soft: #183a2b;
    --success-ink: #9adfb8;
    --risk: #f28b82;
    --risk-hover: #ffaaa3;
    --risk-soft: #44231f;
    --risk-ink: #ffb5ae;
    --info: #8cbcff;
    --info-hover: #a8ccff;
    --info-soft: #1e314b;
    --info-ink: #bcd6ff;
    --neutral-soft: #252d38;
    --neutral-ink: #d5dae2;
    --on-dark: #f7f9fc;
    --on-dark-muted: #aeb8c7;
    --on-dark-line: #3b4553;
    --focus-color: #93b4fd;
    --map-land: #1c232c;
    --map-block: #242c37;
    --map-block-alt: #2a3340;
    --map-road: #394352;
    --map-road-edge: #485264;
    --map-park: #223b2f;
    --map-water: #203440;
    --map-label: #98a2b3;
    --map-route: #8cbcff;
    --map-geofence: #e4e7ec;
  }
  :root[data-theme="dark"] [aria-invalid="true"] { background: var(--risk-soft); }
  :root[data-theme="dark"] #token-input[aria-invalid="true"] { background: var(--risk-soft); }
  :root[data-theme="dark"] .finance-revenue-key,
  :root[data-theme="dark"] .create-order > summary::before,
  :root[data-theme="dark"] .brand-mark.large,
  :root[data-theme="dark"] .public-brand .brand-mark { color: var(--accent-ink); }

  :root[data-theme="dark"] .leaflet-container { background: var(--bg-sunken); }
  :root[data-theme="dark"] .leaflet-bar a,
  :root[data-theme="dark"] .leaflet-control-layers,
  :root[data-theme="dark"] .leaflet-popup-content-wrapper,
  :root[data-theme="dark"] .leaflet-popup-tip,
  :root[data-theme="dark"] .leaflet-tooltip { background: var(--surface-raised); color: var(--ink); border-color: var(--line-strong); }
  :root[data-theme="dark"] .leaflet-bar a:hover { background: var(--surface-muted); }
  :root[data-theme="dark"] .leaflet-bar a.leaflet-disabled { background: var(--surface); color: var(--faint); }
  :root[data-theme="dark"] .leaflet-control-attribution { background: var(--surface); color: var(--muted); }
  :root[data-theme="dark"] .leaflet-control-attribution a,
  :root[data-theme="dark"] .leaflet-container a.leaflet-popup-close-button { color: var(--accent-ink); }
  :root[data-theme="dark"] .leaflet-tooltip-top::before { border-top-color: var(--line-strong); }
  :root[data-theme="dark"] .leaflet-tooltip-bottom::before { border-bottom-color: var(--line-strong); }
  :root[data-theme="dark"] .leaflet-tooltip-left::before { border-left-color: var(--line-strong); }
  :root[data-theme="dark"] .leaflet-tooltip-right::before { border-right-color: var(--line-strong); }
}

.public-topbar .theme-switch,
.topbar .theme-switch { display: inline-grid; place-items: center; flex: 0 0 var(--touch-target); width: var(--touch-target); height: var(--touch-target); padding: var(--space-5); margin: 0; border: 0; border-radius: var(--radius-full); background: transparent; color: var(--muted); }
.theme-switch:hover { background: var(--surface-muted); color: var(--ink); }
.theme-icon { display: block; width: 22px; height: 22px; }
.theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }

@media (max-width: 640px) {
  .public-topbar .theme-switch { margin-left: auto; }
  .public-topbar .public-nav { order: 2; }
}
@media print { .theme-switch { display: none !important; } }
