/* UI palette only: map tiles, roadview and user images are never filtered. */
:root[data-theme=light] { color-scheme:light;--ui-bg:#f3f6fb;--ui-surface:#fff;--ui-muted:#f1f5f9;--ui-text:#172033;--ui-secondary:#526176;--ui-line:#d7e0ec;--ui-accent:#1d4ed8;--ui-active:#eaf2ff;--bg:#f3f6fb;--panel:#fff;--line:#d7e0ec;--muted:#526176;--text:#172033;--accent:#1d4ed8; }
:root[data-theme=dark] { color-scheme:dark;--ui-bg:#0f172a;--ui-surface:#182437;--ui-muted:#233248;--ui-text:#e5edf7;--ui-secondary:#b1bfd1;--ui-line:#40516a;--ui-accent:#93c5fd;--ui-active:#233d63;--bg:#0f172a;--panel:#182437;--line:#40516a;--muted:#b1bfd1;--text:#e5edf7;--accent:#93c5fd; }
html[data-theme] body { background:var(--ui-bg);color:var(--ui-text); }
html[data-theme] .theme-control { display:flex;align-items:center;gap:8px;padding:10px 8px;margin-top:5px;border-top:1px solid var(--ui-line); }
html[data-theme] .theme-control label { font:500 13px/1.4 system-ui,sans-serif;margin:0;white-space:nowrap;color:var(--ui-secondary); }
html[data-theme] .theme-control select { width:auto;flex:1;min-width:0;margin:0;padding:7px 5px;border:1px solid var(--ui-line);border-radius:6px;font:13px/1.4 system-ui,sans-serif;color:var(--ui-text);background:var(--ui-surface); }
html[data-theme] header.profile-topbar .profile-menu { background:var(--ui-surface);border-color:var(--ui-line);color-scheme:inherit; }
html[data-theme] .profile-menu a,html[data-theme] .profile-menu button { color:var(--ui-text); }
html[data-theme] .profile-menu a:hover,html[data-theme] .profile-menu button:hover,html[data-theme] .profile-menu [aria-current=page] { color:var(--ui-accent);background:var(--ui-active); }
html[data-theme] .profile-menu form { border-color:var(--ui-line); }
html[data-theme=dark] :is(.side-panel,.side-panel-inner,.offline-view) { background:var(--ui-bg); }
html[data-theme=dark] :is(.panel-section,.panel-sticky,.search-section,.connection-section,.facility-search-card,.filter-section,.panel-disclosure,.site-detail-panel,.detail-toolbar,.route-panel,.route-heading,.selected-location,.device-card,.asset-card,.offline-detail,.register-table-wrap,.map-state-card,.marker-info-window,.route-waypoint-label,.route-help p,dialog) { background:var(--ui-surface);color:var(--ui-text);border-color:var(--ui-line); }
html[data-theme=dark] :is(.device-card:hover,.device-card.selected,.route-stops li,.route-preview-names li button,.address-result,.form-help,.mode-badge,.map-results-status,#importPreview,.delete-inventory,#registrationSelection,.location-search-notice) { background:var(--ui-muted);color:var(--ui-text);border-color:var(--ui-line); }
html[data-theme=dark] :is(.device-card[aria-pressed=true],.route-preview-names li button[aria-pressed=true],.route-order-choice [aria-pressed=true],.route-waypoint-label.selected,.address-result:hover,.detail-tabs [aria-pressed=true]) { background:var(--ui-active);border-color:#60a5fa;color:#bfdbfe; }
html[data-theme=dark] :is(input,select,textarea) { color:var(--ui-text);background:var(--ui-bg);border-color:var(--ui-line); }
html[data-theme=dark] :is(input,textarea)::placeholder { color:#99aac1;opacity:1; }
html[data-theme=dark] :is(.text-btn,.location-search-card,.btn-light,.map-bottom-tools .btn,.route-stops .btn,.route-endpoint .btn) { color:var(--ui-accent);background:var(--ui-muted);border-color:var(--ui-line); }
html[data-theme=dark] :is(.btn-primary,.map-view-tools [aria-pressed=true]) { color:white;background:#2563eb; }
html[data-theme=dark] :is(.session-label,.device-meta,.asset-ip,.site-code,.site-coordinates,.detail-caption,.filter-grid label,.disclosure-state,.route-result small,.route-endpoint span,.location-search-status,.location-search-dialog .form-help,.address-result span,.auth-description,.intro-tags,.auth-footnote,.offline-heading p,.detail-heading p) { color:var(--ui-secondary); }
html[data-theme=dark] :is(.filter-section > summary,.panel-disclosure > summary,.location-search-disclosure > summary,.location-search-card strong,.site-detail-panel h2,.asset-card h3,.device-card h3,.route-heading h2,.facility-search-heading h2) { color:var(--ui-text); }
html[data-theme=dark] :is(.filter-grid,.panel-disclosure-content,.site-location,.detail-heading,.detail-tabs,.route-endpoint,.route-recommendation,.saved-routes,.route-result,.location-search-disclosure,.route-help p) { border-color:var(--ui-line); }
html[data-theme=dark] .badge.type-badge { color:#dbeafe;background:#354962; }
html[data-theme=dark] #storageNotice { color:#86efac; }
html[data-theme=dark] .server-status-line.error #storageNotice,html[data-theme=dark] .danger-text { color:#fca5a5; }
html[data-theme=dark] :is(.panel-resizer,.route-panel-resizer) { background:#233248; }
html[data-theme=dark] :is(.panel-resizer span,.route-panel-resizer span) { background:#64748b; }
html[data-theme=dark] .location-search-card svg { color:#93c5fd; }
html[data-theme=dark] :is(.device-form label,.marker-info-detail span) { color:var(--ui-text); }
html[data-theme=dark] :is(.result-pager,.recommend-help,.route-help summary,.map-state-card p,.marker-info-detail strong) { color:var(--ui-secondary); }
html[data-theme=dark] :is(#routeCount,.route-endpoint [data-route-current]) { color:var(--ui-accent); }
html[data-theme=dark] .route-endpoint [data-route-clear] { color:var(--ui-secondary); }
html[data-theme=dark] #btnDeleteRoute { color:#fca5a5; }
html[data-theme=dark] :is(.map-action-notice,.map-action-status) { background:var(--ui-surface);color:var(--ui-text);border-color:var(--ui-line); }
html[data-theme=dark] .register-table th { background:var(--ui-muted);color:var(--ui-text); }
html[data-theme=dark] .register-table td { border-color:var(--ui-line); }
html[data-theme=dark] .register-table tr.selected td { background:var(--ui-active); }
/* Account screens use plain section/button selectors. */
html[data-theme=dark] body > main:not([class]) :is(section,.user) { background:var(--ui-surface);border-color:var(--ui-line); }
html[data-theme=dark] body > main:not([class]) button:not(.primary):not(.danger):not(.reply) { background:var(--ui-muted);color:var(--ui-text);border-color:var(--ui-line); }
html[data-theme=dark] .notice { background:var(--ui-active);color:var(--ui-text); }
html[data-theme=dark] .error,html[data-theme=dark] .auth-error { color:#fecaca;background:#4b2430;border-color:#ad5767; }
/* Keep the existing board layout while switching its palette. */
html[data-theme=light] .board-layout :is(input,select,textarea,.editor-toolbar select) { background:var(--ui-surface);color:var(--ui-text);border-color:var(--ui-line); }
html[data-theme=light] .board-layout :is(button,.button) { background:var(--ui-surface);color:var(--ui-text);border-color:var(--ui-line); }
html[data-theme=light] .board-layout :is(.primary,.button.primary) { background:#2563eb;color:white; }
html[data-theme=light] .board-layout :is(.table-heading,.category) { background:#e8eef7;color:#334155; }
html[data-theme=light] .board-row:not(.table-heading):hover { background:var(--ui-active); }
html[data-theme=light] .board-layout .error { background:#fef2f2;color:#991b1b; }
html[data-theme=light] .board-layout .danger { color:#b91c1c; }
html[data-theme=light] :is(.rich-content blockquote,.rich-content th,.preview-banner) { background:var(--ui-muted);color:var(--ui-text); }
html[data-theme=light] :is(.rich-content a,.editor-status) { color:var(--ui-accent); }
html[data-theme=light] .editor-toolbar button[aria-pressed=true] { background:var(--ui-active);color:var(--ui-accent);border-color:#93b4ef; }
html[data-theme=dark] .auth-error { color:#fecaca!important; }
html[data-theme=dark] .auth-card .eyebrow { color:var(--ui-accent); }
html[data-theme=dark] .auth-panel { background:var(--ui-bg); }
html[data-theme] .auth-theme { margin-top:14px;max-width:250px; }
