/* ============================================================================
   DEVIS VOCAL NC — Feuille de style
   Deux thèmes : « nuit » (atelier/soir) et « jour » (plein soleil, contraste max)
   Cibles tactiles ≥ 56 px : utilisable avec des gants.
   ========================================================================== */

:root {
  --accent:      #FF7A18;   /* orange chantier */
  --accent-2:    #17C3B2;   /* turquoise lagon */
  --ok:          #2ECC71;
  --warn:        #FFC145;
  --danger:      #FF5A5A;
  --r:           18px;
  --r-s:         12px;
  --safe-b:      env(safe-area-inset-bottom, 0px);
  --tab-h:       calc(74px + var(--safe-b));
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="nuit"] {
  --bg:        #0B0F14;
  --bg-2:      #0F151C;
  --surface:   #141C25;
  --surface-2: #1B2632;
  --line:      #26333F;
  --text:      #E9EFF6;
  --text-2:    #96A6B8;
  --shadow:    0 10px 30px rgba(0,0,0,.45);
  --glass:     rgba(20,28,37,.86);
}
[data-theme="jour"] {
  --bg:        #F2F5F8;
  --bg-2:      #E8EDF3;
  --surface:   #FFFFFF;
  --surface-2: #EEF3F8;
  --line:      #CBD6E2;
  --text:      #0C1620;
  --text-2:    #526074;
  --shadow:    0 8px 24px rgba(16,32,48,.12);
  --glass:     rgba(255,255,255,.9);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.45;
  padding-bottom: calc(var(--tab-h) + 12px);
  overscroll-behavior-y: none;
  transition: background .25s, color .25s;
}
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9;
      stroke-linecap: round; stroke-linejoin: round; }
button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select, textarea { font-family: inherit; font-size: 17px; }

/* ─────────────────────────── En-tête ─────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  background: var(--glass);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.tb-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.tb-mark {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 15px; letter-spacing: .5px;
  color: #10161D; background: linear-gradient(140deg, var(--accent), #FFB627);
  box-shadow: 0 4px 14px rgba(255,122,24,.35);
}
.tb-title > div { min-width: 0; }
.tb-title strong, .tb-title small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-title strong { font-size: 17px; line-height: 1.15; }
.tb-title small { color: var(--text-2); font-size: 12px; }
.tb-actions { display: flex; align-items: center; gap: 8px; }
.tb-icon, .tb-back {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2);
}
.tb-icon:active, .tb-back:active { transform: scale(.94); }
.pastille {
  font-size: 10px; font-weight: 700; letter-spacing: .6px;
  padding: 5px 8px; border-radius: 999px;
  color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-2) 35%, transparent);
}

/* ─────────────────────────── Écrans ─────────────────────────── */
.ecran { padding: 18px 16px 8px; max-width: 760px; margin: 0 auto; animation: fadeUp .28s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px);} to { opacity: 1; transform: none;} }

.bloc { margin: 22px 0; }
.bloc-tete { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.bloc-tete h2, .h2-seul { font-size: 15px; text-transform: uppercase; letter-spacing: 1.1px; color: var(--text-2); margin: 0 0 12px; font-weight: 700; }
.bloc-tete h2 { margin: 0; }
.aide { font-size: 14px; color: var(--text-2); margin: 6px 0 12px; }
.aide code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.lien { color: var(--accent); font-weight: 600; font-size: 14px; }
.lien-sec { display: block; margin: 16px auto 0; color: var(--text-2); text-decoration: underline; text-underline-offset: 4px; font-size: 15px; }
.badge { background: var(--surface-2); color: var(--text-2); border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 700; }
.version { text-align: center; color: var(--text-2); font-size: 12px; margin: 28px 0 0; }

/* ─────────────────────────── Accueil ─────────────────────────── */
.hero { text-align: center; padding: 14px 0 8px; }
.hero-hello { color: var(--text-2); font-size: 15px; margin: 0 0 4px; }
.hero-titre { font-size: 40px; line-height: 1.03; margin: 0 0 12px; letter-spacing: -1.4px; font-weight: 800; }
.hero-titre span { background: linear-gradient(100deg, var(--accent), #FFC145 60%, var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: var(--text-2); font-size: 15.5px; max-width: 430px; margin: 0 auto 26px; }

.mic-cta {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin: 0 auto; padding: 26px 34px 22px; border-radius: 26px;
  background: linear-gradient(150deg, var(--accent), #FF9E2C);
  color: #14181C; font-weight: 800; font-size: 18px; letter-spacing: -.2px;
  box-shadow: 0 14px 34px rgba(255,122,24,.34);
}
.mic-cta .mic-svg { width: 42px; height: 42px; stroke-width: 2; }
.mic-cta:active { transform: scale(.97); }
.mic-ring { position: absolute; inset: -6px; border-radius: 30px; border: 2px solid rgba(255,122,24,.35); animation: pulse 2.6s ease-out infinite; pointer-events: none; }
.mic-ring.r2 { animation-delay: 1.3s; }
@keyframes pulse { 0% { transform: scale(1); opacity: .8;} 100% { transform: scale(1.16); opacity: 0;} }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 28px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 12px; text-align: center; }
.stat b { display: block; font-size: 20px; font-weight: 800; letter-spacing: -.5px; }
.stat span { font-size: 11.5px; color: var(--text-2); text-transform: uppercase; letter-spacing: .6px; }
.stat.accent b { color: var(--accent); }
.stat.ok b { color: var(--ok); }

/* Rappel de sauvegarde */
.rappel {
  display: block; width: 100%; text-align: left; margin: 18px 0 0;
  border-radius: var(--r-s); padding: 12px 14px; font-size: 14px; line-height: 1.4;
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); color: var(--text);
}
.rappel.danger {
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  border-color: color-mix(in srgb, var(--warn) 50%, transparent);
}
.rappel.argent {
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
}
.rappel.large { padding: 15px 16px; }
.rappel b { display: block; font-size: 15px; margin-bottom: 2px; }
.rappel span { color: var(--text-2); font-size: 13.5px; }
.rappel.large:active { transform: scale(.99); }

.chips { display: flex; flex-wrap: wrap; gap: 9px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 11px 15px; font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 7px;
}
.chip:active { background: var(--surface-2); }

/* ─────────────────────────── Cartes devis ─────────────────────────── */
.cartes { display: flex; flex-direction: column; gap: 10px; }
.carte {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; box-shadow: var(--shadow);
}
.carte:active { transform: scale(.99); }
.carte-ic { width: 44px; height: 44px; border-radius: 13px; flex: none; display: grid; place-items: center; font-size: 20px; background: var(--surface-2); }
.carte-txt { flex: 1; min-width: 0; }
.carte-txt b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.carte-txt small { color: var(--text-2); font-size: 13px; }
.carte-mt { text-align: right; flex: none; }
.carte-mt b { display: block; font-size: 15.5px; font-weight: 800; letter-spacing: -.3px; }
.etiq { font-size: 10.5px; font-weight: 800; letter-spacing: .5px; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; }
.etiq.brouillon { background: color-mix(in srgb, var(--text-2) 18%, transparent); color: var(--text-2); }
.etiq.envoye    { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.etiq.accepte   { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.etiq.refuse    { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.etiq.facture   { background: color-mix(in srgb, var(--accent-2) 20%, transparent); color: var(--accent-2); }
.vide { text-align: center; color: var(--text-2); padding: 34px 16px; font-size: 15px; }

/* ─────────────────────────── Dictée ─────────────────────────── */
.dictee-wrap { padding-bottom: 96px; }
.dictee-etat { text-align: center; color: var(--text-2); font-size: 14px; letter-spacing: .4px; text-transform: uppercase; font-weight: 700; }
.dictee-etat.on { color: var(--accent); }
.scene-mic { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 18px 0 8px; }
.ondes { display: flex; align-items: flex-end; gap: 4px; height: 46px; opacity: .28; transition: opacity .3s; }
.ondes i { width: 5px; height: 8px; border-radius: 3px; background: var(--accent); transition: height .12s ease; }
.ondes.on { opacity: 1; }
.mic-big {
  width: 132px; height: 132px; border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #FF9E2C, var(--accent) 62%);
  color: #14181C; display: grid; place-items: center;
  box-shadow: 0 12px 40px rgba(255,122,24,.4), inset 0 -4px 12px rgba(0,0,0,.18);
  transition: transform .16s;
}
.mic-big .mic-svg { width: 54px; height: 54px; stroke-width: 2; }
.mic-big:active { transform: scale(.95); }
.mic-big.on { background: radial-gradient(circle at 35% 28%, #FF6B6B, #E03131 62%); animation: battement 1.5s ease-in-out infinite; }
@keyframes battement { 0%,100% { box-shadow: 0 12px 40px rgba(224,49,49,.45);} 50% { box-shadow: 0 12px 62px rgba(224,49,49,.8);} }
.chrono { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text-2); font-size: 15px; }

.transcript-box { margin-top: 16px; }
.mini-label { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-2); margin-bottom: 7px; font-weight: 700; }
.transcript {
  min-height: 108px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 15px; font-size: 17px; line-height: 1.5; outline: none;
}
.transcript:focus { border-color: var(--accent); }
.transcript:empty::before { content: attr(data-placeholder); color: var(--text-2); }
.transcript .interim { color: var(--text-2); font-style: italic; }
.transcript-actions { display: flex; gap: 8px; margin-top: 10px; }

.preview-lignes { display: flex; flex-direction: column; gap: 8px; }
.pv {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s);
  animation: fadeUp .22s ease both;
}
.pv-q { font-weight: 800; color: var(--accent); font-size: 15px; min-width: 62px; }
.pv-d { flex: 1; font-size: 15px; min-width: 0; }
.pv-d small { display: block; color: var(--text-2); font-size: 12px; }
.pv-p { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14.5px; }
.pv.doute { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }

/* ─────────────────────────── Formulaires ─────────────────────────── */
.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.champ { display: flex; flex-direction: column; gap: 6px; }
.champ-large { grid-column: 1 / -1; }
.champ span { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--text-2); font-weight: 700; }
.champ input, .champ select, .champ textarea {
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--r-s); padding: 14px 13px; width: 100%; outline: none;
  min-height: 52px; transition: border-color .15s;
}
.champ textarea { min-height: 74px; resize: vertical; line-height: 1.45; }
.champ input:focus, .champ select:focus, .champ textarea:focus { border-color: var(--accent); }
.recherche input, .recherche-modal {
  width: 100%; background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--r); padding: 15px 16px; outline: none; min-height: 54px;
}
.recherche { margin-bottom: 12px; }

.switch { display: flex; align-items: center; gap: 12px; padding: 12px 0; cursor: pointer; }
.switch input { display: none; }
.switch-piste { width: 54px; height: 32px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); position: relative; flex: none; transition: background .2s; }
.switch-piste i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--text-2); transition: transform .2s, background .2s; }
.switch input:checked + .switch-piste { background: color-mix(in srgb, var(--ok) 30%, transparent); border-color: var(--ok); }
.switch input:checked + .switch-piste i { transform: translateX(22px); background: var(--ok); }
.switch-txt { font-size: 16px; font-weight: 600; }

/* ─────────────────────────── Éditeur de devis ─────────────────────────── */
.devis-tete { margin-bottom: 6px; }
.devis-num { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.devis-num span { font-weight: 800; font-size: 19px; letter-spacing: -.4px; }
.statut-select { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 9px 14px; font-size: 14px; font-weight: 700; outline: none; }

.lignes { display: flex; flex-direction: column; gap: 10px; }
.ligne {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px 13px 11px; box-shadow: var(--shadow);
}
.ligne.doute { border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.ligne-h { display: flex; gap: 10px; align-items: flex-start; }
.ligne-des {
  flex: 1; background: transparent; border: 0; color: var(--text); font-size: 16px;
  font-weight: 600; padding: 4px 0; outline: none; resize: none; line-height: 1.35; min-height: 24px;
}
.ligne-suppr { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--text-2); background: var(--surface-2); flex: none; }
.ligne-suppr svg { width: 17px; height: 17px; }
.ligne-g { display: grid; grid-template-columns: 74px 62px 1fr auto; gap: 8px; align-items: end; margin-top: 10px; }
.mini { display: flex; flex-direction: column; gap: 4px; }
.mini label { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-2); font-weight: 700; }
.mini input, .mini select {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 8px; width: 100%; outline: none; min-height: 46px;
  font-variant-numeric: tabular-nums;
}
.mini input:focus, .mini select:focus { border-color: var(--accent); }
.ligne-total { text-align: right; font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; padding-bottom: 12px; white-space: nowrap; }
.ligne-dicte { font-size: 12px; color: var(--text-2); font-style: italic; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.ligne-dicte b { color: var(--warn); font-style: normal; }
/* « Ajouter à mes tarifs » : cible tactile confortable, pas un lien perdu */
.ligne-dicte .lien { font-style: normal; display: inline-block; margin-top: 6px; padding: 8px 0; line-height: 1.35; text-align: left; }

.ajout-rapide { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin-bottom: 10px; }
.photo-item { position: relative; aspect-ratio: 1; border-radius: var(--r-s); overflow: hidden; border: 1px solid var(--line); }
.photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; display: grid; place-items: center; font-size: 15px; line-height: 1; }

.totaux { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 22px 0; }
.tot-l { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 0; font-size: 15px; }
.tot-l span { color: var(--text-2); }
.tot-l b { font-variant-numeric: tabular-nums; font-weight: 700; }
.tot-l.remise b { color: var(--ok); }
.tot-l.grand { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 14px; font-size: 19px; }
.tot-l.grand span { color: var(--text); font-weight: 700; }
.tot-l.grand b { font-size: 26px; font-weight: 800; letter-spacing: -.8px; color: var(--accent); }
.tot-l.acompte { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 12px; }
.tot-l.acompte b { color: var(--accent-2); }

.actions-devis { margin: 20px 0 12px; }
.actions-sec { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }

.btn-principal {
  width: 100%; background: linear-gradient(150deg, var(--accent), #FF9E2C); color: #14181C;
  font-weight: 800; font-size: 17.5px; padding: 18px; border-radius: var(--r);
  box-shadow: 0 8px 24px rgba(255,122,24,.3);
}
.btn-principal:disabled { opacity: .4; box-shadow: none; }
.btn-principal:active:not(:disabled) { transform: scale(.985); }
.btn-ghost {
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  padding: 14px 16px; border-radius: var(--r-s); font-weight: 600; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 52px;
}
.btn-ghost:active { background: var(--surface-2); }
.btn-ghost.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.bloc-btn { width: 100%; margin-top: 8px; }

.barre-bas {
  position: fixed; left: 0; right: 0; bottom: var(--tab-h); z-index: 30;
  padding: 12px 16px; background: var(--glass); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.barre-bas .btn-principal { max-width: 728px; margin: 0 auto; display: block; }

/* ─────────────────────────── Filtres / tarifs ─────────────────────────── */
.filtres { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; scrollbar-width: none; }
.filtres::-webkit-scrollbar { display: none; }
.filtre { white-space: nowrap; padding: 10px 15px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 600; }
.filtre.actif { background: var(--accent); border-color: var(--accent); color: #14181C; }

.tarifs { display: flex; flex-direction: column; gap: 8px; }
.tarif { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); padding: 12px 13px; }
.tarif-t { flex: 1; min-width: 0; }
.tarif-t b { display: block; font-size: 15px; font-weight: 600; }
.tarif-t small { color: var(--text-2); font-size: 12px; }
.tarif-p { display: flex; align-items: center; gap: 5px; }
.tarif-p input { width: 104px; text-align: right; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 11px 9px; outline: none; font-variant-numeric: tabular-nums; font-weight: 700; }
.tarif-p input:focus { border-color: var(--accent); }
.tarif-p em { color: var(--text-2); font-style: normal; font-size: 12px; min-width: 40px; }
.tarif.perso { border-left: 3px solid var(--accent-2); }

.logo-zone { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.logo-preview { width: 82px; height: 82px; border-radius: var(--r-s); border: 1px dashed var(--line); display: grid; place-items: center; color: var(--text-2); font-size: 12px; overflow: hidden; background: var(--surface); flex: none; }
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }

/* ───────── Repli clavier (iPhone installé : pas de micro navigateur) ─────────
   Le gros bouton micro deviendrait un piège : il ne peut rien faire ici.
   On l'efface et on met le champ de saisie directement sous la consigne. */
.dictee-wrap.mode-clavier .scene-mic { display: none; }
.dictee-wrap.mode-clavier .dictee-etat { margin-bottom: 14px; }
.astuce-clavier {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: var(--r); padding: 16px; margin-bottom: 14px;
}
.astuce-clavier b { display: block; font-size: 15.5px; margin-bottom: 6px; }
.astuce-txt { font-size: 14px; color: var(--text-2); line-height: 1.5; margin: 0 0 12px; }
.astuce-txt b { display: inline; font-size: inherit; color: var(--text); }
.astuce-clavier .btn-ghost { width: 100%; }
/* Une fois le geste compris, l'encadré se réduit à un simple rappel */
.astuce-clavier.compact { padding: 11px 14px; }
.astuce-clavier.compact b { font-size: 14px; margin: 0; }
.astuce-clavier.compact .astuce-txt, .astuce-clavier.compact .btn-ghost { display: none; }

/* ─────────────────── Suivi : trésorerie, relances, encaissements ─────────────────── */
.tresorerie { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.treso {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 15px 14px; text-align: left;
}
.treso b { display: block; font-size: 22px; font-weight: 800; letter-spacing: -.6px; }
.treso span { font-size: 11.5px; color: var(--text-2); text-transform: uppercase; letter-spacing: .6px; }
.treso small { display: block; font-size: 12.5px; margin-top: 5px; color: var(--text-2); }
.treso.alerte { border-color: var(--danger); }
.treso.alerte b { color: var(--danger); }
.treso.alerte small { color: var(--danger); font-weight: 700; }
.treso.ok b { color: var(--ok); }
.treso.pleine { grid-column: 1 / -1; }

.etiq.paye { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }
.etiq.retard { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.etiq.partiel { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.carte.retard { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }

.suivi-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.suivi-item.retard { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.suivi-item .carte { border: none; background: none; width: 100%; }
.suivi-actions { display: flex; gap: 8px; padding: 0 12px 12px; }
.suivi-actions button { flex: 1; padding: 11px 8px; border-radius: var(--r-s); font-size: 13.5px; font-weight: 700;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.suivi-actions button.majeur { background: var(--accent); border-color: var(--accent); color: #14181C; }
.suivi-actions button.vert { background: color-mix(in srgb, var(--ok) 20%, transparent); border-color: var(--ok); color: var(--ok); }

/* Bloc facture / paiements dans l'écran devis */
.paie-tete {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: var(--surface-2); border-radius: var(--r-s); padding: 14px; margin-bottom: 12px;
}
.paie-tete .mt { font-size: 21px; font-weight: 800; letter-spacing: -.5px; }
.paie-tete .lb { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--text-2); font-weight: 700; }
.paie-tete small { display: block; font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.paie-tete.du .mt { color: var(--accent); }
.paie-tete.retard { background: color-mix(in srgb, var(--danger) 14%, var(--surface-2)); }
.paie-tete.retard .mt { color: var(--danger); }
.paie-tete.solde { background: color-mix(in srgb, var(--ok) 14%, var(--surface-2)); }
.paie-tete.solde .mt { color: var(--ok); }
.paiements { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.paie-l {
  display: flex; align-items: center; gap: 10px; font-size: 14px;
  background: var(--surface-2); border-radius: var(--r-s); padding: 10px 12px;
}
.paie-l .d { flex: 1; min-width: 0; }
.paie-l .d small { display: block; color: var(--text-2); font-size: 12.5px; }
.paie-l .m { font-weight: 800; }
.paie-l .x { width: 34px; height: 34px; border-radius: 9px; flex: none; color: var(--text-2); font-size: 19px; background: transparent; }

/* Fiche client rappelée sous le champ « Client » */
.fiche-client {
  width: 100%; text-align: left; margin-top: 10px; padding: 12px 14px;
  background: color-mix(in srgb, var(--accent-2) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent-2) 45%, var(--line));
  border-radius: var(--r-s); font-size: 13.5px; color: var(--text); line-height: 1.45;
}
.fiche-client b { color: var(--accent-2); }
.histo-l { display: flex; gap: 10px; align-items: center; background: var(--surface-2); border-radius: var(--r-s); padding: 11px 12px; margin-bottom: 6px; width: 100%; text-align: left; }
.histo-l .d { flex: 1; min-width: 0; }
.histo-l .d b { display: block; font-size: 14.5px; }
.histo-l .d small { color: var(--text-2); font-size: 12.5px; }

.choix-restaure { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.choix { text-align: left; padding: 14px; border-radius: var(--r-s); background: var(--surface-2); border: 1px solid var(--line); }
.choix b { display: block; font-size: 15px; margin-bottom: 3px; }
.choix span { font-size: 13px; color: var(--text-2); line-height: 1.45; }
.choix:first-child { border-color: var(--accent); }
/* Question sans réponse recommandée (le choix TGC) : les deux options partent à
   égalité, et seule celle que l'artisan touche s'allume. Sans ce bloc, « Je
   facture la TGC » serait souligné d'office et orienterait une réponse fiscale. */
.choix-restaure.neutre .choix { border-color: var(--line); }
.choix-restaure.neutre .choix.actif {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* ─────────────────────────── Navigation basse ─────────────────────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(6, 1fr); align-items: center;
  height: var(--tab-h); padding-bottom: var(--safe-b);
  background: var(--glass); backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--text-2); padding: 6px 0; font-size: 10px; font-weight: 600; }
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.actif { color: var(--accent); }
/* Pastille « des factures attendent » sur l'onglet Suivi */
.tab-pastille {
  position: absolute; top: 2px; left: 50%; margin-left: 6px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--danger);
  box-shadow: 0 0 0 2px var(--bg);
}
@media (max-width: 340px) { .tabbar button { font-size: 9px; } }
.tab-fab {
  width: 60px; height: 60px; border-radius: 50%; justify-self: center; margin-top: -22px;
  background: linear-gradient(150deg, var(--accent), #FF9E2C); color: #14181C !important;
  box-shadow: 0 8px 24px rgba(255,122,24,.45); display: grid !important; place-items: center;
}
.tab-fab svg { width: 27px !important; height: 27px !important; stroke-width: 2; }
.tab-fab:active { transform: scale(.93); }

/* ─────────────────────────── Modales & toast ─────────────────────────── */
.modale { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.62); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; }
/* max-height + défilement : sans eux, une modale plus haute que l'écran pousse
   ses boutons d'action hors du champ, et l'artisan se retrouve coincé dans une
   fenêtre qu'il ne peut ni valider ni fermer. Mesuré sur le rappel des mentions :
   797 px de contenu pour 720 px de fenêtre. « dvh » d'abord pour les mobiles,
   où la barre d'URL rétractable fausse « vh ». */
.modale-boite { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 20px; width: 100%; max-width: 520px; box-shadow: var(--shadow); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; }
.modale-boite.grand { max-width: 620px; }
.modale-boite h3 { margin: 0 0 6px; font-size: 19px; }
.modale-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
/* .btn-principal fait 100 % de large par défaut : dans une modale il doit rester en ligne */
.modale-actions .btn-principal { width: auto; flex: 1 1 auto; font-size: 16px; padding: 15px 22px; }
#canvasSign { width: 100%; height: 190px; background: #fff; border-radius: var(--r-s); border: 1px solid var(--line); touch-action: none; margin: 10px 0; display: block; }
.modal-liste { max-height: 52vh; overflow: auto; margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
/* flex: none — sans ça, dans un conteneur en colonne, un libellé qui passe sur
   deux lignes se fait comprimer et le prix disparaît sous le texte. */
.modal-item { flex: none; text-align: left; width: 100%; padding: 13px; border-radius: var(--r-s); background: var(--surface-2); border: 1px solid transparent; }
.modal-item:active { border-color: var(--accent); }
.modal-item b { display: block; font-size: 15px; font-weight: 600; }
.modal-item small { color: var(--text-2); font-size: 12.5px; }

/* ─────────────────────────── Licence expirée ─────────────────────────── */
.licence-bloquee {
  position: fixed; inset: 0; z-index: 999; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.licence-boite {
  max-width: 380px; text-align: center; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); padding: 32px 26px;
  box-shadow: var(--shadow);
}
.licence-ic { font-size: 40px; margin: 0 0 10px; }
.licence-boite h1 { font-size: 21px; margin: 0 0 10px; }
.licence-boite p { color: var(--text-2); font-size: 14.5px; margin: 0 0 10px; line-height: 1.5; }
.licence-contact { color: var(--text) !important; margin-top: 16px !important; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 18px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 13px 20px; border-radius: 999px;
  font-weight: 700; font-size: 14.5px; z-index: 200; box-shadow: var(--shadow);
  animation: toastIn .25s ease both; max-width: 90vw; text-align: center;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px);} to { opacity: 1; transform: translate(-50%, 0);} }

/* ─────────────────────────── Aperçu A4 ─────────────────────────── */
.ecran-apercu { max-width: 900px; }
.apercu-barre { display: flex; gap: 8px; margin-bottom: 14px; }
.apercu-barre .btn-principal { flex: 1; }
.a4-scroll { overflow-x: auto; padding-bottom: 20px; }
.a4 {
  width: 210mm; min-height: 297mm; background: #fff; color: #16202B;
  padding: 15mm 14mm; margin: 0 auto; box-shadow: 0 14px 44px rgba(0,0,0,.35);
  font-size: 10.5pt; line-height: 1.42; transform-origin: top left;
}
.a4 * { box-sizing: border-box; }
.pdf-tete { display: flex; justify-content: space-between; gap: 16mm; padding-bottom: 6mm; border-bottom: 2.5px solid var(--accent); }
.pdf-logo { max-width: 44mm; max-height: 24mm; object-fit: contain; margin-bottom: 3mm; display: block; }
.pdf-ent b { font-size: 14pt; display: block; letter-spacing: -.3px; }
.pdf-ent div { font-size: 9pt; color: #4A5A6B; }
.pdf-titre { text-align: right; flex: none; }
.pdf-titre h1 { margin: 0; font-size: 26pt; letter-spacing: -1px; color: var(--accent); line-height: .95; }
.pdf-titre .num { font-size: 12pt; font-weight: 800; margin-top: 1mm; }
.pdf-titre .meta { font-size: 9pt; color: #4A5A6B; margin-top: 2mm; }
.pdf-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 8mm; margin: 7mm 0 5mm; }
.pdf-bloc { background: #F4F7FA; border-radius: 3mm; padding: 4mm 5mm; }
.pdf-bloc h3 { margin: 0 0 2mm; font-size: 8pt; text-transform: uppercase; letter-spacing: 1px; color: #6B7C8F; }
.pdf-bloc b { font-size: 11pt; }
.pdf-bloc div { font-size: 9.5pt; color: #33455A; }
.pdf-objet { margin: 0 0 5mm; font-size: 10.5pt; }
.pdf-objet b { color: #6B7C8F; text-transform: uppercase; font-size: 8pt; letter-spacing: 1px; display: block; margin-bottom: 1mm; }
table.pdf-t { width: 100%; border-collapse: collapse; margin-bottom: 5mm; }
table.pdf-t th { background: #16202B; color: #fff; font-size: 8.5pt; text-transform: uppercase; letter-spacing: .6px; padding: 2.6mm 2.5mm; text-align: left; font-weight: 700; }
table.pdf-t th.r, table.pdf-t td.r { text-align: right; }
table.pdf-t td { padding: 2.4mm 2.5mm; border-bottom: 1px solid #E1E8EF; font-size: 9.8pt; vertical-align: top; }
table.pdf-t tr:nth-child(even) td { background: #FAFCFD; }
table.pdf-t td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pdf-bas { display: grid; grid-template-columns: 1fr 78mm; gap: 8mm; align-items: start; }
.pdf-tot { border: 1.5px solid #16202B; border-radius: 3mm; overflow: hidden; }
.pdf-tot .l { display: flex; justify-content: space-between; padding: 2.2mm 4mm; font-size: 10pt; }
.pdf-tot .l.sep { border-top: 1px solid #E1E8EF; }
.pdf-tot .l.ttc { background: #16202B; color: #fff; font-weight: 800; font-size: 12.5pt; padding: 3.4mm 4mm; }
.pdf-tot .l.ac { background: #FFF4E8; font-weight: 700; }
.pdf-lettres { font-size: 9pt; font-style: italic; color: #33455A; margin: 3mm 0 5mm; }
.pdf-mentions { font-size: 8.2pt; color: #4A5A6B; white-space: pre-line; line-height: 1.5; }
.pdf-sign { margin-top: 6mm; display: grid; grid-template-columns: 1fr 1fr; gap: 8mm; }
.pdf-sign .box { border: 1px dashed #9FB0C2; border-radius: 3mm; padding: 3mm; min-height: 30mm; font-size: 8.5pt; color: #6B7C8F; }
.pdf-sign .box img { max-width: 100%; max-height: 20mm; display: block; margin-top: 1mm; }
.pdf-photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3mm; margin: 5mm 0; }
.pdf-photos img { width: 100%; height: 28mm; object-fit: cover; border-radius: 2mm; }
.pdf-pied { margin-top: 6mm; padding-top: 3mm; border-top: 1px solid #E1E8EF; font-size: 7.6pt; color: #6B7C8F; text-align: center; }

/* ─────────────────────────── Impression ─────────────────────────── */
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; padding: 0; }
  .topbar, .tabbar, .apercu-barre, .barre-bas, .modale, .toast { display: none !important; }
  .ecran:not(#ecran-apercu) { display: none !important; }
  .ecran-apercu { padding: 0; max-width: none; }
  .a4-scroll { overflow: visible; padding: 0; height: auto !important; }
  /* l'aperçu écran est mis à l'échelle : il faut l'annuler à l'impression */
  .a4 { box-shadow: none; margin: 0; width: 210mm; padding: 12mm 12mm; transform: none !important; }
  table.pdf-t tr { break-inside: avoid; }
  .pdf-bas, .pdf-sign { break-inside: avoid; }
}

/* ─────────────────────────── Grands écrans ─────────────────────────── */
@media (min-width: 720px) {
  .hero-titre { font-size: 52px; }
  .actions-sec { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 380px) {
  .ligne-g { grid-template-columns: 62px 56px 1fr; }
  .ligne-total { grid-column: 1 / -1; text-align: right; padding: 4px 0 0; }
  .hero-titre { font-size: 34px; }
}

/* ═══════════ Mémoire pleine : blocage franc, pas un toast fugace ═══════════
   Un toast de 2,4 s laisse l'artisan travailler sur des données qui ne
   s'enregistrent plus. Ici on barre l'écran jusqu'à ce qu'il ait sauvegardé
   ou fait de la place. */
.blocage {
  position: fixed; inset: 0; z-index: 1200; background: rgba(0,0,0,.62);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  overflow-y: auto;
}
.blocage-boite {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 2px solid var(--danger); border-radius: var(--r); padding: 24px 20px 20px;
  box-shadow: var(--shadow); text-align: center;
}
.blocage-ic { font-size: 38px; margin: 0 0 8px; }
.blocage-boite h2 { font-size: 18px; margin: 0 0 12px; line-height: 1.3; }
.blocage-boite p { color: var(--text-2); font-size: 15px; margin: 0 0 12px; line-height: 1.5; text-align: left; }
.blocage-boite p b { color: var(--text); }
.blocage-boite button { margin-top: 8px; }
.blocage-boite .btn-principal { width: 100%; }

/* ═══════════ Jauge d'espace (Réglages) ═══════════ */
.espace { margin-top: 10px; }
.espace-t { display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
            font-size: 14px; color: var(--text-2); margin-bottom: 6px; }
.espace-t b { color: var(--text); font-size: 14px; white-space: nowrap; }
.espace-b { height: 9px; border-radius: 20px; background: var(--line); overflow: hidden; }
.espace-b i { display: block; height: 100%; border-radius: 20px; transition: width .35s ease; }
.espace-b i.ok        { background: var(--ok); }
.espace-b i.attention { background: var(--accent); }
.espace-b i.danger    { background: var(--danger); }
.espace small { display: block; margin-top: 7px; font-size: 13px; color: var(--text-2); line-height: 1.45; }

/* ═══════════ Métré vocal ═══════════
   Le calcul doit être lisible d'un coup d'œil, pas seulement juste :
   l'artisan vérifie ce que l'app a entendu, il ne refait pas la
   multiplication de tête. */
.ligne-metre {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; margin-top: 8px; padding: 9px 11px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 11px;
  font-size: 14.5px; color: var(--text-2);
}
.ligne-metre .metre-calc b { color: var(--text); }
.ligne-metre .lien { padding: 6px 2px; }
.mes-champs { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 4px; }
.mes-champs input.mes-d {
  width: 92px; min-height: 56px; text-align: center; font-size: 18px; font-weight: 600;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text);
}
.mes-x { font-size: 18px; color: var(--text-2); }
.mes-note { font-size: 15px; color: var(--text-2); }
.mes-res { text-align: center; font-size: 19px; margin: 10px 0 2px; color: var(--text-2); }
.mes-res b { color: var(--accent-2, var(--accent)); font-size: 22px; }

/* ═══════════ Correction d'une ligne ═══════════ */
.cor-dit { font-size: 15.5px; color: var(--text); margin: 2px 0 6px; line-height: 1.45; }
.cor-actuel { font-size: 14px; color: var(--text-2); margin: 0 0 12px; }
.cor-prix { width: 100%; margin-bottom: 12px; text-align: left; }
.cor-entete { font-size: 13px; text-transform: uppercase; letter-spacing: .05em;
              color: var(--text-2); margin: 2px 0 6px; }
/* Cibles confortables : on choisit debout, sur un chantier. */
#corListe .modal-item { min-height: 56px; }
#corListe .modal-item b { font-size: 16px; }

/* ═══════════ Confirmation d'apprentissage ═══════════ */
.app-expl { text-align: center; font-size: 16px; color: var(--text-2); margin: 6px 0; }
.app-expl b { color: var(--text); }
.app-mot {
  width: 100%; min-height: 56px; text-align: center; font-size: 19px; font-weight: 700;
  border: 2px solid var(--accent); border-radius: 13px;
  background: var(--surface); color: var(--text); padding: 0 12px;
}
.app-conflit {
  font-size: 14px; line-height: 1.45; color: var(--text-2); margin: 12px 0 0;
  padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 11px;
}

/* ═══════════ Mots appris (écran Tarifs) ═══════════ */
.mots { display: flex; flex-direction: column; gap: 8px; }
.mot {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.mot-t { flex: 1; min-width: 0; }
.mot-t b { display: block; font-size: 15.5px; }
.mot-t small { display: block; font-size: 13px; color: var(--text-2); margin-top: 2px; }
.mot-x {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--line); background: transparent; color: var(--text-2); font-size: 20px;
}
.ligne-appris {
  margin-top: 6px; font-size: 13.5px; line-height: 1.45; color: var(--text-2);
}

/* ═══════════ Chantiers types ═══════════ */
.chips-t { font-size: 13px; text-transform: uppercase; letter-spacing: .05em;
           color: var(--text-2); margin: 0 0 8px; }
.modeles { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.modele { display: flex; align-items: stretch; gap: 8px; }
.modele-b {
  flex: 1; display: flex; align-items: center; gap: 12px; text-align: left;
  min-height: 64px; padding: 12px 14px; border-radius: var(--r-s);
  background: var(--surface-2); border: 1px solid transparent;
}
.modele-b:active { border-color: var(--accent); }
.modele-ic { font-size: 24px; flex: none; }
.modele-t { min-width: 0; }
.modele-t b { display: block; font-size: 16px; font-weight: 600; }
.modele-t small { display: block; font-size: 13px; color: var(--text-2); margin-top: 2px; }
.modele-x {
  flex: none; width: 48px; border-radius: var(--r-s);
  border: 1px solid var(--line); background: transparent; color: var(--text-2); font-size: 20px;
}
.ban-modele {
  margin: 12px 0; padding: 13px 14px; border-radius: var(--r-s);
  background: var(--surface-2); border: 1px solid var(--accent);
}
.ban-modele p { margin: 0 0 10px; font-size: 14.5px; line-height: 1.5; color: var(--text-2); }
.ban-modele p b { color: var(--text); }
.ban-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ban-actions button { flex: 1 1 auto; min-height: 48px; }
/* Case à cocher confortable : elle se touche avec un gant. */
.case { display: flex; align-items: flex-start; gap: 12px; margin: 14px 0 4px;
        padding: 12px; border-radius: var(--r-s); background: var(--surface-2); }
.case input { width: 26px; height: 26px; flex: none; margin-top: 1px; accent-color: var(--accent); }
.case span { min-width: 0; }
.case b { display: block; font-size: 15.5px; }
.case small { display: block; font-size: 13px; color: var(--text-2); margin-top: 3px; line-height: 1.45; }
