/* 72_01: opt-in esclusivo data-bs-theme=dark. Nessuna regola light alterata.
   Applica al layout condiviso e componenti comuni; pagine CSS specialistiche
   (editor, FullCalendar, grafici, stampe/PDF) richiedono validazione dedicata. */
html[data-bs-theme="dark"] {
    color-scheme: dark;
    --cpm-primary: #8fb7ff;
    --cpm-primary-rgb: 143,183,255;
    --cpm-primary-hover: #b1ceff;
    --cpm-primary-dark: #b1ceff;
    --cpm-primary-soft: #192e4a;
    --cpm-primary-border: #345175;
    --cpm-success: #61d6a0;
    --cpm-success-rgb: 97,214,160;
    --cpm-success-hover: #8deac1;
    --cpm-success-soft: #163b31;
    --cpm-success-border: #2d6855;
    --cpm-warning: #ffd074;
    --cpm-warning-rgb: 255,208,116;
    --cpm-warning-hover: #ffe4a9;
    --cpm-warning-soft: #463718;
    --cpm-warning-border: #73592e;
    --cpm-danger: #ff929d;
    --cpm-danger-rgb: 255,146,157;
    --cpm-danger-hover: #ffb2ba;
    --cpm-danger-soft: #461e28;
    --cpm-danger-border: #75414b;
    --cpm-info: #77dcef;
    --cpm-info-rgb: 119,220,239;
    --cpm-info-hover: #a6edfa;
    --cpm-info-soft: #153943;
    --cpm-info-border: #31616c;
    --cpm-background: #101820;
    --cpm-surface: #1b2935;
    --cpm-surface-soft: #233443;
    --cpm-text: #eff4fa;
    --cpm-text-secondary: #c5d1dd;
    --cpm-muted: #a4b6c7;
    --cpm-border: #3c5062;
    --cpm-border-strong: #597085;
    --cpm-shadow-sm: 0 4px 14px rgba(0,0,0,.24);
    --cpm-shadow-md: 0 10px 28px rgba(0,0,0,.32);
    --cpm-shadow-lg: 0 18px 45px rgba(0,0,0,.40);
    --bs-body-color: var(--cpm-text);
    --bs-body-bg: var(--cpm-background);
    --bs-border-color: var(--cpm-border);
    --bs-link-color: var(--cpm-primary);
    --bs-link-hover-color: var(--cpm-primary-hover);
    --bs-primary: var(--cpm-primary);
    --bs-primary-rgb: var(--cpm-primary-rgb);
}
html[data-bs-theme="dark"] body {
    color: var(--cpm-text);
    background: var(--cpm-background);
}
/* Fascia logo condivisa: il template usa bg-white fuori da app-layout-content. */
html[data-bs-theme="dark"] .brand-banner {
    background-color: var(--cpm-surface) !important;
    border-bottom-color: var(--cpm-border) !important;
}
/* Il layout condiviso usa classi bg-light/bg-white anche come superfici. */
html[data-bs-theme="dark"] body.bg-light,
html[data-bs-theme="dark"] .app-layout-content .bg-light,
html[data-bs-theme="dark"] .app-layout-content .bg-white {
    background-color: var(--cpm-surface) !important;
}
html[data-bs-theme="dark"] .app-layout-content .text-dark:not(.btn):not(.badge):not(.alert) {
    color: var(--cpm-text) !important;
}
html[data-bs-theme="dark"] .app-layout-content .text-muted {
    color: var(--cpm-muted) !important;
}
html[data-bs-theme="dark"] .app-sidebar-topbar {
    background: var(--cpm-surface);
    color: var(--cpm-text);
    border-bottom-color: var(--cpm-border);
}
html[data-bs-theme="dark"] .app-sidebar-brand,
html[data-bs-theme="dark"] .app-sidebar-brand:hover { color: var(--cpm-primary); }
html[data-bs-theme="dark"] .app-sidebar-toggle { border-color: var(--cpm-border); }
html[data-bs-theme="dark"] .app-sidebar-toggle:hover,
html[data-bs-theme="dark"] .app-sidebar-notif-btn,
html[data-bs-theme="dark"] .app-sidebar-notif-btn:hover {
    background: var(--cpm-surface-soft);
    color: var(--cpm-text);
}
html[data-bs-theme="dark"] .app-sidebar-toggler-line { background: var(--cpm-text); }
/* Preservare volutamente i gradienti professionista/famiglia della sidebar. */
html[data-bs-theme="dark"] .app-sidebar:not(.app-sidebar--professional):not(.app-sidebar--family),
html[data-bs-theme="dark"] .app-sidebar:not(.app-sidebar--professional):not(.app-sidebar--family) .app-sidebar-header {
    background: var(--cpm-surface);
    color: var(--cpm-text);
    border-color: var(--cpm-border);
}
html[data-bs-theme="dark"] .app-sidebar:not(.app-sidebar--professional):not(.app-sidebar--family) .app-sidebar-close {
    background: var(--cpm-surface-soft);
    color: var(--cpm-text);
    border-color: var(--cpm-border);
}
html[data-bs-theme="dark"] .card,
html[data-bs-theme="dark"] .cpm-card,
html[data-bs-theme="dark"] .dropdown-menu,
html[data-bs-theme="dark"] .modal-content,
html[data-bs-theme="dark"] .offcanvas,
html[data-bs-theme="dark"] .list-group-item {
    color: var(--cpm-text);
    background-color: var(--cpm-surface);
    border-color: var(--cpm-border);
}
/* Primary/success/danger buttons remain high-contrast (text and surface are separate tokens). */
html[data-bs-theme="dark"] .btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: #265fba;
    --bs-btn-border-color: #265fba;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #3273d0;
    --bs-btn-hover-border-color: #3273d0;
}
html[data-bs-theme="dark"] .btn-outline-primary {
    --bs-btn-color: var(--cpm-primary);
    --bs-btn-border-color: var(--cpm-primary);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #265fba;
    --bs-btn-hover-border-color: #265fba;
}
html[data-bs-theme="dark"] .btn-success {
    --bs-btn-color: #fff;
    --bs-btn-bg: #116b4d;
    --bs-btn-border-color: #116b4d;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #16835e;
    --bs-btn-hover-border-color: #16835e;
}
html[data-bs-theme="dark"] .btn-danger {
    --bs-btn-color: #fff;
    --bs-btn-bg: #a93246;
    --bs-btn-border-color: #a93246;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #c33c53;
    --bs-btn-hover-border-color: #c33c53;
}
html[data-bs-theme="dark"] .bg-primary:not(.alert) {
    background-color: #265fba !important;
}
html[data-bs-theme="dark"] .page-help-card {
    background: linear-gradient(135deg, rgba(143,183,255,.07), transparent 55%), var(--cpm-surface);
    border-color: var(--cpm-border) !important;
}
html[data-bs-theme="dark"] .page-help-list li,
html[data-bs-theme="dark"] .page-help-note { color: var(--cpm-text-secondary); }
html[data-bs-theme="dark"] .page-help-note {
    background: var(--cpm-surface-soft);
    border-color: var(--cpm-border);
}
html[data-bs-theme="dark"] .page-help-icon {
    background: var(--cpm-surface-soft);
    color: var(--cpm-primary);
}
html[data-bs-theme="dark"] .form-control,
html[data-bs-theme="dark"] .form-select,
html[data-bs-theme="dark"] .input-group-text {
    color: var(--cpm-text);
    background-color: var(--cpm-surface-soft);
    border-color: var(--cpm-border-strong);
}
html[data-bs-theme="dark"] .form-control::placeholder { color: var(--cpm-muted); }
html[data-bs-theme="dark"] .table { --bs-table-bg: var(--cpm-surface); --bs-table-color: var(--cpm-text); --bs-table-border-color: var(--cpm-border); }
/* Never globally recolor alerts, badges, charts, external embeds, signed PDF or printing. */
/* 72_01_03: allineare il banner al centro della zona contenuti con sidebar desktop.
   Il mobile/PWA e il tema chiaro mantengono i rispettivi colori e dimensioni. */
@media (min-width: 992px) {
    body.app-sidebar-desktop .brand-banner {
        margin-left: var(--cpm-sidebar-width);
        width: calc(100% - var(--cpm-sidebar-width));
    }
}

/* 72_01_03: soltanto Admin Dashboard; nessun cambiamento di classi Bootstrap o markup funzionale. */
html[data-bs-theme="dark"] .cpm-admin-dashboard .table > thead.table-light {
    --bs-table-bg: var(--cpm-surface-soft);
    --bs-table-color: var(--cpm-text);
    --bs-table-border-color: var(--cpm-border);
}
html[data-bs-theme="dark"] .cpm-admin-dashboard .btn-outline-dark {
    --bs-btn-color: var(--cpm-text);
    --bs-btn-border-color: var(--cpm-border-strong);
    --bs-btn-hover-color: var(--cpm-background);
    --bs-btn-hover-bg: var(--cpm-text);
    --bs-btn-hover-border-color: var(--cpm-text);
    --bs-btn-active-color: var(--cpm-background);
    --bs-btn-active-bg: var(--cpm-text);
    --bs-btn-active-border-color: var(--cpm-text);
}

/* 72_01_04: solo workspace Studio in Dark Mode.
   Gli sfondi pastello chiari definiti dal design system e dal template
   rendevano il testo del tema scuro poco leggibile. */
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-studio-section--blue-deep {
    --cpm-studio-section-soft: #1b3350;
}
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-studio-section--green-deep {
    --cpm-studio-section-soft: #193b30;
}
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-studio-section--orange-deep {
    --cpm-studio-section-soft: #40331d;
}
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-studio-section > .card-header {
    color: var(--cpm-text);
    background: linear-gradient(90deg, var(--cpm-studio-section-soft), var(--cpm-surface) 78%) !important;
}
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-studio-section > .card-header h1,
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-studio-section > .card-header h2,
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-studio-section > .card-header h3 {
    color: var(--cpm-text);
}
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-studio-section > .card-header .text-muted,
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-studio-section > .card-header p {
    color: var(--cpm-text-secondary) !important;
}
/* Dashboard Studio: il template imposta quattro sfondi chiari con !important. */
html[data-bs-theme="dark"] .cpm-studio-workspace > .row.g-3.mb-4 .cpm-professional-stat {
    color: var(--cpm-text) !important;
    border-color: var(--cpm-border) !important;
}
html[data-bs-theme="dark"] .cpm-studio-workspace > .row.g-3.mb-4 > :nth-child(1) .cpm-professional-stat {
    background: var(--cpm-primary-soft) !important;
}
html[data-bs-theme="dark"] .cpm-studio-workspace > .row.g-3.mb-4 > :nth-child(2) .cpm-professional-stat {
    background: var(--cpm-success-soft) !important;
}
html[data-bs-theme="dark"] .cpm-studio-workspace > .row.g-3.mb-4 > :nth-child(3) .cpm-professional-stat {
    background: var(--cpm-info-soft) !important;
}
html[data-bs-theme="dark"] .cpm-studio-workspace > .row.g-3.mb-4 > :nth-child(4) .cpm-professional-stat {
    background: var(--cpm-warning-soft) !important;
}
/* Elenco pratiche / importazioni: intestazioni e badge leggibili. */
html[data-bs-theme="dark"] .cpm-studio-workspace .table > thead.table-light {
    --bs-table-bg: var(--cpm-surface-soft);
    --bs-table-color: var(--cpm-text);
    --bs-table-border-color: var(--cpm-border);
}
html[data-bs-theme="dark"] .cpm-studio-workspace .badge.bg-light.text-dark {
    background-color: var(--cpm-surface-soft) !important;
    color: var(--cpm-text) !important;
    border-color: var(--cpm-border-strong) !important;
}
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-studio-section > .card-header .badge {
    background-color: var(--cpm-surface-soft) !important;
    color: var(--cpm-text) !important;
}
/* Moduli Crea pratica / Importa: no superfici grigio-chiare sul tema scuro. */
html[data-bs-theme="dark"] .cpm-studio-workspace .bg-light-subtle {
    background-color: var(--cpm-surface-soft) !important;
    color: var(--cpm-text);
    border-color: var(--cpm-border) !important;
}
html[data-bs-theme="dark"] .cpm-studio-workspace .alert-light {
    color: var(--cpm-text);
    background-color: var(--cpm-primary-soft);
}
/* Header: il design-system forza pulsanti bianchi con testo troppo chiaro. */
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-professional-hero .btn-outline-primary,
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-professional-hero .btn-outline-dark,
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-professional-hero .btn-outline-secondary {
    color: var(--cpm-text) !important;
    background: var(--cpm-surface-soft) !important;
    border-color: var(--cpm-border-strong) !important;
}
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-professional-hero .btn-outline-primary:hover,
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-professional-hero .btn-outline-primary:focus,
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-professional-hero .btn-outline-dark:hover,
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-professional-hero .btn-outline-secondary:hover {
    color: #fff !important;
    background: #265fba !important;
    border-color: #3273d0 !important;
}
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-professional-hero .btn-primary {
    color: #fff !important;
    background: #265fba !important;
    border-color: #265fba !important;
}


/* 72_01_05: Dashboard Avvocato, soltanto tema scuro. Le varianti pastello
   e l'Autopilot usano colori chiari inline nel template originario. */
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-professional-hero {
    color: var(--cpm-text);
    background: linear-gradient(135deg, #193452 0%, #243d61 100%);
    border-color: var(--cpm-border);
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-professional-hero h1 {
    color: var(--cpm-text) !important;
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-professional-hero .text-muted {
    color: var(--cpm-text-secondary) !important;
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-professional-hero .btn-outline-primary {
    color: #184d93 !important;
    background: #f2f6fc !important;
    border-color: #b7cbea !important;
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-professional-hero .btn-outline-danger {
    color: #8f263a !important;
    background: #fff6f7 !important;
    border-color: #e7aab5 !important;
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-professional-hero .btn-outline-primary:hover,
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-professional-hero .btn-outline-primary:focus-visible,
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-professional-hero .btn-outline-danger:hover,
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-professional-hero .btn-outline-danger:focus-visible {
    color: #172b42 !important;
    background: #ffffff !important;
}
/* Il partial Autopilot contiene uno style proprio: usare il namespace dashboard. */
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-autopilot-card,
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-family-snapshot,
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-family-child-row,
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-planning-wrap {
    color: var(--cpm-text);
    background: var(--cpm-surface);
    border-color: var(--cpm-border);
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-family-data-chip {
    color: var(--cpm-text-secondary);
    background: var(--cpm-surface-soft);
    border-color: var(--cpm-border);
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-family-note {
    color: var(--cpm-text);
    background: #322b23;
    border-color: #705639;
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-action-count,
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-autopilot-section {
    color: var(--cpm-text);
    background: var(--cpm-surface-soft);
    border-color: var(--cpm-border);
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-action-count.is-overdue,
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-autopilot-section.is-overdue {
    background: #38232b;
    border-color: #87515a;
    border-left-color: #ff929d;
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-action-count.is-today,
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-autopilot-section.is-today {
    background: #40331d;
    border-color: #80653a;
    border-left-color: #ffd074;
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-action-count.is-week,
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-autopilot-section.is-week {
    background: #1b3350;
    border-color: #49668d;
    border-left-color: #8fb7ff;
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-autopilot-item {
    border-top-color: var(--cpm-border);
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-autopilot-item.is-reminder-due {
    color: var(--cpm-text);
    background: #40331d;
    border-color: #967241;
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-autopilot-reminder-label,
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-autopilot-reminder-status {
    color: #ffe0a0;
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-autopilot-reminder-status.is-valid {
    color: #8deac1;
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-planning-status {
    color: var(--cpm-text-secondary);
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-planning-row {
    border-top-color: var(--cpm-border);
}
html[data-bs-theme="dark"] .cpm-professional-dashboard .cpm-autopilot-card .badge.bg-light.text-dark {
    color: var(--cpm-text) !important;
    background: var(--cpm-surface-soft) !important;
    border-color: var(--cpm-border-strong) !important;
}

/* 72_01_07: Contrasto semantico delle superfici colorate (solo tema scuro).
   Colori chiari/pastello -> inchiostro scuro; superfici intense -> testo chiaro.
   Non modificare badge, alert, pulsanti, stampe, e anteprime documentali. */
html[data-bs-theme="dark"] {
    --cpm-ink-on-light: #172638;
    --cpm-ink-muted-on-light: #40546a;
}
/* Classi Bootstrap con sfondo SOLIDO, non versioni trasparenti. */
html[data-bs-theme="dark"] .app-layout-content :is(.bg-warning, .bg-info):not(.badge):not(.btn):not(.alert):not([class*="bg-opacity-"]) {
    color: var(--cpm-ink-on-light) !important;
}
html[data-bs-theme="dark"] .app-layout-content :is(.bg-warning, .bg-info):not(.badge):not(.btn):not(.alert):not([class*="bg-opacity-"]) :is(.text-white, .text-light, .text-muted) {
    color: var(--cpm-ink-on-light) !important;
}
/* Verde/rosso saturi abbastanza profondi per mantenere il testo bianco. */
html[data-bs-theme="dark"] .app-layout-content :is(.bg-success, .bg-danger):not(.badge):not(.btn):not(.alert):not([class*="bg-opacity-"]) {
    color: #fff !important;
}
html[data-bs-theme="dark"] .app-layout-content .bg-success:not(.badge):not(.btn):not(.alert):not([class*="bg-opacity-"]) {
    background-color: #116b4d !important;
}
html[data-bs-theme="dark"] .app-layout-content .bg-danger:not(.badge):not(.btn):not(.alert):not([class*="bg-opacity-"]) {
    background-color: #a93246 !important;
}
/* Etichette numeriche Lettere: nessuna trasparenza sui caratteri piccoli. */
html[data-bs-theme="dark"] .app-layout-content .stat-card :is(.small, .h2) {
    opacity: 1 !important;
}
/* La fascia chiara della pagina Lettere deve usare SEMPRE testo scuro. */
html[data-bs-theme="dark"] .app-layout-content .letter-page-hero {
    background: linear-gradient(135deg, #ffffff, #f5f9ff) !important;
    color: var(--cpm-ink-on-light) !important;
}
html[data-bs-theme="dark"] .app-layout-content .letter-page-hero h1 {
    color: var(--cpm-ink-on-light) !important;
}
html[data-bs-theme="dark"] .app-layout-content .letter-page-hero .text-muted {
    color: var(--cpm-ink-muted-on-light) !important;
}
/* Selettore modello: superficie scura, titoli e descrizioni chiari. */
html[data-bs-theme="dark"] .app-layout-content .letter-type-card {
    background: var(--cpm-surface-soft) !important;
    color: var(--cpm-text) !important;
    border-color: var(--cpm-border-strong) !important;
}
html[data-bs-theme="dark"] .app-layout-content .letter-type-card.selected {
    background: var(--cpm-primary-soft) !important;
}
html[data-bs-theme="dark"] .app-layout-content .letter-type-card h6 {
    color: var(--cpm-text) !important;
}
html[data-bs-theme="dark"] .app-layout-content .letter-type-card .text-muted {
    color: var(--cpm-text-secondary) !important;
}
html[data-bs-theme="dark"] .app-layout-content .letter-category-bar {
    background: var(--cpm-surface-soft) !important;
    border-color: var(--cpm-border) !important;
}
html[data-bs-theme="dark"] .app-layout-content .letter-category-btn:not(.active) {
    color: var(--cpm-text) !important;
    background: var(--cpm-surface) !important;
    border-color: var(--cpm-border) !important;
}
html[data-bs-theme="dark"] .app-layout-content .letter-category-btn.active {
    color: #fff !important;
    background: linear-gradient(135deg, #265fba, #184c98) !important;
}
html[data-bs-theme="dark"] .app-layout-content .letter-attachments-panel,
html[data-bs-theme="dark"] .app-layout-content .letter-attachment-item {
    background: var(--cpm-surface-soft) !important;
    color: var(--cpm-text) !important;
    border-color: var(--cpm-border) !important;
}
html[data-bs-theme="dark"] .app-layout-content .letter-attachment-item.is-processing {
    background: var(--cpm-warning-soft) !important;
    border-color: var(--cpm-warning-border) !important;
}
html[data-bs-theme="dark"] .app-layout-content .letter-attachment-item.is-ready {
    background: var(--cpm-success-soft) !important;
    border-color: var(--cpm-success-border) !important;
}
html[data-bs-theme="dark"] .app-layout-content .letter-attachment-meta {
    color: var(--cpm-text-secondary) !important;
}
html[data-bs-theme="dark"] .app-layout-content .letter-attachment-item.is-processing .letter-attachment-status {
    color: var(--cpm-warning) !important;
}
html[data-bs-theme="dark"] .app-layout-content .letter-attachment-item.is-ready .letter-attachment-status {
    color: var(--cpm-success) !important;
}
/* La pagina cartacea e il suo contenuto rimangono chiari e indipendenti dalla UI. */
html[data-bs-theme="dark"] .app-layout-content .preview-box {
    background: #fff !important;
    color: var(--cpm-ink-on-light) !important;
}
html[data-bs-theme="dark"] .app-layout-content .preview-box .text-muted {
    color: var(--cpm-ink-muted-on-light) !important;
}
/* Archivio documentale: le card chiare mantengono il design, ma non testo bianco. */
html[data-bs-theme="dark"] .app-layout-content .studio-archive-shell :is(.archive-card, .archive-search, .archive-stat, .archive-result, .archive-result-selected, .archive-lock) {
    color: var(--cpm-ink-on-light) !important;
}
html[data-bs-theme="dark"] .app-layout-content .studio-archive-shell :is(.archive-card, .archive-search, .archive-stat, .archive-result, .archive-result-selected, .archive-lock) :is(.text-dark, .text-muted, .text-white) {
    color: var(--cpm-ink-muted-on-light) !important;
}
html[data-bs-theme="dark"] .app-layout-content .studio-archive-shell .archive-stat-blue { color: #174c8b !important; }
html[data-bs-theme="dark"] .app-layout-content .studio-archive-shell .archive-stat-green { color: #116335 !important; }
html[data-bs-theme="dark"] .app-layout-content .studio-archive-shell .archive-stat-cyan { color: #0b6178 !important; }
html[data-bs-theme="dark"] .app-layout-content .studio-archive-shell .archive-stat-orange { color: #87520b !important; }
/* L'estremità celeste del gradiente era troppo luminosa per il testo bianco. */
html[data-bs-theme="dark"] .app-layout-content .studio-archive-shell .studio-archive-hero {
    background: linear-gradient(125deg, #08366c 0%, #1252a0 58%, #075667 100%) !important;
    color: #fff !important;
}

/* 72_01_08_03 — Gestisci pratiche Family: selezione del titolare in Dark Mode.
   Il design-system usa #eef2ff per --cpm-group-soft del gruppo owner: sul tema
   scuro il nome/titolo e i controlli risultano poco leggibili. Solo visuale;
   valori checked/disabled, assegnazioni, autosave e logica JS invariati. */
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-professional-selector .cpm-professional-group--owner {
    --cpm-group-soft: #263e57;
}
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-professional-selector .cpm-professional-group--owner
.cpm-professional-option:has(.js-assigned-member-checkbox:checked) {
    background: var(--cpm-group-soft) !important;
    border-color: #7393b0 !important;
    color: #eff4fa !important;
}
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-professional-selector .cpm-professional-group--owner
.cpm-professional-option:has(.js-assigned-member-checkbox:checked) .form-check-label {
    color: #eff4fa !important;
}
html[data-bs-theme="dark"] .cpm-studio-workspace .cpm-professional-selector .cpm-professional-group--owner
.cpm-professional-option:has(.js-assigned-member-checkbox:checked) .form-check-input:disabled ~ .form-check-label {
    color: #c5d1dd !important;
    opacity: .85;
}

/* 74_01_01 — Leggibilita' Dark Mode dell'esperienza Famiglia.
   Il body riceve cpm-family-ui soltanto per la navigazione famiglia (non
   professionisti/clienti); nessuna regola per il tema light, PDF o stampa.
   Corregge i pannelli a fondo chiaro che ereditavano il testo del tema dark. */
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content {
    --cpm-family-panel: #1b2935;
    --cpm-family-panel-raised: #233443;
    --cpm-family-panel-border: #486074;
}
/* Riepilogo famiglia e Autopilot (il precedente fix riguardava solo Pro). */
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content :is(
    .cpm-autopilot-card, .cpm-family-snapshot, .cpm-family-child-row,
    .cpm-action-count, .cpm-autopilot-section, .cpm-planning-wrap
) {
    background: var(--cpm-family-panel) !important;
    color: var(--cpm-text) !important;
    border-color: var(--cpm-family-panel-border) !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content :is(
    .cpm-family-child-row, .cpm-action-count, .cpm-autopilot-section, .cpm-planning-wrap
) {
    background: var(--cpm-family-panel-raised) !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .cpm-family-data-chip {
    background: #30465b !important;
    color: #e8f2fb !important;
    border-color: #597085 !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .cpm-family-data-chip :is(strong, small) {
    color: inherit !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .cpm-family-note {
    background: #40331f !important;
    color: #fff1d6 !important;
    border-color: #886641 !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .cpm-family-note .text-muted {
    color: #f2dcb7 !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content :is(.cpm-action-count, .cpm-autopilot-section).is-overdue {
    background: #38232b !important;
    border-left-color: #ff929d !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content :is(.cpm-action-count, .cpm-autopilot-section).is-today {
    background: #40331f !important;
    border-left-color: #ffd074 !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content :is(.cpm-action-count, .cpm-autopilot-section).is-week {
    background: #1b3350 !important;
    border-left-color: #8fb7ff !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .cpm-autopilot-item.is-reminder-due {
    color: #fff1d6 !important;
    background: #40331f !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content :is(.cpm-autopilot-reminder-label, .cpm-autopilot-reminder-status) {
    color: #ffe0a0 !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .cpm-autopilot-reminder-status.is-valid {
    color: #8deac1 !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .cpm-autopilot-card .badge.bg-light.text-dark {
    background: var(--cpm-family-panel-raised) !important;
    color: var(--cpm-text) !important;
    border-color: var(--cpm-border) !important;
}
/* Dashboard Spese: evitare contatori bianchi con testo pastello. */
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .custom-card {
    background: var(--cpm-family-panel) !important;
    color: var(--cpm-text) !important;
    border-color: var(--cpm-family-panel-border) !important;
}
/* Archivio Documenti: titolo, categoria e stato distinguibili anche nei badge piccoli. */
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content :is(.document-desktop-item, .document-mobile-card, .document-mobile-heading, .document-mobile-field) {
    background: var(--cpm-family-panel) !important;
    color: var(--cpm-text) !important;
    border-color: var(--cpm-family-panel-border) !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content :is(.document-archive-list, .document-mobile-actions) {
    background: #172430 !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content :is(.document-mobile-title, .document-mobile-value, .document-desktop-item h6) {
    color: var(--cpm-text) !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .document-mobile-label {
    color: var(--cpm-text-secondary) !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content :is(.document-desktop-item, .document-mobile-card) .badge.bg-light.text-dark {
    background: #30465b !important;
    color: #f0f5fb !important;
    border-color: #597085 !important;
    opacity: 1 !important;
}
/* Calendario: gli eventi e il box collaborativo devono rimanere scuri. */
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .calendar-event-list {
    background: #172430 !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .calendar-event-card {
    background: var(--cpm-family-panel) !important;
    color: var(--cpm-text) !important;
    border-color: var(--cpm-family-panel-border) !important;
    border-left-color: var(--event-accent, #8fb7ff) !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content :is(.calendar-event-card__title, .calendar-event-card__description) {
    color: var(--cpm-text) !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .calendar-event-card__actions {
    border-top-color: var(--cpm-family-panel-border) !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content :is(.event-participants-card, .event-participants-card .participant-option) {
    color: var(--cpm-text) !important;
    background: var(--cpm-family-panel-raised) !important;
    border-color: var(--cpm-family-panel-border) !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .event-participants-card .participant-option {
    background: var(--cpm-family-panel) !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .event-participants-card :is(.text-muted, .form-text) {
    color: var(--cpm-text-secondary) !important;
}
/* Fascicolo: riepiloghi e importi erano pastello con testo quasi bianco. */
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content :is(.dossier-header, .dossier-kpi, .dossier-mini-box, .dossier-view-nav) {
    color: var(--cpm-text) !important;
    background: var(--cpm-family-panel) !important;
    border-color: var(--cpm-family-panel-border) !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .dossier-header .text-muted,
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content :is(.dossier-kpi, .dossier-mini-box) .text-muted {
    color: var(--cpm-text-secondary) !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .dossier-kpi-purple .value {
    color: #c4b5fd !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .dossier-mini-box strong {
    color: var(--cpm-text) !important;
}
/* Profilo: intestazioni con sfondo pastello creato da setup.css !important. */
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .setup-page .setup-card > .card-header {
    background: linear-gradient(135deg, #263e57, #1b2935) !important;
    color: var(--cpm-text) !important;
    border-bottom-color: var(--cpm-family-panel-border) !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .setup-page :is(.form-control:disabled, .form-control[readonly]) {
    opacity: 1 !important;
    color: var(--cpm-text) !important;
    background: #30465b !important;
    border-color: #597085 !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .setup-page .profile-complete {
    color: var(--cpm-text) !important;
    background: #193b30 !important;
    border-color: #368267 !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .setup-page .cf-calculation-card {
    background: #40331f !important;
    color: #fff1d6 !important;
}
/* Spazio Archiviazione: quattro contatori con superficie e testo coordinati. */
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .storage-stat-box {
    color: var(--cpm-text) !important;
    background: var(--cpm-family-panel-raised) !important;
    border-color: var(--cpm-family-panel-border) !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .storage-stat-label {
    color: var(--cpm-text-secondary) !important;
}
/* Articoli: il titolo e i sommari non devono essere scuri su card scure. */
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .articles-page {
    color: var(--cpm-text) !important;
    background: var(--cpm-background) !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .articles-page :is(.articles-search-card, .article-card) {
    color: var(--cpm-text) !important;
    background: var(--cpm-family-panel) !important;
}
html[data-bs-theme="dark"] body.cpm-family-ui .app-layout-content .articles-page .article-summary {
    color: var(--cpm-text-secondary) !important;
}
/* Superfici editoriali e cartacee intenzionalmente chiare NON sono qui incluse. */

@media print {
    html[data-bs-theme="dark"] { color-scheme: light; }
    html[data-bs-theme="dark"] body { background: #fff !important; color: #000 !important; }
}


/* 76_01_04 – Pratica Family consultata da professionista: contrasto e accenti.
   Si attiva solo se il context processor ha validato la pratica Studio corrente.
   Nessun intervento sull'area Legal generica, sul tema light o sui documenti stampati. */
@media screen {
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content {
        --cpm-family-case-panel: #1b2935;
        --cpm-family-case-raised: #233443;
        --cpm-family-case-border: #486074;
    }
    /* Riepilogo operativo: il partial Autopilot definisce sfondi chiari propri. */
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content :is(
        .cpm-autopilot-card, .cpm-family-snapshot, .cpm-family-child-row,
        .cpm-action-count, .cpm-autopilot-section, .cpm-planning-wrap
    ) {
        background: var(--cpm-family-case-panel) !important;
        color: var(--cpm-text) !important;
        border-color: var(--cpm-family-case-border) !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content :is(
        .cpm-family-child-row, .cpm-action-count, .cpm-autopilot-section
    ) { background: var(--cpm-family-case-raised) !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .cpm-autopilot-card {
        border-left-color: #8fb7ff !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .cpm-family-snapshot {
        border-left-color: #77dcef !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .cpm-family-data-chip {
        background: #30465b !important;
        color: #e8f2fb !important;
        border-color: #597085 !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .cpm-family-data-chip :is(strong,small) { color: inherit !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .cpm-family-note {
        background: #40331f !important;
        color: #fff1d6 !important;
        border-color: #886641 !important;
        border-left-color: #d8a45d !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .cpm-family-note .text-muted { color: #f2dcb7 !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content :is(.cpm-action-count,.cpm-autopilot-section).is-overdue {
        background: #38232b !important; border-left-color: #ff929d !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content :is(.cpm-action-count,.cpm-autopilot-section).is-today {
        background: #40331f !important; border-left-color: #ffd074 !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content :is(.cpm-action-count,.cpm-autopilot-section).is-week {
        background: #1b3350 !important; border-left-color: #8fb7ff !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .cpm-autopilot-item.is-reminder-due {
        background: #40331f !important; color: #fff1d6 !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content :is(.cpm-autopilot-reminder-label,.cpm-autopilot-reminder-status) { color: #ffe0a0 !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .cpm-autopilot-reminder-status.is-valid { color: #8deac1 !important; }
    /* Spese: stesse superfici del genitore, senza appiattire il codice cromatico. */
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .custom-card {
        background: var(--cpm-family-case-panel) !important;
        color: var(--cpm-text) !important;
        border-color: var(--cpm-family-case-border) !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .custom-card.border-start.border-primary { border-left-color: #8fb7ff !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .custom-card.border-start.border-success { border-left-color: #61d6a0 !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .custom-card.border-start.border-danger  { border-left-color: #ff929d !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .custom-card.border-start.border-warning { border-left-color: #ffd074 !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .custom-card.border-start.border-info    { border-left-color: #77dcef !important; }
    /* Documenti: ogni categoria mantiene il proprio accento da 1px. */
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content :is(.document-desktop-item,.document-mobile-card,.document-mobile-heading,.document-mobile-field) {
        background: var(--cpm-family-case-panel) !important;
        color: var(--cpm-text) !important;
        border-color: var(--cpm-family-case-border) !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content :is(.document-desktop-item,.document-mobile-card) {
        border-left-color: var(--document-accent,#8fb7ff) !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content :is(.document-archive-list,.document-mobile-actions) { background: #172430 !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content :is(.document-mobile-title,.document-mobile-value,.document-desktop-item h6) { color: var(--cpm-text) !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .document-mobile-label { color: var(--cpm-text-secondary) !important; }
    /* Fascicolo: ripristino delle linee verticali per ciascuna KPI/mini-box. */
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content :is(.dossier-header,.dossier-kpi,.dossier-mini-box,.dossier-view-nav) {
        background: var(--cpm-family-case-panel) !important;
        color: var(--cpm-text) !important;
        border-color: var(--cpm-family-case-border) !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-header { border-left-color: var(--dossier-blue,#8fb7ff) !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content :is(.dossier-kpi-blue,.dossier-mini-blue) { border-left-color: var(--dossier-blue,#8fb7ff) !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content :is(.dossier-kpi-green,.dossier-mini-green) { border-left-color: var(--dossier-green,#61d6a0) !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content :is(.dossier-kpi-orange,.dossier-mini-orange) { border-left-color: var(--dossier-orange,#ffd074) !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content :is(.dossier-kpi-teal,.dossier-mini-teal) { border-left-color: var(--dossier-teal,#77dcef) !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-kpi-purple { border-left-color: var(--dossier-purple,#c4b5fd) !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-kpi-slate { border-left-color: var(--dossier-slate,#a4b6c7) !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content :is(.dossier-kpi,.dossier-mini-box) .text-muted,
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-header .text-muted { color: var(--cpm-text-secondary) !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-mini-box strong { color: var(--cpm-text) !important; }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-view-nav .nav-link:not(.active) { color: #a9c6ff !important; }
}


/* 76_01_06 – Rifiniture finali Dark Mode su pratica Family professionale e pagine sentenze Studio.
   Solo contrasto/leggibilità: nessuna logica, nessun permesso, nessun comportamento funzionale alterato. */
@media screen {
    /* Archivio documentale e Fascicolo della pratica Family aperta dal professionista. */
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .document-desktop-item :is(.small, .text-muted),
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .document-mobile-card :is(.small, .text-muted, .form-text),
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .document-mobile-field .document-mobile-label {
        color: var(--cpm-text-secondary) !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .document-desktop-item .badge.bg-light.text-dark,
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .document-mobile-card .badge.bg-light.text-dark {
        background: #30465b !important;
        color: #f0f5fb !important;
        border-color: #597085 !important;
    }

    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card,
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card .list-group-item {
        background: var(--cpm-family-case-panel) !important;
        color: var(--cpm-text) !important;
        border-color: var(--cpm-family-case-border) !important;
    }
    /* Il colore di bordo generale non deve cancellare l'accento sinistro
       originale dei sei tipi di card del Fascicolo: manteniamo la larghezza
       gia' definita nel template (4px), cambiando solo la tinta in Dark Mode. */
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card-blue {
        border-left-color: #8fb7ff !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card-green {
        border-left-color: #61d6a0 !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card-orange {
        border-left-color: #ffd074 !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card-teal {
        border-left-color: #77dcef !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card-purple {
        border-left-color: #c4b5fd !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card-slate {
        border-left-color: #b9cadb !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card .card-header {
        border-bottom-color: var(--cpm-family-case-border) !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card-blue .card-header {
        background: rgba(38, 95, 186, .18) !important;
        color: #b9d2ff !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card-green .card-header {
        background: rgba(17, 107, 77, .20) !important;
        color: #9ce4bf !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card-orange .card-header {
        background: rgba(216, 164, 93, .18) !important;
        color: #ffd88f !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card-teal .card-header {
        background: rgba(49, 97, 108, .24) !important;
        color: #9ee5f1 !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card-purple .card-header {
        background: rgba(118, 93, 168, .22) !important;
        color: #ddcfff !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card-slate .card-header {
        background: rgba(89, 112, 133, .22) !important;
        color: #d7e1eb !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card :is(.text-muted, .form-text),
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card .dropdown-header {
        color: var(--cpm-text-secondary) !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card :is(.alert-light, .bg-light):not(.badge),
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card .border.rounded-3.p-3.bg-light,
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card .small.text-muted.border.rounded-3.p-3.h-100.bg-light,
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card .small.text-muted.border.rounded-3.p-2.bg-white {
        background: #172430 !important;
        color: var(--cpm-text) !important;
        border-color: var(--cpm-family-case-border) !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card .dropdown-divider,
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card .list-group-item {
        border-color: var(--cpm-family-case-border) !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card .dropdown-item {
        color: var(--cpm-text) !important;
    }
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card .dropdown-item:hover,
    html[data-bs-theme="dark"] body.cpm-family-case-ui .app-layout-content .dossier-card .dropdown-item:focus {
        background: rgba(143, 183, 255, .14) !important;
        color: var(--cpm-text) !important;
    }

    /* Registra sentenza / Storico sentenze: ganci esclusivamente visuali. */
    html[data-bs-theme="dark"] .cpm-judgment-page .card[style],
    html[data-bs-theme="dark"] .cpm-judgment-page .card-header.bg-white,
    html[data-bs-theme="dark"] .cpm-judgment-page :is(.bg-light, .bg-white):not(.badge):not(.btn):not(.alert) {
        background: var(--cpm-surface) !important;
        color: var(--cpm-text) !important;
        border-color: var(--cpm-border) !important;
    }
    html[data-bs-theme="dark"] .cpm-judgment-page .card-header.bg-white {
        background: var(--cpm-surface-soft) !important;
        border-bottom-color: var(--cpm-border) !important;
    }
    html[data-bs-theme="dark"] .cpm-judgment-page :is(.text-muted, .form-text) {
        color: var(--cpm-text-secondary) !important;
    }
    html[data-bs-theme="dark"] .cpm-judgment-page .cpm-closure-field.is-pending {
        background: #40331f !important;
        border-color: #886641 !important;
        box-shadow: 0 0 0 .12rem rgba(216, 164, 93, .12);
    }
    html[data-bs-theme="dark"] .cpm-judgment-page .cpm-closure-field.is-confirmed {
        background: #163b31 !important;
        border-color: #2d6855 !important;
        box-shadow: 0 0 0 .12rem rgba(97, 214, 160, .10);
    }
    html[data-bs-theme="dark"] .cpm-judgment-page .cpm-closure-field.is-neutral {
        background: var(--cpm-surface) !important;
        border-color: var(--cpm-border) !important;
    }
    html[data-bs-theme="dark"] .cpm-judgment-page .cpm-field-status {
        background: rgba(164, 182, 199, .18) !important;
        color: var(--cpm-text-secondary) !important;
    }
    html[data-bs-theme="dark"] .cpm-judgment-page .cpm-extraction-box,
    html[data-bs-theme="dark"] .cpm-judgment-page .cpm-analysis-comparison,
    html[data-bs-theme="dark"] .cpm-judgment-page .cpm-autopilot-preview,
    html[data-bs-theme="dark"] .cpm-judgment-page .cpm-preview-row,
    html[data-bs-theme="dark"] .cpm-judgment-page .cpm-preview-values > div,
    html[data-bs-theme="dark"] .cpm-judgment-page [data-extracted-fields] {
        background: #172430 !important;
        color: var(--cpm-text) !important;
        border-color: var(--cpm-border) !important;
    }
    html[data-bs-theme="dark"] .cpm-judgment-page .cpm-analysis-comparison .table th,
    html[data-bs-theme="dark"] .cpm-judgment-page .cpm-analysis-comparison .table td,
    html[data-bs-theme="dark"] .cpm-judgment-page .table > :not(caption) > * > * {
        border-color: var(--cpm-border) !important;
        color: inherit;
    }
    html[data-bs-theme="dark"] .cpm-judgment-page .table > thead.table-light {
        --bs-table-bg: var(--cpm-surface-soft);
        --bs-table-color: var(--cpm-text);
        --bs-table-border-color: var(--cpm-border);
    }
    html[data-bs-theme="dark"] .cpm-judgment-page tr.table-light td {
        background: #172430 !important;
        color: var(--cpm-text) !important;
    }
    html[data-bs-theme="dark"] .cpm-judgment-page .cpm-preview-values span,
    html[data-bs-theme="dark"] .cpm-judgment-page .cpm-preview-status,
    html[data-bs-theme="dark"] .cpm-judgment-page .cpm-analysis-badge {
        color: var(--cpm-text-secondary) !important;
    }
    html[data-bs-theme="dark"] .cpm-judgment-page .cpm-preview-status,
    html[data-bs-theme="dark"] .cpm-judgment-page .cpm-analysis-badge {
        border-color: var(--cpm-border-strong) !important;
        background: rgba(89, 112, 133, .16) !important;
    }
    html[data-bs-theme="dark"] .cpm-judgment-page .alert-light {
        background: #172430 !important;
        color: var(--cpm-text) !important;
        border-color: var(--cpm-border) !important;
    }
    html[data-bs-theme="dark"] .cpm-judgment-page .alert-warning,
    html[data-bs-theme="dark"] .cpm-judgment-page .card.border-warning {
        background: #40331f !important;
        color: #fff1d6 !important;
        border-color: #886641 !important;
    }
    html[data-bs-theme="dark"] .cpm-judgment-page .card-header.bg-warning-subtle {
        background: #4a3820 !important;
        color: #ffe4a9 !important;
        border-bottom-color: #886641 !important;
    }
    html[data-bs-theme="dark"] .cpm-judgment-page .badge.text-bg-secondary {
        background: #415466 !important;
        color: #f0f5fb !important;
    }
}
