/* =========================================================
   Stannah Manager — socle visuel commun
   ========================================================= */

:root {
    color-scheme: light;

    --color-primary: #153e75;
    --color-primary-dark: #102f59;
    --color-primary-light: #2563a8;
    --color-primary-soft: #edf5ff;
    --color-secondary: #344054;
    --color-danger: #b42318;
    --color-danger-dark: #8f1d18;
    --color-danger-soft: #fff1f0;
    --color-success: #147a55;
    --color-success-soft: #ecfdf3;
    --color-warning: #9a6700;
    --color-warning-soft: #fff8e8;
    --color-error: #b42318;

    --color-bg: #f4f7fb;
    --color-card: #ffffff;
    --color-text: #182230;
    --color-muted: #667085;
    --color-subtle: #98a2b3;
    --color-border: #dfe6ef;
    --color-border-strong: #cbd5e1;
    --color-table-header: #f6f8fb;
    --color-table-hover: #f4f8fd;

    --radius-sm: 7px;
    --radius-md: 11px;
    --radius-lg: 15px;
    --radius-pill: 999px;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 12px 28px rgba(16, 24, 40, 0.11);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    --sidebar-width: 252px;
    --topbar-height: 64px;
    --page-max-width: 1600px;

    /* Alias conservés pour les composants de carte existants. */
    --muted-color: var(--color-muted);
    --border-color: var(--color-border);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--color-text);
    background: var(--color-bg);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.nav-drawer-open {
    overflow: hidden;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
input,
select,
textarea,
a {
    -webkit-tap-highlight-color: transparent;
}

img,
svg {
    max-width: 100%;
}

h1,
h2,
h3,
h4,
p {
    margin-top: 0;
}

p {
    margin-bottom: 0;
}

h2 {
    margin-bottom: var(--space-4);
    color: #102a4c;
    font-size: clamp(1.45rem, 2vw, 1.85rem);
    line-height: 1.2;
    letter-spacing: -0.025em;
}

h3 {
    margin-bottom: var(--space-3);
    color: var(--color-text);
    font-size: 1.08rem;
    line-height: 1.3;
}

h4 {
    color: var(--color-text);
    font-size: 0.95rem;
}

a {
    color: var(--color-primary-light);
    text-underline-offset: 2px;
}

a:hover {
    color: var(--color-primary);
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid rgba(37, 99, 168, 0.38);
    outline-offset: 2px;
}

main:focus {
    outline: 0;
}

address {
    font-style: normal;
}

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

.skip-link {
    position: fixed;
    top: var(--space-3);
    left: var(--space-3);
    z-index: 10000;
    padding: 10px 14px;
    color: white;
    background: var(--color-primary-dark);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-weight: 750;
    text-decoration: none;
    transform: translateY(calc(-100% - 24px));
    transition: transform 0.16s ease;
}

.skip-link:focus {
    color: white;
    transform: translateY(0);
}

/* =========================================================
   Application shell
   ========================================================= */

.app-shell {
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1100;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    color: white;
    background: linear-gradient(180deg, #102f59 0%, #0c2747 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.app-sidebar :where(a, button):focus-visible {
    outline-color: rgba(183, 215, 255, 0.85);
}

.app-sidebar-header {
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.app-brand,
.app-topbar-brand {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
    color: white;
    text-decoration: none;
}

.app-brand:hover,
.app-topbar-brand:hover {
    color: white;
}

.app-brand-mark {
    width: 34px;
    height: 34px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    color: var(--color-primary);
    background: white;
    border-radius: 9px;
    font-size: 18px;
    font-weight: 850;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.app-brand-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.app-brand-copy strong {
    overflow: hidden;
    font-size: 15px;
    letter-spacing: -0.015em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-brand-copy small {
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 10px;
    font-weight: 550;
}

.app-sidebar-close {
    display: none;
    width: 42px;
    min-height: 42px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: white;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.17);
    border-radius: 9px;
    font-size: 24px;
    line-height: 1;
}

.main-nav {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 14px 10px 24px;
}

.nav-section-label {
    padding: 0 10px;
    margin: 5px 0 7px;
    color: rgba(255, 255, 255, 0.48);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.nav-section-label-admin {
    margin-top: 21px;
}

.nav-primary {
    display: grid;
    gap: 4px;
}

.nav-link,
.nav-admin-toggle {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    color: rgba(255, 255, 255, 0.82);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.2;
    text-align: left;
    text-decoration: none;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.nav-link:hover,
.nav-admin-toggle:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

.nav-link.active,
.nav-link[aria-current="page"] {
    color: white;
    background: rgba(255, 255, 255, 0.13);
    border-color: rgba(255, 255, 255, 0.1);
}

.nav-link-icon {
    width: 25px;
    height: 25px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    color: #d7e9ff;
    background: rgba(255, 255, 255, 0.09);
    border-radius: 7px;
    font-size: 10px;
    font-weight: 850;
}

.nav-link.active .nav-link-icon,
.nav-link[aria-current="page"] .nav-link-icon {
    color: var(--color-primary-dark);
    background: white;
}

.nav-admin {
    display: grid;
    gap: 5px;
}

.nav-admin-toggle {
    cursor: pointer;
}

.nav-admin.active .nav-admin-toggle {
    color: white;
}

.nav-admin-arrow {
    margin-left: auto;
    color: rgba(255, 255, 255, 0.62);
    font-size: 19px;
    line-height: 1;
    transform: rotate(0);
    transition: transform 0.16s ease;
}

.nav-admin.admin-open .nav-admin-arrow {
    transform: rotate(90deg);
}

.nav-admin-menu {
    display: none;
    gap: 3px;
    padding: 3px 0 5px 45px;
}

.nav-admin.admin-open .nav-admin-menu {
    display: grid;
}

.nav-admin-menu a {
    min-height: 34px;
    display: flex;
    align-items: center;
    padding: 7px 10px;
    color: rgba(255, 255, 255, 0.67);
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.nav-admin-menu a:hover {
    color: white;
    background: rgba(255, 255, 255, 0.07);
}

.nav-admin-menu a.active,
.nav-admin-menu a[aria-current="page"] {
    color: white;
    background: rgba(255, 255, 255, 0.12);
}

.app-frame {
    min-width: 0;
    min-height: 100vh;
    margin-left: var(--sidebar-width);
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 850;
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.025);
    backdrop-filter: blur(12px);
}

.app-topbar-inner {
    width: 100%;
    max-width: var(--page-max-width);
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 0 28px;
    margin: 0 auto;
}

.app-topbar-brand {
    display: none;
    color: var(--color-primary-dark);
}

.app-topbar-brand:hover {
    color: var(--color-primary);
}

.app-topbar-context {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.app-topbar-eyebrow {
    color: var(--color-muted);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.app-current-page {
    overflow: hidden;
    margin-top: 2px;
    color: #243b53;
    font-size: 14px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-account-menu {
    position: relative;
    flex: 0 0 auto;
}

.app-account-toggle {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary-dark);
    background: #f5f8fc;
    border: 1px solid var(--color-border-strong);
    border-radius: 50%;
    cursor: pointer;
    list-style: none;
    transition: background-color .15s ease, border-color .15s ease;
}

.app-account-toggle::-webkit-details-marker {
    display: none;
}

.app-account-toggle:hover,
.app-account-menu[open] .app-account-toggle {
    background: var(--color-primary-soft);
    border-color: #adc5df;
}

.app-account-icon,
.app-account-icon svg {
    width: 20px;
    height: 20px;
}

.app-account-icon svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-account-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    min-width: 164px;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 9px;
    box-shadow: var(--shadow-md);
}

.app-account-popover a,
.app-account-popover button {
    width: 100%;
    min-height: 32px;
    display: flex;
    align-items: center;
    padding: 6px 9px;
    color: #344054;
    background: transparent;
    border: 0;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 650;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.app-account-popover a:hover,
.app-account-popover a:focus-visible,
.app-account-popover button:hover,
.app-account-popover button:focus-visible {
    color: var(--color-primary-dark);
    background: var(--color-primary-soft);
}

.app-account-popover form {
    margin: 0;
    border-top: 1px solid var(--color-border);
}

.mobile-menu-toggle {
    min-height: 42px;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--color-primary-dark);
    background: white;
    border: 1px solid var(--color-border-strong);
    border-radius: 9px;
    font-size: 13px;
    font-weight: 700;
}

.mobile-menu-icon {
    width: 18px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.mobile-menu-icon i {
    width: 100%;
    height: 2px;
    display: block;
    background: currentColor;
    border-radius: 2px;
}

.app-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: none;
    width: 100%;
    height: 100%;
    padding: 0;
    background: rgba(15, 23, 42, 0.52);
    border: 0;
    border-radius: 0;
    opacity: 0;
}

main {
    width: 100%;
    max-width: var(--page-max-width);
    padding: 28px 28px 48px;
    margin: 0 auto;
}

/* =========================================================
   En-têtes, barres d’outils et états
   ========================================================= */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-5);
    margin-bottom: var(--space-5);
}

.page-header h2 {
    margin-bottom: var(--space-1);
}

.page-header p {
    margin-bottom: 0;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.toolbar h3 {
    margin-bottom: 0;
}

.toolbar-actions,
.action-buttons {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.toolbar-actions form,
.action-buttons form {
    display: inline-flex;
}

.count {
    color: #344054;
    font-weight: 750;
}

.muted {
    color: var(--color-muted);
    font-size: 0.82rem;
}

.info {
    margin: var(--space-4) 0 0;
    color: var(--color-muted);
    font-size: 0.85rem;
}

.success,
.error {
    padding: 12px 14px;
    margin-bottom: var(--space-4);
    border: 1px solid;
    border-radius: var(--radius-md);
    font-weight: 700;
}

.success {
    color: #116149;
    background: var(--color-success-soft);
    border-color: #abefc6;
}

.error {
    color: #912018;
    background: var(--color-danger-soft);
    border-color: #fecdca;
}

.empty {
    padding: 28px 18px;
    color: var(--color-muted);
    background: #fafcff;
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-md);
    text-align: center;
}

.badge {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    padding: 3px 8px;
    color: #475467;
    background: #eef2f6;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
}

.badge-success {
    color: #116149;
    background: var(--color-success-soft);
}

.badge-danger {
    color: #912018;
    background: var(--color-danger-soft);
}

.badge-warning {
    color: #80520f;
    background: var(--color-warning-soft);
}

.hidden,
[hidden] {
    display: none !important;
}

/* =========================================================
   Surfaces et indicateurs
   ========================================================= */

.card-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.card {
    min-width: 0;
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

a.card {
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

a.card:hover {
    color: inherit;
    border-color: #b9cbe0;
    box-shadow: 0 7px 20px rgba(16, 24, 40, 0.08);
    transform: translateY(-1px);
}

.card h3 {
    color: var(--color-primary-dark);
}

.detail-card {
    margin-bottom: var(--space-5);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4) var(--space-8);
}

.detail-grid > * {
    min-width: 0;
}

.detail-grid > div > input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.detail-grid > div > select,
.detail-grid > div > textarea {
    width: 100%;
}

.detail-label {
    display: block;
    margin-bottom: var(--space-1);
    color: var(--color-muted);
    font-size: 12px;
    font-weight: 700;
}

.detail-value {
    display: block;
    color: var(--color-primary);
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.2;
}

.detail-grid .detail-value {
    color: var(--color-text);
    font-size: 1rem;
    font-weight: 650;
}

.dashboard-metric {
    min-height: 132px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-bottom: 0;
}

.dashboard-metric h3 {
    margin-bottom: 6px;
    color: #344054;
    font-size: 0.88rem;
}

.dashboard-metric .detail-value {
    margin-bottom: 5px;
    font-size: clamp(1.55rem, 2.5vw, 2rem);
}

.dashboard-metric .muted {
    line-height: 1.35;
}

.dashboard-more.card {
    padding: 0;
    overflow: hidden;
}

.dashboard-more > summary {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 13px 17px;
    color: #344054;
    cursor: pointer;
    font-size: 13px;
    font-weight: 750;
    list-style: none;
}

.dashboard-more > summary::-webkit-details-marker {
    display: none;
}

.dashboard-more > summary::after {
    content: "+";
    width: 26px;
    height: 26px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    color: var(--color-primary);
    background: var(--color-primary-soft);
    border-radius: 7px;
    font-size: 17px;
    line-height: 1;
}

.dashboard-more[open] > summary {
    border-bottom: 1px solid var(--color-border);
}

.dashboard-more[open] > summary::after {
    content: "−";
}

.dashboard-more > .card-container {
    padding: 14px;
    margin: 0;
    background: #f8fafc;
}

/* =========================================================
   Formulaires et boutons
   ========================================================= */

form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

label {
    color: #344054;
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    max-width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    color: var(--color-text);
    background: white;
    border: 1px solid var(--color-border-strong);
    border-radius: 9px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.02);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
    min-height: 92px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #98a2b3;
}

input:hover,
select:hover,
textarea:hover {
    border-color: #b6c3d2;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 168, 0.12);
}

input[type="checkbox"],
input[type="radio"] {
    width: 17px;
    height: 17px;
    min-height: 0;
    padding: 0;
    accent-color: var(--color-primary-light);
    box-shadow: none;
}

.search-form {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* Les actions d'une barre de filtres doivent s'aligner sur les champs,
   et non être centrées sur la hauteur combinée libellé + champ. */
.search-form.filter-bar {
    align-items: flex-end;
}

.search-form.filter-bar > button,
.search-form.filter-bar > .button {
    margin-bottom: 0;
}

.search-form-wrapper {
    display: flex;
    min-width: 0;
}

.search-form input[type="text"] {
    min-width: min(320px, 100%);
}

.dossiers-toolbar-actions {
    flex-wrap: nowrap;
    justify-content: flex-end;
}

.dossiers-toolbar-actions form {
    align-items: center;
    flex-wrap: nowrap;
}

.dossiers-page-size-form,
.dossiers-delete-form {
    flex: 0 0 auto;
}

.dossiers-search-form {
    flex: 1 1 470px;
    min-width: 390px;
}

.dossiers-search-form input[type="text"] {
    flex: 1 1 330px;
    width: 330px;
    min-width: 260px;
}

.dossiers-search-form button,
.dossiers-search-form .button {
    flex: 0 0 auto;
}

.form-field {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field label {
    margin: 0;
}

.checkbox-column {
    width: 44px;
    text-align: center;
}

.checkbox-column input {
    width: 17px;
}

button,
.button,
.button-danger {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 14px;
    color: white;
    background: var(--color-primary);
    border: 1px solid var(--color-primary);
    border-radius: 9px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

button:hover,
.button:hover {
    color: white;
    background: var(--color-primary-light);
    border-color: var(--color-primary-light);
    box-shadow: 0 3px 8px rgba(21, 62, 117, 0.16);
}

button:active,
.button:active {
    transform: translateY(1px);
}

.button-secondary {
    color: #344054;
    background: white;
    border-color: var(--color-border-strong);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.button-secondary:hover,
.button-secondary:focus-visible {
    color: var(--color-primary);
    background: var(--color-primary-soft);
    border-color: #adc5df;
}

.button-ghost {
    color: var(--color-primary);
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

.button-ghost:hover,
.button-ghost:focus-visible {
    color: var(--color-primary-dark);
    background: var(--color-primary-soft);
    border-color: transparent;
    box-shadow: none;
}

.button-danger {
    color: white;
    background: var(--color-danger);
    border-color: var(--color-danger);
}

.button-danger:hover,
.button-danger:focus-visible {
    color: white;
    background: var(--color-danger-dark);
    border-color: var(--color-danger-dark);
}

button:disabled,
.button:disabled,
.button[aria-disabled="true"] {
    opacity: 0.52;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* =========================================================
   Tableaux
   ========================================================= */

.table-wrapper,
.dashboard-results-table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.025);
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    scrollbar-color: #b7c2d0 transparent;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
    line-height: 1.4;
    text-align: left;
    vertical-align: middle;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: #475467;
    background: var(--color-table-header);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.025em;
    white-space: nowrap;
}

th a {
    color: inherit;
    text-decoration: none;
}

th a:hover {
    color: var(--color-primary);
}

tbody tr {
    transition: background-color 0.12s ease;
}

tbody tr:hover {
    background: var(--color-table-hover);
}

tbody tr:last-child td {
    border-bottom: 0;
}

td form {
    display: inline-flex;
}

td .button,
td button {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 12px;
}

.sortable-table,
.dashboard-results-table {
    width: 100%;
    table-layout: auto;
}

.sortable-header {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.sortable-header:hover,
.sortable-header:focus-visible {
    color: var(--color-primary);
    background: #e7eff8;
}

.sort-indicator {
    min-width: 10px;
    display: inline-block;
    margin-left: 5px;
    color: var(--color-muted);
    font-size: 10px;
    vertical-align: middle;
}

.sortable-header[data-sort-direction="asc"] .sort-indicator,
.sortable-header[data-sort-direction="desc"] .sort-indicator {
    color: var(--color-primary);
    font-weight: 850;
}

.dashboard-results-table td:last-child,
.dashboard-results-table th:last-child {
    text-align: center;
    white-space: nowrap;
}

/* =========================================================
   Pagination
   ========================================================= */

.dashboard-pagination,
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: 9px 10px;
    margin: 10px 0 12px;
    color: #475467;
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

.dashboard-pagination-left,
.dashboard-pagination-right,
.pagination-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.dashboard-pagination-right {
    justify-content: flex-end;
    margin-left: auto;
}

.pagination-summary {
    flex: 0 0 auto;
    color: var(--color-muted);
    font-size: 12px;
    white-space: nowrap;
}

.pagination-actions {
    justify-content: flex-end;
    margin-left: auto;
}

.pagination-jump {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    margin: 0;
    white-space: nowrap;
}

.pagination-jump label,
.dashboard-pagination-label {
    margin: 0;
    color: var(--color-muted);
    font-size: 11px;
    font-weight: 700;
}

.dashboard-rows-per-page,
.dashboard-page-input,
.pagination-jump input[type="number"] {
    min-width: 68px;
    min-height: 36px;
    height: 36px;
    padding: 5px 8px;
    font-size: 12px;
}

.dashboard-page-input {
    width: 68px;
    text-align: center;
}

.pagination-jump input[type="number"] {
    width: 64px;
    text-align: center;
}

.pagination-go {
    min-height: 36px;
    padding: 7px 10px;
}

.pagination-button {
    min-width: 94px;
    white-space: nowrap;
}

.pagination-button.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.dashboard-pagination .button,
.dashboard-pagination button {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 12px;
}

.dashboard-page-info {
    color: var(--color-muted);
    font-size: 12px;
}

/* =========================================================
   Notifications
   ========================================================= */

.app-toast-region {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 5000;
    width: min(390px, calc(100vw - 28px));
    display: grid;
    gap: 9px;
    pointer-events: none;
}

.app-toast {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) 42px;
    gap: 10px;
    align-items: start;
    padding: 13px 10px 13px 13px;
    color: #145a43;
    background: #f0fdf4;
    border: 1px solid #a9dac7;
    border-left: 4px solid var(--color-success);
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(16, 24, 40, 0.18);
    opacity: 0;
    transform: translateX(18px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: auto;
}

.app-toast.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.app-toast.is-leaving {
    opacity: 0;
    transform: translateX(18px);
}

.app-toast-error {
    color: #8f1d18;
    background: var(--color-danger-soft);
    border-color: #f4b8b3;
    border-left-color: var(--color-danger);
}

.app-toast-icon {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    color: white;
    background: var(--color-success);
    border-radius: 50%;
    font-size: 14px;
    font-weight: 850;
}

.app-toast-error .app-toast-icon {
    background: var(--color-danger);
}

.app-toast-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.app-toast-content strong {
    color: inherit;
    font-size: 13px;
}

.app-toast-content span {
    color: inherit;
    font-size: 12px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.app-toast-close {
    width: 42px;
    min-height: 42px;
    padding: 0;
    place-items: center;
    color: currentColor;
    background: transparent;
    border: 0;
    border-radius: 8px;
    box-shadow: none;
    font-size: 21px;
    line-height: 1;
}

.app-toast-close:hover,
.app-toast-close:focus-visible {
    color: currentColor;
    background: rgba(16, 24, 40, 0.08);
    border: 0;
    box-shadow: none;
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1199px) {
    main {
        padding-inline: 22px;
    }

    .app-topbar-inner {
        padding-inline: 22px;
    }
}

@media (max-width: 1023px) {
    .app-sidebar {
        width: min(320px, 88vw);
        box-shadow: var(--shadow-md);
        transform: translateX(-102%);
        transition: transform 0.2s ease;
    }

    body.nav-drawer-open .app-sidebar {
        transform: translateX(0);
    }

    .app-sidebar-close {
        display: inline-flex;
    }

    .app-sidebar-backdrop {
        display: block;
        visibility: hidden;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }

    body.nav-drawer-open .app-sidebar-backdrop {
        visibility: visible;
        opacity: 1;
    }

    .app-frame {
        margin-left: 0;
    }

    .app-topbar-brand,
    .mobile-menu-toggle {
        display: inline-flex;
    }

    .app-topbar-context {
        flex: 1;
    }

    main {
        padding-top: 22px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .app-topbar-inner,
    main {
        padding-inline: 14px;
    }

    main {
        padding-top: 18px;
        padding-bottom: 36px;
    }

    .page-header,
    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .page-header {
        gap: var(--space-3);
    }

    .toolbar-actions,
    .action-buttons {
        align-items: stretch;
    }

    .search-form {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
    }

    .search-form > :not(input[type="hidden"]),
    .search-form .button,
    .search-form button,
    .search-form select,
    .search-form input:not([type="hidden"]) {
        width: 100%;
        min-width: 0;
    }

    .dossiers-search-form {
        min-width: 0;
    }

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

    th,
    td {
        padding: 10px;
        font-size: 12px;
    }

    .table-wrapper:has(.data-table-responsive) {
        overflow: visible;
        background: transparent;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .data-table-responsive,
    .data-table-responsive tbody,
    .data-table-responsive tr,
    .data-table-responsive td {
        display: block;
        width: 100%;
    }

    .data-table-responsive {
        background: transparent;
    }

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

    .data-table-responsive tbody {
        display: grid;
        gap: 10px;
    }

    .data-table-responsive tr {
        overflow: hidden;
        background: white;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
    }

    .data-table-responsive td {
        display: grid;
        grid-template-columns: minmax(105px, 0.8fr) minmax(0, 1.2fr);
        gap: 12px;
        align-items: start;
        overflow-wrap: anywhere;
        border-bottom: 1px solid var(--color-border);
    }

    .data-table-responsive td::before {
        content: attr(data-label);
        color: var(--color-muted);
        font-size: 11px;
        font-weight: 800;
        letter-spacing: 0.02em;
        text-transform: uppercase;
    }

    .data-table-responsive td:last-child {
        border-bottom: 0;
    }

    .data-table-responsive td form {
        justify-self: start;
    }

    .dashboard-pagination,
    .pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .dashboard-pagination-left,
    .dashboard-pagination-right,
    .pagination-actions {
        width: 100%;
    }

    .dashboard-pagination-right,
    .pagination-actions {
        justify-content: space-between;
        margin-left: 0;
    }

    .pagination-button {
        min-width: 0;
        flex: 1 1 90px;
    }
}

@media (max-width: 620px) {
    .app-topbar {
        min-height: 58px;
    }

    .app-topbar-inner {
        min-height: 58px;
        gap: 10px;
        padding-inline: 12px;
    }

    .app-topbar-context {
        display: none;
    }

    .app-topbar-brand {
        flex: 1;
    }

    .app-topbar-brand .app-brand-mark {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .app-topbar-brand strong {
        overflow: hidden;
        font-size: 14px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-menu-toggle {
        min-height: 42px;
        padding-inline: 10px;
    }

    main {
        padding: 14px 10px 30px;
    }

    h2 {
        font-size: 1.38rem;
    }

    .card {
        padding: 15px;
        margin-bottom: 13px;
        border-radius: 10px;
    }

    .card-container {
        gap: 9px;
        margin-bottom: 13px;
    }

    .card-container .card {
        margin-bottom: 0;
    }

    .card-container .detail-value {
        font-size: 1.35rem;
    }

    .toolbar-actions,
    .action-buttons {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .toolbar-actions > *,
    .action-buttons > *,
    .toolbar-actions form,
    .action-buttons form,
    .toolbar-actions .button,
    .action-buttons .button,
    .toolbar-actions button,
    .action-buttons button {
        width: 100%;
    }

    .app-toast-region {
        top: 8px;
        right: 8px;
        width: calc(100vw - 16px);
    }
}

@media (max-width: 430px) {
    .card-container {
        grid-template-columns: 1fr;
    }

    .dashboard-pagination-right {
        gap: 6px;
    }

    .pagination-jump {
        flex: 1 1 100%;
        justify-content: center;
        order: 3;
    }

    .pagination-actions {
        gap: 6px;
    }
}

/* Corrections de confinement mobile pour les libellés masqués et les fiches
   détaillées contenant des tableaux à largeur intrinsèque importante. */
@media (max-width: 760px) {
    label.sr-only {
        position: absolute;
        width: 1px !important;
        min-width: 1px !important;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    .record-page,
    .record-page > *,
    .record-grid,
    .record-grid > *,
    .record-stack,
    .record-stack > * {
        min-width: 0;
        max-width: 100%;
    }

    .record-hero,
    .record-card,
    .record-section {
        width: 100%;
    }

    .record-section .table-wrapper {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
    }
}

@media (pointer: coarse) {
    button,
    .button,
    .button-danger,
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    select {
        min-height: 44px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
