/* ==========================================================================
   Kourio — design system responsive (mobile-first)
   Référence : 08. Branding (palette latérite + logo KiO) + 07. Guide UX
   Layouts : bottom-bar mobile / rail tablette (≥768px) / sidebar desktop (≥1024px)
   ========================================================================== */

:root {
  /* Base neutre — jour */
  --bg: #F3F1EC;
  --surface: #FFFFFF;
  --ink: #1C2733;
  --ink-soft: #4F5F6D;
  --line: #E2DDD3;

  /* Accents — famille latérite */
  --accent: #E2542A;        /* action principale */
  --accent-strong: #C94922;
  --success: #3FA796;       /* argent / livré */
  --success-strong: #2F8A7A;
  --transit: #C97A4A;       /* en cours */
  --danger: #C13C54;        /* échec / destructif */

  /* Variantes pastel (soft) : badges, icon-badges */
  --accent-soft: #FBE4DC;
  --success-soft: #E1F3F0;
  --transit-soft: #F6E7DC;
  --alert-soft: #F8E0E5;
  --neutral-soft: #EEEAE0;

  /* Sidebar desktop : fond sombre constant, même en thème sombre
     (var(--ink) devient clair en dark mode → texte blanc sur blanc). */
  --sidebar-bg: #1C2733;
  --sidebar-fg: #EDEAE3;

  --radius: 14px;
  --tap: 48px;              /* zone tactile minimale */
  --shadow: 0 1px 3px rgba(28, 39, 51, .08), 0 4px 12px rgba(28, 39, 51, .06);
  --shadow-pop: 0 12px 28px -14px rgba(28, 39, 51, .28);

  /* Néomorphisme : les surfaces naissent du fond par ombre et lumière plutôt
     que par couleur. Plaques extrudées (cartes, icônes d'action) vs champs
     enfoncés (saisie, tri, registre). Les couleurs gardent leur rôle fixe :
     le néo ne touche que les surfaces passives. */
  --neo-surface: #F7F5F0;                 /* plaque (un ton au-dessus de --bg) */
  --neo-well: #EFECE3;                    /* champ enfoncé (un ton en dessous) */
  --neo-hi: rgba(255, 255, 255, .92);     /* lumière haut-gauche */
  --neo-lo: rgba(164, 150, 122, .5);      /* ombre bas-droite, teinte du fond */
  --neo-inset-hi: rgba(255, 255, 255, .9);
  --neo-inset-lo: rgba(156, 144, 114, .38);
  --neo-line: rgba(164, 150, 122, .36);   /* liseré fin pour détacher les plaques */

  /* Breakpoints */
  --bp-tablet: 768px;
  --bp-desktop: 1024px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12181F;
    --surface: #1B242E;
    --ink: #EDEAE3;
    --ink-soft: #A9B6C2;
    --line: #2A3642;
    --accent: #F07A50;      /* accents éclaircis pour rester lisibles */
    --accent-strong: #E2542A;
    --success: #56C4B0;
    --success-strong: #3FA796;
    --transit: #D99A6C;
    --danger: #E0637C;
    --accent-soft: #4A2A1E;
    --success-soft: #16332D;
    --transit-soft: #3A2B20;
    --alert-soft: #3B2028;
    --neutral-soft: #232C36;
    --shadow: 0 1px 3px rgba(0, 0, 0, .35);
    --neo-surface: #17222C;
    --neo-well: #0E141B;
    --neo-hi: rgba(255, 255, 255, .055);
    --neo-lo: rgba(0, 0, 0, .62);
    --neo-inset-hi: rgba(255, 255, 255, .06);
    --neo-inset-lo: rgba(0, 0, 0, .48);
    --neo-line: rgba(255, 255, 255, .09);
  }
}

/* Thème NUIT EXPLICITE : l'utilisateur a choisi — s'applique même si le
   système est en clair (outrepasse prefers-color-scheme). Même palette que le
   bloc media ci-dessus : aucun conflit quand les deux matchent (valeurs
   identiques, ordre de source favorable au bloc explicite). */
:root[data-theme="dark"] {
  --bg: #12181F;
  --surface: #1B242E;
  --ink: #EDEAE3;
  --ink-soft: #A9B6C2;
  --line: #2A3642;
  --accent: #F07A50;      /* accents éclaircis pour rester lisibles */
  --accent-strong: #E2542A;
  --success: #56C4B0;
  --success-strong: #3FA796;
  --transit: #D99A6C;
  --danger: #E0637C;
  --accent-soft: #4A2A1E;
  --success-soft: #16332D;
  --transit-soft: #3A2B20;
  --alert-soft: #3B2028;
  --neutral-soft: #232C36;
  --shadow: 0 1px 3px rgba(0, 0, 0, .35);
  --neo-surface: #17222C;
  --neo-well: #0E141B;
  --neo-hi: rgba(255, 255, 255, .055);
  --neo-lo: rgba(0, 0, 0, .55);
  --neo-inset-hi: rgba(255, 255, 255, .06);
  --neo-inset-lo: rgba(0, 0, 0, .4);
}

/* Bouton bascule jour/nuit : l'icône reflète le thème EFFECTIF (choix explicite
   ou système). Cercle discret de la charte (--neutral-soft / --ink-soft). */
.theme-toggle {
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--neutral-soft); color: var(--ink-soft);
  border: 1px solid var(--line); padding: 0; cursor: pointer;
}
.theme-toggle svg { width: 19px; height: 19px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

/* L'attribut hidden doit TOUJOURS masquer : sans !important, des règles
   comme .btn { display: inline-flex } le neutralisent (le bouton « Supprimer
   mon compte » restait visible quand le code de confirmation apparaissait). */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

/* Typographie : Sora titres, IBM Plex Mono montants */
h1, h2, h3, .sora { font-family: Sora, Inter, system-ui, sans-serif; }
.amount { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace; font-variant-numeric: tabular-nums; }

/* ============================== Logo KiO =================================
   Règle de construction (doc 08) : la hauteur des SVG i et O est toujours
   strictement égale à la taille de police du K. */
.kio { display: inline-flex; align-items: center; line-height: 1; }
.kio-k {
  font-family: Sora, sans-serif; font-weight: 800;
  font-size: var(--logo-fs, 1.3rem); line-height: 1;
}
.kio-i, .kio-o { height: var(--logo-fs, 1.3rem); width: auto; display: block; }
.kio-o { margin-left: 1px; }

.kio-icon { width: var(--logo-icon, 24px); height: var(--logo-icon, 24px); display: block; }

/* ============================== Shell responsive ======================= */

/* Sidebar / rail — masquée sur mobile, affichée dès 768px.
   Le mobile navigue par la bottom-bar (.tabbar). */
.sidebar {
  display: none;
}

/* Débordement du rail tablette (« Plus ») : n'existe qu'entre 768 et 1023px.
   Sur desktop la sidebar montre tout ; sur mobile la tabbar a déjà son Plus. */
.rail-more {
  display: none;
}

.shell { min-height: 100dvh; }

/* Topbar : brand + avatar (mobile), titre + actions (desktop) */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
}
.brand { text-decoration: none; color: var(--ink); }
.brand-top { --logo-fs: 1.35rem; }
.brand-top:hover { color: var(--accent); }
.topbar-title {
  display: none;
  font-family: Sora, sans-serif; font-weight: 800; font-size: 1.25rem;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar .btn-new { display: none; }   /* bouton "Nouvelle course" : desktop uniquement */

/* Avatar + menu (Alpine) */
.avatar-wrap { position: relative; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: Sora, sans-serif; font-weight: 700; text-decoration: none;
  border: none; cursor: pointer; font-size: 1rem; overflow: hidden; padding: 0;
  position: relative;
}
/* Initiales en fond, image par-dessus : si le fichier média manque, onerror
   retire l'img et les initiales restent visibles. */
.avatar-init { line-height: 1; }
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
/* Aperçu d'avatar dans le profil : photo OU initiales, mis à jour dès la
   sélection d'un fichier (avant tout enregistrement). */
.avatar-preview {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: Sora, sans-serif; font-weight: 700; font-size: 1.5rem;
  overflow: hidden; margin-bottom: 10px;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Aperçu de logo dans « Mon activité » : cadre rectangulaire (le rond
   avatar-preview mutilerait un logo) ; le fichier est affiché entier, jamais
   rogné (object-fit: contain). */
.logo-preview {
  width: 160px; max-width: 100%; height: 64px;
  background: var(--surface); border: 1px dashed var(--line); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; margin-bottom: 10px; padding: 6px;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }

/* Signature de marque (panneau Branding) : pad de dessin + recadrage d'une
   photo importée (static/js/signature.js et cropper.js). Le champ fichier du
   formulaire reste invisible — le JS l'alimente via DataTransfer. Le pad et la
   zone de recadrage ont un fond blanc FIXE (l'encre noire doit rester lisible
   même en thème sombre). */
.signature-field .sig-preview {
  width: 220px; max-width: 100%; height: 72px;
  background: var(--surface); border: 1px dashed var(--line); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; margin-bottom: 10px; padding: 6px;
}
.signature-field .sig-preview img {
  max-width: 100%; max-height: 100%; object-fit: contain; display: block;
}
.sig-file-wrap { display: none; }
.sig-modes { margin-top: 8px; }
.sig-pane { margin-top: 12px; }
.sig-canvas, .crop-canvas {
  display: block; width: 100%; height: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  touch-action: none;
}
.sig-canvas { cursor: crosshair; }
.sig-tools { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* Preuves de livraison (écran « livrer », V1) : photo + signature tactile. */
.deliver-evidence { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.evidence-label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 6px; }
.evidence-label small { color: var(--ink-soft); font-weight: 400; }

/* Argent de la course (COD) — groupe de radios du panneau de livraison
   (delivery_detail_panel.html). Même vocabulaire visuel que .evidence-field. */
.deliver-collection {
  display: flex; flex-direction: column; gap: 8px;
  margin: 14px 0; padding: 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.collection-option {
  display: flex; align-items: center; gap: 8px;
  font-size: .92rem; cursor: pointer;
}
.collection-option input[type="radio"] {
  width: 18px; height: 18px; accent-color: var(--accent); margin: 0;
}
.evidence-field input[type="file"] {
  width: 100%; min-height: 46px; padding: 10px; border-radius: 12px;
  border: 1px dashed var(--line); background: var(--surface);
  color: var(--ink-soft); font-size: .85rem;
}
.sig-pad .sig-canvas { width: 100%; height: 140px; }
.avatar-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 50;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-pop);
  min-width: 220px; overflow: hidden;
}
.avatar-menu a, .avatar-menu button {
  display: flex; width: 100%; align-items: center; gap: 10px;
  padding: 12px 14px; color: var(--ink); text-decoration: none;
  background: none; border: none; font-size: .95rem; cursor: pointer;
}
.avatar-menu a:hover, .avatar-menu button:hover { background: var(--bg); }

/* Bottom navigation — mobile uniquement */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 40;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
}
.tabbar a, .tabbar button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; color: var(--ink-soft); text-decoration: none;
  font-size: .7rem; font-weight: 600; min-height: var(--tap); justify-content: center;
}
.tabbar a svg, .tabbar button svg { width: 24px; height: 24px; }
.tabbar a.active, .tabbar button.active { color: var(--accent); }
/* Bouton « Plus » : même gabarit qu'un lien, sans apparence de bouton. */
.tabbar button {
  background: none; border: none; font-family: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Pastille de compteur sur la nav (ex. commandes du portail à valider).
   Positionnée en absolu dans le coin de l'item — sidebar, tabbar mobile et
   rail tablette partagent le même rendu, seul le parent change. */
.nav-item, .tabbar a { position: relative; }
.nav-badge {
  position: absolute; top: 4px; right: 6px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  background: var(--accent); color: #fff;
  font-size: .64rem; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* ============================ Feuillet « Plus » ========================== */
/* Feuillet bas mobile : tous les modules par groupe. Overlay teleporté en
   <body> par Alpine (nav_sheet.html) ; masqué défensivement dès 768px, où la
   navigation se fait par le rail/sidebar. */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(2px);
}
.sheet {
  width: 100%; max-width: 560px; max-height: 70dvh;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--line); border-bottom: none;
  box-shadow: 0 -12px 32px rgba(0, 0, 0, .18);
  overflow-y: auto; overscroll-behavior: contain;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-grip {
  width: 42px; height: 4px; border-radius: 999px;
  background: var(--line); margin: 10px auto 4px; flex-shrink: 0;
}
.sheet-body { padding: 6px 12px 14px; }
.sheet-group + .sheet-group {
  border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px;
}
.sheet-group-label {
  display: block; padding: 0 10px 6px;
  font-size: .66rem; font-weight: 700; letter-spacing: .14em;
  color: var(--ink-soft);
}
.sheet-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 10px; border-radius: 10px;
  color: var(--ink); text-decoration: none; font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}
.sheet-item svg { width: 20px; height: 20px; color: var(--ink-soft); }
.sheet-item.active { background: rgba(226, 84, 42, .10); color: var(--accent); }
.sheet-item.active svg { color: var(--accent); }
.sheet-item:active { background: var(--bg); }

/* Ancres profondes (hub Paramètres → sections du profil) : pas cachées sous
   la topbar sticky (≥768px). 84px ≈ hauteur topbar + marge. */
main [id] { scroll-margin-top: 84px; }

/* =========================== Hub Paramètres ============================== */
/* Hub façon menu de réglages : sections + rangées-tableau (Arc Menu). */
.settings-hub { max-width: 680px; margin: 0 auto; }
.settings-section { margin-bottom: 22px; }
.settings-section-title {
  font-family: Sora, sans-serif; font-weight: 700; font-size: .8rem;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-soft); margin: 0 0 8px; padding: 0 4px;
}
.settings-section-desc {
  font-size: .82rem; color: var(--ink-soft);
  margin: 0 0 12px; padding: 0 4px;
}
.settings-rows {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.settings-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; text-decoration: none; color: var(--ink);
  border-top: 1px solid var(--line);
  -webkit-tap-highlight-color: transparent;
}
.settings-row:first-child { border-top: none; }
.settings-row:active { background: var(--bg); }
.settings-row-icon {
  width: 40px; height: 40px; border-radius: 10px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: rgba(226, 84, 42, .12); color: var(--accent);
}
.settings-row-icon svg { width: 20px; height: 20px; }
.settings-row-text { flex: 1; min-width: 0; }
.settings-row-label { display: block; font-weight: 600; font-size: .95rem; }
.settings-row-desc {
  display: block; color: var(--ink-soft); font-size: .78rem; margin-top: 1px;
}
.settings-row-chevron { color: var(--ink-soft); flex: 0 0 auto; }
.settings-row-chevron svg { width: 16px; height: 16px; }
/* Zone de danger : icône et libellé en framboise, jamais l'accrocheur. */
.settings-row.danger .settings-row-icon { background: rgba(220, 53, 69, .12); color: var(--danger); }
.settings-row.danger .settings-row-label { color: var(--danger); }

/* Notifications du Dashboard (V2) : rangée repérable tant que non lue. */
.settings-row-meta {
  display: block; color: var(--ink-soft); font-size: .72rem; margin-top: 3px;
}
.settings-row.notification-unread {
  background: rgba(226, 84, 42, .06);
}
.settings-row.notification-unread .settings-row-label { color: var(--accent-strong); }
/* Notifications d'invitation : deux actions côte à côte, qui passent à la
   ligne sous le texte sur petit écran (settings-row en flex-wrap). */
.notifications-section .settings-row { flex-wrap: wrap; }
.notif-action { display: inline-flex; }

/* Réglage « Affichage du tableau de bord » : cases à cocher des graphes et
   choix du jour, dans les mêmes rangées-tableau que le reste du hub. */
.chart-picker-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 0 0 6px; }
.chart-group-title {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-soft); margin: 14px 0 4px; padding: 0 4px;
}
.settings-row input[type="checkbox"],
.settings-row input[type="radio"] {
  width: 18px; height: 18px; accent-color: var(--accent); margin: 0;
}
#custom-day .settings-row { background: var(--bg); }

/* Hub Équipe — mot de passe temporaire (affiché une seule fois) et lien public */
.team-action-danger { color: var(--danger); }
.courier-pw-box { background: var(--success-soft); border: 1px solid var(--success); }
.courier-pw-title { font-weight: 700; font-size: .9rem; }
.courier-pw-row { display: flex; align-items: center; gap: 10px; margin: 8px 0 4px; }
.courier-pw {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 1.05rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; color: var(--ink); letter-spacing: .04em;
}
.courier-pw-hint { font-size: .78rem; color: var(--ink-soft); }
/* V2 — boîte à identifiants du parcours 2 : une ligne par information, l'étiquette
   guide l'œil, le code respire (flex) et le lien de jonction se tronque. */
.courier-pw-k { font-size: .78rem; color: var(--ink-soft); min-width: 84px; }
.courier-pw-row .courier-pw { flex: 1; min-width: 0; }
.courier-pw-row .courier-pw-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Page de jonction — email fourni par l'agence, en lecture seule */
.invitation-identifier { background: var(--bg); color: var(--ink-soft); }
.team-public-link {
  display: flex; align-items: center; gap: 10px; margin-top: 10px;
  background: var(--bg); border: 1px dashed var(--line); border-radius: 12px;
  padding: 10px 12px;
}
.team-public-link code {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .78rem; color: var(--ink-soft);
}

/* Zone de contenu */
main {
  max-width: 680px;
  margin: 0 auto;
  padding: 8px 16px calc(84px + env(safe-area-inset-bottom));
}
main.narrow { max-width: 680px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 1.4rem; margin: 0; }
.page-head .sub { color: var(--ink-soft); font-size: .85rem; }

/* ============================== Boutons ================================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: var(--tap);
  border-radius: 12px; border: 1px solid transparent;
  font-family: Inter, sans-serif; font-size: 1rem; font-weight: 600;
  cursor: pointer; text-decoration: none; padding: 10px 16px;
}
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-strong); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-ghost { background: none; color: var(--ink-soft); border: none; box-shadow: none; padding: 8px; }
.btn-sm { min-height: 40px; font-size: .85rem; padding: 8px 12px; width: auto; }
.btn-new { align-items: center; justify-content: center; gap: 7px; width: auto; min-height: 44px; font-size: .9rem; padding: 10px 16px; border-radius: 10px; }
.btn-new svg { width: 16px; height: 16px; }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Barre d'action en bas d'écran : un seul primaire (mobile : fixée) */
.action-bar {
  max-width: 640px; margin: 0 auto;
  position: fixed; inset: auto 0 58px 0; z-index: 30;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 40%);
  display: flex; flex-direction: column; gap: 8px;
}

/* FAB unique : créer une course (mobile/tablette) */
.fab {
  position: fixed; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 45;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none; box-shadow: var(--shadow-pop);
  display: flex; align-items: center; justify-content: center;
}
.fab svg { width: 26px; height: 26px; }

/* Ligne d'encaissement : montant + bouton côte à côte.
   Le .btn pose width:100% (conçu pour les rangées empilées) : dans une rangée
   flex ça lui donne un flex-basis de 100% du conteneur et tout le shrink lui
   revient — l'input (basis 0) se réduit à 0. Ici le bouton garde un plancher
   (min-width) pour rester bien visible à côté du champ, sans jamais l'écraser :
   l'input prend le reste (flex:1). Les libellés longs (« Percevoir la
   compensation ») dépassent le plancher et suivent leur contenu. */
.collect-row { display: flex; gap: 10px; }
.collect-row input { flex: 1; min-width: 0; }
.collect-row .btn { width: auto; flex: 0 0 auto; min-width: 150px; }

/* ============================== Listes & cartes ======================= */

.card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.card a { display: block; padding: 14px; color: var(--ink); text-decoration: none; }

/* Carte course : icon-badge + client + adresse + montant à droite (style maquette) */
.delivery-card a { display: flex; align-items: center; gap: 12px; }
.delivery-card .client { font-weight: 600; }
.delivery-card .card-amt { font-weight: 700; color: var(--ink); white-space: nowrap; }
.delivery-card .route { color: var(--ink-soft); font-size: .85rem; margin-top: 2px; }
.delivery-card .badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.icon-badge {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-badge svg { width: 20px; height: 20px; }

/* Corps de carte avec icon-badge : contenu à côté de l'icône */
.card-list-body { flex: 1; min-width: 0; }
.delivery-card a, .client-card > a { display: flex; align-items: center; gap: 12px; }
.client-card .route { margin-top: 2px; }
/* Carte client : lien principal étirable + bouton « Modifier » à droite */
.client-card { display: flex; align-items: center; }
.client-card > a { flex: 1; min-width: 0; }
.client-card .btn-edit {
  flex: 0 0 auto; padding: 10px; color: var(--ink-soft); border: none; background: none;
}
.client-card .btn-edit svg { width: 18px; height: 18px; }

/* État vide des listes */
.card.empty { text-align: center; color: var(--ink-soft); padding: 28px 16px; }

/* Couleurs de statut : pastel de fond + teinte forte — rôle fixe partout */
.st-pending, .badge-pending, .ib-pending      { --st-bg: var(--neutral-soft); --st-fg: var(--ink-soft); }
.st-paused, .badge-paused, .ib-paused         { --st-bg: var(--neutral-soft); --st-fg: var(--ink-soft); }
.st-in_progress, .badge-in_progress, .ib-in_progress { --st-bg: var(--transit-soft); --st-fg: var(--transit); }
.st-delivered, .badge-delivered, .ib-delivered { --st-bg: var(--success-soft); --st-fg: var(--success); }
.st-failed, .badge-failed, .ib-failed          { --st-bg: var(--alert-soft); --st-fg: var(--danger); }
.st-cancelled, .badge-cancelled, .ib-cancelled, .ib-neutral { --st-bg: var(--neutral-soft); --st-fg: var(--ink-soft); }
.st-pending_validation, .badge-pending_validation, .ib-pending_validation { --st-bg: var(--transit-soft); --st-fg: var(--transit); }

/* Facturation — cycle de vie d'une facture : brouillon (neutre), émise (en cours). */
.badge-draft  { --st-bg: var(--neutral-soft); --st-fg: var(--ink-soft); }
.badge-issued { --st-bg: var(--transit-soft); --st-fg: var(--transit); }

/* État du paiement (courses livrées) : même logique pastel/teinte que les statuts */
.badge-paid    { --st-bg: var(--success-soft); --st-fg: var(--success); }
.badge-partial { --st-bg: var(--transit-soft); --st-fg: var(--transit); }
.badge-unpaid  { --st-bg: var(--alert-soft); --st-fg: var(--danger); }

/* État d'un membre d'équipe (hub Équipe) : actif / désactivé par le Manager */
.badge-active   { --st-bg: var(--success-soft); --st-fg: var(--success); }
.badge-disabled { --st-bg: var(--neutral-soft); --st-fg: var(--ink-soft); }

/* Course sans livreur assigné (liste Courses, V1) */
.badge-unassigned { --st-bg: var(--neutral-soft); --st-fg: var(--ink-soft); }

/* Prêts & emprunts — sens (créance/dette) et état (en cours/soldé) */
.badge-lent        { --st-bg: var(--success-soft); --st-fg: var(--success); }
.badge-borrowed     { --st-bg: var(--alert-soft); --st-fg: var(--danger); }
.badge-outstanding  { --st-bg: var(--transit-soft); --st-fg: var(--transit); }
.badge-repaid       { --st-bg: var(--neutral-soft); --st-fg: var(--ink-soft); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 600;
  background: var(--st-bg, var(--neutral-soft)); color: var(--st-fg, var(--ink-soft));
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.icon-badge { background: var(--st-bg, var(--neutral-soft)); color: var(--st-fg, var(--ink-soft)); }

.alert-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--transit); }

/* Chips de filtre par statut */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; margin: 0 -16px 4px; padding-left: 16px; padding-right: 16px; -webkit-overflow-scrolling: touch; }
.chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px;
  background: var(--surface); color: var(--ink-soft); border: 1px solid var(--line);
  text-decoration: none; font-size: .8rem; font-weight: 600; min-height: 38px; display: inline-flex; align-items: center;
}
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .count { margin-left: 4px; opacity: .7; }

/* ============================== Détail course =========================== */

.timeline { padding: 4px 0 4px 6px; }
.timeline .step { display: flex; gap: 12px; padding: 10px 0; }
.timeline .line { display: flex; flex-direction: column; align-items: center; }
.timeline .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line); border: 2px solid var(--bg); flex: 0 0 auto; }
.timeline .dot.done { background: var(--accent); }
.timeline .bar { flex: 1; width: 2px; background: var(--line); }
.timeline .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.timeline .value { font-weight: 600; }

/* Montant central */
.amount-hero { text-align: center; padding: 18px 0 8px; }
.amount-hero .amount { font-size: 2.1rem; font-weight: 700; color: var(--success); }

/* ============================== Caisse ================================== */

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 14px; }
.stat .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.stat .v { font-size: 1.25rem; font-weight: 700; margin-top: 2px; }
.stat.income .v { color: var(--success); }
.stat.pending .v { color: var(--transit); }
.stat.remain .v { color: var(--danger); }

/* ========================== Tableau de bord (accueil) =================== */

/* Graphique 7 jours : barres flex, hauteur en % portée en inline par la vue.
   Aucune lib externe — le rendu doit tenir hors-ligne (service worker) et
   sous la CSP stricte. */
.chart-card { padding: 14px; }
.chart-title { font-size: .95rem; font-weight: 600; margin-bottom: 12px; }
.chart { display: flex; gap: 8px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.chart-zone { height: 110px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.chart-bar { width: 60%; max-width: 36px; background: var(--accent-soft); border-radius: 6px 6px 0 0; display: flex; align-items: flex-end; justify-content: center; }
.chart-value { font-size: .6rem; color: var(--ink-soft); padding-bottom: 2px; }
.chart-label { font-size: .68rem; color: var(--ink-soft); margin-top: 6px; }

/* ===================== Dashboard analytique (Chart.js) ================= */

/* Rangée jour / période : formulaire GET, soumission au changement. */
.dash-controls {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px; margin-bottom: 16px;
}
.dash-control { display: flex; flex-direction: column; gap: 4px; }
.dash-control label { font-size: .72rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.dash-control input, .dash-control select { min-height: 38px; }
.dash-control select { background: var(--bg); }
.dash-apply { align-self: flex-end; }
.dash-configure { align-self: center; margin-left: auto; white-space: nowrap; }

/* Sections de graphes groupées par thème. */
.chart-section { margin-top: 20px; }
.chart-section-title {
  font-family: Sora, sans-serif; font-size: .85rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft);
  margin: 0 0 10px;
}
.chart-card { padding: 14px; }
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.chart-title { font-size: .95rem; font-weight: 600; }
.chart-desc { font-size: .78rem; color: var(--ink-soft); margin: 2px 0 10px; }
.chart-balance { font-size: 1.15rem; font-weight: 700; white-space: nowrap; }
.chart-canvas { position: relative; height: 260px; }
.chart-canvas canvas { width: 100% !important; height: 100% !important; }
.chart-error::after {
  content: 'Graphe indisponible'; display: block; text-align: center;
  font-size: .8rem; color: var(--ink-soft); padding: 8px 0 0;
}

/* Sélecteur de compte des graphes (solde, tendance). */
.account-select {
  display: flex; align-items: center; gap: 10px; margin-top: 10px;
  padding-top: 10px; border-top: 1px solid var(--line);
}
.account-select label { font-size: .78rem; color: var(--ink-soft); }
.account-select select { flex: 1; min-width: 0; background: var(--bg); }

/* Tableaux (statement et livre) : défilement horizontal si étroit. */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { font-weight: 500; color: var(--ink-soft); }
.table td.amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table td.income { color: var(--success); }
.table td.expense { color: var(--danger); }
.table td.strong { font-weight: 700; }
.table tr.total-row th, .table tr.total-row td { border-top: 2px solid var(--line); font-weight: 700; }
.table tr.subrow th { padding-left: 18px; font-weight: 400; }

/* Actions rapides : deux cartes-lien vers les écrans du jour. */
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 16px; }
.quick-link { display: flex; align-items: center; justify-content: space-between; padding: 14px; font-weight: 600; }
.quick-link .quick-arrow { color: var(--ink-soft); }

.ledger-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; gap: 10px; }
.ledger-item + .ledger-item { border-top: 1px solid var(--line); }
.ledger-item .who { font-weight: 600; font-size: .95rem; }
.ledger-item .when { color: var(--ink-soft); font-size: .78rem; }

/* En-tête de groupe de l'annuaire Contacts (onglet Mon activité) : la ligne
   porte le nom de la catégorie + l'effectif, détachée de ses contacts. */
.cat-group { font-weight: 600; }
.cat-group + .ledger-item { border-top: none; }

/* ============================== Tableaux (desktop) ===================== */

.table-scroll { display: none; }
.data-table { display: table; width: 100%; border-spacing: 0; }
.data-head, .data-row { display: table-row; }
.data-head span, .data-cell { display: table-cell; }
.data-head span {
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-soft); font-family: "IBM Plex Mono", monospace;
}
.data-row { text-decoration: none; color: var(--ink); cursor: pointer; }
.data-row:hover .data-cell { background: var(--bg); }
.data-cell { padding: 12px; border-bottom: 1px solid var(--line); font-size: .9rem; vertical-align: middle; color: var(--ink); text-decoration: none; }
.data-cell .icon-badge { width: 32px; height: 32px; border-radius: 9px; margin-right: 10px; }
.data-cell .icon-badge svg { width: 16px; height: 16px; }
.data-cell.action-cell { width: 48px; text-align: right; }
.data-cell.action-cell svg { width: 18px; height: 18px; vertical-align: middle; color: var(--ink-soft); }
.data-cell.amt { font-family: "IBM Plex Mono", monospace; font-weight: 600; white-space: nowrap; }

/* ============================== Double panneau tablette ==================
   Master-detail (maquette tablette) : liste à gauche (44%) + détail à droite.
   Actif uniquement en 768–1023px ; mobile et desktop gardent leurs vues. */
.split { display: block; }
.split-detail { display: none; }
.t-list-hdr { display: none; }                   /* header « Courses » de la liste : tablette */
.panel-hero, .panel-photo { display: none; }     /* en-tête compact + zone photo : tablette */
.delivery-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.panel-empty { color: var(--ink-soft); text-align: center; padding: 48px 16px; font-size: .95rem; }


/* ============================== Formulaires ============================= */

form .field { margin-bottom: 14px; }
form label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
form input, form select, form textarea {
  width: 100%; min-height: var(--tap);
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font-family: Inter, sans-serif; font-size: 1rem;
}
form input:focus, form select:focus, form textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent;
}
form .errors { color: var(--danger); font-size: .82rem; margin-top: 4px; }
form .hint { color: var(--ink-soft); font-size: .78rem; margin-top: 4px; }

/* Cases à cocher des formulaires : la règle générale `form input { width:100% }`
   étirerait les checkboxes — on les borne (même logique que .settings-row). */
form .field input[type="checkbox"],
form .field input[type="radio"] {
  width: 20px; height: 20px; accent-color: var(--accent); margin: 0;
}

/* Grille de saisie des lignes (éditeur de lignes de facture, identifiants
   fiscaux) : partagée par invoicing/form.html et invoicing/settings.html — elle
   vit ici et non dans un <style> local pour servir les deux écrans. */
.invoice-line {
  display: grid; grid-template-columns: 2fr 70px 110px 130px 1fr auto;
  gap: 8px; align-items: center; margin-bottom: 8px;
}
.invoice-line input, .invoice-line select { min-width: 0; }
@media (max-width: 640px) {
  .invoice-line { grid-template-columns: 1fr 1fr; }
  .invoice-line .btn { grid-column: 1 / -1; }
}

.inline-toggle { text-align: left; background: none; border: none; color: var(--accent); font-weight: 600; padding: 8px 0; cursor: pointer; font-size: .95rem; }

/* ============================== Alertes ================================= */

.alert {
  padding: 12px 14px; border-radius: 12px; margin-bottom: 12px;
  font-size: .9rem; font-weight: 500;
}
.alert.success { background: var(--success); color: #fff; }
.alert.error { background: var(--danger); color: #fff; }
.alert.warning { background: var(--transit); color: #fff; }

/* ============================== Auth ==================================== */

.auth-screen { display: flex; flex-direction: column; width: 100%; max-width: 420px; margin: auto; padding: 24px; }
.auth-screen .tagline { text-align: center; color: var(--ink-soft); margin-bottom: 28px; }
.auth-screen h1 { font-size: 1.2rem; }
.auth-screen .foot { text-align: center; margin-top: 18px; color: var(--ink-soft); font-size: .9rem; }
.auth-screen .foot a { color: var(--accent); text-decoration: none; font-weight: 600; }
.auth-wrap { display: flex; flex-direction: column; min-height: 100dvh; max-width: none; margin: 0; padding: 0; }

/* Barre de navigation des pages d'authentification (anonymes, pas de topbar) :
   pleine largeur — même langage que la nav publique (.l-nav) : liseré.
   Fond de plaque (--surface) pour se détacher du fond du thème ; le brand
   cliquable ramène à la landing ; la carte se centre dans l'espace restant.
   NB : pas de position:sticky ici. Dans un flex column à min-height:100dvh avec
   un frère en margin:auto, le sticky n'était pas dessiné sur desktop (header
   invisible) — et il n'apporte rien : la page ne défile pas. */
.auth-head {
  display: flex; align-items: center; flex: 0 0 auto;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.auth-head .brand { --logo-fs: 1.35rem; padding: 12px 20px; }
.auth-head .brand:hover { color: var(--accent); }

/* Pages auth : pas de sidebar — la bande du header doit rester PLEINE LARGEUR.
   Le .shell desktop est décalé de 80/232 px pour la sidebar connectée (présente
   nulle part ici) ; body.auth annule ce décalage (spécificité > .shell). */
body.auth .shell { margin-left: 0; }

/* Desktop/tablette : le wordmark se centre dans la bande. */
@media (min-width: 768px) {
  .auth-head { justify-content: center; }
}

/* Liens tertiaires */
.tertiary { color: var(--ink-soft); text-decoration: none; font-size: .85rem; }
.tertiary.danger { color: var(--danger); }

.muted { color: var(--ink-soft); }

/* ==========================================================================
   TABLETTE ≥ 768px — rail latéral + layouts multi-colonnes
   ========================================================================== */
@media (min-width: 768px) {
  /* La navigation latérale (rail tablette / sidebar desktop) remplace la
     bottom-nav mobile : on la masque partout dès 768px, ainsi que le FAB. */
  .tabbar { display: none; }
  .fab { display: none; }

  /* Rail latéral */
  .sidebar {
    display: flex; flex-direction: column; align-items: center; gap: 22px;
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: 80px;
    background: var(--surface); border-right: 1px solid var(--line);
    padding: 20px 0;
  }
  .sidebar-brand { color: var(--ink); --logo-icon: 30px; }
  .sidebar-brand .brand { color: inherit; }
  .brand-word { display: none; }

  .sidebar-nav { display: flex; flex-direction: column; gap: 18px; width: 100%; }
  .nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 6px 0; color: var(--ink-soft); text-decoration: none;
    font-size: .62rem; font-weight: 600; letter-spacing: .02em;
  }
  .nav-item svg { width: 22px; height: 22px; }
  .nav-item.active { color: var(--accent); }

  /* Groupes de navigation : colonne ; libellés masqués sur le rail
     (réaffichés ≥1024px). Le feuillet « Plus » reste VIVANT en tablette
     (768-1023px) : le rail y montre le cœur + un débordement « Plus » ; il
     n'est masqué qu'en desktop ≥1024px, où la sidebar montre tout. */
  .sidebar-group { display: flex; flex-direction: column; }
  .sidebar-group-label { display: none; }

  .sidebar-foot { display: none; }

  /* Avatar en bas du rail : le menu s'ouvre vers le haut et vers la droite.
     Le défaut (top: 100%, right: 0) le ferait sortir de l'écran en bas à gauche. */
  .sidebar-foot .avatar-menu {
    top: auto;
    bottom: calc(100% + 8px);
    left: 0;
    right: auto;
  }

  /* Shell décalé du rail */
  .shell { margin-left: 80px; }

  .topbar {
    padding: 14px 24px;
    background: var(--surface); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 30;
  }
  .brand-top { display: none; }
  .topbar-title { display: block; }

  main { max-width: none; padding: 24px; }
  main.narrow { max-width: 680px; }

  /* Liste de courses : grille 2 colonnes (remplace le flux simple) */
  .card-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .card-list .card { margin-bottom: 0; }

  /* Barre d'action non fixée sur tablette */
  .action-bar { position: static; background: none; padding: 0; margin: 24px 0 0; }

  /* Formulaire de recherche élargi */
  .chips { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
}

@media (min-width: 768px) and (max-width: 1023.98px) {
  /* Pas de topbar en tablette (maquette) :
     la navigation se fait par le rail, l'avatar vit en bas du rail.
     (.tabbar et .fab sont déjà masqués par le bloc ≥768px.) */

  /* Rail « cœur + débordement » : seuls les modules primaires (TABBAR) et le
     bouton « Plus » restent — le reste vit dans le feuillet. La nav ne grandit
     jamais linéairement : quel que soit le nombre de modules, le rail affiche
     le même nombre de boutons (voir .input/11, hiérarchie nav). */
  .sidebar-nav .nav-item:not(.is-primary) { display: none; }
  .sidebar-group:not(:has(.nav-item.is-primary)) { display: none; }
  .rail-more {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 6px 0; color: var(--ink-soft);
    font-size: .62rem; font-weight: 600; letter-spacing: .02em;
    border: none; background: none; cursor: pointer;
  }
  .rail-more svg { width: 22px; height: 22px; }

  /* Le label du rail doit tenir sur UNE ligne : « Tableau de bord » est le
     seul libellé assez long pour wraper sur 2 lignes dans le rail de 80px
     (cœur + débordement). On impose nowrap, avec l'ellipsis en filet de
     sécurité au cas où un futur libellé serait plus long que le rail. */
  .nav-item .nav-label {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%; line-height: 1.2;
  }

  .topbar { display: none; }
  .sidebar-foot {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    margin-top: auto; padding-bottom: 4px;
  }
  .sidebar-foot-name { display: none; }

  .split { display: flex; align-items: stretch; }

  /* Sans filtre : liste seule en pleine largeur, panneau détail caché. */
  .split:not(.is-filtered) { display: block; }
  .split:not(.is-filtered) .split-list {
    width: 100%; border-right: none; padding-right: 0;
  }
  .split:not(.is-filtered) .split-detail { display: none; }

  /* Filtre actif : double panneau master-detail (liste 44% / détail 56%). */
  .split.is-filtered .split-list { width: 44%; }
  .split-list {
    min-width: 0;
    border-right: 1px solid var(--line); padding-right: 22px;
    max-height: calc(100dvh - 60px); overflow-y: auto;
  }
  .split-detail {
    display: block; flex: 1; min-width: 0; padding-left: 22px;
    max-height: calc(100dvh - 60px); overflow-y: auto;
  }

  /* Le titre « Courses » + bouton « Nouvelle » vivent dans la colonne liste. */
  .is-split-head { display: none; }
  .t-list-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
  .t-list-title { font-family: Sora, sans-serif; font-weight: 800; font-size: 1.25rem; }
  .t-new-btn {
    background: var(--accent); color: #fff; border-radius: 9px;
    padding: 8px 12px; display: inline-flex; align-items: center; gap: 6px;
    font-size: .78rem; font-weight: 700; font-family: Sora, sans-serif; text-decoration: none;
  }
  .t-new-btn svg { width: 15px; height: 15px; }

  /* Cartes de liste : compactes, sur une colonne (m-card maquette). */
  .split .card-list { grid-template-columns: 1fr; }
  .split .delivery-card { margin-bottom: 10px; }
  .split .delivery-card a { padding: 12px 14px; }
  .split .delivery-card .client { font-family: Sora, sans-serif; font-weight: 700; font-size: .95rem; }
  .split .delivery-card .route { font-size: .78rem; }
  .split .delivery-card .card-amt { font-size: .9rem; }
  .split .delivery-card .badges { display: none; }   /* le statut est porté par l'icon-badge */

  /* Panneau détail : en-tête compact + photo + actions (maquette). */
  .panel-hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
  .panel-client { font-family: Sora, sans-serif; font-weight: 800; font-size: 1.25rem; }
  .panel-addr { display: flex; align-items: center; gap: 5px; font-size: .8rem; color: var(--ink-soft); margin-top: 4px; }
  .panel-addr svg { width: 13px; height: 13px; }
  .panel-amt { font-size: 1.45rem; font-weight: 700; }
  .panel-photo {
    border: 1.5px dashed var(--line); border-radius: 12px; min-height: 84px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    color: var(--ink-soft); font-size: .8rem; margin-bottom: 16px; text-align: center;
  }
  .panel-photo.ok { border-style: solid; border-color: var(--success); color: var(--success); }
  .panel-photo svg { width: 22px; height: 22px; }
  .panel-photo small { opacity: .75; }

  .split-detail .page-head { display: none; }
  .split-detail .timeline-card { display: none; }
  .split-detail .amount-hero { display: none; }
  .split-detail .panel-proof-alert { display: none; }

  /* Panneau détail en colonne flex : on place la rangée d'actions primaires
     directement sous la photo (maquette), puis secondaires, puis menu. */
  .split-detail { display: flex; flex-direction: column; }
  .split-detail .panel-hero { order: 1; }
  .split-detail .panel-photo { order: 2; }
  .split-detail .action-bar { order: 3; }
  .split-detail .panel-actions { order: 4; }
  .split-detail .panel-menu { order: 5; }

  /* Actions du panneau : une rangée de boutons compacts (t-btn-row). */
  .split-detail .action-bar { display: flex; flex-direction: row; gap: 10px; margin: 0 0 4px; }
  .split-detail .action-bar form { flex: 1; min-width: 0; }
  .split-detail .action-bar .btn { min-height: 46px; font-size: .85rem; padding: 8px 10px; }
  .split-detail .collect-row input { min-width: 0; }
  .split-detail .panel-actions { margin-top: 14px; }
  .split-detail .panel-actions .btn { min-height: 42px; font-size: .8rem; padding: 8px 10px; }
  .split-detail .panel-menu { margin-top: 10px; justify-content: flex-start; }
}

/* ==========================================================================
   DESKTOP ≥ 1024px — sidebar complète + topbar + tableaux
   ========================================================================== */
@media (min-width: 1024px) {
  .sidebar {
    width: 232px; align-items: stretch;
    background: var(--sidebar-bg); color: var(--sidebar-fg);
    border-right: none; padding: 24px 18px;
    gap: 6px;
  }
  .sidebar-brand { padding: 0 10px; margin-bottom: 18px; --logo-icon: 26px; --logo-hole: var(--sidebar-bg); }
  .sidebar-brand .brand { display: flex; align-items: center; gap: 10px; color: #EDEAE3; font-family: Sora, sans-serif; font-weight: 800; font-size: 1.1rem; }
  .sidebar-brand .kio-icon { color: #EDEAE3; }
  .sidebar-brand .brand-word { display: inline; }

  .sidebar-nav { gap: 4px; }

  /* En desktop, la sidebar montre tous les modules groupés : le feuillet
     « Plus » (mobile/tablette) n'a plus d'objet — on le neutralise. */
  .sheet-overlay { display: none; }

  .nav-item {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 11px 12px; border-radius: 10px;
    font-size: .9rem; color: rgba(237, 234, 227, .68);
  }
  .nav-item svg { width: 18px; height: 18px; }
  .nav-item:hover { background: rgba(255, 255, 255, .06); color: #EDEAE3; }
  .nav-item.active { background: rgba(226, 84, 42, .20); color: #F07A50; }

  /* Libellés de groupe en petites capitales, discrètes sur la sidebar. */
  .sidebar-group + .sidebar-group { margin-top: 12px; }
  .sidebar-group-label {
    display: block; padding: 0 12px 4px;
    font-size: .62rem; font-weight: 700; letter-spacing: .14em;
    color: rgba(237, 234, 227, .42);
  }

  .sidebar-foot {
    display: flex; align-items: center; gap: 10px;
    margin-top: auto; padding: 10px 8px 4px;
    color: rgba(237, 234, 227, .72); font-size: .82rem;
    border-top: 1px solid rgba(237, 234, 227, .14);
    min-width: 0;
  }
  .sidebar-foot .avatar { width: 34px; height: 34px; font-size: .85rem; flex: 0 0 auto; }
  .sidebar-foot-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Basculer jour/nuit : masqué dans la sidebar sur desktop — la topbar suffit.
     Conservé en tablette, où la topbar n'existe pas. */
  .sidebar-foot .theme-toggle { display: none; }

  .top-avatar { display: none; }

  .shell { margin-left: 232px; }

  .topbar { padding: 16px 32px; }
  .topbar-actions { gap: 14px; }
  .topbar .btn-new { display: inline-flex; }

  main { padding: 28px 32px; }
  /* Pleine largeur desktop : même les pages « narrow » (défaut) utilisent tout
     l'espace après la sidebar — plus aucune colonne centrée limitée. */
  main.narrow { max-width: none; }

  /* Hub Paramètres : un peu plus large sur desktop, sans devenir un tableau. */
  .settings-hub { max-width: 760px; }

  .fab { display: none; }

  /* Vue cartes → tableau */
  .card-list { display: none; }
  .table-scroll { display: block; }
  .card-list + .table-scroll { margin-top: 0; }

  /* Stats caisse : 4 cases sur une ligne */
  .stats { grid-template-columns: repeat(4, 1fr); }
  .stat .v { font-size: 1.5rem; }

  /* Journal de caisse en tableau */
  .ledger { width: 100%; }
  .ledger-item { display: table-row; }
  .ledger-item > div { display: table-cell; vertical-align: middle; padding: 12px 16px; }
  .ledger-item > div:last-child { text-align: right; }

  /* Formulaire de détail / édition : bloc central large */
  .form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
  .form-card .alert:first-child { margin-top: 0; }

  /* Formulaires autonomes (.grid-2) : en pleine largeur desktop, les champs ne
     s'étirent plus sur tout l'écran — la grille les répartit par paires. Les
     champs longs (textarea), le sélecteur client, l'alerte, le bloc conditionnel
     « nouveau client » et le bouton d'action prennent toute la largeur. */
  .form-card.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 24px;
    align-items: start;
  }
  .form-card.grid-2 > * { min-width: 0; }
  .form-card.grid-2 > .field:has(textarea),
  .form-card.grid-2 > .field:has(.client-results),
  .form-card.grid-2 > .field.signature-field,
  .form-card.grid-2 > .alert,
  .form-card.grid-2 > [x-show],
  .form-card.grid-2 > .btn { grid-column: 1 / -1; }
  /* Le .btn pose width:100% (rangées empilées mobiles) : dans la grille on le
     laisse prendre sa taille de contenu, aligné à gauche. */
  .form-card.grid-2 > .btn { justify-self: start; width: auto; }

  /* Bloc conditionnel « nouveau client » (formulaire de course) : pleine
     largeur, ses propres champs répartis en 2 colonnes ; le premier (nom)
     s'étire sur toute la largeur. */
  .form-card.grid-2 > [x-show] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 24px;
  }
  .form-card.grid-2 > [x-show] .field:first-child { grid-column: 1 / -1; }
}

@media (min-width: 1400px) {
  /* Pleine largeur sur très grands écrans : plus de cap à 1440 px. */
  main.wide { max-width: none; }
}

/* ==========================================================================
   CARNET D'ADRESSES — fiche client, favoris, autocomplétion
   ========================================================================== */

/* Rangée d'information (nom + étoile favori, montant + date…) */
.row1 { display: flex; align-items: center; gap: 6px; }

/* Compteur de résultats au-dessus de la liste */
.count-line { margin: 2px 0 10px; }

/* Étoile favori (cartes + fiche) */
.star { color: var(--transit); font-size: .85em; }

/* Actions d'une carte client : rangée d'icônes à droite du lien principal.
   Les règles générales .card a (padding 14px, display block) ne doivent pas
   toucher ces petits boutons : on les reprend avec une spécificité plus forte. */
.card-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; padding-right: 10px; }
.card-actions form { margin: 0; }
.card-actions .icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  color: var(--ink-soft); border: none; background: none; cursor: pointer;
}
.card-actions .icon-btn svg { width: 18px; height: 18px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: none; background: none; color: var(--ink-soft); cursor: pointer; text-decoration: none; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.active { color: var(--transit); }
.icon-btn.active svg { fill: currentColor; }

/* Rangée d'actions du tableau desktop */
.action-row { display: inline-flex; align-items: center; gap: 2px; }
.data-cell.action-cell { width: 132px; text-align: right; }

/* Autocomplétion client (formulaire de course) : le <select> d'autorité est
   caché, la liste de résultats prend le relais à l'affichage. */
.client-select { display: none; }
.client-results { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-top: 6px; background: var(--surface); }
.search-result {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 12px 14px; text-align: left;
  background: none; border: none; border-bottom: 1px solid var(--line);
  color: var(--ink); font-family: Inter, sans-serif; font-size: .95rem; cursor: pointer;
}
.search-result:last-child { border-bottom: none; }
.search-result:active { background: var(--neutral-soft); }
.search-result-name { font-weight: 600; }
.search-empty { padding: 12px 14px; color: var(--ink-soft); font-size: .9rem; }

/* Fiche client */
.section-title { font-family: Sora, sans-serif; font-size: 1.05rem; font-weight: 700; margin: 20px 0 10px; }
.head-actions { display: flex; align-items: center; gap: 8px; }
.head-actions form { margin: 0; }
.head-actions .btn.is-favorite { color: var(--transit); border-color: var(--transit); }
.contact-card .contact-line { margin-bottom: 4px; font-size: .95rem; }
.contact-card .contact-line.strong { font-weight: 600; font-size: 1.05rem; }
.contact-card a { display: inline; padding: 0; color: var(--accent); }

/* ==========================================================================
   NÉOMORPHISME — surfaces de l'app (clients, courses, caisse)
   Les surfaces naissent du fond par ombre et lumière plutôt que par couleur :
   plaques extrudées (cartes, tuiles, chips, boutons secondaires) vs champs
   enfoncés (saisie, tri, rangées de comptabilité). À l'appui, tout s'enfonce
   (inset) pour un retour tactile immédiat. Les couleurs gardent leur rôle
   fixe : le néo ne touche que les surfaces passives.
   ========================================================================== */

/* Cartes : plaque extrudée, sans bordure ni blanc rapporté. */
.card {
  background: var(--neo-surface);
  border: 1px solid var(--neo-line);
  box-shadow: -6px -6px 14px var(--neo-hi), 6px 6px 16px var(--neo-lo);
}
.card:active {
  border-color: var(--neo-inset-lo);
  box-shadow: inset 3px 3px 8px var(--neo-inset-lo), inset -3px -3px 8px var(--neo-inset-hi);
}

/* Tuiles de chiffres clés (caisse, fiche client) : même plaque, plus douce. */
.stat {
  background: var(--neo-surface);
  border: 1px solid var(--neo-line);
  box-shadow: -4px -4px 10px var(--neo-hi), 4px 4px 12px var(--neo-lo);
}

/* Chips de filtre (courses) : pastille en relief, la sélection s'enfonce. */
.chip {
  background: var(--neo-surface);
  border: 1px solid var(--neo-line);
  box-shadow: -3px -3px 7px var(--neo-hi), 3px 3px 7px var(--neo-lo);
}
.chip.active {
  border-color: var(--ink);
  box-shadow: inset 3px 3px 7px rgba(0, 0, 0, .35), inset -3px -3px 7px rgba(255, 255, 255, .1);
}

/* Champs de saisie : enfoncés dans le fond, opposés aux plaques. */
form input, form select, form textarea {
  background: var(--neo-well);
  border: 1px solid var(--neo-line);
  box-shadow: inset 3px 3px 8px var(--neo-inset-lo), inset -3px -3px 8px var(--neo-inset-hi);
}

/* Boutons secondaires : petite plaque cliquable en relief. */
.btn-secondary {
  background: var(--neo-surface);
  border: 1px solid var(--neo-line);
  box-shadow: -3px -3px 7px var(--neo-hi), 3px 3px 7px var(--neo-lo);
}
.btn-secondary:active {
  border-color: var(--neo-inset-lo);
  box-shadow: inset 3px 3px 7px var(--neo-inset-lo), inset -3px -3px 7px var(--neo-inset-hi);
}

/* Boutons pleins (action, échec, succès, FAB) : ombre portée douce, la
   couleur pleine reste la surface — pas de néo dessus. */
.btn-primary {
  box-shadow: 0 6px 14px -6px rgba(178, 74, 32, .45), 0 2px 4px rgba(178, 74, 32, .2);
}
.btn-danger, .btn-success, .fab {
  box-shadow: 0 6px 14px -6px rgba(28, 39, 51, .35), 0 2px 4px rgba(28, 39, 51, .18);
}
.btn-primary:active, .btn-danger:active, .btn-success:active {
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .2);
}

/* Rangées du registre de caisse : chacune enfoncée dans sa plaque. */
.ledger-item {
  background: var(--neo-well);
  border: 1px solid var(--neo-line);
  border-radius: 10px;
  margin: 6px 10px;
  box-shadow: inset 2px 2px 6px var(--neo-inset-lo), inset -2px -2px 6px var(--neo-inset-hi);
}
.ledger-item + .ledger-item { border-top: none; }

/* Initiales du contact (filtre |initials). Pastille en relief, sans couleur
   détournée : le guide UX interdit les couleurs décoratives. */
.initials {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: Sora, sans-serif; font-weight: 700; font-size: .8rem;
  background: var(--neo-well); color: var(--ink-soft);
  border: 1px solid var(--neo-line);
  box-shadow: -3px -3px 8px var(--neo-hi), 3px 3px 8px var(--neo-inset-lo);
}

/* Icônes d'action (appeler, WhatsApp, favori, modifier) : pastilles rondes
   en relief sur les cartes comme dans le tableau desktop. */
.card-actions .icon-btn, .action-row .icon-btn {
  border-radius: 50%;
  background: var(--neo-surface);
  border: 1px solid var(--neo-line);
  box-shadow: -3px -3px 7px var(--neo-hi), 3px 3px 7px var(--neo-lo);
}
.card-actions .icon-btn:active, .action-row .icon-btn:active {
  border-color: var(--neo-inset-lo);
  box-shadow: inset 3px 3px 7px var(--neo-inset-lo), inset -3px -3px 7px var(--neo-inset-hi);
  color: var(--accent-strong);
}

/* Barre recherche + tri de la liste clients : disposition seule, les champs
   héritent du style enfoncé des formulaires ci-dessus. L'input retient son
   étirement flex (width:100% du formulaire ferait déborder le select). */
.client-list-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.client-list-toolbar input[type="search"] { flex: 1; min-width: 0; }
.client-list-toolbar select { flex: 0 0 auto; width: auto; }

/* Autocomplétion (formulaire de course) : liste de résultats en plaque
   au-dessus du champ, le survol/appui en enfonce les rangées. */
.client-results {
  background: var(--neo-surface);
  border: 1px solid var(--neo-line);
  box-shadow: -4px -4px 10px var(--neo-hi), 4px 4px 12px var(--neo-lo);
}
.search-result:active { background: var(--neo-well); }

/* ============ Bascule Clients / Prospects (carnet d'adresses) ============= */
/* Segmented control : le carnet n'ajoute pas de 4e onglet (guide UX), la
   bascule vit en tête d'écran. La surbrillance du segment actif reprend le
   plein du chip actif (fond encre, texte clair) — cohérent avec les chips. */
.seg-toggle {
  display: flex; gap: 6px; padding: 4px; margin-bottom: 14px;
  background: var(--neo-well);
  border: 1px solid var(--neo-line);
  border-radius: 999px; width: fit-content; max-width: 100%;
}
.seg {
  flex: 1 1 auto; padding: 8px 22px; border-radius: 999px;
  color: var(--ink-soft); text-decoration: none;
  font-size: .85rem; font-weight: 600; text-align: center; white-space: nowrap;
}
.seg-active { background: var(--ink); color: var(--bg); }

/* Catégorie de contact : pastille neutre à côté du nom — les couleurs de
   statut restent réservées aux états, jamais à une valeur d'inventaire. */
.badge.cat { --st-bg: var(--neutral-soft); --st-fg: var(--ink-soft); }

/* Statuts de prospect : Nouveau (neutre, rien encore engagé), Contacté (en
   cours), Converti en client (objectif atteint). Mêmes sémantiques que les
   statuts de course. */
.st-new       { --st-bg: var(--neutral-soft); --st-fg: var(--ink-soft); }
.st-contacted { --st-bg: var(--transit-soft); --st-fg: var(--transit); }
.st-converted { --st-bg: var(--success-soft); --st-fg: var(--success); }

/* Choix « qui paie » du formulaire de course : liste pleine largeur de
   radio-cartes. Le libellé RadioSelect porte la classe .payer-choice ;
   chaque <label> est une carte sélectionnable (input caché visuellement). */
.payer-choice { display: flex; flex-direction: column; gap: 8px; }
.payer-choice label {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 12px; min-height: var(--tap);
  background: var(--neo-surface); border: 1px solid var(--neo-line);
  cursor: pointer; font-weight: 600;
  box-shadow: -3px -3px 8px var(--neo-hi), 3px 3px 8px var(--neo-lo);
}
.payer-choice input { width: 18px; height: 18px; accent-color: var(--accent); }
.payer-choice label:has(input:checked) {
  border-color: var(--accent);
  color: var(--accent-strong);
  box-shadow: inset 2px 2px 6px var(--neo-inset-lo), inset -2px -2px 6px var(--neo-inset-hi);
}

/* Sous-titre de section du menu avatar (ex. « Compte ») : groupe des liens
   liés sous un intitulé, sans être lui-même un lien cliquable. Sépare les
   réglages (Paramètres) des actions de compte (profil, mot de passe, déconnexion). */
.avatar-menu-section {
  display: block; /* span neutre : repousse les items en flux inline */
  padding: 10px 14px 4px; font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft);
}

/* ==========================================================================
   PROFIL — suppression d'avatar, code de confirmation, colonnes desktop
   ========================================================================== */

/* Suppression d'avatar : bouton tertiaire destructif + panneau de confirmation
   inline (remplace la case « Effacer » du widget Django). */
.avatar-actions { margin-top: 10px; }
.avatar-delete-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; padding: 6px 0;
  color: var(--danger); font-size: .85rem; font-weight: 600; cursor: pointer;
}
.avatar-delete-toggle svg { width: 16px; height: 16px; }

/* Code de confirmation de suppression du compte (B5) : affiché en grand,
   teinte d'alerte — c'est le geste du danger, pas un champ banal. */
.code-display {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 1.5rem; font-weight: 600; letter-spacing: .45em; text-indent: .45em;
  text-align: center; padding: 12px 14px; margin-bottom: 10px;
  border-radius: 12px; color: var(--danger);
  background: var(--alert-soft); border: 1px dashed var(--danger);
}

/* Titres de section du Profil : même gabarit que l'ancien style inline. */
.profile-section-title { font-size: 1rem; margin: 28px 0 10px; }

/* Le Profil remplace la classe .narrow : même largeur (680px) en mobile/tablette,
   mais pleine largeur sur desktop pour loger les deux colonnes ci-dessous. */
main.profile-main { max-width: 680px; }

/* Deux colonnes sur desktop : la moitié droite de l'écran était vide.
   Mobile/tablette : le flux simple (une colonne) reste la mise en page. */
@media (min-width: 1024px) {
  main.profile-main { max-width: none; }
  .profile-grid {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 24px; align-items: start;
  }
  .profile-grid > * { min-width: 0; }
  .profile-col > .profile-section-title:first-child { margin-top: 0; }
  .profile-full { grid-column: 1 / -1; }
  /* 5 tuiles du bilan sur une ligne (au lieu de 4 qui faisaient retomber la
     5e sur une deuxième ligne). */
  .profile-stats { grid-template-columns: repeat(5, 1fr); }
}

/* ===== Onglet Facture : aperçu statique du modèle =====
   Image GÉNÉRIQUE par gabarit (static/branding/preview/) — aucune génération
   serveur à la visite. Desktop : formulaire à gauche, image dans la moitié
   droite (grille 2 colonnes), bouton « Voir un aperçu » masqué. Tablette/
   mobile : colonne simple, bouton qui ouvre la même image en surimpression
   avec « Fermer l'aperçu » (aucun nouvel onglet). */
.facture-grid { display: block; }
.facture-preview { display: none; align-self: start; }
.facture-preview-img {
  width: 100%; height: auto; display: block;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: #fff;
}
.facture-preview-head { font-weight: 600; font-size: .9rem; margin-bottom: 8px; }
.facture-preview .hint { margin-top: 8px; }
.preview-open { width: 100%; margin-bottom: 12px; }
@media (min-width: 1024px) {
  /* Deux moitiés égales : le formulaire à gauche, l'aperçu à droite (l'aside
     est le 1er enfant du DOM mais grid-template-areas le place en colonne 2). */
  .facture-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: 'form preview';
    gap: 28px; align-items: start;
  }
  .facture-form { grid-area: form; }
  .facture-preview { grid-area: preview; display: block; position: sticky; top: 20px; }
  .facture-grid > * { min-width: 0; }
  /* L'aperçu doit tenir dans la hauteur d'écran sans scroller : l'image est
     réduite pour entrer dans la zone visible (max-height : topbar + marges +
     en-tête + note), en gardant son ratio — le formulaire, lui, peut défiler. */
  .facture-preview-img {
    width: auto; height: auto;
    max-width: 100%;
    /* Un peu sous la hauteur d'écran : l'aperçu (en-tête + image + note) doit
       apparaître COMPLÈTEMENT, sans jamais déclencher de scroll. */
    max-height: calc(100vh - 220px);
    margin-inline: auto;
  }
  /* Le bouton « Voir un aperçu » n'existe qu'en tablette/mobile : en desktop
     l'image est toujours visible à droite. */
  .preview-open { display: none; }
}

/* Surimpression tablette/mobile : la même image, intégrée à l'écran, avec
   « Fermer l'aperçu ». Même langage visuel que le dialogue de confirmation. */
.preview-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 14, 18, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.preview-modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  max-width: 460px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.preview-modal-card .btn { width: 100%; }

/* ===== Dialogue de confirmation réutilisable (partials/confirm_dialog.html) =====
   Modal aux couleurs de la charte : fond assombri, carte sur --surface, titre en
   Sora (hérité de h2), message pré-ligne (white-space: pre-line) pour les
   récapitulatifs multi-lignes, action destructive à droite en dernier (Guide UX). */
.confirm-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 14, 18, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.confirm-dialog {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
  padding: 24px; width: 100%; max-width: 400px;
}
.confirm-title { font-size: 1.15rem; margin: 0 0 8px; }
.confirm-message {
  color: var(--ink-soft); font-size: .92rem; line-height: 1.55;
  white-space: pre-line; margin: 0;
}
.confirm-icon {
  color: var(--danger); margin-bottom: 12px;
}
.confirm-icon svg { width: 26px; height: 26px; }
.confirm-actions {
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 22px;
}
/* Le .btn pose width:100% (rangées empilées) : dans la modale on veut les deux
   boutons côte à côte, Annuler à gauche, l'action à droite en dernier (Guide UX).
   flex:1 1 auto → largeur naturelle, répartition égale si la place le permet,
   repli en deux lignes si les libellés sont trop larges (flex-wrap ci-dessus). */
.confirm-actions .btn { width: auto; flex: 1 1 auto; }

/* ============================== Catégories (onglet Contacts) ============= */

/* Mode Cartes : grille de catégories — classe NEUVE (pas .card-list) : la règle
   desktop mobile.css:709 qui masque .card-list ne la vise pas, le bug « cartes
   vides » en est corrigé. Chaque carte est entièrement cliquable (bouton) et
   ouvre la modale qui révèle les contacts par lots. */
.cat-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.cat-grid .card { margin-bottom: 0; }
.cat-card { padding: 0; }
.cat-card-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px; background: none; border: none; color: var(--ink);
  text-align: left; font: inherit; cursor: pointer;
}
.cat-card-body { flex: 1; min-width: 0; }
.cat-card-name { font-weight: 600; display: block; }
.cat-card-count { color: var(--ink-soft); font-size: .78rem; }

/* Modale « catégorie » (mode Cartes) — même langage que le dialogue de
   confirmation (fixed, fond assombri, carte centrée). L'état est global
   ($store.catModal) : le téléport body n'interfère pas avec la portée. */
.cat-overlay {
  /* Sous le dialogue de confirmation (100) : téléporté en fin de body, il
     passerait devant lui à z-index égal — la suppression resterait invisible. */
  position: fixed; inset: 0; z-index: 90;
  background: rgba(10, 14, 18, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.cat-modal {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
  width: 100%; max-width: 600px; max-height: 85dvh;
  display: flex; flex-direction: column; overflow: hidden;
}
.cat-modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 12px; border-bottom: 1px solid var(--line);
}
.cat-modal-title { flex: 1; min-width: 0; font-weight: 700; font-size: 1.05rem; }
.cat-modal-actions { display: flex; gap: 4px; }
.cat-modal .cat-contacts { overflow-y: auto; padding: 14px 16px; }

/* Mode Annuaire : accordéon — une seule section ouverte à la fois (openPk).
   Le chevron pivote à l'ouverture ; la section se replie au prochain choix. */
.cat-accordion .card { margin-bottom: 10px; }
.cat-section { padding: 0; }
.cat-header {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 14px; background: none; border: none; color: var(--ink);
  text-align: left; font: inherit; cursor: pointer;
}
.cat-chevron {
  color: var(--ink-soft); flex: 0 0 auto;
  transition: transform 150ms ease; /* même tempo que --dur-2 (motion.css) */
}
.cat-header[aria-expanded="true"] .cat-chevron { transform: rotate(90deg); }
.cat-name { font-weight: 600; flex: 1; min-width: 0; }
.cat-count { color: var(--ink-soft); font-size: .78rem; flex: 0 0 auto; }
.cat-body { padding: 0 14px 14px; }

/* Grille de contacts (modale et accordéon) : tuiles présentables plutôt que
   lignes pleine largeur — initials, nom, téléphone/adresse, actions. */
.cat-contacts { display: grid; grid-template-columns: 1fr; gap: 10px; }
.cat-contacts .card { margin-bottom: 0; }
.cat-more { grid-column: 1 / -1; justify-self: center; min-width: 180px; }

@media (min-width: 768px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .cat-contacts { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  /* La modale plafonne à 2 colonnes (max-width 600px) ; l'accordéon, pleine
     largeur, passe à 3. */
  .cat-accordion .cat-contacts { grid-template-columns: repeat(3, 1fr); }
}

/* ============================ Onboarding ================================= */

/* Bandeau de rappel du parcours de bienvenue : persistant (pas de fermeture),
   distinct des alertes (pas auto-fermé par htmx). Vit hors du content, entre
   la topbar et le main. */
.onboarding-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line);
  font-size: .9rem; font-weight: 500; color: var(--ink);
}
.onboarding-banner .btn { width: auto; }

/* Indicatrice d'étapes du wizard (1/2 Profil, 2/2 Activité). */
.wizard-steps {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.wizard-step {
  padding: 8px 14px; border-radius: 999px;
  background: var(--neutral-soft); color: var(--ink-soft);
  font-size: .85rem; font-weight: 600;
}
.wizard-step.active { background: var(--accent); color: #fff; }
.wizard-step.done { background: var(--success-soft); color: var(--success-strong); }

/* Actions du wizard (Continuer/Terminer + Plus tard). */
.wizard-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: 18px;
}
.wizard-actions .btn { width: auto; }
