:root {
        --navy: #14324f;
        --navy-2: #1f4e79;
        --green: #1e7d43;
        --orange: #f77f00;
        --line: #d6dde5;
        --bg: #eef1f5;
        --text: #1c2733;
        --muted: #5a6b7d;
    }
    * { box-sizing: border-box; }
    body {
        margin: 0;
        font-family: Arial, "Segoe UI", Helvetica, sans-serif;
        background: var(--bg);
        color: var(--text);
        font-size: 14px;
    }
    .page {
        max-width: 1120px;
        margin: 0 auto;
        padding: 24px 16px 60px;
    }

    /* ---- Bandeau drapeau ---- */
    .flag-stripe { display: flex; height: 6px; }
    .flag-stripe span { flex: 1; }
    .flag-stripe .c-orange { background: var(--orange); }
    .flag-stripe .c-white { background: #fff; }
    .flag-stripe .c-green { background: var(--green); }

    /* ---- En-tête officiel ---- */
    .doc-header {
        background: #fff;
        border: 1px solid var(--line);
        border-top: 4px solid var(--navy);
        padding: 18px 22px;
        margin-bottom: 18px;
        border-radius: 8px;
        box-shadow: 0 1px 4px rgba(20, 50, 79, .08);
    }
    .doc-header .top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 24px;
    }
    .doc-header .left,
    .doc-header .right {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    .doc-header .left { align-items: center; text-align: center; }
    .doc-header .right { align-items: center; text-align: center; }
    .doc-header .ministere {
        font-weight: bold;
        font-size: 15px;
        color: var(--navy);
        letter-spacing: .3px;
        line-height: 1.35;
    }
    .doc-header .dir {
        font-weight: bold;
        font-size: 13px;
        color: var(--navy-2);
        letter-spacing: 1px;
    }
    .doc-header .republique {
        font-weight: bold;
        font-size: 14px;
        color: var(--navy);
        letter-spacing: .3px;
    }
    .doc-header .devise {
        font-style: italic;
        font-size: 12px;
        color: var(--muted);
    }
    .header-logo { height: 48px; width: auto; margin-top: 12px; }
    .logo-left { display: block; }
    .logo-right { display: block; height: 60px; }

    /* ---- Navigation principale ---- */
    .nav-top { display: flex; flex-wrap: wrap; gap: 6px; background: linear-gradient(180deg, #ffffff 0%, #f5f8fb 100%); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 18px; box-shadow: 0 2px 8px rgba(20,50,79,.06); }
    .nav-top a { padding: 8px 16px; border-radius: 6px; text-decoration: none; font-size: 13px; font-weight: bold; color: var(--navy); background: #eef3f8; border: 1px solid transparent; transition: all .15s ease; }
    .nav-top a.active { background: var(--navy); color: #fff; box-shadow: 0 2px 6px rgba(20,50,79,.3); }
    .nav-top a:hover { background: var(--green); color: #fff; }
    .nav-top .user-info { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
    .nav-top .user-info strong { color: var(--navy); }
    .nav-top .user-info a { background: transparent; color: #b00020; padding: 7px 10px; }
    .nav-top .user-info a:hover { background: #fdecea; color: #b00020; }

    /* ---- Menu déroulant (Export) ---- */
    .nav-drop { position: relative; }
    .nav-drop .dd-btn { padding: 8px 16px; border-radius: 6px; text-decoration: none; font-size: 13px; font-weight: bold; color: var(--navy); background: #eef3f8; border: 1px solid transparent; transition: all .15s ease; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
    .nav-drop .dd-btn:hover { background: var(--green); color: #fff; }
    .nav-drop .dd-menu { position: absolute; top: calc(100% + 4px); left: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; min-width: 190px; box-shadow: 0 8px 20px rgba(0,0,0,.14); padding: 6px; display: none; z-index: 200; }
    .nav-drop.open .dd-menu { display: block; }
    .nav-drop .dd-menu a { display: block; padding: 9px 12px; border-radius: 5px; color: var(--navy); background: transparent; font-size: 13px; }
    .nav-drop .dd-menu a:hover { background: #e6f4ea; color: var(--green); }
    /* ---- Menu utilisateur (connecté) ---- */
    .nav-drop.user-drop { margin-left: auto; }
    .nav-drop.user-drop .dd-btn.user-btn { gap: 8px; background: #eaf5ee; border: 1px solid #c9e3d2; color: var(--navy); }
    .nav-drop.user-drop .dd-btn.user-btn:hover { background: var(--green); color: #fff; border-color: var(--green); }
    .nav-drop.user-drop .dd-btn.user-btn:hover .status-dot { background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.25); }
    .status-dot { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.22); flex-shrink: 0; animation: status-pulse 2s ease-in-out infinite; }
    @keyframes status-pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(34,197,94,.22); } 50% { box-shadow: 0 0 0 5px rgba(34,197,94,.12); } }
    .nav-drop.user-drop .dd-menu { left: auto; right: 0; min-width: 210px; }
    .dd-menu-head { padding: 9px 12px 10px; font-size: 12px; font-weight: bold; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
    .dd-menu-head::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #22c55e; display: inline-block; }
    .online-count { display: flex; align-items: center; gap: 8px; padding: 7px 12px; margin-bottom: 4px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
    .online-count .status-dot { width: 8px; height: 8px; box-shadow: 0 0 0 2px rgba(34,197,94,.18); }
    .nav-drop .dd-menu a.logout-link { color: #b00020; }
    .nav-drop .dd-menu a.logout-link:hover { background: #fdecea; color: #b00020; }
    .doc-title {
        text-align: center;
        margin-top: 16px;
        padding-top: 12px;
        border-top: 1px solid var(--line);
    }
    .doc-title h1 {
        margin: 0;
        font-size: 16.5px;
        color: var(--navy);
        text-transform: uppercase;
        line-height: 1.4;
    }
    .doc-title .sub {
        margin-top: 6px;
        font-size: 13px;
        color: var(--muted);
        font-style: italic;
    }

    /* ---- Messages ---- */
    .alert {
        padding: 14px 18px;
        border-radius: 6px;
        margin-bottom: 18px;
        font-size: 14px;
        border: 1px solid;
    }
    .alert-success {
        background: #e6f4ea;
        color: #135c2b;
        border-color: #b7e0c3;
    }
    .alert-error {
        background: #fdecea;
        color: #b00020;
        border-color: #f5c6cb;
    }

    /* ---- Navigation sections ---- */
    .nav-sections {
        background: #fff;
        border: 1px solid var(--line);
        padding: 12px 16px;
        margin-bottom: 18px;
        border-radius: 6px;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .nav-sections a {
        display: inline-block;
        padding: 6px 12px;
        background: var(--navy);
        color: #fff;
        text-decoration: none;
        font-size: 12.5px;
        border-radius: 4px;
    }
    .nav-sections a:hover { background: var(--navy-2); }

    /* ---- Cartes sections ---- */
    section.card {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 8px;
        margin-bottom: 22px;
        overflow: hidden;
        box-shadow: 0 1px 3px rgba(20, 50, 79, .06);
    }
    section.card .card-head {
        background: linear-gradient(135deg, #1e7d43, #14532d);
        color: #fff;
        padding: 13px 18px;
        font-weight: bold;
        font-size: 14px;
        letter-spacing: .5px;
        text-transform: uppercase;
    }
    section.card .card-head .ref {
        color: #ffe9b8;
        font-weight: normal;
    }
    section.card .card-body {
        padding: 18px;
    }

    h3.subtitle {
        font-size: 13.5px;
        color: var(--navy-2);
        border-left: 4px solid var(--orange);
        padding-left: 10px;
        margin: 22px 0 12px;
    }

    /* ---- Champs ---- */
    label.field {
        display: block;
        font-weight: bold;
        font-size: 12.5px;
        color: var(--text);
        margin-bottom: 4px;
    }
    label.field .num { color: var(--orange); }
    input[type="text"], input[type="date"], input[type="time"], input[type="number"],
    select, textarea {
        width: 100%;
        padding: 8px 10px;
        border: 1px solid #c3ccd6;
        border-radius: 4px;
        font-family: inherit;
        font-size: 13.5px;
        color: var(--text);
        background: #fff;
    }
    input:focus, select:focus, textarea:focus {
        outline: none;
        border-color: var(--navy-2);
        box-shadow: 0 0 0 2px rgba(31,78,121,.12);
    }
    textarea { resize: vertical; min-height: 64px; }
    input[readonly], input.calc {
        background: #f3f6f9;
        color: #33475b;
        font-weight: bold;
    }
    .grid {
        display: grid;
        gap: 14px;
    }
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
    .grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
    @media (max-width: 760px) {
        .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
        .doc-header .top { flex-direction: column; align-items: stretch; gap: 16px; }
        .doc-header .right { align-items: flex-start; text-align: left; }
        .logo-right { margin-left: 0; }
    }
    .hint { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 2px; }

    /* ---- Tableaux ---- */
    .table-wrap { overflow-x: auto; }
    table.data {
        width: 100%;
        border-collapse: collapse;
        font-size: 13px;
    }
    table.data th, table.data td {
        border: 1px solid var(--line);
        padding: 6px 7px;
        vertical-align: top;
    }
    table.data th {
        background: #e6edf4;
        color: var(--navy);
        font-size: 11.5px;
        text-align: center;
        white-space: nowrap;
        text-transform: uppercase;
        letter-spacing: .4px;
        font-weight: bold;
    }
    table.data td.center { text-align: center; }
    table.data input, table.data select {
        padding: 6px 7px;
        font-size: 13px;
    }
    #table-zones .zone-select,
    #table-zones .zone-input {
        min-width: 145px;
        transition: opacity .15s ease;
    }
    #table-zones .zone-livrable { min-width: 190px; }
    #table-zones .zone-lat,
    #table-zones .zone-lng { min-width: 105px; width: 105px; }
    #table-zones .zone-select.zone-loading,
    #table-zones .zone-input.zone-loading {
        opacity: .55;
    }
    table.data .row-num {
        text-align: center;
        color: var(--muted);
        font-weight: bold;
        width: 34px;
    }
    .btn-link {
        display: inline-block;
        margin-top: 10px;
        background: #fff;
        color: var(--green);
        border: 1px dashed var(--green);
        padding: 7px 14px;
        border-radius: 4px;
        cursor: pointer;
        font-size: 12.5px;
        font-weight: bold;
    }
    .btn-link:hover { background: #eef9f1; }
    .btn-mini {
        display: inline-block;
        padding: 5px 9px;
        border: 1px solid var(--green);
        border-radius: 4px;
        background: #fff;
        color: var(--green);
        font-size: 12px;
        font-weight: bold;
        cursor: pointer;
        white-space: nowrap;
    }
    .btn-mini:hover { background: #eef9f1; }
    .btn-mini:focus-visible { outline: 2px solid rgba(30, 125, 67, .35); outline-offset: 1px; }

    /* ---- Actions ---- */
    .actions {
        position: sticky;
        bottom: 0;
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 6px;
        padding: 14px 18px;
        margin-top: 10px;
        display: flex;
        gap: 12px;
        flex-wrap: wrap;
        box-shadow: 0 -2px 10px rgba(0,0,0,.06);
    }
    .btn {
        padding: 10px 20px;
        border: none;
        border-radius: 6px;
        font-size: 13.5px;
        font-weight: bold;
        cursor: pointer;
        letter-spacing: .3px;
        transition: all .15s ease;
        display: inline-flex;
        align-items: center;
        gap: 6px;
        text-decoration: none;
    }
    .btn-primary { background: var(--green); color: #fff; box-shadow: 0 2px 4px rgba(30, 125, 67, .25); }
    .btn-primary:hover { background: #176735; box-shadow: 0 3px 8px rgba(30, 125, 67, .35); }
    .btn-ghost { background: #fff; color: var(--navy); border: 1px solid var(--navy); }
    .btn-ghost:hover { background: #f0f4f8; }

    /* ---- Modale ---- */
    .modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
    .modal-box { background: #fff; border-radius: 8px; max-width: 520px; width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.28); overflow: hidden; }
    .modal-head { background: linear-gradient(135deg, #1e7d43, #14532d); color: #fff; padding: 16px 20px; font-weight: bold; font-size: 15px; }
    .modal-body { padding: 22px 20px; font-size: 14px; line-height: 1.6; color: var(--text); }
    .modal-foot { padding: 14px 20px; text-align: right; border-top: 1px solid var(--line); }

    /* ---- Accessibilité : focus clavier visible ---- */
    a:focus-visible,
    button:focus-visible,
    input:focus-visible,
    select:focus-visible,
    textarea:focus-visible,
    .btn:focus-visible {
        outline: 3px solid var(--orange);
        outline-offset: 2px;
    }
    .btn:disabled,
    button:disabled {
        opacity: .6;
        cursor: not-allowed;
        box-shadow: none;
    }
    .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;
    }

    /* ---- Responsive : navigation et en-tête ---- */
    @media (max-width: 760px) {
        .page { padding: 16px 12px 48px; }
        .nav-top { padding: 8px; gap: 5px; }
        .nav-top a, .nav-drop .dd-btn { padding: 8px 11px; font-size: 12.5px; }
        .nav-drop { flex: 1 1 auto; }
        .nav-drop .dd-btn { width: 100%; justify-content: center; }
        .nav-drop.user-drop {
            width: 100%;
            margin-left: 0;
            padding-top: 8px;
            border-top: 1px solid var(--line);
        }
        .nav-drop.user-drop .dd-btn.user-btn { width: 100%; }
        .doc-header { padding: 14px 16px; }
        .doc-title h1 { font-size: 15px; }
        .bar-row .lbl { width: 120px; }
    }
    @media (max-width: 480px) {
        .btn { width: 100%; justify-content: center; }
        .toolbar { flex-direction: column; align-items: stretch; }
        .doc-header .left, .doc-header .right { width: 100%; }
        .header-logo, .logo-right { height: 42px; }
    }

    /* ---- Respect de la préférence de réduction des animations ---- */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: .01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: .01ms !important;
            scroll-behavior: auto !important;
        }
    }

    /* ---- Impression ---- */
    @media print {
        body { background: #fff; }
        .page { max-width: none; padding: 0; }
        .nav-top, .nav-sections, .actions, .btn-link, .toolbar, .no-print, .user-info { display: none !important; }
        .doc-header { border: 1px solid #000; box-shadow: none; }
        section.card { border: 1px solid #000; page-break-inside: avoid; box-shadow: none; }
        section.card .card-head { background: var(--green) !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
        table.data th { background: #eee !important; -webkit-print-color-adjust: exact; }
        a[href]::after { content: ""; }
    }
