:root {
    --theme-page:#efedf2;
    --theme-shell:#f8f7f9;
    --theme-surface:#fff;
    --theme-surface-soft:#f7f5f8;
    --theme-border:#e3dee6;
    --theme-text:#251d2c;
    --theme-heading:#372549;
    --theme-muted:#776f7c;
    --theme-accent:#b9ba6c;
}

html[data-theme="dark"] {
    --theme-page:#24202a;
    --theme-shell:#2d2833;
    --theme-surface:#39323f;
    --theme-surface-soft:#453c4c;
    --theme-border:#665b70;
    --theme-text:#f3eff6;
    --theme-heading:#fbf8fc;
    --theme-muted:#b8afbd;
    --theme-accent:#c6c879;
    color-scheme:dark;
    background:var(--theme-page);
}

.theme-card {
    display:grid;
    grid-template-columns:48px minmax(0,1fr) auto;
    align-items:center;
    gap:12px;
    padding:14px;
    border:1px solid rgba(55,37,73,.09);
    border-radius:18px;
    background:#fff;
    box-shadow:0 9px 26px rgba(55,37,73,.055);
}
.theme-card-icon { display:grid; width:48px; height:48px; place-items:center; border-radius:15px; color:#554361; background:#eeefd8; }
.theme-card-icon .app-icon { width:25px; height:25px; }
.theme-card-copy { display:flex; min-width:0; flex-direction:column; gap:3px; }
.theme-card-copy strong { color:#372549; font-size:.78rem; }
.theme-card-copy small { color:#776f7c; font-size:.6rem; line-height:1.4; }
.theme-switch { display:grid; width:54px; height:44px; place-items:center; padding:0; border:0; border-radius:14px; background:transparent; cursor:pointer; }
.theme-switch-track { position:relative; display:block; width:46px; height:26px; border:1px solid #c9c1ce; border-radius:999px; background:#e6e1e9; transition:background-color .18s ease,border-color .18s ease; }
.theme-switch-thumb { position:absolute; top:3px; left:3px; width:18px; height:18px; border-radius:50%; background:#fff; box-shadow:0 2px 6px rgba(55,37,73,.25); transition:transform .18s ease; }
.theme-switch[aria-checked="true"] .theme-switch-track { border-color:#b9ba6c; background:#b9ba6c; }
.theme-switch[aria-checked="true"] .theme-switch-thumb { transform:translateX(20px); background:#372549; }
.theme-switch:focus-visible { outline:3px solid rgba(185,186,108,.72); outline-offset:2px; }

html[data-theme="dark"] body { color:var(--theme-text); background:var(--theme-page); }
html[data-theme="dark"] .app-shell,
html[data-theme="dark"] .maintenance-entry-shell,
html[data-theme="dark"] .maintenance-entry-shell .app-content { color:var(--theme-text); background:var(--theme-shell); box-shadow:none; }
html[data-theme="dark"] .brand-hero,
html[data-theme="dark"] .maintenance-entry-toolbar { background:#4a3658; }
html[data-theme="dark"] .maintenance-entry-header { background:#39323f; box-shadow:0 2px 7px rgba(0,0,0,.24); }
html[data-theme="dark"] .maintenance-technician,
html[data-theme="dark"] .maintenance-entry-title { color:#17131b; background:var(--theme-accent); }

html[data-theme="dark"] :where(
    .auth-card,.identity-card,.maintenance-filters,.maintenance-card-item,.detail-panel,
    .runtime-card,.sync-card,.theme-card,.empty-state,.action-zone,.media-picker,
    .maintenance-equipment-card,.media-section,.signature-section,.operation-choice,
    .supervision-technician-card,.supervision-breakdown-list>li
) { color:var(--theme-text); border-color:var(--theme-border); background:var(--theme-surface); box-shadow:0 9px 28px rgba(0,0,0,.2); }

html[data-theme="dark"] :where(
    .auth-heading h2,.form-field label,.identity-card strong,.breakdown-heading h2,
    .section-heading h2,.detail-heading h2,.maintenance-copy strong,.detail-panel h3,
    .form-section-heading h3,.media-heading h4,.runtime-heading strong,
    .settings-page-heading h2,.theme-card-copy strong,.supervision-overview-heading h2,
    .supervision-detail-heading h2,.supervision-technician-heading strong,
    .supervision-breakdown-list>li>strong,.maintenance-equipment-card,
    .maintenance-equipment-data strong,.runtime-grid strong,.sync-main strong
) { color:var(--theme-heading); }

html[data-theme="dark"] :where(
    .auth-heading p,.form-field small,.identity-card small,.card-label,.maintenance-card-data,
    .maintenance-card-checks,.maintenance-copy>span:nth-child(2),.maintenance-copy small,
    .settings-page-heading p,.theme-card-copy small,.runtime-grid small,.runtime-message,
    .supervision-overview-heading p,.supervision-technician-heading small,
    .supervision-breakdown-list>li>span,.supervision-breakdown-list>li>small,
    .supervision-detail-heading small,.maintenance-equipment-card small,.sync-main small,
    .automatic-sync-note
) { color:var(--theme-muted); }

html[data-theme="dark"] :where(input,textarea,select) { color:var(--theme-text); border-color:var(--theme-border); background:var(--theme-surface-soft); }
html[data-theme="dark"] :where(input,textarea)::placeholder { color:#8e8493; }
html[data-theme="dark"] :where(input,textarea,select):focus { border-color:var(--theme-accent); box-shadow:0 0 0 3px rgba(198,200,121,.2); }
html[data-theme="dark"] .maintenance-entry-fields input:disabled { color:var(--theme-text); background:var(--theme-surface-soft); }

html[data-theme="dark"] :where(
    .maintenance-card,.breakdown-button,.small-icon-button,.maintenance-card-menu button,
    .secondary-button,.settings-logout,.supervision-filters button
) { color:var(--theme-text); border-color:var(--theme-border); background:var(--theme-surface); }
html[data-theme="dark"] :where(.maintenance-card,.breakdown-button):hover { border-color:#62576b; }
html[data-theme="dark"] .maintenance-card-item .maintenance-card { background:transparent; box-shadow:none; }
html[data-theme="dark"] .breakdown-button.has-items.tone-violet,
html[data-theme="dark"] .breakdown-button.has-items.tone-green { color:var(--theme-text)!important; border-color:var(--theme-border)!important; background:var(--theme-surface)!important; box-shadow:0 7px 22px rgba(0,0,0,.2)!important; }
html[data-theme="dark"] .breakdown-button.has-items .breakdown-count.is-positive { color:#211a27!important; border-color:var(--theme-accent)!important; background:var(--theme-accent)!important; }
html[data-theme="dark"] .breakdown-button .breakdown-count.is-zero { color:var(--theme-muted)!important; background:var(--theme-surface-soft)!important; }

html[data-theme="dark"] :where(
    .pilot-hint,.queued-note,.draft-policy,.runtime-grid span,.media-list li,
    .supervision-count-grid button,.supervision-breakdown-list p,.supervision-timeline div
) { color:var(--theme-text); background:var(--theme-surface-soft); }
html[data-theme="dark"] .success-hint,
html[data-theme="dark"] :where(.snapshot-pill,.filter-loading,.completion-policy,.supervision-classification span) { color:#e9edb1; background:#303321; }
html[data-theme="dark"] .date-tile { color:#f0ebf3; background:#342e3b; }
html[data-theme="dark"] .state-badge { color:#e9edb1; background:#303321; }
html[data-theme="dark"] .state-badge.in-progress { color:#ffd493; background:#4a3217; }
html[data-theme="dark"] :where(.state-badge.stopped,.state-badge.equipment-stopped) { color:#ffb7c2; background:#49232b; }
html[data-theme="dark"] .state-badge.claimed,
html[data-theme="dark"] .state-badge.reported,
html[data-theme="dark"] .state-badge.waiting { color:#d9c8e3; background:#382c40; }

html[data-theme="dark"] .theme-card-icon { color:#f0e99b; background:#504a35; }
html[data-theme="dark"] .theme-switch-track { border-color:#766a7f; background:#5a5063; }
html[data-theme="dark"] .theme-switch[aria-checked="true"] .theme-switch-track { border-color:var(--theme-accent); background:var(--theme-accent); }
html[data-theme="dark"] .theme-switch[aria-checked="true"] .theme-switch-thumb { background:#4a3658; }
html[data-theme="dark"] .supervision-entry-card { color:var(--theme-text); border-color:var(--theme-border); background:linear-gradient(135deg,#39323f 0%,#424332 100%); box-shadow:0 9px 26px rgba(0,0,0,.14); }
html[data-theme="dark"] .supervision-entry-card small,
html[data-theme="dark"] .supervision-entry-arrow { color:var(--theme-muted); }
html[data-theme="dark"] .supervision-inline-back { color:#ded5e4; background:#342d3a; }
html[data-theme="dark"] .supervision-active-total { color:var(--theme-heading); }
html[data-theme="dark"] .supervision-active-total small { color:var(--theme-muted); }
html[data-theme="dark"] .supervision-count-grid .status-stopped { color:#ffb7c2; background:#49232b; }
html[data-theme="dark"] .supervision-count-grid .status-in-progress { color:#c9e0b6; background:#283524; }
html[data-theme="dark"] .supervision-count-grid .status-completed { color:#cad1d1; background:#303638; }
html[data-theme="dark"] .supervision-filters button.active { color:#fff; border-color:#8e759f; background:#604b6e; }

html[data-theme="dark"] .maintenance-context-modal { color:var(--theme-text)!important; border-color:var(--theme-border)!important; background:var(--theme-surface)!important; }
html[data-theme="dark"] .detail-tool-panel,
html[data-theme="dark"] .maintenance-bottom-bar { color:var(--theme-text); border-color:var(--theme-border); background:var(--theme-surface); }
html[data-theme="dark"] .detail-tool-panel textarea,
html[data-theme="dark"] .signature-canvas { color:var(--theme-text); border-color:var(--theme-border); background:var(--theme-surface-soft); }
html[data-theme="dark"] .maintenance-bottom-bar { box-shadow:0 -8px 24px rgba(0,0,0,.28); }
html[data-theme="dark"] .maintenance-bottom-bar button { color:var(--theme-muted); }
html[data-theme="dark"] .maintenance-bottom-bar button.active { color:var(--theme-accent); }
html[data-theme="dark"] #blazor-error-ui { color:#ffc3c9; background:#3c2025; }

@media (prefers-reduced-motion:reduce) {
    .theme-switch-track,.theme-switch-thumb { transition:none; }
}
