/* ============================================================================
   L'Atelier de Mathéo — feuille de style unique
   Toutes les pages héritent de base.html et chargent ce fichier.
   Style « Sable & Prune » (octobre 2026) : fond pierre, cartes blanches très
   arrondies, prune pour l'action principale, ambre pour les repères. Les
   couleurs ne sont définies qu'ici, dans les variables ci-dessous.
   ========================================================================= */

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
img, svg { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

/* ── Thème clair (défaut) ────────────────────────────────────────────────── */
:root {
  --bg:            #EEE9E1;
  --surface:       #FFFFFF;
  --surface-2:     #F6F2EC;
  --surface-3:     #ECE5DB;
  --sand:          #DCD1C1;
  --sand-text:     #4A4250;
  --border:        #E8E1D6;
  --border-strong: #D3C8B8;
  --text:          #221C27;
  --text-2:        #5F5666;
  --text-3:        #776E7E;

  /* Prune : bouton principal, élément actif, cartes fortes */
  --accent:         #33243F;
  --accent-hover:   #46345A;
  --accent-soft:    #EFE9F3;
  --accent-border:  #D7CBE0;
  --on-accent:      #F8F3FA;
  --accent-muted:   #C9BCD3;   /* texte secondaire sur fond prune */
  --accent-2:       #46345A;   /* surface secondaire sur fond prune */

  /* Ambre et corail : repères visuels */
  --highlight:      #F2B13F;
  --on-highlight:   #2B1D0A;
  --highlight-soft: #FCEFD6;
  --coral:          #E5715A;
  --on-coral:       #2B120C;
  --coral-soft:     #FBE3DD;

  /* États */
  --green:  #2C7155;  --green-soft:  #E3F1EA;  --green-border:  #B8DCC9;
  --blue:   #2B5C93;  --blue-soft:   #E8F0F9;  --blue-border:   #C3D6EC;
  --amber:  #9A5A0E;  --amber-soft:  #FCF0DC;  --amber-border:  #EFD3A6;
  --red:    #B23B2C;  --red-soft:    #FBEAE7;  --red-border:    #F0C3BB;
  --violet: #6A3E8F;  --violet-soft: #F2EAF8;  --violet-border: #DBC9EA;

  --radius:    24px;
  --radius-sm: 14px;
  --radius-lg: 30px;
  --pill:      999px;

  --shadow-1: 0 1px 2px rgba(51,36,63,.04);
  --shadow-2: 0 10px 28px rgba(51,36,63,.08), 0 2px 6px rgba(51,36,63,.04);
  --shadow-3: 0 24px 60px rgba(51,36,63,.18), 0 6px 16px rgba(51,36,63,.08);
  --ring: 0 0 0 3px color-mix(in srgb, var(--highlight) 55%, transparent);

  --sidebar-w: 248px;
  --topbar-h:  76px;

  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Outfit", "Manrope", -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, monospace;

  /* alias legacy (utilisés par le JS du module devis) */
  --surface2: var(--surface-2);
  --text2: var(--text-2);
  --t2: var(--text-2);
  --accent-light: var(--accent-soft);
  --warn: var(--red);
  --warn-light: var(--red-soft);
  --amber-light: var(--amber-soft);
  --blue-light: var(--blue-soft);
  --nav-h: var(--topbar-h);

  color-scheme: light;
}

/* ── Thème sombre « Aubergine » ──────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #15111B;
    --surface:       #211B29;
    --surface-2:     #2A2333;
    --surface-3:     #332B3E;
    --sand:          #2E2539;
    --sand-text:     #CFC4DA;
    --border:        #352C40;
    --border-strong: #4A3F57;
    --text:          #F3EEF6;
    --text-2:        #B4A9C0;
    --text-3:        #978CA4;
    --accent:        #E9B3D2;
    --accent-hover:  #F2C6DF;
    --accent-soft:   #3A2B45;
    --accent-border: #574468;
    --on-accent:     #2A1B33;
    --accent-muted:  #6B4F67;
    --accent-2:      #F4CDE2;
    --highlight:     #F0A85A;  --on-highlight: #2A1B12;  --highlight-soft: #3A2A1D;
    --coral:         #EE8C76;  --on-coral: #2B120C;      --coral-soft: #3D2320;
    --green:  #6CC79F;  --green-soft:  #1D3329;  --green-border:  #2F5845;
    --blue:   #8DB8E8;  --blue-soft:   #1B2738;  --blue-border:   #2C4260;
    --amber:  #EBB56C;  --amber-soft:  #33281A;  --amber-border:  #5A4423;
    --red:    #F08D7E;  --red-soft:    #3A1F21;  --red-border:    #633331;
    --violet: #C6A6EC;  --violet-soft: #2D2340;  --violet-border: #4A3A66;
    --shadow-1: 0 1px 2px rgba(0,0,0,.35);
    --shadow-2: 0 10px 28px rgba(0,0,0,.4);
    --shadow-3: 0 24px 60px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg:            #15111B;
  --surface:       #211B29;
  --surface-2:     #2A2333;
  --surface-3:     #332B3E;
  --sand:          #2E2539;
  --sand-text:     #CFC4DA;
  --border:        #352C40;
  --border-strong: #4A3F57;
  --text:          #F3EEF6;
  --text-2:        #B4A9C0;
  --text-3:        #978CA4;
  --accent:        #E9B3D2;
  --accent-hover:  #F2C6DF;
  --accent-soft:   #3A2B45;
  --accent-border: #574468;
  --on-accent:     #2A1B33;
  --accent-muted:  #6B4F67;
  --accent-2:      #F4CDE2;
  --highlight:     #F0A85A;  --on-highlight: #2A1B12;  --highlight-soft: #3A2A1D;
  --coral:         #EE8C76;  --on-coral: #2B120C;      --coral-soft: #3D2320;
  --green:  #6CC79F;  --green-soft:  #1D3329;  --green-border:  #2F5845;
  --blue:   #8DB8E8;  --blue-soft:   #1B2738;  --blue-border:   #2C4260;
  --amber:  #EBB56C;  --amber-soft:  #33281A;  --amber-border:  #5A4423;
  --red:    #F08D7E;  --red-soft:    #3A1F21;  --red-border:    #633331;
  --violet: #C6A6EC;  --violet-soft: #2D2340;  --violet-border: #4A3A66;
  --shadow-1: 0 1px 2px rgba(0,0,0,.35);
  --shadow-2: 0 10px 28px rgba(0,0,0,.4);
  --shadow-3: 0 24px 60px rgba(0,0,0,.6);
  color-scheme: dark;
}

/* ── Base ────────────────────────────────────────────────────────────────── */
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display { font-family: var(--display); }
::selection { background: color-mix(in srgb, var(--highlight) 45%, transparent); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 10px; }

.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 999;
  background: var(--accent); color: var(--on-accent);
  padding: 10px 16px; border-radius: var(--pill); font-weight: 700;
}
.skip-link:focus { left: 8px; }

/* ── Icônes ──────────────────────────────────────────────────────────────── */
/* Taille par défaut de toute icône. Un <svg> sans width/height ni règle CSS
   s'étire à la largeur de son conteneur : cette règle garantit une taille
   sensée partout. Les règles plus précises restent prioritaires. */
.ico {
  width: 1.1em; height: 1.1em;
  flex-shrink: 0;
  vertical-align: -0.17em;
  display: inline-block;
}

/* ── Structure ───────────────────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; gap: 0; }

/* Barre latérale : un panneau blanc flottant, entrées en pilules. */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 0; height: 100vh;
  padding: 18px 0 18px 18px;
  z-index: 60;
}
.sb-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none; color: inherit;
}
.sb-brand img { width: 58px; height: auto; flex-shrink: 0; }
.sb-brand b { display: block; font-family: var(--display); font-size: 16px; font-weight: 650; letter-spacing: -.01em; line-height: 1.1; }
.sb-brand small { display: block; font-size: 12px; color: var(--text-2); line-height: 1.3; font-weight: 600; }
:root[data-theme="dark"] .sb-brand img { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sb-brand img { filter: invert(1); } }

.sb-nav {
  padding: 10px; display: flex; flex-direction: column; gap: 3px;
  flex: 1; overflow-y: auto;
  background: var(--surface); border-radius: var(--radius);
}
.sb-section { font-size: 10.5px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); padding: 12px 12px 4px; }
.sb-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px 9px 9px; border-radius: var(--pill);
  text-decoration: none; color: var(--text-2);
  font-size: 14.5px; font-weight: 650;
  transition: background .13s, color .13s;
  position: relative;
}
.sb-link svg {
  width: 34px; height: 34px; padding: 8px; border-radius: 50%;
  flex-shrink: 0; stroke-width: 2; background: var(--surface-2);
  transition: background .13s, color .13s;
}
.sb-link:hover { background: var(--surface-2); color: var(--text); }
.sb-link.active { background: var(--accent); color: var(--on-accent); }
.sb-link.active svg { background: var(--accent-2); color: var(--highlight); }
.sb-link .sb-count {
  margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: var(--pill);
  font-size: 11.5px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums;
  background: var(--highlight); color: var(--on-highlight);
}

.sb-foot {
  padding: 8px; display: flex; gap: 6px; align-items: center;
  background: var(--surface); border-radius: var(--radius);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  min-height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 16px 28px 10px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}
.topbar-head { min-width: 0; flex: 1; }
.topbar h1 {
  font-family: var(--display);
  font-size: 30px; font-weight: 600; letter-spacing: -.02em;
  line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-sub { font-size: 13.5px; color: var(--text-2); display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 3px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

.page { padding: 12px 28px 64px; max-width: 1400px; width: 100%; }

/* ── Burger + overlay + barre du bas (mobile) ────────────────────────────── */
.burger, .sb-overlay, .tabbar { display: none; }
.burger {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface); border: 0;
  cursor: pointer; place-items: center; color: var(--text);
}
.burger svg { width: 20px; height: 20px; }
.burger:active { background: var(--surface-2); }

/* ── Boutons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px;
  border-radius: var(--pill); border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 700; text-decoration: none;
  cursor: pointer; white-space: nowrap;
  transition: background .13s, border-color .13s, transform .06s, box-shadow .13s, color .13s;
}
.btn svg { width: 16px; height: 16px; stroke-width: 2.2; flex-shrink: 0; }
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary svg { color: var(--highlight); }

.btn-accent { background: var(--highlight); border-color: var(--highlight); color: var(--on-highlight); }
.btn-accent:hover { background: color-mix(in srgb, var(--highlight) 88%, #000); border-color: transparent; }

.btn-danger { background: var(--surface); border-color: var(--red-border); color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }

.btn-sm { height: 36px; padding: 0 14px; font-size: 13.5px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-icon { width: 42px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { margin: 0; display: inline-flex; }

/* ── Cartes ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 0;
  border-radius: var(--radius);
  padding: 22px;
}
.card + .card { margin-top: 18px; }
/* Même respiration entre tous les blocs d'une page, même quand une carte est
   rangée dans un formulaire (import de facture, puis formulaire d'achat…).
   Les marges verticales se fusionnent : pas d'espace doublé. */
.page > * + *, .page > form > * + * { margin-top: 18px; }
.page > script + *, .page > * + script { margin-top: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 22px 12px;
}
.card-head h2, .card-title {
  font-family: var(--display);
  font-size: 18px; font-weight: 600; letter-spacing: -.01em;
  color: var(--text); margin: 0; text-transform: none;
}
.card > .card-title { margin-bottom: 14px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px 22px 22px; }
/* Variantes de carte du tableau de bord */
.card-sand { background: var(--sand); color: var(--text); }
.card-prune { background: var(--accent); color: var(--on-accent); }
.card-prune .text-muted, .card-prune .hint { color: var(--accent-muted); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
.grid-side { grid-template-columns: minmax(0,1.25fr) minmax(300px,.75fr); align-items: start; }
.grid-side-rev { grid-template-columns: minmax(300px,.8fr) minmax(0,1.2fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* ── Statistiques ────────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 0;
  border-radius: var(--radius); padding: 18px 18px 16px;
  display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit;
  transition: transform .12s, box-shadow .13s;
  position: relative; overflow: hidden;
}
a.stat:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.stat-top { display: flex; align-items: center; gap: 9px; }
.stat-ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-2); color: var(--text-2); }
.stat-ico svg { width: 16px; height: 16px; stroke-width: 2.2; }
.stat-label { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.stat-val { font-family: var(--display); font-size: 30px; font-weight: 600; letter-spacing: -.025em; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 6px; }
.stat-hint { font-size: 12.5px; color: var(--text-3); }
.stat.tone-green .stat-ico { background: var(--green-soft); color: var(--green); }
.stat.tone-blue  .stat-ico { background: var(--blue-soft);  color: var(--blue); }
.stat.tone-amber .stat-ico { background: var(--highlight-soft); color: var(--amber); }
.stat.tone-red   .stat-ico { background: var(--coral-soft);   color: var(--red); }
.stat.tone-red   .stat-val { color: var(--red); }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px 4px 9px; border-radius: var(--pill);
  font-size: 12px; font-weight: 750; line-height: 1.45;
  border: 0; background: var(--surface-3); color: var(--text-2);
  white-space: nowrap; vertical-align: middle;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-plain::before { display: none; }
.badge-en_cours, .badge-envoyee  { background: var(--blue-soft);   color: var(--blue); }
.badge-termine,  .badge-payee    { background: var(--green-soft);  color: var(--green); }
.badge-en_attente, .badge-brouillon { background: var(--amber-soft); color: var(--amber); }
.badge-annule,   .badge-annulee  { background: var(--red-soft);    color: var(--red); }
.badge-3d        { background: var(--coral-soft); color: #A3402C; }
.badge-informatique { background: var(--accent-soft); color: var(--violet); }
.badge-mobile    { background: var(--highlight-soft); color: var(--amber); }
.badge-autre     { background: var(--surface-3); color: var(--text-2); }
.badge-creation  { background: var(--surface-3); color: var(--text-2); }
.badge-passage   { background: var(--amber-soft); color: var(--amber); }
.badge-info      { background: var(--blue-soft);  color: var(--blue); }
.badge-cloture   { background: var(--green-soft); color: var(--green); }
.badge-lg { font-size: 13px; padding: 5px 13px 5px 11px; }
/* Étapes du suivi : « reçu » et « rendu » sont neutres, les deux bouts du
   parcours ; « prêt » passe en ambre, la seule étape qui appelle le client. */
.badge-recu       { background: var(--surface-3); color: var(--text-2); }
.badge-diagnostic { background: var(--blue-soft);   color: var(--blue); }
.badge-devis      { background: var(--amber-soft);  color: var(--amber); }
.badge-reparation, .badge-production { background: var(--violet-soft); color: var(--violet); }
.badge-pret       { background: var(--highlight);   color: var(--on-highlight); }
.badge-rendu, .badge-restitue { background: var(--surface-3); color: var(--text-3); }
:root[data-theme="dark"] .badge-3d { color: var(--coral); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge-3d { color: var(--coral); } }

/* ── Tableaux ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
  font-size: 12px; font-weight: 750; letter-spacing: 0; text-transform: none;
  color: var(--text-3); text-align: left;
  padding: 10px 16px; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
td.strong { font-weight: 750; }
.cell-main { font-weight: 700; color: var(--text); }
a.cell-main { min-width: 230px; }
.cell-mono { font-family: var(--mono); font-size: 13px; letter-spacing: -.02em; }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sortable::after { content: "\2195"; opacity: .3; margin-left: 6px; font-size: 10px; }
th.sortable.asc::after  { content: "\2191"; opacity: 1; color: var(--accent); }
th.sortable.desc::after { content: "\2193"; opacity: 1; color: var(--accent); }

.row-link { color: inherit; text-decoration: none; display: block; }
.row-link:hover { color: var(--accent); }
tr.is-hidden, .is-hidden { display: none !important; }

/* ── Liste mobile ────────────────────────────────────────────────────────── */
.mobile-list { display: none; flex-direction: column; gap: 8px; padding: 6px 10px 10px; }
.m-card {
  display: block; text-decoration: none; color: inherit;
  padding: 14px 16px; border-radius: 20px; background: var(--surface-2);
}
.m-card:active { background: var(--surface-3); }
.m-top { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.m-title { font-weight: 750; font-size: 15px; line-height: 1.35; }
.m-sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.m-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; font-size: 12.5px; color: var(--text-3); }
.m-row .amount { margin-left: auto; font-family: var(--display); font-weight: 600; color: var(--text); font-size: 16px; font-variant-numeric: tabular-nums; }

/* ── Barre d'outils (recherche + filtres) ────────────────────────────────── */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search { position: relative; flex: 1; min-width: 220px; }
.search > svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-3); pointer-events: none; }
.search input:not([type="checkbox"]):not([type="radio"]):not([type="file"]) { padding-left: 44px; border-radius: var(--pill); border-color: transparent; background: var(--surface); height: 46px; }
.search kbd { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); }
.search input:focus ~ kbd, .search input:not(:placeholder-shown) ~ kbd { opacity: 0; }
kbd {
  font-family: var(--font); font-size: 11px; font-weight: 700; color: var(--text-3);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 6px; line-height: 1.5;
  transition: opacity .12s;
}

.filters { display: flex; gap: 4px; flex-wrap: wrap; background: var(--surface); border: 0; border-radius: var(--pill); padding: 5px; }
.filters a {
  padding: 7px 15px; border-radius: var(--pill); text-decoration: none;
  font-size: 13.5px; font-weight: 700; color: var(--text-2); white-space: nowrap;
  transition: background .12s, color .12s;
}
.filters a:hover { color: var(--text); background: var(--surface-2); }
.filters a.active { background: var(--accent); color: var(--on-accent); }

.result-count { font-size: 13px; color: var(--text-3); padding: 0 4px 10px; }

/* ── Formulaires ─────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.col1 { grid-template-columns: 1fr; }
.form-grid.col3 { grid-template-columns: repeat(3, 1fr); }
.form-group { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.form-group.span2 { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.hint { font-size: 12.5px; color: var(--text-3); }

/* Champs posés sur un bloc déjà teinté : fond blanc pour rester visibles. */
.achat-ligne :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea),
.qr-zone :where(input, select), .picker-head :where(input) { background-color: var(--surface); }
/* :where() = priorité nulle : toute largeur plus précise ailleurs l'emporte. */
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea) {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14.5px;
  color: var(--text);
  transition: border-color .13s, box-shadow .13s, background .13s;
  min-height: 44px;
}
:where(textarea) { min-height: 88px; resize: vertical; line-height: 1.5; }
:where(input:hover:not(:focus):not([readonly]), select:hover:not(:focus), textarea:hover:not(:focus)) { border-color: var(--border-strong); }
:where(input:focus, select:focus, textarea:focus) { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
:where(input[readonly]) { background: var(--surface-3); color: var(--text-2); }
:where(select) {
  appearance: none; cursor: pointer; padding-right: 38px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235F5666' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
input[type="file"] {
  width: 100%; padding: 12px 14px; font-size: 14px;
  border: 2px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer;
}
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 700; font-size: 13px; margin-right: 12px; cursor: pointer;
  border: 0; border-radius: var(--pill); padding: 7px 14px; background: var(--accent); color: var(--on-accent);
}
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; font-weight: 600; color: var(--text); }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }

/* ── Sélecteur segmenté (particulier / professionnel) ────────────────────── */
.segmented { display: flex; gap: 4px; background: var(--surface-2); border: 0; border-radius: var(--pill); padding: 5px; }
.segmented label {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--pill); cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--text-2);
  transition: background .12s, color .12s;
}
.segmented label:hover { color: var(--text); }
.segmented label.on { background: var(--accent); color: var(--on-accent); }
.segmented input { margin: 0; }

/* ── Encaissement ────────────────────────────────────────────────────────── */
.paiement-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.paiement-form .form-group { flex: 1; min-width: 190px; }

/* ── Lignes de facturation ───────────────────────────────────────────────── */
.ligne-row {
  display: grid;
  grid-template-columns: minmax(0,3fr) 88px 116px 100px 36px;
  gap: 10px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.ligne-row:first-child { padding-top: 0; }
.ligne-row:last-child { border-bottom: none; padding-bottom: 0; }
.lig-total { text-align: right; font-variant-numeric: tabular-nums; font-weight: 750; font-size: 14px; }
.ligne-row .form-group { gap: 0; }
.lig-detail { margin-top: 5px; }

@media (max-width: 900px) {
  .ligne-row {
    grid-template-columns: 1fr 1fr 36px;
    gap: 8px; padding: 14px 0;
  }
  .ligne-row .form-group:first-child { grid-column: 1 / -1; }
  .lig-total { grid-column: 1 / 3; text-align: left; }
}

/* ── Clé / valeur ────────────────────────────────────────────────────────── */
.kv { display: flex; flex-direction: column; }
.kv-row { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv-row:last-child { border-bottom: none; }
.kv-key { color: var(--text-2); flex-shrink: 0; }
.kv-val { font-weight: 700; text-align: right; word-break: break-word; }
/* Lignes chiffrées (estimation du devis) : le libellé passe à la ligne, le
   montant ne se coupe jamais. */
.kv-chiffre .kv-key { flex-shrink: 1; min-width: 0; overflow-wrap: anywhere; }
.kv-chiffre .kv-val { flex-shrink: 0; white-space: nowrap; word-break: normal; }
.kv-val a { color: var(--accent); text-decoration: none; }
.remise-devis { display: flex; gap: 8px; margin-top: 12px; }
.livraison-devis { display: flex; gap: 8px; align-items: center; margin-top: 10px; min-height: 38px; }
.livraison-devis .check { flex: 1; margin: 0; }
.remise-devis select { flex: 1; min-width: 0; }
/* Champ chiffré + unité (%, €) : prioritaire sur la règle générale des champs à 100 % */
.champ-unite { position: relative; width: 110px; flex-shrink: 0; }
.temps-tranche { display: flex; gap: 8px; flex-wrap: wrap; }
.temps-tranche .champ-unite { width: 96px; }
.temps-tranche .champ-unite .champ-unite-val { padding-right: 40px; }
.champ-unite .champ-unite-val { width: 100%; padding-right: 30px; text-align: right; }
.champ-unite span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 14px; font-weight: 700; color: var(--text-2); pointer-events: none; }
.kv-val a:hover { text-decoration: underline; }

/* ── Timeline ────────────────────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; position: relative; padding-left: 6px; }
.tl-item { display: flex; gap: 14px; padding-bottom: 18px; position: relative; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: 8px; top: 22px; bottom: 0;
  width: 2px; background: var(--border);
}
.tl-item:last-child::before { display: none; }
.tl-dot {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; margin-top: 3px;
  background: var(--surface); border: 2.5px solid var(--border-strong); z-index: 1;
}
.tl-dot.creation { border-color: var(--text-3); }
.tl-dot.passage  { border-color: var(--highlight); background: var(--highlight-soft); }
.tl-dot.info     { border-color: var(--blue);  background: var(--blue-soft); }
.tl-dot.cloture  { border-color: var(--accent); background: var(--accent); }
.tl-body { flex: 1; min-width: 0; }
.tl-note { font-size: 14.5px; line-height: 1.5; }
.tl-meta { font-size: 12.5px; color: var(--text-3); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ── État vide ───────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 24px; color: var(--text-2); }
.empty > svg { width: 52px; height: 52px; margin: 0 auto 16px; padding: 13px; border-radius: 50%; background: var(--surface-2); color: var(--text-3); stroke-width: 1.8; }
.empty h3 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.empty p { font-size: 14px; margin-bottom: 18px; }

/* ── Divers ──────────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-2); }
.text-dim { color: var(--text-3); }
.text-accent { color: var(--accent); }
.text-right { text-align: right; }
.small { font-size: 12.5px; }
.amount { font-variant-numeric: tabular-nums; font-weight: 750; }
.amount-lg { font-family: var(--display); font-size: 26px; font-weight: 600; letter-spacing: -.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-16 { margin-bottom: 16px; }
.sticky-side { position: sticky; top: calc(var(--topbar-h) + 16px); }
.link { color: var(--accent); text-decoration: none; font-weight: 700; }
.link:hover { text-decoration: underline; }

/* ── Mini graphique d'activité ───────────────────────────────────────────── */
.chart { display: flex; align-items: flex-end; gap: 12px; height: 170px; margin: 6px 0 2px; }
.chart-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; height: 100%; min-width: 0; }
.chart-track { width: 100%; flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.chart-bar {
  width: 100%; max-width: 56px; border-radius: 12px 12px 4px 4px;
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--surface)) 0 6px, color-mix(in srgb, var(--accent) 30%, var(--surface)) 6px 12px);
  min-height: 8px; transition: height .3s cubic-bezier(.2,.9,.3,1);
}
.chart-bar.is-empty { background: none; height: 3px !important; min-height: 3px; border-radius: 2px; border-top: 3px solid var(--border-strong); }
.chart-col.now .chart-bar { background: repeating-linear-gradient(135deg, var(--accent) 0 6px, var(--accent-hover) 6px 12px); }
.chart-x { font-size: 12px; color: var(--text-3); font-weight: 700; white-space: nowrap; }
.chart-col.now .chart-x { color: var(--text); }

/* Infobulle du graphique, ancrée au sommet de la barre. --dx garde les
   bulles des colonnes extrêmes dans la carte. */
.chart-col { cursor: default; }
.chart-col:focus { outline: none; }
.chart-col:focus-visible .chart-bar { box-shadow: 0 0 0 3px var(--highlight); }
.chart-bar { position: relative; min-height: 0; }
.chart-bar:not(.is-empty) { min-height: 6px; }
.chart-tip {
  --dx: -50%;
  position: absolute; bottom: 100%; left: 50%; z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 11px 7px; border-radius: 12px; white-space: nowrap;
  background: var(--accent); color: var(--on-accent);
  box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none;
  transform: translate(var(--dx), -2px);
  transition: opacity .12s ease, transform .12s ease;
}
.chart-tip b { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.chart-tip-mois { font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; opacity: .7; }
.chart-tip-n { font-size: 10.5px; opacity: .7; }
.chart-tip::after {
  content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px;
  border: 5px solid transparent; border-top-color: var(--accent);
}
.chart-col:hover .chart-tip,
.chart-col:focus .chart-tip,
.chart-col.is-open .chart-tip { opacity: 1; transform: translate(var(--dx), -8px); }

.chart-col:first-child .chart-tip { --dx: -16%; }
.chart-col:first-child .chart-tip::after { left: 16%; }
.chart-col:last-child  .chart-tip { --dx: -84%; }
.chart-col:last-child  .chart-tip::after { left: 84%; }

@media (prefers-reduced-motion: reduce) {
  .chart-tip { transition: none; }
}

/* ── Alerte / ligne compacte ─────────────────────────────────────────────── */
.row-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; margin: 0 -12px; border-radius: 18px;
  text-decoration: none; color: inherit;
  transition: background .12s;
}
a.row-item:hover { background: var(--surface-2); }
.row-item-body { min-width: 0; flex: 1; }
/* Blocs (et non textes « en ligne ») : sinon un nom trop long sort de la carte
   au lieu d'être coupé par « … », et la ligne du dessous se met à la suite. */
.row-item-title { display: block; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item-sub { display: block; font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .tag { font-size: 12px; font-weight: 750; color: var(--amber); white-space: nowrap; }

/* ── Toasts ──────────────────────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 900; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  background: var(--accent); color: var(--on-accent); border: 0;
  box-shadow: var(--shadow-3); border-radius: var(--pill);
  padding: 12px 20px 12px 16px; font-size: 14px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
  animation: toast-in .22s cubic-bezier(.2,.9,.3,1);
  max-width: 380px;
}
.toast::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--highlight); flex-shrink: 0; }
.toast.err::before { background: var(--coral); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }

/* ── Modale ──────────────────────────────────────────────────────────────── */
.modal-back {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(34,28,39,.45); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
  animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border: 0;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-3);
  width: min(440px, 100%); padding: 26px;
  animation: pop .18s cubic-bezier(.2,.9,.3,1);
}
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
.modal h3 { font-size: 20px; font-weight: 600; margin-bottom: 7px; }
.modal p { font-size: 14.5px; color: var(--text-2); margin-bottom: 20px; line-height: 1.5; }
.modal .btn-group { justify-content: flex-end; }
.modal-wide { width: min(560px, 100%); }
.shortcut-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.shortcut-row:last-child { border-bottom: none; }
.shortcut-row kbd { font-size: 12px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .grid-side, .grid-side-rev, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .sticky-side { position: static; }
}

@media (max-width: 900px) {
  /* Le menu complet glisse depuis la gauche ; la barre du bas porte les
     écrans du quotidien. */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100dvh;
    transform: translateX(-105%);
    transition: transform .22s cubic-bezier(.3,.8,.3,1);
    width: 290px; padding: 14px; background: var(--bg);
    box-shadow: var(--shadow-3);
  }
  body.nav-open .sidebar { transform: none; }
  .sb-overlay {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(34,28,39,.4); opacity: 0; pointer-events: none;
    transition: opacity .2s;
  }
  body.nav-open .sb-overlay { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .burger { display: grid; }
  .topbar { padding: 12px 16px 8px; gap: 10px; flex-wrap: wrap; }
  .topbar-head { flex: 1 1 160px; }
  .topbar-actions { flex-shrink: 1; min-width: 0; margin-left: auto; }
  .topbar h1 { font-size: 22px; }
  .page { padding: 8px 14px calc(110px + env(safe-area-inset-bottom)); }

  .tabbar {
    display: flex; align-items: center; justify-content: space-around;
    position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 70; height: 68px; padding: 0 8px; border-radius: var(--pill);
    background: var(--accent); box-shadow: 0 14px 34px rgba(51,36,63,.3);
  }
  .tabbar { transition: transform .22s cubic-bezier(.3,.8,.3,1); }
  body.nav-open .tabbar { transform: translateY(160%); }
  .tab {
    width: 48px; height: 48px; border-radius: 50%;
    display: grid; place-items: center; color: var(--accent-muted);
    text-decoration: none; border: 0; background: transparent; cursor: pointer;
  }
  .tab svg { width: 21px; height: 21px; stroke-width: 2.1; }
  .tab.active { background: var(--accent-2); color: var(--highlight); }
  .tab-plus { width: 56px; height: 56px; background: var(--highlight); color: var(--on-highlight); }
  .tab-plus svg { width: 23px; height: 23px; stroke-width: 2.6; }
  .tab-txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

  .table-wrap { display: none; }
  .mobile-list { display: flex; }
  /* Listes : chaque élément devient une carte blanche posée sur le fond. */
  .card.card-mobile-flush { padding: 0; background: transparent; overflow: visible; }
  .card-mobile-flush .card-head { padding: 4px 4px 10px; }
  .card-mobile-flush .mobile-list { padding: 0; gap: 10px; }
  .card-mobile-flush .m-card { background: var(--surface); }
  .card-mobile-flush .m-card:active { background: var(--surface-2); }

  .card { padding: 18px; border-radius: 24px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 15px; }
  .stat-val { font-size: 24px; }
  .form-grid, .form-grid.col3 { grid-template-columns: 1fr; }
  .topbar-actions .btn span.lbl { display: none; }
  .topbar-actions .btn { padding: 0 13px; }
  .btn { height: 44px; }
  .toasts { left: 14px; right: 14px; bottom: calc(92px + env(safe-area-inset-bottom)); align-items: stretch; }
  .toast { max-width: none; }
}

@media (max-width: 460px) {
  .topbar-sub { font-size: 12.5px; }
  .filters { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
}

/* ── Impression : facture A4 ─────────────────────────────────────────────── */

/* ── Écrans de connexion / configuration ─────────────────────────────────── */
.auth-body { background: var(--bg); }
.auth-shell {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}
.auth-card {
  width: min(400px, 100%);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
  padding: 34px 30px; border: 0;
}
.auth-shell-large { justify-content: flex-start; padding-top: 40px; }
.auth-card-large { width: min(720px, 100%); }
.auth-logo { width: 150px; height: auto; margin: 0 auto 18px; display: block; }
:root[data-theme="dark"] .auth-logo { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .auth-logo { filter: invert(1); } }
.auth-card h1 {
  font-size: 24px; font-weight: 600; letter-spacing: -.02em;
  text-align: center; line-height: 1.3;
}
.auth-card-large h1 { text-align: left; font-size: 23px; }
.auth-sub {
  font-size: 14px; color: var(--text-2); text-align: center;
  margin: 6px 0 24px; line-height: 1.5;
}
.auth-card-large .auth-sub { text-align: left; }
.auth-erreur {
  background: var(--red-soft); border: 1px solid var(--red-border); color: var(--red);
  border-radius: 10px; padding: 11px 14px; font-size: 13.5px; font-weight: 600;
  margin-bottom: 18px;
}
.auth-pied { margin-top: 22px; font-size: 12.5px; color: var(--text-3); text-align: center; }
.auth-note {
  margin-top: 24px; padding: 14px 16px; border-radius: 10px;
  background: var(--amber-soft); border: 1px solid var(--amber-border);
  font-size: 13px; line-height: 1.6; color: var(--text);
}
.code-input {
  font-family: var(--mono); font-size: 22px !important; letter-spacing: .35em;
  text-align: center; font-weight: 700; padding: 12px !important;
}
.code-input::placeholder { letter-spacing: .35em; color: var(--text-3); opacity: .5; }

.etapes { list-style: none; display: flex; flex-direction: column; gap: 28px; }
.etapes > li { display: flex; gap: 16px; }
.etape-num {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 800; font-size: 14px; border: 1px solid var(--accent-border);
}
.etape-corps { flex: 1; min-width: 0; }
.etape-corps h2 { font-size: 15.5px; font-weight: 720; margin-bottom: 6px; }

.qr-zone {
  display: flex; gap: 20px; align-items: center; flex-wrap: wrap;
  margin-top: 16px; padding: 18px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.qr {
  background: #fff; padding: 10px; border-radius: 10px; line-height: 0;
  box-shadow: var(--shadow-1); flex-shrink: 0;
}
/* hauteur automatique : le viewBox porte le ratio, jamais de rognage */
.qr svg { width: 240px; height: auto; max-width: 100%; display: block; }
.qr-manuel { flex: 1; min-width: 190px; }
.secret {
  display: block; font-family: var(--mono); font-size: 13.5px; font-weight: 700;
  word-break: break-all; line-height: 1.6; user-select: all;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; color: var(--accent);
}

@media (max-width: 560px) {
  .auth-card { padding: 26px 20px; }
  .qr-zone { justify-content: center; }
  .etapes > li { gap: 12px; }
}

/* Tableau d'un devis / d'une facture : défile dans sa boîte sur un petit écran. */
.doc-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media print { .doc-table { overflow: visible; } }

/* ── Facture ─────────────────────────────────────────────────────────────── */
.invoice { background: var(--surface); }
.inv-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; padding-bottom: 22px; border-bottom: 2px solid var(--text); margin-bottom: 24px; }
.inv-head > div:first-child { flex: 1 1 auto; min-width: 0; }
.inv-logo { width: 230px; height: auto; margin-bottom: 10px; }
:root[data-theme="dark"] .invoice .inv-logo { filter: invert(1); }
@media print { .inv-logo { width: 190px; filter: none !important; margin-bottom: 6px; } }
.inv-brand { font-family: var(--display); font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
.inv-meta { text-align: right; flex: 0 0 auto; }
.inv-word { font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--text-2); }
.inv-num { font-family: var(--display); font-size: 22px; font-weight: 650; letter-spacing: -.02em; color: var(--accent); }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 26px; }
.inv-block-title { font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); margin-bottom: 7px; }
.inv-party { font-size: 13.5px; line-height: 1.65; }
.inv-party .who { font-weight: 750; font-size: 15px; }
.inv-totals { display: flex; justify-content: flex-end; margin: 22px 0; }
.inv-totals-inner { min-width: 260px; }
.inv-tot-row { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.inv-tot-row.grand { border-bottom: none; border-top: 2px solid var(--text); margin-top: 4px; padding-top: 12px; font-size: 19px; font-weight: 850; }
.inv-tot-row.grand span:last-child { color: var(--accent); }
.inv-objet { margin-bottom: 22px; }
.inv-notes { margin-bottom: 18px; }
.inv-legal { font-size: 11.5px; color: var(--text-2); border-top: 1px solid var(--border); padding-top: 14px; line-height: 1.6; }

/* Zone de signature du devis : sans elle, le document reste une estimation. */
.devis-accord {
  display: flex; gap: 24px; justify-content: space-between; align-items: flex-start;
  padding: 16px 0 20px; margin-bottom: 4px;
  border-top: 1px solid var(--border);
  page-break-inside: avoid;
}
.devis-cadre {
  width: 240px; height: 90px; flex-shrink: 0;
  border: 1px dashed var(--border-strong); border-radius: 8px;
}
@media (max-width: 560px) {
  .devis-accord { flex-direction: column; }
  .devis-cadre { width: 100%; }
}
.inv-stamp {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 13px; border-radius: 6px;
  font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  border: 2px solid var(--accent); color: var(--accent);
}
@media (max-width: 700px) { .inv-parties { grid-template-columns: 1fr; } }

/* ── Références de pièces (devis mobile) ─────────────────────────────────
   Une ligne par référence fournisseur, triées par prix : le nom exact de la
   pièce est ce qui évite de se tromper au moment de commander. */
.variantes { display: flex; flex-direction: column; gap: 6px; max-height: 380px; overflow-y: auto; padding-right: 2px; }
.variante {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); transition: border-color .12s, background .12s;
}
.variante:hover { border-color: var(--accent-border); }
.variante { border-radius: 14px; }
.variante.on { border-color: var(--accent); background: var(--accent-soft); }
.variante input { margin: 0; flex-shrink: 0; }
.variante-nom { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.35; }
.variante-prix { font-variant-numeric: tabular-nums; white-space: nowrap; }
.variante-autre .variante-nom { color: var(--text-2); font-style: italic; }
.badge-gamme-eco        { background: var(--surface-3); color: var(--text-2); }
.badge-gamme-qualite    { background: var(--blue-soft); color: var(--blue); border-color: var(--blue-border); }
.badge-gamme-origine    { background: var(--green-soft); color: var(--green); }
.badge-gamme-accessoire { background: var(--violet-soft); color: var(--violet); border-color: var(--violet-border); }

/* ── Sélecteur d'appareil ────────────────────────────────────────────────── */
.appareil-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; cursor: pointer; font: inherit; font-size: 14.5px;
  padding: 10px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
.appareil-trigger:hover { border-color: var(--accent); }
.appareil-trigger:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.appareil-trigger .vide { color: var(--text-3); }
.appareil-trigger .origine { display: block; font-size: 12px; font-weight: 400; color: var(--text-3); margin-top: 2px; }
.appareil-trigger .chev { color: var(--text-3); font-size: 12px; }

.picker { width: min(780px, 100%); max-height: min(80vh, 720px); padding: 0; display: flex; flex-direction: column; }
.picker-head { padding: 16px 18px 13px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 11px; }
.picker-head .rangee { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.picker-head h3 { margin: 0; }
.picker-marques { display: flex; gap: 6px; flex-wrap: wrap; }
.picker-onglet {
  cursor: pointer; font: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
  transition: background .12s, color .12s, border-color .12s;
}
.picker-onglet:hover { color: var(--text); border-color: var(--border-strong); }
.picker-onglet.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.picker-body { overflow-y: auto; padding: 0 18px 16px; }
.picker-fam {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  padding: 15px 0 8px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; color: var(--text-3);
}
.picker-fam span { opacity: .6; font-weight: 600; }
.picker-grid { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
.picker-item {
  position: relative; text-align: left; cursor: pointer; font: inherit; font-size: 13.5px;
  padding: 9px 22px 9px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  transition: background .12s, border-color .12s, transform .06s;
}
.picker-item:hover { background: var(--accent-soft); border-color: var(--accent-border); }
.picker-item:active { transform: scale(.98); }
.picker-item.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pastille { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.picker-item .pastille { position: absolute; top: 9px; right: 9px; }
.picker-item.on .pastille { background: var(--highlight); }
.picker-vide { padding: 34px 4px; text-align: center; color: var(--text-2); font-size: 14px; }
.picker-pied {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 18px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-3);
}

@media (max-width: 640px) {
  .picker { max-height: 88vh; }
  .picker-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
}

/* ── Impression ────────────────────────────────────────────────────────────
   Ce bloc doit rester en fin de fichier : a specificite egale, c'est
   l'ordre qui tranche, et les regles .inv-* definies plus haut
   annuleraient sinon les reserrages du papier. */
/* Tableau de bord : six tuiles, jamais une seule orpheline sur sa ligne */
@media (min-width: 761px) { .stats-6 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1240px) { .stats-6 { grid-template-columns: repeat(6, 1fr); } }

/* Propositions sous un champ (désignation d'un achat) */
.propositions-hote { position: relative; }
.propositions { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  max-height: 320px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 10px; box-shadow: var(--shadow-3); padding: 4px; }
.proposition { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.proposition:hover, .proposition.actif { background: var(--surface-2); }
.proposition-nom { font-size: 14px; font-weight: 600; color: var(--text); }
.proposition-detail { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.proposition-source { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: var(--surface-3); color: var(--text-2); }
.proposition-source.src-historique { background: var(--green-soft); color: var(--green); }
.proposition-source.src-catalogue { background: var(--blue-soft); color: var(--blue); }
.proposition-source.src-filament { background: var(--violet-soft); color: var(--violet); }

/* Mode de saisie des prix d'un achat */
.mode-prix { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.mode-prix-lbl { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.mode-prix .hint { flex-basis: 100%; }
.achat-tva { font-weight: 500 !important; color: var(--text-3) !important; margin-bottom: 2px; }
.achat-tva[hidden] { display: none !important; }
/* Lignes d'un achat */
.achat-ligne { border: 0; border-radius: 18px; padding: 12px; margin-bottom: 10px; background: var(--surface-2); }
.achat-ligne-haut { display: flex; gap: 8px; align-items: flex-start; }
.achat-ligne-haut .propositions-hote { flex: 1; min-width: 0; }
.achat-ligne-haut .ligne-designation { font-weight: 600; }
.achat-ligne-champs { display: grid; grid-template-columns: 80px 130px 1fr 1.3fr; gap: 10px; margin-top: 10px; }
.achat-ligne-pied { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--text-3); min-height: 16px; }
.achat-ligne-ref { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.achat-ligne-total { font-weight: 700; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.achat-totaux { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.achat-totaux .form-group { width: 160px; }
.achat-total-general { text-align: right; }
.achat-total-general span { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.achat-total-general b { font-size: 24px; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) {
  .achat-ligne-champs { grid-template-columns: 70px 1fr; }
  .achat-ligne-champs .lc-cat, .achat-ligne-champs .lc-cmd { grid-column: 1 / -1; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ── Prix fournisseur ───────────────────────────────────────────────────── */
.import-fournisseur { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.import-fournisseur input[type=file] { flex: 1; min-width: 200px; font-size: 13.5px; }
.rapport-chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; }
.rapport-chiffres div { background: var(--surface-2); border: 0; border-radius: 16px; padding: 8px 10px; }
.rapport-chiffres b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.rapport-chiffres span { font-size: 12px; color: var(--text-3); }
.ecart-hausse, .ecart-hausse b { color: var(--red); }
.ecart-baisse, .ecart-baisse b { color: var(--green); }
.rapport-titre { font-size: 14px; font-weight: 700; margin: 20px 0 4px; }
.rapport-details { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.rapport-details summary { cursor: pointer; font-weight: 600; font-size: 13.5px; }
.rapport-details .table-wrap { margin-top: 8px; }
.rapport-liste { margin: 8px 0 0 18px; font-size: 13px; color: var(--text-2); }

/* ── Import de facture fournisseur ─────────────────────────────────────── */
.import-facture { display: flex; gap: 14px 20px; align-items: center; flex-wrap: wrap; border-style: dashed; }
.import-facture-texte { flex: 1 1 320px; display: flex; flex-direction: column; gap: 4px; }
.import-facture-texte b { display: inline-flex; align-items: center; gap: 6px; }
.import-facture-texte b svg { width: 16px; height: 16px; }
.import-facture-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.import-facture-form input[type=file] { font-size: 13px; max-width: 260px; }
.import-resultat.ok { border-color: var(--green-border); background: var(--green-soft); }
.import-resultat.ok > b { color: var(--green); }
.import-resultat.alerte { border-color: var(--amber-border); background: var(--amber-soft); }
.import-resultat.alerte > b { color: var(--amber); }
.import-resultat > b { display: inline-flex; align-items: center; gap: 6px; }
.import-resultat > b svg, .import-doublon svg { width: 16px; height: 16px; }
.import-doublon { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--red); }

/* ── Stock ─────────────────────────────────────────────────────────────── */
.stock-qte { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; padding: 2px 8px;
  border-radius: 99px; font-weight: 750; font-variant-numeric: tabular-nums; background: var(--green-soft); color: var(--green); }
.stock-qte.stock-bas { background: var(--amber-soft); color: var(--amber); }
.stock-qte.stock-vide { background: var(--red-soft); color: var(--red); }
.stock-gros { font-family: var(--display); font-size: 44px; font-weight: 600; letter-spacing: -.03em; color: var(--green); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stock-gros.stock-bas { color: var(--amber); }
.stock-gros.stock-vide { color: var(--red); }
.stock-ajuster .form-group { gap: 8px; }
.stock-ajuster-ligne { display: flex; gap: 8px; }
.stock-ajuster-ligne input { flex: 1; min-width: 0; }
.stock-mvt { min-width: 44px; text-align: center; font-weight: 750; font-variant-numeric: tabular-nums; border-radius: 7px; padding: 3px 6px; font-size: 13px; }
.stock-mvt.entree { background: var(--green-soft); color: var(--green); }
.stock-mvt.sortie { background: var(--surface-3); color: var(--text-2); }
.stock-prendre { display: flex; gap: 8px; }
.stock-prendre select { flex: 1; min-width: 0; }
.stock-prendre input { width: 64px; flex-shrink: 0; }
.lc-stock { display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap; margin: 10px 0 0; font-weight: 600; font-size: 13px; }
.lc-stock .check { margin: 0; }
.lc-stock .hint { font-weight: 400; }
.lc-lot { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 500; color: var(--text-2); }
.lc-lot[hidden] { display: none; }
.lc-lot input[type=number] { width: 70px; padding: 5px 8px; }

/* ── Achats ──────────────────────────────────────────────────────────────── */
.badge-achat-a_recevoir { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-border); }
.badge-achat-recu { background: var(--green-soft); color: var(--green); }
.badge-bouton { cursor: pointer; font: inherit; font-size: 12px; font-weight: 700; }
.badge-bouton:hover { border-color: var(--amber); }
.badge-bouton:hover::after { content: " → reçu"; }
.achats-filtres select { width: auto; min-width: 0; flex: 0 1 220px; }
.achats-total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13.5px; color: var(--text-2); }
.achats-total b { font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums; }
.cat-barre { display: block; text-decoration: none; color: inherit; padding: 7px 0; }
.cat-barre-haut { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.cat-barre-haut b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat-barre-piste { display: block; height: 8px; margin-top: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.cat-barre-piste span { display: block; height: 100%; border-radius: 99px; background: var(--coral); }
.cat-barre:hover .cat-barre-haut span { color: var(--text); text-decoration: underline; }
/* Choix exclusif en boutons (statut d'un achat) */
.seg { display: inline-flex; gap: 4px; padding: 5px; border-radius: 999px; background: var(--surface-2); border: 0; }
.seg-opt { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span { display: inline-flex; align-items: center; gap: 6px; padding: 7px 15px; border-radius: 999px; }
.seg-opt span svg { width: 15px; height: 15px; }
.seg-opt input:checked + span { background: var(--accent); color: var(--on-accent); }
.seg-opt input:focus-visible + span { box-shadow: var(--ring); }
@media (max-width: 720px) {
  .achats-filtres select { flex: 1 1 140px; }
}

@media print {
  @page { size: A4 portrait; margin: 14mm; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  /* Les trois selecteurs sont necessaires : le theme sombre est declare en
     :root:not([data-theme="light"]), plus specifique qu'un simple :root. Sans
     eux, imprimer depuis un navigateur en mode sombre sort une page noire, que
     print-color-adjust: exact envoie telle quelle sur le papier. */
  :root,
  :root[data-theme="dark"],
  :root:not([data-theme="light"]) {
    --bg: #fff; --surface: #fff; --surface-2: #f6f5f2; --surface-3: #eee;
    --border: #d8d5cc; --border-strong: #b9b5a9;
    --text: #111; --text-2: #555; --text-3: #777;
    --accent: #33243F; --accent-soft: #EFE9F3; --accent-border: #D7CBE0;
  }
  body { background: #fff !important; font-size: 12px; }
  .sidebar, .topbar, .sb-overlay, .tabbar, .no-print, .toasts, .modal-back { display: none !important; }
  .shell { display: block; }
  .page { padding: 0 !important; max-width: 100% !important; }
  .card, .invoice { box-shadow: none !important; border: none !important; padding: 0 !important; }
  .grid-side, .grid-side-rev { display: block !important; }
  thead th { background: #f6f5f2 !important; }
  a { text-decoration: none !important; color: inherit !important; }

  /* ── Devis et facture : tenir sur une seule A4 ─────────────────────────
     Sans ces reserrages le document deborde d'une cinquantaine de
     millimetres, et le client recoit une seconde feuille qui ne porte que
     la signature. Les valeurs d'ecran restent confortables : seul le papier
     est comprime. */
  .inv-head { padding-bottom: 10px; margin-bottom: 12px; }
  .inv-brand { font-size: 17px; }
  .inv-num { font-size: 17px; }
  .inv-word { font-size: 10px; }
  .inv-block-title { font-size: 9px; margin-bottom: 3px; }
  .inv-party { font-size: 10.5px; line-height: 1.4; }
  .inv-party .who { font-size: 12px; }
  .inv-head .mt-8, .inv-meta .small { margin-top: 4px !important; font-size: 10px; }

  /* La largeur de la fenetre d'impression n'a rien a voir avec celle du
     papier : depuis un telephone elle passerait sous le seuil mobile et
     empilerait les colonnes, ajoutant trente millimetres. */
  .inv-parties { grid-template-columns: 1fr 1fr !important; gap: 14px; margin-bottom: 12px; }

  .inv-objet { margin-bottom: 10px; }
  .inv-objet > div:not(.inv-block-title) { font-size: 11.5px !important; line-height: 1.45 !important; }
  .inv-notes { margin-bottom: 10px; }
  .inv-notes ul { font-size: 10px !important; line-height: 1.45 !important; }

  table { font-size: 11px; page-break-inside: auto; }
  thead { display: table-header-group; }
  tr { page-break-inside: avoid; }
  thead th { padding: 5px 8px; font-size: 9px; }
  tbody td { padding: 5px 8px; }
  tbody td .small { font-size: 9.5px; }

  .inv-totals { margin: 10px 0; }
  .inv-totals-inner { min-width: 210px; }
  .inv-tot-row { padding: 3px 0; font-size: 11.5px; }
  .inv-tot-row.grand { font-size: 15px; padding-top: 6px; margin-top: 2px; }

  .devis-accord { padding: 8px 0 8px; margin-bottom: 0; }
  .devis-cadre { width: 190px; height: 46px; }

  .inv-legal { font-size: 9px; line-height: 1.4; padding-top: 8px; }
}

/* ── Synchro fournisseur ─────────────────────────────────────────────────── */
.synchro-encours { font-size: 13.5px; padding: 12px 14px; border-radius: 16px; background: var(--accent-soft); }
.synchro-barre { height: 6px; border-radius: 3px; background: var(--surface); margin-top: 8px; overflow: hidden; }
.synchro-barre span { display: block; height: 100%; background: var(--accent); transition: width .3s; }

/* ── Tableau de bord ─────────────────────────────────────────────────────── */
.db-ligne { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 18px; align-items: stretch; }
.db-ligne > .card { margin: 0; }
.db-colonne { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.db-colonne > .card { margin: 0; }
.db-titre { font-family: var(--display); font-size: 19px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; margin: 0; }
.db-entete { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

/* Le mois */
.db-mois { flex: 2 1 520px; min-width: 0; min-height: 330px; padding: 28px; position: relative; overflow: hidden;
  display: flex; flex-wrap: wrap; gap: 18px; }
.db-mois-texte { flex: 1 1 220px; display: flex; flex-direction: column; justify-content: space-between; gap: 20px; position: relative; z-index: 1; }
.db-mois .db-titre { font-size: 23px; }
.db-sur { font-size: 13px; font-weight: 600; color: var(--sand-text); }
.db-gros { font-family: var(--display); font-size: 46px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.db-gros-2 { font-family: var(--display); font-size: 28px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.db-pastille { display: inline-block; margin-top: 8px; padding: 5px 12px; border-radius: var(--pill); background: var(--surface); font-size: 12.5px; font-weight: 800; }
.db-legende { list-style: none; display: flex; flex-direction: column; gap: 9px; font-size: 13.5px; font-weight: 700; }
.db-legende li { display: flex; align-items: center; gap: 10px; }
.db-trait { width: 28px; height: 8px; border-radius: 4px; }
.b-ambre { background: var(--highlight); color: var(--on-highlight); }
.b-corail { background: var(--coral); color: var(--on-coral); }
.b-prune { background: var(--accent); color: var(--on-accent); }
.b-sable { background: var(--surface); color: var(--text); }
.bulles { flex: 1 1 300px; position: relative; min-height: 270px; }
.bulle { width: calc(var(--d) * 1px); height: calc(var(--d) * 1px); position: absolute; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; line-height: 1.15; padding: 8px; }
.bulle b { font-family: var(--display); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bulle span { font-size: 11.5px; font-weight: 750; }
.bulle.b-ambre { box-shadow: 0 0 0 14px color-mix(in srgb, var(--highlight) 30%, transparent); }
.bulle.b-corail { box-shadow: 0 0 0 11px color-mix(in srgb, var(--coral) 26%, transparent); }
/* Quatre places qui se chevauchent peu, quelle que soit la taille. */
.bulle-1 { right: 4%; top: 4%; z-index: 1; }
.bulle-2 { left: 2%; bottom: 2%; z-index: 2; }
.bulle-3 { left: 6%; top: 0; z-index: 3; }
.bulle-4 { right: 10%; bottom: 0; z-index: 3; }
.db-vide { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-weight: 600; color: var(--sand-text); padding: 20px; }
.db-fleche { position: absolute; top: 20px; right: 20px; width: 42px; height: 42px; border-radius: 50%; z-index: 4;
  background: var(--accent); color: var(--highlight); display: grid; place-items: center; }
.db-fleche svg { width: 18px; height: 18px; }

/* Planning */
.db-planning { flex: 1 1 330px; min-width: 0; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.db-planning .db-entete { margin-bottom: 0; align-items: center; }
.db-mois-nom { font-size: 13.5px; font-weight: 800; color: var(--accent-muted); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; text-align: center; }
.cal-tete { font-size: 11.5px; font-weight: 800; color: var(--accent-muted); padding-bottom: 2px; }
.cal-j { width: 34px; height: 34px; justify-self: center; position: relative; display: grid; place-items: center; border-radius: 50%;
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-j.rdv { box-shadow: inset 0 0 0 2px var(--highlight); }
.cal-j.ech::after { content: ""; position: absolute; bottom: 2px; left: 50%; width: 6px; height: 6px; margin-left: -3px;
  border-radius: 50%; background: var(--coral); }
.cal-j.auj { background: var(--highlight); color: var(--on-highlight); box-shadow: none; }
.cal-j.auj.ech::after { background: var(--accent); }
.cal-legende { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--accent-muted); }
.cal-legende span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legende i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.l-auj { background: var(--highlight); }
.l-rdv { box-shadow: inset 0 0 0 2px var(--highlight); }
.l-ech { background: var(--coral); width: 7px !important; height: 7px !important; }
.db-ajout { margin-top: auto; align-self: flex-start; }
.db-pret-code { text-align: center; min-width: 46px; line-height: 1.25; }
.db-pret { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 18px; background: var(--accent-2);
  text-decoration: none; color: inherit; }
.db-pret:hover { filter: brightness(1.08); }
.db-pret-code { font-family: var(--display); font-weight: 600; font-size: 13px; color: var(--highlight); white-space: nowrap; }
.db-pret-txt { flex: 1; min-width: 0; font-size: 13px; line-height: 1.35; }
.db-pret-txt span { color: var(--accent-muted); }
.db-pret-chev { width: 16px; height: 16px; transform: rotate(180deg); flex-shrink: 0; }
.db-pret-vide { margin-top: auto; font-size: 13px; color: var(--accent-muted); padding: 12px 14px; border-radius: 18px; background: var(--accent-2); }

/* Six mois */
.db-graphe { flex: 2 1 520px; min-width: 0; display: flex; flex-direction: column; container-type: inline-size; }
/* 12 mois quand la carte est large, 6 sinon : les barres gardent un écart serré. */
.db-graphe .vue-6 { display: none; }
@container (max-width: 640px) {
  .db-graphe .vue-12, .db-graphe .chart-col.mois-ancien { display: none; }
  .db-graphe .vue-6 { display: inherit; }
  .db-graphe span.vue-6 { display: inline; }
  .db-graphe .chart-col:nth-child(7) .chart-tip { --dx: -16%; }
  .db-graphe .chart-col:nth-child(7) .chart-tip::after { left: 16%; }
}
.db-chiffres { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.db-chiffres b { display: block; font-family: var(--display); font-size: 18px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
/* Graphique 6 mois : axe des montants + grille pointillée, il remplit la carte. */
.graphe { flex: 1; display: flex; gap: 12px; min-height: 230px; margin-top: 18px; }
.graphe-axe { display: flex; flex-direction: column; justify-content: space-between; padding-bottom: 28px;
  font-size: 11.5px; font-weight: 700; color: var(--text-3); text-align: right; min-width: 42px; }
.graphe-axe span { line-height: 1; transform: translateY(-50%); }
.graphe-axe span:last-child { transform: translateY(50%); }
.graphe-zone { flex: 1; position: relative; display: flex; }
.graphe-grille { position: absolute; left: 0; right: 0; top: 0; bottom: 28px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.graphe-grille i { display: block; border-top: 1.5px dashed var(--border); }
.graphe-grille i:last-child { border-top: 1.5px solid var(--border-strong); }
.graphe .chart { flex: 1; height: auto; margin: 0; position: relative; gap: 10px; }
.graphe .chart-col { gap: 10px; }
.graphe .chart-x { height: 18px; line-height: 18px; }

/* Objectif */
.db-objectif .db-entete { margin-bottom: 0; align-items: baseline; }
.db-pct { font-family: var(--display); font-size: 26px; font-weight: 600; }
.obj-piste { position: relative; height: 14px; border-radius: 7px; background: var(--surface-3); margin-top: 38px; }
.obj-barre { height: 14px; border-radius: 7px; background: var(--accent); }
.obj-bulle { position: absolute; top: -34px; transform: translateX(-50%); padding: 4px 10px; border-radius: 9px;
  background: var(--accent); color: var(--on-accent); font-size: 11.5px; font-weight: 800; white-space: nowrap; }
.obj-bornes { display: flex; justify-content: space-between; margin-top: 9px; font-size: 12px; font-weight: 700; color: var(--text-3); }

.db-encaisser { display: flex; align-items: center; justify-content: space-between; gap: 14px; text-decoration: none; color: inherit;
  transition: transform .12s, box-shadow .13s; }
.db-encaisser:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.db-encaisser .db-titre { display: block; font-size: 17px; }
.db-encaisser.a-relancer .db-gros-2 { color: var(--red); }

/* Commandes récentes */
.db-recentes { flex: 2 1 520px; min-width: 0; }
.db-liste { display: flex; flex-direction: column; gap: 8px; padding: 4px 16px 18px; }
.db-cmd { display: flex; align-items: center; gap: 14px; padding: 11px 14px; border-radius: 20px; background: var(--surface-2);
  text-decoration: none; color: inherit; transition: background .12s; flex-wrap: wrap; }
.db-cmd:hover { background: var(--surface-3); }
.db-cmd-type { width: 42px; height: 42px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--display); font-weight: 600; font-size: 12.5px; background: var(--sand); color: var(--text); }
.db-cmd-type.t-mobile { background: var(--highlight); color: var(--on-highlight); }
.db-cmd-type.t-3d { background: var(--coral); color: var(--on-coral); }
.db-cmd-type.t-informatique { background: var(--accent); color: var(--on-accent); }
.db-cmd-corps { flex: 1 1 200px; min-width: 0; }
.db-cmd-titre { display: block; font-weight: 750; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-cmd-sous { display: block; font-size: 12.5px; color: var(--text-3); }
.db-cmd-montant { font-family: var(--display); font-weight: 600; font-size: 16px; min-width: 76px; text-align: right; font-variant-numeric: tabular-nums; }

.db-tuiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.db-tuile { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: 22px; background: var(--surface); text-decoration: none; color: inherit; }
.db-tuile:hover { box-shadow: var(--shadow-2); }
.db-tuile b { display: block; font-family: var(--display); font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.db-tuile span span { font-size: 12px; color: var(--text-3); }
.db-tuile-ico { width: 40px; height: 40px; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; flex-shrink: 0; }
.db-tuile-ico svg { width: 18px; height: 18px; }

@media (max-width: 900px) {
  .db-ligne { gap: 12px; margin-bottom: 12px; }
  .db-colonne { gap: 12px; }
  .db-mois { min-height: 0; padding: 22px; }
  .db-gros { font-size: 38px; }
  /* Petit écran : les bulles s'alignent au lieu de se superposer. */
  .bulles { min-height: 0; flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 16px; padding: 10px 0 4px; }
  .bulle { position: static; width: calc(var(--d) * .62px); height: calc(var(--d) * .62px); }
  .bulle b { font-size: 16px; }
  .bulle span { font-size: 10.5px; }
  .bulle.b-ambre, .bulle.b-corail { box-shadow: 0 0 0 7px color-mix(in srgb, currentColor 0%, transparent); }
  .db-vide { position: static; }
  .db-legende { flex-direction: row; flex-wrap: wrap; gap: 8px 16px; }
  .db-cmd-statut { order: 3; }
  .db-cmd-montant { margin-left: auto; }
  .db-liste { padding: 4px 10px 12px; }
  .graphe { min-height: 190px; }
  .graphe .chart { gap: 8px; }
  .graphe-axe { min-width: 34px; font-size: 10.5px; }
}

/* ── Devis : panneau d'estimation en carte prune ─────────────────────────── */
.devis-estimation {
  --text: var(--on-accent); --text-2: var(--accent-muted); --text-3: var(--accent-muted);
  --border: color-mix(in srgb, var(--on-accent) 14%, transparent); --border-strong: transparent;
  --surface-2: var(--accent-2); --surface: var(--accent-2); --total-couleur: var(--highlight);
  color: var(--text);
}
.devis-estimation .card-title { color: var(--on-accent); }
.devis-total { font-family: var(--display); font-size: 44px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; margin: 4px 0 16px; font-variant-numeric: tabular-nums; }
.devis-estimation select { background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23C9BCD3' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
.devis-estimation input[type="checkbox"] { accent-color: var(--highlight); }
.devis-estimation .rentabilite { --text-3: #5F5666; color: #221C27; }

/* ── Agenda ──────────────────────────────────────────────────────────────── */
.ag-ligne { display: flex; align-items: center; gap: 14px; padding: 10px 12px; margin: 0 -12px; border-radius: 18px; }
.ag-ligne + .ag-ligne { margin-top: 4px; }
.ag-ligne:hover { background: var(--surface-2); }
.ag-ligne:target { background: var(--highlight-soft); }
.ag-date { width: 52px; height: 52px; flex-shrink: 0; border-radius: 16px; background: var(--accent); color: var(--on-accent);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.ag-date b { font-family: var(--display); font-size: 20px; font-weight: 600; }
.ag-date span { font-size: 11px; font-weight: 700; color: var(--accent-muted); margin-top: 3px; }
.ag-ligne.retard .ag-date { background: var(--coral); color: var(--on-coral); }
.ag-ligne.retard .ag-date span { color: var(--on-coral); }
.ag-ligne.fait { opacity: .6; }
.ag-ligne.fait .ag-titre { text-decoration: line-through; }
.ag-corps { flex: 1; min-width: 0; }
.ag-titre { display: block; font-weight: 750; font-size: 14.5px; }
.ag-sous { display: block; font-size: 12.5px; color: var(--text-3); }
.ag-genre { font-weight: 800; }
.ag-genre.g-rdv { color: var(--amber); }
.ag-genre.g-echeance { color: #A3402C; }
.ag-genre.g-rappel { color: var(--blue); }
.ag-actions { display: flex; gap: 4px; flex-shrink: 0; }
.echeance-pastille { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--pill);
  background: var(--coral-soft); color: #A3402C; font-size: 12px; font-weight: 800; }
.echeance-pastille svg { width: 13px; height: 13px; }

/* ── Étapes du suivi de réparation ───────────────────────────────────────── */
.etapes-suivi { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.etape-suivi { display: inline-flex; align-items: center; gap: 9px; height: 42px; padding: 0 16px 0 6px;
  border-radius: var(--pill); border: 1.5px solid var(--border); background: var(--surface);
  font: inherit; font-size: 13.5px; font-weight: 700; color: var(--text-2); cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s; }
.etape-suivi:hover { border-color: var(--border-strong); color: var(--text); }
.etape-suivi .etape-num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); font-size: 12.5px; font-weight: 800; border: 0; color: inherit; }
.etape-suivi .etape-num svg { width: 15px; height: 15px; stroke-width: 2.6; }
.etape-suivi.faite { background: var(--green-soft); border-color: transparent; color: var(--green); }
.etape-suivi.faite .etape-num { background: var(--green); color: #fff; }
.etape-suivi.actuelle { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.etape-suivi.actuelle .etape-num { background: var(--highlight); color: var(--on-highlight); }
.etapes-fin { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.etape-suivi.fin-annule.actuelle { background: var(--red-soft); border-color: transparent; color: var(--red); }
.etape-suivi.fin-annule.actuelle .etape-num { background: var(--red); color: #fff; }

/* Date + heure côte à côte (estimation du suivi) */
.date-heure { display: flex; gap: 8px; }
.date-heure input[type="date"] { flex: 1 1 auto; min-width: 0; }
.date-heure input[type="time"] { flex: 0 0 120px; }

/* ── Bon de livraison ────────────────────────────────────────────────────── */
.bl-ligne { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) 80px 90px; gap: 8px; margin-top: 8px; }
.bl-ligne input:nth-child(3), .bl-ligne input:nth-child(4) { text-align: right; }
.bl-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 22px 0 6px; page-break-inside: avoid; }
.bl-signatures .devis-cadre { width: 100%; margin-top: 10px; }
@media (max-width: 700px) {
  .bl-ligne { grid-template-columns: 1fr 1fr; }
  .bl-ligne input:first-child, .bl-ligne input:nth-child(2) { grid-column: 1 / -1; }
  .bl-signatures { grid-template-columns: 1fr; }
}
@media print { .bl-signatures { grid-template-columns: 1fr 1fr !important; } .bl-signatures .devis-cadre { height: 60px; } }

/* ── Signature ───────────────────────────────────────────────────────────── */
.zone-signature { width: 100%; height: auto; aspect-ratio: 600 / 220; display: block; touch-action: none; cursor: crosshair;
  background: #fff; border: 2px dashed var(--border-strong); border-radius: var(--radius-sm); }
.signature-actuelle { background: #fff; border-radius: var(--radius-sm); padding: 12px; border: 1px solid var(--border); }
.signature-actuelle img { max-height: 90px; width: auto; }
.bl-signature-img { max-height: 70px; width: auto; margin: 8px auto 0; }
.apercu-signature { width: 100%; height: 130px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.envoi-mail textarea { min-height: 220px; }
