/* =========================================================================
   SOS IT - Shell v2 (senior UI)
   Collapsible sidebar (icon rail) · Light/Dark · Lucide · Brand red
   ========================================================================= */

:root {
    --primary: #dc2626;
    --primary-dark: #b91c1c;
    --primary-light: #fef2f2;
    --primary-rgb: 220, 38, 38;

    --bg-color: #ffffff;
    --surface-color: #ffffff;
    --surface-elevated: #ffffff;
    --border-color: #e4e4e7;
    --border-strong: #d4d4d8;
    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;

    --thead-bg: #fafafa;
    --thead-text: #71717a;
    --row-hover-bg: #fafafa;

    --muted-icon-bg: #f4f4f5;
    --muted-icon-fg: #71717a;

    --sidebar-bg: #ffffff;
    --sidebar-fg: #3f3f46;
    --sidebar-accent: #f4f4f5;
    --sidebar-accent-fg: #18181b;
    --sidebar-border: #e4e4e7;
    --sidebar-ring: rgba(220, 38, 38, 0.35);
    --sidebar-muted: #71717a;
    --chrome-bg: #ffffff;

    --sidebar-width: 16rem;
    --sidebar-width-icon: 3.5rem; /* rail 56px - centre les boutons 36px */
    --topbar-height: 3.5rem;
    --sidebar-icon-btn: 2.25rem; /* h-9 w-9 */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --fab-size: 2.75rem;
    --fab-gap: 0.75rem;
    --mobile-chrome-offset: calc(var(--safe-top) + var(--fab-size) + var(--fab-gap) + 0.35rem);

    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.625rem;
    --radius-xl: 0.75rem;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --t: 150ms ease;
    --t-theme: 220ms ease;
    --t-sidebar: 300ms cubic-bezier(0.2, 0, 0, 1); /* LibreChat EASING */
}

/*
  Dark = tokens CSS (approche Tailwind/genechao) :
  une seule source, pas de dark: partout.
  Esthétique proche OpenCode / Kimi : toile profonde, surfaces discrètes.
*/
[data-theme="dark"] {
    --primary: #f04444;
    --primary-dark: #dc2626;
    --primary-light: rgba(240, 68, 68, 0.14);
    --primary-rgb: 240, 68, 68;

    --bg-color: #0a0a0a;
    --surface-color: #111111;
    --surface-elevated: #161616;
    --border-color: #1f1f1f;
    --border-strong: #2a2a2a;
    --text-primary: #f5f5f5;
    --text-secondary: #a3a3a3;
    --text-muted: #737373;

    --thead-bg: #0f0f0f;
    --thead-text: #a3a3a3;
    --row-hover-bg: #141414;

    --muted-icon-bg: #1a1a1a;
    --muted-icon-fg: #a3a3a3;

    --sidebar-bg: #0a0a0a;
    --sidebar-fg: #a3a3a3;
    --sidebar-accent: #161616;
    --sidebar-accent-fg: #f5f5f5;
    --sidebar-border: #1f1f1f;
    --sidebar-ring: rgba(240, 68, 68, 0.4);
    --sidebar-muted: #737373;

    --white: #f5f5f5;
    --body-bg-light: #0a0a0a;
    --card-bg: #111111;
    --input-bg: #0a0a0a;
    --chrome-bg: #0a0a0a;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.55);
}

/* =========================================================================
   Scrollbars - charte SOS (rouge brand, pas le gris OS)
   ========================================================================= */
:root {
    --scrollbar-size: 10px;
    --scrollbar-track: #f4f4f5;
    --scrollbar-thumb: #dc2626;
    --scrollbar-thumb-hover: #b91c1c;
    --scrollbar-thumb-active: #991b1b;
}

[data-theme="dark"] {
    --scrollbar-track: #111111;
    --scrollbar-thumb: #f04444;
    --scrollbar-thumb-hover: #dc2626;
    --scrollbar-thumb-active: #b91c1c;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* Viewport: piste transparente → pas de bande vide à droite du topbar */
html {
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
    background: transparent;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
    border-color: transparent;
}

/* Chromium / Safari / Edge */
*::-webkit-scrollbar {
    width: var(--scrollbar-size);
    height: var(--scrollbar-size);
}

*::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid var(--scrollbar-track);
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    border: 2px solid var(--scrollbar-track);
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:active {
    background: var(--scrollbar-thumb-active);
    border: 2px solid var(--scrollbar-track);
    background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
    background: var(--scrollbar-track);
}

/* Sidebar : rail fin (toujours charte rouge, discret) */
.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--primary-rgb), 0.55) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(var(--primary-rgb), 0.45);
    border: none;
    border-radius: 999px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--primary-rgb), 0.75);
    border: none;
}

html {
    color-scheme: light;
}

[data-theme="dark"] html,
html[data-theme="dark"] {
    color-scheme: dark;
}

body {
    background: var(--bg-color);
    color: var(--text-primary);
}

html,
body {
    background-color: var(--bg-color);
}

/* -------------------------------------------------------------------------
   Photo de fond globale (login + console)
   Photo visible + voile blanc (clair) / sombre (dark) - sans flou
   ---------------------------------------------------------------------- */
:root {
    --sos-bg-photo: url("../img/sos-bg.webp");
    --sos-bg-photo-fallback: url("../img/sos-bg.jpg");
    --sos-bg-veil: rgba(255, 255, 255, 0.96);
}

html[data-theme="dark"] {
    --sos-bg-veil: rgba(9, 9, 11, 0.96);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-color: transparent;
    background-image: var(--sos-bg-photo-fallback);
    background-image: var(--sos-bg-photo);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 1;
    filter: none;
    transform: none;
}

/* Voile blanc (clair) / quasi noir (dark) - même force */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: var(--sos-bg-veil);
}

/* Contenu / chrome au-dessus de la photo */
.sidebar,
.main-panel,
.sos-footer,
.top-bar,
.sidebar-mobile-fab {
    position: relative;
    z-index: 1;
}

.sidebar {
    z-index: 40;
}

/* Transitions thème (désactivées si reduce-motion) */
html:not([data-reduce-motion="true"]) body,
html:not([data-reduce-motion="true"]) .main-panel,
html:not([data-reduce-motion="true"]) .sidebar,
html:not([data-reduce-motion="true"]) .top-bar,
html:not([data-reduce-motion="true"]) .sos-footer,
html:not([data-reduce-motion="true"]) .sos-page-header,
html:not([data-reduce-motion="true"]) .page-header,
html:not([data-reduce-motion="true"]) .sos-mode-toggle__rail,
html:not([data-reduce-motion="true"]) .sos-mode-toggle__thumb {
    transition:
        background-color var(--t-theme, 220ms ease),
        border-color var(--t-theme, 220ms ease),
        color var(--t-theme, 220ms ease),
        box-shadow var(--t-theme, 220ms ease);
}

.sos-visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* -------------------------------------------------------------------------
   Mode toggle (pill sun/moon) - tokens, pas de couleurs hardcodées
   ---------------------------------------------------------------------- */
.sos-mode-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font: inherit;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

.sos-mode-toggle__rail {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    width: 3.5rem;
    height: 1.85rem;
    padding: 0.15rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--muted-icon-bg);
    box-sizing: border-box;
}

.sos-mode-toggle__opt {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    pointer-events: none;
}

.sos-mode-toggle__opt .lucide-icon {
    width: 0.85rem;
    height: 0.85rem;
    stroke-width: 1.75;
}

.sos-mode-toggle__thumb {
    position: absolute;
    top: 0.15rem;
    left: 0.15rem;
    width: calc(50% - 0.15rem);
    height: calc(100% - 0.3rem);
    border-radius: 999px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xs);
    z-index: 0;
    transition: transform var(--t-theme, 220ms ease), background-color var(--t-theme, 220ms ease);
}

html[data-theme="light"] .sos-mode-toggle__opt--light,
[data-theme="light"] .sos-mode-toggle__opt--light {
    color: var(--text-primary);
}

html[data-theme="dark"] .sos-mode-toggle__thumb,
[data-theme="dark"] .sos-mode-toggle__thumb {
    transform: translateX(100%);
}

html[data-theme="dark"] .sos-mode-toggle__opt--dark,
[data-theme="dark"] .sos-mode-toggle__opt--dark {
    color: var(--text-primary);
}

.sos-mode-toggle:hover .sos-mode-toggle__rail {
    border-color: var(--border-strong);
}

.sos-mode-toggle:focus-visible .sos-mode-toggle__rail {
    outline: none;
    box-shadow: 0 0 0 3px var(--sidebar-ring);
}

/* Disable flashy button animations globally in shell */
.btn,
.sidebar-toggle-btn,
.theme-toggle,
.notif-bell {
    animation: none !important;
    transform: none !important;
}

.btn:hover,
.sidebar-toggle-btn:hover,
.theme-toggle:hover {
    transform: none !important;
}

/* -------------------------------------------------------------------------
   Sidebar - LibreChat UnifiedSidebar / ExpandedPanel adapted (SOS red)
   ---------------------------------------------------------------------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--footer-height, 2.75rem));
    height: calc(100dvh - var(--footer-height, 2.75rem));
    bottom: var(--footer-height, 2.75rem);
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    box-shadow: none;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width var(--t-sidebar);
    border-right: 1px solid var(--sidebar-border);
}

/* Shell sans topbar / footer : tout dans la sidebar */
body.shell-sidebar-only {
    --topbar-height: 0px;
    --footer-height: 0px;
}

body.shell-sidebar-only .sidebar {
    height: 100vh;
    height: 100dvh;
    bottom: 0;
}

body.shell-sidebar-only .sos-footer,
body.shell-sidebar-only .top-bar {
    display: none !important;
}

body.shell-sidebar-only .main-panel .content {
    padding-top: 1.25rem !important;
    padding-bottom: 2rem;
    padding-left: var(--content-padding, 1.5rem);
    padding-right: var(--content-padding, 1.5rem);
}

/* Évite le double padding haut (content + wrap page) - niveau uniforme */
body.shell-sidebar-only .page-wrap,
body.shell-sidebar-only .ann-wrap,
body.shell-sidebar-only .dash-wrap,
body.shell-sidebar-only .rsi-wrap,
body.shell-sidebar-only .estab-wrap,
body.shell-sidebar-only .salle-wrap,
body.shell-sidebar-only .prof-wrap,
body.shell-sidebar-only .dsi-wrap,
body.shell-sidebar-only .p-wrap,
body.shell-sidebar-only .u-wrap,
body.shell-sidebar-only .audit-wrap,
body.shell-sidebar-only .rc-wrap,
body.shell-sidebar-only .console-container,
body.shell-sidebar-only .settings-wrap,
body.shell-sidebar-only .set-wrap,
body.shell-sidebar-only .ni {
    padding-top: 0 !important;
}

.sidebar-header {
    min-height: 3.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.65rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: nowrap;
    min-width: 0;
    flex: 1;
    line-height: 1.15;
    gap: 0.1rem;
}

.sidebar-brand-sub {
    font-family: 'Inter', sans-serif;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #18181b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

[data-theme="dark"] .sidebar-brand-sub {
    color: #e4e4e7;
}

.sidebar-collapse-btn {
    width: var(--sidebar-icon-btn);
    height: var(--sidebar-icon-btn);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: auto;
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--sidebar-muted);
    cursor: pointer;
    padding: 0;
    transition: background-color var(--t), color var(--t), border-color var(--t);
}

.sidebar-collapse-btn:hover {
    background: var(--sidebar-accent);
    color: var(--sidebar-accent-fg);
    border-color: var(--sidebar-border);
}

.sidebar-collapse-btn .lucide-icon {
    width: 1.125rem;
    height: 1.125rem;
}

/* Logo réseau MlfMonde (visible seulement sidebar ouverte) */
.sidebar-mlf {
    flex-shrink: 0;
    padding: 0.35rem 0.55rem 0.45rem;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    box-sizing: border-box;
}

.sidebar-mlf__link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    text-decoration: none;
    border-radius: 0.4rem;
    padding: 0.2rem 0.15rem;
    overflow: visible;
    transition: background-color var(--t);
}

.sidebar-mlf__link:hover {
    background: rgba(15, 98, 127, 0.06);
}

.sidebar-mlf__logo {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 5.75rem;
    object-fit: contain;
    object-position: center;
    filter: none;
}
/* Demandeur : pas de logo à côté du nom - logo plein largeur dans le bandeau */
body:not(.sidebar-collapsed) .sidebar-logo--collapsed-only {
    display: none !important;
}
.sidebar-brand-name {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}
.sidebar-brand-name > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-brand-icon {
    width: 1rem !important;
    height: 1rem !important;
    flex-shrink: 0;
    color: #dc2626;
}
.sidebar-brand-text--demandeur .sidebar-brand-sub {
    padding-left: 1.4rem; /* aligne sous le texte, après l’icône */
}
.sidebar-mlf--estab {
    padding: 0.45rem 0.45rem 0.55rem;
}
.sidebar-mlf__link--estab {
    padding: 0.15rem;
    width: 100%;
}
.sidebar-mlf__logo--estab {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 7.5rem !important;
    object-fit: contain;
    object-position: center;
}
.sidebar-mlf__link--estab:hover {
    background: rgba(220, 38, 38, 0.06);
}

/* Pas de logo établissement : ne rien afficher (ni MlfMonde, ni SOS) */
.sidebar-mlf--empty {
    display: none !important;
}


.sidebar-chrome {
    border-top: 1px solid var(--sidebar-border);
    padding: 0.65rem 0.65rem 0.75rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

/* Thème Clair / Sombre / Système */
.sb-theme {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.25rem;
    padding: 0.2rem;
    border-radius: 0.625rem;
    background: var(--sidebar-accent, #f4f4f5);
    border: 1px solid var(--sidebar-border, #e4e4e7);
}

.sb-theme__btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 2.55rem;
    padding: 0.3rem 0.2rem;
    margin: 0;
    border: 1px solid transparent;
    border-radius: 0.45rem;
    background: transparent;
    color: var(--sidebar-muted, #71717a);
    font-family: inherit;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background-color var(--t), color var(--t), border-color var(--t);
}

.sb-theme__btn .lucide-icon {
    width: 0.95rem;
    height: 0.95rem;
}

.sb-theme__btn:hover {
    color: var(--text-primary, #18181b);
    background: rgba(255, 255, 255, 0.7);
}

.sb-theme__btn.is-active {
    background: #fff;
    color: #18181b;
    border-color: #e4e4e7;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .sb-theme {
    background: #18181b;
    border-color: #27272a;
}

[data-theme="dark"] .sb-theme__btn:hover {
    background: #27272a;
    color: #fafafa;
}

[data-theme="dark"] .sb-theme__btn.is-active {
    background: #27272a;
    color: #fafafa;
    border-color: #3f3f46;
}

/* -------------------------------------------------------------------------
   Recherche globale - déclencheur sidebar + palette Ctrl+K
   ---------------------------------------------------------------------- */
.sb-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 2.35rem;
    padding: 0.4rem 0.55rem;
    margin: 0;
    border: 1px solid var(--sidebar-border, #e4e4e7);
    border-radius: 0.55rem;
    background: var(--sidebar-accent, #f4f4f5);
    color: var(--sidebar-muted, #71717a);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background-color var(--t), border-color var(--t), color var(--t), box-shadow var(--t);
}

.sb-search .lucide-icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    color: var(--sidebar-muted, #71717a);
}

.sb-search__label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sb-search__kbd {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    flex-shrink: 0;
    padding: 0;
    border: none;
    background: transparent;
    font-family: inherit;
}

.sb-search__kbd span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.2rem;
    padding: 0 0.3rem;
    border: 1px solid var(--sidebar-border, #e4e4e7);
    border-radius: 0.3rem;
    background: #fff;
    color: #71717a;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1;
}

.sb-search:hover {
    color: var(--text-primary, #18181b);
    border-color: #d4d4d8;
    background: #fff;
}

.sb-search:hover .lucide-icon {
    color: #dc2626;
}

.sb-search:focus-visible {
    outline: none;
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
}

.sb-push {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 2.15rem;
    padding: 0.35rem 0.55rem;
    margin: 0;
    border: 1px solid var(--sidebar-border, #e4e4e7);
    border-radius: 0.55rem;
    background: #fff;
    color: #52525b;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background-color var(--t), border-color var(--t), color var(--t);
}

.sb-push .lucide-icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    color: #dc2626;
}

.sb-push__text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sb-push:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #18181b;
}

.sb-push.is-on {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.sb-push--install {
    color: #3f3f46;
}

.sb-push--install .lucide-icon { color: #52525b; }

body.sidebar-collapsed .sb-push {
    width: var(--sidebar-icon-btn);
    height: var(--sidebar-icon-btn);
    min-height: var(--sidebar-icon-btn);
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-lg);
}

body.sidebar-collapsed .sb-push__text {
    display: none !important;
}

[data-theme="dark"] .sb-push {
    background: #18181b;
    border-color: #27272a;
    color: #a1a1aa;
}

[data-theme="dark"] .sb-push:hover,
[data-theme="dark"] .sb-push.is-on {
    background: rgba(220, 38, 38, 0.12);
    border-color: rgba(220, 38, 38, 0.35);
    color: #fecaca;
}

[data-theme="dark"] .sb-search {
    background: #18181b;
    border-color: #27272a;
    color: #a1a1aa;
}

[data-theme="dark"] .sb-search__kbd span {
    background: #09090b;
    border-color: #3f3f46;
    color: #a1a1aa;
}

[data-theme="dark"] .sb-search:hover {
    background: #27272a;
    border-color: #3f3f46;
    color: #fafafa;
}

body.sidebar-collapsed .sb-search {
    width: var(--sidebar-icon-btn);
    height: var(--sidebar-icon-btn);
    min-height: var(--sidebar-icon-btn);
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-lg);
}

body.sidebar-collapsed .sb-search__label,
body.sidebar-collapsed .sb-search__kbd {
    display: none !important;
}

body.sidebar-collapsed .sb-search[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 0.65rem);
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    padding: 0.35rem 0.55rem;
    border-radius: var(--radius);
    background: var(--text-primary);
    color: var(--surface-color);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 1200;
    box-shadow: var(--shadow-sm);
    transition: opacity 120ms ease, transform 120ms ease;
}

body.sidebar-collapsed .sb-search {
    position: relative;
}

body.sidebar-collapsed .sb-search[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.sos-cmd {
    position: fixed;
    inset: 0;
    z-index: 14000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 12vh 1rem 2rem;
}

.sos-cmd.is-open,
.sos-cmd:not([hidden]) {
    display: flex;
}

.sos-cmd[hidden] {
    display: none !important;
}

.sos-cmd__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(9, 9, 11, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.sos-cmd__panel {
    position: relative;
    z-index: 1;
    width: min(100%, 36rem);
    max-height: min(72vh, 34rem);
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e4e4e7;
    border-radius: 0.75rem;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
    overflow: hidden;
    animation: sosCmdIn 140ms ease-out;
}

@keyframes sosCmdIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .sos-cmd__panel { animation: none; }
}

.sos-cmd__head {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #f4f4f5;
}

.sos-cmd__search-icon {
    width: 1.15rem;
    height: 1.15rem;
    color: #a1a1aa;
    flex-shrink: 0;
}

.sos-cmd__input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: #18181b;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.4;
    padding: 0;
    margin: 0;
    box-shadow: none;
}

.sos-cmd__input::placeholder {
    color: #a1a1aa;
    font-weight: 450;
}

.sos-cmd__esc {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 1.45rem;
    padding: 0 0.4rem;
    border: 1px solid #e4e4e7;
    border-radius: 0.3rem;
    background: #fafafa;
    color: #71717a;
    font-family: inherit;
    font-size: 0.625rem;
    font-weight: 700;
    cursor: pointer;
}

.sos-cmd__body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0.4rem 0.4rem 0.55rem;
}

.sos-cmd__hint {
    padding: 1.5rem 1rem;
    text-align: center;
    color: #71717a;
    font-size: 0.8125rem;
    line-height: 1.45;
}

.sos-cmd__hint p { margin: 0; }
.sos-cmd__hint p + p { margin-top: 0.65rem; }

.sos-cmd__empty-title {
    font-weight: 700;
    color: #18181b;
    font-size: 0.875rem;
    margin-bottom: 0.25rem !important;
}

.sos-cmd__hint-keys {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    color: #a1a1aa;
    font-size: 0.75rem;
}

.sos-cmd__hint-keys kbd,
.sos-cmd__foot kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.2rem;
    padding: 0 0.3rem;
    border: 1px solid #e4e4e7;
    border-radius: 0.25rem;
    background: #fafafa;
    color: #52525b;
    font-family: inherit;
    font-size: 0.625rem;
    font-weight: 700;
}

.sos-cmd__group {
    margin-bottom: 0.35rem;
}

.sos-cmd__group-label {
    padding: 0.45rem 0.65rem 0.25rem;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #a1a1aa;
}

.sos-cmd__item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    margin: 0;
    padding: 0.55rem 0.65rem;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    background: transparent;
    color: inherit;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background-color 80ms ease;
}

.sos-cmd__item.is-active,
.sos-cmd__item:hover {
    background: #f4f4f5;
    border-color: #e4e4e7;
}

.sos-cmd__item.is-active {
    background: #fef2f2;
    border-color: #fecaca;
}

.sos-cmd__icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.45rem;
    background: #f4f4f5;
    border: 1px solid #e4e4e7;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #52525b;
}

.sos-cmd__item.is-active .sos-cmd__icon {
    background: #fee2e2;
    border-color: #fecaca;
    color: #dc2626;
}

.sos-cmd__icon .lucide-icon {
    width: 1rem;
    height: 1rem;
}

.sos-cmd__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.sos-cmd__title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #18181b;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sos-cmd__sub {
    font-size: 0.6875rem;
    color: #71717a;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sos-cmd__meta {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.sos-cmd__meta-text {
    font-size: 0.625rem;
    color: #a1a1aa;
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sos-cmd__badge {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.4rem;
    border-radius: 0.3rem;
    font-size: 0.625rem;
    font-weight: 700;
    background: #f4f4f5;
    color: #52525b;
    border: 1px solid #e4e4e7;
}

.sos-cmd__badge--new { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.sos-cmd__badge--progress { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.sos-cmd__badge--done { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.sos-cmd__badge--rejected { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.sos-cmd__badge--cancelled { background: #f4f4f5; color: #52525b; border-color: #d4d4d8; }

.sos-cmd__enter {
    width: 0.85rem;
    height: 0.85rem;
    color: #a1a1aa;
    opacity: 0;
}

.sos-cmd__item.is-active .sos-cmd__enter {
    opacity: 1;
    color: #dc2626;
}

.sos-cmd__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.85rem;
    border-top: 1px solid #f4f4f5;
    background: #fafafa;
    font-size: 0.6875rem;
    color: #71717a;
}

.sos-cmd__foot-left {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.sos-cmd__foot-left .lucide-icon {
    width: 0.8rem;
    height: 0.8rem;
    flex-shrink: 0;
}

.sos-cmd__foot-right {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    flex-shrink: 0;
}

[data-theme="dark"] .sos-cmd__panel {
    background: #18181b;
    border-color: #27272a;
}

[data-theme="dark"] .sos-cmd__head,
[data-theme="dark"] .sos-cmd__foot {
    border-color: #27272a;
    background: #09090b;
}

[data-theme="dark"] .sos-cmd__input { color: #fafafa; }
[data-theme="dark"] .sos-cmd__esc {
    background: #18181b;
    border-color: #3f3f46;
    color: #a1a1aa;
}

[data-theme="dark"] .sos-cmd__item.is-active,
[data-theme="dark"] .sos-cmd__item:hover {
    background: #27272a;
    border-color: #3f3f46;
}

[data-theme="dark"] .sos-cmd__item.is-active {
    background: rgba(220, 38, 38, 0.12);
    border-color: rgba(220, 38, 38, 0.35);
}

[data-theme="dark"] .sos-cmd__icon {
    background: #27272a;
    border-color: #3f3f46;
    color: #a1a1aa;
}

[data-theme="dark"] .sos-cmd__title,
[data-theme="dark"] .sos-cmd__empty-title { color: #fafafa; }

[data-theme="dark"] .sos-cmd__hint-keys kbd,
[data-theme="dark"] .sos-cmd__foot kbd {
    background: #18181b;
    border-color: #3f3f46;
    color: #a1a1aa;
}

.sidebar-chrome__meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.2rem 0.15rem 0;
    font-size: 0.6875rem;
    color: var(--sidebar-muted);
}

.sidebar-chrome__version {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    opacity: 0.85;
}

/* Notifs dans la nav */
.notif-nav-btn {
    position: relative;
}

/* Identité utilisateur */
.sb-user {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    width: 100%;
}

.sb-user__identity {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.55rem 0.55rem;
    border-radius: 0.75rem;
    background: var(--sidebar-accent, #f4f4f5);
    border: 1px solid var(--sidebar-border, #e4e4e7);
    text-decoration: none;
    color: inherit;
    transition: border-color var(--t), background-color var(--t);
}

.sb-user__identity:hover {
    border-color: #d4d4d8;
    background: #eeeef0;
}

.sb-user__avatar,
.sb-user__avatar-wrap.sos-avatar {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.55rem;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border-color, #e4e4e7);
    background: #f4f4f5;
}

.sb-user__avatar--fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f4f4f5;
    color: #71717a;
    border: 1px solid var(--border-color, #e4e4e7);
}

/* Avatar unifié (photo ou icône) */
.sos-avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    background: #f4f4f5;
    border: 1px solid #e4e4e7;
    color: #71717a;
}
.sos-avatar--sm { width: 1.75rem; height: 1.75rem; border-radius: 0.4rem; }
.sos-avatar--md { width: 2.25rem; height: 2.25rem; border-radius: 0.55rem; }
.sos-avatar--lg { width: 2.75rem; height: 2.75rem; border-radius: 0.6rem; }
.sos-avatar--xl { width: 4rem; height: 4rem; border-radius: 0.625rem; }
.sos-avatar__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    background: #fff;
}
.sos-avatar__icon {
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    z-index: 0;
}
.sos-avatar--fallback .sos-avatar__icon,
.sos-avatar:not(:has(.sos-avatar__img)) .sos-avatar__icon {
    display: inline-flex;
}
.sos-avatar--sm .sos-avatar__icon .lucide-icon { width: 0.9rem; height: 0.9rem; }
.sos-avatar--md .sos-avatar__icon .lucide-icon { width: 1.05rem; height: 1.05rem; }
.sos-avatar--lg .sos-avatar__icon .lucide-icon { width: 1.2rem; height: 1.2rem; }
.sos-avatar--xl .sos-avatar__icon .lucide-icon { width: 1.65rem; height: 1.65rem; }

[data-theme="dark"] .sos-avatar {
    background: #27272a;
    border-color: #3f3f46;
    color: #a1a1aa;
}

.sb-user__text {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding-top: 0.05rem;
}

.sb-user__name {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--text-primary, #18181b);
    line-height: 1.25;
    word-break: break-word;
}

.sb-user__role {
    display: inline-flex;
    align-self: flex-start;
    max-width: 100%;
    padding: 0.2rem 0.45rem;
    border-radius: 0.35rem;
    border: 1px solid transparent;
    font-size: 0.625rem;
    font-weight: 600;
    line-height: 1.3;
}

.sb-user__go {
    width: 0.95rem !important;
    height: 0.95rem !important;
    color: #a1a1aa;
    flex-shrink: 0;
    margin-top: 0.35rem;
}

.sb-user__logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    min-height: 2.125rem;
    padding: 0.4rem 0.65rem;
    margin: 0;
    border: 1px solid #fecaca;
    border-radius: 0.55rem;
    background: #fef2f2;
    color: #b91c1c;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--t), border-color var(--t), color var(--t);
}

.sb-user__logout .lucide-icon {
    width: 0.9375rem;
    height: 0.9375rem;
    flex-shrink: 0;
}

.sb-user__logout:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

.sb-user__logout:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
}

[data-theme="dark"] .sb-user__identity {
    background: #18181b;
    border-color: #27272a;
}

[data-theme="dark"] .sb-user__identity:hover {
    background: #1f1f23;
    border-color: #3f3f46;
}

[data-theme="dark"] .sb-user__avatar {
    background: #09090b;
    border-color: #3f3f46;
}

[data-theme="dark"] .sb-user__name {
    color: #fafafa;
}

[data-theme="dark"] .sb-user__logout {
    background: rgba(220, 38, 38, 0.12);
    border-color: rgba(220, 38, 38, 0.35);
    color: #fca5a5;
}

[data-theme="dark"] .sb-user__logout:hover {
    background: rgba(220, 38, 38, 0.2);
    border-color: rgba(248, 113, 113, 0.45);
    color: #fecaca;
}

.sidebar-mobile-fab {
    display: none;
    position: fixed;
    top: max(0.75rem, var(--safe-top, 0px));
    left: max(0.75rem, var(--safe-left, 0px));
    z-index: 1205;
    width: var(--fab-size, 2.75rem);
    height: var(--fab-size, 2.75rem);
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    padding: 0;
}

.sidebar-mobile-fab .lucide-icon {
    width: 1.25rem;
    height: 1.25rem;
}


/* =========================================================================
   Wordmark SOS IT : S + logo (O) + S IT
   ========================================================================= */
.sos-wordmark {
    display: inline-flex;
    align-items: center;
    gap: 0.08em;
    font-family: 'Outfit', 'Inter', sans-serif;
    font-weight: 800;
    color: #dc2626;
    letter-spacing: -0.04em;
    line-height: 1;
    white-space: nowrap;
    user-select: none;
}
.sos-wordmark__letter,
.sos-wordmark__it {
    display: inline-block;
    line-height: 1;
}
.sos-wordmark__it {
    margin-left: 0.22em;
    letter-spacing: -0.02em;
}
.sos-wordmark__mark {
    display: block;
    flex-shrink: 0;
    object-fit: contain;
    width: 1.35em;
    height: 1.35em;
}
.sos-wordmark--sm { font-size: 1.05rem; }
.sos-wordmark--md { font-size: 1.35rem; }
.sos-wordmark--lg { font-size: 1.85rem; }
.sos-wordmark--auth { font-size: 2.35rem; }
.sos-wordmark--auth .sos-wordmark__mark { width: 2.55rem; height: 2.55rem; }
.sos-wordmark--sidebar { font-size: 1.85rem; }
.sos-wordmark--sidebar .sos-wordmark__mark {
    width: 2.4rem;
    height: 2.4rem;
}

.sidebar-logo--wordmark {
    width: auto !important;
    max-width: calc(100% - 2.5rem);
    height: auto !important;
    min-height: var(--sidebar-icon-btn);
    padding: 0.1rem 0.1rem;
    overflow: visible;
    justify-content: flex-start;
    flex: 1 1 auto;
}
.sidebar-logo--wordmark .sos-wordmark {
    max-width: 100%;
    width: 100%;
}

/* Rail réduit : garder uniquement le picto logo */
body.sidebar-collapsed .sidebar-logo--wordmark {
    width: 2.65rem !important;
    height: 2.65rem !important;
    max-width: none;
    padding: 0;
    justify-content: center;
    overflow: hidden;
}
body.sidebar-collapsed .sidebar-logo--wordmark .sos-wordmark {
    gap: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
body.sidebar-collapsed .sidebar-logo--wordmark .sos-wordmark__letter,
body.sidebar-collapsed .sidebar-logo--wordmark .sos-wordmark__it {
    display: none !important;
}
body.sidebar-collapsed .sidebar-logo--wordmark .sos-wordmark__mark {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
    object-position: center;
}

.sidebar-logo {
    width: var(--sidebar-icon-btn);
    height: var(--sidebar-icon-btn);
    border-radius: var(--radius-lg);
    background: transparent;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-decoration: none;
    box-shadow: none;
    overflow: hidden;
    transition: opacity var(--t), transform var(--t);
}

.sidebar-logo:hover {
    background: transparent;
    opacity: 0.92;
    box-shadow: none;
}

.sidebar-logo .sidebar-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.sidebar-logo .lucide-icon,
.sidebar-logo .sidebar-logo-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: #fff;
    stroke: #fff;
}

.sidebar-brand-name {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 150ms ease;
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
}

.sidebar .nav {
    list-style: none;
    margin: 0;
    padding: 0 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem; /* LibreChat gap-1 */
    min-height: 100%;
}

.sidebar .nav-item {
    margin: 0;
}

.sidebar .nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    height: var(--sidebar-icon-btn);
    padding: 0 0.625rem;
    border-radius: var(--radius-lg); /* rounded-lg */
    color: var(--sidebar-fg) !important;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    outline: none;
    transition: background-color var(--t), color var(--t);
}

.sidebar .nav-link .lucide-icon {
    width: 1.25rem; /* h-5 w-5 */
    height: 1.25rem;
    flex-shrink: 0;
    color: inherit;
    stroke-width: 1.75;
}

.sidebar .nav-link-text {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.sidebar .nav-link:hover {
    background: var(--sidebar-accent);
    color: var(--sidebar-accent-fg) !important;
}

.sidebar .nav-link:focus-visible {
    box-shadow: 0 0 0 2px var(--sidebar-ring);
}

.sidebar .nav-link.active {
    background: var(--primary-light);
    color: var(--primary) !important;
    font-weight: 600;
}

.sidebar .nav-link.active .lucide-icon {
    color: var(--primary);
}

.sidebar .nav-section-label {
    list-style: none;
    padding: 0.875rem 0.625rem 0.35rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
    white-space: nowrap;
    overflow: hidden;
}

/* Paramètres - sous-menu collapsible */
.sidebar .nav-group {
    list-style: none;
}

.sidebar .nav-group__toggle {
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.sidebar .nav-group__chevron {
    width: 0.875rem !important;
    height: 0.875rem !important;
    margin-left: auto;
    opacity: 0.7;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.sidebar .nav-group.is-open .nav-group__chevron {
    transform: rotate(180deg);
}

.sidebar .nav-group__list {
    list-style: none;
    margin: 0.15rem 0 0.25rem;
    padding: 0 0 0 0.55rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    border-left: 1px solid var(--sidebar-border);
    margin-left: 1.15rem;
}

.sidebar .nav-group__list[hidden] {
    display: none;
}

.sidebar .nav-group__link {
    height: 2rem;
    font-size: 0.8125rem;
    padding-left: 0.5rem;
}

body.sidebar-collapsed .sidebar .nav-group__list,
body.sidebar-collapsed .sidebar .nav-group__chevron {
    display: none !important;
}

/* Settings subnav (page Profil / Apparence) */
.set-subnav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    position: sticky;
    top: calc(var(--topbar-height) + 1rem);
}

.set-subnav__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.25rem;
    padding: 0.4rem 0.65rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary, #52525b);
    text-decoration: none;
    border: 1px solid transparent;
}

.set-subnav__item .lucide-icon {
    width: 1.125rem;
    height: 1.125rem;
    stroke-width: 1.75;
    flex-shrink: 0;
}

.set-subnav__item:hover {
    background: var(--bg-color, #f4f4f5);
    color: var(--text-primary, #18181b);
}

.set-subnav__item.is-active {
    background: rgba(220, 38, 38, 0.08);
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.18);
}

@media (max-width: 768px) {
    .set-subnav {
        flex-direction: row;
        flex-wrap: wrap;
        position: static;
        margin-bottom: 0.25rem;
    }
    .set-subnav__item {
        flex: 1;
        justify-content: center;
        min-width: 7rem;
    }
}

/* -------------------------------------------------------------------------
   Appearance prefs (data-* on <html>)
   ---------------------------------------------------------------------- */
html[data-font="inter"] body,
html[data-font="inter"] .main-panel {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
html[data-font="outfit"] body,
html[data-font="outfit"] .main-panel {
    font-family: 'Outfit', 'Inter', sans-serif;
}
html[data-font="source-sans"] body,
html[data-font="source-sans"] .main-panel {
    font-family: 'Source Sans 3', 'Inter', sans-serif;
}
html[data-font="ibm-plex"] body,
html[data-font="ibm-plex"] .main-panel {
    font-family: 'IBM Plex Sans', 'Inter', sans-serif;
}
html[data-font="atkinson"] body,
html[data-font="atkinson"] .main-panel {
    font-family: 'Atkinson Hyperlegible', 'Inter', sans-serif;
}

html[data-font-size="sm"] { font-size: 14px; }
html[data-font-size="md"] { font-size: 15px; }
html[data-font-size="lg"] { font-size: 16.5px; }

html[data-contrast="high"] {
    --border-color: #a1a1aa;
    --border-strong: #71717a;
    --text-muted: #52525b;
    --text-secondary: #3f3f46;
}
html[data-theme="dark"][data-contrast="high"] {
    --border-color: #71717a;
    --border-strong: #a1a1aa;
    --text-muted: #d4d4d8;
    --text-secondary: #e4e4e7;
}
html[data-contrast="high"] body {
    -webkit-font-smoothing: antialiased;
}
html[data-contrast="high"] .top-bar,
html[data-contrast="high"] .sos-page-header,
html[data-contrast="high"] .sos-card,
html[data-contrast="high"] .set-panel,
html[data-contrast="high"] .u-modal__box {
    border-width: 1.5px;
}

html[data-density="compact"] {
    --topbar-height: 3rem;
    --sidebar-icon-btn: 2rem;
}
html[data-density="compact"] .main-panel .content {
    padding-top: calc(var(--topbar-height) + 0.85rem);
}
html[data-density="compact"] .sos-page-header {
    padding: 0.75rem 0.875rem;
    margin-bottom: 0.875rem;
}
html[data-density="compact"] .sidebar .nav-link {
    height: 2rem;
    font-size: 0.8125rem;
}

html[data-reduce-motion="true"] *,
html[data-reduce-motion="true"] *::before,
html[data-reduce-motion="true"] *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

html[data-underline-links="true"] .main-panel a:not(.ni-btn):not(.sos-filterbar__btn):not(.quick-btn):not(.export-btn):not(.sb-search) {
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

html[data-large-targets="true"] .sidebar .nav-link,
html[data-large-targets="true"] .sb-theme__btn,
html[data-large-targets="true"] .ni-btn,
html[data-large-targets="true"] .sos-filterbar__btn,
html[data-large-targets="true"] .quick-btn {
    min-height: 2.75rem;
}

html[data-sticky-tables="true"] .dash-table thead th,
html[data-sticky-tables="true"] .audit-table thead th,
html[data-sticky-tables="true"] .req-table thead th,
html[data-sticky-tables="true"] table.sos-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.sidebar-footer {
    border-top: 1px solid var(--sidebar-border);
    padding: 0.5rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: stretch;
}

/* Compteur RSI invisible (JS auto-refresh conserve #countdown) */
.sidebar-footer--hidden {
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    opacity: 0;
    pointer-events: none;
}

/* Pied de page pleine largeur - ligne continue sous la sidebar (pas de décalage) */
.sos-footer {
    left: 0 !important;
    border-top: 1px solid var(--sidebar-border, var(--border-color));
    transition: none;
}

body.sidebar-collapsed .sos-footer {
    left: 0 !important;
}

.sidebar-footer__nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    width: 100%;
}

.sidebar-footer__nav .nav-item {
    width: 100%;
}

.sidebar-footer__nav .nav-link {
    margin: 0;
    justify-content: flex-start;
    width: 100%;
}

.sidebar .countdown-display {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--sidebar-muted);
    font-size: 0.75rem;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-lg);
}

.sidebar .countdown-display .lucide-icon {
    width: 0.875rem;
    height: 0.875rem;
    flex-shrink: 0;
}

/* Collapsed = rail icônes centré (LibreChat-like) */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-width-icon);
    transform: none;
    overflow: visible !important; /* sinon tooltip / focus ring → bande noire coupée */
}

body.sidebar-collapsed .sidebar-brand-name,
body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .sidebar-brand-sub,
body.sidebar-collapsed .sidebar .nav-link-text,
body.sidebar-collapsed .sidebar .nav-section-label span,
body.sidebar-collapsed .sidebar .countdown-unit,
body.sidebar-collapsed .sidebar .countdown-value,
body.sidebar-collapsed .sidebar-chrome__meta,
body.sidebar-collapsed .sidebar .topbar-role-pill,
body.sidebar-collapsed .sidebar .topbar-user-name,
body.sidebar-collapsed .sidebar .topbar-user-chevron,
body.sidebar-collapsed .sidebar .nav-group__chevron,
body.sidebar-collapsed .sb-user__text,
body.sidebar-collapsed .sb-user__go,
body.sidebar-collapsed .sb-user__logout span,
body.sidebar-collapsed .sb-theme__btn span {
    display: none !important;
}

body.sidebar-collapsed .sidebar .nav-section-label {
    display: none !important;
}

/* Logo MlfMonde : disparaît quand le rail est réduit */
body.sidebar-collapsed .sidebar-mlf {
    display: none !important;
}

/* Rail réduit : logo SOS en haut, avec air sous le bord (pas collé) */
body.sidebar-collapsed .sidebar-header {
    order: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0;
    padding: 1.75rem 0.35rem 0.85rem;
    margin-top: 0;
    min-height: 0;
    border-bottom: none;
    overflow: visible;
    flex-shrink: 0;
}

body.sidebar-collapsed .sidebar-collapse-btn {
    display: none !important;
}

body.sidebar-collapsed .sidebar-logo,
body.sidebar-collapsed .sidebar-logo.sidebar-logo--expand {
    width: var(--sidebar-icon-btn) !important;
    height: var(--sidebar-icon-btn) !important;
    max-width: var(--sidebar-icon-btn);
    margin: 0 0 0.85rem !important;
    cursor: pointer;
    border-radius: 0.4rem;
    box-shadow: none;
    outline: none;
    padding: 0;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

body.sidebar-collapsed .sidebar-logo:hover,
body.sidebar-collapsed .sidebar-logo:focus,
body.sidebar-collapsed .sidebar-logo:focus-visible {
    background: transparent;
    opacity: 0.92;
    box-shadow: none;
    outline: none;
}

body.sidebar-collapsed .sidebar-logo .sidebar-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}

body.sidebar-collapsed .sidebar-logo .lucide-icon,
body.sidebar-collapsed .sidebar-logo .sidebar-logo-icon {
    width: 0.9rem;
    height: 0.9rem;
}

/* Ligne sous le logo, puis la nav */
body.sidebar-collapsed .sidebar-header::before {
    display: none !important;
    content: none !important;
}

body.sidebar-collapsed .sidebar-header::after {
    content: "";
    display: block;
    width: 100%;
    height: 1px;
    background: var(--sidebar-border);
    flex-shrink: 0;
    margin: 0;
}

body.sidebar-collapsed .sidebar-nav {
    order: 1;
    flex: 1 1 auto;
    padding: 0.95rem 0 0.5rem;
    display: flex;
    justify-content: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 0;
}

body.sidebar-collapsed .sidebar-chrome {
    order: 2;
}

/* Pas de tooltip sur le logo réduit : clic = étendre, évite le « truc noir » */
body.sidebar-collapsed .sidebar-logo[data-tooltip]::after {
    display: none !important;
    content: none !important;
    opacity: 0 !important;
}

body.sidebar-collapsed .sidebar .nav {
    width: 100%;
    padding: 0;
    align-items: center;
    gap: 0.2rem;
}

body.sidebar-collapsed .sidebar .nav-item,
body.sidebar-collapsed .sidebar .nav-group {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 0;
}

body.sidebar-collapsed .sidebar .nav-link,
body.sidebar-collapsed .sidebar .nav-group__toggle {
    justify-content: center;
    align-items: center;
    padding: 0 !important;
    margin: 0;
    width: var(--sidebar-icon-btn);
    height: var(--sidebar-icon-btn);
    min-width: var(--sidebar-icon-btn);
    max-width: var(--sidebar-icon-btn);
    gap: 0;
    border-radius: var(--radius-lg);
}

body.sidebar-collapsed .sidebar .nav-link .lucide-icon,
body.sidebar-collapsed .sidebar .nav-group__toggle .lucide-icon {
    margin: 0;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

body.sidebar-collapsed .sidebar .nav-group__list {
    display: none !important;
}

/* Notif : icône + badge dans le rail */
body.sidebar-collapsed .sidebar .nav-item--notif,
body.sidebar-collapsed .sidebar .sidebar-nav-notif {
    display: flex;
    justify-content: center;
    width: 100%;
}

body.sidebar-collapsed .sidebar .notif-nav-btn {
    position: relative;
}

/* Chrome bas : colonne centrée, même axe que les icônes nav */
body.sidebar-collapsed .sidebar-chrome {
    align-items: center;
    padding: 0.5rem 0.35rem 0.65rem;
    gap: 0.45rem;
}

body.sidebar-collapsed .sb-theme {
    grid-template-columns: 1fr;
    width: var(--sidebar-icon-btn);
    padding: 0.15rem;
    gap: 0.15rem;
}

body.sidebar-collapsed .sb-theme__btn {
    min-height: calc(var(--sidebar-icon-btn) - 0.35rem);
    padding: 0.2rem 0;
    width: 100%;
}

body.sidebar-collapsed .sb-user {
    align-items: center;
    gap: 0.45rem;
}

body.sidebar-collapsed .sb-user__identity {
    width: var(--sidebar-icon-btn);
    height: var(--sidebar-icon-btn);
    padding: 0;
    margin: 0;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    background: transparent;
    border-color: transparent;
    pointer-events: auto;
}

body.sidebar-collapsed .sb-user__avatar,
body.sidebar-collapsed .sb-user__avatar--fallback,
body.sidebar-collapsed .sb-user__avatar-wrap.sos-avatar {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.45rem;
}

body.sidebar-collapsed .sb-user__logout {
    width: var(--sidebar-icon-btn);
    height: var(--sidebar-icon-btn);
    min-height: var(--sidebar-icon-btn);
    padding: 0;
    border-radius: var(--radius-lg);
}

body.sidebar-collapsed .sidebar-footer {
    display: none;
}

body.sidebar-collapsed .sidebar .countdown-display {
    display: none;
}

/* Tooltips to the right (LibreChat TooltipAnchor side="right") */
body.sidebar-collapsed .sidebar .nav-link[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 0.65rem);
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    padding: 0.35rem 0.55rem;
    border-radius: var(--radius);
    background: var(--text-primary);
    color: var(--surface-color);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 1200;
    box-shadow: var(--shadow-sm);
    transition: opacity 120ms ease, transform 120ms ease;
}

body.sidebar-collapsed .sidebar .nav-link[data-tooltip]:hover::after,
body.sidebar-collapsed .sidebar .nav-link[data-tooltip]:focus-visible::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

body.sidebar-collapsed .sb-user__identity[data-tooltip],
body.sidebar-collapsed .sb-user__logout[data-tooltip],
body.sidebar-collapsed .sidebar-collapse-btn[data-tooltip],
body.sidebar-collapsed .sidebar .countdown-display[data-tooltip] {
    position: relative;
}

body.sidebar-collapsed .sb-user__identity[data-tooltip]::after,
body.sidebar-collapsed .sb-user__logout[data-tooltip]::after,
body.sidebar-collapsed .sidebar-collapse-btn[data-tooltip]::after,
body.sidebar-collapsed .sidebar .countdown-display[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 0.65rem);
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    padding: 0.35rem 0.55rem;
    border-radius: var(--radius);
    background: var(--text-primary);
    color: var(--surface-color);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 1200;
    box-shadow: var(--shadow-sm);
    transition: opacity 120ms ease, transform 120ms ease;
}

body.sidebar-collapsed .sb-user__identity[data-tooltip]:hover::after,
body.sidebar-collapsed .sb-user__logout[data-tooltip]:hover::after,
body.sidebar-collapsed .sidebar-collapse-btn[data-tooltip]:hover::after,
body.sidebar-collapsed .sidebar .countdown-display[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

[data-theme="dark"] body.sidebar-collapsed .sidebar .nav-link[data-tooltip]::after,
[data-theme="dark"] body.sidebar-collapsed .sidebar-collapse-btn[data-tooltip]::after,
[data-theme="dark"] body.sidebar-collapsed .sidebar .countdown-display[data-tooltip]::after {
    background: #fafafa;
    color: #18181b;
}

/* Layout offsets - topbar uses left/right (pas width+margin) pour éviter
   la bande vide à droite du profil quand la scrollbar apparaît. */
.main-panel {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    transition: margin-left var(--t-sidebar), width var(--t-sidebar);
}

.sos-footer {
    left: 0 !important;
    transition: none;
}

body.sidebar-collapsed .main-panel {
    margin-left: var(--sidebar-width-icon);
    width: calc(100% - var(--sidebar-width-icon));
}

body.sidebar-collapsed .sos-footer {
    left: 0 !important;
}

/* -------------------------------------------------------------------------
   Topbar
   ---------------------------------------------------------------------- */
.top-bar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    width: auto;
    margin-left: 0;
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    /* Opaque = même couleur que le fond (plus de bande grise / verre) */
    background: var(--chrome-bg, var(--bg-color));
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: 1px solid var(--border-color);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem 0 0.75rem;
    gap: 0.75rem;
    box-shadow: none;
    transition: left var(--t-sidebar);
    box-sizing: border-box;
}

body.sidebar-collapsed .top-bar {
    left: var(--sidebar-width-icon);
    width: auto;
    margin-left: 0;
}

.top-bar-left,
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.top-bar-left {
    flex: 0 1 auto;
}

.top-bar-center {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    padding: 0 0.75rem;
    overflow: hidden;
}

.top-bar-page {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    max-width: 100%;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-bar-page__sep {
    color: var(--border-strong);
    font-weight: 500;
    flex-shrink: 0;
}

.top-bar-page__label {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-bar-right {
    margin-left: auto;
    flex-shrink: 0;
    padding-right: 0;
}

.top-bar-theme {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: auto;
    padding: 0;
    border-radius: 0;
    border: none;
    background: transparent;
    flex-shrink: 0;
    overflow: visible;
}

.top-bar-theme .theme-sos-switch,
.top-bar-theme .sos-switch {
    min-width: 0;
    min-height: 0;
    padding: 0;
}

.top-bar-brand {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0;
    min-width: 0;
}

.top-bar-title-prefix {
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-transform: none;
    color: var(--text-primary);
    line-height: 1.25;
}

.top-bar-title {
    display: none; /* legacy - titre porté par .sos-page-header */
}

.sidebar-toggle-btn,
.theme-toggle {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
}

.sidebar-toggle-btn:hover,
.theme-toggle:hover {
    background: var(--bg-color);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.sidebar-toggle-btn .lucide-icon,
.theme-toggle .lucide-icon {
    width: 1.125rem;
    height: 1.125rem;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.topbar-user-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--border-color);
    position: relative;
}

.topbar-role-pill {
    display: inline-flex;
    align-items: flex-start;
    border-radius: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    line-height: 1.25;
    padding: 0.3rem 0.5rem;
    max-width: 100%;
    white-space: normal;
}

.topbar-user-menu {
    position: relative;
}

.topbar-user-card {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.2rem 0.35rem 0.2rem 0.2rem;
    margin: 0;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
    max-width: 14rem;
}

.topbar-user-card:hover,
.topbar-user-section.is-open .topbar-user-card {
    background: var(--bg-color);
    border-color: var(--border-color);
}

.topbar-user-name {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: min(16rem, 28vw);
}

.topbar-user-chevron {
    width: 0.875rem !important;
    height: 0.875rem !important;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.12s ease;
}

.topbar-user-section.is-open .topbar-user-chevron {
    transform: rotate(180deg);
}

.topbar-avatar-img,
.topbar-avatar-fallback {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    flex-shrink: 0;
}

.topbar-avatar-img {
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.topbar-avatar-fallback {
    background: #dc2626;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.topbar-user-dropdown {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    min-width: 11.5rem;
    padding: 0.3rem;
    background: var(--surface-color, #fff);
    border: 1px solid var(--border-strong, #e4e4e7);
    border-radius: 0.55rem;
    box-shadow:
        0 10px 15px -3px rgba(0, 0, 0, 0.08),
        0 4px 6px -4px rgba(0, 0, 0, 0.06);
    z-index: 1300;
}

.topbar-user-dropdown[hidden] {
    display: none !important;
}

.topbar-user-dropdown__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: none;
    border-radius: 0.4rem;
    background: transparent;
    color: var(--text-primary, #18181b);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    text-decoration: none;
    text-align: left;
    cursor: pointer;
}

.topbar-user-dropdown__item:hover {
    background: var(--bg-color, #f4f4f5);
}

.topbar-user-dropdown__item .lucide-icon {
    width: 0.95rem !important;
    height: 0.95rem !important;
    color: var(--text-muted, #71717a);
    flex-shrink: 0;
}

.topbar-user-dropdown__item--danger {
    color: #dc2626;
}

.topbar-user-dropdown__item--danger .lucide-icon {
    color: #dc2626;
}

.topbar-user-dropdown__item--danger:hover {
    background: #fef2f2;
}

[data-theme="dark"] .topbar-user-dropdown {
    background: var(--surface-elevated, var(--surface-color));
    border-color: var(--border-strong);
}

[data-theme="dark"] .topbar-user-dropdown__item:hover {
    background: var(--row-hover-bg);
}

[data-theme="dark"] .topbar-user-dropdown__item--danger:hover {
    background: rgba(220, 38, 38, 0.12);
}

/* -------------------------------------------------------------------------
   Content inset
   ---------------------------------------------------------------------- */
.main-panel {
    min-height: 100vh;
    background: transparent;
    background-color: transparent;
}

.main-panel .content {
    padding: calc(var(--topbar-height) + 1.25rem) 1.5rem 4rem;
    position: relative;
    z-index: 1;
    background: transparent;
}

.bg-pattern-app,
.bg-pattern-page,
.bg-pattern-dash,
.bg-pattern {
    display: none !important;
}

/* -------------------------------------------------------------------------
   Page header / cards / tables (shared)
   ---------------------------------------------------------------------- */
.sos-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xs);
    text-align: left;
}

/* Legacy page-header → même cadre blanc */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xs);
    text-align: left;
}

.page-header > div:first-child,
.sos-page-header__left {
    text-align: left;
}

.sos-page-header__left {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 0;
}

/* Icône titre page - carré rouge brand (28×28, icône blanche 16px) */
.sos-page-header .h-icon,
.page-header .h-icon {
    width: 1.75rem;
    height: 1.75rem;
    background: #dc2626;
    border-radius: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
}

.sos-page-header .h-icon .lucide-icon,
.sos-page-header .h-icon i,
.page-header .h-icon .lucide-icon,
.page-header .h-icon i,
.page-header h1 .h-icon .lucide-icon,
.page-header h1 .h-icon i {
    width: 1rem;
    height: 1rem;
    color: #fff;
    stroke: #fff;
    stroke-width: 1.75;
}

.sos-page-header .h-icon--logo,
.page-header .h-icon--logo {
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 0.2rem;
    overflow: hidden;
}
.sos-page-header .h-icon__logo,
.page-header .h-icon__logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

[data-theme="dark"] .sos-page-header .h-icon,
[data-theme="dark"] .page-header .h-icon {
    background: #ef4444;
}

/* Icônes UI pages (labels, cards, stats) - alignées sidebar */
.sos-ui-icon,
.sos-ui-icon .lucide-icon,
i.sos-ui-icon[data-lucide] {
    width: 1.25rem !important;
    height: 1.25rem !important;
    flex-shrink: 0;
    stroke-width: 1.75;
}

.sos-page-header__titles h1,
.page-header h1 {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0 0 0.2rem;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sos-page-header__titles p,
.page-header p {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.sos-page-header__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Pages full-bleed left (pas centrées) */
.page-wrap,
.u-wrap,
.req-wrap,
.estab-wrap,
.dsi-wrap,
.ann-wrap {
    max-width: none !important;
    width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
    text-align: left;
}

.main-panel .content {
    padding-bottom: calc(var(--footer-height, 2.75rem) + 2rem);
}

.sos-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xs);
    overflow: visible;
}

.sos-card__head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--thead-bg);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-primary);
}

.sos-card__head .lucide-icon {
    width: 0.9375rem;
    height: 0.9375rem;
    color: var(--primary);
}

.sos-card__body {
    padding: 1rem;
}

.sos-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
    gap: 0.5rem;
}

.sos-empty .lucide-icon {
    width: 2rem;
    height: 2rem;
    color: var(--text-muted);
}

.sos-empty p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Data tables */
.table,
table.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface-color);
}

.table thead th,
table.data-table thead th {
    background: var(--thead-bg);
    color: var(--thead-text);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: left;
    padding: 0.7rem 0.875rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table tbody td,
table.data-table tbody td {
    padding: 0.75rem 0.875rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-primary);
    vertical-align: middle;
}

.table tbody tr:hover,
table.data-table tbody tr:hover {
    background: var(--row-hover-bg);
}

/* Status badges */
.badge-status,
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.2;
}

/* Dark mode surfaces for legacy inline whites */
[data-theme="dark"] .sos-toast {
    background: var(--surface-color);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .f-card,
[data-theme="dark"] .settings-card,
[data-theme="dark"] .kpi-card,
[data-theme="dark"] .chart-card,
[data-theme="dark"] .dash-card,
[data-theme="dark"] .sos-page-header,
[data-theme="dark"] .page-header {
    background: var(--surface-color);
    border-color: var(--border-color);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--bg-color);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

/* -------------------------------------------------------------------------
   Mobile
   ---------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .sidebar {
        width: var(--sidebar-width);
        height: 100vh;
        height: 100dvh;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform var(--t);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
    }

    body.sidebar-collapsed .sidebar.open {
        transform: translateX(0);
    }

    .main-panel,
    body.sidebar-collapsed .main-panel {
        margin-left: 0;
        width: 100%;
    }

    .top-bar,
    body.sidebar-collapsed .top-bar {
        left: 0;
        right: 0;
        width: auto;
        margin-left: 0;
    }

    .sos-footer,
    body.sidebar-collapsed .sos-footer {
        left: 0 !important;
    }

    .sidebar-toggle.mobile-only {
        display: inline-flex !important;
    }

    .sidebar-mobile-fab.mobile-only,
    .sidebar-mobile-fab {
        display: inline-flex !important;
        top: max(0.75rem, var(--safe-top));
        left: max(0.75rem, var(--safe-left));
        width: var(--fab-size);
        height: var(--fab-size);
        min-width: 44px;
        min-height: 44px;
    }

    .sidebar-collapse-btn,
    .sidebar-toggle-btn {
        display: none;
    }

    body.shell-sidebar-only .main-panel .content {
        padding-top: var(--mobile-chrome-offset) !important;
        padding-right: max(1rem, var(--safe-right)) !important;
        padding-bottom: max(2rem, calc(var(--safe-bottom) + 1.25rem)) !important;
        padding-left: max(1rem, var(--safe-left)) !important;
    }

    .main-panel .content {
        padding: calc(var(--topbar-height) + 1rem + var(--safe-top)) max(1rem, var(--safe-right)) max(4rem, calc(var(--safe-bottom) + 2rem)) max(1rem, var(--safe-left));
    }

    .sidebar {
        width: min(18rem, calc(100vw - 3rem));
        padding-top: var(--safe-top);
        padding-bottom: var(--safe-bottom);
        z-index: 1210;
    }

    body.sidebar-drawer-open {
        overflow: hidden;
        touch-action: none;
    }

    .sidebar-overlay.is-visible,
    .sidebar.open ~ .sidebar-overlay {
        opacity: 1;
        visibility: visible;
        transition: opacity 0.2s ease, visibility 0s;
        z-index: 1200;
    }

    .top-bar-brand .top-bar-title-prefix {
        max-width: 7.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar-user-name {
        display: none;
    }
}

@media (max-width: 640px) {
    .top-bar-center {
        display: none;
    }
}

/* Skeleton nav (loading feel optional) */
.sos-nav-skeleton {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.5rem;
}

.sos-nav-skeleton__row {
    height: 2rem;
    border-radius: var(--radius);
    background: linear-gradient(90deg, var(--sidebar-accent) 25%, var(--border-color) 50%, var(--sidebar-accent) 75%);
    background-size: 200% 100%;
}

/* =========================================================================
   SOS Skeleton - charte rouge / surfaces / boutons
   ========================================================================= */
@keyframes sos-skel-shine {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.sos-skel {
    display: block;
    border-radius: 0.5rem;
    background: linear-gradient(
        90deg,
        #f4f4f5 0%,
        #e4e4e7 40%,
        #f4f4f5 80%
    );
    background-size: 200% 100%;
    animation: sos-skel-shine 1.35s ease-in-out infinite;
    color: transparent !important;
    pointer-events: none;
    user-select: none;
}

[data-theme="dark"] .sos-skel {
    background: linear-gradient(90deg, #27272a 0%, #3f3f46 40%, #27272a 80%);
    background-size: 200% 100%;
}

.sos-skel--text { height: 0.75rem; width: 100%; max-width: 12rem; }
.sos-skel--text-sm { height: 0.625rem; width: 100%; max-width: 8rem; }
.sos-skel--title { height: 1.25rem; width: 100%; max-width: 16rem; border-radius: 0.4rem; }
.sos-skel--avatar { width: 2.5rem; height: 2.5rem; border-radius: 0.5rem; flex-shrink: 0; }
.sos-skel--icon {
    width: 1.75rem; height: 1.75rem; border-radius: 0.4rem; flex-shrink: 0;
    background: linear-gradient(90deg, #fecaca 0%, #fee2e2 45%, #fecaca 90%);
    background-size: 200% 100%;
}
[data-theme="dark"] .sos-skel--icon {
    background: linear-gradient(90deg, #7f1d1d 0%, #991b1b 45%, #7f1d1d 90%);
    background-size: 200% 100%;
}
.sos-skel--btn {
    height: 2.25rem;
    width: 7.5rem;
    border-radius: 0.375rem;
    background: linear-gradient(90deg, #fecaca 0%, #fca5a5 40%, #fecaca 80%);
    background-size: 200% 100%;
}
.sos-skel--btn-ghost {
    height: 2.25rem;
    width: 6.5rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border-color, #e4e4e7);
    background: linear-gradient(90deg, #fafafa 0%, #f4f4f5 40%, #fafafa 80%);
    background-size: 200% 100%;
}
.sos-skel--input { height: 2.375rem; width: 100%; border-radius: 0.375rem; }
.sos-skel--card {
    background: var(--surface-color, #fff);
    border: 1px solid var(--border-color, #e4e4e7);
    border-radius: var(--radius-xl, 0.75rem);
    padding: 1rem 1.125rem;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(0,0,0,0.04));
}
[data-theme="dark"] .sos-skel--card { background: var(--surface-color); border-color: var(--border-strong); }
.sos-skel--kpi { min-height: 6.5rem; }
.sos-skel--chart { height: 14rem; width: 100%; border-radius: 0.5rem; }
.sos-skel--row { height: 2.75rem; width: 100%; border-radius: 0.375rem; margin-bottom: 0.5rem; }

.sos-skel-page {
    display: none;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    padding: 0.25rem 0 2rem;
}
body.sos-booting .sos-skel-page,
html.sos-booting .sos-skel-page { display: flex; }
body.sos-booting .sos-page-live,
html.sos-booting .sos-page-live { display: none !important; }

.sos-skel-page__header {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
    flex-wrap: wrap; margin-bottom: 0.25rem;
}
.sos-skel-page__header-left { display: flex; align-items: center; gap: 0.75rem; }
.sos-skel-page__kpis {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 0.75rem;
}
.sos-skel-page__grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 1rem;
}
@media (max-width: 900px) {
    .sos-skel-page__grid { grid-template-columns: 1fr; }
}
.sos-skel-page__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

html[data-reduce-motion="true"] .sos-skel,
html[data-reduce-motion="true"] .sos-skel--icon,
html[data-reduce-motion="true"] .sos-skel--btn,
html[data-reduce-motion="true"] .sos-skel--btn-ghost {
    animation: none;
}

/* =========================================================================
   SOS Switch - MD3-inspired (rouge SOS)
   ========================================================================= */
.sos-switch {
    --sos-sw-ease: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 48px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.sos-switch[aria-disabled="true"],
.sos-switch:has(.sos-switch__input:disabled) {
    cursor: not-allowed;
    opacity: 0.5;
}

.sos-switch__input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sos-switch__track {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 52px;
    height: 32px;
    border-radius: 999px;
    border: 2px solid var(--border-strong);
    background: var(--bg-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    flex-shrink: 0;
}

.sos-switch--sm .sos-switch__track {
    width: 40px;
    height: 24px;
}

.sos-switch__thumb {
    position: absolute;
    top: 50%;
    left: 2px;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border-radius: 999px;
    background: var(--text-secondary);
    color: var(--surface-color);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition:
        transform 0.3s var(--sos-sw-ease),
        width 0.3s var(--sos-sw-ease),
        height 0.3s var(--sos-sw-ease),
        background-color 0.3s ease,
        color 0.3s ease,
        left 0.3s var(--sos-sw-ease);
}

.sos-switch--sm .sos-switch__thumb {
    width: 12px;
    height: 12px;
    left: 2px;
}

.sos-switch__icon {
    position: absolute;
    width: 0.875rem;
    height: 0.875rem;
    stroke-width: 3;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.sos-switch--sm .sos-switch__icon {
    width: 0.625rem;
    height: 0.625rem;
}

.sos-switch__icon--on {
    opacity: 0;
    transform: scale(0.5) rotate(-45deg);
    color: var(--primary);
}

.sos-switch__icon--off {
    opacity: 1;
    transform: scale(1);
    color: var(--surface-color);
}

/* Checked - rouge SOS (défaut / thème) */
.sos-switch__input:checked + .sos-switch__track {
    background: var(--primary);
    border-color: var(--primary);
}

.sos-switch__input:checked + .sos-switch__track .sos-switch__thumb {
    left: calc(100% - 2px);
    transform: translate(-100%, -50%);
    width: 24px;
    height: 24px;
    background: #fff;
    color: var(--primary);
}

.sos-switch--sm .sos-switch__input:checked + .sos-switch__track .sos-switch__thumb {
    width: 16px;
    height: 16px;
}

.sos-switch__input:checked + .sos-switch__track .sos-switch__icon--on {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.sos-switch__input:checked + .sos-switch__track .sos-switch__icon--off {
    opacity: 0;
    transform: scale(0.5) rotate(45deg);
}

/* SOS live status - actif = vert, inactif = rouge */
.sos-switch--status .sos-switch__track {
    background: #fef2f2;
    border-color: #dc2626;
}

.sos-switch--status .sos-switch__thumb {
    background: #dc2626;
    color: #fff;
}

.sos-switch--status .sos-switch__icon--off {
    color: #fff;
}

.sos-switch--status .sos-switch__icon--on {
    color: #16a34a;
}

.sos-switch--status .sos-switch__input:checked + .sos-switch__track {
    background: #16a34a;
    border-color: #16a34a;
}

.sos-switch--status .sos-switch__input:checked + .sos-switch__track .sos-switch__thumb {
    background: #fff;
    color: #16a34a;
}

.sos-switch--status:hover:not([aria-disabled="true"]) .sos-switch__track::after {
    background: #dc2626;
}

.sos-switch--status:has(.sos-switch__input:checked):hover:not([aria-disabled="true"]) .sos-switch__track::after {
    background: #16a34a;
}

.sos-switch--status .sos-switch__input:focus-visible + .sos-switch__track {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.25);
}

.sos-switch--status .sos-switch__input:checked:focus-visible + .sos-switch__track {
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.28);
}

/* Press stretch */
.sos-switch:active:not([aria-disabled="true"]) .sos-switch__thumb {
    width: 28px;
    height: 28px;
}

.sos-switch--sm:active:not([aria-disabled="true"]) .sos-switch__thumb {
    width: 20px;
    height: 20px;
}

/* Focus */
.sos-switch__input:focus-visible + .sos-switch__track {
    box-shadow: 0 0 0 3px var(--sidebar-ring, rgba(220, 38, 38, 0.35));
}

/* Hover halo */
.sos-switch:hover:not([aria-disabled="true"]) .sos-switch__track::after {
    content: "";
    position: absolute;
    inset: -8px;
    border-radius: 999px;
    background: var(--primary);
    opacity: 0.06;
    pointer-events: none;
}

[data-theme="dark"] .sos-switch__thumb {
    background: #a1a1aa;
}

[data-theme="dark"] .sos-switch__input:checked + .sos-switch__track .sos-switch__thumb {
    background: #fff;
}

/* =========================================================================
   PWA install modal - charte SOS
   ========================================================================= */
.sos-pwa-modal {
    max-width: min(22rem, calc(100vw - 1.5rem - var(--safe-left, 0px) - var(--safe-right, 0px)));
    width: 100%;
    box-sizing: border-box;
}
#sosPwaInstallModal.sos-modal-backdrop {
    z-index: 13100 !important;
    padding: max(1rem, var(--safe-top, 0px)) max(1rem, var(--safe-right, 0px)) max(1rem, var(--safe-bottom, 0px)) max(1rem, var(--safe-left, 0px));
    align-items: center;
}

.sos-pwa-modal__app {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 0.85rem;
}

.sos-pwa-modal__icon {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 0;
    object-fit: contain;
    background: transparent;
    border: none;
    box-shadow: none;
    flex-shrink: 0;
    display: block;
}

.sos-pwa-modal__meta { min-width: 0; }
.sos-pwa-modal__name {
    margin: 0;
    font-family: 'Outfit', Inter, sans-serif;
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.sos-pwa-modal__host {
    margin: 0.2rem 0 0;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.sos-pwa-modal__host .lucide-icon {
    width: 0.85rem;
    height: 0.85rem;
    color: #dc2626;
    flex-shrink: 0;
}

.sos-pwa-modal__link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0.85rem 0 0.25rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid #e4e4e7;
    border-radius: 0.5rem;
    background: #fafafa;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.sos-pwa-modal__link:hover {
    border-color: #fecaca;
    background: #fef2f2;
}
.sos-pwa-modal__link-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.4rem;
    background: #fff;
    border: 1px solid #e4e4e7;
    color: #71717a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sos-pwa-modal__link-icon .lucide-icon { width: 1rem; height: 1rem; }
.sos-pwa-modal__link-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 0.1rem; }
.sos-pwa-modal__link-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #18181b;
}
.sos-pwa-modal__link-url {
    font-size: 0.6875rem;
    font-weight: 500;
    color: #71717a;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sos-pwa-modal__link-ext {
    width: 0.875rem;
    height: 0.875rem;
    color: #a1a1aa;
    flex-shrink: 0;
}
[data-theme="dark"] .sos-pwa-modal__link {
    background: #18181b;
    border-color: #3f3f46;
}
[data-theme="dark"] .sos-pwa-modal__link:hover {
    background: #27272a;
    border-color: #7f1d1d;
}
[data-theme="dark"] .sos-pwa-modal__link-icon {
    background: #09090b;
    border-color: #3f3f46;
    color: #a1a1aa;
}
[data-theme="dark"] .sos-pwa-modal__link-label { color: #fafafa; }
[data-theme="dark"] .sos-pwa-modal__link-url { color: #a1a1aa; }

.sos-pwa-modal__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.45rem 0.95rem;
    border-radius: 0.45rem;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 650;
    cursor: pointer;
    border: 1px solid transparent;
}
.sos-pwa-modal__btn .lucide-icon { width: 0.95rem; height: 0.95rem; }
.sos-pwa-modal__btn--ghost {
    background: var(--surface-color);
    border-color: var(--border-color);
    color: var(--text-primary);
}
.sos-pwa-modal__btn--ghost:hover { border-color: #a1a1aa; }
.sos-pwa-modal__btn--primary {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}
.sos-pwa-modal__btn--primary:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

/* =========================================================================
   Dialog / Modal standard (B6) - shadcn-like
   ========================================================================= */
.sos-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 13000; /* au-dessus sidebar / chrome, sous command palette */
    background: rgba(9, 9, 11, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 150ms ease, visibility 150ms ease;
}

.sos-modal-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

body.sos-modal-open {
    overflow: hidden;
}

/* Overlay plein viewport : au-dessus sidebar / chrome (sos-overlay-above-sidebar) */
.u-modal,
.modal-overlay,
.sos-modal-backdrop {
    position: fixed !important;
    inset: 0 !important;
    z-index: 13000 !important;
}
/* Alertes (succès/erreur/confirm) au-dessus des fiches détails */
#customConfirmModal.modal-overlay,
#customConfirmModal.modal-overlay.visible {
    z-index: 14600 !important;
}
.u-modal.open,
.modal-overlay.open,
.modal-overlay.visible,
.sos-modal-backdrop.is-open {
    display: flex !important;
}
body.sos-modal-open .sidebar,
body.sos-modal-open .sidebar-mobile-fab {
    z-index: 1000 !important;
}

.sos-modal__foot .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}


.sos-modal {
    width: 100%;
    max-width: 28rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.sos-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.125rem;
    border-bottom: 1px solid var(--border-color);
}

.sos-modal__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.sos-modal__title .lucide-icon {
    width: 1.05rem;
    height: 1.05rem;
    color: #dc2626;
    flex-shrink: 0;
}

.sos-modal__msg {
    margin: 0;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.sos-modal__msg + .sos-modal__msg {
    margin-top: 0.65rem;
}

.sos-modal__msg .lucide-icon {
    width: 0.95rem;
    height: 0.95rem;
    color: #dc2626;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.sos-modal__msg--muted {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.sos-modal__msg--muted .lucide-icon {
    color: var(--text-muted);
}

.sos-modal__msg code {
    font-size: 0.78em;
    padding: 0.05em 0.3em;
    border-radius: 0.25rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
}

.sos-modal__body {
    padding: 1.125rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.sos-modal__foot {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.875rem 1.125rem;
    border-top: 1px solid var(--border-color);
    background: var(--thead-bg);
}

.sos-modal__close {
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sos-modal__close:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

/* =========================================================================
   Toast - Sonner / shadcn style (sobre, bas-droite)
   ========================================================================= */
.sos-toast-stack {
    position: fixed;
    bottom: calc(var(--footer-height, 2.75rem) + 0.75rem + var(--safe-bottom, 0px));
    right: max(1rem, var(--safe-right, 0px));
    left: auto;
    z-index: 4000;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    width: min(22rem, calc(100vw - 2rem - var(--safe-left, 0px) - var(--safe-right, 0px)));
    max-width: calc(100vw - 2rem);
    pointer-events: none;
    box-sizing: border-box;
}

.sos-toast {
    pointer-events: auto;
    position: relative;
    top: auto !important;
    right: auto !important;
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.75rem 0.75rem 0.75rem 0.875rem;
    background: var(--surface-color, #fff);
    border: 1px solid var(--border-color, #e4e4e7);
    border-radius: 0.5rem;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 4px 12px rgba(0, 0, 0, 0.06);
    color: var(--text-primary, #18181b);
    animation: sosToastIn 0.22s ease-out;
}

.sos-toast.sos-toast--exiting,
.sos-toast--exiting {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

@keyframes sosToastIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.sos-toast__glyph {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--bg-color, #f4f4f5);
    color: var(--text-secondary, #52525b);
}

.sos-toast__glyph i,
.sos-toast__glyph .lucide-icon {
    width: 0.875rem;
    height: 0.875rem;
}

.sos-toast--success .sos-toast__glyph {
    background: #ecfdf5;
    color: #15803d;
}

.sos-toast--danger .sos-toast__glyph,
.sos-toast--error .sos-toast__glyph {
    background: #fef2f2;
    color: #dc2626;
}

.sos-toast--warning .sos-toast__glyph {
    background: #fffbeb;
    color: #b45309;
}

.sos-toast--info .sos-toast__glyph {
    background: #eff6ff;
    color: #2563eb;
}

.sos-toast__msg,
.sos-toast__text,
.sos-toast__body {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-primary, #18181b);
}

.sos-toast__dismiss,
.sos-toast__close {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 0.375rem;
    background: transparent;
    color: var(--text-muted, #a1a1aa);
    cursor: pointer;
    padding: 0;
}

.sos-toast__dismiss:hover,
.sos-toast__close:hover {
    background: var(--bg-color, #f4f4f5);
    color: var(--text-primary, #18181b);
}

.sos-toast__dismiss i,
.sos-toast__close i {
    width: 0.875rem;
    height: 0.875rem;
}

/* pas de barre colorée type “IA” */
.sos-toast--success,
.sos-toast--danger,
.sos-toast--error,
.sos-toast--info,
.sos-toast--warning {
    border-left: 1px solid var(--border-color, #e4e4e7) !important;
}

[data-theme="dark"] .sos-toast {
    background: #18181b;
    border-color: #27272a;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

/* =========================================================================
   Selects - Untitled UI NativeSelect → SOS (ring inset + chevron + brand focus)
   Réf. /opt/sos-design-refs/untitled-ui/components/base/select/select-native.tsx
   ========================================================================= */
select,
select.form-control,
select.u-input,
select.filter-input,
select.f-input,
select.sos-select,
.sos-select,
.purge-card__actions select {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-color: var(--surface-color, #fff) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2371717a' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.7rem center !important;
    background-size: 1rem !important;
    padding: 0.5rem 2.35rem 0.5rem 0.75rem !important;
    border: none !important;
    border-radius: 0.5rem !important; /* rounded-lg */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important; /* shadow-xs */
    outline: 1px solid var(--border-strong, #d4d4d8) !important;
    outline-offset: -1px !important; /* ring-inset */
    color: var(--text-primary, #18181b) !important;
    font-size: 0.8125rem !important;
    font-family: 'Inter', sans-serif !important;
    font-weight: 500 !important;
    min-height: 2.375rem;
    line-height: 1.25;
    cursor: pointer;
    transition: outline-color 0.1s ease, box-shadow 0.1s ease;
}

select:hover,
select.form-control:hover,
select.u-input:hover {
    outline-color: #a1a1aa !important;
}

select:focus,
select.form-control:focus,
select.u-input:focus,
select.filter-input:focus,
select.f-input:focus,
select.sos-select:focus,
.purge-card__actions select:focus {
    outline: 1px solid #a1a1aa !important;
    outline-offset: -1px !important;
    box-shadow: none !important;
}

[data-theme="dark"] select,
[data-theme="dark"] select.form-control,
[data-theme="dark"] select.u-input,
[data-theme="dark"] .purge-card__actions select {
    background-color: #09090b !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23a1a1aa' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") !important;
    outline-color: #3f3f46 !important;
    color: #fafafa !important;
    box-shadow: none !important;
}

/* =========================================================================
   Custom dropdown (.sos-dd) - remplace le popup OS non stylable
   Réf. Untitled UI Select / shadcn Select
   ========================================================================= */
select.sos-dd__native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    appearance: none !important;
    pointer-events: none !important;
    opacity: 0 !important;
}

.sos-dd {
    position: relative;
    width: 100%;
    font-family: 'Inter', sans-serif;
}

.sos-dd__trigger {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    min-height: 2.5rem;
    padding: 0.45rem 0.7rem 0.45rem 0.65rem;
    border: none;
    border-radius: 0.5rem;
    background: var(--surface-color, #fff);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    outline: 1px solid var(--border-strong, #d4d4d8);
    outline-offset: -1px;
    color: var(--text-primary, #18181b);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: outline-color 0.1s ease, box-shadow 0.1s ease;
}

.sos-dd__trigger:hover {
    outline-color: #a1a1aa;
}

.sos-dd__trigger:focus,
.sos-dd__trigger:focus-visible,
.sos-dd--open .sos-dd__trigger {
    outline: 1px solid #a1a1aa;
    outline-offset: -1px;
    box-shadow: none;
}

.sos-dd__trigger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sos-dd__value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sos-dd__chevron {
    width: 1rem !important;
    height: 1rem !important;
    color: #71717a;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.sos-dd--open .sos-dd__chevron {
    transform: rotate(180deg);
}

/* Variante compacte (toolbar / batch / filtres) */
.sos-dd--sm {
    width: auto;
    min-width: 12rem;
}

.sos-dd--sm .sos-dd__trigger {
    min-height: 2rem;
    padding: 0.3rem 0.55rem;
    font-size: 0.78125rem;
}

input[type="date"].sos-date::-webkit-calendar-picker-indicator,
input[type="date"].rc-date::-webkit-calendar-picker-indicator,
input[type="date"].sos-filterbar__control::-webkit-calendar-picker-indicator,
.sos-filterbar__control[type="date"]::-webkit-calendar-picker-indicator {
    display: none;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Date inputs - même langage visuel que .sos-dd__trigger */
input[type="date"].sos-date,
input[type="date"].rc-date,
input[type="date"].sos-filterbar__control,
.sos-filterbar__control[type="date"] {
    display: inline-flex;
    align-items: center;
    min-height: 2.5rem;
    padding: 0.45rem 0.7rem;
    border: none;
    border-radius: 0.5rem;
    background: var(--surface-color, #fff);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    outline: 1px solid var(--border-strong, #d4d4d8);
    outline-offset: -1px;
    color: var(--text-primary, #18181b);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    color-scheme: light;
    cursor: pointer;
    transition: outline-color 0.1s ease, box-shadow 0.1s ease;
}

input[type="date"].rc-date,
input[type="date"].sos-date--sm {
    min-height: 2rem;
    padding: 0.3rem 0.55rem;
    font-size: 0.78125rem;
}

input[type="date"].sos-date:hover,
input[type="date"].rc-date:hover,
input[type="date"].sos-filterbar__control:hover,
.sos-filterbar__control[type="date"]:hover {
    outline-color: #a1a1aa;
}

input[type="date"].sos-date:focus,
input[type="date"].rc-date:focus,
input[type="date"].sos-filterbar__control:focus,
.sos-filterbar__control[type="date"]:focus {
    outline: 1px solid #a1a1aa;
    outline-offset: -1px;
    box-shadow: none;
}

[data-theme="dark"] input[type="date"].sos-date,
[data-theme="dark"] input[type="date"].rc-date,
[data-theme="dark"] input[type="date"].sos-filterbar__control,
[data-theme="dark"] .sos-filterbar__control[type="date"] {
    background: #18181b;
    color: #fafafa;
    outline-color: #3f3f46;
    color-scheme: dark;
    box-shadow: none;
}

[data-theme="dark"] input[type="date"].sos-date:hover,
[data-theme="dark"] input[type="date"].rc-date:hover,
[data-theme="dark"] input[type="date"].sos-filterbar__control:hover,
[data-theme="dark"] .sos-filterbar__control[type="date"]:hover,
[data-theme="dark"] input[type="date"].sos-date:focus,
[data-theme="dark"] input[type="date"].rc-date:focus,
[data-theme="dark"] input[type="date"].sos-filterbar__control:focus,
[data-theme="dark"] .sos-filterbar__control[type="date"]:focus {
    outline-color: #71717a;
}

/* -------------------------------------------------------------------------
   SOS DatePicker - dropdown calendrier moderne (remplace le picker natif)
   ---------------------------------------------------------------------- */
.sos-dp {
    position: relative;
    display: inline-flex;
    width: 100%;
    min-width: 0;
    vertical-align: middle;
}

.sos-dp__native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    clip: rect(0, 0, 0, 0) !important;
}

.sos-dp__trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    min-height: 2.5rem;
    padding: 0.4rem 0.65rem;
    margin: 0;
    border: none;
    border-radius: 0.5rem;
    background: var(--surface-color, #fff);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    outline: 1px solid var(--border-strong, #d4d4d8);
    outline-offset: -1px;
    color: var(--text-primary, #18181b);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: outline-color 0.1s ease, box-shadow 0.1s ease;
}

.sos-dp--sm .sos-dp__trigger {
    min-height: 2rem;
    padding: 0.28rem 0.5rem;
    font-size: 0.78125rem;
}

.sos-dp__trigger:hover {
    outline-color: #a1a1aa;
}

.sos-dp--open .sos-dp__trigger,
.sos-dp__trigger:focus-visible {
    outline-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
}

.sos-dp__icon {
    width: 0.95rem;
    height: 0.95rem;
    color: #dc2626;
    flex-shrink: 0;
}

.sos-dp__value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.sos-dp__value.is-placeholder {
    color: #a1a1aa;
    font-weight: 450;
}

.sos-dp__chevron {
    width: 0.9rem;
    height: 0.9rem;
    color: #a1a1aa;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.sos-dp--open .sos-dp__chevron {
    transform: rotate(180deg);
    color: #dc2626;
}

.sos-dp__panel {
    position: fixed;
    z-index: 13500; /* date panel: au-dessus modals */
    width: 18rem;
    padding: 0.65rem;
    border-radius: 0.75rem;
    background: #fff;
    border: 1px solid #e4e4e7;
    box-shadow:
        0 18px 40px rgba(0, 0, 0, 0.14),
        0 4px 10px rgba(0, 0, 0, 0.06);
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
    pointer-events: none;
    transition: opacity 120ms ease, transform 120ms ease;
}

.sos-dp__panel--open {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.sos-dp__head {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.55rem;
}

.sos-dp__nav,
.sos-dp__month-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    border: 1px solid transparent;
    background: transparent;
    color: #3f3f46;
    cursor: pointer;
    font-family: inherit;
    border-radius: 0.45rem;
}

.sos-dp__nav {
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
}

.sos-dp__nav:hover {
    background: #f4f4f5;
    border-color: #e4e4e7;
}

.sos-dp__nav .lucide-icon {
    width: 1rem;
    height: 1rem;
}

.sos-dp__month-btn {
    flex: 1;
    gap: 0.3rem;
    min-height: 2rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #18181b;
}

.sos-dp__month-btn:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.sos-dp__month-btn .lucide-icon {
    width: 0.85rem;
    height: 0.85rem;
    color: #a1a1aa;
}

.sos-dp__month-label {
    text-transform: capitalize;
}

.sos-dp__grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.15rem;
    margin-bottom: 0.45rem;
}

.sos-dp__dow {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 1.65rem;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #a1a1aa;
}

.sos-dp__day {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    margin: 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 0.45rem;
    background: transparent;
    color: #18181b;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

.sos-dp__day:hover {
    background: #f4f4f5;
    border-color: #e4e4e7;
}

.sos-dp__day.is-muted {
    color: #d4d4d8;
    font-weight: 500;
}

.sos-dp__day.is-today:not(.is-selected) {
    border-color: #fecaca;
    color: #dc2626;
}

.sos-dp__day.is-selected {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(220, 38, 38, 0.35);
}

.sos-dp__day.is-selected:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.sos-dp__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-top: 0.45rem;
    border-top: 1px solid #f4f4f5;
}

.sos-dp__link {
    margin: 0;
    padding: 0.35rem 0.45rem;
    border: none;
    background: transparent;
    color: #71717a;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 0.35rem;
}

.sos-dp__link:hover {
    background: #f4f4f5;
    color: #18181b;
}

.sos-dp__link--accent {
    color: #dc2626;
}

.sos-dp__link--accent:hover {
    background: #fef2f2;
    color: #b91c1c;
}

[data-theme="dark"] .sos-dp__trigger {
    background: #18181b;
    color: #fafafa;
    outline-color: #3f3f46;
    box-shadow: none;
}

[data-theme="dark"] .sos-dp__trigger:hover {
    outline-color: #71717a;
}

[data-theme="dark"] .sos-dp--open .sos-dp__trigger,
[data-theme="dark"] .sos-dp__trigger:focus-visible {
    outline-color: #dc2626;
}

[data-theme="dark"] .sos-dp__value.is-placeholder {
    color: #71717a;
}

[data-theme="dark"] .sos-dp__panel {
    background: #18181b;
    border-color: #27272a;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .sos-dp__nav:hover {
    background: #27272a;
    border-color: #3f3f46;
    color: #fafafa;
}

[data-theme="dark"] .sos-dp__month-btn {
    color: #fafafa;
}

[data-theme="dark"] .sos-dp__month-btn:hover {
    background: rgba(220, 38, 38, 0.12);
    border-color: rgba(220, 38, 38, 0.35);
    color: #fecaca;
}

[data-theme="dark"] .sos-dp__day {
    color: #fafafa;
}

[data-theme="dark"] .sos-dp__day:hover {
    background: #27272a;
    border-color: #3f3f46;
}

[data-theme="dark"] .sos-dp__day.is-muted {
    color: #3f3f46;
}

[data-theme="dark"] .sos-dp__foot {
    border-color: #27272a;
}

[data-theme="dark"] .sos-dp__link:hover {
    background: #27272a;
    color: #fafafa;
}

.sos-dd__panel {
    display: none;
    position: fixed;
    z-index: 13500; /* au-dessus des modals (13000), sous command palette (14000) */
    min-width: 12rem;
    max-height: 18rem;
    overflow: hidden;
    border-radius: 0.625rem;
    background: var(--surface-color, #fff);
    border: 1px solid var(--border-strong, #e4e4e7);
    box-shadow:
        0 10px 15px -3px rgba(0, 0, 0, 0.08),
        0 4px 6px -4px rgba(0, 0, 0, 0.06);
}

.sos-dd__panel--open,
.sos-dd--open .sos-dd__panel {
    display: block;
    animation: sos-dd-in 0.12s ease-out;
}

@keyframes sos-dd-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.sos-dd__list {
    max-height: 18rem;
    overflow-y: auto;
    padding: 0.3rem;
}

.sos-dd__option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 0.55rem;
    border: none;
    border-radius: 0.4rem;
    background: transparent;
    color: var(--text-primary, #18181b);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.1s ease;
}

.sos-dd__option:hover,
.sos-dd__option:focus {
    background: #f4f4f5;
    outline: none;
}

.sos-dd__option--selected {
    background: rgba(220, 38, 38, 0.06);
    color: #b91c1c;
}

.sos-dd__option--selected:hover {
    background: rgba(220, 38, 38, 0.1);
}

.sos-dd__option--disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.sos-dd__label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sos-dd__check {
    width: 0.9rem !important;
    height: 0.9rem !important;
    color: #dc2626;
    flex-shrink: 0;
}

.sos-dd__media,
.sos-dd__trigger-media {
    position: relative;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 0.35rem;
    background: #f4f4f5;
    border: 1px solid #e4e4e7;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.sos-dd__media img,
.sos-dd__trigger-media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.sos-dd__media .lucide-icon,
.sos-dd__trigger-media .lucide-icon {
    width: 0.85rem !important;
    height: 0.85rem !important;
    color: #71717a;
}

.sos-dd__media img + .sos-dd__fallback,
.sos-dd__trigger-media img + .sos-dd__fallback {
    display: none;
}

.sos-dd__media--fallback .sos-dd__fallback,
.sos-dd__media--fallback .lucide-icon {
    display: block;
}

.sos-dd--plain .sos-dd__trigger-media,
.sos-dd--plain .sos-dd__media {
    display: none;
}

[data-theme="dark"] .sos-dd__trigger {
    background: #09090b;
    outline-color: #3f3f46;
    color: #fafafa;
    box-shadow: none;
}

[data-theme="dark"] .sos-dd__trigger:hover {
    outline-color: #52525b;
}

[data-theme="dark"] .sos-dd--open .sos-dd__trigger,
[data-theme="dark"] .sos-dd__trigger:focus {
    outline-color: #52525b;
}

[data-theme="dark"] .sos-dd__panel {
    background: #18181b;
    border-color: #3f3f46;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .sos-dd__option:hover,
[data-theme="dark"] .sos-dd__option:focus {
    background: #27272a;
}

[data-theme="dark"] .sos-dd__option--selected {
    background: rgba(220, 38, 38, 0.15);
    color: #fca5a5;
}

[data-theme="dark"] .sos-dd__media,
[data-theme="dark"] .sos-dd__trigger-media {
    background: #27272a;
    border-color: #3f3f46;
}

/* Labels avec icône Lucide */
.sos-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary, #52525b);
    margin-bottom: 0.35rem;
}

.sos-label .lucide-icon,
.sos-label i[data-lucide] {
    width: 1.25rem;
    height: 1.25rem;
    color: #71717a;
    flex-shrink: 0;
    stroke-width: 1.75;
}

.sos-label .req {
    color: #dc2626;
    font-weight: 700;
}

/* =========================================================================
   Icon action buttons (tables)
   ========================================================================= */
.sos-icon-btn {
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--t), color var(--t), border-color var(--t);
}

.sos-icon-btn .lucide-icon,
.sos-icon-btn i {
    width: 1.25rem;
    height: 1.25rem;
    stroke-width: 1.75;
}

.sos-icon-btn:hover {
    background: var(--bg-color);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.sos-icon-btn--danger:hover {
    background: var(--primary-light);
    color: #dc2626;
    border-color: #fecaca;
}

.sos-icon-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.sos-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
}

[data-theme="dark"] .top-bar-theme {
    background: #18181b;
    border-color: #3f3f46;
}

.theme-sos-switch {
    min-width: auto;
    min-height: auto;
    padding: 0;
}

.theme-sos-switch .sos-switch__track {
    width: 40px;
    height: 24px;
}

.theme-sos-switch .sos-switch__thumb {
    width: 12px;
    height: 12px;
}

.theme-sos-switch .sos-switch__input:checked + .sos-switch__track .sos-switch__thumb {
    width: 16px;
    height: 16px;
}

.theme-sos-switch .sos-switch__icon {
    width: 0.625rem;
    height: 0.625rem;
}

/* Establishment logo tile */
.est-logo {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.625rem;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.est-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 3px;
}

.est-logo .lucide-icon {
    width: 1.125rem;
    height: 1.125rem;
    color: #dc2626;
}

/* -------------------------------------------------------------------------
   Fixed footer - flush with main panel (same left as .main-panel)
   Overrides legacy left:220px from global-theme.css
   ---------------------------------------------------------------------- */
.sos-footer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: auto !important;
    margin: 0 !important;
    height: var(--footer-height, 2.75rem);
    /* Même toile que page + topbar (plus de bande surface grise) */
    background: var(--chrome-bg, var(--bg-color));
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.72rem;
    color: var(--text-muted);
    z-index: 999;
    padding: 0 1rem;
}

body.sidebar-collapsed .sos-footer {
    left: 0 !important;
}

/* Footer global */

.sos-footer__logo {
    display: inline-flex;
    align-items: center;
    margin-right: 0.25rem;
}

.sos-footer__logo img {
    height: 14px;
    width: auto;
    opacity: 0.45;
    filter: grayscale(100%);
}

.sos-footer__logo:hover img {
    opacity: 0.75;
    filter: grayscale(0%);
}

.sos-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
}

.sos-footer a:hover {
    color: #dc2626;
}

:root {
    --footer-height: 2.75rem;
}

/* =========================================================================
   Focus champs - pas de halo bleu / rouge « IA »
   Bordure discrète uniquement (accessibilité sans glow)
   ========================================================================= */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]):focus,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]):focus-visible,
textarea:focus,
textarea:focus-visible,
select:focus,
select:focus-visible,
.form-control:focus,
.form-control:focus-visible,
.u-input:focus,
.u-input:focus-visible,
.filter-input:focus,
.f-input:focus,
.sos-select:focus,
.auth-input:focus,
.auth-select:focus,
.search-input:focus {
    outline: none !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]):focus,
textarea:focus,
.form-control:focus,
.u-input:focus,
.filter-input:focus,
.f-input:focus,
.search-input:focus {
    border-color: #a1a1aa !important;
}

.u-input-group:focus-within,
.sos-auth-field-box:focus-within {
    outline: none !important;
    box-shadow: none !important;
    border-color: #a1a1aa !important;
}

/* Kill browser autofill / Material blue glow leftovers */
.form-group .form-control:focus,
.bmd-form-group .form-control:focus,
.md-form .form-control:focus {
    outline: none !important;
    box-shadow: none !important;
    border-color: #a1a1aa !important;
}

[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .u-input:focus {
    border-color: #52525b !important;
    box-shadow: none !important;
}

/* =========================================================================
   Back button unifié (.sos-back-btn) - toujours à droite du page-header
   ===================================================================== */
.sos-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    color: var(--text-secondary, #64748b);
    background: var(--surface-color, #fff);
    border: 1px solid var(--border-color, #e4e4e7);
    border-radius: 0.375rem;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.2;
    min-height: 2rem;
    transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.sos-back-btn:hover {
    color: var(--text-primary, #18181b);
    background: var(--bg-color, #f8fafc);
    border-color: #d4d4d8;
    text-decoration: none;
}
.sos-back-btn .lucide-icon,
.sos-back-btn i {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    stroke-width: 1.75;
}

.page-header .sos-back-btn,
.sos-page-header .sos-back-btn,
.sos-page-header__actions .sos-back-btn {
    margin-left: auto;
}

/* Si le header a déjà __actions, le back reste dans le flex gap */
.sos-page-header__actions .sos-back-btn {
    margin-left: 0;
}

/* =========================================================================
   Pagination moderne (.sos-pagination) - projet entier
   ===================================================================== */
.sos-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.15rem 0;
    width: 100%;
}

.sos-pagination__info {
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
    font-weight: 500;
}

.sos-pagination__info strong {
    color: var(--text-primary, #18181b);
    font-weight: 700;
}

.sos-pagination__list {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
}

.sos-pagination__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.45rem;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    color: var(--text-secondary, #64748b);
    background: var(--surface-color, #fff);
    border: 1px solid var(--border-color, #e4e4e7);
    border-radius: 0.375rem;
    text-decoration: none;
    line-height: 1;
    user-select: none;
    transition: color 0.12s, background 0.12s, border-color 0.12s;
}

a.sos-pagination__btn:hover {
    color: var(--text-primary, #18181b);
    background: var(--bg-color, #f4f4f5);
    border-color: #d4d4d8;
    text-decoration: none;
}

.sos-pagination__btn--active {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff !important;
    cursor: default;
}

.sos-pagination__btn--ellipsis {
    border-color: transparent;
    background: transparent;
    color: var(--text-muted, #a1a1aa);
    cursor: default;
    min-width: 1.5rem;
}

.sos-pagination__item.is-disabled .sos-pagination__btn,
.sos-pagination__item.disabled .sos-pagination__btn {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Compat anciens liens si une vue custom locale les utilise encore */
.sos-pagination__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.45rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    background: var(--surface-color, #fff);
    border: 1px solid var(--border-color, #e4e4e7);
    border-radius: 0.375rem;
    text-decoration: none;
}
.sos-pagination__link:hover {
    color: var(--text-primary, #18181b);
    background: var(--bg-color, #f4f4f5);
}
.sos-pagination__link--active {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff !important;
}

@media (max-width: 480px) {
    .sos-pagination {
        justify-content: center;
    }
    .sos-pagination__btn,
    .sos-pagination__link {
        min-width: 1.75rem;
        height: 1.75rem;
        font-size: 0.75rem;
    }
}

/* =========================================================================
   Filter bar - Notion / Linear style (projet entier)
   ========================================================================= */
.sos-filterbar {
    background: var(--surface-color, #fff);
    border: 1px solid var(--border-color, #e4e4e7);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    overflow: visible;
}

.sos-filterbar__toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.625rem 0.75rem;
    min-height: 3.25rem;
}

.sos-filterbar__field {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
    height: 2.25rem;
}

.sos-filterbar__field--search {
    flex: 1 1 16rem;
    min-width: 12rem;
}

.sos-filterbar__field--md {
    flex: 0 1 11.5rem;
    width: 11.5rem;
}

.sos-filterbar__field--sm {
    flex: 0 1 8.5rem;
    width: 8.5rem;
}

.sos-filterbar__field > .lucide-icon,
.sos-filterbar__field > i[data-lucide] {
    position: absolute;
    left: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    stroke-width: 1.75;
    color: #a1a1aa;
    pointer-events: none;
    z-index: 1;
}

.sos-filterbar__control {
    width: 100%;
    height: 2.25rem;
    padding: 0 0.75rem 0 2.125rem;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-primary, #18181b);
    background: var(--surface-color, #fff);
    border: 1px solid var(--border-strong, #d4d4d8);
    border-radius: 0.375rem;
    outline: none;
    appearance: none;
    box-shadow: none;
}

.sos-filterbar__control::placeholder {
    color: #a1a1aa;
    font-weight: 400;
}

.sos-filterbar__control:hover {
    border-color: #a1a1aa;
}

.sos-filterbar__control:focus {
    border-color: #71717a;
}

/* Select sans icône à gauche (sos-select gère le trigger) */
.sos-filterbar__field--select > .lucide-icon,
.sos-filterbar__field--select > i[data-lucide] {
    display: none;
}

.sos-filterbar__field--select .sos-filterbar__control,
.sos-filterbar__field--select select.sos-filterbar__control {
    padding-left: 0.75rem;
}

.sos-filterbar__actions {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin-left: auto;
    flex-shrink: 0;
}

.sos-filterbar__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    height: 2.25rem;
    padding: 0 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.sos-filterbar__btn .lucide-icon,
.sos-filterbar__btn i {
    width: 1rem;
    height: 1rem;
    stroke-width: 1.75;
}

.sos-filterbar__btn--primary {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}

.sos-filterbar__btn--primary:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #fff;
}

.sos-filterbar__btn--ghost {
    background: #fff;
    color: #52525b;
    border-color: #d4d4d8;
}

.sos-filterbar__btn--ghost:hover {
    background: #f4f4f5;
    color: #18181b;
}

.sos-filterbar__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.4rem 0.75rem 0.55rem;
    border-top: 1px solid #f4f4f5;
}

.sos-filterbar__toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    height: 1.75rem;
    padding: 0 0.4rem;
    border: none;
    background: transparent;
    color: #71717a;
    font-size: 0.75rem;
    font-weight: 550;
    font-family: inherit;
    cursor: pointer;
    border-radius: 0.25rem;
}

.sos-filterbar__toggle:hover {
    color: #18181b;
    background: #f4f4f5;
}

.sos-filterbar__toggle.is-open {
    color: #18181b;
}

.sos-filterbar__toggle .lucide-icon,
.sos-filterbar__toggle i {
    width: 0.875rem;
    height: 0.875rem;
    stroke-width: 1.75;
}

.sos-filterbar__count {
    font-size: 0.75rem;
    color: #a1a1aa;
    font-weight: 500;
}

.sos-filterbar__chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.125rem;
    height: 1.125rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: #f4f4f5;
    color: #52525b;
    font-size: 0.625rem;
    font-weight: 700;
}

.sos-filterbar__adv {
    display: none;
    padding: 0.75rem;
    border-top: 1px solid #f4f4f5;
    background: #fafafa;
}

.sos-filterbar__adv.is-open {
    display: block;
}

.sos-filterbar__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem 0.75rem;
    align-items: start;
}

.sos-filterbar__cell {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.sos-filterbar__label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #71717a;
    letter-spacing: 0.01em;
    line-height: 1;
    margin: 0;
    height: 0.875rem;
}

.sos-filterbar__cell .sos-filterbar__field {
    width: 100%;
}

.sos-filterbar__cell .sos-filterbar__control {
    padding-left: 0.75rem;
}

.sos-filterbar__cell .sos-filterbar__field > .lucide-icon,
.sos-filterbar__cell .sos-filterbar__field > i[data-lucide] {
    display: none;
}

[data-theme="dark"] .sos-filterbar {
    background: #18181b;
    border-color: #3f3f46;
}

[data-theme="dark"] .sos-filterbar__control,
[data-theme="dark"] .sos-filterbar__btn--ghost {
    background: #09090b;
    color: #fafafa;
    border-color: #3f3f46;
}

[data-theme="dark"] .sos-filterbar__adv {
    background: #09090b;
    border-color: #27272a;
}

[data-theme="dark"] .sos-filterbar__meta {
    border-color: #27272a;
}

@media (max-width: 900px) {
    .sos-filterbar__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .sos-filterbar__field--md,
    .sos-filterbar__field--sm {
        flex: 1 1 9rem;
        width: auto;
    }
}

@media (max-width: 560px) {
    .sos-filterbar__grid {
        grid-template-columns: 1fr;
    }
    .sos-filterbar__actions {
        margin-left: 0;
        width: 100%;
    }
    .sos-filterbar__actions .sos-filterbar__btn {
        flex: 1;
    }
}

/* =========================================================================
   DARK MODE - système global (Notion / Figma style)
   Couvre pages, cards, tables, modals, filterbar, toasts, badges, boutons
   ========================================================================= */

[data-theme="dark"] {
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    --info: #38bdf8;
}

/* Fond app + grilles */
[data-theme="dark"] body,
[data-theme="dark"] .main-panel,
[data-theme="dark"] .content {
    background-color: transparent !important;
    color: var(--text-primary);
}

[data-theme="dark"] .bg-pattern-page,
[data-theme="dark"] .bg-pattern-dash,
[data-theme="dark"] .bg-pattern-app,
[data-theme="dark"] .bg-pattern {
    display: none !important;
}

/* Surfaces / cards génériques (toutes pages) */
[data-theme="dark"] .sos-page-header,
[data-theme="dark"] .page-header,
[data-theme="dark"] .sos-card,
[data-theme="dark"] .sos-filterbar,
[data-theme="dark"] .req-card,
[data-theme="dark"] .audit-card,
[data-theme="dark"] .u-panel,
[data-theme="dark"] .u-card,
[data-theme="dark"] .u-stat,
[data-theme="dark"] .u-filter,
[data-theme="dark"] .p-panel,
[data-theme="dark"] .kpi-card,
[data-theme="dark"] .chart-card,
[data-theme="dark"] .dash-card,
[data-theme="dark"] .pcard,
[data-theme="dark"] .estab-card,
[data-theme="dark"] .accounts-card,
[data-theme="dark"] .ann-card,
[data-theme="dark"] .m-card,
[data-theme="dark"] .f-card,
[data-theme="dark"] .ov-card,
[data-theme="dark"] .sos-admin__card,
[data-theme="dark"] .data-card,
[data-theme="dark"] .form-card,
[data-theme="dark"] .card-panel {
    background: var(--surface-color) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary);
    box-shadow: var(--shadow-xs);
}

[data-theme="dark"] .req-card__head,
[data-theme="dark"] .audit-card__head,
[data-theme="dark"] .u-panel__head,
[data-theme="dark"] .u-card__head,
[data-theme="dark"] .p-panel__head,
[data-theme="dark"] .dash-card__head,
[data-theme="dark"] .chart-card__head,
[data-theme="dark"] .pcard__head,
[data-theme="dark"] .sos-admin__card-head,
[data-theme="dark"] .card-panel__head {
    background: var(--thead-bg) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .req-card__head-title,
[data-theme="dark"] .audit-card__head-title,
[data-theme="dark"] .u-panel__title,
[data-theme="dark"] .p-panel__head,
[data-theme="dark"] .sos-page-header__titles h1,
[data-theme="dark"] .page-header h1 {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .req-card__count,
[data-theme="dark"] .audit-card__count {
    background: #27272a !important;
    color: var(--text-secondary) !important;
}

/* Tables */
[data-theme="dark"] .req-table th,
[data-theme="dark"] .audit-table th,
[data-theme="dark"] .u-table th,
[data-theme="dark"] .ov-table th,
[data-theme="dark"] .estab-table th,
[data-theme="dark"] .accounts-table th,
[data-theme="dark"] .m-table th,
[data-theme="dark"] .prof-table th,
[data-theme="dark"] table thead th {
    background: var(--thead-bg) !important;
    color: var(--thead-text) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .req-table td,
[data-theme="dark"] .audit-table td,
[data-theme="dark"] .u-table td,
[data-theme="dark"] .ov-table td,
[data-theme="dark"] table tbody td {
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .req-table tbody tr:hover td,
[data-theme="dark"] .audit-table tbody tr:hover td,
[data-theme="dark"] .u-table tbody tr:hover td,
[data-theme="dark"] table tbody tr:hover td {
    background: var(--row-hover-bg) !important;
}

[data-theme="dark"] code,
[data-theme="dark"] .req-table code,
[data-theme="dark"] .audit-table code {
    background: #09090b !important;
    border-color: var(--border-strong) !important;
    color: var(--text-secondary) !important;
}

/* Inputs / boutons */
[data-theme="dark"] .u-input,
[data-theme="dark"] .p-input,
[data-theme="dark"] .req-input,
[data-theme="dark"] .af-input,
[data-theme="dark"] .f-input,
[data-theme="dark"] .form-control,
[data-theme="dark"] .sos-filterbar__control {
    background: #09090b !important;
    color: var(--text-primary) !important;
    border-color: var(--border-strong) !important;
}

[data-theme="dark"] .u-input-group,
[data-theme="dark"] .u-input-group .u-suffix,
[data-theme="dark"] .p-pw-btn,
[data-theme="dark"] .u-pw-btn,
[data-theme="dark"] .pw-gen-btn,
[data-theme="dark"] .pw-toggle {
    background: #09090b !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-strong) !important;
}

[data-theme="dark"] .u-btn--ghost,
[data-theme="dark"] .p-btn--ghost,
[data-theme="dark"] .req-btn--ghost,
[data-theme="dark"] .af-btn--ghost,
[data-theme="dark"] .sos-filterbar__btn--ghost,
[data-theme="dark"] .sos-back-btn,
[data-theme="dark"] .export-btn,
[data-theme="dark"] .quick-btn {
    background: var(--surface-color) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-strong) !important;
}

[data-theme="dark"] .u-btn--ghost:hover,
[data-theme="dark"] .p-btn--ghost:hover,
[data-theme="dark"] .sos-filterbar__btn--ghost:hover,
[data-theme="dark"] .sos-back-btn:hover,
[data-theme="dark"] .export-btn:hover,
[data-theme="dark"] .quick-btn:hover {
    background: #27272a !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .sos-icon-btn {
    background: var(--surface-color) !important;
    border-color: var(--border-strong) !important;
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .sos-icon-btn:hover {
    background: #27272a !important;
    color: var(--text-primary) !important;
}

/* Filterbar dark polish */
[data-theme="dark"] .sos-filterbar__adv {
    background: #0c0c0e !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .sos-filterbar__meta {
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .sos-filterbar__toggle {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .sos-filterbar__toggle:hover,
[data-theme="dark"] .sos-filterbar__toggle.is-open {
    color: var(--text-primary) !important;
    background: #27272a !important;
}

[data-theme="dark"] .sos-filterbar__chip {
    background: #27272a !important;
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .sos-filterbar__count,
[data-theme="dark"] .sos-filterbar__label {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .sos-filterbar__control[type="date"] {
    color-scheme: dark;
}

/* Modals */
[data-theme="dark"] .u-modal,
[data-theme="dark"] .modal-backdrop {
    background: rgba(0, 0, 0, 0.78) !important;
}

[data-theme="dark"] .u-modal__box,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-dialog .modal-content {
    background: #18181b !important;
    border-color: #3f3f46 !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .u-modal__top,
[data-theme="dark"] .u-modal__foot,
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    background: #0c0c0e !important;
    border-color: #27272a !important;
}

[data-theme="dark"] .u-modal__top h3,
[data-theme="dark"] .u-modal__sub,
[data-theme="dark"] .u-confirm__row .v,
[data-theme="dark"] .p-identity__name,
[data-theme="dark"] .p-meta__value,
[data-theme="dark"] .u-name,
[data-theme="dark"] .req-estab__name,
[data-theme="dark"] .audit-estab__name {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .u-confirm,
[data-theme="dark"] .u-delete-warn,
[data-theme="dark"] .p-alert--err,
[data-theme="dark"] .u-errors {
    background: rgba(239, 68, 68, 0.1) !important;
    border-color: #7f1d1d !important;
    color: #fecaca !important;
}

[data-theme="dark"] .p-alert--ok,
[data-theme="dark"] .sos-alert--success {
    background: rgba(34, 197, 94, 0.1) !important;
    border-color: #14532d !important;
    color: #bbf7d0 !important;
}

[data-theme="dark"] .u-roles,
[data-theme="dark"] .role-panel {
    background: #0c0c0e !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .u-role {
    background: #18181b !important;
    border-color: #27272a !important;
}

[data-theme="dark"] .u-role__name {
    color: var(--text-primary) !important;
}

/* Badges - lisibles sur fond sombre */
[data-theme="dark"] .u-badge--dsi,
[data-theme="dark"] .p-badge--dsi { background: rgba(109, 40, 217, 0.2); color: #c4b5fd; border-color: rgba(167, 139, 250, 0.35); }
[data-theme="dark"] .u-badge--rsi,
[data-theme="dark"] .p-badge--rsi { background: rgba(29, 78, 216, 0.2); color: #93c5fd; border-color: rgba(96, 165, 250, 0.35); }
[data-theme="dark"] .u-badge--technicien,
[data-theme="dark"] .p-badge--technicien { background: rgba(4, 120, 87, 0.2); color: #6ee7b7; border-color: rgba(52, 211, 153, 0.35); }
[data-theme="dark"] .u-badge--consultation,
[data-theme="dark"] .p-badge--consultation { background: rgba(3, 105, 161, 0.2); color: #7dd3fc; border-color: rgba(56, 189, 248, 0.35); }
[data-theme="dark"] .u-badge--requester,
[data-theme="dark"] .p-badge--requester { background: #27272a; color: #d4d4d8; border-color: #3f3f46; }
[data-theme="dark"] .u-badge--super_admin,
[data-theme="dark"] .p-badge--super_admin { background: rgba(180, 83, 9, 0.2); color: #fcd34d; border-color: rgba(251, 191, 36, 0.35); }
[data-theme="dark"] .u-badge--on,
[data-theme="dark"] .req-badge--ok { background: rgba(4, 120, 87, 0.2); color: #6ee7b7; border-color: rgba(52, 211, 153, 0.35); }
[data-theme="dark"] .u-badge--off,
[data-theme="dark"] .req-badge--off { background: rgba(220, 38, 38, 0.2); color: #fca5a5; border-color: rgba(248, 113, 113, 0.35); }
[data-theme="dark"] .req-badge--warn { background: rgba(180, 83, 9, 0.2); color: #fcd34d; border-color: rgba(251, 191, 36, 0.35); }
[data-theme="dark"] .req-badge--default { background: #27272a; color: #d4d4d8; border-color: #3f3f46; }

/* Toast glyphs */
[data-theme="dark"] .sos-toast--success .sos-toast__glyph { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
[data-theme="dark"] .sos-toast--danger .sos-toast__glyph { background: rgba(239, 68, 68, 0.15); color: #f87171; }
[data-theme="dark"] .sos-toast--warning .sos-toast__glyph { background: rgba(234, 179, 8, 0.15); color: #facc15; }
[data-theme="dark"] .sos-toast--info .sos-toast__glyph { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }

[data-theme="dark"] .toast {
    background: #18181b !important;
    border-color: #3f3f46 !important;
    color: var(--text-primary) !important;
}

/* KPI icons */
[data-theme="dark"] .kpi-card__icon--total { background: rgba(239, 68, 68, 0.15); color: #f87171; }
[data-theme="dark"] .kpi-card__icon--done { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
[data-theme="dark"] .kpi-card__icon--pending { background: #27272a; color: #a1a1aa; }
[data-theme="dark"] .kpi-card__icon--progress { background: rgba(37, 99, 235, 0.15); color: #60a5fa; }
[data-theme="dark"] .kpi-card__icon--refused { background: rgba(180, 83, 9, 0.15); color: #fbbf24; }
[data-theme="dark"] .kpi-card__icon--rating { background: rgba(202, 138, 4, 0.15); color: #facc15; }
[data-theme="dark"] .kpi-card__value,
[data-theme="dark"] .u-stat__num { color: var(--text-primary) !important; }
[data-theme="dark"] .kpi-card__label,
[data-theme="dark"] .u-stat__label { color: var(--text-muted) !important; }

/* Avatar / identity */
[data-theme="dark"] .p-avatar,
[data-theme="dark"] .avatar-img {
    border-color: var(--border-color) !important;
    background: #09090b !important;
}

[data-theme="dark"] .p-avatar-fallback,
[data-theme="dark"] .avatar-placeholder {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.35) !important;
    color: #f87171 !important;
}

[data-theme="dark"] .p-wrap,
[data-theme="dark"] .u-wrap,
[data-theme="dark"] .req-wrap,
[data-theme="dark"] .audit-wrap,
[data-theme="dark"] .dash-wrap {
    color: var(--text-primary);
}

[data-theme="dark"] .mono,
[data-theme="dark"] .u-muted,
[data-theme="dark"] .req-estab__slug,
[data-theme="dark"] .audit-estab__slug {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .req-pager,
[data-theme="dark"] .audit-pager,
[data-theme="dark"] .u-pager,
[data-theme="dark"] .u-actions-row,
[data-theme="dark"] .p-actions {
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .u-stat__icon {
    background: rgba(239, 68, 68, 0.12) !important;
    color: #f87171 !important;
}

/* Pagination dark */
[data-theme="dark"] .sos-pagination__btn {
    background: var(--surface-color);
    border-color: var(--border-strong);
    color: var(--text-secondary);
}

[data-theme="dark"] a.sos-pagination__btn:hover {
    background: #27272a;
    color: var(--text-primary);
}

[data-theme="dark"] .sos-pagination__btn--active {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff !important;
}

/* =========================================================================
   RESPONSIVE - tablette & téléphone (shell + pages)
   ========================================================================= */
@media (max-width: 991.98px) {
    .sos-page-header,
    .page-header {
        padding: 0.875rem 1rem;
        gap: 0.75rem;
    }

    .sos-page-header__titles h1,
    .page-header h1 {
        font-size: 1.125rem;
    }

    .sos-filterbar__toolbar {
        align-items: stretch;
    }

    .sos-filterbar__field--search {
        flex: 1 1 100%;
        min-width: 0;
    }

    .sos-filterbar__actions {
        margin-left: 0;
        width: 100%;
    }

    .sos-filterbar__actions .sos-filterbar__btn {
        flex: 1;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .charts-row {
        grid-template-columns: 1fr !important;
    }

    .p-grid {
        grid-template-columns: 1fr !important;
    }

    .u-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 768px) {
    .content {
        padding-left: 0.875rem !important;
        padding-right: 0.875rem !important;
    }

    .sos-page-header__actions {
        width: 100%;
    }

    .sos-back-btn {
        width: 100%;
        justify-content: center;
    }

    .u-form-grid,
    .p-row,
    .u-edit-grid {
        grid-template-columns: 1fr !important;
    }

    .req-table,
    .audit-table,
    .u-table {
        font-size: 0.75rem;
    }

    .quick-actions {
        gap: 0.375rem;
    }

    .quick-btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}

@media (max-width: 560px) {
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr));
    }

    .u-stats {
        grid-template-columns: 1fr !important;
    }

    .sos-filterbar__grid {
        grid-template-columns: 1fr !important;
    }

    .top-bar-title-prefix {
        font-size: 0.75rem;
        max-width: 9rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sos-pagination {
        justify-content: center;
    }

    .sos-pagination__info {
        width: 100%;
        text-align: center;
    }
}


/* Demandeur sidebar - logo établissement */
.sidebar-logo-img--estab {
    object-fit: contain;
    background: transparent;
    border-radius: 0.35rem;
    padding: 0;
}
.sidebar-brand-sub {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--sidebar-muted);
    letter-spacing: 0.02em;
    line-height: 1.2;
    margin-top: 0.1rem;
}
body.sidebar-collapsed .sidebar-brand-sub {
    display: none !important;
}
.sb-user__identity--static {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
    flex: 1;
    text-decoration: none;
    color: inherit;
    cursor: default;
}
.sb-user__identity--static .user-avatar__fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: #dc2626;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
}

/* Demandeur console page helpers */
.dm-wrap { max-width: none; width: 100%; padding-top: 1.5rem; padding-bottom: 3.5rem; position: relative; z-index: 10; }
.dm-hero {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.dm-hero__title {
    margin: 0;
    font-family: 'Outfit', Inter, sans-serif;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}
.dm-hero__sub {
    margin: 0.35rem 0 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.dm-hero__sub .lucide-icon { width: 0.9rem; height: 0.9rem; color: #dc2626; }
.dm-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.65rem; }
.dm-pill {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.25rem 0.55rem; border-radius: 999px;
    font-size: 0.7rem; font-weight: 650;
    background: var(--thead-bg); color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.dm-pill .lucide-icon { width: 0.75rem; height: 0.75rem; color: #dc2626; }
.dm-cta {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    padding: 1rem 1.15rem; margin-bottom: 1.25rem;
    background: var(--surface-color); border: 1px solid var(--border-color);
    border-radius: var(--radius-xl); box-shadow: var(--shadow-xs);
}
.dm-cta__title {
    margin: 0; font-size: 0.9375rem; font-weight: 700; color: var(--text-primary);
    display: inline-flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
}
.dm-cta__title .lucide-icon { width: 1.05rem; height: 1.05rem; color: #dc2626; }
.dm-cta__desc { margin: 0; font-size: 0.78rem; color: var(--text-muted); }
.dm-status {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.2rem 0.55rem; border-radius: 999px;
    font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
.dm-status--on { background: rgba(22,163,74,0.12); color: #166534; }
.dm-status--off { background: rgba(220,38,38,0.1); color: #b91c1c; }
.dm-status__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.dm-table-wrap { overflow-x: auto; }
.dm-badge {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.2rem 0.55rem; border-radius: 999px;
    font-size: 0.7rem; font-weight: 700;
}
.dm-badge--ok { background: rgba(22,163,74,0.12); color: #166534; }
.dm-badge--run { background: rgba(37,99,235,0.12); color: #1e40af; }
.dm-badge--wait { background: rgba(202,138,4,0.14); color: #854d0e; }
.dm-badge--bad { background: rgba(220,38,38,0.1); color: #991b1b; }
.dm-badge--mute { background: var(--thead-bg); color: var(--text-muted); }
.dm-ref {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 700; color: #dc2626; text-decoration: none; font-size: 0.8rem;
}
.dm-ref:hover { text-decoration: underline; }
.dm-btn-cancel {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.3rem 0.55rem; border-radius: 0.4rem;
    background: #fef2f2; color: #dc2626; border: 1px solid #fecaca;
    font-size: 0.7rem; font-weight: 700; font-family: inherit; cursor: pointer;
}
.dm-btn-cancel:hover { background: #fee2e2; }
.dm-btn-cancel .lucide-icon { width: 0.8rem; height: 0.8rem; }
.dm-empty {
    padding: 3rem 1.25rem; text-align: center; color: var(--text-muted);
}
.dm-empty__icon {
    width: 3rem; height: 3rem; border-radius: 0.75rem;
    background: var(--thead-bg); border: 1px solid var(--border-color);
    display: inline-flex; align-items: center; justify-content: center; margin-bottom: 0.75rem;
}
.dm-empty__icon .lucide-icon { width: 1.25rem; height: 1.25rem; color: var(--text-muted); }
@media (max-width: 640px) {
    .dm-cta { flex-direction: column; align-items: stretch; }
    .dm-cta .btn { width: 100%; justify-content: center; }
}


.sidebar-chrome__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
}
.sidebar-chrome__clock {
    font-size: 0.68rem;
    font-weight: 650;
    color: var(--sidebar-muted);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}
body.sidebar-collapsed .sidebar-chrome__clock {
    display: none;
}

@keyframes dmSosPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.28); }
    70% { box-shadow: 0 0 0 5px rgba(22, 163, 74, 0); }
}
@keyframes dmSosDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(0.85); }
}
.dm-status--on {
    animation: dmSosPulse 2.8s ease-out infinite;
}
.dm-status--on .dm-status__dot {
    animation: dmSosDot 2.8s ease-in-out infinite;
}
.dm-cta__title--live {
    animation: none;
}
.dm-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1.15rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color);
}
.dm-filters__search {
    flex: 1 1 12rem;
    min-width: 10rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--surface-color);
}
.dm-filters__search .lucide-icon { width: 0.9rem; height: 0.9rem; color: var(--text-muted); flex-shrink: 0; }
.dm-filters__search input {
    border: none; outline: none; background: transparent; width: 100%;
    font: inherit; font-size: 0.8125rem; color: var(--text-primary);
}
.dm-filters select {
    min-height: 2.15rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--surface-color);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.8125rem;
}
.dm-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.75rem 1.15rem;
    border-top: 1px solid var(--border-color);
    background: var(--thead-bg);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* PWA modal : un seul message visible (display:flex override le [hidden] natif) */
.sos-pwa-modal .sos-modal__msg[hidden],
.sos-pwa-modal [data-sos-pwa-install-confirm][hidden] {
    display: none !important;
}

/* Brand text vide (wordmark dans le logo) */
.sidebar-brand-text:empty,
.sidebar-brand-text:not(:has(*)) {
    display: none;
}


/* === RESPONSIVE ADVANCED 1.1.4 === */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(9, 9, 11, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0s 0.2s;
    touch-action: none;
}

.sidebar-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease, visibility 0s;
}

/* Shared fluid cards / KPI */
.sos-card {
    padding: 0;
}
.sos-card__body {
    padding: clamp(0.85rem, 2.2vw, 1.15rem);
}
.sos-card__head {
    padding: clamp(0.65rem, 1.8vw, 0.85rem) clamp(0.85rem, 2.2vw, 1.15rem);
}
.kpi-grid {
    display: grid;
    gap: clamp(0.65rem, 2vw, 1rem);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
}
.kpi-card,
.section-card {
    min-width: 0;
}
.sos-table-wrap,
.table-responsive,
.dm-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

/* Page header actions wrap cleanly under FAB chrome */
.sos-page-header {
    gap: clamp(0.65rem, 2vw, 1rem);
    flex-wrap: wrap;
}
.sos-page-header__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    min-width: 0;
}
.sos-page-header__titles {
    min-width: 0;
    flex: 1 1 12rem;
}
.sos-page-header__titles h1 {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Buttons: comfortable touch targets on small screens */
@media (max-width: 991.98px) {
    .btn,
    .sos-filterbar__btn,
    .quick-btn,
    .export-btn,
    .ni-btn,
    .dm-cta,
    .sos-back-btn {
        min-height: 44px;
    }
    .sos-filterbar__control,
    .sos-filterbar input,
    .sos-filterbar select {
        min-height: 44px;
        min-width: 0;
    }
    .sos-filterbar__toolbar {
        gap: 0.5rem;
    }
    .sos-modal,
    .sos-pwa-modal {
        margin: max(0.75rem, var(--safe-top)) max(0.75rem, var(--safe-right)) max(0.75rem, var(--safe-bottom)) max(0.75rem, var(--safe-left));
        max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 1.5rem);
        overflow: auto;
    }
    .sos-modal-backdrop {
        padding: max(0.5rem, var(--safe-top)) max(0.5rem, var(--safe-right)) max(0.5rem, var(--safe-bottom)) max(0.5rem, var(--safe-left));
        align-items: flex-start;
    }
    .sos-toast-stack {
        bottom: max(0.75rem, calc(var(--safe-bottom) + 0.75rem));
        right: max(0.75rem, var(--safe-right));
        width: min(22rem, calc(100vw - 1.5rem - var(--safe-left) - var(--safe-right)));
    }
    .sos-toast {
        align-items: flex-start;
    }
    .sos-toast__msg,
    .sos-modal__msg {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        overflow-wrap: anywhere;
        line-height: 1.45;
    }
}

@media (max-width: 768px) {
    .sos-page-header__left {
        width: 100%;
    }
    .sos-page-header__actions {
        width: 100%;
    }
    .sos-page-header__actions > * {
        flex: 1 1 auto;
    }
    .sos-filterbar__actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .sos-filterbar__actions .sos-filterbar__btn {
        flex: 1 1 calc(50% - 0.25rem);
        justify-content: center;
    }
    .btn-group,
    .quick-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .btn-group .btn,
    .quick-actions .quick-btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .sos-filterbar__actions .sos-filterbar__btn,
    .sos-page-header__actions > .btn,
    .sos-page-header__actions > a,
    .sos-page-header__actions > button {
        flex: 1 1 100%;
        width: 100%;
        justify-content: center;
    }
    .sos-pagination {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }
    .sos-pagination__nav {
        justify-content: center;
        flex-wrap: wrap;
    }
    body.shell-sidebar-only .main-panel .content {
        padding-left: max(0.75rem, var(--safe-left)) !important;
        padding-right: max(0.75rem, var(--safe-right)) !important;
    }
}

/* Hide FAB when drawer open to avoid double chrome */
body.sidebar-drawer-open .sidebar-mobile-fab {
    opacity: 0;
    pointer-events: none;
}

/* PWA install modal above FAB */
.sos-modal-backdrop:has(.sos-pwa-modal),
.sos-pwa-modal-host {
    z-index: 13050;
}


/* Push permission gate */
#sosPushGateModal {
    z-index: 13150 !important;
}
#sosPushGateModal .sos-modal__foot {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}
