/* =============================================================================
   RECENSEMENT — Feuille de style (refonte UI/UX)
   -----------------------------------------------------------------------------
   Direction : interface administrative officielle, sobre, fiable et moderne.
   Identité  : vert institutionnel (émeraude) + encre forêt profonde, accent ambre.
   Typo      : Bricolage Grotesque (titres) · Manrope (texte/données).
   Socle     : Bootstrap 5 conservé, couche visuelle entièrement repensée.
   Soin particulier porté à la lisibilité et au confort sur mobile / tablette.
   ============================================================================= */

/* ----------------------------- 1. JETONS ---------------------------------- */
:root {
    /* Encre (sidebar, surfaces sombres) */
    --ink:        #0d241d;
    --ink-2:      #133329;
    --ink-soft:   #1c4338;

    /* Couleur principale */
    --brand:      #12936b;
    --brand-600:  #0f7e5b;
    --brand-700:  #0c6a4d;
    --brand-100:  #e3f4ee;
    --brand-050:  #f1faf6;

    /* Accent chaud */
    --amber:      #e0a33a;
    --amber-700:  #b07a18;
    --amber-100:  #fbf0d8;

    /* Surfaces & neutres */
    --bg:         #f4f7f5;
    --surface:    #ffffff;
    --surface-2:  #f8faf9;
    --line:       #e6ece9;
    --line-strong:#d4ded9;

    /* Texte */
    --text:       #14231e;
    --text-soft:  #36473f;
    --muted:      #62756c;

    /* Sémantique */
    --success:    #15915f;
    --danger:     #d6453f;
    --warning:    #d98a16;
    --info:       #2f74b5;

    /* Rayons */
    --r-sm:  9px;
    --r-md:  13px;
    --r-lg:  18px;
    --r-xl:  24px;

    /* Ombres */
    --shadow-xs: 0 1px 2px rgba(13,36,29,.05);
    --shadow-sm: 0 1px 2px rgba(13,36,29,.05), 0 4px 12px rgba(13,36,29,.05);
    --shadow-md: 0 2px 6px rgba(13,36,29,.06), 0 12px 28px rgba(13,36,29,.08);
    --shadow-lg: 0 18px 50px rgba(13,36,29,.16);

    --sidebar-w: 268px;
    --topbar-h:  66px;

    /* Mappage Bootstrap */
    --bs-primary: var(--brand);
    --bs-primary-rgb: 18, 147, 107;
    --bs-link-color: var(--brand-700);
    --bs-link-hover-color: var(--brand-700);
    --bs-border-color: var(--line);
    --bs-body-color: var(--text);
    --bs-body-font-family: 'Manrope', system-ui, -apple-system, sans-serif;
}

/* ----------------------------- 2. BASE ------------------------------------ */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Manrope', system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6, .display-font {
    font-family: 'Bricolage Grotesque', 'Manrope', sans-serif;
    letter-spacing: -0.015em;
    color: var(--text);
}

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

::selection { background: rgba(18,147,107,.18); }

/* Défilement plus discret */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #b9c6c0; background-clip: content-box; }

/* Focus accessible et homogène */
a:focus-visible, button:focus-visible, .btn:focus-visible,
.form-control:focus-visible, .form-select:focus-visible,
.page-link:focus-visible, .nav-link:focus-visible {
    outline: 3px solid rgba(18,147,107,.35);
    outline-offset: 2px;
}

.text-muted { color: var(--muted) !important; }
.fw-semibold { font-weight: 600 !important; }

/* ----------------------------- 3. MISE EN PAGE ---------------------------- */
.app-layout { display: flex; min-height: 100vh; min-height: 100dvh; }

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.content {
    padding: 30px clamp(18px, 4vw, 44px) 72px;
    flex: 1;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* ----------------------------- 4. SIDEBAR --------------------------------- */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--ink);
    background-image:
        radial-gradient(120% 60% at 15% -5%, rgba(18,147,107,.30), transparent 60%),
        linear-gradient(180deg, var(--ink-2), var(--ink));
    color: #c6dad2;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    padding: 20px 14px 16px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 20px;
    margin-bottom: 6px;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 1.28rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-mark {
    width: 42px; height: 42px;
    display: grid; place-items: center;
    background: linear-gradient(145deg, var(--brand), var(--brand-700));
    border-radius: 13px;
    font-size: 1.3rem;
    color: #fff;
    box-shadow: 0 8px 20px rgba(18,147,107,.45), inset 0 1px 0 rgba(255,255,255,.25);
    flex-shrink: 0;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }

.nav-section {
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: #6f8a81;
    padding: 18px 14px 7px;
    font-weight: 700;
}

.sidebar .nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 11px 14px;
    border-radius: 11px;
    color: #b4c9c1;
    font-weight: 500;
    font-size: .94rem;
    text-decoration: none;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}
.sidebar .nav-link i { font-size: 1.12rem; width: 22px; text-align: center; flex-shrink: 0; }
.sidebar .nav-link span { white-space: nowrap; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link:active { transform: scale(.99); }
.sidebar .nav-link.active {
    background: linear-gradient(135deg, var(--brand), var(--brand-700));
    color: #fff;
    box-shadow: 0 8px 20px rgba(12,106,77,.42);
}
.sidebar .nav-link.active::before {
    content: "";
    position: absolute;
    left: -14px; top: 50%;
    transform: translateY(-50%);
    width: 4px; height: 22px;
    background: var(--amber);
    border-radius: 0 4px 4px 0;
}

.nav-logout {
    margin-top: 10px;
    color: #f0a3a0 !important;
}
.nav-logout:hover { background: rgba(214,69,63,.16) !important; color: #ffd0ce !important; }

.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(7,20,16,.55);
    backdrop-filter: blur(2px);
    z-index: 1035;
    opacity: 0;
    transition: opacity .25s ease;
}
.sidebar-backdrop.show { opacity: 1; }

/* ----------------------------- 5. TOPBAR ---------------------------------- */
.topbar {
    position: sticky; top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: var(--topbar-h);
    padding: 12px clamp(18px, 4vw, 44px);
    background: rgba(255,255,255,.82);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line);
}
.topbar-title {
    font-size: 1.32rem;
    font-weight: 700;
    margin: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.btn-icon {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 11px;
    width: 44px; height: 44px;
    font-size: 1.3rem;
    color: var(--text);
    display: grid; place-items: center;
    transition: background .15s ease, border-color .15s ease;
}
.btn-icon:hover { background: var(--surface-2); border-color: var(--line-strong); }

.btn-user {
    display: flex; align-items: center; gap: 10px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 5px 12px 5px 6px;
    text-align: left;
    line-height: 1.15;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.btn-user:hover { border-color: var(--line-strong); box-shadow: var(--shadow-xs); }
.btn-user small { font-size: .72rem; color: var(--muted); }
.btn-user::after { margin-left: 2px; color: var(--muted); }

.topbar-user .dropdown-menu { border-radius: var(--r-md); border-color: var(--line); box-shadow: var(--shadow-md); padding: 6px; }
.topbar-user .dropdown-item { border-radius: 9px; padding: 9px 12px; font-weight: 500; }
.topbar-user .dropdown-item:active { background: var(--brand); }

/* Avatars */
.avatar, .avatar-placeholder {
    display: inline-grid; place-items: center;
    background: linear-gradient(140deg, var(--brand), var(--brand-700));
    color: #fff;
    font-weight: 700;
    border-radius: 50%;
    line-height: 1;
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.2);
}
.avatar-img {
    border-radius: 50%;
    object-fit: cover;
    display: inline-block;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--line);
    flex-shrink: 0;
}

/* ----------------------------- 6. CARTES ---------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s ease, transform .2s ease;
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--line);
    padding: 17px 22px;
    font-weight: 700;
    font-size: 1.02rem;
    font-family: 'Bricolage Grotesque', sans-serif;
    letter-spacing: -.01em;
}
.card-body { padding: 22px; }

/* Cartes statistiques — alignées à gauche, chiffre proéminent */
.stat-card {
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 16px;
    padding: 20px 22px;
    min-height: auto;
    overflow: hidden;
    position: relative;
}
.stat-card::after {
    content: "";
    position: absolute;
    right: -30px; top: -30px;
    width: 110px; height: 110px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(18,147,107,.06), transparent 70%);
    pointer-events: none;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
/* Conteneur texte (chiffre + libellé) : peut rétrécir pour éviter tout débordement */
.stat-card > div:not(.stat-icon) { min-width: 0; flex: 1 1 auto; }
.stat-icon {
    width: 54px; height: 54px;
    border-radius: 15px;
    display: grid; place-items: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.stat-icon.c-emerald { background: var(--brand-100); color: var(--brand-700); }
.stat-icon.c-amber   { background: var(--amber-100); color: var(--amber-700); }
.stat-icon.c-blue    { background: #e4eef7; color: var(--info); }
.stat-icon.c-rose    { background: #fbe4e3; color: var(--danger); }
.stat-value {
    font-size: 1.95rem;
    font-weight: 700;
    line-height: 1;
    font-family: 'Bricolage Grotesque', sans-serif;
    color: var(--text);
}
.stat-label {
    color: var(--muted);
    font-size: .86rem;
    font-weight: 600;
    margin-top: 3px;
    overflow-wrap: anywhere;
    line-height: 1.25;
}

/* ----------------------------- 7. TABLEAUX -------------------------------- */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--r-lg);
    -webkit-overflow-scrolling: touch;
}
.table { margin: 0; color: var(--text); }
.table thead th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    border-bottom: 1px solid var(--line);
    padding: 13px 16px;
    white-space: nowrap;
}
.table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-color: var(--line);
    color: var(--text-soft);
}
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: var(--brand-050); }
.table tbody tr:last-child td { border-bottom: 0; }

/* ----------------------------- 8. BOUTONS --------------------------------- */
.btn {
    border-radius: var(--r-sm);
    font-weight: 600;
    padding: 9px 16px;
    transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-sm { border-radius: 8px; padding: 6px 11px; }
.btn-lg { padding: 12px 22px; border-radius: var(--r-md); }

.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-600);
    --bs-btn-hover-border-color: var(--brand-600);
    --bs-btn-active-bg: var(--brand-700);
    --bs-btn-active-border-color: var(--brand-700);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
    box-shadow: 0 8px 18px rgba(15,126,91,.26);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand-700);
    --bs-btn-border-color: var(--line-strong);
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--brand-700);
    --bs-btn-active-border-color: var(--brand-700);
}
.btn-outline-secondary {
    --bs-btn-color: var(--text-soft);
    --bs-btn-border-color: var(--line-strong);
    --bs-btn-hover-bg: var(--surface-2);
    --bs-btn-hover-border-color: var(--line-strong);
    --bs-btn-hover-color: var(--text);
    --bs-btn-active-bg: var(--line);
}
.btn-outline-success {
    --bs-btn-color: var(--brand-700);
    --bs-btn-border-color: rgba(18,147,107,.45);
    --bs-btn-hover-bg: var(--brand-600);
    --bs-btn-hover-border-color: var(--brand-600);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--brand-700);
}
.btn-danger {
    --bs-btn-bg: var(--danger);
    --bs-btn-border-color: var(--danger);
    --bs-btn-hover-bg: #c23a35;
    --bs-btn-hover-border-color: #c23a35;
    --bs-btn-active-bg: #a93330;
}
.btn-light {
    --bs-btn-bg: var(--surface-2);
    --bs-btn-border-color: var(--line);
    --bs-btn-hover-bg: var(--line);
}
.text-emerald, .text-primary { color: var(--brand-700) !important; }

.action-btns { display: flex; gap: 6px; }
.action-btns .btn { width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0; }

/* Variante avec libellé (ex. page Validations : « Valider » / « Rejeter ») :
   les boutons prennent leur taille naturelle, le texte reste visible et les
   boutons passent à la ligne sur petits écrans plutôt que de déborder. */
.action-btns.action-btns-text { flex-wrap: wrap; }
.action-btns.action-btns-text .btn {
    width: auto;
    height: auto;
    padding: 6px 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.action-btns.action-btns-text form { display: inline-flex; }

/* ----------------------------- 9. FORMULAIRES ----------------------------- */
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: 6px; color: var(--text-soft); }
.form-label .req, label .req, .req { color: var(--danger); font-weight: 700; margin-left: 2px; }
.form-text { color: var(--muted); font-size: .8rem; }

.form-control, .form-select {
    border-radius: var(--r-sm);
    border-color: var(--line-strong);
    padding: 11px 13px;
    font-size: .95rem;
    color: var(--text);
    background-color: #fff;
    min-height: 46px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control::placeholder { color: #9aaaa3; }
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(18,147,107,.14);
}
.form-control:disabled, .form-select:disabled { background: var(--surface-2); color: var(--muted); }
.form-select:disabled { opacity: .8; }

.input-group-text {
    background: var(--surface-2);
    border-color: var(--line-strong);
    border-radius: var(--r-sm);
    color: var(--muted);
}
.input-group .btn { border-color: var(--line-strong); }

/* ----------------------------- 10. BADGES & DIVERS ------------------------ */
.badge {
    font-weight: 600;
    padding: .42em .72em;
    border-radius: 7px;
    letter-spacing: .01em;
}
.badge.bg-success { background: var(--success) !important; }
.badge.bg-warning { background: var(--amber-100) !important; color: var(--amber-700) !important; }
.badge.bg-secondary { background: #eef2f0 !important; color: var(--text-soft) !important; }
.badge.bg-light { background: var(--surface-2) !important; color: var(--text-soft) !important; border: 1px solid var(--line); }

.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.empty-state { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-state i { font-size: 2.8rem; opacity: .45; color: var(--brand); }
.empty-state p { margin-top: 10px; }

/* En-tête de section de page */
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.section-head h2, .section-head h1 { margin: 0; font-size: 1.4rem; }

/* ----------------------------- 11. PAGINATION ----------------------------- */
.pagination { gap: 3px; }
.pagination .page-link {
    color: var(--brand-700);
    border-color: var(--line);
    padding: 7px 12px;
    font-weight: 600;
    border-radius: 9px !important;
    margin: 0;
    transition: background .14s ease, border-color .14s ease;
}
.pagination .page-item.active .page-link {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    box-shadow: 0 5px 14px rgba(18,147,107,.3);
}
.pagination .page-item.disabled .page-link { color: var(--muted); background: transparent; border-color: var(--line); }
.pagination .page-link:hover { background: var(--brand-100); border-color: var(--brand); }

/* ----------------------------- 12. MODALES -------------------------------- */
.modal-content {
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal-title { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; }
.modal-body { padding: 22px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--line); background: var(--surface-2); }
.modal-backdrop.show { opacity: .55; }
.btn-close:focus { box-shadow: none; }

/* ----------------------------- 13. ALERTES -------------------------------- */
.alert {
    position: relative;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    padding: 14px 44px 14px 16px;
    font-weight: 500;
    overflow: hidden;
    box-shadow: var(--shadow-xs);
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert::before {
    font-family: "bootstrap-icons";
    font-size: 1.15rem;
    line-height: 1;
    flex-shrink: 0;
}
.alert-success { background: var(--brand-050); border-color: rgba(21,145,95,.3); color: #0c5b3c; }
.alert-success::before { content: "\F26B"; color: var(--success); }
.alert-danger  { background: #fdeceb; border-color: rgba(214,69,63,.3); color: #97241f; }
.alert-danger::before { content: "\F623"; color: var(--danger); }
.alert-warning { background: #fdf4e3; border-color: rgba(217,138,22,.35); color: #8a5b0e; }
.alert-warning::before { content: "\F33A"; color: var(--warning); }
.alert-info    { background: #e9f1f9; border-color: rgba(47,116,181,.3); color: #1f5183; }
.alert-info::before { content: "\F431"; color: var(--info); }
.alert .btn-close { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); padding: .6rem; }

/* Barre de minuterie (disparition auto à 10 s) */
.alert-timer {
    position: absolute;
    left: 0; bottom: 0;
    height: 3px;
    width: 100%;
    transform-origin: left center;
    background: currentColor;
    opacity: .35;
    animation: alert-countdown 10s linear forwards;
}
@keyframes alert-countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ----------------------------- 14. AUTH ----------------------------------- */
.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    background: var(--bg);
}
.auth-visual {
    background: var(--ink);
    background-image:
        radial-gradient(circle at 82% 8%, rgba(18,147,107,.40), transparent 52%),
        radial-gradient(circle at 8% 92%, rgba(224,163,58,.22), transparent 48%),
        linear-gradient(160deg, var(--ink-2), var(--ink));
    color: #fff;
    padding: clamp(40px, 5vw, 64px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}
.auth-visual .brand {
    display: flex; align-items: center; gap: 12px;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-weight: 700; font-size: 1.4rem;
    position: relative; z-index: 1;
}
.auth-visual h2 {
    font-size: clamp(1.9rem, 3vw, 2.9rem);
    line-height: 1.08;
    margin: 0 0 16px;
    color: #fff;
    position: relative; z-index: 1;
}
.auth-visual p { color: #b6cdc4; max-width: 440px; position: relative; z-index: 1; }
.auth-feature { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; position: relative; z-index: 1; }
.auth-feature i { color: var(--amber); font-size: 1.25rem; margin-top: 2px; }

.auth-form-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(28px, 4vw, 48px);
}
.auth-card { width: 100%; max-width: 410px; }
.auth-card h1 { font-size: 1.75rem; margin-bottom: 4px; }
.auth-card .subtitle { color: var(--muted); margin-bottom: 28px; }
.logo-icon { font-size: 2.7rem; color: var(--brand); }

.credentials-hint {
    background: var(--surface-2);
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-md);
    padding: 13px 15px;
    font-size: .82rem;
    color: var(--muted);
    margin-top: 24px;
}
.credentials-hint code { color: var(--brand-700); font-weight: 600; }

/* ----------------------------- 15. COMPOSANTS MÉTIER ---------------------- */
/* Bandeau de zone (haut des pages agent) */
.zone-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 15px 18px;
    border-radius: var(--r-lg);
    background: linear-gradient(110deg, var(--brand-100), var(--brand-050));
    border: 1px solid rgba(18,147,107,.22);
    color: var(--text);
}
.zone-banner > i {
    font-size: 22px;
    color: var(--brand-700);
    background: #fff;
    width: 46px; height: 46px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 13px;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}
.zone-banner-label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.zone-banner strong { font-size: 16px; }

/* Carte de zone (tableau de bord agent) */
.zone-card {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    padding: 24px;
    border-radius: var(--r-lg);
    background: var(--ink);
    background-image: radial-gradient(circle at 12% 0%, rgba(18,147,107,.38), transparent 55%), linear-gradient(160deg, var(--ink-2), var(--ink));
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.zone-card-icon {
    font-size: 26px;
    width: 56px; height: 56px;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 15px;
    background: rgba(255,255,255,.12);
    color: #fff;
}
.zone-card-label { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.7); font-weight: 700; }
.zone-card-value { font-family: 'Bricolage Grotesque', sans-serif; font-size: 22px; font-weight: 700; line-height: 1.2; margin-top: 2px; color: #fff; }
.zone-card-note { margin: 8px 0 0; font-size: 13px; color: rgba(255,255,255,.78); max-width: 680px; }
.zone-card.p-3 { background: var(--brand-050); background-image: none; color: var(--text); border: 1px solid rgba(18,147,107,.2); }
.zone-card.p-3 .zone-card-icon { background: var(--brand-100); color: var(--brand-700); }
.zone-card.p-3 .zone-card-label { color: var(--muted); }
.zone-card.p-3 .zone-card-value { color: var(--text); }
.zone-card.p-3 .zone-card-note { color: var(--text-soft); }

/* Badge code d'occupation (allure « cachet officiel ») */
.badge-code {
    font-family: 'Consolas', 'SFMono-Regular', ui-monospace, monospace;
    font-weight: 700;
    letter-spacing: .05em;
    color: var(--brand-700);
    background: var(--brand-100);
    border: 1px solid rgba(18,147,107,.3);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 13px;
    white-space: nowrap;
}

/* ============================================================================
   16. RESPONSIVE — soin particulier mobile / tablette
   ========================================================================== */

/* Tablettes & mobiles : sidebar repliable en tiroir ------------------------ */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform .28s cubic-bezier(.4,0,.2,1);
        width: 280px;
        max-width: 84vw;
        box-shadow: 0 0 60px rgba(0,0,0,.4);
        padding-top: max(20px, env(safe-area-inset-top));
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; }
    .app-main { margin-left: 0 !important; }
    .content { padding: 24px 18px 80px; }
    .topbar { padding: 10px 16px; }
    .topbar-title { font-size: 1.18rem; }
}

/* Tablettes ----------------------------------------------------------------- */
@media (max-width: 768px) {
    .card-body { padding: 18px; }
    .card-header { padding: 15px 18px; font-size: .98rem; }
    .stat-card { padding: 16px; gap: 13px; }
    .stat-icon { width: 48px; height: 48px; font-size: 1.3rem; border-radius: 13px; }
    .stat-value { font-size: 1.6rem; }
    .table thead th { padding: 11px 13px; }
    .table tbody td { padding: 12px 13px; }
}

/* Mobiles : tableaux en mode CARTES + formulaires pleine largeur ------------ */
@media (max-width: 576px) {
    body { font-size: 14.5px; }
    .content { padding: 18px 13px 84px; }
    .topbar { gap: 10px; }
    .topbar-title { font-size: 1.05rem; }

    .section-head { margin-bottom: 16px; }

    /* Cartes statistiques : éviter que le libellé (ex. « Occupations ») déborde */
    .stat-card { gap: 10px; padding: 13px; }
    .stat-icon { width: 42px; height: 42px; font-size: 1.15rem; border-radius: 12px; }
    .stat-value { font-size: 1.5rem; }
    .stat-label { font-size: .72rem; letter-spacing: -.01em; }

    /* Zone d'actions empilée et pleine largeur */
    .page-actions {
        flex-direction: column;
        width: 100%;
        align-items: stretch;
    }
    .page-actions .input-group,
    .page-actions .form-control,
    .page-actions .form-select,
    .page-actions .btn { width: 100%; max-width: 100% !important; }
    .d-flex.flex-wrap.justify-content-between > .btn { width: 100%; justify-content: center; }

    /* Champ de recherche : icône + champ sur une ligne, bouton pleine largeur dessous */
    .search-form .input-group { row-gap: 8px; }
    .search-form .input-group > .input-group-text { border-radius: var(--r-sm) 0 0 var(--r-sm); }
    .search-form .input-group > .search-input { flex: 1 1 0; min-width: 0; width: auto; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
    .search-form .input-group > .btn { flex: 1 0 100%; border-radius: var(--r-sm) !important; }

    /* Tableaux responsifs : chaque ligne devient une carte lisible.
       On garde overflow-x:auto (hérité) : en mode cartes le tableau passe en
       blocs pleine largeur (aucun débordement) ; tout tableau resté en mode
       classique défile horizontalement DANS son cadre sans décaler la page. */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tbody tr {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: var(--r-md);
        margin-bottom: 12px;
        padding: 6px 6px 4px;
        box-shadow: var(--shadow-xs);
    }
    .table-cards tbody tr:hover { background: #fff; }
    .table-cards tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 14px;
        padding: 10px 14px !important;
        border: none !important;
        border-bottom: 1px solid var(--line) !important;
        text-align: right;
        word-break: break-word;
        overflow-wrap: anywhere;
        color: var(--text);
        min-width: 0;
    }
    .table-cards tbody td:last-child { border-bottom: none !important; }
    .table-cards tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--muted);
        font-size: .72rem;
        text-transform: uppercase;
        letter-spacing: .05em;
        text-align: left;
        flex-shrink: 0;
        flex-basis: 38%;
        max-width: 38%;
        padding-top: 2px;
    }
    /* Cellule sans libellé (pas de data-label) : on neutralise la pseudo-colonne */
    .table-cards tbody td:not([data-label])::before { content: ""; flex-basis: 0; max-width: 0; }
    .table-cards tbody td.actions-cell {
        justify-content: flex-end;
        padding-top: 12px !important;
        background: var(--surface-2);
        border-radius: 0 0 10px 10px;
        margin: 4px -6px -4px;
    }
    .table-cards tbody td.actions-cell::before { display: none; }
    /* État vide (ligne unique en colspan) : centré, pleine largeur */
    .table-cards tbody td:has(.empty-state) { justify-content: center; }
    .table-cards tbody td .empty-state { width: 100%; padding: 30px 12px; }
    /* Garde-fou anti-débordement horizontal sur petits écrans */
    img, svg, table, pre, code, .badge { max-width: 100%; }
    input, select, textarea, .form-control, .form-select { max-width: 100% !important; }
    .input-group { max-width: 100% !important; }
    .badge-code { white-space: normal; overflow-wrap: anywhere; }
    .action-btns { flex-wrap: wrap; gap: 6px; }

    /* Modales : quasi plein écran, footer collant */
    .modal-dialog { margin: 10px; }
    .modal-content { border-radius: var(--r-lg); }
    .modal-header, .modal-body, .modal-footer { padding-left: 16px; padding-right: 16px; }
    .modal-footer { position: sticky; bottom: 0; flex-wrap: wrap; gap: 8px; }
    .modal-footer .btn { flex: 1; min-width: 120px; }

    .auth-form-wrap { padding: 24px 16px; }
    .auth-card h1 { font-size: 1.45rem; }
}

/* Très petits écrans -------------------------------------------------------- */
@media (max-width: 380px) {
    .stat-card { flex-direction: row; }
    .stat-value { font-size: 1.4rem; }
    .btn-user span.d-none.d-sm-inline { display: none !important; }
}

/* Auth : visuel masqué sous 860px ------------------------------------------ */
@media (max-width: 860px) {
/* Auth : sous 860px, le visuel passe AU-DESSUS du formulaire (empilé).
   On scrolle vers le bas pour atteindre le formulaire. */
@media (max-width: 860px) {
    .auth-page { display: block; min-height: 100vh; min-height: 100dvh; }
    .auth-visual {
        display: flex;
        min-height: auto;
        padding: clamp(32px, 7vw, 52px) clamp(22px, 6vw, 44px);
        gap: 22px;
    }
    .auth-visual h2 { font-size: clamp(1.8rem, 7vw, 2.4rem); }
    .auth-form-wrap { padding: 32px 18px 48px; }
}
}

/* Mouvement réduit ---------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
    .alert-timer { animation: none; opacity: .25; }
}

/* Impression ---------------------------------------------------------------- */
@media print {
    .sidebar, .topbar, .page-actions, .btn, .sidebar-backdrop { display: none !important; }
    .content { padding: 0; max-width: 100%; }
    .card { box-shadow: none; border: 1px solid #ccc; }
    body { background: #fff; }
}
