/* Mobile first : la base vise un téléphone ; ≥700px tablette, ≥1024px ordinateur (menu latéral). */
:root {
    --bg: #f4f5f7; --surface: #fff; --fg: #1d2330; --muted: #6b7385; --faint: #a3a9b6;
    --border: #e4e7ec; --border-strong: #d3d8e0; --border-hover: #bcc3ce; --subtle: #f7f8fa;
    --fg-2: #4a5263; --neutral-soft: #eceef2;
    --accent: #1f5eff; --accent-hover: #1a50dc; --accent-soft: #eaf0ff; --accent-fg: #fff;
    --ok: #1a8a4a; --ok-soft: #e2f5e9; --ok-soft-hover: #d3efdf; --warn: #b7791f; --warn-soft: #fcf0d9; --err: #c53030; --err-soft: #fde7e7;
    --shadow-sm: 0 1px 2px rgb(16 24 40 / .05);
    --shadow: 0 1px 3px rgb(16 24 40 / .07), 0 1px 2px rgb(16 24 40 / .04);
    --shadow-lg: 0 16px 40px -12px rgb(16 24 40 / .22), 0 2px 6px rgb(16 24 40 / .05);
    --radius: 16px; --radius-sm: 11px; --tap: 48px;
    --appbar-h: 56px; --nav-h: 66px; --content: 1120px;
    --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
    color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--fg);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body:has(.sheet[open]) { overflow: hidden; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
h1, h2, h3 { letter-spacing: -.015em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
em { font-style: normal; font-weight: 400; color: var(--faint); }
.icon { width: 20px; height: 20px; flex: none; }
.icon-xl { width: 36px; height: 36px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ================= Navigation : onglets en bas (mobile) / menu latéral (ordinateur) ================= */
.nav {
    position: fixed; inset: auto 0 0 0; z-index: 30; padding-bottom: var(--safe-b);
    background: rgb(255 255 255 / .94); backdrop-filter: saturate(1.8) blur(14px); -webkit-backdrop-filter: saturate(1.8) blur(14px);
    border-top: 1px solid var(--border);
}
.nav-brand, .nav-user { display: none; }
.nav-items { display: flex; }
.nav-items a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: var(--nav-h); color: var(--muted); font-size: .72rem; font-weight: 600; text-decoration: none;
}
.nav-ico { display: grid; place-items: center; width: 56px; height: 30px; border-radius: 15px; transition: background .15s; }
.nav-items a.active { color: var(--accent); }
.nav-items a.active .nav-ico { background: var(--accent-soft); }
.brand-mark {
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: var(--accent-fg);
    background: linear-gradient(140deg, var(--accent) 0%, #5a8bff 100%); box-shadow: 0 6px 14px -4px rgb(31 94 255 / .55);
}
.brand-mark .icon { width: 19px; height: 19px; }

/* ================= Barre du haut ================= */
.appbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 4px;
    min-height: calc(var(--appbar-h) + var(--safe-t)); padding: var(--safe-t) 4px 0 16px;
    background: rgb(244 245 247 / .9); backdrop-filter: saturate(1.8) blur(14px); -webkit-backdrop-filter: saturate(1.8) blur(14px);
}
.appbar:has(> .back) { padding-left: 4px; }
.appbar form { margin: 0; }
.appbar-title { flex: 1; min-width: 0; margin: 0; font-size: 1.2rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
    display: inline-grid; place-items: center; flex: none; width: var(--tap); height: var(--tap);
    border: 0; border-radius: 50%; background: transparent; color: var(--fg); cursor: pointer; text-decoration: none;
    transition: background .15s;
}
.icon-btn:hover, .icon-btn:active { background: rgb(16 24 40 / .06); }

main { max-width: calc(var(--content) + 24px); margin: 0 auto; padding: 4px 12px 24px; }
body.app main { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 24px); }

/* ================= Blocs génériques ================= */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.cards { display: grid; gap: 12px; }
.section-title {
    display: flex; align-items: center; gap: 8px; min-height: 36px; margin: 22px 2px 8px;
    font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.section-title:first-child, #toast + .section-title, .hint + .section-title { margin-top: 4px; }
.section-title.late { color: var(--err); }
.section-title form { margin: 0 0 0 auto; }
.count {
    min-width: 22px; padding: 1px 7px; border-radius: 999px; background: rgb(16 24 40 / .07);
    color: var(--fg); font-size: .72rem; text-align: center; letter-spacing: 0;
}
.section-title.late .count { background: var(--err-soft); color: var(--err); }
.section-link {
    margin-left: auto; display: inline-flex; align-items: center; gap: 5px; min-height: 36px; padding: 0 10px;
    border: 0; border-radius: 999px; background: none; color: var(--accent); font-size: .85rem; font-weight: 600;
    letter-spacing: 0; text-transform: none; text-decoration: none; cursor: pointer;
}
.section-link:hover { background: var(--accent-soft); }
.section-link .icon { width: 17px; height: 17px; }
.empty {
    display: grid; justify-items: center; gap: 6px; padding: 40px 20px; text-align: center; color: var(--muted);
    border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
}
.empty p { margin: 0; }
.empty strong { color: var(--fg); font-size: 1.05rem; }
.empty .btn { margin-top: 10px; }
.empty-ico { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 6px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); }
.hint { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--accent-soft); color: #22346b; font-size: .93rem; }

.bar { display: block; height: 6px; border-radius: 3px; background: var(--neutral-soft); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #22a35a, var(--ok)); }

.badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px;
    background: var(--neutral-soft); color: var(--fg-2); font-size: .74rem; font-weight: 600; line-height: 1.35; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.status-realise, .badge.stage-gagne { background: var(--ok-soft); color: var(--ok); }
.badge.status-absent, .badge.status-reporte, .badge.stage-a_relancer { background: var(--warn-soft); color: var(--warn); }
.badge.status-annule, .badge.stage-perdu { background: var(--err-soft); color: var(--err); }
.badge.stage-rdv_planifie, .badge.stage-interesse { background: var(--accent-soft); color: var(--accent); }

.alert { margin-bottom: 12px; padding: 12px 14px; border: 1px solid; border-radius: var(--radius-sm); font-size: .95rem; }
.alert-success { background: #e9f7ee; border-color: #bfe5cd; color: #14663a; }
.alert-warning { background: #fdf4e1; border-color: #f1dcaa; color: #86581a; }
.alert-error { background: #fdecec; border-color: #f3c3c3; color: #9b2222; }

/* ================= Boutons et champs (cibles ≥ 44px, police 16px : pas de zoom iOS) ================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 18px;
    border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); color: var(--fg);
    box-shadow: var(--shadow-sm); font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--subtle); border-color: var(--border-hover); }
.btn:active { transform: scale(.98); }
.btn .icon { width: 18px; height: 18px; }
.btn-primary {
    background: var(--accent); border-color: var(--accent); color: var(--accent-fg);
    box-shadow: 0 1px 2px rgb(31 94 255 / .35), inset 0 1px 0 rgb(255 255 255 / .14);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-done { background: var(--ok-soft); border-color: transparent; color: var(--ok); box-shadow: none; }
.btn-done:hover { background: var(--ok-soft-hover); border-color: transparent; }
.btn-block { width: 100%; }

.form-grid { display: grid; gap: 16px; }
.row-2 { display: grid; gap: 16px; }
@media (min-width: 480px) { .row-2 { grid-template-columns: 1fr 1fr; gap: 12px; } }
.field { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field > span, .field > legend { padding: 0; font-size: .84rem; font-weight: 600; color: var(--fg-2); }
.field > legend { margin-bottom: 8px; }
input, select, textarea {
    width: 100%; min-height: var(--tap); padding: 10px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--fg); font: inherit; font-size: 16px; box-shadow: var(--shadow-sm);
    transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { min-height: 92px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgb(31 94 255 / .14); }
input[type="file"] { padding: 9px; background: var(--surface); }
input[type="file"]::file-selector-button {
    margin-right: 12px; padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: 8px;
    background: var(--subtle); color: var(--fg); font: inherit; font-weight: 600; cursor: pointer;
}
details.more > summary { display: flex; align-items: center; gap: 6px; min-height: 44px; color: var(--accent); font-weight: 600; cursor: pointer; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸"; transition: transform .15s; }
details.more[open] > summary::before { transform: rotate(90deg); }
details.more[open] > summary { margin-bottom: 8px; }

/* Choix tactiles (boutons radio en pastilles) */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; display: inline-flex; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; padding: 0; }
.choice span {
    display: inline-flex; align-items: center; min-height: 42px; padding: 0 15px; border: 1px solid var(--border-strong);
    border-radius: 999px; background: var(--surface); color: var(--fg); font-size: .92rem; font-weight: 500;
    white-space: nowrap; cursor: pointer; transition: background .12s, border-color .12s, color .12s;
}
.choice span:hover { border-color: var(--border-hover); }
.choice input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; box-shadow: 0 2px 6px -2px rgb(31 94 255 / .5); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Résultat / interlocuteur / documents : seulement si le RDV a eu lieu. */
form:has(input[name="status"]:not([value="realise"]):checked) .when-realise { display: none; }

/* Pastilles de filtre défilant horizontalement */
.chips { display: flex; gap: 8px; margin: 0 -12px; padding: 4px 12px 10px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips .choice span { min-height: 38px; }
.chip {
    flex: none; display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 14px;
    border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--fg);
    font-size: .9rem; font-weight: 500; text-decoration: none; white-space: nowrap; transition: border-color .12s;
}
.chip:hover { border-color: var(--border-hover); }
.chip b { padding: 0 6px; border-radius: 999px; background: rgb(16 24 40 / .06); font-size: .78rem; font-weight: 600; color: var(--muted); }
.chip.active { background: var(--fg); border-color: var(--fg); color: var(--surface); }
.chip.active b { background: rgb(255 255 255 / .18); color: var(--surface); }
.chips.sticky { position: sticky; top: calc(var(--appbar-h) + var(--safe-t)); z-index: 10; background: var(--bg); padding-top: 8px; }

/* ================= Tableau de bord ================= */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 4px 0 6px; }
.kpi {
    position: relative; display: grid; gap: 1px; padding: 10px 10px 9px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.kpi-ico { display: none; }
.kpi-label { font-size: .7rem; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi strong { font-size: 1.4rem; font-weight: 700; line-height: 1.15; letter-spacing: -.03em; }
.kpi-sub { display: none; font-size: .8rem; color: var(--muted); }
.kpi-err strong { color: var(--err); }
.kpi-ok strong { color: var(--ok); }
.dash { display: grid; }

/* ================= Carte RDV ================= */
.rdv {
    display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); container: card / inline-size;
    border-radius: var(--radius); box-shadow: var(--shadow); transition: box-shadow .2s, border-color .2s;
}
@media (hover: hover) { .rdv:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); } }
.rdv.flash { animation: flash 1.4s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 4px rgb(31 94 255 / .45); } }
.rdv-body { flex: 1; display: grid; align-content: start; gap: 10px; padding: 16px 16px 14px; }
.rdv.status-annule .rdv-body { opacity: .65; }
.rdv-head { display: flex; align-items: flex-start; gap: 12px; }
.rdv-pos {
    flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px;
    background: var(--accent-soft); color: var(--accent); font-size: .9rem; font-weight: 700;
}
.rdv-pos .icon { width: 18px; height: 18px; stroke-width: 2.6; }
.status-realise .rdv-pos { background: var(--ok-soft); color: var(--ok); }
.status-absent .rdv-pos, .status-reporte .rdv-pos { background: var(--warn-soft); color: var(--warn); }
.status-annule .rdv-pos { background: var(--err-soft); color: var(--err); }
.rdv-title { flex: 1; min-width: 0; }
.rdv-title h3 { margin: 0; font-size: 1.02rem; font-weight: 650; line-height: 1.3; }
.rdv-title h3 a { color: var(--fg); text-decoration: none; }
.rdv-title h3 a:hover { color: var(--accent); }
.rdv-sub { margin-top: 2px; color: var(--muted); font-size: .9rem; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; color: var(--muted); font-size: .9rem; }
.meta > span:not(.badge) { display: inline-flex; align-items: flex-start; gap: 6px; }
.meta .icon { width: 16px; height: 16px; margin-top: 2px; color: var(--faint); }
.meta .when { color: var(--fg); font-weight: 600; }
.meta .when .icon { color: var(--accent); }
.meta .addr { flex-basis: 100%; }
.note-preview {
    margin: 0; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--subtle); border: 1px solid #eef0f3;
    color: #3a4252; font-size: .9rem; white-space: pre-line;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.report { border-radius: var(--radius-sm); background: var(--ok-soft); font-size: .9rem; }
.report > summary { display: flex; gap: 8px; padding: 10px 12px; cursor: pointer; list-style: none; }
.report > summary::-webkit-details-marker { display: none; }
.report > summary .icon { width: 18px; height: 18px; color: var(--ok); margin-top: 1px; }
.report > summary::after { content: "Détails"; margin-left: auto; padding-left: 8px; color: var(--ok); font-weight: 600; font-size: .8rem; white-space: nowrap; }
.report[open] > summary::after { content: "Masquer"; }
.report dl { margin: 0; padding: 0 12px 12px 38px; }
.report dt { margin-top: 8px; font-size: .72rem; font-weight: 700; color: #4f7a61; text-transform: uppercase; letter-spacing: .04em; }
.report dd { margin: 0; }
.rdv-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px 14px; border-top: 1px solid var(--border); }
.rdv-actions .btn { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; font-size: .9rem; }
/* Carte étroite (téléphone) : « Compte rendu » prend toute la largeur sous les autres actions ; carte large : une seule ligne. */
.rdv-actions .cr { flex-basis: 100%; min-height: var(--tap); }
@container card (min-width: 420px) {
    .rdv-actions { flex-wrap: nowrap; }
    .rdv-actions .cr { flex-basis: auto; flex-grow: 1.3; min-height: 44px; }
}
.round {
    flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
    text-decoration: none; transition: filter .15s, transform .05s;
}
.round:hover { filter: brightness(.95); }
.round:active { transform: scale(.95); }
.round .icon { width: 19px; height: 19px; }
.round.call { background: var(--ok-soft); color: var(--ok); }
.round.go { background: var(--accent-soft); color: var(--accent); }
.round.disabled { background: var(--subtle); color: #c7ccd5; cursor: not-allowed; }

/* ================= Listes (tournées, leads) ================= */
.list { margin: 0; padding: 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list > li { display: flex; align-items: center; }
.list > li + li { border-top: 1px solid var(--border); }
.list-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 70px; padding: 12px 10px 12px 14px; color: inherit; text-decoration: none; transition: background .12s; }
.list-link:hover, .list-link:active { background: var(--subtle); }
.list-text { flex: 1; min-width: 0; display: grid; gap: 4px; }
.list-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub:empty { display: none; }
.list .chevron { color: var(--faint); }
.list .call { margin-right: 10px; width: 42px; height: 42px; background: var(--ok-soft); color: var(--ok); }
.list .call:hover { background: var(--ok-soft-hover); }
.list-count { margin: 6px 2px 10px; color: var(--muted); font-size: .85rem; font-weight: 500; }
.avatar { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--neutral-soft); color: var(--fg-2); font-size: .88rem; font-weight: 700; }
.avatar.stage-rdv_planifie, .avatar.stage-interesse { background: var(--accent-soft); color: var(--accent); }
.avatar.stage-gagne { background: var(--ok-soft); color: var(--ok); }
.avatar.stage-a_relancer { background: var(--warn-soft); color: var(--warn); }
.avatar.stage-perdu { background: var(--err-soft); color: var(--err); }
.tile-ico { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }

/* Recherche collée sous la barre du haut */
.searchbar { position: sticky; top: calc(var(--appbar-h) + var(--safe-t)); z-index: 10; margin: -4px -12px 0; padding: 4px 12px 0; background: var(--bg); }
.search-field { position: relative; margin-bottom: 10px; }
.search-field .icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search-field input { padding-left: 46px; border-radius: 999px; min-height: 50px; }

/* ================= Tournée ================= */
.summary { display: grid; gap: 10px; margin: 4px 0 6px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.summary-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.summary-row strong { font-size: 1.15rem; letter-spacing: -.02em; }

/* ================= Fiche lead ================= */
.lead-layout { display: grid; gap: 4px; }
.lead-panel { display: grid; gap: 12px; align-content: start; }
.hero {
    display: grid; justify-items: start; gap: 8px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius);
    background: linear-gradient(180deg, #f1f5ff 0%, var(--surface) 58%); box-shadow: var(--shadow);
}
.hero h2 { margin: 0; font-size: 1.35rem; line-height: 1.25; letter-spacing: -.02em; }
.hero-info { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: .93rem; }
.hero-info li { display: flex; align-items: flex-start; gap: 8px; }
.hero-info .icon { width: 17px; height: 17px; margin-top: 2px; color: var(--faint); }
.quick { justify-self: stretch; display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; margin-top: 6px; }
.quick a {
    display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 11px 4px; border-radius: 13px;
    background: var(--accent-soft); color: var(--accent); font-size: .78rem; font-weight: 600; text-decoration: none; transition: filter .15s;
}
.quick a.q-phone { background: var(--ok-soft); color: var(--ok); }
.quick a:hover { filter: brightness(.96); }
.saved { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0; color: var(--ok); font-weight: 600; }

/* ================= Import / connexion ================= */
.dropzone {
    display: grid; justify-items: center; gap: 6px; padding: 26px 16px; border: 1.5px dashed #c3cad6;
    border-radius: var(--radius); background: linear-gradient(180deg, #f6f8ff, var(--subtle)); text-align: center; color: var(--accent); cursor: pointer;
    transition: border-color .15s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone strong { color: var(--fg); font-size: 1.05rem; }
.dropzone input { margin-top: 10px; max-width: 420px; }
body.guest { background: radial-gradient(1200px 600px at 50% -10%, #dfe8ff 0%, var(--bg) 60%) fixed; }
body.guest .appbar { display: none; }
body.guest main { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px 16px; }
.login { display: grid; gap: 16px; width: 100%; max-width: 400px; padding: 28px 24px; box-shadow: var(--shadow-lg); }
.login-brand { display: grid; justify-items: center; gap: 6px; padding-bottom: 6px; text-align: center; }
.login-brand strong { font-size: 1.4rem; letter-spacing: -.02em; }
.login-brand .brand-mark { width: 52px; height: 52px; border-radius: 16px; margin-bottom: 4px; }
.login-brand .brand-mark .icon { width: 26px; height: 26px; }

/* ================= Panneau (bottom sheet) des formulaires ================= */
.sheet {
    width: 100%; max-width: 100%; max-height: 92vh; max-height: 92dvh; margin: auto 0 0; padding: 0; border: 0;
    border-radius: 20px 20px 0 0; background: var(--surface); color: var(--fg); box-shadow: var(--shadow-lg);
}
.sheet::backdrop { background: rgb(15 20 30 / .42); backdrop-filter: blur(2px); }
.sheet[open] { animation: sheet-up .22s cubic-bezier(.2, .8, .3, 1); }
@keyframes sheet-up { from { transform: translateY(40%); } }
.sheet-form { display: flex; flex-direction: column; max-height: 92vh; max-height: 92dvh; }
.sheet-grab { flex: none; width: 40px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--border-strong); }
.sheet-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 6px 12px 18px; border-bottom: 1px solid var(--border); }
.sheet-head > div { flex: 1; min-width: 0; }
.sheet-head h2 { margin: 0; font-size: 1.15rem; }
.sheet-head p { margin: 2px 0 0; color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-body { flex: 1; display: grid; align-content: start; gap: 18px; padding: 18px; overflow-y: auto; overscroll-behavior: contain; }
.sheet-error:empty { display: none; }
.sheet-error .alert { margin: 0; }
.sheet-foot { flex: none; display: flex; gap: 10px; padding: 12px 18px calc(12px + var(--safe-b)); border-top: 1px solid var(--border); background: var(--subtle); border-radius: 0 0 20px 20px; }
.sheet-foot .btn-primary { flex: 1; }

.htmx-request { opacity: .6; transition: opacity .2s; }
.mobile-only { display: block; }

/* ================= Tablette ================= */
@media (min-width: 700px) {
    main { padding: 8px 20px 32px; }
    .chips { margin: 0 -20px; padding-inline: 20px; }
    .searchbar { margin-inline: -20px; padding-inline: 20px; }
    .cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
    .kpis { gap: 12px; }
    .kpi { padding: 14px 16px; gap: 2px; }
    .kpi-label { font-size: .8rem; }
    .kpi strong { font-size: 1.8rem; }
    .kpi-sub { display: block; }
    .sheet { max-width: 600px; margin: auto; border-radius: 20px; }
    .sheet-grab { display: none; }
    .sheet-head { padding-top: 12px; }
    main > form.panel { max-width: 640px; }
}

/* ================= Ordinateur : menu latéral, contenu centré ================= */
@media (min-width: 1024px) {
    :root { --appbar-h: 80px; }
    body.app { padding-left: 252px; }
    body.app main { padding: 0 32px 48px; max-width: calc(var(--content) + 64px); }
    .mobile-only { display: none; }

    .nav {
        inset: 0 auto 0 0; width: 252px; display: flex; flex-direction: column; gap: 4px; padding: 22px 14px 16px;
        background: var(--surface); border-top: 0; border-right: 1px solid var(--border); backdrop-filter: none;
    }
    .nav-brand { display: flex; align-items: center; gap: 11px; padding: 2px 10px 26px; color: var(--fg); font-size: 1.12rem; font-weight: 750; letter-spacing: -.02em; text-decoration: none; }
    .nav-items { flex-direction: column; gap: 2px; }
    .nav-items a { flex: none; flex-direction: row; justify-content: flex-start; gap: 10px; height: 44px; padding: 0 10px; border-radius: 11px; font-size: .95rem; transition: background .12s, color .12s; }
    .nav-items a:hover { background: var(--subtle); color: var(--fg); }
    .nav-items a.active { background: var(--accent-soft); color: var(--accent); }
    .nav-items a.active .nav-ico { background: none; }
    .nav-ico { width: auto; height: auto; }
    .nav-user { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 14px 4px 0 8px; border-top: 1px solid var(--border); }
    .nav-user .avatar { width: 36px; height: 36px; background: var(--accent-soft); color: var(--accent); }
    .nav-user-name { flex: 1; min-width: 0; font-weight: 600; font-size: .93rem; overflow: hidden; text-overflow: ellipsis; }
    .nav-user form { margin: 0; }
    .nav-user .icon-btn { width: 40px; height: 40px; color: var(--muted); }

    .appbar { padding: 0 max(32px, calc((100% - var(--content)) / 2)); gap: 14px; }
    .appbar:has(> .back) { padding-left: max(32px, calc((100% - var(--content)) / 2)); }
    .appbar-title { font-size: 1.65rem; letter-spacing: -.025em; }
    .appbar .back { width: 40px; height: 40px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
    .appbar .back:hover { background: var(--subtle); }

    .chips { margin: 0; padding-inline: 0; flex-wrap: wrap; overflow: visible; }
    .chips.sticky { margin: 0 -8px; padding: 10px 8px 12px; }
    .cards { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
    .cards > .empty { grid-column: 1 / -1; }
    .section-title { margin-top: 28px; }

    /* Agenda : RDV à gauche, tournées à droite */
    .kpis { gap: 16px; margin-bottom: 8px; }
    .kpi { padding: 18px 20px; }
    .kpi-ico { display: grid; place-items: center; position: absolute; top: 16px; right: 16px; width: 38px; height: 38px; border-radius: 12px; background: var(--subtle); color: var(--muted); }
    .kpi-err .kpi-ico { background: var(--err-soft); color: var(--err); }
    .kpi-ok .kpi-ico { background: var(--ok-soft); color: var(--ok); }
    .kpi strong { font-size: 2rem; margin-top: 4px; }
    .dash { grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
    .dash-main .cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
    .dash-side { position: sticky; top: calc(var(--appbar-h) + 8px); }
    .dash-main > .section-title:first-child, .dash-side > .section-title:first-child, .dash-main > .hint:first-child { margin-top: 28px; }

    /* Tournée : résumé sur une ligne */
    .summary { grid-template-columns: auto minmax(120px, 1fr) auto; align-items: center; gap: 24px; padding: 18px 22px; }
    .summary-row { display: contents; }
    .summary-row > :last-child { order: 3; }
    .summary .bar { order: 2; height: 8px; }

    /* Leads : cartes en grille, recherche sur une ligne */
    .searchbar { position: static; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin: 0 0 6px; padding: 0; }
    .searchbar .search-field { flex: 0 1 460px; margin: 0; }
    .searchbar .chips { flex: 1 1 auto; padding: 0; }
    .list.leads { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; background: none; border: 0; box-shadow: none; overflow: visible; }
    .list.leads > li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; transition: box-shadow .2s, border-color .2s; }
    .list.leads > li + li { border-top: 1px solid var(--border); }
    .list.leads > li:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
    .list.leads .list-link:hover { background: none; }

    /* Fiche lead : identité + suivi à gauche, historique à droite */
    .lead-layout { grid-template-columns: 400px minmax(0, 1fr); gap: 28px; align-items: start; }
    .lead-layout > .lead-panel { position: sticky; top: calc(var(--appbar-h) + 8px); }
    .lead-rdvs > .section-title:first-child { margin-top: 0; }
    .lead-rdvs .cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

    main > form.panel { padding: 26px; }
}
@media (min-width: 1440px) {
    :root { --content: 1240px; }
}
