/* =========================================================================
   Design system
   Les couleurs de marque sont injectees par le layout depuis les parametres
   de la societe : --brand et --brand-accent sont surchargees en ligne sur
   <html>, tout le reste en derive.
   ========================================================================= */

:root {
    --brand: #1668b3;
    --brand-accent: #57b743;

    --brand-050: color-mix(in srgb, var(--brand) 6%, #ffffff);
    --brand-100: color-mix(in srgb, var(--brand) 12%, #ffffff);
    --brand-200: color-mix(in srgb, var(--brand) 24%, #ffffff);
    --brand-600: color-mix(in srgb, var(--brand) 88%, #000000);
    --brand-700: color-mix(in srgb, var(--brand) 72%, #000000);

    --ink-900: #0f172a;
    --ink-800: #1e293b;
    --ink-700: #334155;
    --ink-600: #475569;
    --ink-500: #64748b;
    --ink-400: #94a3b8;
    --ink-300: #cbd5e1;
    --ink-200: #e2e8f0;
    --ink-100: #f1f5f9;
    --ink-050: #f8fafc;

    --success: #15803d;
    --success-bg: #dcfce7;
    --warning: #b45309;
    --warning-bg: #fef3c7;
    --danger: #b91c1c;
    --danger-bg: #fee2e2;
    --info: #1d4ed8;
    --info-bg: #dbeafe;

    --surface: #ffffff;
    --canvas: #f6f8fb;
    --border: var(--ink-200);
    --border-strong: var(--ink-300);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

    --sidebar-w: 252px;
    --header-h: 60px;

    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

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

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink-800);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4, h5 {
    margin: 0;
    font-weight: 650;
    color: var(--ink-900);
    letter-spacing: -0.01em;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 0.75rem; }
p:last-child { margin-bottom: 0; }

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover { text-decoration: underline; }

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
}

code, .mono {
    font-family: var(--mono);
    font-size: 0.9em;
}

/* ============================ Mise en page ============================= */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--ink-900);
    color: var(--ink-300);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    padding: 0.75rem 0.875rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: var(--header-h);
}

/* Bloc de marque (voir templates/partials/_brand.html.twig) ---------------- */

.brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
}

.brand__mark {
    border-radius: 9px;
    background: linear-gradient(135deg, var(--brand), var(--brand-accent));
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.brand__text { min-width: 0; }

.brand__name {
    display: block;
    font-weight: 680;
    font-size: 0.875rem;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--ink-900);
}

.brand__tagline {
    display: block;
    font-size: 0.6875rem;
    color: var(--ink-500);
    line-height: 1.2;
}

/* Le logo fourni est large et sur fond blanc : sur le menu sombre, il est posé
   sur une plaque claire pour rester lisible sans le détourer. */
.brand--logo img {
    display: block;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.brand--sidebar.brand--logo {
    background: #fff;
    border-radius: 8px;
    padding: 6px 9px;
    width: 100%;
}

.brand--sidebar .brand__name { color: #fff; }
.brand--sidebar .brand__tagline { color: var(--ink-500); }

.sidebar__nav {
    padding: 0.75rem 0.625rem 1.5rem;
    flex: 1;
}

.nav-section {
    margin-bottom: 0.25rem;
}

.nav-section__title {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ink-600);
    font-weight: 650;
    padding: 0.875rem 0.625rem 0.375rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.625rem;
    border-radius: var(--radius-sm);
    color: var(--ink-300);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
    text-decoration: none;
    margin-bottom: 1px;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    text-decoration: none;
}

.nav-link.is-active {
    background: var(--brand);
    color: #fff;
    font-weight: 600;
}

.nav-link__icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    opacity: 0.85;
}

.nav-link.is-active .nav-link__icon { opacity: 1; }

.nav-link__badge {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    border-radius: 999px;
    padding: 0.0625rem 0.4375rem;
    font-size: 0.6875rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.nav-sub {
    padding-left: 1.6875rem;
}

.nav-sub .nav-link {
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
    font-size: 0.78125rem;
}

.main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.header {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 40;
}

.header__search {
    flex: 1;
    max-width: 460px;
    position: relative;
}

.header__actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.content {
    padding: 1.5rem;
    flex: 1;
    max-width: 1600px;
    width: 100%;
}

.page-head {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.page-head__text { min-width: 0; }

.page-head__sub {
    color: var(--ink-500);
    font-size: 0.8125rem;
    margin-top: 0.125rem;
}

.page-head__actions {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ============================== Composants ============================= */

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

.card__head {
    padding: 0.875rem 1.125rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.card__title {
    font-size: 0.9375rem;
    font-weight: 650;
    color: var(--ink-900);
}

.card__actions { margin-left: auto; display: flex; gap: 0.5rem; }

.card__body { padding: 1.125rem; }
.card__body--flush { padding: 0; }

.card__foot {
    padding: 0.75rem 1.125rem;
    border-top: 1px solid var(--border);
    background: var(--ink-050);
    border-radius: 0 0 var(--radius) var(--radius);
}

.grid {
    display: grid;
    gap: 1rem;
}

.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }

.stack { display: grid; gap: 1rem; }
.stack--sm { gap: 0.625rem; }

/* KPI ------------------------------------------------------------------- */

.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.125rem;
    box-shadow: var(--shadow-xs);
    position: relative;
    overflow: hidden;
}

.kpi::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--brand);
    opacity: 0.9;
}

.kpi--accent::before { background: var(--brand-accent); }
.kpi--warning::before { background: var(--warning); }
.kpi--danger::before { background: var(--danger); }
.kpi--success::before { background: var(--success); }

.kpi__label {
    font-size: 0.75rem;
    color: var(--ink-500);
    font-weight: 550;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.kpi__value {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--ink-900);
    line-height: 1.15;
    margin-top: 0.3125rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.kpi__meta {
    font-size: 0.75rem;
    color: var(--ink-500);
    margin-top: 0.25rem;
}

/* Boutons --------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4375rem;
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink-800);
    font-size: 0.8125rem;
    font-weight: 550;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
    white-space: nowrap;
    line-height: 1.3;
}

.btn:hover {
    background: var(--ink-050);
    text-decoration: none;
    border-color: var(--ink-400);
}

.btn:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.btn:disabled,
.btn.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn--primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.btn--primary:hover {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #fff;
}

.btn--accent {
    background: var(--brand-accent);
    border-color: var(--brand-accent);
    color: #fff;
}

.btn--accent:hover { filter: brightness(0.94); color: #fff; }

.btn--danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn--danger:hover { filter: brightness(0.92); color: #fff; }

.btn--ghost {
    border-color: transparent;
    background: transparent;
    color: var(--ink-600);
}

.btn--ghost:hover { background: var(--ink-100); border-color: transparent; }

.btn--sm { padding: 0.3125rem 0.625rem; font-size: 0.75rem; }
.btn--lg { padding: 0.6875rem 1.25rem; font-size: 0.875rem; }
.btn--block { width: 100%; }
.btn--icon { padding: 0.4375rem; }

.btn__icon { width: 15px; height: 15px; flex-shrink: 0; }

.btn-group { display: inline-flex; gap: 0.375rem; flex-wrap: wrap; }

/* Badges ---------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    padding: 0.1875rem 0.5rem;
    border-radius: 999px;
    font-size: 0.71875rem;
    font-weight: 600;
    line-height: 1.35;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge--neutral { background: var(--ink-100); color: var(--ink-700); border-color: var(--ink-200); }
.badge--muted { background: var(--ink-100); color: var(--ink-500); border-color: var(--ink-200); }
.badge--info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 22%, #ffffff); }
.badge--success { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb, var(--success) 22%, #ffffff); }
.badge--warning { background: var(--warning-bg); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 22%, #ffffff); }
.badge--danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 22%, #ffffff); }

.badge__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* Tableaux -------------------------------------------------------------- */

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.table th {
    text-align: left;
    padding: 0.625rem 0.875rem;
    font-weight: 600;
    font-size: 0.71875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-500);
    background: var(--ink-050);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 0.6875rem 0.875rem;
    border-bottom: 1px solid var(--ink-100);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--brand-050); }

.table--compact td { padding: 0.5rem 0.75rem; }

.table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.table .shrink { width: 1%; white-space: nowrap; }

.table__ref {
    font-family: var(--mono);
    font-size: 0.78125rem;
    font-weight: 600;
    color: var(--brand);
}

.table__primary { font-weight: 600; color: var(--ink-900); }
.table__meta { color: var(--ink-500); font-size: 0.75rem; }

/* Formulaires ----------------------------------------------------------- */

.field { margin-bottom: 0.875rem; }
.field:last-child { margin-bottom: 0; }

.field__label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ink-700);
    margin-bottom: 0.3125rem;
}

.field__label .req { color: var(--danger); margin-left: 2px; }

.field__help {
    font-size: 0.71875rem;
    color: var(--ink-500);
    margin-top: 0.25rem;
}

.field__error {
    font-size: 0.71875rem;
    color: var(--danger);
    margin-top: 0.25rem;
    font-weight: 550;
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 0.5rem 0.6875rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--ink-900);
    background: var(--surface);
    transition: border-color 0.12s, box-shadow 0.12s;
    /* 16px minimum sur mobile : en dessous, iOS zoome sur le champ au focus. */
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent);
}

.input[readonly] { background: var(--ink-050); color: var(--ink-600); }

.textarea { min-height: 76px; resize: vertical; }

.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.625rem center;
    padding-right: 1.875rem;
}

.is-invalid .input,
.is-invalid .select,
.is-invalid .textarea,
.input.is-invalid,
.select.is-invalid {
    border-color: var(--danger);
}

.field-row {
    display: grid;
    gap: 0.875rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.field-row--3 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.8125rem;
    cursor: pointer;
}

.checkbox input[type="checkbox"],
.checkbox input[type="radio"] {
    width: 16px;
    height: 16px;
    margin: 2px 0 0;
    accent-color: var(--brand);
    flex-shrink: 0;
    cursor: pointer;
}

.fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 0 0 1rem;
}

.fieldset__legend {
    font-size: 0.75rem;
    font-weight: 680;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-500);
    padding: 0 0.4375rem;
    margin-left: -0.4375rem;
}

.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }

.input-group__addon {
    display: flex;
    align-items: center;
    padding: 0 0.6875rem;
    background: var(--ink-100);
    border: 1px solid var(--border-strong);
    border-left: 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.8125rem;
    color: var(--ink-600);
    font-weight: 550;
    white-space: nowrap;
}

/* Recherche ------------------------------------------------------------- */

.search {
    position: relative;
    display: flex;
    align-items: center;
}

.search__icon {
    position: absolute;
    left: 0.625rem;
    width: 15px;
    height: 15px;
    color: var(--ink-400);
    pointer-events: none;
}

.search .input { padding-left: 2rem; }

.search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 420px;
    overflow-y: auto;
    z-index: 80;
    display: none;
}

.search-results.is-open { display: block; }

.search-results__group {
    padding: 0.4375rem 0.75rem 0.1875rem;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-400);
    font-weight: 650;
}

.search-results__item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    color: var(--ink-800);
    text-decoration: none;
    border-left: 2px solid transparent;
}

.search-results__item:hover,
.search-results__item.is-highlighted {
    background: var(--brand-050);
    border-left-color: var(--brand);
    text-decoration: none;
}

.search-results__empty {
    padding: 1rem 0.75rem;
    color: var(--ink-500);
    font-size: 0.8125rem;
    text-align: center;
}

/* Alertes --------------------------------------------------------------- */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.75rem 0.9375rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    border: 1px solid transparent;
    margin-bottom: 1rem;
}

.alert__icon { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }

.alert--success { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb, var(--success) 20%, #ffffff); }
.alert--danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 20%, #ffffff); }
.alert--warning { background: var(--warning-bg); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 20%, #ffffff); }
.alert--info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 20%, #ffffff); }

.alert a { color: inherit; font-weight: 600; text-decoration: underline; }

/* Etat vide ------------------------------------------------------------- */

.empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--ink-500);
}

.empty__icon {
    width: 42px;
    height: 42px;
    color: var(--ink-300);
    margin: 0 auto 0.75rem;
}

.empty__title {
    font-size: 0.9375rem;
    font-weight: 620;
    color: var(--ink-700);
    margin-bottom: 0.25rem;
}

.empty__text { font-size: 0.8125rem; max-width: 380px; margin: 0 auto 1rem; }

/* Frise de suivi -------------------------------------------------------- */

.timeline { position: relative; padding-left: 1.75rem; }

.timeline::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--ink-200);
}

.timeline__item { position: relative; padding-bottom: 1.125rem; }
.timeline__item:last-child { padding-bottom: 0; }

.timeline__dot {
    position: absolute;
    left: -1.75rem;
    top: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--ink-300);
    display: grid;
    place-items: center;
}

.timeline__dot svg { width: 10px; height: 10px; color: #fff; }

.timeline__item.is-done .timeline__dot { background: var(--success); border-color: var(--success); }
.timeline__item.is-current .timeline__dot { background: var(--brand); border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.timeline__item.is-danger .timeline__dot { background: var(--danger); border-color: var(--danger); }

.timeline__title { font-weight: 600; color: var(--ink-900); font-size: 0.875rem; }
.timeline__meta { font-size: 0.75rem; color: var(--ink-500); }
.timeline__item.is-pending .timeline__title { color: var(--ink-400); font-weight: 500; }

/* Listes de definitions ------------------------------------------------- */

.dl { display: grid; gap: 0.625rem; }

.dl__row {
    display: grid;
    grid-template-columns: minmax(110px, 38%) 1fr;
    gap: 0.75rem;
    font-size: 0.8125rem;
    align-items: baseline;
}

.dl__key { color: var(--ink-500); }
.dl__val { color: var(--ink-900); font-weight: 550; min-width: 0; overflow-wrap: anywhere; }

/* Divers ---------------------------------------------------------------- */

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 0.71875rem;
    font-weight: 680;
    flex-shrink: 0;
}

.avatar--sm { width: 26px; height: 26px; font-size: 0.625rem; }

.progress {
    height: 5px;
    background: var(--ink-200);
    border-radius: 999px;
    overflow: hidden;
}

.progress__bar {
    height: 100%;
    background: var(--brand-accent);
    border-radius: 999px;
    transition: width 0.3s;
}

.toolbar {
    display: flex;
    gap: 0.625rem;
    flex-wrap: wrap;
    align-items: flex-end;
    padding: 0.875rem 1.125rem;
    border-bottom: 1px solid var(--border);
    background: var(--ink-050);
    border-radius: var(--radius) var(--radius) 0 0;
}

.toolbar .field { margin-bottom: 0; }
.toolbar__grow { flex: 1; min-width: 190px; }

.pagination {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.pagination__info { font-size: 0.8125rem; color: var(--ink-500); }
.pagination__pages { display: flex; gap: 0.1875rem; margin-left: auto; flex-wrap: wrap; }

.pagination__page {
    min-width: 30px;
    height: 30px;
    padding: 0 0.4375rem;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 0.8125rem;
    color: var(--ink-700);
    font-variant-numeric: tabular-nums;
}

.pagination__page:hover { background: var(--ink-100); text-decoration: none; }
.pagination__page.is-active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 620; }
.pagination__page.is-gap { border: 0; background: transparent; pointer-events: none; }

.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
    overflow-x: auto;
}

.tab {
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 550;
    color: var(--ink-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
}

.tab:hover { color: var(--ink-800); text-decoration: none; }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 620; }

.dropdown { position: relative; }

.dropdown__menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.3125rem;
    z-index: 70;
    display: none;
}

.dropdown__menu.is-open { display: block; }

.dropdown__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4375rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--ink-700);
    width: 100%;
    background: none;
    border: 0;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
}

.dropdown__item:hover { background: var(--ink-100); text-decoration: none; color: var(--ink-900); }
.dropdown__item--danger { color: var(--danger); }
.dropdown__divider { height: 1px; background: var(--border); margin: 0.3125rem 0; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    padding: 0.25rem 0.5625rem;
    border-radius: 999px;
    background: var(--ink-100);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--ink-700);
}

.chip__remove { color: var(--ink-400); display: grid; place-items: center; }
.chip__remove:hover { color: var(--danger); }

/* Utilitaires ----------------------------------------------------------- */

.muted { color: var(--ink-500); }
.small { font-size: 0.75rem; }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-brand { color: var(--brand); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.3125rem; }
.gap-2 { gap: 0.625rem; }
.gap-3 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }
.ml-auto { margin-left: auto; }
.mt-1 { margin-top: 0.3125rem; }
.mt-2 { margin-top: 0.625rem; }
.mt-3 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.625rem; }
.mb-3 { margin-bottom: 1rem; }
.hidden { display: none !important; }

.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;
}

/* Menu mobile ----------------------------------------------------------- */

.sidebar-toggle { display: none; }
.sidebar-backdrop { display: none; }

.mobile-only { display: none; }

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

@media (max-width: 1100px) {
    .grid--sidebar { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: var(--shadow-lg);
    }

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

    .main { margin-left: 0; }

    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: var(--radius-sm);
        border: 1px solid var(--border);
        background: var(--surface);
        color: var(--ink-700);
        cursor: pointer;
        flex-shrink: 0;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 55;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.22s;
    }

    .sidebar-backdrop.is-open { opacity: 1; pointer-events: auto; }

    .content { padding: 1rem; }
    .header { padding: 0 0.875rem; gap: 0.625rem; }
    .mobile-only { display: block; }
}

@media (max-width: 640px) {
    /* Sur telephone, tout champ sous 16px declenche un zoom automatique iOS
       au focus, qui casse la mise en page du formulaire. */
    .input,
    .select,
    .textarea {
        font-size: 16px;
        padding: 0.625rem 0.6875rem;
    }

    h1 { font-size: 1.25rem; }

    .page-head { gap: 0.75rem; }
    .page-head__actions { margin-left: 0; width: 100%; }
    .page-head__actions .btn { flex: 1; }

    .btn { padding: 0.5625rem 0.875rem; }
    .btn--sm { padding: 0.375rem 0.6875rem; }

    .kpi__value { font-size: 1.375rem; }

    .grid--kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.625rem; }
    .kpi { padding: 0.75rem 0.875rem; }

    .card__body { padding: 0.875rem; }
    .toolbar { padding: 0.75rem 0.875rem; }
    .toolbar__grow { min-width: 100%; }

    .dl__row { grid-template-columns: 1fr; gap: 0.125rem; }

    .desktop-only { display: none !important; }

    /* Les tableaux larges deviennent des cartes empilees : sur un ecran de
       telephone, un tableau a huit colonnes n'est lisible dans aucun sens. */
    .table--cards thead { display: none; }

    .table--cards tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 0.625rem;
        padding: 0.625rem 0.75rem;
        background: var(--surface);
    }

    .table--cards tbody tr:hover { background: var(--surface); }

    .table--cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.75rem;
        padding: 0.3125rem 0;
        border: 0;
        text-align: right;
    }

    .table--cards td::before {
        content: attr(data-label);
        font-size: 0.6875rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--ink-500);
        font-weight: 620;
        text-align: left;
        flex-shrink: 0;
    }

    .table--cards td[data-label=""]::before { content: none; }
    .table--cards td.num { text-align: right; }
}

/* ============================== Impression ============================= */

@media print {
    .sidebar,
    .header,
    .page-head__actions,
    .toolbar,
    .pagination,
    .no-print {
        display: none !important;
    }

    body { background: #fff; }
    .main { margin-left: 0; }
    .content { padding: 0; max-width: none; }
    .card { border: 0; box-shadow: none; }
    .table td, .table th { padding: 0.25rem 0.375rem; }

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