/* The light dashboard stays the default; these rules apply only after opt in. */
.theme-toggle{width:34px;height:34px;flex:none;display:inline-grid;place-items:center;border:1px solid #dfe7f1;border-radius:8px;background:#fff;color:#526782;cursor:pointer}
.theme-toggle .icon{width:17px;height:17px}
.theme-toggle:hover{color:#1766e8;background:#f1f6ff}
.theme-toggle:focus-visible{outline:2px solid #4b91ed;outline-offset:2px}
.login-form-area .form-top .theme-toggle{order:4}
@media(max-width:480px){.public-header .brand{gap:6px;font-size:13px}.header-actions{gap:4px}.header-actions .locale-switch select{max-width:68px}.header-actions .theme-toggle{width:30px;height:30px}}

:root[data-theme="dark"]{color-scheme:dark;color:#e8f0fa;background:#0b1422}
:root[data-theme="dark"] body{background:#0b1422}
:root[data-theme="dark"] .muted{color:#91a6bc}
:root[data-theme="dark"] .eyebrow{color:#78afff}
:root[data-theme="dark"] .brand-accent{color:#75adff}
:root[data-theme="dark"] .button.subtle,
:root[data-theme="dark"] .theme-toggle,
:root[data-theme="dark"] .locale-switch select{background:#1b2c42;color:#dbe8f7;border-color:#344b65}
:root[data-theme="dark"] .theme-toggle:hover,
:root[data-theme="dark"] .icon-button:hover{background:#263c56;color:#8fc0ff}
:root[data-theme="dark"] .icon-button{color:#aec0d3}
:root[data-theme="dark"] .connection{background:#1b2c42;border-color:#344b65;color:#b9c9db}
:root[data-theme="dark"] .loading-ring{border-color:#344b65;border-top-color:#75adff}

/* Public map and fleet list. */
:root[data-theme="dark"] .public-shell,
:root[data-theme="dark"] .admin-shell{background:#0b1422}
:root[data-theme="dark"] .public-header,
:root[data-theme="dark"] .fleet-sidebar,
:root[data-theme="dark"] .mobile-bottom-nav{background:#142235;border-color:#2b4057}
:root[data-theme="dark"] .public-content{border-color:#2b4057;box-shadow:0 15px 35px rgba(0,0,0,.16)}
:root[data-theme="dark"] .top-nav a,
:root[data-theme="dark"] .top-nav button{color:#a9b9cb}
:root[data-theme="dark"] .top-nav a:hover,
:root[data-theme="dark"] .top-nav button:hover,
:root[data-theme="dark"] .top-nav a.active,
:root[data-theme="dark"] .top-nav button.active{color:#85b8ff}
:root[data-theme="dark"] .sidebar-heading h1,
:root[data-theme="dark"] .empty-list strong{color:#e8f0fa}
:root[data-theme="dark"] .sidebar-heading p,
:root[data-theme="dark"] .sidebar-stats span:not(.stat-orb),
:root[data-theme="dark"] .sidebar-footer,
:root[data-theme="dark"] .empty-list,
:root[data-theme="dark"] .bus-row-time{color:#9cafc3}
:root[data-theme="dark"] .sidebar-stats{background:linear-gradient(105deg,#1b304a,#18283d);border-color:#2c4563}
:root[data-theme="dark"] .stat-orb{background:#263c58;color:#85b8ff}
:root[data-theme="dark"] .stat-divider{background:#344b65}
:root[data-theme="dark"] .filter-block label{color:#c1d0df}
:root[data-theme="dark"] .filter-block input,
:root[data-theme="dark"] .filter-block select,
:root[data-theme="dark"] .admin-toolbar select,
:root[data-theme="dark"] .admin-search input{background:#101e2e;color:#e8f0fa;border-color:#344b65}
:root[data-theme="dark"] .filter-block input::placeholder,
:root[data-theme="dark"] .admin-search input::placeholder{color:#8fa2b7}
:root[data-theme="dark"] .search-field>.icon,
:root[data-theme="dark"] .search-field button{color:#a7bad0}
:root[data-theme="dark"] .list-title,
:root[data-theme="dark"] .bus-row,
:root[data-theme="dark"] .sidebar-footer{border-color:#2b4057}
:root[data-theme="dark"] .list-title strong span{color:#9cafc3}
:root[data-theme="dark"] .bus-row{background:#142235;color:#e8f0fa}
:root[data-theme="dark"] .bus-row:hover,
:root[data-theme="dark"] .bus-row.selected{background:#203751}
:root[data-theme="dark"] .bus-row-main small b{background:#263c56;color:#c5d7e8}
:root[data-theme="dark"] .mobile-bottom-nav>*{color:#9cafc3}
:root[data-theme="dark"] .mobile-bottom-nav .active{color:#85b8ff}

/* Map controls and popups stay readable over either map provider. */
:root[data-theme="dark"] .public-map-area,
:root[data-theme="dark"] .admin-map-card,
:root[data-theme="dark"] .fleet-map,
:root[data-theme="dark"] .public-shell.monitor-mode{background:#243a49}
:root[data-theme="dark"] .fleet-map{background:radial-gradient(circle at 70% 20%,#284357,#1a3041 70%,#152737)}
:root[data-theme="dark"] .fleet-map .leaflet-tile-pane{filter:brightness(.78) invert(1) hue-rotate(180deg) saturate(.7)}
:root[data-theme="dark"] .fleet-map .leaflet-control-zoom a{background:#1b2c42;color:#e8f0fa;border-color:#344b65}
:root[data-theme="dark"] .fleet-map .leaflet-control-attribution{background:rgba(20,34,53,.88);color:#b9c9db}
:root[data-theme="dark"] .fleet-map .leaflet-control-attribution a{color:#8fc0ff}
:root[data-theme="dark"] .map-error{background:linear-gradient(135deg,#1a3041,#243a49)}
:root[data-theme="dark"] .map-error-card,
:root[data-theme="dark"] .map-count,
:root[data-theme="dark"] .map-legend,
:root[data-theme="dark"] .map-bus-card,
:root[data-theme="dark"] .map-display-toggle,
:root[data-theme="dark"] .admin-map-count{background:#142235;border-color:#344b65;color:#e8f0fa;box-shadow:0 8px 24px rgba(0,0,0,.24)}
:root[data-theme="dark"] .map-legend,
:root[data-theme="dark"] .map-count,
:root[data-theme="dark"] .map-card-content p,
:root[data-theme="dark"] .map-card-facts span{color:#c1d0df}
:root[data-theme="dark"] .map-card-content small,
:root[data-theme="dark"] .map-error-card p{color:#a7bad0}
:root[data-theme="dark"] .map-bus-icon{background:linear-gradient(145deg,#253e5d,#1c3048);color:#8fc0ff}
:root[data-theme="dark"] .map-display-toggle:hover{background:#263c56;color:#8fc0ff}
:root[data-theme="dark"] .sidebar-handle{background:#142235;border-color:#344b65;color:#e8f0fa;box-shadow:0 8px 24px rgba(0,0,0,.28)}
:root[data-theme="dark"] .sidebar-handle:hover{background:#263c56;color:#8fc0ff}
:root[data-theme="dark"] .public-shell.monitor-mode .map-display-toggle{background:#142235;border-color:#344b65}

/* Login and administration. */
:root[data-theme="dark"] .login-shell{background:radial-gradient(circle at 15% 10%,#1a304b,#0b1422 52%,#101b2b)}
:root[data-theme="dark"] .login-back,
:root[data-theme="dark"] .login-form-intro p,
:root[data-theme="dark"] .form-guard,
:root[data-theme="dark"] .form-footnote{color:#a9b9cb}
:root[data-theme="dark"] .login-card{background:#142235;border-color:#2b4057;box-shadow:0 30px 80px rgba(0,0,0,.32)}
:root[data-theme="dark"] .login-visual{background:linear-gradient(148deg,#092b61,#104884 61%,#126c9c)}
:root[data-theme="dark"] .form-symbol,
:root[data-theme="dark"] .detail-bus-icon{background:#203b5b;color:#8fc0ff}
:root[data-theme="dark"] .password-field button{color:#a9b9cb}
:root[data-theme="dark"] .form-error,
:root[data-theme="dark"] .inline-alert{background:#43292d;border-color:#775057;color:#ffc0c5}
:root[data-theme="dark"] .admin-nav{background:linear-gradient(175deg,#091827,#0c1c2d 55%,#081625)}
:root[data-theme="dark"] .admin-topbar{background:#142235;border-color:#2b4057}
:root[data-theme="dark"] .admin-breadcrumb,
:root[data-theme="dark"] .page-intro p,
:root[data-theme="dark"] .pagination,
:root[data-theme="dark"] .detail-heading p,
:root[data-theme="dark"] .detail-last-gps,
:root[data-theme="dark"] .track-footer{color:#a9b9cb}
:root[data-theme="dark"] .admin-breadcrumb strong,
:root[data-theme="dark"] .table-bus strong,
:root[data-theme="dark"] .metric-card strong,
:root[data-theme="dark"] .timeline-item strong,
:root[data-theme="dark"] .journey-extra strong{color:#e8f0fa}
:root[data-theme="dark"] .title-count,
:root[data-theme="dark"] .detail-plate,
:root[data-theme="dark"] .row-arrow{background:#203b5b;color:#8fc0ff}
:root[data-theme="dark"] .table-card,
:root[data-theme="dark"] .metric-card,
:root[data-theme="dark"] .journey-card,
:root[data-theme="dark"] .track-card{background:#142235;border-color:#2b4057;box-shadow:0 5px 20px rgba(0,0,0,.12)}
:root[data-theme="dark"] .fleet-table th{background:#1a2b40;color:#b9c9db;border-color:#2b4057}
:root[data-theme="dark"] .fleet-table td{color:#c4d3e3;border-color:#2b4057}
:root[data-theme="dark"] .fleet-table tbody tr:hover{background:#203751}
:root[data-theme="dark"] .table-bus small,
:root[data-theme="dark"] .metric-card>span,
:root[data-theme="dark"] .metric-card small,
:root[data-theme="dark"] .timeline-item small,
:root[data-theme="dark"] .timeline-item div>span,
:root[data-theme="dark"] .journey-extra span{color:#a9b9cb}
:root[data-theme="dark"] .journey-extra{border-color:#2b4057}
:root[data-theme="dark"] .timeline-item:before{background:#344b65}
:root[data-theme="dark"] .timeline-node{background:#142235;border-color:#7890a9}
:root[data-theme="dark"] .track-pill{background:#173e34;color:#80dfb2}
:root[data-theme="dark"] .status-badge.scheduled,
:root[data-theme="dark"] .mini-status.online,
:root[data-theme="dark"] .status-badge.online{background:#203b5b;color:#9bc7ff}
:root[data-theme="dark"] .mini-status.moving,
:root[data-theme="dark"] .status-badge.moving{background:#173e34;color:#87e2b7}
:root[data-theme="dark"] .mini-status.stopped,
:root[data-theme="dark"] .status-badge.stopped{background:#4b3a1c;color:#f3cf87}
:root[data-theme="dark"] .mini-status.stale,
:root[data-theme="dark"] .status-badge.stale,
:root[data-theme="dark"] .status-badge.completed,
:root[data-theme="dark"] .status-badge.unknown{background:#293a4d;color:#bccbdc}
:root[data-theme="dark"] .mini-status.offline,
:root[data-theme="dark"] .status-badge.offline,
:root[data-theme="dark"] .status-badge.cancelled{background:#4b2b35;color:#ffabb5}
:root[data-theme="dark"] .public-shell.embed-mode{background:transparent}
:root[data-theme="dark"] .map-card-anchor.is-anchored .map-bus-card::after{border-color:#2b4057}
/* The wordmark is a solid blue path; flip it to white on dark backgrounds. */
:root[data-theme="dark"] .brand-text{filter:brightness(0) invert(1)}
