/* ============================================================
   SAMRO Facture — Design system (refonte 2026)
   Réf. : handoff-desktop.md / handoff-mobile.md.
   Namespace .ui-* / .sidebar / .app pour cohabiter avec l'ancien
   style pendant la migration page par page. Aucune dépendance externe.
   ============================================================ */

:root {
  /* Fonds & surfaces */
  --bg: #f6f5f3;
  --surface: #ffffff;
  --surface-2: #fafaf9;   /* en-têtes de tableau */
  --surface-3: #f4f2ef;   /* champs désactivés, hover doux */

  /* Bordures & séparateurs */
  --border: #e9e7e3;
  --row-sep: #f4f2ef;

  /* Texte */
  --text: #1c1917;
  --text-2: #57534e;
  --text-3: #78716c;
  --text-muted: #a8a29e;

  /* Rouge SAMRO */
  --red: #c02434;
  --red-hover: #9a1c2a;
  --red-050: #fbe9eb;     /* fond nav active / avatar / badge rôle */
  --red-100: #fdecec;     /* hover destructif */
  --red-border: #f3d5d8;  /* bordure destructive */

  /* Noir (boutons contour, pagination active) */
  --ink: #1c1917;

  /* Statuts */
  --ok-bg: #e7f5ec;   --ok-fg: #1c7c3f;
  --no-bg: #fdecec;   --no-fg: #c02434;
  --wait-bg: #fdf3e1; --wait-fg: #a16207;

  /* Encart d'avertissement */
  --notice-bg: #fdf6e3; --notice-border: #f2e3b3; --notice-fg: #7a5b0d;

  /* Rayons */
  --r-card: 14px;
  --r-btn: 9px;
  --r-input: 8px;
  --r-pill: 99px;

  /* Divers */
  --font: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --shadow-hover: 0 4px 16px rgba(28, 25, 23, 0.07);
  --sidebar-w: 224px;
  --tabbar-h: 60px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-hover); }

img { max-width: 100%; }

input[type="checkbox"], input[type="radio"] { accent-color: var(--red); }

.num { font-variant-numeric: tabular-nums; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.text-right { text-align: right; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.d-none { display: none !important; }   /* remplace l'utilitaire Bootstrap (retiré au nettoyage) */

/* ---------- Shell : sidebar + contenu ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  padding: 24px 20px 20px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.sidebar__logo { font-weight: 800; font-size: 20px; letter-spacing: 0.04em; color: var(--red); }
.sidebar__sub  { font-size: 11px; color: var(--text-muted); font-weight: 500; }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }

.sidebar__link {
  border-radius: 9px;
  padding: 9px 12px;
  font: 600 13.5px var(--font);
  color: var(--text-2);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.sidebar__link:hover { background: var(--surface-3); color: var(--text); }
.sidebar__link.is-active { background: var(--red-050); color: var(--red); font-weight: 700; }

.sidebar__foot {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar__user { min-width: 0; flex: 1; }
.sidebar__name { font: 700 13px var(--font); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__role { font-size: 11.5px; color: var(--text-muted); }

.avatar {
  width: 36px; height: 36px; flex: none;
  border-radius: 50%;
  background: var(--red-050); color: var(--red);
  display: flex; align-items: center; justify-content: center;
  font: 700 13px var(--font);
}

/* Colonne de contenu (topbar mobile + main) */
.content-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Contenu principal */
.ui-main { flex: 1; min-width: 0; padding: 36px 44px; overflow-x: clip; }

/* Bouton "masquer le menu" (desktop) */
.menu-toggle {
  border: 1px solid var(--border); background: #fff;
  border-radius: 8px; padding: 6px 12px;
  font: 600 12px var(--font); color: var(--text-3);
  cursor: pointer; margin-bottom: 18px;
}
.menu-toggle:hover { background: var(--surface-3); color: var(--text); }
.app.sidebar-hidden .sidebar { display: none; }

/* ---------- Barre d'onglets (mobile) ---------- */
.tabbar { display: none; }
.mobile-topbar { display: none; }

/* ---------- En-tête de page ---------- */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-title { font: 700 26px var(--font); letter-spacing: -0.01em; margin: 0; }
.page-count { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Boutons ---------- */
.ui-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--r-btn);
  padding: 10px 18px; font: 600 13px var(--font); line-height: 1;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.ui-btn:disabled { opacity: .55; cursor: default; }

.ui-btn--primary   { background: var(--red); color: #fff; border-color: var(--red); }
.ui-btn--primary:hover { background: var(--red-hover); border-color: var(--red-hover); color: #fff; }

.ui-btn--secondary { background: #fff; border-color: var(--border); color: var(--text-2); }
.ui-btn--secondary:hover { background: var(--surface-3); color: var(--text); }

.ui-btn--danger    { background: #fff; border-color: var(--red-border); color: var(--red); }
.ui-btn--danger:hover { background: var(--red-100); color: var(--red); }

.ui-btn--ink       { background: #fff; border-color: var(--ink); color: var(--ink); }
.ui-btn--ink:hover { background: var(--ink); color: #fff; }

.ui-btn--sm    { padding: 7px 12px; font-size: 12px; }
.ui-btn--block { width: 100%; }

/* ---------- Cartes ---------- */
.ui-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); }
.ui-card__body { padding: 20px; }
.ui-card__title { font: 700 16px var(--font); margin: 0 0 4px; }
.ui-card__sub { font-size: 13px; color: var(--text-3); margin: 0 0 16px; }

/* ---------- Formulaires ---------- */
.ui-label { display: block; font: 600 12px var(--font); color: var(--text-3); margin-bottom: 6px; }
.ui-field { margin-bottom: 16px; }

.ui-input, .ui-select {
  width: 100%;
  border: 1px solid var(--border); border-radius: var(--r-input);
  padding: 9px 11px; font: 500 14px var(--font); color: var(--text);
  background: #fff; transition: border-color .12s, box-shadow .12s;
}
.ui-select { padding-right: 8px; }
.ui-input::placeholder { color: var(--text-muted); }
.ui-input:focus, .ui-select:focus {
  outline: none; border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(192, 36, 52, 0.15);
}
.ui-input:disabled, .ui-input[readonly] { background: var(--surface-3); color: var(--text-3); }
.ui-input--muted { background: var(--surface-2); }
.ui-input--pin { text-align: center; letter-spacing: 0.4em; font: 600 18px var(--font); }

/* ---------- Badges / pastilles ---------- */
.ui-badge {
  display: inline-flex; align-items: center;
  border-radius: var(--r-pill); padding: 3px 10px; font: 700 12px var(--font);
}
.ui-badge--paye    { background: var(--ok-bg);   color: var(--ok-fg); }
.ui-badge--impaye  { background: var(--no-bg);   color: var(--no-fg); }
.ui-badge--acompte { background: var(--wait-bg); color: var(--wait-fg); }
.ui-badge--muted   { background: var(--surface-3); color: var(--text-2); }
.ui-badge--role    { background: var(--red-050);  color: var(--red); }
/* Statut de stock (mêmes tons que les statuts de paiement, noms sémantiques). */
.ui-badge--ok      { background: var(--ok-bg);   color: var(--ok-fg); }
.ui-badge--faible  { background: var(--wait-bg); color: var(--wait-fg); }
.ui-badge--rupture { background: var(--no-bg);   color: var(--no-fg); }

/* ---------- Tableaux (CSS grid par ligne) ---------- */
/* Chaque page pose ses colonnes via style="--cols: ...". */
/* .ui-table (Journal, Comptes, Versements) ET .hist-list (Historique) partagent le
   même chrome desktop ; l'historique ne diffère que par ses colonnes (--cols) et sa
   carte mobile (grid-template-areas, plus bas). */
.ui-table { --cols: 1fr; width: 100%; }
.ui-table, .hist-list { border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; background: var(--surface); }
.hist-list { --cols: 88px 104px 1fr 140px 190px 240px; }
.ui-thead, .ui-tr, .hist-head, .hist-item {
  display: grid; grid-template-columns: var(--cols);
  align-items: center; gap: 12px; padding: 11px 16px;
}
.ui-thead, .hist-head {
  background: var(--surface-2);
  font: 700 11.5px var(--font); text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-3);
}
.ui-tr, .hist-item { border-top: 1px solid var(--row-sep); font-size: 13.5px; }
.ui-tr:hover, .hist-item:hover { background: var(--surface-2); }
.ui-tr--muted, .hist-item.is-annulee { color: var(--text-muted); }

/* ---------- Alertes / encarts ---------- */
.ui-alert { border-radius: 10px; padding: 10px 14px; font-size: 13.5px; border: 1px solid transparent; }
.ui-alert--success { background: var(--ok-bg);   color: var(--ok-fg);   border-color: #cdead6; }
.ui-alert--danger  { background: var(--no-bg);   color: var(--no-fg);   border-color: var(--red-border); }
.ui-alert--warning { background: var(--notice-bg); color: var(--notice-fg); border-color: var(--notice-border); }
.ui-alert--info    { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }

/* ---------- Pied de page ---------- */
.app-footer { text-align: center; color: var(--text-muted); font-size: 12.5px; padding: 28px 16px; }

/* ---------- Séparateur ---------- */
.ui-hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ---------- Feuille du bas « Plus » (mobile) ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet[hidden] { display: none; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(28, 25, 23, 0.4); }
.sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--surface); border-radius: 16px 16px 0 0;
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.15);
}
.sheet__grip { width: 36px; height: 4px; border-radius: 2px; background: var(--border); margin: 8px auto 4px; }
.sheet__user { display: flex; align-items: center; gap: 10px; padding: 10px 6px 12px; }
.sheet__link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 8px; border-top: 1px solid var(--row-sep);
  font: 600 15px var(--font); color: var(--text);
}
.sheet__link .chev { color: var(--text-muted); }
.sheet__link--danger { color: var(--red); }

/* ============================================================
   Responsive : < 860px → sidebar masquée, tab bar en bas
   Points de rupture (une media query ne peut pas lire une var(), d'où les
   littéraux répétés) : 600 = les champs .champs s'empilent (volontairement sous
   860 : entre les deux, flex-wrap suffit) · 768 = grille produits 2 colonnes ·
   860 = shell (sidebar↔tab bar) + tableaux en cartes · 1100 = grille produits 3 col.
   ============================================================ */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .menu-toggle { display: none; }

  .ui-main { padding: 16px; padding-bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom, 0px)); }

  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 12px 16px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
  }
  .mobile-topbar__title { font: 700 19px var(--font); }

  .page-title { font-size: 21px; }

  /* Tableaux .ui-table → cartes empilées (Journal, Comptes, Versements) :
     plus AUCUN défilement horizontal. Chaque cellule = « étiquette : valeur ». */
  .ui-table { display: block; border: none; background: none; overflow: visible; }
  .ui-table .ui-thead { display: none; }
  .ui-table .ui-tr {
    display: block;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 8px 14px; margin-bottom: 10px;
  }
  .ui-table .ui-tr:hover { background: var(--surface); }
  .ui-table .ui-tr > * {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 5px 0; text-align: right; word-break: break-word;
  }
  .ui-table .ui-tr > * + * { border-top: 1px solid var(--row-sep); }
  .ui-table .ui-tr > *::before {
    content: attr(data-label); flex: 0 0 auto; text-align: left;
    font: 600 12px var(--font); color: var(--text-3);
  }
  .ui-table .ui-tr > *:empty { display: none; }

  .tabbar {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .tabbar__item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 8px 0; min-height: var(--tabbar-h);
    color: var(--text-muted); font: 600 10.5px var(--font); text-decoration: none;
  }
  .tabbar__item .ico { font-size: 17px; line-height: 1; }
  .tabbar__item.is-active { color: var(--red); font-weight: 700; }
}

/* ============================================================
   Page « Nouvelle facture »
   ============================================================ */
.facture-infos { display: grid; grid-template-columns: 120px 150px 1fr 180px 180px; gap: 14px; }

/* Tableau des lignes (structure <table> conservée pour facture.js).
   table-layout:fixed impose les largeurs de colonnes déclarées dans le <thead> ;
   sans lui, la largeur intrinsèque des <input> ferait déborder le tableau sur
   desktop/tablette. (Sur mobile ≤860, le tableau passe en fiches — propriété inerte.) */
.lignes { width: 100%; border-collapse: collapse; table-layout: fixed; }
.lignes thead th {
  text-align: left; padding: 0 8px 10px;
  font: 700 11.5px var(--font); text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-3); white-space: nowrap;
}
.lignes thead th.text-right { text-align: right; }
.lignes tbody td { padding: 8px; border-top: 1px solid var(--row-sep); vertical-align: middle; }
.lignes .ui-input, .lignes .ui-select { padding: 8px 10px; }
.lignes .js-total-ligne { text-align: right; font-weight: 700; white-space: nowrap; }

/* Vignette photo d'une ligne (44×44, remplace l'ancien 54px) */
.vignette-vide {
  width: 44px; height: 44px; border-radius: 8px;
  background: var(--surface-3); border: 1px dashed #d6d3d1;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 11px; text-align: center; cursor: pointer;
}
.vignette-vide:hover { border-color: var(--red); color: var(--red); }
.vignette-vide.chargement { opacity: .5; }
.vignette { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; background: #fff; border: 1px solid var(--border); cursor: pointer; }
.vignette:hover { border-color: var(--red); }
/* Bouton 📷 d'une ligne (tactile) : carré 44×44, identique à la vignette. */
.ligne-photo-cam { display: none; width: 44px; height: 44px; margin: 0; padding: 0; font-size: 1.15rem; }
@media (pointer: coarse) { .ligne-photo-cam { display: inline-flex; align-items: center; justify-content: center; } }

/* Rangée de champs (filtres, formulaires). Desktop : les champs grandissent /
   rétrécissent et s'alignent. Mobile (≤600) : chaque champ passe pleine largeur,
   sauf .champs-2 (paires 50/50 sur une ligne, ex. dates) et .champs-auto (boutons). */
.champs { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.champs > * { flex: 1 1 180px; min-width: 0; }
.champs > .champs-large { flex-grow: 2.4; }
.champs > .champs-auto { flex: 0 0 auto; }
@media (max-width: 600px) {
  .champs > * { flex-basis: 100%; }
  .champs > .champs-2 { flex-basis: calc(50% - 6px); }
}

/* Autocomplétion de la désignation */
.autocomplete-box {
  position: absolute; z-index: 1000; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-hover);
  max-height: 280px; overflow-y: auto; min-width: 280px;
}
.autocomplete-item { display: flex; gap: .6rem; align-items: center; padding: .5rem .7rem; cursor: pointer; }
.autocomplete-item:hover, .autocomplete-item.actif { background: var(--surface-3); }
.autocomplete-item img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }
.autocomplete-item .prix { margin-left: auto; color: var(--red); font-weight: 700; font-size: 12px; }

/* Bloc totaux à droite */
.facture-totaux { display: flex; justify-content: flex-end; }
.facture-totaux > .ui-card { width: 400px; max-width: 100%; }
.tot-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; }
.tot-net { font: 800 24px var(--font); color: var(--red); }
.tot-lettres { text-align: right; font-size: 12px; font-style: italic; color: var(--text-3); margin-top: 4px; }
.pay-label { margin: 0; }
.pay-input { display: flex; align-items: center; gap: 6px; }
.pay-input .ui-input { width: 120px; text-align: right; }

/* Mobile (≤860, quand la tab bar apparaît) : infos en 2 colonnes, totaux pleine
   largeur, et chaque ligne de facture devient une fiche empilée (crochets cell-* et
   data-label) — plus de défilement horizontal. */
@media (max-width: 860px) {
  .facture-infos { grid-template-columns: 1fr 1fr; }
  /* N° + Date restent appairés ; les champs marqués .infos-pleine (Nom client,
     Téléphone, Caissier) passent pleine largeur. */
  .facture-infos .infos-pleine { grid-column: 1 / -1; }
  .facture-totaux > .ui-card { width: 100%; }
  .lignes thead { display: none; }
  .lignes, .lignes tbody { display: block; width: 100%; }
  .lignes tr.ligne {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px;
    position: relative; border: 1px solid var(--border); border-radius: 12px;
    padding: 12px; margin-bottom: 12px; background: #fff;
  }
  .lignes tr.ligne > td { display: block; padding: 0; border: 0; }
  .lignes tr.ligne > td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 4px;
    font: 700 .7rem var(--font); letter-spacing: .04em; text-transform: uppercase; color: var(--text-3);
  }
  .lignes tr.ligne > td.cell-designation { grid-column: 1 / -1; order: 1; }
  .lignes tr.ligne > td.cell-reference { order: 2; }
  .lignes tr.ligne > td.cell-unite { order: 3; }
  .lignes tr.ligne > td.cell-quantite { order: 4; }
  .lignes tr.ligne > td.cell-prix { order: 5; }
  .lignes tr.ligne > td.cell-photo { grid-column: 1 / -1; order: 6; display: flex; align-items: center; gap: 10px; }
  .lignes tr.ligne > td.cell-photo::before { margin-bottom: 0; }
  .lignes tr.ligne > td.cell-total {
    grid-column: 1 / -1; order: 7; display: flex; align-items: baseline; justify-content: space-between;
    margin-top: 2px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 1.1rem;
  }
  .lignes tr.ligne > td.cell-total::before {
    content: "Total"; margin-bottom: 0; font: 400 .9rem var(--font);
    text-transform: none; letter-spacing: normal; color: var(--text-3);
  }
  .lignes tr.ligne > td.cell-suppr { position: absolute; top: 8px; right: 8px; }
}

/* ============================================================
   Historique — tableau (desktop) / cartes compactes (mobile)
   ============================================================ */
/* Chrome desktop (liste / en-tête / ligne) mutualisé avec .ui-table (plus haut) ;
   ici uniquement l'alignement des cellules + la carte compacte mobile. */
.h-num { font-weight: 700; }
.h-client { font-weight: 600; }
.h-montant { text-align: right; font-weight: 700; }
.h-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

@media (max-width: 860px) {
  .hist-list { border: none; background: none; border-radius: 0; overflow: visible; }
  .hist-head { display: none; }
  .hist-item {
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "num date paiement"
      "client client client"
      "montant montant actions";
    gap: 4px 10px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 12px 14px; margin-bottom: 10px;
  }
  .hist-item.is-annulee { background: var(--surface-2); }
  .h-num { grid-area: num; }
  .h-date { grid-area: date; color: var(--text-3); font-size: 12.5px; align-self: center; }
  .h-paiement { grid-area: paiement; justify-self: end; align-self: center; text-align: right; }
  .h-client { grid-area: client; }
  .h-montant { grid-area: montant; align-self: center; }
  .h-actions { grid-area: actions; }
}

/* ============================================================
   Réglages / Gestion — grilles 2 colonnes
   ============================================================ */
.reglages-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 1100px; align-items: start; }
.gestion-grid { display: grid; grid-template-columns: 380px 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) {
  .reglages-grid, .gestion-grid { grid-template-columns: 1fr; }
}

/* Catalogue produits : grille de cartes */
.produits-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.produit-card { overflow: hidden; transition: box-shadow .15s; }
.produit-card:hover { box-shadow: var(--shadow-hover); }
.page-num { min-width: 38px; text-align: center; }
.page-num.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
@media (max-width: 1100px) { .produits-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px)  { .produits-grid { grid-template-columns: repeat(2, 1fr); } }

/* ============================================================
   Modale (vanilla, remplace Bootstrap)
   Ouverture : ajouter la classe .is-open sur .ui-modal.
   Fermeture générique : [data-modal-close] / fond / Échap (footer.php).
   ============================================================ */
.ui-modal { position: fixed; inset: 0; z-index: 50; display: none; }
.ui-modal.is-open { display: block; }
.ui-modal__backdrop { position: absolute; inset: 0; background: rgba(28, 25, 23, 0.45); }
.ui-modal__dialog {
  position: relative; background: var(--surface); border-radius: 14px;
  width: calc(100% - 32px); max-width: 520px; margin: 6vh auto; max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.ui-modal__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.ui-modal__title { font: 700 16px var(--font); margin: 0; }
.ui-modal__close { border: none; background: none; font-size: 24px; line-height: 1; color: var(--text-3); cursor: pointer; padding: 2px 8px; border-radius: 8px; }
.ui-modal__close:hover { background: var(--surface-3); color: var(--text); }
.ui-modal__body { padding: 18px; overflow-y: auto; }
.ui-modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); }

/* Bouton appareil-photo de la modale produit : tactile seulement (display géré
   par style.css : none par défaut, block en pointer:coarse) ; ici juste le look. */
.p-image-cam { border: 1px solid var(--border); border-radius: var(--r-btn); background: #fff; min-height: 40px; font-size: 1.1rem; cursor: pointer; }

/* Zone de texte (ex. requête SQL de l'outil generer-pin) */
.ui-textarea { width: 100%; border: 1px solid var(--border); border-radius: var(--r-input); padding: 9px 11px; font: 500 13px var(--font); color: var(--text); }

/* ============================================================
   Facture : aperçu A4 (desktop) ↔ PDF (mobile)
   L'A4 (210mm) ne tient pas sur un téléphone : sur écran ≤860px on masque la
   feuille et on affiche le PDF (facture-pdf.php). Desktop ET impression inchangés
   (media « screen » uniquement, et le bloc PDF est .no-print).
   ============================================================ */
.facture-pdf-mobile { display: none; }
.facture-pdf-mobile iframe {
  width: 100%; height: 70vh; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface); margin-bottom: 10px;
}
@media screen and (max-width: 860px) {
  .feuille-a4--masquer-mobile { display: none; }
  .facture-pdf-mobile { display: block; }
}

/* ============================================================
   Tableau de bord (gestionnaire)
   ============================================================ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { padding: 16px 18px; }   /* la chrome (fond/bord/rayon) vient de .ui-card */
.stat__label { font: 600 12px var(--font); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.stat__value { font: 800 26px var(--font); letter-spacing: -0.01em; margin-top: 6px; }
.stat__value .u { font-size: 15px; font-weight: 700; color: var(--text-3); }
.stat__sub { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.stat--link { text-decoration: none; color: inherit; display: block; }   /* tuile cliquable (filtre) */
.ui-card__title--tight { margin-bottom: 12px; }

.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .dash-cols { grid-template-columns: 1fr; } }

/* Barres horizontales (magnitude, mono-teinte) : encaissements par moyen, etc. */
.bar-row { display: grid; grid-template-columns: 116px 1fr auto; align-items: center; gap: 12px; padding: 7px 0; }
.bar-track { height: 10px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--red); border-radius: 99px; min-width: 2px; }
.bar-val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Graphe SVG (CA par jour) */
.chart { width: 100%; height: auto; display: block; }
.chart .baseline { stroke: var(--border); stroke-width: 1; }
.chart .grid { stroke: var(--row-sep); stroke-width: 1; }
.chart .bar { fill: var(--red); }
.chart text { fill: var(--text-3); font: 500 10px var(--font); }

/* ============================================================
   Menu d'actions « kebab » (⋮)
   Le menu est en position:fixed (positionné par footer.php) → jamais rogné par
   l'overflow des tableaux. Ouverture/fermeture gérées en vanilla (footer.php).
   ============================================================ */
.kebab { display: inline-block; }
/* Le markup pose .ui-btn.ui-btn--secondary (fond, bordure, hover) ; ici on ne
   surcharge que le carré à glyphe. */
.kebab__btn { width: 34px; height: 34px; padding: 0; font-size: 20px; }
.kebab.is-open .kebab__btn { border-color: var(--red); color: var(--red); }
.kebab__menu {
  position: fixed; z-index: 60; display: none;
  min-width: 190px; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 8px 24px rgba(28, 25, 23, 0.16); padding: 6px;
}
.kebab.is-open .kebab__menu { display: block; }
.kebab__item {
  display: block; width: 100%; box-sizing: border-box; text-align: left;
  background: none; border: none; padding: 10px 12px; border-radius: 8px;
  font: 500 14px var(--font); color: var(--text); cursor: pointer; text-decoration: none;
}
.kebab__item:hover { background: var(--surface-3); }
.kebab__item--danger { color: var(--red); }

/* ============================================================
   Impression : ne montrer que la feuille de facture
   ============================================================ */
@media print {
  .sidebar, .tabbar, .mobile-topbar, .app-footer, .menu-toggle, .no-print { display: none !important; }
  .app { display: block; }
  .ui-main { padding: 0; }
}
