/* ApsyNDF v2 — design « Le bureau » : thème clair fixe, accents orange / rouge / jaune. */

:root {
    color-scheme: light;
    --bg: #faf8f5;
    --surface: #ffffff;
    --ink: #303036;
    --muted: #756f75;
    --line: #e8e0d9;
    --line-strong: #d9cdc2;
    --orange: #f18a00;
    --orange-ink: #8a4700;
    --orange-soft: #fff0dc;
    --red: #b30c30;
    --red-dark: #8f0a27;
    --red-soft: #fde8ec;
    --yellow-soft: #fff0c9;
    --yellow-ink: #805a00;
    --green-soft: #e3f4e8;
    --green-ink: #1f6b3a;
    --blue-soft: #e6effa;
    --blue-ink: #24548f;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(48, 48, 54, .05), 0 4px 16px rgba(48, 48, 54, .04);
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 16px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: var(--orange-ink); }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 1.75rem; line-height: 1.2; font-weight: 650; letter-spacing: -.5px; margin-bottom: 6px; }
h2 { font-size: 1.1rem; font-weight: 650; margin-bottom: 12px; }
h3 { font-size: 1rem; font-weight: 650; margin-bottom: 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #c26600; outline-offset: 2px; border-radius: 3px; }

.icon { flex: 0 0 auto; }
.muted { color: var(--muted); }
.fine { font-size: .8125rem; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: fixed; top: -60px; left: 16px; z-index: 100; background: #fff; padding: 10px 14px; }
.skip-link:focus { top: 8px; }
.hidden, [hidden] { display: none !important; }

/* ---------- Barre supérieure & navigation ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    height: 72px; padding: 0 24px;
    background: var(--surface); border-top: 4px solid var(--orange); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 18px; color: var(--ink); text-decoration: none !important; }
.brand img { height: 48px; width: auto; }
.brand-name { border-left: 1px solid var(--line); padding-left: 18px; font-weight: 600; font-size: 1.05rem; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-identity { display: flex; flex-direction: column; line-height: 1.25; font-size: .875rem; }
.topbar-identity small { color: var(--muted); }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--orange-soft); color: var(--orange-ink); font-weight: 650;
}
.button.menu-toggle { display: none; }

.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: calc(100vh - 72px); }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-section { margin: 18px 12px 6px; font-size: .6875rem; font-weight: 650; text-transform: uppercase; letter-spacing: 1.3px; color: #92878d; }
.nav-link {
    display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 7px;
    color: #5f585e; font-size: .9rem; text-decoration: none !important;
}
.nav-link:hover { background: #faf5ee; }
.nav-link.active { background: var(--orange-soft); color: var(--orange-ink); font-weight: 600; }

.main { padding: 28px 32px 64px; min-width: 0; max-width: 1280px; width: 100%; }

/* ---------- En-têtes de page ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 0; color: var(--muted); }
.eyebrow { display: block; font-size: .7rem; font-weight: 650; letter-spacing: 1.4px; text-transform: uppercase; color: #a35b10; margin-bottom: 6px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); margin-bottom: 10px; text-decoration: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Boutons ---------- */
.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 8px 15px; border-radius: var(--radius-sm);
    background: var(--surface); color: #4c444a; border: 1px solid var(--line-strong);
    font-size: .9rem; font-weight: 500; line-height: 1.2; text-decoration: none !important; cursor: pointer;
}
.button:hover { background: #fbf6ef; }
.button-primary { background: var(--red); border-color: var(--red); color: #fff; }
.button-primary:hover { background: var(--red-dark); }
.button-accent { background: var(--orange); border-color: var(--orange); color: #fff; }
.button-accent:hover { background: #d97b00; }
.button-danger { color: var(--red); border-color: #e9b8c3; }
.button-danger:hover { background: var(--red-soft); }
.button-quiet { border-color: transparent; background: transparent; }
.button-small { min-height: 32px; padding: 5px 10px; font-size: .82rem; }
.button-block { width: 100%; }
.button[disabled] { opacity: .55; cursor: not-allowed; }
.link-button { background: none; border: 0; padding: 0; color: var(--orange-ink); cursor: pointer; text-decoration: underline; }

/* ---------- Panneaux & cartes ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 20px; }
.panel.narrow { max-width: 640px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat strong { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .button { margin-top: 12px; }

/* ---------- Messages ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid; font-size: .92rem; }
.alert-success { background: var(--green-soft); border-color: #b9e0c5; color: var(--green-ink); }
.alert-error { background: var(--red-soft); border-color: #f3c0cb; color: var(--red-dark); }
.alert-info { background: var(--blue-soft); border-color: #c6d8ef; color: var(--blue-ink); }
.alert-warning { background: var(--yellow-soft); border-color: #f1dc9c; color: var(--yellow-ink); }

/* ---------- Statuts ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: #f1ece7; color: #5f585e; }
.badge-draft { background: #f1ece7; color: #5f585e; }
.badge-submitted, .badge-pending { background: var(--yellow-soft); color: var(--yellow-ink); }
.badge-approved { background: var(--green-soft); color: var(--green-ink); }
.badge-integrated { background: var(--blue-soft); color: var(--blue-ink); }
.badge-returned { background: var(--orange-soft); color: var(--orange-ink); }
.badge-rejected { background: var(--red-soft); color: var(--red-dark); }
.badge-archived { background: #eee; color: #777; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: #fdfaf6; }
.table tr.row-link { cursor: pointer; }
.table .actions { justify-content: flex-end; flex-wrap: nowrap; }
.table tfoot td { font-weight: 650; border-bottom: 0; }

/* ---------- Formulaires ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field-label { font-size: .875rem; font-weight: 600; }
.field .hint { font-size: .8rem; color: var(--muted); }
.required::after { content: " *"; color: var(--red); }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=month], input[type=search], select, textarea {
    width: 100%; min-height: 42px; padding: 8px 11px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--orange); outline: 2px solid rgba(241, 138, 0, .25); outline-offset: 0; }
input[type=file] { font-size: .875rem; }
input[readonly] { background: #f7f3ee; }
.input-suffix { display: flex; align-items: stretch; }
.input-suffix input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-suffix span { display: inline-flex; align-items: center; padding: 0 11px; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: #f7f3ee; color: var(--muted); font-size: .875rem; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 650; margin-bottom: 10px; padding: 0; }

/* Choix sous forme de cartes (oui / non, catégories) */
.choice-group { display: flex; gap: 10px; flex-wrap: wrap; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice span {
    display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 8px 16px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; font-size: .9rem; cursor: pointer;
}
.choice input:checked + span { border-color: var(--orange); background: var(--orange-soft); color: var(--orange-ink); font-weight: 600; }
.choice input:focus-visible + span { outline: 3px solid #c26600; outline-offset: 2px; }
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.category-grid .choice span { width: 100%; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--red); }
.checkbox-list { display: flex; flex-direction: column; gap: 8px; }

/* Bloc de calcul (estimation, km) */
.calc { margin-top: 6px; padding: 12px 14px; border-radius: var(--radius-sm); background: #fbf7f1; border: 1px dashed var(--line-strong); font-size: .875rem; }
.calc dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; margin: 0; }
.calc dt { color: var(--muted); }
.calc dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.calc .total { font-weight: 650; color: var(--ink); }
.calc-note { margin: 6px 0 0; }

/* Autocomplétion d'adresses */
.autocomplete { position: relative; }
.autocomplete-list {
    position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 2px);
    background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow);
    list-style: none; margin: 0; padding: 4px; max-height: 300px; overflow-y: auto;
}
.autocomplete-list li { padding: 8px 10px; border-radius: 5px; cursor: pointer; font-size: .9rem; }
.autocomplete-list li small { display: block; color: var(--muted); font-size: .78rem; }
.autocomplete-list li[aria-selected=true], .autocomplete-list li:hover { background: var(--orange-soft); }
.autocomplete-list .group { padding: 6px 10px 2px; font-size: .7rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); cursor: default; background: none !important; }

/* Pièces jointes */
.files { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.files li { display: flex; align-items: center; gap: 8px; font-size: .875rem; }
.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 14px; background: #fdfbf8; }

/* Historique */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--line); margin-left: 6px; font-size: .875rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--orange); }
.timeline li:last-child { border-left-color: transparent; }
.timeline time { color: var(--muted); font-size: .8rem; display: block; }
.timeline blockquote { margin: 4px 0 0; padding: 6px 10px; background: #faf6f1; border-radius: 5px; }

/* Résumé d'une note */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 20px; margin: 0; }
.summary dt { font-size: .78rem; color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; }
.layout-2 { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }

/* Filtres */
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filters .field { min-width: 180px; }

/* ---------- Lightbox ---------- */
.lightbox { border: 0; padding: 0; width: min(1100px, 96vw); height: min(92vh, 1000px); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.lightbox::backdrop { background: rgba(30, 26, 28, .55); }
.lightbox-inner { display: flex; flex-direction: column; height: 100%; }
.lightbox-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.lightbox-head h2 { margin: 0; font-size: 1rem; }
.lightbox-body { flex: 1; background: #525659; }
.lightbox-body iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ---------- Connexion ---------- */
body.public { min-height: 100vh; display: flex; flex-direction: column; padding: 16px; border-top: 4px solid var(--orange); }
.public-main { width: 100%; max-width: 460px; margin: auto; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 32px; box-shadow: var(--shadow); text-align: center; }
.login-logo { height: 72px; margin-bottom: 16px; }
.dev-login { margin-top: 26px; padding-top: 18px; border-top: 1px dashed var(--line-strong); text-align: left; }
.dev-login h2 { font-size: .95rem; margin-bottom: 2px; }
.dev-login-form { display: flex; gap: 8px; margin-top: 8px; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { display: none; position: fixed; top: 72px; left: 0; right: 0; bottom: 0; z-index: 15; overflow-y: auto; }
    .sidebar.open { display: flex; }
    .button.menu-toggle { display: inline-flex; }
    .topbar-identity, .hide-mobile { display: none; }
    .main { padding: 20px 16px 48px; }
    .layout-2 { grid-template-columns: 1fr; }
    .topbar { padding: 0 16px; }
    .brand-name { display: none; }
}
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    h1 { font-size: 1.45rem; }
    .panel { padding: 16px; }
    .table.responsive thead { display: none; }
    .table.responsive tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
    .table.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 6px; text-align: right; }
    .table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; }
    .table.responsive td.num { white-space: normal; }
    .table.responsive .actions { justify-content: flex-end; }
    .form-actions .button { flex: 1; }
}

/* Aperçu de document intégré */
.doc-preview { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 12px; }
.multi-select { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; max-height: 260px; overflow-y: auto; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fdfbf8; }
.level-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 14px; }
.level-box h3 { display: flex; align-items: center; gap: 8px; }
.level-chip { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--orange-soft); color: var(--orange-ink); font-size: .8rem; font-weight: 700; }
.circuit { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .875rem; }
.circuit .arrow { color: var(--muted); }
.section-title { margin-top: 22px; }

/* Statistiques cliquables */
a.stat { color: inherit; text-decoration: none; }
a.stat:hover { border-color: var(--orange); }

/* Onglets */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 9px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: .9rem; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--orange-ink); border-bottom-color: var(--orange); font-weight: 600; }

/* Choix de la catégorie de dépense */
.category-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.category-tile {
    display: flex; flex-direction: column; gap: 6px; padding: 18px; min-height: 120px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    color: var(--ink); text-decoration: none !important;
}
.category-tile .icon { width: 26px; height: 26px; color: var(--orange); }
.category-tile span { color: var(--muted); font-size: .85rem; }
.category-tile:hover { border-color: var(--orange); background: #fffaf3; }

/* Formulaire de trajet */
.quick-fill { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.mileage-calc dl { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line-strong); }

/* Liste des dépenses d'une note */
.expense-list { display: flex; flex-direction: column; }
.expense { border-top: 1px solid var(--line); padding: 14px 10px; }
.expense:first-child { border-top: 0; }
.expense-main { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 14px; align-items: start; }
.expense-date { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .875rem; padding-top: 1px; }
.expense-body { min-width: 0; font-size: .92rem; }
.expense-body .fine { margin-top: 2px; overflow-wrap: anywhere; }
.expense-amounts { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.expense-amounts .amount { font-weight: 650; font-size: 1rem; }
.expense-amounts .struck { text-decoration: line-through; color: var(--muted); font-size: .85rem; }
.expense-actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 0 106px; }
.files.inline { flex-direction: row; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }
.flag { display: inline-block; margin-top: 6px; padding: 3px 8px; border-radius: 5px; background: var(--yellow-soft); color: var(--yellow-ink); font-size: .8rem; }
.correction { margin-top: 6px; padding: 6px 10px; border-left: 3px solid var(--red); background: var(--red-soft); color: var(--red-dark); font-size: .82rem; border-radius: 0 5px 5px 0; }
.calc-line { color: var(--orange-ink); }
.correct-box { margin: 8px 0 0 106px; }
.correct-box summary { cursor: pointer; font-size: .85rem; color: var(--orange-ink); }
.correct-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 8px; padding: 12px; background: #fbf7f1; border-radius: var(--radius-sm); }
.correct-form .field { min-width: 130px; }
.correct-form .grow { flex: 1; min-width: 220px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 20px; margin: 16px 0 0; padding-top: 12px; border-top: 2px solid var(--line); font-size: .95rem; }
.totals dt { text-align: right; color: var(--muted); }
.totals dd { margin: 0; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; min-width: 110px; }
.totals .strong { color: var(--red-dark); }
.submit-panel form { justify-content: flex-end; }
.decision-panel { border-color: var(--orange); }

/* Suivi */
.summary-stack { grid-template-columns: 1fr; gap: 10px; }
.circuit-steps { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.circuit-steps li { display: flex; gap: 10px; align-items: center; font-size: .9rem; padding: 6px 8px; border-radius: 6px; }
.circuit-steps li.current { background: var(--yellow-soft); }

/* Lightbox : case intégrée */
.integrate-toggle { padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }

@media (max-width: 640px) {
    .expense-main { grid-template-columns: 1fr auto; }
    .expense-date { grid-column: 1 / -1; }
    .expense-actions, .correct-box { margin-left: 0; }
}

/* Page d'installation */
.install-card { text-align: left; max-width: 560px; }
.install-card h1, .install-card > .muted { text-align: center; }
.install-card .login-logo { display: block; margin: 0 auto 16px; }
.install-card h2 { margin-top: 22px; }
.checks { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.checks li { display: flex; gap: 10px; align-items: flex-start; }
.check-mark { flex: 0 0 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; }
.checks .ok .check-mark { background: var(--green-soft); color: var(--green-ink); }
.checks .ko .check-mark { background: var(--red-soft); color: var(--red-dark); }
.install-end { margin-top: 18px; }
.public-main:has(.install-card) { max-width: 560px; }

/* Bandeau du site de démonstration */
.demo-banner { background: var(--yellow-soft); color: var(--yellow-ink); text-align: center; font-size: .88rem; padding: 6px 16px; border-bottom: 1px solid var(--line); }

/* Mise en service */
.checks.readiness { margin: 0; gap: 0; font-size: .95rem; }
.checks.readiness li { align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.checks.readiness li:last-child { border-bottom: 0; }
.readiness-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.readiness-items { color: var(--ink); }

/* Note : dépenses à gauche, justificatif à droite (design « Le bureau ») */
.layout-proof { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 44%); gap: 20px; align-items: start; }
.main:has(.layout-proof) { max-width: 1600px; }
.proof-column { position: sticky; top: 88px; }
.proof-panel { display: flex; flex-direction: column; margin-bottom: 0; padding: 16px; }
.proof-panel .panel-head { margin-bottom: 10px; }
.proof-panel .empty .icon { width: 32px; height: 32px; color: var(--line-strong); }
.proof-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.proof-tab {
    display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; padding: 5px 10px;
    border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; font-size: .8rem; cursor: pointer; white-space: nowrap;
}
.proof-tab:hover { background: #fbf6ef; }
.proof-tab.active { border-color: var(--orange); background: var(--orange-soft); color: var(--orange-ink); font-weight: 600; }
.proof-number { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; border-radius: 50%; background: var(--line); font-size: .7rem; }
.proof-tab.active .proof-number { background: var(--orange); color: #fff; }
.proof-toolbar { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.proof-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; color: var(--muted); }
.proof-frame { width: 100%; height: calc(100vh - 260px); min-height: 420px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #e9e4de; display: block; }
.report-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 20px; }
.expense.is-viewed, .expense.has-proof.is-viewed:hover { background: var(--orange-soft); box-shadow: inset 3px 0 0 var(--orange); border-radius: 6px; }

@media (max-width: 1100px) {
    .layout-proof { grid-template-columns: 1fr; }
    .proof-main { display: contents; }
    .proof-main > * { order: 1; }
    .proof-column { position: static; order: 2; margin-bottom: 20px; }
    .proof-main > .report-meta { order: 3; }
    .proof-frame { height: 75vh; min-height: 360px; }
}

/* Compteur dans le menu (notes à valider, à intégrer, véhicules à approuver) */
.nav-badge {
    margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--red); color: #fff; font-size: .75rem; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* Bloc de dépense cliquable : affiche son justificatif dans la visionneuse */
.expense.has-proof { cursor: pointer; border-radius: 6px; transition: background .12s ease; }
.expense.has-proof:hover { background: #fdf8f1; }
.expense.has-proof:focus-visible { outline: 3px solid #c26600; outline-offset: 2px; }
.integrate-group { display: inline-flex; align-items: center; gap: 8px; }
.integrate-group.hidden { display: none; }
.payment-field { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; font-weight: 600; white-space: nowrap; }
.payment-field abbr { color: var(--red); text-decoration: none; }
.payment-field input { padding: 6px 8px; }
.payment-field.is-disabled { opacity: .55; }
.payment-date { display: block; margin-top: 3px; }

/* Emails (administration) */
.mail-body { white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: .92rem; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; margin: 0; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.template-editor { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.template-editor textarea { width: 100%; font-family: inherit; line-height: 1.5; }
.template-side { display: flex; flex-direction: column; gap: 16px; }
.variables { margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: .88rem; }
.variables dd { margin: 0; color: var(--muted); font-size: .82rem; }
.reset-template { margin-top: 12px; }
@media (max-width: 900px) { .template-editor { grid-template-columns: 1fr; } }

/* Barèmes : modification dans le tableau */
.table .actions form { display: inline-flex; }
.rate-edit td { background: #fbf7f1; }
.rate-edit-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.rate-edit-form .field { min-width: 140px; }
.rate-edit-form .grow { flex: 1; min-width: 200px; }
.rate-edit-form .full { flex-basis: 100%; margin: 0; }
.table.responsive tr.rate-edit.hidden { display: none !important; }
@media (max-width: 640px) {
    .table.responsive .rate-edit td { display: block; text-align: left; }
    .table.responsive .rate-edit td::before { content: none; }
}

/* Cellule d'actions des tableaux : reste une vraie cellule (lignes de séparation alignées),
   boutons alignés à droite sur une ligne. */
.table td.actions { display: table-cell; text-align: right; white-space: nowrap; }
.table td.actions > * { display: inline-flex; vertical-align: middle; }
.table td.actions > * + * { margin-left: 6px; }
@media (max-width: 640px) {
    .table.responsive td.actions { display: flex; justify-content: flex-end; gap: 6px; white-space: normal; }
    .table.responsive td.actions > * + * { margin-left: 0; }
}

/* Indicateur de chargement (PDF, justificatifs) */
.lightbox-body, .proof-stage { position: relative; }
.loader {
    position: absolute; inset: 0; z-index: 2;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    background: #f4efe9; color: var(--muted); font-size: .95rem;
}
.loader.hidden { display: none; }
.spinner {
    width: 42px; height: 42px; border-radius: 50%;
    border: 4px solid var(--orange-soft); border-top-color: var(--orange); border-right-color: var(--red);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* Règles et distances */
.rules { max-width: 900px; }
.rules h3 { margin-top: 16px; }
.rule-list { margin: 0 0 8px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.rule-table { margin: 6px 0 10px; }
.rule-table td.num { font-weight: 600; }
.distance-finder .distance-result { margin: 14px 0 0; font-size: 1.1rem; }
.distance-wrap { max-height: 70vh; }
.distance-table { font-size: .82rem; }
.distance-table th, .distance-table td { padding: 6px 8px; white-space: nowrap; }
.distance-table thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; text-align: right; }
.distance-table tbody th { position: sticky; left: 0; background: var(--surface); z-index: 1; text-align: left; font-weight: 600; text-transform: none; letter-spacing: 0; font-size: .82rem; color: var(--ink); }
.distance-table .corner { left: 0; z-index: 2; text-align: left; }
.distance-table td.self { background: #f1ece7; }
.distance-table tbody tr:hover td, .distance-table tbody tr:hover th { background: #fdf6ec; }
.distance-table td.fixed, .legend-fixed { font-weight: 700; text-decoration: underline; text-decoration-color: var(--orange); text-underline-offset: 3px; }
.cell-edit { font: inherit; color: inherit; background: none; border: 0; padding: 2px 4px; border-radius: 4px; cursor: pointer; text-decoration: inherit; }
.cell-edit:hover { background: var(--orange-soft); }
.simulator .form-grid { margin-top: 12px; }
.simulator-result { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 18px 0 8px; }
.simulator-result div { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.simulator-result dt { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.simulator-result dd { margin: 2px 0 0; font-size: 1.2rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.site-number { display: inline-block; min-width: 22px; color: var(--muted); font-weight: 400; }
.circuit-steps li.done .level-chip { background: var(--green-soft); color: var(--green-ink); }

/* Envoi de fichiers : zone de dépôt et aperçus */
.dropzone { display: flex; flex-direction: column; gap: 10px; }
.dropzone-target {
    position: relative; display: flex; align-items: center; justify-content: center; gap: 10px;
    min-height: 84px; padding: 16px; text-align: center; color: var(--muted); font-size: .9rem;
    border: 2px dashed var(--line-strong); border-radius: var(--radius); background: #fff; transition: border-color .12s, background .12s;
}
.dropzone-target .icon { width: 26px; height: 26px; color: var(--orange); transform: rotate(180deg); }
.dropzone-target strong { color: var(--ink); }
.dropzone-target:hover, .dropzone-target.is-dragging { border-color: var(--orange); background: var(--orange-soft); }
.dropzone-target:focus-within { outline: 3px solid #c26600; outline-offset: 2px; }
/* Le champ couvre toute la zone (clic, dépôt, message « champ obligatoire » du navigateur). */
.dropzone-target input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.has-files .dropzone-target { min-height: 56px; }
.upload-previews { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.upload-previews:empty { display: none; }
.upload-preview { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; font-size: .8rem; min-width: 0; }

.upload-preview.has-error { border-color: #f3c0cb; background: var(--red-soft); }
.upload-thumb { display: flex; align-items: center; justify-content: center; height: 150px; overflow: hidden; border-radius: 4px; background: #f4efe9; }
button.upload-thumb { width: 100%; border: 0; padding: 0; font: inherit; }
.upload-thumb { cursor: zoom-in; }
.upload-thumb:hover { outline: 2px solid var(--orange-soft); }
.lightbox-body > img { display: block; max-width: 100%; max-height: 100%; margin: auto; object-fit: contain; height: 100%; }
.upload-thumb img, .upload-thumb canvas { max-width: 100%; max-height: 150px; object-fit: contain; display: block; }
.upload-fallback { font-weight: 700; font-size: 1.4rem; color: var(--muted); }
.upload-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-error { color: var(--red-dark); }
.upload-remove {
    position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%;
    border: 1px solid var(--line-strong); background: #fff; color: var(--ink); font-size: 1rem; line-height: 1; cursor: pointer;
}
.upload-remove:hover { background: var(--red-soft); color: var(--red-dark); }
.hide-desktop { display: none; }
@media (max-width: 900px) { .hide-desktop { display: inline; } }
.upload-preview progress { width: 100%; height: 6px; accent-color: var(--orange); }
.upload-preview.is-uploading { border-color: var(--line-strong); }
.upload-preview.is-uploaded { border-color: #b9e0c5; }
.upload-preview.is-uploaded .fine { color: var(--green-ink); }
.dropzone > .alert { margin: 0; }
