@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

* { box-sizing: border-box; }

:root {
    --navy: #0B2A43;
    --navy-light: #123A5C;
    --blue: #1E5C86;
    --gold: #E8A33D;
    --gold-dark: #B97C1F;
    --green: #2F6B3A;
    --red: #C23B33;
    --paper: #F6F1E4;
    --paper-card: #FFFDF6;
    --line: #E4DCC5;
    --line-soft: #EFE9D6;
    --ink: #241F14;
    --ink-soft: #3A3527;
    --muted: #6B6455;
    --muted-2: #8A8370;
}

html, body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 14px;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ---------- SIDEBAR ---------- */
.sidebar {
    width: 250px;
    min-width: 250px;
    background: var(--navy);
    color: #EFE6CE;
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #2C5477 transparent;
}
.sidebar > * { flex-shrink: 0; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #2C5477; border-radius: 6px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: #3B6A94; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand-photo {
    width: 46px; height: 46px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--gold); flex-shrink: 0; background: #fff;
}
.brand-title { font-family: 'Fraunces', serif; font-weight: 600; font-size: 17px; color: #F7EFD9; line-height: 1.2; }
.brand-sub { font-size: 11px; color: #9FB4C6; margin-top: 2px; line-height: 1.3; }

.btn-new {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--gold); color: #3A2708; font-weight: 600; font-size: 13.5px;
    padding: 10px 14px; border-radius: 8px; margin-bottom: 22px; border: none;
}
.btn-new:hover { filter: brightness(1.05); text-decoration: none; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: #5F7A8F; margin: 14px 4px 4px; }
.sidebar-group-label:first-child { margin-top: 2px; }
.sidebar-tab {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
    color: #C7D4DE; font-size: 13.5px; font-weight: 500;
}
.sidebar-tab:hover { background: var(--navy-light); color: #F7EFD9; text-decoration: none; }
.sidebar-tab.active { background: var(--gold); color: #3A2708; }

.sidebar-foot { margin-top: auto; padding-top: 18px; border-top: 1px solid #1B4262; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #F7EFD9; }
.sidebar-user-role { font-size: 11px; color: #9FB4C6; margin-bottom: 10px; }
.sidebar-logout { display: inline-block; font-size: 11.5px; color: #E8A33D; margin-bottom: 14px; }
.sidebar-logout:hover { text-decoration: underline; }
.sidebar-foot-count { font-family: 'Fraunces', serif; font-size: 24px; font-weight: 600; color: var(--gold); }
.sidebar-foot-label { font-size: 11px; color: #9FB4C6; margin-top: -2px; }
.sidebar-foot-year { font-size: 11px; color: #5F7A8F; margin-top: 8px; }

/* ---------- LOGIN ---------- */
.login-body { background: var(--navy); min-height: 100vh; margin: 0; display: flex; align-items: center; justify-content: center; font-family: 'IBM Plex Sans', sans-serif; }
.login-shell { width: 100%; max-width: 400px; padding: 20px; }
.login-card { background: var(--paper-card); border-radius: 16px; padding: 36px 32px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.35); }
.login-logo { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; margin-bottom: 14px; border: 2px solid var(--gold); }
.login-card h1 { font-family: 'Fraunces', serif; font-size: 20px; margin: 0 0 4px; color: var(--ink); }
.login-sub { font-size: 12.5px; color: var(--muted); margin: 0 0 20px; }
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-submit { width: 100%; justify-content: center; margin-top: 4px; }
.login-hint { font-size: 11.5px; color: var(--muted-2); margin-top: 18px; }
.login-hint code { background: var(--line-soft); padding: 1px 5px; border-radius: 4px; }

/* ---------- MAIN ---------- */
.main-area { flex: 1; min-width: 0; padding: 30px 38px 50px; max-width: 1200px; }

.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.panel-head h1 { font-family: 'Fraunces', serif; font-size: 26px; font-weight: 600; margin: 0 0 4px; }
.panel-head p { margin: 0; color: var(--muted); font-size: 13.5px; }

.wave-divider { width: 100%; height: 20px; display: block; margin: 16px 0 24px; }

.flash {
    padding: 11px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 13.5px; font-weight: 500;
    display: flex; align-items: center; gap: 8px;
}
.flash-success { background: #E7F0E4; color: #204A28; border: 1px solid #BFDAB6; }
.flash-error { background: #FBE9E7; color: #5A2A24; border: 1px solid #E0B4AE; }

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px; font-family: inherit; font-size: 13.5px;
    font-weight: 500; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
    cursor: pointer; background: none;
}
.btn:hover { text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-primary { background: var(--blue); color: #FCF9EF; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: #D8CFB4; }
.btn-ghost:hover { background: var(--line-soft); }
.btn-danger { background: var(--red); color: #FCF3F1; }
.btn-danger:hover { filter: brightness(1.08); }

.icon-btn {
    background: transparent; border: 1px solid transparent; border-radius: 7px;
    width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
    color: #5A5440; cursor: pointer;
}
.icon-btn:hover { background: var(--line-soft); border-color: #D8CFB4; }
.icon-btn-danger:hover { color: var(--red); background: #FBE9E7; border-color: #F0C6C0; }

/* ---------- STAT CARDS ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--paper-card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; align-items: center; gap: 12px; }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 18px; }
.stat-value { font-family: 'Fraunces', serif; font-size: 24px; font-weight: 600; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- CHARTS ---------- */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.chart-card { background: var(--paper-card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; }
.chart-card-wide { grid-column: 1 / -1; }
.chart-card h3 { font-family: 'Fraunces', serif; font-size: 15px; font-weight: 600; margin: 0 0 14px; }
.chart-canvas-wrap { position: relative; width: 100%; overflow: hidden; }
.chart-canvas-wrap canvas { position: absolute; top: 0; left: 0; width: 100% !important; height: 100% !important; }

.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table td { padding: 8px 6px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.muted { color: var(--muted-2); }

/* ---------- BADGES ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 500; padding: 3px 9px 3px 7px; border-radius: 20px; border: 1px solid; white-space: nowrap; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }
.nature-exec    { background: #E7F0E4; color: #204A28; border-color: #2F6B3A; }
.nature-exec .badge-dot    { background: #2F6B3A; }
.nature-liaison { background: #E4EEF4; color: #123C58; border-color: #1E5C86; }
.nature-liaison .badge-dot { background: #1E5C86; }
.nature-part    { background: #F6EBD8; color: #7A5313; border-color: #B97C1F; }
.nature-part .badge-dot    { background: #B97C1F; }
.nature-danger  { background: #FBE9E7; color: #8A342C; border-color: #C23B33; }
.nature-danger .badge-dot  { background: #C23B33; }

/* ---------- FILTER BAR ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; align-items: center; }
.search-box { display: flex; align-items: center; gap: 8px; background: var(--paper-card); border: 1px solid #D8CFB4; border-radius: 8px; padding: 0 10px; height: 36px; flex: 1; min-width: 220px; }
.search-box input { border: none; outline: none; background: transparent; font-family: inherit; font-size: 13.5px; flex: 1; color: var(--ink); height: 100%; }
.filter-bar select { height: 36px; border-radius: 8px; border: 1px solid #D8CFB4; background: var(--paper-card); font-family: inherit; font-size: 13px; color: var(--ink-soft); padding: 0 10px; max-width: 190px; }

/* ---------- TABLE ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-card); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th { text-align: left; padding: 11px 12px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-2); border-bottom: 1px solid var(--line); font-weight: 600; white-space: nowrap; background: #F4EEDC; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; color: var(--ink-soft); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #FBF7EB; }
.objet-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; }
.cell-icon { margin-right: 4px; color: var(--gold-dark); }
.actions-col { white-space: nowrap; text-align: right; }
.actions-col .icon-btn { margin-left: 2px; }

.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; font-size: 13px; }
.pagination-btns { display: flex; gap: 6px; }
.pagination-btns a.icon-btn.disabled { opacity: 0.35; pointer-events: none; }

/* ---------- EMPTY STATE ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); background: var(--paper-card); border: 1px dashed #D8CFB4; border-radius: 12px; }
.empty-state h3 { font-family: 'Fraunces', serif; color: var(--ink); margin: 14px 0 4px; }

/* ---------- NOTES ---------- */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }

/* ---------- BIBLIOTHEQUE / MEDIATHEQUE ---------- */
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.res-card { background: var(--paper-card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.res-thumb { height: 120px; background-size: cover; background-position: center; background-color: #F0EAD8; display: block; }
.res-thumb-icon { display: flex; align-items: center; justify-content: center; font-size: 36px; }
.res-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.res-actions { margin-top: 10px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.note-card { background: var(--paper-card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; border-left: 4px solid var(--blue); }
.note-card.note-high { border-left-color: var(--gold-dark); }
.note-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.note-actions { display: flex; gap: 2px; flex-shrink: 0; }
.note-title { font-family: 'Fraunces', serif; font-size: 15.5px; font-weight: 600; margin: 0 0 6px; color: var(--ink); }
.note-content { font-size: 13px; color: var(--ink-soft); margin: 0 0 10px; white-space: pre-line; }
.note-foot { font-size: 11.5px; }

/* ---------- FORM ---------- */
.form-card { background: var(--paper-card); border: 1px solid var(--line); border-radius: 14px; padding: 26px 30px; max-width: 700px; }
.mission-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row .field { min-width: 220px; }
.field label { font-size: 12.5px; font-weight: 600; color: #4A4432; }
.field .err { color: var(--red); font-weight: 500; }
.field input, .field select, .field textarea {
    border: 1px solid #D8CFB4; border-radius: 8px; padding: 9px 11px; font-family: inherit;
    font-size: 13.5px; color: var(--ink); background: #FFFEFA; resize: vertical; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,92,134,0.12); }
.field input.invalid, .field select.invalid, .field textarea.invalid { border-color: var(--red); }

.segmented { display: flex; gap: 6px; flex-wrap: wrap; }
.segment { flex: 1; min-width: 150px; }
.segment { position: relative; }
.segment input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; padding: 0; border: 0; }
.segment span {
    display: block; padding: 9px 10px; border-radius: 8px; border: 1px solid #D8CFB4; text-align: center;
    background: #FFFEFA; color: #4A4432; font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.segment input:checked + span { background: var(--blue); color: #FCF9EF; border-color: var(--blue); }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

datalist { }

/* ---------- CONFIRM (delete) ---------- */
.confirm-shell { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.confirm-card { background: var(--paper-card); border-radius: 14px; padding: 30px; max-width: 380px; text-align: center; border: 1px solid var(--line); }
.confirm-icon { color: var(--red); margin-bottom: 8px; font-size: 28px; }
.confirm-card h3 { font-family: 'Fraunces', serif; margin: 0 0 8px; font-size: 17px; }
.confirm-card p { margin: 0 0 18px; font-size: 13.5px; color: var(--muted); }
.confirm-actions { display: flex; justify-content: center; gap: 10px; }

/* ---------- PRINT DOCUMENT ---------- */
.print-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; font-size: 13px; color: #4A4432; font-weight: 500; }
.print-toolbar > div { display: flex; gap: 8px; }
.print-page-wrap { display: flex; justify-content: center; }
.print-page { background: #FFFFFF; padding: 46px 52px; border-radius: 4px; color: #1A1A1A; font-family: 'IBM Plex Sans', sans-serif; box-shadow: 0 2px 10px rgba(0,0,0,0.12); width: 100%; max-width: 760px; }
.print-letterhead { display: flex; align-items: center; gap: 16px; }
.print-flag { display: flex; height: 30px; width: 46px; flex-shrink: 0; border: 1px solid #ccc; }
.print-flag span { flex: 1; }
.print-titles { flex: 1; text-align: center; }
.print-country { font-weight: 600; font-size: 14px; letter-spacing: 0.03em; }
.print-motto { font-size: 11px; font-style: italic; color: #555; margin: 1px 0; }
.print-agency { font-size: 12.5px; font-weight: 600; margin-top: 4px; color: var(--blue); }
.print-photo { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 2px solid var(--blue); }
.print-rule { border: none; border-top: 2px solid var(--blue); margin: 16px 0 10px; }
.print-title { font-family: 'Fraunces', serif; text-align: center; font-size: 24px; font-weight: 700; letter-spacing: 0.06em; margin: 18px 0 2px; }
.print-ref { text-align: center; font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: #555; margin-bottom: 18px; }
.print-lead { font-size: 13px; margin-bottom: 16px; }
.print-table { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.print-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
.print-label { width: 42%; color: #555; font-weight: 500; }
.print-value { font-weight: 500; color: #1A1A1A; }
.print-blank { border-bottom: 1px dotted #999 !important; }
.print-note { font-size: 11.5px; color: #666; font-style: italic; margin-bottom: 40px; }
.print-signatures { display: flex; justify-content: space-between; margin-top: 30px; }
.sig-block { font-size: 12.5px; }
.sig-right { text-align: center; }
.sig-role { font-weight: 600; margin-bottom: 46px; }
.sig-name { font-size: 11px; color: #666; }

@media print {
    .no-print, .sidebar, .mobile-topbar, .sidebar-backdrop { display: none !important; }
    body { background: #fff; }
    .main-area { padding: 0; max-width: none; }
    .print-page { box-shadow: none; padding: 0; }
    @page { size: A4; margin: 14mm 12mm; }
}

/* ---------- ORDRE DE MISSION OFFICIEL (modèle ARD) ---------- */
.om-page { padding: 0 0 50px; max-width: 720px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.om-entete { width: 92%; display: block; margin: 0 auto; border-bottom: 3px double #1E5C86; }
.om-numero-box {
    text-align: center; font-weight: 700; font-size: 15px; letter-spacing: 0.02em;
    border: 1.8px solid #1A1A1A; display: inline-block; padding: 7px 24px;
    margin: 28px auto 30px; position: relative; left: 50%; transform: translateX(-50%);
}
.om-fields { padding: 0 52px; }
.om-line { display: flex; align-items: baseline; gap: 8px; margin-bottom: 22px; font-size: 13.5px; }
.om-line-block { align-items: flex-start; }
.om-label { flex-shrink: 0; font-weight: 700; white-space: nowrap; }
.om-colon { flex-shrink: 0; font-weight: 700; }
.om-value { flex: 1; font-weight: 700; color: #101010; }
.om-dotted { border-bottom: 1px dotted #555; padding-bottom: 3px; min-height: 1.3em; }
.om-signoff { padding: 10px 52px 0; font-size: 13.5px; }
.om-signoff > div:first-child { text-align: right; margin-bottom: 30px; font-weight: 600; }
.om-signature { text-align: right; }

/* Bascule d'aperçu couleur / noir & blanc (affecte aussi l'impression) */
.om-bw { filter: grayscale(100%); }
.om-signature-space { height: 46px; }
.om-signature-name { font-weight: 700; }

@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
}



/* ---------- BOUTON D'INSTALLATION (application de bureau) ---------- */
.sidebar-install-wrap { margin-top: 18px; }
.sidebar-install {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 9px 12px; border-radius: 8px;
    border: 1px dashed #3B6183; background: transparent; color: #C7D4DE;
    font-family: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
}
.sidebar-install:hover { background: var(--navy-light); color: #F7EFD9; border-style: solid; }
.sidebar-install[hidden] { display: none; }
.install-hint { font-size: 11.5px; line-height: 1.45; color: #9FB4C6; margin-top: 8px; }
.install-hint[hidden] { display: none; }


/* =========================================================================
   VERSION TÉLÉPHONE / TABLETTE  (écran uniquement — n'affecte jamais l'impression)
   ========================================================================= */
.mobile-topbar, .sidebar-backdrop, .sidebar-close { display: none; }

@media screen and (max-width: 900px) {
    .app-shell { flex-direction: column; min-height: 100vh; }
    body.nav-open { overflow: hidden; }

    /* Barre du haut */
    .mobile-topbar {
        display: flex; align-items: center; gap: 12px;
        position: sticky; top: 0; z-index: 30;
        background: var(--navy); color: #F7EFD9;
        padding: 10px 14px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    }
    .burger {
        width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
        border: 1px solid #2C5477; background: transparent; color: #F7EFD9;
        display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
    }
    .burger:active { background: var(--navy-light); }
    .mobile-brand {
        display: flex; align-items: center; gap: 10px; min-width: 0;
        color: #F7EFD9; text-decoration: none;
        font-family: 'Fraunces', serif; font-weight: 600; font-size: 18px;
    }
    .mobile-brand:hover { text-decoration: none; }
    .mobile-brand-photo { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold); background: #fff; flex-shrink: 0; }

    /* Menu : tiroir latéral */
    .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
        width: min(300px, 86vw); min-width: 0; height: 100%;
        padding: 18px 16px 24px;
        transform: translateX(-105%); visibility: hidden;
        transition: transform 0.25s ease, visibility 0s linear 0.25s;
    }
    .sidebar.open {
        transform: translateX(0); visibility: visible;
        transition: transform 0.25s ease, visibility 0s;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.35);
    }
    .sidebar-backdrop {
        display: block; position: fixed; inset: 0; z-index: 40;
        background: rgba(8, 16, 24, 0.55); opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
    }
    .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
    .sidebar-close {
        display: inline-flex; align-items: center; justify-content: center;
        position: absolute; top: 10px; right: 10px; width: 40px; height: 40px;
        border: none; background: transparent; color: #C7D4DE; font-size: 30px; line-height: 1; cursor: pointer;
    }
    .brand { padding-right: 40px; }
    .sidebar-nav { flex-direction: column; }
    .sidebar-tab { padding: 13px 12px; font-size: 15px; }
    .sidebar-foot { display: block; }
    .sidebar-install { padding: 12px; font-size: 14px; }

    /* Contenu */
    .main-area { padding: 18px 16px 44px; max-width: 100%; width: 100%; min-width: 0; }
    .panel-head { flex-direction: column; align-items: stretch; gap: 12px; }
    .panel-head h1 { font-size: 22px; }
    .panel-head p { font-size: 13px; }
    .panel-head > .btn { width: 100%; justify-content: center; padding: 12px 16px; }
    .wave-divider { margin: 12px 0 18px; }

    /* Cartes de chiffres : 2 par ligne */
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
    .stat-card { padding: 12px; gap: 10px; }
    .stat-icon { width: 34px; height: 34px; font-size: 15px; }
    .stat-value { font-size: 20px; }
    .stat-label { font-size: 11.5px; }
    .chart-grid { grid-template-columns: 1fr; }
    .chart-card { padding: 14px; }

    /* Recherche et filtres */
    .filter-bar { gap: 8px; }
    .search-box { flex: 1 1 100%; min-width: 0; height: 44px; }
    .filter-bar select, .filter-bar input[type="date"] { flex: 1 1 calc(50% - 4px); max-width: none; min-width: 0; height: 44px; font-size: 14px; }
    .filter-bar .btn { flex: 1 1 auto; justify-content: center; min-height: 44px; }

    /* Tableaux : défilement horizontal doux dans leur cadre */
    .table-wrap { -webkit-overflow-scrolling: touch; }
    .objet-cell { max-width: 200px; }
    .icon-btn { width: 38px; height: 38px; }
    .pagination { flex-wrap: wrap; gap: 10px; }

    /* Formulaires */
    .form-card { padding: 18px 16px; max-width: 100%; }
    .field-row { gap: 14px; }
    .field-row .field { min-width: 0; flex: 1 1 100%; }
    .field input, .field select, .field textarea { font-size: 16px; padding: 11px 12px; }
    .segmented { gap: 8px; }
    .segment { min-width: 0; flex: 1 1 calc(50% - 8px); }
    .segment span { padding: 11px 8px; }
    .form-actions { flex-direction: column-reverse; gap: 10px; }
    .form-actions .btn { width: 100%; justify-content: center; padding: 13px 16px; }

    /* Grilles de cartes */
    .notes-grid, .res-grid { grid-template-columns: 1fr; }

    /* Confirmations */
    .confirm-shell { min-height: 50vh; padding: 0 4px; }
    .confirm-card { max-width: 100%; }

    /* Documents imprimables : aperçu lisible sur petit écran */
    .print-toolbar { flex-wrap: wrap; gap: 10px; }
    .print-toolbar > div { flex-wrap: wrap; }
    .print-page:not(.om-page) { padding: 22px 16px; }
    .om-fields { padding: 0 14px; }
    .om-signoff { padding: 10px 14px 0; }
    .om-line { flex-wrap: wrap; font-size: 13px; gap: 4px 8px; margin-bottom: 18px; }
    .om-label { white-space: normal; }
    .om-value { min-width: 60%; }
    .om-numero-box { font-size: 13px; padding: 6px 12px; max-width: 94%; width: max-content; }

    /* Page de connexion */
    .login-card { padding: 28px 20px; }
}

@media screen and (max-width: 420px) {
    .main-area { padding: 16px 12px 40px; }
    .stat-grid { gap: 8px; }
    .stat-card { flex-direction: column; align-items: flex-start; gap: 6px; }
}


/* Tableaux -> cartes sur téléphone (écran uniquement) */
@media screen and (max-width: 700px) {
    .table-wrap { border: 0; background: transparent; overflow: visible; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table thead { display: none; }
    .data-table tbody tr {
        background: var(--paper-card); border: 1px solid var(--line); border-radius: 12px;
        padding: 6px 14px; margin-bottom: 12px;
    }
    .data-table tbody tr:hover { background: var(--paper-card); }
    .data-table td {
        display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
        padding: 9px 0; border-bottom: 1px dashed var(--line-soft); text-align: right;
        white-space: normal; max-width: none; overflow: visible;
    }
    .data-table tbody tr:last-child td { border-bottom: 1px dashed var(--line-soft); }
    .data-table td:last-child { border-bottom: 0; }
    .data-table td::before {
        content: attr(data-label); flex-shrink: 0; text-align: left; padding-top: 3px;
        font-family: 'IBM Plex Sans', sans-serif; font-size: 11px; font-weight: 600;
        text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-2);
    }
    .data-table td.actions-col { justify-content: flex-end; padding-top: 10px; }
    .data-table td.actions-col::before { display: none; }
    .objet-cell { max-width: none; white-space: normal; overflow: visible; text-overflow: clip; }
}


/* Onglets, groupe de boutons d'en-tête, grille de 3 cartes */
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
    padding: 9px 16px; border-radius: 8px; border: 1px solid #D8CFB4; background: var(--paper-card);
    color: var(--ink-soft); font-size: 13.5px; font-weight: 500;
}
.tab:hover { text-decoration: none; background: var(--line-soft); }
.tab.active { background: var(--blue); color: #FCF9EF; border-color: var(--blue); }
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }

/* KoboCollect */
.flash-warning { background: #F6EBD8; color: #7A5313; border: 1px solid #E6CFA3; }
.flash-warning a { color: #7A5313; }
.kv-row { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px dashed var(--line-soft); }
.kv-row:last-of-type { border-bottom: 0; }
.kv-key { flex: 0 0 36%; color: var(--muted-2); font-size: 12.5px; font-weight: 600; }
.kv-val { flex: 1; color: var(--ink); word-break: break-word; }
.rep-line { display: grid; grid-template-columns: minmax(120px, 34%) 1fr 90px; gap: 12px; align-items: center; padding: 5px 0; font-size: 13px; }
.rep-bar { height: 10px; background: #E9EEF3; border-radius: 6px; overflow: hidden; }
.rep-bar span { display: block; height: 100%; background: var(--blue); border-radius: 6px; }
.rep-n { text-align: right; font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; }
.rep-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.rep-nums div { background: #F4EEDC; border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.rep-nums .muted { font-size: 11.5px; }
.rep-nums strong { font-family: 'Fraunces', serif; font-size: 18px; }
.proj-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line-soft); }
.proj-line:last-child { border-bottom: 0; }

@media screen and (max-width: 900px) {
    .head-actions { flex-direction: column; align-items: stretch; }
    .head-actions .btn { width: 100%; justify-content: center; padding: 12px 16px; }
    .tabs .tab { flex: 1 1 calc(50% - 6px); text-align: center; padding: 11px 8px; }
    .stat-grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media screen and (max-width: 700px) {
    .kv-row { flex-direction: column; gap: 3px; }
    .kv-key { flex: none; }
    .rep-line { grid-template-columns: 1fr 70px; row-gap: 4px; }
    .rep-line .rep-bar { grid-column: 1 / -1; grid-row: 2; }
    .rep-nums { grid-template-columns: repeat(2, 1fr); }
    .proj-line { flex-direction: column; align-items: stretch; }
    .proj-line .btn { width: 100%; justify-content: center; }
}


/* ---------- COMPTES RENDUS : liste lisible + page de lecture ---------- */
.autogrow { overflow: hidden; resize: none; min-height: 90px; line-height: 1.6; font-size: 15px; }

.cr-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 18px; }
.cr-card {
    background: var(--paper-card); border: 1px solid var(--line); border-left: 4px solid var(--blue);
    border-radius: 14px; padding: 20px 22px; display: flex; flex-direction: column; gap: 6px;
}
.cr-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.cr-card-title { font-family: 'Fraunces', serif; font-size: 20px; line-height: 1.3; margin: 4px 0 2px; }
.cr-card-title a { color: var(--ink); }
.cr-card-title a:hover { color: var(--blue); text-decoration: underline; }
.cr-card-meta { font-size: 15px; color: var(--ink-soft); }
.cr-card-text { font-size: 16px; line-height: 1.65; color: var(--ink); margin: 6px 0; }
.cr-card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 10px; }

.cr-doc {
    max-width: 880px; background: var(--paper-card); border: 1px solid var(--line);
    border-radius: 16px; padding: 34px 40px 40px;
}
.cr-entete { display: none; width: 100%; max-width: 640px; margin: 0 auto 18px; }
.cr-badge {
    display: inline-block; font-size: 12.5px; font-weight: 700; letter-spacing: 0.14em;
    color: #FCF9EF; background: var(--navy); padding: 6px 14px; border-radius: 6px;
}
.cr-title { font-family: 'Fraunces', serif; font-size: 28px; line-height: 1.3; margin: 14px 0 20px; color: var(--ink); }
.cr-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 32px; padding: 18px 0 6px; border-top: 1px solid var(--line); }
.cr-meta .k { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-2); font-weight: 600; }
.cr-meta .v { font-size: 19px; line-height: 1.4; color: var(--ink); font-weight: 500; margin-top: 3px; }
.cr-sec { margin-top: 30px; }
.cr-sec h2 {
    font-family: 'Fraunces', serif; font-size: 20px; margin: 0 0 14px; padding: 9px 16px;
    background: #E9EEF3; border-left: 4px solid var(--blue); border-radius: 4px; color: var(--navy);
}
.cr-txt { font-size: 19px; line-height: 1.75; white-space: pre-wrap; word-wrap: break-word; color: var(--ink); }
.cr-vide { font-size: 16px; color: var(--muted-2); font-style: italic; margin: 0; }

@media screen and (max-width: 900px) {
    .cr-list { grid-template-columns: 1fr; }
    .cr-card { padding: 18px 16px; }
    .cr-card-actions .btn { flex: 1; justify-content: center; }
    .cr-doc { padding: 22px 18px 28px; border-radius: 12px; }
    .cr-title { font-size: 23px; }
    .cr-meta { grid-template-columns: 1fr; gap: 14px; }
    .cr-meta .v { font-size: 18px; }
    .cr-txt { font-size: 18px; line-height: 1.7; }
}
@media print {
    .cr-doc { border: 0; padding: 0; max-width: none; background: #fff; }
    .cr-entete { display: block; }
    .cr-badge { background: none; color: #000; border: 1.5px solid #000; }
    .cr-title { font-size: 20pt; }
    .cr-meta .v { font-size: 12.5pt; }
    .cr-txt { font-size: 12.5pt; line-height: 1.55; }
    .cr-sec h2 { font-size: 13pt; background: #eee; break-after: avoid; }
    .cr-sec { break-inside: auto; }
}
