/* Shared TEO palette and adapters for the November 5 planner and legacy pages. */
:root {
    --teo-theme-page: #0f172a;
    --teo-theme-surface: #142035;
    --teo-theme-raised: #1b2b43;
    --teo-theme-input: #0e1a2b;
    --teo-theme-text: #edf3fa;
    --teo-theme-muted: #a8b8cb;
    --teo-theme-border: #41536d;
    --teo-theme-input-border: #647b98;
    --teo-theme-primary: #285a93;
    --teo-theme-on-primary: #fff;
    --teo-theme-link: #a6caff;
    --teo-theme-accent: #ffad79;
    --teo-theme-focus: #84b7ff;
    --teo-theme-success: #94e1bf;
    --teo-theme-warning: #ffca92;
    --teo-theme-danger: #ffc2bd;
}

:root[data-teo-theme="dark"] { color-scheme: dark; }

:root[data-teo-theme="light"] {
    color-scheme: light;
    --teo-theme-page: #f3f6fa;
    --teo-theme-surface: #ffffff;
    --teo-theme-raised: #e9eff7;
    --teo-theme-input: #ffffff;
    --teo-theme-text: #17253a;
    --teo-theme-muted: #4e5f74;
    --teo-theme-border: #bdc9d9;
    --teo-theme-input-border: #7488a1;
    --teo-theme-primary: #1f5f97;
    --teo-theme-on-primary: #fff;
    --teo-theme-link: #174f85;
    --teo-theme-accent: #a34316;
    --teo-theme-focus: #245b97;
    --teo-theme-success: #175c42;
    --teo-theme-warning: #70450c;
    --teo-theme-danger: #922e36;
    --teo-theme-success-bg: #e5f3ec;
    --teo-theme-warning-bg: #fff2dd;
    --teo-theme-danger-bg: #fbe9eb;
    --teo-theme-shadow: 0 12px 32px #213a5c17;
}

:root[data-teo-theme] .teo-theme-control {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    flex: 0 0 auto;
    margin: 0;
    color: var(--teo-theme-muted);
    font: 600 .8rem/1.3 system-ui, sans-serif;
}

:root[data-teo-theme] .teo-theme-control select {
    width: auto;
    min-width: 5.8rem;
    min-height: 44px;
    margin: 0;
    padding: .45rem .6rem;
    border: 1px solid var(--teo-theme-input-border);
    border-radius: .55rem;
    background: var(--teo-theme-input);
    color: var(--teo-theme-text);
    font: inherit;
    cursor: pointer;
}

:root[data-teo-theme] .teo-theme-control select:focus-visible {
    outline: 3px solid var(--teo-theme-focus);
    outline-offset: 2px;
}

.card > .teo-theme-control { margin-block-start: 1rem; }
:where(.site-nav, .top-actions, header .actions):has(.teo-theme-control) { flex-wrap: wrap; }

@media screen {
    :root[data-teo-theme="light"][data-teo-page] {
        --bg: var(--teo-theme-page);
        --panel: var(--teo-theme-surface);
        --panel-light: var(--teo-theme-raised);
        --text: var(--teo-theme-text);
        --muted: var(--teo-theme-muted);
        --line: var(--teo-theme-border);
        --blue: var(--teo-theme-primary);
        --orange: var(--teo-theme-accent);
        --brand-orange: var(--teo-theme-accent);
        --green: #237452;
        --red: #a52c38;
        --danger: var(--teo-theme-danger);
        --shadow: var(--teo-theme-shadow);
    }

    :root[data-teo-theme="light"][data-teo-page] body {
        background: var(--teo-theme-page);
        color: var(--teo-theme-text);
    }

    :root[data-teo-theme="light"][data-teo-page] :is(header, .site-nav) {
        background: var(--teo-theme-surface);
        border-bottom-color: var(--teo-theme-border);
    }

    :root[data-teo-theme="light"][data-teo-page] :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
        background: var(--teo-theme-input);
        color: var(--teo-theme-text);
        border-color: var(--teo-theme-input-border);
    }

    :root[data-teo-theme="light"][data-teo-page] :is(a, button, input, select, textarea, [tabindex]):focus-visible {
        outline: 3px solid var(--teo-theme-focus);
        outline-offset: 2px;
    }

    :root[data-teo-theme="light"][data-teo-page] :is(.muted, .subtitle, .small, .hint) { color: var(--teo-theme-muted); }

    :root[data-teo-theme="light"] :is(.hero, .status-card, .stat, .module, .progress-card, .panel, .card, .table-wrap) {
        background: var(--teo-theme-surface);
        border-color: var(--teo-theme-border);
        box-shadow: var(--teo-theme-shadow);
    }

    :root[data-teo-theme="light"] :is(.hero, .card) { border-top-color: var(--teo-theme-accent); }
    :root[data-teo-theme="light"] :is(.hero p, .legend-row, .made, label, .chart-summary, .chart-note) { color: var(--teo-theme-muted); }
    :root[data-teo-theme="light"] :is(.eyebrow, .trend-limit, .warn, .status-warn) { color: var(--teo-theme-warning); }
    :root[data-teo-theme="light"] :is(.status-ok, .ok) { color: var(--teo-theme-success); }
    :root[data-teo-theme="light"] .status-bad { color: var(--teo-theme-danger); }

    :root[data-teo-theme="light"] :is(.button, .admin-link, .btn-secondary, .menu > button) {
        background: var(--teo-theme-raised);
        color: var(--teo-theme-text);
        border-color: var(--teo-theme-border);
    }

    :root[data-teo-theme="light"] :is(.button.primary, .primary, .btn-success, .btn-purple, .btn-danger) {
        color: var(--teo-theme-on-primary);
    }

    :root[data-teo-theme="light"] .button.primary { background: var(--teo-theme-primary); }
    :root[data-teo-theme="light"] .btn-warning { background: var(--teo-theme-warning-bg); color: var(--teo-theme-warning); }
    :root[data-teo-theme="light"] .account-link { color: var(--teo-theme-muted); }
    :root[data-teo-theme="light"] .donut::before { background: var(--teo-theme-surface); }
    :root[data-teo-theme="light"] .donut.empty { background: #a7b5c8; }
    :root[data-teo-theme="light"] .version { background: var(--teo-theme-surface); color: var(--teo-theme-muted); }

    /* Existing project planner. */
    :root[data-teo-theme="light"][data-teo-page="planner"] :is(.menu-list, .gantt-label, .gantt-wrapper, .status-line, .stat-card, .person-card, .work-item) {
        background: var(--teo-theme-surface);
        border-color: var(--teo-theme-border);
    }

    :root[data-teo-theme="light"][data-teo-page="planner"] :is(.panel h2, .gantt-month, .menu-list button:hover, .legend span, .badge, .capacity) {
        background: var(--teo-theme-raised);
        border-color: var(--teo-theme-border);
    }

    :root[data-teo-theme="light"] :is(.menu-list .divider, .gantt-label, .gantt-month, .bar-container) { border-color: var(--teo-theme-border); }
    :root[data-teo-theme="light"] .menu-list .divider { background: var(--teo-theme-border); }
    :root[data-teo-theme="light"] .bar-container { background-image: linear-gradient(to right, #c7d2e1 1px, transparent 1px); }
    :root[data-teo-theme="light"] .bar { color: #1d3652; background: #e0ecfa; box-shadow: 0 2px 6px #213a5c24; }
    :root[data-teo-theme="light"] .bar.Konstruktion { background: #eadef8; color: #4a2e70; }
    :root[data-teo-theme="light"] .bar.Elektroprojekt { background: #ffedc5; color: #633e10; }
    :root[data-teo-theme="light"] .bar.Mechanik { background: #d9f0e3; color: #154e39; }
    :root[data-teo-theme="light"] .bar.Instandhaltung { background: #e2e9f1; color: #354c64; }
    :root[data-teo-theme="light"] .bar.Prüfung { background: #fbe2e6; color: #822d3d; }
    :root[data-teo-theme="light"] .bar.Fremdfirma { background: #d7eff4; color: #134a5a; }
    :root[data-teo-theme="light"] .bar.donebar { opacity: 1; border: 1px dashed #70849e; }
    :root[data-teo-theme="light"] .work-item.done { opacity: 1; color: var(--teo-theme-muted); }
    :root[data-teo-theme="light"] .work-item .prio-Hoch { color: var(--teo-theme-danger); background: var(--teo-theme-danger-bg); }
    :root[data-teo-theme="light"] .work-item .prio-Mittel { color: var(--teo-theme-warning); background: var(--teo-theme-warning-bg); }
    :root[data-teo-theme="light"] .work-item .prio-Niedrig { color: var(--teo-theme-success); background: var(--teo-theme-success-bg); }
    :root[data-teo-theme="light"] .completion-report { color: var(--teo-theme-text); background: var(--teo-theme-success-bg); border-color: #a7cbb7; }
    :root[data-teo-theme="light"] :is(.gantt-label, .work-item) [style*="color:#9ca3af"],
    :root[data-teo-theme="light"] .work-item [style*="color:#cbd5e1"] { color: var(--teo-theme-muted) !important; }

    /* Existing admin/login and sensor views. */
    :root[data-teo-theme="light"][data-teo-page="admin"] :is(nav, .rights > *, .pill) { background: var(--teo-theme-raised); }
    :root[data-teo-theme="light"][data-teo-page="admin"] :is(a, button):not(.primary, .danger, .success, .active) {
        background: var(--teo-theme-raised);
        color: var(--teo-theme-text);
    }

    :root[data-teo-theme="light"][data-teo-page="admin"] nav :is(.active, [aria-current="page"]) {
        background: var(--teo-theme-primary);
        color: var(--teo-theme-on-primary);
    }

    :root[data-teo-theme="light"][data-teo-page="admin"] :is(.danger, .success) { color: var(--teo-theme-on-primary); }
    :root[data-teo-theme="light"] .error { background: var(--teo-theme-danger-bg); color: var(--teo-theme-danger); }
    :root[data-teo-theme="light"] .notice { background: var(--teo-theme-success-bg); color: var(--teo-theme-success); }
    :root[data-teo-theme="light"][data-teo-page="login"] .card { border-top-color: var(--teo-theme-accent); }
    :root[data-teo-theme="light"][data-teo-page="sensors"] a:not(.button) { color: var(--teo-theme-link); }
    :root[data-teo-theme="light"] .trend-actions a[aria-current="page"] {
        background: #d9e9fa;
        color: #17486e;
        box-shadow: inset 0 0 0 1px #5d84ad;
    }

    :root[data-teo-theme="light"] .chart-scroll { background: var(--teo-theme-surface); }
    :root[data-teo-theme="light"] .sensor-chart text { fill: var(--teo-theme-muted); }
    :root[data-teo-theme="light"] .sensor-chart .chart-gridline { stroke: #ced9e6; }
    :root[data-teo-theme="light"] .sensor-chart .chart-axis { stroke: #7d91aa; }
    :root[data-teo-theme="light"] .sensor-chart.temperature .chart-line { stroke: #a34316; }
    :root[data-teo-theme="light"] .sensor-chart.temperature .chart-point { fill: #a34316; }
    :root[data-teo-theme="light"] .sensor-chart.humidity .chart-line { stroke: #1e5e99; }
    :root[data-teo-theme="light"] .sensor-chart.humidity .chart-point { fill: #1e5e99; }

    /* Team plan timeline, status, dialog and import preview. */
    :root[data-teo-theme="light"][data-teo-page="team"] .site-nav a { color: var(--teo-theme-link); }
    :root[data-teo-theme="light"][data-teo-page="team"] .site-nav strong { color: var(--teo-theme-text); }
    :root[data-teo-theme="light"][data-teo-page="team"] button:not(.primary, .danger, .assignment-bar, .absence-bar):hover { background: #dce7f3; }
    :root[data-teo-theme="light"][data-teo-page="team"] button.primary { color: var(--teo-theme-on-primary); background: var(--teo-theme-primary); border-color: var(--teo-theme-primary); }
    :root[data-teo-theme="light"][data-teo-page="team"] button.primary:hover { background: #194e7d; }
    :root[data-teo-theme="light"][data-teo-page="team"] button.danger { color: var(--teo-theme-danger); border-color: #bd747e; background: var(--teo-theme-danger-bg); }
    :root[data-teo-theme="light"] .save-status { background: var(--teo-theme-success-bg); border-color: #9abcae; color: var(--teo-theme-success); }
    :root[data-teo-theme="light"] .save-error { background: var(--teo-theme-danger-bg); border-color: #bd747e; color: var(--teo-theme-danger); }
    :root[data-teo-theme="light"] .team-tabs { background: var(--teo-theme-raised); }
    :root[data-teo-theme="light"] .team-tabs button.selected { color: var(--teo-theme-text); background: #fff; box-shadow: 0 1px 5px #263c5930; }
    :root[data-teo-theme="light"] .team-tabs span { color: #3e5e80; background: #dce7f3; }
    :root[data-teo-theme="light"] .summary-grid .attention strong { color: var(--teo-theme-warning); }
    :root[data-teo-theme="light"] :is(.plan-caption strong, .date-day strong) { color: var(--teo-theme-text); }
    :root[data-teo-theme="light"] .timeline-scroll { scrollbar-color: #7a8fa9 #eef2f7; }
    :root[data-teo-theme="light"] :is(.timeline-head, .person-head) { background: var(--teo-theme-raised); }
    :root[data-teo-theme="light"] :is(.date-day, .person-row, .background-day) { border-color: #d3deeb; }
    :root[data-teo-theme="light"] :is(.date-day.weekend, .background-day.weekend) { background: #edf2f8; }
    :root[data-teo-theme="light"] .date-day.today { background: #d7e8fb; color: #234e7c; }
    :root[data-teo-theme="light"] .date-day.today strong { color: #143d66; }
    :root[data-teo-theme="light"] .background-day.today { background: #eaf3fe; border-left-color: #7199c8; }
    :root[data-teo-theme="light"] .person-cell { background: #f4f7fb; }
    :root[data-teo-theme="light"] .person-button:hover { color: var(--teo-theme-link); }
    :root[data-teo-theme="light"] .avatar { color: #174975; background: #dceafa; border-color: #99b8d6; }
    :root[data-teo-theme="light"] :is(.trainee-avatar, .mini-badge) { color: #4d3470; background: #eee4fb; border-color: #bba6d1; }
    :root[data-teo-theme="light"] :is(.row-count, .free-label, .calculation-note, .read-label) { color: var(--teo-theme-muted); }
    :root[data-teo-theme="light"] .assignment-bar { background: #dbeafe; color: #173653; border-color: #7195bc; border-left-color: #356ea9; }
    :root[data-teo-theme="light"] .assignment-bar:hover { filter: brightness(.95); }
    :root[data-teo-theme="light"] .assignment-bar small { color: inherit; }
    :root[data-teo-theme="light"] .bar-progress { background: #2c69a31f; }
    :root[data-teo-theme="light"] .assignment-bar.laeuft { background: #dcefe5; color: #184a38; border-color: #6f9d89; border-left-color: #28765a; }
    :root[data-teo-theme="light"] .assignment-bar.blockiert { background: #fff1d8; color: #653f11; border-color: #b79768; border-left-color: #99651e; }
    :root[data-teo-theme="light"] .assignment-bar.erledigt { background: #e6edf4; color: #3b4e63; border-color: #93a4b9; border-left-color: #667c94; opacity: 1; }
    :root[data-teo-theme="light"] .assignment-bar.has-conflict { border-bottom-color: #a34f1b; }
    :root[data-teo-theme="light"] .conflict-mark { background: #ffda9b; color: #664019; }
    :root[data-teo-theme="light"] .absence-bar { background: repeating-linear-gradient(135deg, #e0e6ee, #e0e6ee 5px, #d5dfe9 5px, #d5dfe9 10px); border-color: #7e91a8; color: #2e4057; }
    :root[data-teo-theme="light"] .absence-bar.berufsschule { background: #eadff8; border-color: #a48abb; color: #4c3569; }
    :root[data-teo-theme="light"] .absence-bar.abwesend { background: #f7e9d7; border-color: #ad9274; color: #60472f; }
    :root[data-teo-theme="light"] .warnings { background: var(--teo-theme-warning-bg); border-color: #c5a77c; }
    :root[data-teo-theme="light"] :is(.warnings h2, .warnings > button span, .import-table td small) { color: var(--teo-theme-warning); }
    :root[data-teo-theme="light"] .team-dialog { background: var(--teo-theme-surface); border-color: var(--teo-theme-border); box-shadow: 0 20px 80px #22395750; }
    :root[data-teo-theme="light"] .team-dialog::backdrop { background: #20314d66; }
    :root[data-teo-theme="light"] :is(.dialog-body p, .dialog-body label:not(.check), .check) { color: var(--teo-theme-muted); }
    :root[data-teo-theme="light"] .field-hint { color: var(--teo-theme-muted) !important; }
    :root[data-teo-theme="light"] :is(.dialog-footer, .import-table th) { background: var(--teo-theme-raised); }
    :root[data-teo-theme="light"] .form-error { background: var(--teo-theme-danger-bg); border-color: #bd747e; color: var(--teo-theme-danger) !important; }
    :root[data-teo-theme="light"] .form-error p { color: var(--teo-theme-danger); }
}

/* This section is used when the same sheet is attached to the tour shadow root. */
:host([data-teo-theme="light"]) {
    --teo-bg: #fff;
    --teo-line: #9cabc0;
    --teo-text: #17253a;
    --teo-muted: #4e5f74;
    --teo-accent: #a34316;
    color-scheme: light;
}

:host([data-teo-theme="light"]) :is(button, .launcher) { background: #e9eff7; color: var(--teo-text); }
:host([data-teo-theme="light"]) button:hover { background: #dce7f3; }
:host([data-teo-theme="light"]) button.primary { background: #1f5f97; color: #fff; border-color: #1f5f97; }
:host([data-teo-theme="light"]) button.primary:hover { background: #194e7d; }
:host([data-teo-theme="light"]) button.quiet { background: transparent; }
:host([data-teo-theme="light"]) a { color: #174f85; }
:host([data-teo-theme="light"]) .practice { background: #edf3f9; }
:host([data-teo-theme="light"]) .feedback { color: #175c42; }
:host([data-teo-theme="light"]) :is(.missing, .step-list button[aria-current="step"]) { background: #fff2dd; color: #70450c; }
:host([data-teo-theme="light"]) .progress { background: #dbe4ef; }
:host([data-teo-theme="light"]) :is(button, a, summary):focus-visible { outline: 3px solid #245b97; outline-offset: 2px; }

@media print {
    .teo-theme-control { display: none !important; }
}
