/* =====================================================================
   Collecte - Feuille de style unique (site, espace intervenant, administration)
   Palette neutre : ardoise #0F172A, sarcelle #0F766E / #14B8A6. Telephone d'abord.
   Aucun style en ligne dans les pages (CSP style-src 'self') : les couleurs de statut sont des classes.
   ===================================================================== */

:root {
    --accent: #0F766E;
    --accent-2: #14B8A6;
    --accent-soft: #CCFBF1;
    --ink: #0F172A;
    --text: #334155;
    --muted: #64748B;
    --line: #E2E8F0;
    --bg: #F1F5F9;
    --surface: #FFFFFF;
    --ok: #166534; --ok-bg: #F0FDF4; --ok-line: #BBF7D0;
    --ko: #B91C1C; --ko-bg: #FEF2F2; --ko-line: #FECACA;
    --warn: #92400E; --warn-bg: #FFFBEB; --warn-line: #FDE68A;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 18px rgba(15, 23, 42, .06);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; color: var(--text); background: var(--bg);
    -webkit-font-smoothing: antialiased; min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3 { color: var(--ink); line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.05rem; }
a { color: var(--accent); }
img { max-width: 100%; }
p { margin: 0 0 .7em; }
code { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; font-size: .85em; word-break: break-all; }
.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: var(--ko); font-weight: 600; }
.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); border-radius: 8px; padding: 6px 10px; font-size: .88rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: .74rem; font-weight: 700; color: var(--accent); margin: 0 0 4px; }
.small-title { font-weight: 700; color: var(--ink); font-size: .9rem; margin: 18px 0 8px; }

/* ---------- Barre du haut ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px; background: var(--ink); color: #fff; border-bottom: 3px solid var(--accent-2); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; min-width: 0; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toplink, .linkbtn { color: rgba(255, 255, 255, .88); font: inherit; font-size: .9rem; background: none; border: 0; text-decoration: underline; cursor: pointer; padding: 6px 0; }
.topbar form { margin: 0; }

/* ---------- Mise en page ---------- */
main { flex: 1; width: 100%; }
.narrow { max-width: 680px; margin: 0 auto; padding: 20px 16px 48px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.prose p { white-space: normal; }
.foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; padding: 18px 16px 24px; font-size: .85rem; color: var(--muted); }
.foot a { color: var(--muted); }

/* ---------- Accueil ---------- */
.home { max-width: 900px; margin: 0 auto; padding: 0 16px 40px; }
.hero { text-align: center; padding: 48px 0 28px; }
.hero h1 { font-size: clamp(1.9rem, 6vw, 2.8rem); letter-spacing: -.02em; }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 560px; margin: 0 auto 28px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 12px; display: grid; gap: 4px; justify-items: center; }
.step span { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; }
.step b { color: var(--ink); }
.step small { color: var(--muted); font-size: .82rem; }
.contact { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 560px) { .steps { grid-template-columns: 1fr; } }

/* ---------- Boutons et formulaires ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: .66em 1.1em; border-radius: 10px; border: 1px solid transparent;
    font-family: inherit; font-weight: 600; font-size: .95rem; line-height: 1.2; cursor: pointer; text-decoration: none; text-align: center; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #115E59; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--ko-bg); color: var(--ko); border-color: var(--ko-line); }
.btn-sm { padding: .42em .8em; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-big { padding: .95em 1.1em; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-weight: 600; font-size: .85rem; color: var(--ink); }
.field small { color: var(--muted); font-size: .8rem; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=search], input[type=date], select, textarea {
    width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 1px solid #CBD5E1; border-radius: 9px; padding: .6em .75em; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); outline-offset: 0; border-color: var(--accent-2); }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; margin: 8px 0 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1.6fr; gap: 0 10px; }
.form-card { display: grid; gap: 4px; }
.form-card h1 { margin-bottom: 0; }

.flash { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: .93rem; background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-line); }
.flash-error { background: var(--ko-bg); color: var(--ko); border-color: var(--ko-line); }

/* ---------- Statuts ---------- */
.badge { --b: #64748B; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600;
    white-space: nowrap; color: var(--b); background: color-mix(in srgb, var(--b) 11%, #fff); border: 1px solid color-mix(in srgb, var(--b) 30%, #fff); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--b); }
.st-planned { --b: #64748B; }
.st-picked_up { --b: #2563EB; }
.st-in_progress { --b: #D97706; }
.st-ready { --b: #7C3AED; }
.st-returned { --b: #16A34A; }
.st-cancelled { --b: #DC2626; }

/* ---------- Suivi client ---------- */
.meta { color: var(--muted); }
.meta b { color: var(--ink); }
.timeline { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 0; }
.timeline li { position: relative; padding: 0 0 16px 30px; display: grid; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 4px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #CBD5E1; background: #fff; }
.timeline li::after { content: ""; position: absolute; left: 12px; top: 20px; bottom: 0; width: 2px; background: #E2E8F0; }
.timeline li:last-child::after { display: none; }
.timeline .tl-done::before { background: var(--accent); border-color: var(--accent); }
.timeline .tl-done::after { background: var(--accent); }
.timeline .tl-current::before { background: #fff; border: 4px solid var(--accent-2); }
.timeline .tl-todo b { color: var(--muted); font-weight: 500; }
.timeline small { color: var(--muted); font-size: .82rem; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin: 8px 0 12px; }
.gallery a, .gallery .photo-del { position: relative; display: block; aspect-ratio: 1; border-radius: 9px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-sm { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.stage-tag { position: absolute; left: 4px; bottom: 4px; background: rgba(15, 23, 42, .75); color: #fff; font-size: .68rem; font-weight: 700; border-radius: 5px; padding: 0 5px; }
.photo-del { margin: 0; }
.photo-del button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(185, 28, 28, .9); color: #fff; font-weight: 700; cursor: pointer; }
.signature { margin: 10px 0; }
.signature img { width: 100%; max-width: 360px; background: #fff; border: 1px solid var(--line); border-radius: 9px; display: block; }
.signature figcaption { font-size: .85rem; color: var(--muted); margin-top: 4px; }

/* ---------- Espace intervenant ---------- */
.iv-who-am-i strong { display: block; font-size: 1.02rem; }
.iv-who-am-i small { color: rgba(255, 255, 255, .7); font-size: .8rem; }
.iv-main { max-width: 640px; margin: 0 auto; padding: 14px 16px 60px; }
.iv-login { display: grid; gap: 12px; text-align: center; margin-top: 8vh; }
.iv-login input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; }
.iv-new { padding: 0; overflow: hidden; }
.iv-new > summary { list-style: none; border-radius: 0; padding: 1em; }
.iv-new > summary::-webkit-details-marker { display: none; }
.iv-new[open] > summary { background: var(--ink); }
.iv-new .iv-form { padding: 16px; }
.iv-group { display: flex; align-items: center; gap: 8px; font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; margin: 22px 0 10px; }
.iv-group span { background: var(--line); color: var(--text); border-radius: 999px; padding: 1px 9px; font-size: .78rem; }
.iv-card { border-left: 5px solid var(--b, #64748B); }
.st-line-planned { --b: #64748B; } .st-line-picked_up { --b: #2563EB; } .st-line-in_progress { --b: #D97706; }
.st-line-ready { --b: #7C3AED; } .st-line-returned { --b: #16A34A; } .st-line-cancelled { --b: #DC2626; }
.iv-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.iv-client { margin-bottom: 2px; }
.iv-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.iv-actions .btn { flex: 1 1 auto; }
.photo-form { margin: 10px 0; display: grid; gap: 8px; }
.photo-pick { position: relative; overflow: hidden; }
.photo-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.photo-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.photo-status { margin: 0; font-size: .88rem; }
.iv-next { margin: 12px 0 4px; }
.iv-note { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 12px; }
.iv-more { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.iv-more > summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .92rem; padding: 4px 0; }
.iv-form { display: grid; gap: 4px; margin-top: 8px; }
.iv-form select, .iv-form input[name=note] { margin-bottom: 8px; }
.desc { background: var(--bg); border-radius: 9px; padding: 10px 12px; font-size: .92rem; }
.history { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; font-size: .9rem; }

/* ---------- Pave de signature ---------- */
.sign-dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 20px)); max-width: none; box-shadow: 0 30px 70px rgba(0, 0, 0, .35); }
.sign-dialog::backdrop { background: rgba(15, 23, 42, .6); }
.sign-box { padding: 16px; display: grid; gap: 8px; }
.sign-box h2 { margin: 0; }
.sign-box p { margin: 0; }
#sign-pad { width: 100%; height: 220px; border: 2px dashed #94A3B8; border-radius: 10px; touch-action: none; background: #fff; }
.sign-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sign-actions #sign-ok { grid-column: 1 / -1; }

/* ---------- Administration ---------- */
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 16px; background: #1E293B; }
.admin-nav a { color: #CBD5E1; text-decoration: none; padding: 7px 12px; border-radius: 8px; font-size: .9rem; font-weight: 500; }
.admin-nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.admin-nav a.active { background: var(--accent); color: #fff; }
.admin-main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 5px 11px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: .85rem; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip b { font-weight: 700; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 12px; background: #F8FAFC; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr[data-href] { cursor: pointer; }
.table tr[data-href]:hover td { background: #F8FAFC; }
.table a { color: var(--ink); font-weight: 600; text-decoration: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: .93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); word-break: break-word; }
.link-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.link-box code { flex: 1 1 260px; }
.notice { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.notice strong { font-size: 1.15rem; letter-spacing: .08em; }
.var-list { columns: 2; font-size: .85rem; margin: 0; padding-left: 18px; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline { display: inline; margin: 0; }
.mt { margin-top: 14px; }
.actions-row input.pin-input { width: auto; flex: 1 1 220px; }
fieldset.card { box-shadow: none; margin: 14px 0; }
fieldset.card legend { padding: 0 6px; color: var(--ink); }
details > summary { cursor: pointer; }
.log { font-size: .85rem; }
.log .ko { color: var(--ko); }
.log .ok { color: var(--ok); }
@media (max-width: 860px) {
    .cols, .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .var-list { columns: 1; }
    .table.cards thead { display: none; }
    .table.cards tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
    .table.cards td { padding: 0; border: 0; }
    .table.cards td.hide-sm { display: none; }
}
