/* =====================================================================
 *  BELTRAME LOCATION V8 — Feuille de style (charte Groupe Beltrame)
 * ===================================================================== */
:root {
    --or: #E4B424;
    --or-texte: #B8901C;
    --or-clair: #FDF8EA;
    --anthracite: #1B2028;
    --anthracite-2: #262C36;
    --texte: #2D3748;
    --gris: #718096;
    --bordure: #E2E8F0;
    --fond-carte: #F7FAFC;
    --fond: #EEF1F5;
    --bleu: #1A569B; --bleu-fond: #EBF8FF; --bleu-barre: #3182CE;
    --rouge: #C53030; --rouge-fond: #FFF5F5;
    --vert: #38A169; --vert-fond: #F0FFF4;
    --radius: 8px;
    --header-h: 64px;
    --form-w: 500px;
    --shadow: 0 1px 2px rgba(27, 32, 40, .06), 0 4px 14px rgba(27, 32, 40, .06);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: Arial, Helvetica, sans-serif; font-size: 14px; color: var(--texte);
    background: var(--fond); min-height: 100vh; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
b.req { color: var(--rouge); font-weight: 700; }

/* ---------- Écran de chargement ---------- */
.loader-screen { position: fixed; inset: 0; z-index: 9999; background: var(--anthracite); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; transition: opacity .4s; }
.loader-logo { height: 54px; }
.loader-spinner { width: 36px; height: 36px; border: 3px solid rgba(228, 180, 36, .25); border-top-color: var(--or); border-radius: 50%; animation: spin 1s linear infinite; }
.loader-text { color: #fff; font-size: 14px; max-width: 760px; text-align: center; line-height: 1.5; padding: 0 20px; }
.loader-screen.erreur { justify-content: flex-start; padding-top: 60px; overflow-y: auto; }
.loader-screen.erreur .loader-spinner { display: none; }
.loader-error { background: #fff; color: var(--texte); border-left: 5px solid var(--rouge); border-radius: var(--radius); padding: 18px 22px; max-width: 820px; width: calc(100% - 32px); text-align: left; }
.loader-error h3 { margin: 0 0 8px; color: var(--rouge); text-transform: uppercase; font-size: 15px; }
.loader-error li { margin: 4px 0; font-family: Consolas, monospace; font-size: 12.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Bandeau ---------- */
.topbar {
    position: sticky; top: 0; z-index: 50; height: var(--header-h);
    display: flex; align-items: center; gap: 18px; padding: 0 20px;
    background: var(--anthracite); border-bottom: 3px solid var(--or); color: #fff;
}
.topbar-logo { height: 38px; }
.topbar-title { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-app { font-weight: 700; letter-spacing: 1px; font-size: 15px; }
.topbar-sub { color: var(--or); font-size: 11.5px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.badge-version { font-size: 11.5px; color: #CBD5E0; border: 1px solid #4A5568; border-radius: 20px; padding: 4px 10px; white-space: nowrap; }

/* ---------- Boutons ---------- */
.btn { font-family: inherit; font-size: 13px; font-weight: 700; border-radius: var(--radius); border: 1px solid transparent; padding: 9px 16px; cursor: pointer; transition: background .15s, border-color .15s, opacity .15s; white-space: nowrap; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--anthracite); color: #fff; border-color: var(--anthracite); }
.btn-primary:hover:not(:disabled) { background: #000; }
.btn-gold { background: var(--or); color: var(--anthracite); }
.btn-gold:hover:not(:disabled) { background: #F0C53A; }
.btn-ghost-light { background: transparent; color: #fff; border-color: #4A5568; }
.btn-ghost-light:hover { border-color: #fff; }
.btn-ghost { background: #fff; color: var(--texte); border-color: var(--bordure); }
.btn-ghost:hover { border-color: var(--gris); }
.btn-big { width: 100%; padding: 13px; font-size: 15px; letter-spacing: .5px; text-transform: uppercase; }
.btn-link { background: none; border: none; color: var(--or-texte); font-weight: 700; font-size: 12.5px; cursor: pointer; padding: 2px 0 10px; font-family: inherit; }
.btn-link:hover { text-decoration: underline; }
.btn-small { padding: 5px 10px; font-size: 12px; }

/* ---------- Mise en page ---------- */
.layout { display: grid; grid-template-columns: var(--form-w) minmax(0, 1fr); gap: 20px; padding: 20px; align-items: start; max-width: 1800px; margin: 0 auto; }
.panel-form { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 22px 0; }
.panel-results { position: sticky; top: calc(var(--header-h) + 20px); max-height: calc(100vh - var(--header-h) - 40px); overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-right: 4px; }

/* ---------- Formulaire ---------- */
.fsec { padding: 16px 0 10px; border-bottom: 1px solid var(--bordure); }
.fsec:last-of-type { border-bottom: none; }
.fsec-title { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--anthracite); }
.fsec-title .num { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; border-radius: 4px; background: var(--anthracite); color: var(--or); font-size: 12px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { grid-template-columns: 1.15fr 1fr 1fr; }
.row-4 { grid-template-columns: repeat(4, 1fr); }
.fg { margin-bottom: 10px; min-width: 0; }
label { display: block; font-size: 12px; font-weight: 700; color: var(--texte); margin-bottom: 5px; }
input[type=text], input[type=number], input[type=date], input[type=time], select {
    width: 100%; height: 38px; padding: 0 10px; font-family: inherit; font-size: 13.5px; color: var(--texte);
    background: #fff; border: 1px solid #CBD5E0; border-radius: 6px; transition: border-color .15s, box-shadow .15s, background .15s;
}
select { cursor: pointer; min-width: 0; max-width: 100%; text-overflow: ellipsis; }
input:focus, select:focus { outline: none; border-color: var(--or-texte); box-shadow: 0 0 0 3px rgba(228, 180, 36, .25); }
input:disabled, select:disabled { background: #F1F3F6; color: var(--gris); cursor: not-allowed; }
input.auto { background: var(--or-clair); border-style: dashed; border-color: var(--or); color: var(--or-texte); font-weight: 700; }
input.ok-coords { border-left: 4px solid var(--vert); }
input.err, select.err { border-color: var(--rouge); background: var(--rouge-fond); }
.hint { margin: 4px 0 0; font-size: 11.5px; color: var(--gris); line-height: 1.35; }
.hint b { color: var(--texte); }
.hint a, .hint .lien { color: var(--or-texte); font-weight: 700; cursor: pointer; text-decoration: underline; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 13px; margin: 2px 0 10px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--anthracite); margin: 0; }
.pin { display: inline-flex; width: 18px; height: 18px; border-radius: 50%; align-items: center; justify-content: center; font-size: 10px; color: #fff; margin-right: 6px; vertical-align: -3px; }
.pin-a { background: var(--vert); } .pin-b { background: var(--or-texte); } .pin-r { background: var(--bleu); } .pin-f { background: var(--rouge); } .pin-e { background: var(--gris); }

.etapes .etape { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.etapes .etape input { flex: 1; }
.etapes .etape .rm { flex: 0 0 34px; height: 34px; border: 1px solid var(--bordure); background: #fff; border-radius: 6px; cursor: pointer; color: var(--gris); font-size: 16px; }
.etapes .etape .rm:hover { color: var(--rouge); border-color: var(--rouge); }

.seg { display: flex; border: 1px solid #CBD5E0; border-radius: 6px; overflow: hidden; }
.seg button { flex: 1; border: none; background: #fff; padding: 9px 6px; font-family: inherit; font-size: 12.5px; cursor: pointer; color: var(--texte); border-right: 1px solid var(--bordure); }
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--anthracite); color: var(--or); font-weight: 700; }

.jours { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.jour { border: 1px solid var(--bordure); border-left: 4px solid var(--vert); border-radius: 6px; padding: 8px 10px; background: var(--fond-carte); }
.jour.excursion { border-left-color: var(--or); background: var(--or-clair); }
.jour-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.jour-head span:last-child { color: var(--gris); font-weight: 400; }
.jour .seg button { padding: 6px 4px; font-size: 12px; }
.jour .km { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; }
.jour .km input { height: 30px; width: 90px; }
.jours .vide { grid-column: 1 / -1; font-size: 12.5px; color: var(--gris); font-style: italic; }

.form-actions { position: sticky; bottom: 0; background: #fff; padding: 12px 0 16px; border-top: 1px solid var(--bordure); margin-top: 4px; z-index: 5; }
.missing { background: var(--rouge-fond); border-left: 4px solid var(--rouge); color: var(--rouge); font-size: 12.5px; padding: 8px 10px; border-radius: 4px; margin-bottom: 10px; line-height: 1.45; }

/* ---------- Résultats ---------- */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.empty { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; padding: 50px 30px; color: var(--gris); }
.empty-logo { width: 54px; opacity: .9; }
.empty h3 { color: var(--anthracite); text-transform: uppercase; letter-spacing: 1px; margin: 12px 0 8px; }

.stale { position: relative; }
.stale-banner { background: var(--or-clair); border: 1px solid var(--or); color: var(--anthracite); border-radius: var(--radius); padding: 10px 14px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stale .price, .stale .details { opacity: .45; filter: grayscale(.6); }

.price { background: var(--anthracite); color: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.price-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px; padding: 18px 22px 14px; border-bottom: 3px solid var(--or); }
.price-label { font-size: 11px; color: var(--or); text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700; }
.price-value { font-size: 40px; font-weight: 700; letter-spacing: -1px; line-height: 1.05; margin-top: 4px; }
.price-value small { font-size: 15px; font-weight: 400; color: #CBD5E0; letter-spacing: 0; }
.price-sub { font-size: 12.5px; color: #CBD5E0; margin-top: 6px; }
.price-lines { min-width: 230px; font-size: 13px; }
.price-lines div { display: flex; justify-content: space-between; gap: 18px; padding: 2px 0; }
.price-lines div span { color: #CBD5E0; }
.price-lines .tot { border-top: 1px solid #4A5568; margin-top: 4px; padding-top: 5px; font-weight: 700; color: var(--or); }
.price-lines .tot span { color: var(--or); }
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--anthracite-2); }
.kpi { padding: 10px 14px; border-right: 1px solid #343B47; }
.kpi:last-child { border-right: none; }
.kpi-l { font-size: 10.5px; color: #A0AEC0; text-transform: uppercase; letter-spacing: .6px; }
.kpi-v { font-size: 15px; font-weight: 700; margin-top: 3px; }
.kpi-v.pos { color: #68D391; } .kpi-v.neg { color: #FC8181; }

.alerts { display: flex; flex-direction: column; gap: 6px; }
.alert { border-radius: 6px; padding: 9px 12px; font-size: 13px; line-height: 1.4; border-left: 4px solid; }
.alert.stop { background: var(--rouge-fond); border-color: var(--rouge); color: #742A2A; font-weight: 700; }
.alert.warn { background: var(--or-clair); border-color: var(--or); color: #744210; }
.alert.info { background: var(--bleu-fond); border-color: var(--bleu-barre); color: #2A4365; }

.choice { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.choice-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--anthracite); }
.choice .opts { display: flex; gap: 10px; flex-wrap: wrap; }
.opt { border: 1px solid var(--bordure); border-radius: 6px; padding: 8px 12px; cursor: pointer; background: var(--fond-carte); font-size: 12.5px; text-align: left; font-family: inherit; color: var(--texte); }
.opt b { display: block; font-size: 15px; margin-top: 2px; }
.opt.active { border-color: var(--anthracite); background: var(--anthracite); color: #fff; }
.opt.active b { color: var(--or); }

.details { display: flex; flex-direction: column; gap: 12px; }
details.card > summary { list-style: none; cursor: pointer; padding: 13px 18px; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--anthracite); display: flex; justify-content: space-between; align-items: center; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: '+'; font-size: 18px; color: var(--or-texte); }
details.card[open] > summary::after { content: '–'; }
details.card > summary .sum-val { margin-left: auto; margin-right: 14px; color: var(--texte); letter-spacing: 0; font-size: 13.5px; text-transform: none; }
.card-body { padding: 0 18px 14px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--gris); font-weight: 700; padding: 6px 8px; border-bottom: 2px solid var(--bordure); }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--bordure); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl .sub td { color: var(--gris); font-size: 12.5px; }
.tbl .sub td:first-child { padding-left: 22px; }
.tbl .total td { font-weight: 700; border-top: 2px solid var(--anthracite); background: var(--fond-carte); }
.tbl .muted { color: var(--gris); font-size: 12px; }
.tag { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 3px; background: var(--fond-carte); border: 1px solid var(--bordure); color: var(--gris); text-transform: uppercase; }
.tag.calc { background: var(--or-clair); border-color: var(--or); color: var(--or-texte); }
.tl-time { font-weight: 700; white-space: nowrap; }

.map-card summary { padding: 13px 18px; }
.map { height: 360px; border-radius: 0 0 var(--radius) var(--radius); background: #E2E8F0; }

.toast { position: sticky; top: 0; z-index: 20; background: var(--anthracite); color: #fff; border-left: 4px solid var(--or); padding: 10px 14px; border-radius: 6px; font-size: 13px; box-shadow: var(--shadow); }
.toast.warn { border-left-color: var(--rouge); }

/* ---------- Écrans plus petits ---------- */
@media (max-width: 1500px) { :root { --form-w: 460px; } .kpis { grid-template-columns: repeat(3, 1fr); } .kpi:nth-child(3) { border-right: none; } }
@media (max-width: 1280px) { :root { --form-w: 420px; } .row-4 { grid-template-columns: 1fr 1fr; } .price-value { font-size: 34px; } }
@media (max-width: 1100px) {
    .layout { grid-template-columns: minmax(0, 1fr); padding: 12px; }
    .panel-results { position: static; max-height: none; overflow: visible; }
    .topbar-sub, .badge-version { display: none; }
}
@media (max-width: 620px) {
    .row, .row-3, .row-4 { grid-template-columns: 1fr; }
    .topbar { padding: 0 10px; gap: 8px; } .topbar-logo { height: 26px; } .topbar-title { display: none; }
    .topbar-actions .btn { padding: 8px 10px; font-size: 12px; }
    .panel-form { padding: 4px 14px 0; }
    .price-top { padding: 14px; } .price-value { font-size: 30px; } .price-lines { min-width: 0; width: 100%; }
    .tbl { font-size: 12px; } .tbl th, .tbl td { padding: 5px 4px; }
    .card-body { padding: 0 10px 12px; overflow-x: auto; }
    .kpis { grid-template-columns: 1fr 1fr; }
}

/* ---------- Impression : uniquement la fiche ---------- */
.print-only { display: none; }
@media print {
    @page { size: A4 portrait; margin: 10mm; }
    body { background: #fff; }
    .topbar, .layout, .loader-screen, .toast { display: none !important; }
    .print-only { display: block !important; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
