/* ==========================================================================
   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;
  --surface-2: #F7F5F0;      /* fond alterné : champs, tuiles, pastilles */
  --well: #EFECE3;           /* champ en creux (un ton en dessous du fond) */

  /* Accents — famille latérite */
  --accent: #E2542A;        /* action principale */
  --accent-strong: #C94922;
  --success: #3FA796;       /* argent / livré */
  --success-strong: #2F8A7A;
  --success-deep: #2A8063;  /* fond bouton success : contraste AA (4.81:1) */
  --transit: #C97A4A;       /* en cours */
  --transit-strong: #A65E30; /* texte "en cours" : contraste ≥3:1 sur crème */
  --danger: #C13C54;        /* échec / destructif */

  /* Encres de texte posées sur les pastels — contraste AA ≥ 4.5:1 validé sur
     la pastel associée (ne pas confondre avec les --*-strong, réservées aux
     montants/grands textes sur fond clair, ni avec --*-deep). */
  --success-ink: #1F6B5A;   /* ≥4.5:1 sur --success-soft */
  --transit-ink: #7C451F;   /* ≥4.5:1 sur --transit-soft */
  --danger-ink: #9E2F45;    /* ≥4.5:1 sur --alert-soft */
  --accent-ink: #A3391B;    /* texte/action sur --accent-soft (alertes CTA) */

  /* 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.
     Couleurs dérivées en tokens pour ne jamais coder d'hex en dur. */
  --sidebar-bg: #1C2733;
  --sidebar-fg: #EDEAE3;
  --sidebar-fg-dim: rgba(237, 234, 227, .68);
  --sidebar-fg-mid: rgba(237, 234, 227, .72);
  --sidebar-fg-faint: rgba(237, 234, 227, .42);
  --sidebar-line: rgba(237, 234, 227, .14);
  --sidebar-active: #F07A50;
  --sidebar-active-bg: rgba(226, 84, 42, .20);

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

  /* Chevron des menus déroulants (.fselect) : token portant la data-URI, pour
     pouvoir l'éclaircir en thème sombre (couleur encodée dans le SVG). */
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234F5F6D' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");

  /* Relief « ombre douce » (html.style-soft) — ombres tokenisées : sur le fond
     sombre #12181F une ombre noire à 10% est invisible, la variante dark doit
     pouvoir assombrir/renforcer sans dupliquer les valeurs en dur. */
  --shadow-soft-card: 0 2px 8px rgba(28, 39, 51, .10), 0 1px 2px rgba(28, 39, 51, .06);
  --shadow-soft-chip: 0 1px 2px rgba(28, 39, 51, .08);
  --shadow-soft-field: 0 1px 2px rgba(28, 39, 51, .05);

  /* Ombres des calques flottants (feuillets, modales) et des boutons pleins —
     invariantes au style mais tokenisées pour s'atténuer en thème sombre
     (source unique : la variante dark ci-dessous). */
  --shadow-dialog: 0 24px 60px rgba(10, 14, 18, .35);
  --shadow-dialog-top: 0 -12px 32px rgba(10, 14, 18, .18);
  --shadow-btn-accent: 0 6px 14px -6px rgba(178, 74, 32, .45), 0 2px 4px rgba(178, 74, 32, .2);
  --shadow-btn: 0 6px 14px -6px rgba(28, 39, 51, .35), 0 2px 4px rgba(28, 39, 51, .18);
  --shadow-btn-inset: inset 0 2px 6px rgba(0, 0, 0, .2);

  /* Relief « néo » — style OPTIONNEL choisi dans Paramètres → Apparence
     (le défaut reste plat : surface + liseré fin + ombre quasi nulle).
     Tokens partagés entre la surcouche html.style-neo (en bas de fichier) et
     le hover desktop des cartes (motion.css) : une seule source de valeurs. */
  --neo-hi: rgba(255, 255, 255, .92);
  --neo-lo: rgba(164, 150, 122, .5);
  --neo-inset-hi: rgba(255, 255, 255, .9);
  --neo-inset-lo: rgba(156, 144, 114, .38);
  --neo-border: rgba(164, 150, 122, .36);
  --neo-border-dim: rgba(164, 150, 122, .2);
}

/* Mode sombre — SOURCE UNIQUE. `data-theme` est TOUJOURS posé par le JS de
   base.html (résolution du « auto » via prefers-color-scheme au chargement,
   et à chaque bascule système), donc un seul bloc suffit : plus de duplication
   entre @media et :root[data-theme=dark]. */
:root[data-theme="dark"] {
  --bg: #12181F;
  --surface: #1B242E;
  --ink: #EDEAE3;
  --ink-soft: #A9B6C2;
  --line: #2A3642;
  /* Surfaces hiérarchisées (fidèles au dark d'origine) : --surface-2 = plaque
     de carte (un ton plus clair que le fond), --well = champ en creux (sombre). */
  --surface-2: #17222C;
  --well: #0E141B;
  /* Relief « néo » dark — ombres subtiles (pas de halo clair 92%). */
  --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-border: rgba(255, 255, 255, .09);
  --neo-border-dim: rgba(255, 255, 255, .05);
  --accent: #F07A50;      /* accents éclaircis pour rester lisibles */
  --accent-strong: #E2542A;
  --success: #56C4B0;
  --success-strong: #3FA796;
  --success-deep: #2A8063;
  --transit: #D99A6C;
  --transit-strong: #B5753F;
  --danger: #E0637C;
  --accent-soft: #4A2A1E;
  --success-soft: #16332D;
  --transit-soft: #3A2B20;
  --alert-soft: #3B2028;
  --neutral-soft: #232C36;
  /* Encres pastel dark (≥4.5:1 sur leur pastel sombre) — l'encodage hex de la
     data-URI du chevron vit dans les tokens --chevron ci-dessus/dessous. */
  --success-ink: var(--success);   /* ≥4.5:1 sur #16332D */
  --transit-ink: var(--transit);   /* ≥4.5:1 sur #3A2B20 */
  --danger-ink: #EE8299;           /* ≥4.5:1 sur #3B2028 */
  --accent-ink: #FF8A5B;           /* ≥4.5:1 sur #4A2A1E et le fond */
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A9B6C2' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  --shadow-pop: 0 12px 28px -14px rgba(0, 0, 0, .75);
  --shadow-soft-card: 0 1px 1px rgba(0, 0, 0, .35), 0 14px 26px -18px rgba(0, 0, 0, .9);
  --shadow-soft-chip: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-soft-field: 0 1px 2px rgba(0, 0, 0, .42);
  --shadow-dialog: 0 24px 60px rgba(0, 0, 0, .75);
  --shadow-dialog-top: 0 -12px 32px rgba(0, 0, 0, .5);
  --shadow-btn-accent: 0 6px 16px -6px rgba(0, 0, 0, .7), 0 2px 4px rgba(0, 0, 0, .45);
  --shadow-btn: 0 6px 16px -6px rgba(0, 0, 0, .7), 0 2px 4px rgba(0, 0, 0, .5);
  --shadow-btn-inset: inset 0 2px 6px rgba(0, 0, 0, .45);
}

/* 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; }

* { 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: var(--shadow-dialog-top);
  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: color-mix(in srgb, var(--accent) 12%, transparent); 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: color-mix(in srgb, var(--danger) 12%, transparent); 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: color-mix(in srgb, var(--accent) 6%, transparent);
}
.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) !important; }
.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: "IBM Plex Mono", ui-monospace, SFMono-Regular, 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); }
/* Lien à copier (page publique de l'équipe, suivi d'une course, facture) :
   une ligne creuse + un bouton Copier. */
.copy-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;
}
.copy-link code {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, 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-strong); 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-deep); color: #fff; }
.btn-ghost { background: none; color: var(--ink-soft); border: none; box-shadow: none; padding: 8px; }
/* Destructif en contour (Zone de danger du profil) : garde la taille d'un
   secondaire mais annonce la couleur du danger — jamais un plein de la même
   taille que le primaire (Guide UX). */
.btn-outline-danger {
  background: var(--surface);
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-outline-danger:active { background: var(--alert-soft); }
.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).
   Fond OPAQUE (surface + liseré, comme la .tabbar) : un dégradé translucide
   laissait les textes du contenu transparaître sous la barre au défilement
   (rendu illisible signalé — bug « polices en fond »). */
.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: var(--surface);
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
}

/* Pages avec dock d'action fixe (encaisser, livrer…) : le dock est haut (jusqu'à
   ~160px pour « Frais à encaisser ») et retiré du flux. On réserve assez de marge
   basse sous le contenu pour que sa fin puisse défiler AU-DESSUS du dock — sinon
   les derniers éléments restent coincés derrière, invisibles même en bas de page. */
main:has(.action-bar) {
  padding-bottom: calc(220px + env(safe-area-inset-bottom));
}

/* 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: none; margin-bottom: 12px;
}
.card a { display: block; padding: 14px; color: var(--ink); text-decoration: none; }

/* Carte course — style latérite (refonte UI) : surface claire, montant orange
   en gros à droite, code mono, badges pastel. Structure en colonnes.
   Compacte : padding réduit, ombre nulle (plate — style plat). */
.delivery-card {
  box-shadow: none;
}
.delivery-card a {
  display: flex; flex-direction: column; gap: 4px; padding: 10px 12px;
  color: var(--ink); text-decoration: none;
}
.delivery-card .dc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.delivery-card .dc-left { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.delivery-card .client { display: block; font-weight: 700; font-size: .98rem; }
.delivery-card .dc-code { display: block; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: .6rem; color: var(--ink-soft); letter-spacing: .02em; }
.delivery-card .dc-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 0 auto; }
.delivery-card .dc-route { color: var(--ink-soft); font-size: .82rem; }
.delivery-card .dc-meta { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: .76rem; flex-wrap: wrap; }
.delivery-card .dc-meta-item { display: inline-flex; align-items: center; gap: 4px; }
.delivery-card .dc-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 2px; }
.delivery-card .dc-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.delivery-card .card-amt { font-weight: 800; color: var(--accent); white-space: nowrap; font-size: 1.3rem; line-height: 1; font-variant-numeric: tabular-nums; margin-left: auto; }
.delivery-card .card-amt small { font-size: .75rem; color: var(--ink-soft); }

/* État survol des cartes cliquables — même réaction que les lignes de tableau
   (.data-row:hover) : fond légèrement teinté. Spécificité (0,3,0) pour gagner
   sur `.delivery-card.card` (0,2,0) qui fixe le fond au repos. */
.delivery-card.card:hover, .client-card.card:hover, .quick-link.card:hover { background: var(--bg); }
.delivery-card { transition: background .12s ease; }

.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.
   NB : `.card a { display:block }` (plus haut) doit être neutralisé sur la
   carte client/prospect — son lien principal redevient flex (initiales à
   gauche, corps à droite), sans toucher à la carte course (dc-*, en colonne). */
.client-card { display: flex; align-items: center; }
.client-card > a {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 12px;
}
.client-card .card-list-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.client-card .route { margin-top: 2px; font-size: .8rem; color: var(--ink-soft); }
.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-ink); }
.st-delivered, .badge-delivered, .ib-delivered { --st-bg: var(--success-soft); --st-fg: var(--success-ink); }
.st-failed, .badge-failed, .ib-failed          { --st-bg: var(--alert-soft); --st-fg: var(--danger-ink); }
.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-ink); }

/* 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-ink); }

/* É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-ink); }
.badge-partial { --st-bg: var(--transit-soft); --st-fg: var(--transit-ink); }
.badge-unpaid  { --st-bg: var(--alert-soft); --st-fg: var(--danger-ink); }

/* É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-ink); }
.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-ink); }
.badge-borrowed     { --st-bg: var(--alert-soft); --st-fg: var(--danger-ink); }
.badge-outstanding  { --st-bg: var(--transit-soft); --st-fg: var(--transit-ink); }
.badge-repaid       { --st-bg: var(--neutral-soft); --st-fg: var(--ink-soft); }

/* Photo de preuve absente (liste Courses) : pastel transit — avertissement non bloquant. */
.badge-proof { --st-bg: var(--transit-soft); --st-fg: var(--transit-ink); }

/* Badges génériques par TONALITÉ (synthèses finance, compteurs…), pour les cas
   sans classe d'état dédiée : même pastel/encre AA que la famille d'états. */
.badge-warning { --st-bg: var(--transit-soft); --st-fg: var(--transit-ink); }
.badge-success { --st-bg: var(--success-soft); --st-fg: var(--success-ink); }
.badge-danger  { --st-bg: var(--alert-soft); --st-fg: var(--danger-ink); }

/* Remises d'espèces : cycle de vie déclarée → validée / refusée. « Déclarée »
   est en transit (elle attend une décision), « validée » actée, « refusée »
   écartée — même famille pastel/encre que les statuts de course. */
.badge-declared  { --st-bg: var(--transit-soft); --st-fg: var(--transit-ink); }
.badge-validated { --st-bg: var(--success-soft); --st-fg: var(--success-ink); }
.badge-refused   { --st-bg: var(--alert-soft); --st-fg: var(--danger-ink); }

.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; }

/* ============================== Barre de filtres (refonte UI) ============ */
/* Une rangée de menus déroulants sur UNE ligne, défilable droite-gauche sans
   repli (modèle Stitch). Chaque select navigue vers l'URL des filtres. */
.filterbar {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: thin;
  flex-wrap: nowrap; min-width: 0;
  -webkit-overflow-scrolling: touch; padding: 2px 0 12px;
  margin: 0 -16px 4px; padding-left: 16px; padding-right: 16px;
  scrollbar-color: var(--line) transparent;
}
.filterbar > * { flex: 0 0 auto; flex-shrink: 0; }
.filterbar::-webkit-scrollbar { height: 6px; }
.filterbar::-webkit-scrollbar-track { background: transparent; }
.filterbar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.fselect {
  flex: 0 0 auto; flex-shrink: 0; appearance: none; -webkit-appearance: none;
  height: 38px; min-width: 128px; padding: 0 30px 0 14px; border-radius: 999px;
  background: var(--surface); color: var(--ink-soft); border: 1px solid var(--line);
  font-family: inherit; font-size: .8rem; font-weight: 600; cursor: pointer;
  background-image: var(--chevron);
  background-repeat: no-repeat; background-position: right 12px center;
}
.fselect:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.fselect option { color: var(--ink); background: var(--surface); }


/* ============================== 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-strong); }

/* ============================== 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: none; 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-strong); }
.stat.pending .v { color: var(--transit-strong); }
.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: none;
  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; }
/* Pas de fond propre : le select suit le style des champs de formulaire
   (--well, cohérent avec le <input> voisin) et les surcouches soft/néo. */
.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; }

/* 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; overflow-x: hidden; }
.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;
}
/* Largeurs de colonnes stabilisées : Client (large) / Adresse (auto) / Statut
   (compacte, badges sur une seule ligne) / Montant (à droite). */
.data-head span:first-child { width: 32%; }
.data-head span:nth-child(2) { width: 26%; }
.data-head span:nth-child(3) { width: 30%; }
.data-head span:last-child { width: auto; text-align: right; }
.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; text-align: right; }
/* La colonne statut : badges alignés sur une ligne, sans étalement. */
.data-cell:nth-child(3) { white-space: nowrap; }
.data-cell:nth-child(3) .badge { margin-right: 4px; }

/* ============================== 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;
}
/* Cases à cocher & radios des réglages : pas de cadre orange au clic souris —
   l'état coché (point/coche en accent) montre déjà la sélection. Le rectangle
   venait de la règle de focus ci-dessus, appliquée au clic. Il ne reste qu'en
   navigation clavier (:focus-visible), posé sur l'icône arrondie qui porte le
   contrôle plutôt qu'autour du point circulaire. */
form input[type="radio"]:focus:not(:focus-visible),
form input[type="checkbox"]:focus:not(:focus-visible),
.settings-row input[type="radio"]:focus:not(:focus-visible),
.settings-row input[type="checkbox"]:focus:not(:focus-visible) {
  outline: none;
}
.settings-row:has(input[type="radio"]:focus-visible) .settings-row-icon,
.settings-row:has(input[type="checkbox"]:focus-visible) .settings-row-icon {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.settings-row:has(input[type="radio"]:focus-visible) input,
.settings-row:has(input[type="checkbox"]:focus-visible) input {
  outline: none;
}
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;
  border: 1px solid var(--line); /* structure sur le fond ; la pastel porte le sens */
}
/* Alertes — mêmes pastels/encres que la famille de badges : texte AA ≥4.5:1.
   Le blanc sur les pleines (--success/--danger/--transit) tombait sous 3:1. */
.alert.success { background: var(--success-soft); color: var(--success-ink); }
.alert.error { background: var(--alert-soft); color: var(--danger-ink); }
.alert.warning { background: var(--transit-soft); color: var(--transit-ink); }

/* Bandeau-CTA plein largeur (rappel « courses à encaisser », commandes portail) :
   un lien qui se lit comme un rappel. Pastel accent + encre accessible. */
.alert-cta {
  background: var(--accent-soft); color: var(--accent-ink);
  display: block; text-decoration: none; font-weight: 600;
}
.alert-cta:hover { text-decoration: underline; }

/* Lien « Revenir à aujourd'hui » sous le titre des jours passés : petit lien
   accent en AA (plus sombre que --accent, qui serait <4.5:1 en texte fin). */
.sub-link { color: var(--accent-ink); font-weight: 600; text-decoration: none; }
.sub-link:hover { text-decoration: underline; }

/* ============================== 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); }
/* Les actions destructives/annexes sont portées par des <button class="tertiary">
   : un bouton doit oublier son apparence natale (fond, bordure, police, taille)
   pour se comporter exactement comme le lien tertiaire — plus de resets inline
   répétés dans les gabarits. */
button.tertiary {
  background: none; border: none; padding: 0;
  font-family: inherit; line-height: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.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; overflow-x: hidden; }
  .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; }
  /* La marge basse anti-dock (mobile) n'a plus lieu d'être : le dock est statique. */
  main:has(.action-bar) { padding-bottom: 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);
    /* Même taille que les libellés du rail : « Plus » est un bouton du même
       menu, il n'y a pas de raison qu'il soit écrit plus petit. */
    font-size: .68rem; font-weight: 600; letter-spacing: .02em;
    border: none; background: none; cursor: pointer;
  }
  .rail-more svg { width: 22px; height: 22px; }

  /* Le libellé du rail doit rester LISIBLE, et il ne dispose que de 80 px.
     « Tableau de bord » (le plus long du Manager) et « Encaissements du jour »
     (celui du livreur) n'y tiennent pas sur une ligne : le `nowrap` d'avant les
     rendait en « Tableau… » et « Encaissements… », et un bouton de navigation
     tronqué ne dit plus où il mène — c'est pire qu'un bouton sur deux lignes.
     On autorise donc le retour à la ligne (la hauteur du rail suit, elle n'est
     pas contrainte), et on remonte la taille : à .62rem, ce libellé était écrit
     plus petit que tout le reste de l'application, souvent lu dehors.
     `overflow-wrap` n'est qu'un filet — il ne coupe un mot que s'il ne tient
     pas seul sur une ligne, ce qui n'arrive à aucun libellé actuel. */
  .nav-item .nav-label {
    line-height: 1.15;
    font-size: .68rem;
    overflow-wrap: break-word;
  }

  .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; overflow-x: hidden;
  }
  .split-detail {
    display: block; flex: 1; min-width: 0; padding-left: 22px;
    max-height: calc(100dvh - 60px); overflow-y: auto; overflow-x: hidden;
  }

  /* 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-strong); color: #fff; border-radius: 9px; /* AA 4.71:1 */
    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 .dc-route { font-size: .78rem; }
  .split .delivery-card .card-amt { font-size: 1.2rem; }

  /* 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: var(--sidebar-fg); font-family: Sora, sans-serif; font-weight: 800; font-size: 1.1rem; }
  .sidebar-brand .kio-icon { color: var(--sidebar-fg); }
  .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: var(--sidebar-fg-dim);
  }
  .nav-item svg { width: 18px; height: 18px; }
  .nav-item:hover { background: rgba(255, 255, 255, .06); color: var(--sidebar-fg); }
  .nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); }

  /* 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: var(--sidebar-fg-faint);
  }

  .sidebar-foot {
    display: flex; align-items: center; gap: 10px;
    margin-top: auto; padding: 10px 8px 4px;
    color: var(--sidebar-fg-mid); font-size: .82rem;
    border-top: 1px solid var(--sidebar-line);
    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); }

/* ==========================================================================
   REFONTE UI — style PLAT latérite (défaut). Les surfaces s'appuient sur
   couleur + liseré fin + ombre quasi nulle. Les deux autres styles (ombre
   douce / néo) sont des surcouches optionnelles plus bas, portées par des
   tokens déclarés en :root (--neo-*, --sidebar-*). Le clair/sombre utilise
   les tokens --surface/--line (source unique : :root[data-theme=dark]).
   ========================================================================== */

/* Cartes : surface + liseré fin + ombre nulle (style plat). */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
}
.card:active { box-shadow: none; }

/* Tuiles de chiffres clés (caisse, fiche client). */
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
}

/* Chips de filtre (courses) : pastille plate, la sélection reste pleine. */
.chip {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
}
.chip.active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
  box-shadow: none;
}

/* --- Carte course, style PLAT par défaut : surface + liseré fin, ni ombre ni
   relief. En style soft/néo, les surcouches html.style-* (fin de fichier, plus
   spécifiques 0-2-1) la surchargent comme toutes les autres cartes : la carte
   suit le style choisi — cohérence totale entre les composants. --- */
.delivery-card.card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
}
.delivery-card.card:active { box-shadow: none; }

/* Champs de saisie : fond en creux (--well) + liseré fin — hiérarchie dark
   fidèle à l'origine : les champs sont un ton en dessous du fond, pas à plat. */
form input, form select, form textarea {
  background: var(--well);
  border: 1px solid var(--line);
  box-shadow: none;
}

/* Boutons secondaires : contour + liseré fin, surface claire. */
.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: none;
}
.btn-secondary:active { background: var(--surface-2); }

/* 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: var(--shadow-btn-accent);
}
.btn-danger, .btn-success, .fab {
  box-shadow: var(--shadow-btn);
}
.btn-primary:active, .btn-danger:active, .btn-success:active {
  box-shadow: var(--shadow-btn-inset);
}
/* Le « + Nouvelle course » du panneau tablette est un primaire compact :
   il reprend l'ombre des pleins pour rester identique à .btn-primary. */
.t-new-btn { box-shadow: var(--shadow-btn-accent); }

/* Rangées du registre de caisse : rangées plates, séparées par un liseré. */
.ledger-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 6px 10px;
  box-shadow: none;
}
.ledger-item + .ledger-item { border-top: none; }

/* Initiales du contact (filtre |initials). Pastille neutre, plate. */
.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(--surface-2); color: var(--ink-soft);
  border: 1px solid var(--line);
  box-shadow: none;
}

/* Icônes d'action (appeler, WhatsApp, favori, modifier) : pastilles rondes
   plates avec le fond teinté du statut. */
.card-actions .icon-btn, .action-row .icon-btn {
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: none;
}
.card-actions .icon-btn:active, .action-row .icon-btn:active {
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* Barre recherche + tri de la liste clients : disposition seule, les champs
   héritent du style des formulaires ci-dessus. */
.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 surface
   au-dessus du champ, le survol/appui teinte la rangée. */
.client-results {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-pop); /* token : variante sombre renforcée */
}
.search-result:active { background: var(--surface-2); }

/* ============ 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(--surface-2);
  border: 1px solid var(--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-ink); }
.st-converted { --st-bg: var(--success-soft); --st-fg: var(--success-ink); }

/* 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(--surface); border: 1px solid var(--line);
  cursor: pointer; font-weight: 600;
  box-shadow: none;
}
.payer-choice input { width: 18px; height: 18px; accent-color: var(--accent); }
.payer-choice label:has(input:checked) {
  border-color: var(--accent);
  color: var(--accent-ink); /* AA ≥4.5:1 sur le fond accent-soft */
  background: var(--accent-soft);
}

/* 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: none;
  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; }
/* Onglets d'aperçu (reçu A5 / facture A4) : réutilisent les .chip des filtres,
   sans leur décalage de bord (prévu pour le scroll horizontal d'une barre de
   filtres pleine largeur — ici la rangée vit dans un volet). */
.preview-chips { margin: 0 0 8px; padding: 0; }
.preview-chips .chip { min-height: 34px; padding: 5px 12px; font-size: .78rem; cursor: pointer; }
@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: var(--shadow-dialog);
  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: var(--shadow-dialog);
  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-strong); 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; }

/* ==========================================================================
   STYLES VISUELS (refonte UI) — surcouches choisies dans Paramètres → Apparence.
   Le style de BASE (par défaut, sans classe) est « latérite moderne » (plat).
   - html.style-soft : ombre douce (surfaces détachées, plus de relief).
   - html.style-neo  : néomorphisme (relief 3D, ombres bi-directionnelles).
   La classe est posée sur <html> par base.html (context processor user_ui_style).
   ========================================================================== */

/* ---------- STYLE « Ombre douce » : surface + liseré + ombre légère ---------- */
html.style-soft .card,
html.style-soft .stat,
html.style-soft .settings-rows,
html.style-soft .dash-controls,
html.style-soft .data-table {
  box-shadow: var(--shadow-soft-card);
}
html.style-soft .chip,
html.style-soft .btn-secondary,
html.style-soft .payer-choice label {
  box-shadow: var(--shadow-soft-chip);
}
html.style-soft form input,
html.style-soft form select,
html.style-soft form textarea,
html.style-soft .fselect,
html.style-soft .dash-control select,
html.style-soft .account-select select {
  box-shadow: var(--shadow-soft-field);
}
/* Surfaces du langage « ombre douce » non couvertes : la bascule Clients/
   Prospects gardait son appui plat, l'autocomplétion son ombre dure du style
   plat (--shadow-pop). On les détache avec les ombres du style choisi pour que
   tous les éléments suivent le même relief. */
html.style-soft .seg-toggle,
html.style-soft .client-results {
  box-shadow: var(--shadow-soft-card);
}
/* Retour d'appui des cartes en soft : fin cadre intérieur au lieu du néant
   plat (le néo a son inset) — le style garde un feedback perceptible. */
html.style-soft .card:active {
  box-shadow: inset 0 0 0 1px var(--line);
}

/* ---------- STYLE « Néo » : relief 3D (ombres bi-directionnelles) ---------- */
html.style-neo .card {
  background: var(--surface-2);
  border: 1px solid var(--neo-border);
  box-shadow: -6px -6px 14px var(--neo-hi), 6px 6px 16px var(--neo-lo);
}
html.style-neo .card:active {
  box-shadow: inset 3px 3px 8px var(--neo-inset-lo), inset -3px -3px 8px var(--neo-inset-hi);
}
html.style-neo .stat {
  background: var(--surface-2);
  border: 1px solid var(--neo-border);
  box-shadow: -4px -4px 10px var(--neo-hi), 4px 4px 12px var(--neo-lo);
}
html.style-neo .chip {
  background: var(--surface-2);
  border: 1px solid var(--neo-border);
  box-shadow: -3px -3px 7px var(--neo-hi), 3px 3px 7px var(--neo-lo);
}
html.style-neo .chip.active {
  box-shadow: inset 3px 3px 7px var(--neo-inset-lo), inset -3px -3px 7px var(--neo-inset-hi);
}
html.style-neo form input,
html.style-neo form select,
html.style-neo form textarea,
html.style-neo .fselect,
html.style-neo .dash-control select,
html.style-neo .account-select select {
  background: var(--surface-2);
  border: 1px solid var(--neo-border);
  box-shadow: inset 3px 3px 8px var(--neo-inset-lo), inset -3px -3px 8px var(--neo-inset-hi);
}
html.style-neo .btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--neo-border);
  box-shadow: -3px -3px 7px var(--neo-hi), 3px 3px 7px var(--neo-lo);
}
html.style-neo .btn-secondary:active {
  box-shadow: inset 3px 3px 7px var(--neo-inset-lo), inset -3px -3px 7px var(--neo-inset-hi);
}
html.style-neo .ledger-item {
  background: var(--surface-2);
  border: 1px solid var(--neo-border);
  box-shadow: inset 3px 3px 8px var(--neo-inset-lo), inset -3px -3px 8px var(--neo-inset-hi);
}
html.style-neo .initials,
html.style-neo .icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--neo-border);
  box-shadow: -3px -3px 8px var(--neo-hi), 3px 3px 8px var(--neo-lo);
}
/* Les icônes d'action sont des pastilles rondes en néo, comme en plat pour les
   cartes (.card-actions/.action-row) : on arrondit aussi celles hors cartes
   (fermeture de modale, tuiles de contact) pour un vocabulaire unique. */
html.style-neo .icon-btn { border-radius: 50%; }
html.style-neo .seg-toggle,
html.style-neo .client-results {
  background: var(--surface-2);
  border: 1px solid var(--neo-border);
  box-shadow: -4px -4px 10px var(--neo-hi), 4px 4px 12px var(--neo-lo);
}

/* Vue tableau desktop (Courses) : en néo, les lignes deviennent des plaques
   en relief — sinon le style néo ne s'applique pas sur cet écran (tableau). */
html.style-neo .data-table {
  background: var(--surface-2);
  border: 1px solid var(--neo-border);
  border-radius: var(--radius);
  box-shadow: -4px -4px 10px var(--neo-hi), 4px 4px 12px var(--neo-lo);
}
html.style-neo .data-row .data-cell { border-bottom: 1px solid var(--neo-border-dim); }
/* Le tableau desktop garde son fond/liseré en soft (l'ombre est posée par le
   groupe html.style-soft plus haut, via le token --shadow-soft-card). */
html.style-soft .data-table {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* « Trous » du style néo : plaques qui n'étaient pas couvertes par la surcouche
   (listes de réglages, contrôleurs du dashboard, radio-cartes du paiement).
   Mêmes surface-2 / liseré néo / ombres bi-directionnelles que .card. */
html.style-neo .settings-rows,
html.style-neo .dash-controls {
  background: var(--surface-2);
  border: 1px solid var(--neo-border);
  border-radius: var(--radius);
  box-shadow: -4px -4px 10px var(--neo-hi), 4px 4px 12px var(--neo-lo);
}
html.style-neo .settings-row { border-color: var(--neo-border-dim); }
html.style-neo .dash-control select { background: var(--surface-2); }
html.style-neo .payer-choice label {
  background: var(--surface-2);
  border: 1px solid var(--neo-border);
  box-shadow: -3px -3px 7px var(--neo-hi), 3px 3px 7px var(--neo-lo);
}
html.style-neo .payer-choice label:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, .06);
}

/* Le néo assombrit le fond des surfaces passives en thème sombre. */
html.style-neo form input,
html.style-neo form select,
html.style-neo form textarea,
html.style-neo .card,
html.style-neo .stat,
html.style-neo .chip,
html.style-neo .btn-secondary,
html.style-neo .ledger-item {
  color: var(--ink);
}

/* ==========================================================================
   COHÉRENCE INTER-STYLES (fin de fichier)
   Plaques restées plates en néo à côté de surfaces sculptées, sélection
   master-detail, champs fichiers, formulaires-cartes. Règles volontairement
   APRÈS les surcouches pour gagner en spécificité/ordre.
   ========================================================================== */

/* Groupe COD du panneau livraison + lien public de l'Équipe : mêmes relief,
   fond et liseré que .card/.settings-rows — le néo ne laisse plus de plaque
   plate sur un écran par ailleurs sculpté. */
html.style-neo .deliver-collection,
html.style-neo .copy-link {
  background: var(--surface-2);
  border: 1px solid var(--neo-border);
  box-shadow: -4px -4px 10px var(--neo-hi), 4px 4px 12px var(--neo-lo);
}
/* Codes à copier de l'Équipe (identifiant, mot de passe, lien) : un creux,
   comme un champ — lisible et dans le langage néo. */
html.style-neo .courier-pw {
  background: var(--surface);
  border: 1px solid var(--neo-border);
  box-shadow: inset 2px 2px 6px var(--neo-inset-lo), inset -2px -2px 6px var(--neo-inset-hi);
}
/* Zone photo du panneau tablette (détail course) : creux de dépôt. */
html.style-neo .panel-photo {
  background: var(--surface-2);
  border-color: var(--neo-border-dim);
  box-shadow: inset 2px 2px 6px var(--neo-inset-lo), inset -2px -2px 6px var(--neo-inset-hi);
}
/* Champ fichier : le groupe des champs néo force un bord plein et perd le
   pointillé « déposer une photo » — on restaure la signalétique de la zone. */
html.style-neo input[type="file"] {
  border: 1.5px dashed var(--neo-border-dim);
  background: var(--surface-2);
  box-shadow: none;
}
/* Autocomplétion : en néo son conteneur est déjà surface-2, le retour d'appui
   surface-2 de base devient invisible — on l'envoie vers le fond de page. */
html.style-neo .search-result:active { background: var(--bg); }
/* En néo, le survol des cartes ne doit pas les « évidér » en les ramenant au
   fond de page (--bg) : on teinte le dessus de la plaque d'un ton neutre. */
html.style-neo .delivery-card.card:hover,
html.style-neo .client-card.card:hover,
html.style-neo .quick-link.card:hover {
  background: var(--neutral-soft);
}
/* Sélection master-detail : le repère (cadre accent intérieur) était écrasé
   par les ombres des surcouches — re-déclaré après elles. */
html.style-soft .delivery-card.selected,
html.style-neo .delivery-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
/* .form-card n'a de carte qu'en desktop (style de base dans @media ≥1024) :
   les surcouches la suivaient à toutes les largeurs → ombre « fantôme » en
   soft et carte néo sur mobile. Recadrées sur le breakpoint où elle existe. */
@media (min-width: 1024px) {
  html.style-soft .form-card { box-shadow: var(--shadow-soft-card); }
  html.style-neo .form-card {
    background: var(--surface-2);
    border: 1px solid var(--neo-border);
    border-radius: var(--radius);
    box-shadow: -4px -4px 10px var(--neo-hi), 4px 4px 12px var(--neo-lo);
  }
}

/* #7 — Champ mot de passe : bouton œil Afficher/Masquer (QA V0).
   js/password_toggle.js enveloppe chaque input[type=password] dans .pwd-field
   et y ajoute .pwd-reveal. Le type bascule password ↔ text (même CSS). */
.pwd-field { position: relative; display: block; width: 100%; }
.pwd-field input[type="password"],
.pwd-field input[type="text"] { width: 100%; padding-right: 2.7rem; }
.pwd-reveal {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  border: 0; background: none; padding: 6px; cursor: pointer;
  color: var(--ink-soft); display: inline-flex; align-items: center; line-height: 0;
}
.pwd-reveal svg { width: 20px; height: 20px; display: block; }
.pwd-reveal:hover { color: var(--ink); }
.pwd-reveal.is-open { color: var(--accent); }

/* #8 — Champ téléphone (B1) : enrobage .phone-field posé par js/phone_field.js
   (un <select> d'indicatif devant l'input, placeholder piloté par le pays).
   Les règles de base `form input/select` ci-dessus s'appliquent toujours — ici
   on ne fait que répartir l'espace : le pays a la largeur de son libellé
   (borné), le numéro prend le reste de la ligne. */
.phone-field { display: flex; gap: 8px; align-items: center; width: 100%; }
.phone-field .phone-field-country {
  flex: 0 0 auto; width: auto; max-width: 46%;
  cursor: pointer;
}
.phone-field input { flex: 1 1 0; min-width: 0; }


/* ================== A2 — Tournées de livraison & escales ==================
   Une tournée est un REGROUPEMENT de courses (même départ, même donneur
   d'ordre) : elle n'a pas de statut propre, son badge se dérive des statuts de
   ses courses. Le cartouche du carnet et la carte de l'écran « Tournées »
   partagent le même en-tête (.tour-card-hd, partial tour_head.html).

   NB de spécificité : `.card a` (0,1,1) donne padding/display à tout lien d'une
   carte — les ancres d'en-tête sont donc ciblées en 2 classes (0,2,0) pour
   reprendre la main (même raison pour .leg-addr). */

.tour-card { padding: 0; overflow: hidden; }
.tour-card .tour-card-hd {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px; color: var(--ink); text-decoration: none;
}
.tour-ic {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-ink);
}
.tour-ic svg { width: 18px; height: 18px; }
.tour-hd-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tour-name { font-weight: 700; font-size: .98rem; }
.tour-sub { font-size: .76rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tour-hd-right { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.tour-count { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: .72rem; color: var(--ink-soft); }

/* Statut DÉRIVÉ d'une tournée — préparation / en cours / terminée / annulée. */
.ts-preparation { --st-bg: var(--neutral-soft); --st-fg: var(--ink-soft); }
.ts-en_cours    { --st-bg: var(--transit-soft); --st-fg: var(--transit-ink); }
.ts-terminee    { --st-bg: var(--success-soft); --st-fg: var(--success-ink); }
.ts-annulee     { --st-bg: var(--alert-soft);  --st-fg: var(--danger-ink); }

/* Chip « Tournée » de la vue tableau desktop : signale qu'une course est membre
   d'une tournée (le regroupement visuel vit dans la vue cartes). */
.badge-tour { --st-bg: var(--accent-soft); --st-fg: var(--accent-ink); }

/* Courses membres rangées sous leur cartouche : encart discret plutôt qu'une
   seconde carte pleine largeur (on ne double pas la bordure). */
.tour-legs { display: flex; flex-direction: column; gap: 8px; padding: 0 10px 10px; }
.tour-legs .delivery-card {
  margin-bottom: 0; background: var(--surface-2);
  border-color: transparent; border-radius: 10px;
}

/* Fiche tournée — une ligne par destination, dans l'ordre de passage. */
.legs-card { padding: 4px 0; }
.leg-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.leg-row:last-child { border-bottom: none; }
.leg-no {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--neutral-soft); color: var(--ink-soft);
  font-weight: 700; font-size: .78rem;
}
.leg-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.leg-row .leg-addr { display: inline; padding: 0; color: var(--ink); font-weight: 600; text-decoration: none; }
.leg-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .76rem; color: var(--ink-soft); }
.leg-meta .amount { color: var(--accent); font-weight: 700; }

/* Itinéraire à escales (panneau de la course) : départ → escales → livraison.
   Le point courant est cerclé (c'est LUI qu'on marque « point atteint »). */
.stops { display: flex; flex-direction: column; margin-top: 8px; }
.stop-line { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; }
.stop-dot {
  flex: 0 0 auto; width: 12px; height: 12px; margin-top: 4px;
  border-radius: 50%; border: 2px solid var(--line); background: var(--surface);
}
.stop-dot.done { border-color: var(--success); background: var(--success); }
.stop-dot.now { border-color: var(--transit); background: var(--transit); box-shadow: 0 0 0 4px var(--transit-soft); }
.stop-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.stop-label { font-size: .72rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.stop-addr { font-size: .9rem; }
.stop-sub { font-size: .78rem; color: var(--ink-soft); }
.stop-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.stop-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

/* Journal de la course (panneau détail) — les modifications réussies et les
   tentatives refusées, mêlées. Une ligne d'échec se distingue par un fond
   pastel rouge : c'est l'information que le bureau ne recevait nulle part, et
   elle doit se repérer sans lire. Le reste de la liste est volontairement
   discret — un journal se consulte, il ne s'annonce pas. */
.journal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.journal-title { font-weight: 700; font-size: .95rem; }
.journal { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.journal-row { padding: 9px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; }
.journal-row:first-child { border-top: 0; padding-top: 0; }
.journal-row--failed {
  background: var(--alert-soft); border-radius: 10px;
  padding: 9px 10px; border-top: 0; margin: 4px 0;
}
.journal-line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.journal-action { font-weight: 600; font-size: .88rem; }
.journal-when { font-size: .78rem; }
.journal-meta { font-size: .76rem; color: var(--ink-soft); }
.journal-row--failed .journal-action, .journal-row--failed .journal-reason { color: var(--danger-ink); }
.journal-reason { font-size: .84rem; }
.journal-move { font-size: .84rem; }
