/* Neutral identity. Future tenant styles override tokens here, never individual views. */
[data-color="neutral"] { --palette-swatch: #334e68; }
[data-color="blue"] { --palette-swatch: #175da8; }
[data-color="green"] { --palette-swatch: #216b4b; }
[data-color="purple"] { --palette-swatch: #7042a0; }
[data-color="orange"] { --palette-swatch: #984312; }
/* Grid chrome stays light; headers follow the selected palette independently of the sidebar. */
:root {
    --grid-toolbar-background: #f3f4f6;
    --grid-control-background: #ffffff;
    --grid-chrome-border: #d8e0e7;
    --grid-header-background: color-mix(in srgb, var(--palette-solid) 18%, #ffffff);
    --grid-header-hover-background: color-mix(in srgb, var(--palette-solid) 26%, #ffffff);
    --grid-chrome-text: #202e3c;
    --grid-chrome-muted: #526171;
    --grid-filter-active-background: var(--palette-solid);
    --grid-filter-active-text: #ffffff;
    /* Colonne riservate ai profili nazionali: ambra, distinta dalle tinte delle palette; sempre accompagnata dal lucchetto. */
    --grid-reserved-header-background: #f6dfae;
    --grid-reserved-header-hover-background: #f0d08f;
    --grid-reserved-header-text: #4d3000;
    --grid-reserved-accent: #b45309;
    --grid-reserved-cell-tint: color-mix(in srgb, #d97706 10%, transparent);
}
:root,
[data-bs-theme="light"] {
    --brand-primary: #334e68;
    --brand-primary-rgb: 51, 78, 104;
    --palette-solid: #334e68;
    --brand-secondary: #526777;
    --brand-on-primary: #ffffff;
    --surface-page: #f3f5f7;
    --surface-panel: #ffffff;
    --surface-subtle: #e9eef3;
    --text-primary: #202e3c;
    --text-secondary: #526171;
    --border-common: #d8e0e7;
    --focus-color: #1765a5;
    --sidebar-background: #ffffff;
    --sidebar-text: #425466;
    --sidebar-active-background: #e9eef3;
    --sidebar-active-text: #243d54;
    --sidebar-reserved-text: #75450b;
    --sidebar-reserved-active-text: var(--sidebar-reserved-text);
    --panel-radius: .75rem;
    --sidebar-width: 17rem;
    --sidebar-compact-width: 4.5rem;
    --header-height: 4.5rem;
    --bs-primary: var(--brand-primary);
    --bs-primary-rgb: var(--brand-primary-rgb);
    --bs-secondary: var(--brand-secondary);
    --bs-body-color: var(--text-primary);
    --bs-body-bg: var(--surface-page);
    --bs-secondary-color: var(--text-secondary);
    --bs-border-color: var(--border-common);
    --bs-link-color: var(--brand-primary);
    --bs-link-color-rgb: var(--brand-primary-rgb);
    --bs-link-hover-color: var(--text-primary);
    --bs-link-hover-color-rgb: 32, 46, 60;
    --bs-body-font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

[data-bs-theme="dark"] {
    --brand-primary: #b4cadd;
    --brand-primary-rgb: 180, 202, 221;
    --brand-secondary: #a4b7c6;
    --brand-on-primary: #192733;
    --surface-page: #151d25;
    --surface-panel: #1e2934;
    --surface-subtle: #2b3a49;
    --text-primary: #e5edf4;
    --text-secondary: #b5c4d1;
    --border-common: #405163;
    --focus-color: #8fc9fa;
    --sidebar-background: #1e2934;
    --sidebar-text: #c6d3df;
    --sidebar-active-background: #32475b;
    --sidebar-active-text: #eef5fa;
    --sidebar-reserved-text: #ffdb98;
    --sidebar-reserved-active-text: var(--sidebar-reserved-text);
    --bs-link-hover-color-rgb: 229, 237, 244;
    --bs-body-color: var(--text-primary);
    --bs-body-bg: var(--surface-page);
    --bs-secondary-color: var(--text-secondary);
    --bs-border-color: var(--border-common);
    --bs-link-color: var(--brand-primary);
    --bs-link-color-rgb: var(--brand-primary-rgb);
    --bs-link-hover-color: var(--text-primary);
}

/* Personal palettes are allowlisted; each includes accessible light/dark accents. */
:root[data-palette="blue"] { --palette-solid: #175da8; --brand-primary: #175da8; --brand-primary-rgb: 23, 93, 168; --focus-color: #175da8; }
:root[data-palette="green"] { --palette-solid: #216b4b; --brand-primary: #216b4b; --brand-primary-rgb: 33, 107, 75; --focus-color: #216b4b; }
:root[data-palette="purple"] { --palette-solid: #7042a0; --brand-primary: #7042a0; --brand-primary-rgb: 112, 66, 160; --focus-color: #7042a0; }
:root[data-palette="orange"] { --palette-solid: #984312; --brand-primary: #984312; --brand-primary-rgb: 152, 67, 18; --focus-color: #984312; }
:root[data-bs-theme="dark"][data-palette="blue"] { --brand-primary: #9ecbff; --brand-primary-rgb: 158, 203, 255; --focus-color: #9ecbff; }
:root[data-bs-theme="dark"][data-palette="green"] { --brand-primary: #93d9b4; --brand-primary-rgb: 147, 217, 180; --focus-color: #93d9b4; }
:root[data-bs-theme="dark"][data-palette="purple"] { --brand-primary: #d2b6f5; --brand-primary-rgb: 210, 182, 245; --focus-color: #d2b6f5; }
:root[data-bs-theme="dark"][data-palette="orange"] { --brand-primary: #ffc39e; --brand-primary-rgb: 255, 195, 158; --focus-color: #ffc39e; }

[data-sidebar-color="light"] .app-menu {
    --sidebar-background: #ffffff; --sidebar-text: #425466;
    --sidebar-active-background: #e9eef3; --sidebar-active-text: #243d54;
    --sidebar-reserved-text: #75450b;
    --sidebar-reserved-active-text: var(--sidebar-reserved-text);
}
[data-sidebar-color="light"] .app-menu {
    --text-primary: #202e3c; --text-secondary: #526171; --border-common: #d8e0e7;
    --focus-color: #175da8; --bs-btn-close-filter: none;
}
[data-sidebar-color="dark"] .app-menu {
    --sidebar-background: #1e2934; --sidebar-text: #c6d3df;
    --sidebar-active-background: #32475b; --sidebar-active-text: #eef5fa;
    --sidebar-reserved-text: #ffdb98;
    --sidebar-reserved-active-text: var(--sidebar-reserved-text);
}
[data-sidebar-color="dark"] .app-menu {
    --text-primary: #e5edf4; --text-secondary: #b5c4d1; --border-common: #405163;
    --focus-color: #9ecbff; --bs-btn-close-filter: invert(1) grayscale(100%) brightness(200%);
}
[data-sidebar-color="brand"] .app-menu {
    --sidebar-background: var(--palette-solid); --sidebar-text: #ffffff;
    --sidebar-active-background: #ffffff; --sidebar-active-text: var(--palette-solid);
    --sidebar-reserved-text: #ffdb98;
    --sidebar-reserved-active-text: #75450b;
}
[data-sidebar-color="brand"] .app-menu {
    --text-primary: #ffffff; --text-secondary: #ffffff; --border-common: #ffffff;
    --focus-color: #ffffff; --bs-btn-close-filter: invert(1) grayscale(100%) brightness(200%);
}

:root { --associate-inactive-text: #595959; }
[data-bs-theme="dark"] { --associate-inactive-text: #b8b8b8; }
