/* RAIOT palette values. Status colors intentionally retain their meaning. */
:root {
    --raiot-color-ground: #060b16;
    --raiot-color-panel: #0a1222;
    --raiot-color-surface: #0d1729;
    --raiot-color-raised: #14243b;
    --raiot-color-line: #253851;
    --raiot-color-line-hi: #3a577c;
    --raiot-color-text: #eaf1ff;
    --raiot-color-muted: #b0bfda;
    --raiot-color-accent: #4fb8ff;
    --raiot-color-accent-rgb: 79, 184, 255;
    --raiot-color-highlight: #8ad3ff;
    --raiot-color-secondary: #34e0c0;
    --raiot-color-success: #3ddc97;
    --raiot-color-warning: #e9c68e;
    --raiot-color-danger: #ff6b8b;
    --raiot-color-violet: #b899fa;
    --raiot-color-orange: #f99258;
    --raiot-color-rose: #ed8cc8;
}
:root[data-raiot-theme="graphite"] {
    --raiot-color-ground: #141211;
    --raiot-color-panel: #1b1715;
    --raiot-color-surface: #241f1b;
    --raiot-color-raised: #322921;
    --raiot-color-line: #5b493a;
    --raiot-color-line-hi: #927258;
    --raiot-color-text: #fff1e3;
    --raiot-color-muted: #dac4ae;
    --raiot-color-accent: #ffb778;
    --raiot-color-accent-rgb: 255, 183, 120;
    --raiot-color-highlight: #ffd3a7;
    --raiot-color-secondary: #eed29f;
    --raiot-color-violet: #c7a2e8;
    --raiot-color-orange: #eb9066;
    --raiot-color-rose: #ef9fb1;
}
:root[data-raiot-theme="contrast"] {
    --raiot-color-ground: #000;
    --raiot-color-panel: #070707;
    --raiot-color-surface: #121212;
    --raiot-color-raised: #242424;
    --raiot-color-line: #7d7d7d;
    --raiot-color-line-hi: #b1b1b1;
    --raiot-color-text: #fff;
    --raiot-color-muted: #ededed;
    --raiot-color-accent: #fff378;
    --raiot-color-accent-rgb: 255, 243, 120;
    --raiot-color-highlight: #fff8af;
    --raiot-color-secondary: #a0eaff;
    --raiot-color-success: #64e7a1;
    --raiot-color-warning: #ffe285;
    --raiot-color-danger: #ff95aa;
    --raiot-color-violet: #dcc1ff;
    --raiot-color-orange: #ffb685;
    --raiot-color-rose: #ffaef1;
}

.raiot-app, .raiot-auth {
    --bs-body-bg: var(--raiot-color-ground);
    --bs-body-color: var(--raiot-color-text);
    --bs-primary: var(--raiot-color-accent);
    --bs-primary-rgb: var(--raiot-color-accent-rgb);
    --bs-link-color: var(--raiot-color-highlight);
    --bs-link-hover-color: var(--raiot-color-accent);
    --bs-border-color: var(--raiot-color-line);
    --bs-secondary-color: var(--raiot-color-muted);
    --bs-secondary-bg: var(--raiot-color-raised);
    --bs-tertiary-bg: var(--raiot-color-panel);
    --vg-accent: var(--raiot-color-accent);
    --vg-success: var(--raiot-color-success);
    --vg-warning: var(--raiot-color-warning);
    --vg-danger: var(--raiot-color-danger);
    --vgf-ok: var(--raiot-color-success);
    --vgf-warn: var(--raiot-color-warning);
    --vgf-bad: var(--raiot-color-danger);
    --vgt-ok: var(--raiot-color-success);
    --vgt-warn: var(--raiot-color-warning);
    --vgt-bad: var(--raiot-color-danger);
    --vgv-ok: var(--raiot-color-success);
    --vgv-warn: var(--raiot-color-warning);
    --vgv-bad: var(--raiot-color-danger);
    --edge-bg-primary: var(--raiot-color-ground);
    --edge-bg-card: var(--raiot-color-surface);
    --edge-bg-card-hover: var(--raiot-color-raised);
    --edge-bg-input: var(--raiot-color-panel);
    --edge-surface: var(--raiot-color-surface);
    --edge-surface-2: var(--raiot-color-raised);
    --edge-border: var(--raiot-color-line);
    --edge-border-hover: var(--raiot-color-line-hi);
    --edge-border-focus: var(--raiot-color-accent);
    --edge-accent: var(--raiot-color-accent);
    --edge-accent-light: var(--raiot-color-highlight);
    --edge-accent-glow: color-mix(in srgb, var(--edge-accent) 25%, transparent);
    --edge-info: var(--raiot-color-highlight);
    --edge-text: var(--raiot-color-text);
    --edge-text-muted: var(--raiot-color-muted);
    --edge-text-dim: var(--raiot-color-muted);
    --edge-muted: var(--raiot-color-muted);
    background-color: var(--raiot-color-ground);
    color: var(--raiot-color-text);
}
.raiot-app :is(.card, .modal-content, .dropdown-menu, .swal2-popup),
.raiot-auth :is(.modal-content, .dropdown-menu, .swal2-popup) {
    background-color: var(--raiot-color-surface);
    color: var(--raiot-color-text);
    border-color: var(--raiot-color-line);
}
.raiot-app :is(.table, .table-dark, .table-striped) {
    --bs-table-color: var(--raiot-color-text);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--raiot-color-line);
    --bs-table-striped-color: var(--raiot-color-text);
    --bs-table-striped-bg: color-mix(in srgb, var(--raiot-color-raised) 40%, transparent);
    --bs-table-hover-color: var(--raiot-color-text);
    --bs-table-hover-bg: var(--raiot-color-raised);
    color: var(--raiot-color-text);
}
.raiot-app .swal2-popup { background-color: var(--raiot-color-surface) !important; color: var(--raiot-color-text); }
.raiot-app .swal2-popup :is(.swal2-title, .swal2-html-container) { color: var(--raiot-color-text); }
.raiot-app .table :is(td, th) { border-color: var(--raiot-color-line); }
.raiot-app .text-muted, .raiot-auth .text-muted { color: var(--raiot-color-muted) !important; }
.raiot-app :is(.form-control, .form-select, .custom-select, .raiot-theme-picker select),
.raiot-auth :is(.form-control, .form-select) {
    background-color: var(--raiot-color-panel);
    color: var(--raiot-color-text);
    border-color: var(--raiot-color-line);
}
.raiot-app :is(.form-control, .form-select)::placeholder,
.raiot-auth .form-control::placeholder { color: var(--raiot-color-muted); }
.raiot-app :is(.form-control, .form-select, .custom-select, .raiot-theme-picker select):focus,
.raiot-auth :is(.form-control, .form-select):focus {
    background-color: var(--raiot-color-panel);
    color: var(--raiot-color-text);
    border-color: var(--raiot-color-accent);
    box-shadow: 0 0 0 .18rem color-mix(in srgb, var(--raiot-color-accent) 30%, transparent);
}
.raiot-app :is(.form-control, .form-select, .custom-select):disabled {
    background: var(--raiot-color-raised);
    color: var(--raiot-color-muted);
    opacity: 1;
}
.raiot-app :is(.form-control, .form-select):disabled::placeholder {
    color: var(--raiot-color-muted);
    opacity: 1;
}
.raiot-app .vgcam-section .table .form-control:disabled { cursor: not-allowed; }
.raiot-app .btn-primary {
    --bs-btn-bg: var(--raiot-color-accent);
    --bs-btn-color: var(--raiot-color-ground);
    --bs-btn-border-color: var(--raiot-color-accent);
    --bs-btn-hover-bg: var(--raiot-color-highlight);
    --bs-btn-hover-border-color: var(--raiot-color-highlight);
    --bs-btn-hover-color: var(--raiot-color-ground);
    --bs-btn-active-bg: var(--raiot-color-highlight);
    --bs-btn-active-color: var(--raiot-color-ground);
    --bs-btn-active-border-color: var(--raiot-color-highlight);
    background-color: var(--bs-btn-bg);
    border-color: var(--bs-btn-border-color);
    color: var(--bs-btn-color);
}
.raiot-app .btn-primary:hover:not(:disabled) {
    background-color: var(--bs-btn-hover-bg);
    border-color: var(--bs-btn-hover-border-color);
    color: var(--bs-btn-hover-color);
}
.raiot-app .btn-outline-primary {
    --bs-btn-hover-color: var(--raiot-color-ground);
    --bs-btn-hover-bg: var(--raiot-color-accent);
    --bs-btn-hover-border-color: var(--raiot-color-accent);
    border-color: var(--raiot-color-accent);
    color: var(--raiot-color-highlight);
}
.raiot-app .btn-outline-primary:hover:not(:disabled) {
    background-color: var(--bs-btn-hover-bg);
    border-color: var(--bs-btn-hover-border-color);
    color: var(--bs-btn-hover-color);
}
.raiot-app input:is([type="checkbox"], [type="radio"]) { accent-color: var(--raiot-color-accent); }
.raiot-app .form-check-input:checked {
    background-color: var(--raiot-color-accent);
    border-color: var(--raiot-color-highlight);
}
.raiot-app .site-setup p, .raiot-app .site-setup__option span span { color: var(--raiot-color-muted); }
.raiot-app .site-setup__save { color: var(--raiot-color-ground); }

/* Older counting and Scene Change screens use their own component classes. */
.raiot-app :is(.sc-detail, .sc-list, .sc-metric, .fc-stat, .fc-table-wrap) {
    background: var(--raiot-color-surface);
    border-color: var(--raiot-color-line);
}
.raiot-app :is(.sc-list-hd, .fc-table th, .fc-select, .fc-search) {
    background: var(--raiot-color-panel);
    border-color: var(--raiot-color-line);
}
.raiot-app :is(.sc-item, .sc-rtable td, .sc-rtable th, .fc-table td) {
    border-block-end-color: var(--raiot-color-line);
}
.raiot-app :is(.sc-item.active, .fc-page-btn.active, .cm-tab.active, .fc-note, .fc-zone-badge:not(.warn)) {
    background: var(--raiot-color-raised);
    border-color: var(--raiot-color-line-hi);
    color: var(--raiot-color-highlight);
}
.raiot-app .sc-item.active { border-inline-start-color: var(--raiot-color-accent); }
.raiot-app :is(.sc-btn.primary, .fc-seg button.active, .pc-step.active .pc-step-num) {
    background: var(--raiot-color-accent);
    border-color: var(--raiot-color-highlight);
    color: var(--raiot-color-ground);
}
.raiot-app .sc-btn.primary:hover { background: var(--raiot-color-highlight); }
.raiot-app :is(.fc-search, .fc-field input, .fc-field select):focus { border-color: var(--raiot-color-accent); }
.raiot-app :is(.fc-action-btn:not(.danger):hover, .fc-page-btn:hover, .fc-adv-toggle) { color: var(--raiot-color-highlight); }
.raiot-app .draw-field select option { background-color: var(--raiot-color-panel); }

@media screen {
    .raiot-app .text-primary, .raiot-auth .text-primary { color: var(--raiot-color-highlight) !important; }
    .raiot-app .border-primary { border-color: var(--raiot-color-accent) !important; }
    .raiot-app .alert-danger, .raiot-auth .alert-danger {
        background: color-mix(in srgb, var(--raiot-color-danger) 12%, var(--raiot-color-surface));
        color: var(--raiot-color-danger);
        border-color: var(--raiot-color-danger);
    }
    .raiot-app #page-content :is(.card, .dashboard-card, .main-card) > .card-header:not(.bg-transparent) {
        background: var(--raiot-color-panel);
        border-color: var(--raiot-color-line);
    }
    .raiot-app #page-content .card > .card-header:is(.bg-primary, .bg-gradient-primary) {
        background: var(--raiot-color-accent) !important;
        color: var(--raiot-color-ground) !important;
    }
    .raiot-app :is(.dashboard-card, .kpi-card, .main-card, .fsh-table-wrap, .vg-state--framed) {
        background: var(--raiot-color-surface);
        border-color: var(--raiot-color-line);
    }
    .raiot-app :is(.fsh-page, .fr-page) {
        background: var(--raiot-color-ground);
        color: var(--raiot-color-text);
    }
    .raiot-app .layout-grid > :is(.side-panel, .main-panel),
    .raiot-app :is(.fr-page, .fsh-page) :is(.card-head, .st-empty, .fsh-table thead),
    .raiot-app .bg-dark-soft,
    .raiot-app #noVideoSelected.alert-info {
        background: var(--raiot-color-panel);
        color: var(--raiot-color-text);
        border-color: var(--raiot-color-line);
    }
    .raiot-app #page-content :is(.config-section, .inference-status, .edge-page .stat-card, .edge-page .filter-bar,
        .edge-page .section-card, .edge-page .group-card, .edge-page .stream-card, .edge-page .guide-card,
        .edge-page .health-card, .edge-page .chart-section, #cameraPreviewPopover, #cameraPreviewPopover .preview-content) {
        background: var(--raiot-color-surface);
        border-color: var(--raiot-color-line);
    }
    .raiot-app #page-content :is(.config-section-header, .edge-page .group-head, .edge-page #aiPanel, #zone-multi) {
        background: var(--raiot-color-raised);
        border-color: var(--raiot-color-line);
    }
    .raiot-app .edge-page .field-control :is(select, option, input[type="text"], input[type="number"]) {
        background: var(--raiot-color-panel);
        color: var(--raiot-color-text);
    }
    .raiot-app .edge-page .skeleton-loader {
        background-image: linear-gradient(90deg, var(--raiot-color-surface) 25%, var(--raiot-color-raised) 50%, var(--raiot-color-surface) 75%);
    }
    .raiot-app .sc-banner.ok {
        background: color-mix(in srgb, var(--raiot-color-success) 10%, var(--raiot-color-surface));
        border-color: var(--raiot-color-success);
    }
    .raiot-app .raiot-legacy-dashboard .bg-gray-dark,
    .raiot-app.raiot-legacy-dashboard .bg-gray-dark {
        background-color: var(--raiot-color-panel) !important;
        color: var(--raiot-color-text);
    }
    .raiot-app .permissions-editor .header-text h1 {
        background-image: linear-gradient(135deg, var(--raiot-color-text), var(--raiot-color-highlight));
    }
    .raiot-app .permissions-editor :is(.bulk-actions-bar, .accordion-item, .permission-card) {
        background: var(--raiot-color-panel);
        border-color: var(--raiot-color-line);
    }
    .raiot-app .permissions-editor {
        --primary-gradient: linear-gradient(135deg, var(--raiot-color-highlight), var(--raiot-color-accent));
        --primary-hover: linear-gradient(135deg, var(--raiot-color-accent), var(--raiot-color-highlight));
        --glass-bg: var(--raiot-color-panel);
        --glass-border: var(--raiot-color-line);
    }
    .raiot-app .permissions-editor .main-card {
        background: var(--raiot-color-surface);
        border-color: var(--raiot-color-line);
    }
    .raiot-app .permissions-editor :is(.gradient-sphere, .gradient-sphere-2) {
        background: radial-gradient(circle, color-mix(in srgb, var(--raiot-color-accent) 12%, transparent), transparent 70%);
    }
    .raiot-app .permissions-editor :is(.role-badge, .stat-chip, .filter-btn, .search-input) {
        background: var(--raiot-color-raised);
        border-color: var(--raiot-color-line);
        color: var(--raiot-color-text);
    }
    .raiot-app .permissions-editor :is(.filter-btn.active, .filter-btn:hover) {
        background: var(--raiot-color-accent);
        border-color: var(--raiot-color-accent);
        color: var(--raiot-color-ground);
    }
    .raiot-app .permissions-editor :is(.search-input:focus, .permission-card:hover) {
        border-color: var(--raiot-color-accent);
    }
    .raiot-app .permissions-editor :is(.fab-main, .permission-checkbox input:checked ~ .checkbox-custom) {
        color: var(--raiot-color-ground);
    }
    .raiot-app .permissions-editor .custom-checkbox input:checked ~ .checkmark::after {
        border-color: var(--raiot-color-ground);
    }
    .raiot-app .permissions-editor .custom-checkbox input:indeterminate ~ .checkmark::after {
        background: var(--raiot-color-ground);
    }
    .raiot-app .camera-interval-history {
        --bg-card: var(--raiot-color-surface);
        --bg-card-light: var(--raiot-color-panel);
        --bg-hover: var(--raiot-color-raised);
        --border-dark: var(--raiot-color-line);
        --text-primary: var(--raiot-color-text);
        --text-secondary: var(--raiot-color-muted);
        --text-muted: var(--raiot-color-muted);
        --primary-color: var(--raiot-color-accent);
        --primary-dark: var(--raiot-color-highlight);
    }
    .raiot-app .camera-interval-history .table-header-row {
        background: var(--raiot-color-raised);
    }
    .raiot-app .camera-interval-history .page-item.disabled .page-link {
        background-color: var(--raiot-color-panel) !important;
        border-color: var(--raiot-color-line);
    }
}

@media print {
    .raiot-app .permissions-editor,
    .raiot-app .permissions-editor :is(.glass-effect, .main-card, .card-header, .accordion-item, .permission-card) {
        background: #fff;
        color: #111;
        border-color: #777;
        box-shadow: none;
        color-scheme: light;
    }
    .raiot-app .permissions-editor :is(.header-text h1, .card-title, .group-name, .permission-name, .empty-state p) {
        background: none;
        color: #111;
        -webkit-text-fill-color: currentColor;
    }
}

.raiot-theme-menu { padding: .65rem .9rem; }
.raiot-theme-picker {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
    margin: 0;
    color: var(--raiot-color-text);
    font-weight: 700;
}
.raiot-theme-picker select {
    max-inline-size: 100%;
    min-block-size: 2.5rem;
    padding: .3rem .55rem;
    border: 1px solid var(--raiot-color-line-hi);
    border-radius: var(--vg-radius-sm);
    font: inherit;
}
.raiot-theme-picker select:focus-visible {
    outline: 2px solid var(--raiot-color-accent);
    outline-offset: 2px;
}
.raiot-theme-settings { margin-block-end: 1.25rem; }
