/*
 * Écrans terrain — feuille de style.
 * Esprit du kit de référence : Figtree, cartes blanches très arrondies, ombres douces,
 * violet pour l'action, jaune-vert pour ce qu'il faut savoir avant de passer.
 * Pensé pour une main, un pouce, et un écran en plein soleil : grands contrastes, cibles ≥ 44 px.
 */

:root {
    --bg: #F5F4F8;
    --card: #FFFFFF;
    --ink: #0C0C0C;
    --ink-2: #45444F;
    --ink-3: #85848F;
    --line: #ECEBF1;
    --primary: #7648D1;          /* violet de la marque, assombri pour un texte blanc lisible */
    --primary-press: #6438BD;
    --primary-soft: #F1EBFD;
    --brand: #905AFC;
    --lime: #F0EA4E;
    --lime-soft: #FAF7C8;
    --lime-ink: #4D4A0B;
    --red: #D92D20;
    --red-soft: #FDECEA;
    --amber: #B45309;
    --amber-soft: #FEF3DC;
    --green: #15803D;
    --green-soft: #E7F7EC;
    --solid: #0C0C0C;            /* boutons et bandeaux pleins (inversés) */
    --on-solid: #FFFFFF;
    --on-primary: #FFFFFF;       /* texte posé sur le violet */
    --on-amber: #FFFFFF;
    --tint: #FFFFFF;             /* couleur avec laquelle on éclaircit les étiquettes */
    --note-ink: #24230A;
    --chev: #C9C8D1;
    color-scheme: light;

    --r-xl: 24px;
    --r-l: 18px;
    --r-m: 14px;
    --r-s: 10px;
    --sh-1: 0 1px 2px rgba(18, 16, 40, .04), 0 6px 20px -12px rgba(18, 16, 40, .14);
    --sh-2: 0 2px 6px rgba(18, 16, 40, .06), 0 18px 40px -18px rgba(18, 16, 40, .28);
    --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
html.sheet-open { overflow: hidden; }
body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
[x-cloak] { display: none !important; }
.mono { font-family: var(--mono); letter-spacing: -.01em; }
.ico { flex: none; display: block; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }
.screen { padding: 12px 16px calc(96px + var(--safe-b)); }
.screen.has-actionbar { padding-bottom: calc(168px + var(--safe-b)); }

/* ── En-têtes ─────────────────────────────────────────────── */
.hero { padding: 20px 4px 18px; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--ink-3); letter-spacing: .01em; }
.hero h1 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin-top: 2px; }

.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    margin: -12px -16px 8px; padding: 10px 12px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.topbar-ref { font-size: 13px; color: var(--ink-3); }
.icon-btn {
    width: 44px; height: 44px; border-radius: 50%;
    display: grid; place-items: center; color: var(--ink);
    background: var(--card); box-shadow: var(--sh-1);
}
.icon-btn.ghost { visibility: hidden; }

/* ── Recherche ────────────────────────────────────────────── */
.searchbar {
    display: flex; align-items: center; gap: 12px;
    height: 56px; padding: 0 18px;
    border-radius: 999px; background: var(--card); box-shadow: var(--sh-1);
    color: var(--ink-3); font-size: 15px;
}
.searchbar.input { margin-top: 8px; color: var(--ink-2); }
.searchbar input {
    flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none;
    font-size: 17px; font-weight: 500; color: var(--ink);
}
.searchbar input::placeholder { color: var(--ink-3); font-weight: 400; }
.searchbar input::-webkit-search-cancel-button { -webkit-appearance: none; }
.spinner {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2.5px solid var(--primary-soft); border-top-color: var(--primary);
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Sections et listes ───────────────────────────────────── */
.section { margin-top: 26px; }
.az-letter { margin: 8px 4px -2px; font-size: 15px; font-weight: 800; color: var(--primary); }
.az-letter:first-child { margin-top: 0; }
.section-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: var(--ink-3); margin: 0 4px 10px;
}
.count {
    font-size: 12px; letter-spacing: 0; padding: 1px 8px; border-radius: 999px;
    background: var(--primary-soft); color: var(--primary);
}
.stack { display: flex; flex-direction: column; gap: 10px; }

.card { background: var(--card); border-radius: var(--r-l); box-shadow: var(--sh-1); }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 14px 14px 16px; min-height: 72px; }
.tap { transition: transform .12s ease; }
.tap:active { transform: scale(.985); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.row-sub { font-size: 14px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-chev { color: var(--chev); }

.avatar {
    width: 46px; height: 46px; border-radius: 15px; flex: none;
    display: grid; place-items: center;
    font-weight: 700; font-size: 15px; letter-spacing: -.02em;
    color: var(--c); background: color-mix(in srgb, var(--c) 13%, var(--tint));
}

/* Étiquettes de matériel : la couleur dit le type */
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.tag {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px 3px 7px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
    color: color-mix(in srgb, var(--c) 82%, black); background: color-mix(in srgb, var(--c) 12%, var(--tint));
}
.tag-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

.pill {
    flex: none; display: inline-flex; align-items: center;
    padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
    background: var(--line); color: var(--ink-2);
}
.pill.late { background: var(--red-soft); color: var(--red); }
.pill.soon { background: var(--amber-soft); color: var(--amber); }
.pill.done, .pill.ok { background: var(--green-soft); color: var(--green); }

.empty {
    margin: 48px 12px; text-align: center; color: var(--ink-3); font-size: 15px;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
}

/* ── Fiche client ─────────────────────────────────────────── */
.id-card { padding: 22px 20px 18px; border-radius: var(--r-xl); }
.client-name { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.client-addr { margin-top: 6px; color: var(--ink-2); font-size: 15px; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin-top: 18px; }
.quick-btn {
    height: 64px; border-radius: var(--r-m);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    background: var(--primary-soft); color: var(--primary);
    font-size: 13px; font-weight: 700;
}
.quick-btn:active { background: color-mix(in srgb, var(--primary-soft) 70%, var(--primary)); }
.second-phone { display: block; margin-top: 12px; font-size: 14px; color: var(--ink-3); }
.second-phone .mono { color: var(--ink-2); }

.note-card {
    margin-top: 12px; padding: 16px 18px;
    background: var(--lime-soft); box-shadow: none;
    border: 1px solid color-mix(in srgb, var(--lime) 55%, var(--tint));
}
.note-title {
    display: flex; align-items: center; gap: 6px;
    font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--lime-ink);
}
.note-body { margin-top: 8px; font-size: 16px; font-weight: 500; color: var(--note-ink); }
.note-meta { font-weight: 400; font-size: 13px; color: color-mix(in srgb, var(--lime-ink) 75%, var(--tint)); }

.visit-row { margin-top: 12px; color: var(--ink-2); }

.equip summary { list-style: none; display: flex; align-items: center; gap: 14px; padding: 14px 14px 14px 16px; min-height: 68px; cursor: pointer; }
.equip summary::-webkit-details-marker { display: none; }
.equip-dot { width: 12px; height: 40px; border-radius: 6px; background: var(--c); flex: none; }
.equip[open] .rot { transform: rotate(90deg); }
.rot { transition: transform .2s ease; }
.equip-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.specs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 12px 14px; border-radius: var(--r-m); background: var(--bg); }
.specs dt { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.specs dd { font-size: 15px; font-weight: 600; }
.hw { padding: 12px 14px; border-radius: var(--r-m); border: 1px solid var(--line); }
.hw-top { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.hw-name { font-weight: 600; margin-top: 2px; }
.serial {
    margin-top: 8px; display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: var(--r-s);
    background: var(--bg); font-size: 15px; font-weight: 600; color: var(--ink);
}
.serial .ico { color: var(--ink-3); }
.hw-warranty { margin-top: 8px; font-size: 13px; font-weight: 600; }
.hw-warranty.ok { color: var(--green); }
.hw-warranty.off { color: var(--ink-3); }

/* Historique */
.day + .day { margin-top: 18px; }
.day-label { font-size: 14px; font-weight: 700; margin: 0 4px 10px; color: var(--ink-2); }
.timeline { list-style: none; position: relative; padding-left: 34px; display: flex; flex-direction: column; gap: 10px; }
.timeline::before { content: ''; position: absolute; left: 13px; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: var(--line); }
.entry { position: relative; }
.entry-node {
    position: absolute; left: -34px; top: 12px;
    width: 28px; height: 28px; border-radius: 50%;
    display: grid; place-items: center; color: #fff;
    background: var(--ink-3); border: 3px solid var(--bg);
}
.type-intervention .entry-node { background: var(--primary); }
.type-photos .entry-node, .type-document .entry-node { background: #0891B2; }
.type-pose .entry-node { background: var(--green); }
.type-alerte .entry-node { background: var(--red); }
.entry-card { background: var(--card); border-radius: var(--r-m); box-shadow: var(--sh-1); padding: 12px 14px; }
.entry-meta { font-size: 13px; color: var(--ink-3); }
.entry-meta b { color: var(--ink-2); font-weight: 700; }
.entry-body { margin-top: 4px; font-size: 15.5px; color: var(--ink); overflow-wrap: anywhere; }
.entry-body strong { font-weight: 700; }
.thumbs { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.thumbs::-webkit-scrollbar { display: none; }
.thumbs img, .thumb-wait { width: 76px; height: 76px; border-radius: var(--r-s); object-fit: cover; flex: none; background: var(--primary-soft); display: grid; place-items: center; color: var(--primary); }
.more { width: 100%; height: 48px; margin-top: 14px; border-radius: var(--r-m); background: var(--card); box-shadow: var(--sh-1); font-weight: 600; color: var(--primary); }

/* ── Barre d'action et navigation ─────────────────────────── */
.actionbar {
    position: fixed; z-index: 30; left: 0; right: 0;
    bottom: calc(76px + var(--safe-b));
    max-width: 560px; margin: 0 auto; padding: 0 16px;
    display: flex; gap: 10px;
}
.btn {
    height: 56px; border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-weight: 700; font-size: 16px; letter-spacing: -.01em;
}
.btn.primary { flex: 1; background: var(--primary); color: var(--on-primary); box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--primary) 70%, transparent); }
.btn.primary:active { background: var(--primary-press); }
.btn.primary:disabled { opacity: .45; box-shadow: none; }
.btn.round { width: 56px; flex: none; background: var(--solid); color: var(--on-solid); box-shadow: var(--sh-2); }
.btn.block { width: 100%; margin-top: 14px; }

.tabbar {
    position: fixed; z-index: 25; left: 0; right: 0; bottom: 0;
    display: flex; justify-content: center; gap: 4px;
    padding: 8px 16px calc(8px + var(--safe-b));
    background: color-mix(in srgb, var(--card) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(16px);
    -webkit-backdrop-filter: saturate(1.4) blur(16px);
    border-top: 1px solid var(--line);
}
.tabbar a {
    flex: 1; max-width: 140px; height: 52px; border-radius: var(--r-m);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 11.5px; font-weight: 600; color: var(--ink-3);
}
.tabbar a.on { color: var(--primary); background: var(--primary-soft); }

/* ── Feuille d'ajout ──────────────────────────────────────── */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(12, 12, 20, .42); }
.sheet {
    position: fixed; z-index: 41; left: 0; right: 0; bottom: 0;
    max-width: 560px; margin: 0 auto; max-height: 92dvh; overflow-y: auto;
    padding: 8px 18px calc(18px + var(--safe-b));
    background: var(--card); border-radius: 26px 26px 0 0; box-shadow: var(--sh-2);
}
.sheet-in { animation: sheet-up .26s cubic-bezier(.2, .8, .2, 1); }
.sheet-out { animation: sheet-up .18s ease-in reverse; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
.sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 8px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.sheet-head .icon-btn { box-shadow: none; background: var(--bg); }
.sheet-hint { font-size: 13.5px; color: var(--ink-3); margin: 2px 0 12px; }
.sheet textarea {
    width: 100%; min-height: 120px; resize: vertical;
    padding: 14px 16px; border-radius: var(--r-m);
    border: 1.5px solid var(--line); background: var(--bg);
    font-size: 17px; line-height: 1.45; outline: 0;
}
.sheet textarea:focus { border-color: var(--brand); background: var(--card); }
.previews { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto; padding-bottom: 2px; }
.preview { position: relative; width: 84px; height: 84px; border-radius: var(--r-m); overflow: hidden; flex: none; background: var(--bg); }
.preview img { width: 100%; height: 100%; object-fit: cover; }
.preview button { position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(12, 12, 20, .62); }
.preview.add { display: grid; place-items: center; color: var(--primary); border: 1.5px dashed color-mix(in srgb, var(--primary) 40%, var(--tint)); background: var(--primary-soft); cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { height: 36px; padding: 0 14px; border-radius: 999px; background: var(--bg); font-size: 14px; font-weight: 600; color: var(--ink-2); }
.chip.on { background: var(--primary); color: var(--on-primary); }
.sheet-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tool {
    height: 44px; padding: 0 14px; border-radius: 999px;
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--bg); font-size: 14.5px; font-weight: 600; color: var(--ink-2); cursor: pointer;
    border: 0; max-width: 100%;
}
select.tool { appearance: none; padding-right: 16px; text-overflow: ellipsis; }
.tool.toggle.on { background: var(--lime); color: var(--lime-ink); }
.sheet-error { margin-top: 12px; padding: 10px 14px; border-radius: var(--r-s); background: var(--red-soft); color: var(--red); font-size: 14.5px; font-weight: 600; }

/* ── Notifications ────────────────────────────────────────── */
.toasts { position: fixed; z-index: 60; left: 0; right: 0; top: calc(12px + env(safe-area-inset-top, 0px)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 999px; background: var(--solid); color: var(--on-solid); font-weight: 600; font-size: 15px; box-shadow: var(--sh-2); animation: toast-in .25s ease; }
.toast.ok { background: var(--ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ── État du réseau et des envois ─────────────────────────── */
.netstatus {
    position: fixed; z-index: 35; left: 50%; transform: translateX(-50%);
    bottom: calc(84px + var(--safe-b));
    padding: 8px 16px; border-radius: 999px;
    background: var(--amber-soft); color: var(--amber);
    font-size: 13.5px; font-weight: 700; box-shadow: var(--sh-1);
    white-space: nowrap;
}
.netstatus.offline { background: var(--solid); color: var(--on-solid); }
.netstatus[hidden] { display: none; }
.pending-badge { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); font-size: 12px; font-weight: 700; }
.offline-banner { margin: 4px 0 14px; padding: 12px 16px; border-radius: var(--r-m); background: var(--solid); color: var(--on-solid); font-size: 14px; }
.offline-banner b { font-weight: 700; }
.btn.secondary { flex: 1; background: var(--primary-soft); color: var(--primary); height: 48px; font-size: 15px; }

/* Avec la barre d'action, la pastille passe au-dessus des boutons. */
body:has(.actionbar) .netstatus { bottom: calc(144px + var(--safe-b)); }
/* L'écran hors ligne a son propre bandeau. */
body.is-offline-shell .netstatus { display: none; }

.embark { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; padding: 12px 14px; border-radius: var(--r-m); background: var(--card); box-shadow: var(--sh-1); font-size: 14.5px; }
.embark .row-main { gap: 0; }
.embark button { flex: none; height: 38px; padding: 0 14px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 14px; }
.embark.done button { background: var(--green-soft); color: var(--green); }

/* ── Compte rendu d'intervention ──────────────────────────── */
.cr { padding-bottom: calc(40px + var(--safe-b)); }
body.is-report .tabbar { display: none; }
.cr-head { padding: 4px 4px 6px; }
.cr-head .client-name { font-size: 24px; }
.cr-resumed { margin-top: 10px; padding: 10px 14px; border-radius: var(--r-m); background: var(--lime-soft); color: var(--lime-ink); font-size: 14px; font-weight: 600; }
.cr-resumed button { margin-left: 6px; text-decoration: underline; font-weight: 700; color: inherit; }
.cr-sec { margin-top: 12px; padding: 16px 16px 18px; border-radius: var(--r-xl); scroll-margin-top: 72px; }
.cr-title { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 12px; }
.cr-num { width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); font-size: 14px; font-weight: 700; }
.cr-field { display: block; margin-top: 12px; }
.cr-field:first-child { margin-top: 0; }
.cr-label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.cr-hint { display: block; font-size: 13px; color: var(--ink-3); margin-top: 8px; }
.cr-hint.center { text-align: center; margin-top: 12px; }
.cr input[type=text], .cr input[type=date], .cr input[type=time], .cr textarea {
    width: 100%; min-height: 48px; padding: 12px 14px; border-radius: var(--r-m);
    border: 1.5px solid var(--line); background: var(--bg); font-size: 16px; outline: 0; resize: vertical;
}
.cr input:focus, .cr textarea:focus { border-color: var(--brand); background: var(--card); }
.cr-row { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; }
.cr-row > .cr-field { margin-top: 0; }
.cr-row > .cr-field:nth-child(3) { grid-column: 1 / -1; }
.cr-inline { display: flex; gap: 8px; align-items: center; }
.cr-inline input { flex: 1; }
.cr-inline .chip { height: 48px; flex: none; }
.cr-picks { display: flex; flex-direction: column; gap: 10px; }
.cr-inst { border-radius: var(--r-m); border: 1px solid var(--line); overflow: hidden; }
.cr-pick { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; min-height: 56px; }
.cr-pick + .cr-pick { border-top: 1px solid var(--line); }
.cr-pick.sub { padding-left: 38px; }
.cr-pick .ico { color: transparent; }
.cr-pick.on { background: var(--primary-soft); }
.cr-pick.on .ico { color: var(--primary); }
.cr-pick .equip-dot { height: 28px; width: 8px; }
.chip.warn.on { background: var(--amber); color: var(--on-amber); }
.cr-other { margin-top: 4px; }
.cr-photos + .cr-photos { margin-top: 14px; }
.cr-photos .previews { margin-top: 0; }
.cr .tool.toggle.on { background: var(--solid); color: var(--on-solid); }
.cr-sign { margin-top: 14px; }
.sigpad { position: relative; height: 180px; border-radius: var(--r-m); border: 2px dashed color-mix(in srgb, var(--primary) 35%, white); background: #fff; margin-bottom: 8px; }
.sigpad canvas { position: absolute; inset: 0; border-radius: inherit; }
.sigpad .sig-hint { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); font-size: 14px; pointer-events: none; }
.sigpad.signed { border-style: solid; border-color: var(--green); }
.sigpad.signed .sig-hint { display: none; }
.cr-submit { margin-top: 18px; height: 60px; font-size: 17px; }
.cr-warranty { display: flex; align-items: flex-start; gap: 8px; margin-top: 10px; padding: 10px 12px; border-radius: var(--r-m); background: var(--green-soft); color: var(--green); font-size: 14px; line-height: 1.4; }
.cr-warranty b { font-weight: 700; }
/* Checklist d'entretien et mesures */
#sec-checks[hidden] { display: none; }
/* Formulaire réglé par l'entreprise : champs obligatoires, champs ajoutés */
.cr-req { color: var(--red); font-weight: 700; }
.cr-opt { font-weight: 500; color: var(--ink-3); }
.cr-extra { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
.cr-extra .cr-seg { align-self: flex-start; }
.cr-unit { font-style: normal; font-weight: 700; color: var(--ink-3); min-width: 28px; }
@media (min-width: 768px) { .cr-extra { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cr-extra .cr-wide { grid-column: 1 / -1; } }
.cr-checks-head .cr-title { margin: 0; min-width: 0; white-space: nowrap; }
@media (max-width: 767px) { .cr-title-sub { display: none; } }
.cr-title-sub { font-weight: 500; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-drift { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 10px 12px; border-radius: var(--r-m); background: var(--amber-soft); color: var(--amber); font-size: 14px; font-weight: 600; }
.cr-checks-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.cr-checks-head .cr-label { margin: 0; }
.cr-checks-head .chip { height: 36px; white-space: nowrap; flex: none; }
.cr-check { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.cr-check:last-child { border-bottom: 0; }
.cr-check-label { flex: 1 1 180px; font-size: 15px; }
.cr-seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--bg); gap: 2px; }
.cr-seg button { min-width: 64px; height: 38px; padding: 0 10px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.cr-seg button.on.is-ok { background: var(--green); color: #fff; }
.cr-seg button.on.is-anomalie { background: var(--amber); color: var(--on-amber); }
.cr-seg button.on.is-na { background: var(--ink-3); color: #fff; }
.cr-measures { margin-top: 14px; }
.cr-measures-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.cr-measure { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.cr-measure .cr-inline input { min-width: 0; }
.cr-measure em { font-style: normal; font-weight: 700; color: var(--ink-3); min-width: 28px; }
.cr-measure small { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.quick-report { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; height: 52px; border-radius: var(--r-m); background: var(--solid); color: var(--on-solid); font-weight: 700; font-size: 15.5px; }

/* ── Menu du compte ─────────────────────────────────────────────── */
.hero-account { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.account { position: relative; flex: none; }
.avatar-btn {
    width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
    background: var(--brand, #905AFC); color: #fff; font: inherit; font-weight: 700; font-size: 17px;
    box-shadow: 0 4px 14px rgba(144, 90, 252, .3);
}
.avatar-btn { overflow: hidden; padding: 0; }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.account-menu {
    position: absolute; right: 0; top: 52px; z-index: 40; width: 260px; padding: 14px;
    display: grid; gap: 4px;
    box-shadow: 0 12px 40px rgba(24, 20, 48, .18), 0 2px 6px rgba(24, 20, 48, .06);
}
.account-name { font-weight: 700; font-size: 15px; }
.account-mail { font-size: 13px; color: var(--ink-3); margin-bottom: 8px; word-break: break-all; }
.account-item {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 10px;
    border: 0; border-radius: 12px; background: transparent; color: inherit; font: inherit; font-weight: 600;
    text-align: left; text-decoration: none; cursor: pointer;
}
.account-item:active, .account-item:hover { background: var(--bg); }
.account-item.danger { color: var(--red); }
.account-hint, .account-warning { font-size: 12px; color: var(--ink-3); padding: 4px 10px 0; line-height: 1.4; }
.account-warning { color: var(--amber); }

/* Logo de l'entreprise sur l'accueil. */
.brand-logo { display: block; max-height: 32px; max-width: 180px; object-fit: contain; margin-bottom: 14px; }
.brand-logo-dark { display: none; }

/* ── Itinéraire : choix de l'application ───────────────────────── */
.nav-pick { position: relative; }
.nav-pick > summary { list-style: none; cursor: pointer; }
.nav-pick > summary::-webkit-details-marker { display: none; }
.nav-pick[open] > summary { background: color-mix(in srgb, var(--primary-soft) 70%, var(--primary)); }
.nav-menu {
    position: absolute; top: 72px; left: 50%; transform: translateX(-50%); z-index: 30;
    width: 210px; padding: 6px; display: grid; gap: 2px;
    box-shadow: 0 12px 40px rgba(24, 20, 48, .18), 0 2px 6px rgba(24, 20, 48, .06);
}
.nav-menu a { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; border-radius: 12px; font-weight: 600; color: var(--ink); }
.nav-menu a:active, .nav-menu a:hover { background: var(--bg); }
.nav-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.nav-dot.waze { background: #33CCFF; }
.nav-dot.google { background: #34A853; }
.nav-dot.apple { background: #8E8E93; }
.nav-apple { display: none !important; }
.is-ios .nav-apple { display: flex !important; }

/* ── Mode sombre ───────────────────────────────────────────────────
 * Automatique (réglage du téléphone) ou forcé depuis le menu du compte (data-theme sur <html>).
 * La zone de signature reste blanche : la signature doit ressortir sur le PDF. */
:root[data-theme="dark"] {
    --bg: #0F0E14;
    --card: #1B1A23;
    --ink: #F2F1F6;
    --ink-2: #C9C7D4;
    --ink-3: #9C9AAB;
    --line: #2C2B36;
    --primary: #B79BFF;
    --primary-press: #A383FF;
    --primary-soft: #2A2142;
    --brand: #A47BFF;
    --lime: #D9D23A;
    --lime-soft: #2A2914;
    --lime-ink: #E9E4A2;
    --red: #FF8A7E;
    --red-soft: #3B1916;
    --amber: #F6B54E;
    --amber-soft: #3A2B10;
    --green: #5BE38E;
    --green-soft: #12301E;
    --solid: #F2F1F6;
    --on-solid: #121119;
    --on-primary: #170C33;
    --on-amber: #241600;
    --tint: #1B1A23;
    --note-ink: #F4F0BF;
    --chev: #5D5B6B;
    --sh-1: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -14px rgba(0, 0, 0, .6);
    --sh-2: 0 2px 6px rgba(0, 0, 0, .35), 0 18px 40px -18px rgba(0, 0, 0, .7);
    color-scheme: dark;
}

/* Étiquettes : sur fond sombre, la couleur du type est éclaircie pour rester lisible. */
:root[data-theme="dark"] .tag, :root[data-theme="dark"] .avatar { color: color-mix(in srgb, var(--c) 55%, white) !important; }
/* Le logo (souvent sombre sur transparent) garde un fond clair. */
:root[data-theme="dark"] .brand-logo { background: #FFFFFF; padding: 6px 10px; border-radius: 10px; box-sizing: content-box; }
/* …sauf s'il existe un logo prévu pour le mode sombre (Paramètres). */
:root[data-theme="dark"] .has-dark-logo .brand-logo { display: none; }
:root[data-theme="dark"] .has-dark-logo .brand-logo-dark { display: block; background: none; padding: 0; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
    --bg: #0F0E14;
    --card: #1B1A23;
    --ink: #F2F1F6;
    --ink-2: #C9C7D4;
    --ink-3: #9C9AAB;
    --line: #2C2B36;
    --primary: #B79BFF;
    --primary-press: #A383FF;
    --primary-soft: #2A2142;
    --brand: #A47BFF;
    --lime: #D9D23A;
    --lime-soft: #2A2914;
    --lime-ink: #E9E4A2;
    --red: #FF8A7E;
    --red-soft: #3B1916;
    --amber: #F6B54E;
    --amber-soft: #3A2B10;
    --green: #5BE38E;
    --green-soft: #12301E;
    --solid: #F2F1F6;
    --on-solid: #121119;
    --on-primary: #170C33;
    --on-amber: #241600;
    --tint: #1B1A23;
    --note-ink: #F4F0BF;
    --chev: #5D5B6B;
    --sh-1: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -14px rgba(0, 0, 0, .6);
    --sh-2: 0 2px 6px rgba(0, 0, 0, .35), 0 18px 40px -18px rgba(0, 0, 0, .7);
    color-scheme: dark;
    }

/* Étiquettes : sur fond sombre, la couleur du type est éclaircie pour rester lisible. */
:root:not([data-theme="light"]) .tag, :root:not([data-theme="light"]) .avatar { color: color-mix(in srgb, var(--c) 55%, white) !important; }
/* Le logo (souvent sombre sur transparent) garde un fond clair. */
:root:not([data-theme="light"]) .brand-logo { background: #FFFFFF; padding: 6px 10px; border-radius: 10px; box-sizing: content-box; }
:root:not([data-theme="light"]) .has-dark-logo .brand-logo { display: none; }
:root:not([data-theme="light"]) .has-dark-logo .brand-logo-dark { display: block; background: none; padding: 0; }
}

/* Choix du thème dans le menu du compte */
.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin: 6px 0 4px; border-radius: 12px; background: var(--bg); }
.theme-switch button { min-height: 44px; border-radius: 9px; display: grid; place-items: center; color: var(--ink-3); }
.theme-switch button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--sh-1); }

/* Ma tournée du jour : numéro d'ordre de passage */
.tour-n { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font-weight: 800; font-size: 14px; }
.tour-route { display: flex; align-items: center; justify-content: center; text-decoration: none; }
/* Prochain arrêt de la tournée : lancer la navigation d'un geste. */
.next-stop { display: flex; flex-direction: column; gap: 10px; padding: 16px; margin-bottom: 12px; box-shadow: var(--sh-1), inset 0 0 0 1.5px color-mix(in srgb, var(--primary) 30%, transparent); }
.next-kicker { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--primary); }
.next-client { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; }
.next-client .row-title { font-size: 18px; }
.next-actions { display: flex; gap: 8px; }
.next-actions .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; text-decoration: none; }
.next-actions .next-alt { flex: 0 0 auto; padding: 0 18px; }
.next-stop.is-done { flex-direction: row; align-items: center; gap: 10px; font-weight: 700; color: var(--primary); box-shadow: var(--sh-1); }
.row.is-done { opacity: .6; }
.row.is-done .tour-n { background: var(--primary-soft); color: var(--primary); }
.row.is-next { box-shadow: var(--sh-1), inset 3px 0 0 var(--primary); }

/* Logo texte (Paramètres → Apparence) : suit le thème et le mode sombre */
.ce-wordmark { display: inline-flex; align-items: center; gap: .5em; font-family: var(--ce-display, var(--font)); font-weight: 800; font-size: 22px; line-height: 1; letter-spacing: -.025em; color: var(--ink); white-space: nowrap; }
.ce-wordmark-mark { flex: none; width: 1.1em; height: 1.1em; border-radius: 999px; background: linear-gradient(to bottom, var(--ce-sun) 0 55%, var(--ce-hill) 55% 100%); }
.ce-wordmark-accent { color: var(--ce-accent, var(--primary)); }
:root[data-theme="dark"] .ce-wordmark-accent { color: var(--ce-accent-dark, var(--primary)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ce-wordmark-accent { color: var(--ce-accent-dark, var(--primary)); } }
.brand-logos .ce-wordmark { margin-bottom: 10px; }

/* ── Tablette (iPad et grands écrans) ─────────────────────────────────────
 * Le téléphone garde sa colonne unique. À partir de 768 px, on profite de la largeur :
 * accueil et fiche client sur deux colonnes, compte rendu plus aéré, grand cadre de signature.
 */
@media (min-width: 768px) {
    .app { max-width: 1180px; }
    .screen { padding: 16px 28px calc(104px + var(--safe-b)); }
    .topbar { margin: -16px -28px 12px; padding: 12px 20px; }
    .hero { padding-top: 28px; }
    .hero h1 { font-size: 34px; }
    .searchbar.input { max-width: 720px; }

    /* Accueil : deux colonnes */
    .home-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 0 28px; align-items: start; }
    .home-col { min-width: 0; }
    .home-grid.is-single { grid-template-columns: minmax(0, 760px); }
    /* Liste des clients : deux colonnes */
    .az-list .stack { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
    .az-list .az-letter { grid-column: 1 / -1; }

    /* Fiche client : la fiche reste visible à gauche, l'historique défile à droite */
    .client-grid { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 24px; align-items: start; }
    .client-aside { position: sticky; top: 76px; max-height: calc(100dvh - 92px); overflow-y: auto; padding: 2px 4px 24px; margin: -2px -4px 0; scrollbar-width: thin; }
    .client-main { min-width: 0; }
    .client-main > .section:first-child { margin-top: 0; }

    /* Feuilles et barres : un peu plus larges, centrées */
    .sheet { max-width: 640px; border-radius: 26px; bottom: 24px; }
    .tabbar a { max-width: 180px; }

    /* Compte rendu : plus large, champs côte à côte */
    .cr { max-width: 980px; margin: 0 auto; }
    .cr-head .client-name { font-size: 30px; }
    .cr-sec { padding: 20px 22px 22px; }
    .cr-row { grid-template-columns: 1.2fr 1fr 1.3fr; }
    .cr-row > .cr-field:nth-child(3) { grid-column: auto; }
    .previews { flex-wrap: wrap; overflow-x: visible; }
    .preview { width: 112px; height: 112px; }
    .thumbs img, .thumb-wait { width: 96px; height: 96px; }
    /* Le client signe confortablement sur une tablette */
    .sigpad { height: 300px; }
    .sigpad .sig-hint { font-size: 16px; }
    .cr-submit { display: flex; max-width: 480px; margin-left: auto; margin-right: auto; }
    /* Photos : les quatre étapes côte à côte */
    #sec-7 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 18px; }
    #sec-7 > .cr-title { grid-column: 1 / -1; margin-bottom: 0; }
    .cr-photos + .cr-photos { margin-top: 0; }
    /* Fiche client : sur tablette, les boutons d'ajout restent en tête de l'historique, pas en bas de l'écran */
    .client-main > .actionbar { position: sticky; top: 68px; z-index: 15; left: auto; right: auto; bottom: auto; max-width: none; margin: -8px 0 10px; padding: 8px 0;
        background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); }
    body:has(.actionbar) .netstatus { bottom: calc(88px + var(--safe-b)); }
    .screen.has-actionbar { padding-bottom: calc(104px + var(--safe-b)); }
}

/* iPad à l'horizontale : les six premières parties du compte rendu deux par deux, comme sur la feuille */
@media (min-width: 1024px) {
    .cr-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; align-items: stretch; }
    .cr-grid > .cr-span { grid-column: 1 / -1; }
    /* Les points contrôlés sur deux colonnes, les mesures sur une ligne */
    .cr-checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
    .cr-checks .cr-check:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
    .cr-measures-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
    .cr-grid .cr-row { grid-template-columns: 1.3fr 1fr; }
    .cr-grid .cr-row > .cr-field:nth-child(3) { grid-column: 1 / -1; }
    .client-grid { grid-template-columns: 400px minmax(0, 1fr); gap: 32px; }
    .sigpad { height: 340px; }
}
