/* Devis & Factures — thème « Carnet » de Socle : papier crème, encre, terracotta.
   Barre latérale sur grand écran, onglets en bas sur téléphone. */

:root {
  --bg: #FAF6EF;
  --card: #FFFDF8;
  --tx: #1C1917;
  --mu: #57534E;
  --mu2: #8A837A;
  --pr: #C05B33;
  --pr-tx: #FDF9F2;
  --pr-soft: #F6E3D9;
  --sec: #F0EAE0;
  --acc: #F5EFE4;
  --bd: #E7DFD2;
  --ok: #4D7C0F;
  --ok-soft: #EAF2DC;
  --warn: #B45309;
  --warn-soft: #FBEBD6;
  --info: #0369A1;
  --info-soft: #DCEEF8;
  --dng: #B91C1C;
  --dng-soft: #FBE1E1;
  --side: #F5EFE4;
  --side-tx: #44403C;
  --side-acc: #EAE2D4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(28, 25, 23, .06), 0 1px 8px rgba(28, 25, 23, .05);
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --heading: "Bitter", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
.dark {
  --bg: #171412; --card: #211D1A; --tx: #EDE8E0; --mu: #A8A29E; --mu2: #78716C;
  --pr: #E0805A; --pr-tx: #1C1210; --pr-soft: #3A2A22; --sec: #2E2823; --acc: #2E2823; --bd: #35302A;
  --ok: #A3E635; --ok-soft: #22301A; --warn: #F59E0B; --warn-soft: #3A2A12; --info: #38BDF8; --info-soft: #14303D;
  --dng: #EF4444; --dng-soft: #3B1B1B; --side: #211D1A; --side-tx: #D6D0C6; --side-acc: #2E2823;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--tx);
  font-family: var(--font); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--heading); margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
a { color: var(--pr); }
button { font: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.mu { color: var(--mu); }
.sm { font-size: 13px; }
.xs { font-size: 12px; }
.b { font-weight: 700; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Coque ---------- */
.app { display: flex; min-height: 100dvh; }
.side {
  display: none; position: fixed; inset: 0 auto 0 0; width: 248px; flex-direction: column;
  background: var(--side); color: var(--side-tx); border-right: 1px solid var(--bd); padding: 20px 14px;
}
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 16px; }
.side .brand .nom { font-family: var(--heading); font-weight: 700; font-size: 16px; color: var(--tx); line-height: 1.15; }
.side .brand .sous { font-size: 12px; color: var(--mu2); }
.side nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; flex: 1; }
.side nav a, .side nav button {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 0; background: none;
  color: var(--side-tx); text-decoration: none; font-weight: 600; font-size: 14px; cursor: pointer; text-align: left;
}
.side nav a:hover { background: var(--side-acc); }
.side nav a.on { background: var(--pr); color: var(--pr-tx); }
.side .pied { border-top: 1px solid var(--bd); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.side .cta { margin: 6px 0 10px; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  height: 56px; padding: 0 16px; padding-top: env(safe-area-inset-top); background: var(--side); border-bottom: 1px solid var(--bd);
}
.top .nom { font-family: var(--heading); font-weight: 700; font-size: 16px; color: var(--tx); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { flex: 1; min-width: 0; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.conteneur { max-width: 960px; margin: 0 auto; padding: 18px 16px 24px; }
.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--bd); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 4px 7px; font-size: 11px; font-weight: 600; color: var(--mu); text-decoration: none; }
.tabs a.on { color: var(--pr); }
.tabs a.creer span.rond { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 999px; background: var(--pr); color: var(--pr-tx); }
.icone { width: 20px; height: 20px; flex-shrink: 0; }
.icone.s { width: 16px; height: 16px; }
.picto-socle { width: 22px; height: 16px; color: var(--pr); flex-shrink: 0; }
.socle {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--mu); text-decoration: none; line-height: 1.2;
}
.socle a { text-decoration: none; } .socle b { color: var(--pr); font-weight: 700; }
.socle.pill { background: var(--pr); color: var(--pr-tx); padding: 5px 10px; border-radius: 999px; font-weight: 600; }
.socle.pill b, .socle.pill .picto-socle { color: var(--pr-tx); }
.pied-page { text-align: center; padding: 18px 16px 6px; }

@media (min-width: 1024px) {
  .side { display: flex; }
  .top, .tabs { display: none; }
  .main { margin-left: 248px; padding-bottom: 0; }
  .conteneur { padding: 32px 36px 40px; }
  h1 { font-size: 30px; }
}

/* ---------- Composants ---------- */
.entete { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.entete .sous { color: var(--mu); font-size: 14px; margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 10px; border: 1px solid transparent; background: var(--pr); color: var(--pr-tx); font-weight: 700; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: opacity .15s, background .15s; box-shadow: var(--shadow);
}
.btn:hover { opacity: .92; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sec { background: var(--card); color: var(--tx); border-color: var(--bd); }
.btn.sec:hover { background: var(--acc); opacity: 1; }
.btn.ghost { background: transparent; color: var(--pr); box-shadow: none; }
.btn.ghost:hover { background: var(--pr-soft); opacity: 1; }
.btn.dng { background: var(--dng-soft); color: var(--dng); box-shadow: none; }
.btn.petit { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.grand { height: 48px; font-size: 15px; padding: 0 20px; }
.btn.bloc { width: 100%; }
.btn .icone { width: 17px; height: 17px; }
.carte { background: var(--card); border: 1px solid var(--bd); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.carte + .carte { margin-top: 14px; }
.carte .titre { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.carte .titre h2 { display: flex; align-items: center; gap: 8px; }
.carte .titre .icone { color: var(--pr); }
.grille { display: grid; gap: 12px; }
.g2 { grid-template-columns: 1fr; }
.g3 { grid-template-columns: 1fr; }
.g4 { grid-template-columns: 1fr 1fr; }
@media (min-width: 640px) { .g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); } }
.span2 { grid-column: 1 / -1; }
.kpi { padding: 16px; }
.kpi .lib { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--mu); }
.kpi .val { font-family: var(--mono); font-size: 22px; font-weight: 600; margin-top: 4px; }
.kpi .sous { font-size: 12px; color: var(--mu); margin-top: 2px; }
.kpi.ok .val { color: var(--ok); }
.kpi.dng .val { color: var(--dng); }
.kpi.pr .val { color: var(--pr); }
.gros-boutons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.gros-boutons a {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 18px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--bd); text-decoration: none; color: var(--tx); box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
.gros-boutons a:hover { border-color: var(--pr); transform: translateY(-1px); }
.gros-boutons a .ico { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: var(--pr-soft); color: var(--pr); }
.gros-boutons a .t { font-family: var(--heading); font-weight: 700; font-size: 17px; }
.gros-boutons a .d { font-size: 12.5px; color: var(--mu); }
.gros-boutons a.pr { background: var(--pr); color: var(--pr-tx); border-color: var(--pr); }
.gros-boutons a.pr .ico { background: rgba(255, 255, 255, .18); color: var(--pr-tx); }
.gros-boutons a.pr .d { color: var(--pr-tx); opacity: .85; }
.bandeau { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); border: 1px solid; margin-bottom: 16px; font-size: 14px; }
.bandeau .icone { flex-shrink: 0; margin-top: 1px; }
.bandeau.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); color: var(--tx); }
.bandeau.warn .icone { color: var(--warn); }
.bandeau.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 40%, transparent); }
.bandeau.info .icone { color: var(--info); }
.bandeau.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.bandeau.ok .icone { color: var(--ok); }
.bandeau .corps { flex: 1; }
.bandeau .corps .btn { margin-top: 8px; }

/* Listes de documents */
.liste { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--bd); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.liste li + li { border-top: 1px solid var(--bd); }
.liste a.ligne { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; color: inherit; text-decoration: none; }
.liste a.ligne:hover { background: var(--acc); }
.liste .g { min-width: 0; flex: 1; }
.liste .num { font-family: var(--mono); font-weight: 600; font-size: 14px; }
.liste .infos { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.liste .cli { font-size: 14px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.liste .cli .mu { font-weight: 400; }
.liste .d { text-align: right; flex-shrink: 0; }
.liste .d .tot { display: block; font-family: var(--mono); font-weight: 600; font-size: 15px; }
.liste .d .dt { display: block; font-size: 12px; color: var(--mu); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.chip.neutre { background: var(--sec); color: var(--mu); border-color: var(--bd); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.dng { background: var(--dng-soft); color: var(--dng); }
.chip .icone { width: 12px; height: 12px; }
.onglets { display: flex; gap: 4px; padding: 4px; margin-bottom: 14px; background: var(--sec); border-radius: 12px; }
.onglets button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; border: 0; border-radius: 9px; background: none; color: var(--mu); font-weight: 700; font-size: 14px; cursor: pointer; }
.onglets button .icone { width: 18px; height: 18px; }
.onglets button .n { font-family: var(--mono); font-size: 12px; font-weight: 400; opacity: .8; }
.onglets button.on { background: var(--card); color: var(--pr); box-shadow: var(--shadow); }
.filtres { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.filtres::-webkit-scrollbar { display: none; }
.filtres button { flex-shrink: 0; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--bd); background: var(--card); color: var(--mu); font-size: 12.5px; font-weight: 700; cursor: pointer; }
.filtres button.on { background: var(--pr); border-color: var(--pr); color: var(--pr-tx); }
.recherche { position: relative; margin-bottom: 12px; }
.recherche .icone { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--mu2); pointer-events: none; }
.recherche input { padding-left: 40px; }
.vide { text-align: center; padding: 40px 16px; border: 1px dashed var(--bd); border-radius: var(--radius); color: var(--mu); }
.vide .ico { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 999px; background: var(--pr-soft); color: var(--pr); margin-bottom: 10px; }
.vide .t { font-weight: 700; color: var(--tx); }
.vide .btn { margin-top: 14px; }

/* Formulaires */
label.lib, .lib { display: block; font-size: 12px; font-weight: 700; color: var(--mu); margin: 0 0 4px; }
.champ, input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--bd); border-radius: 10px; background: var(--card); color: var(--tx);
  font: inherit; font-size: 16px; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 72px; padding: 10px 12px; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pr); box-shadow: 0 0 0 3px var(--pr-soft); }
input[type=number] { font-family: var(--mono); }
input[type=file] { font-size: 14px; }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2357534E' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; }
@media (min-width: 640px) { .champ, input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea { font-size: 14px; } }
.aide { font-size: 12px; color: var(--mu); margin-top: 4px; }
.coche { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.coche input { width: 18px; height: 18px; accent-color: var(--pr); }
.bascule { display: flex; border: 1px solid var(--bd); border-radius: 10px; padding: 3px; background: var(--card); }
.bascule button { flex: 1; height: 34px; border: 0; border-radius: 8px; background: none; color: var(--mu); font-weight: 700; font-size: 13px; cursor: pointer; }
.bascule button.on { background: var(--pr); color: var(--pr-tx); }
.ligne-doc { border: 1px solid var(--bd); border-radius: 10px; padding: 12px; background: var(--bg); }
.ligne-doc + .ligne-doc { margin-top: 10px; }
.ligne-doc .pied { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.ligne-doc .pied .tot { font-family: var(--mono); font-weight: 600; }
.ligne-doc .outils { display: flex; gap: 2px; }
.ib { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: none; color: var(--mu); cursor: pointer; }
.ib:hover { background: var(--acc); color: var(--tx); }
.ib:disabled { opacity: .3; cursor: default; }
.ib.dng:hover { background: var(--dng-soft); color: var(--dng); }
.ib .icone { width: 16px; height: 16px; }
.recap { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding: 12px 16px; background: var(--card); border: 1px solid var(--bd); border-radius: var(--radius); box-shadow: 0 -4px 24px rgba(28, 25, 23, .12); }
.recap .tot { font-family: var(--mono); font-size: 20px; font-weight: 600; color: var(--pr); }
.recap .tot small { font-family: var(--font); font-size: 12px; color: var(--mu); font-weight: 400; }
@media (min-width: 1024px) { .recap { bottom: 16px; } }
.logo-apercu { height: 56px; max-width: 160px; object-fit: contain; background: #fff; border: 1px solid var(--bd); border-radius: 8px; padding: 4px; }

/* Barre d'actions d'un document */
.barre-doc { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.statut-ligne { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 14px; color: var(--mu); }
.historique { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.historique li { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-top: 1px solid var(--bd); }
.historique li:first-child { border-top: 0; }
.historique .icone { color: var(--mu2); margin-top: 1px; }

/* ---------- Document papier (aperçu + impression) ---------- */
.feuille-cadre { background: #E9E2D6; padding: 12px; border-radius: var(--radius); overflow-x: auto; }
.dark .feuille-cadre { background: #0F0D0B; }
.papier {
  background: #fff; color: #1C1210; width: 100%; max-width: 720px; margin: 0 auto; padding: 36px 38px; border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .15); font-family: var(--font); font-size: 12.5px; line-height: 1.45;
}
.papier .brouillon { text-align: center; color: #C05B33; font-weight: 700; letter-spacing: .1em; font-size: 11px; margin-bottom: 12px; }
.papier .haut { display: flex; justify-content: space-between; gap: 24px; border-bottom: 2px solid #1C1210; padding-bottom: 14px; }
.papier .ent .nom { font-family: var(--heading); font-size: 20px; font-weight: 800; }
.papier .ent .act { color: #6E6259; font-size: 11.5px; margin-bottom: 4px; }
.papier .ent img { height: 56px; max-width: 170px; object-fit: contain; display: block; margin: 6px 0 8px; }
.papier .ent .info { font-size: 11px; line-height: 1.5; }
.papier .haut .client { align-self: flex-start; }
.papier .titre-ligne { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-top: 16px; }
.papier .typ { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.papier .typ .t { font-family: var(--heading); font-size: 24px; font-weight: 800; color: #C05B33; letter-spacing: .02em; }
.papier .typ .n { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.papier .dates { text-align: right; font-size: 11.5px; line-height: 1.5; }
.papier .dates .regle { color: #4D7C0F; font-weight: 700; }
.papier .objet { margin-top: 12px; }
.papier .etq { font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: #6E6259; margin-bottom: 2px; }
.papier .client { min-width: 210px; max-width: 280px; border: 1px solid #E7DCCE; border-radius: 6px; padding: 10px 12px; font-size: 12px; }
.papier .client .nm { font-weight: 700; font-size: 13px; }
.papier table { width: 100%; border-collapse: collapse; margin-top: 18px; }
.papier th { text-align: left; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; padding: 8px 8px; background: #F6EEE1; border-bottom: 2px solid #1C1210; }
.papier td { padding: 8px; border-bottom: 1px solid #E7DCCE; vertical-align: top; }
.papier .c { text-align: center; } .papier .r { text-align: right; white-space: nowrap; font-family: var(--mono); }
.papier .total { display: flex; justify-content: flex-end; margin-top: 10px; }
.papier .total div { display: flex; justify-content: space-between; gap: 40px; min-width: 260px; padding: 10px 14px; border-radius: 6px; background: #F6EEE1; font-family: var(--heading); font-weight: 800; font-size: 15px; color: #C05B33; }
.papier .total div span:last-child { font-family: var(--mono); }
.papier .total .detail { display: block; min-width: 280px; padding: 8px 0 0; background: none; color: #1C1210; font-family: var(--font); font-weight: 400; font-size: 12px; }
.papier .total .detail > div { display: flex; justify-content: space-between; gap: 24px; padding: 3px 14px; }
.papier .total .detail > div.ttc { margin-top: 6px; padding: 10px 14px; border-radius: 6px; background: #F6EEE1; font-family: var(--heading); font-weight: 800; font-size: 15px; color: #C05B33; }
.papier .mentions { margin-top: 16px; font-size: 10.5px; color: #6E6259; line-height: 1.55; }
.papier .mentions .forte { color: #1C1210; font-weight: 700; }
.papier .accord { display: flex; justify-content: flex-end; margin-top: 12px; }
.papier .accord div { width: 250px; height: 78px; border: 1px solid #E7DCCE; border-radius: 6px; padding: 8px; font-size: 10.5px; color: #6E6259; }
.papier .merci { margin-top: 14px; color: #C05B33; font-style: italic; }
.papier .bas { margin-top: 22px; padding-top: 8px; border-top: 1px solid #E7DCCE; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 10px; color: #6E6259; }
.papier .bas b { color: #C05B33; }

/* ---------- Toasts, modales ---------- */
.toasts { position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px; background: var(--card); color: var(--tx); border: 1px solid var(--bd); box-shadow: 0 6px 24px rgba(0, 0, 0, .14); font-size: 14px; animation: toast-in .2s ease-out; pointer-events: auto; }
.toast .icone { flex-shrink: 0; }
.toast.ok .icone { color: var(--ok); }
.toast.err .icone { color: var(--dng); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.modale { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(20, 16, 12, .55); backdrop-filter: blur(2px); }
.modale[hidden] { display: none; }
.modale .boite { width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto; background: var(--card); border: 1px solid var(--bd); border-radius: 14px; padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); animation: toast-in .18s ease-out; }
.modale .boite.large { max-width: 640px; }
.modale h2 { margin-bottom: 4px; }
.modale .desc { color: var(--mu); font-size: 14px; margin-bottom: 14px; }
.modale .pied { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modale .pj { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; background: var(--acc); font-size: 13px; }
.sep { height: 1px; background: var(--bd); margin: 14px 0; }

/* ---------- Connexion ---------- */
.auth { max-width: 440px; margin: 0 auto; padding: 48px 16px; }
.auth-tete { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; margin-bottom: 22px; }
.auth-logo { display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 16px; background: var(--tx); box-shadow: var(--shadow); }
.auth-logo .picto-socle { width: 30px; height: 22px; }
.auth-carte { padding: 22px; }
.sync { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--mu2); }
.sync .icone { width: 14px; height: 14px; }
.sync.ok .icone { color: var(--ok); }
.sync.erreur { color: var(--dng); }
.sync.en-cours .icone { animation: tourne 1s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }

/* ---------- Signature ---------- */
.signature-zone { position: relative; border: 1px dashed var(--bd); border-radius: 10px; background: #fff; overflow: hidden; }
.signature-zone canvas { display: block; width: 100%; height: auto; cursor: crosshair; }
.signature-aide { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #bbb; font-size: 18px; pointer-events: none; font-style: italic; }
.papier .accord .signe { height: auto; min-height: 78px; }
.papier .accord .signe img { display: block; height: 52px; margin-top: 4px; }

/* ---------- Statistiques ---------- */
.graphe { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; height: 200px; align-items: end; }
.graphe .colonne { display: flex; flex-direction: column; align-items: center; height: 100%; gap: 4px; }
.graphe .barres { display: flex; align-items: flex-end; gap: 2px; flex: 1; width: 100%; justify-content: center; }
.graphe .barre { width: 40%; min-height: 2px; border-radius: 3px 3px 0 0; }
.graphe .barre.pr { background: var(--pr); }
.graphe .barre.ok { background: var(--ok); }
.graphe .mois { font-size: 11px; color: var(--mu); }
.graphe .valeur { font-size: 10px; color: var(--mu2); font-family: var(--mono); white-space: nowrap; height: 12px; }
.legende { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 8px; vertical-align: middle; }
.legende.pr { background: var(--pr); } .legende.ok { background: var(--ok); }
.biblio select { height: 34px; font-size: 13px; width: auto; max-width: 360px; }
.historique li a { color: inherit; text-decoration: none; }
.historique li a:hover { color: var(--pr); }
@media (max-width: 640px) { .graphe { gap: 3px; } .graphe .valeur { display: none; } .graphe .mois { font-size: 9px; } }

/* ---------- Impression : seule la feuille sort ---------- */
@media print {
  body { background: #fff; }
  .side, .top, .tabs, .toasts, .modale, .barre-doc, .statut-ligne, .entete, .pied-page, .carte, .no-print { display: none !important; }
  .main { margin: 0; padding: 0; }
  .conteneur { max-width: none; padding: 0; }
  .feuille-cadre { background: none; padding: 0; border-radius: 0; overflow: visible; }
  .papier { max-width: none; box-shadow: none; border-radius: 0; padding: 0; font-size: 12px; }
  @page { size: A4; margin: 14mm; }
}
