/* =====================================================================================
   Spectral Market — PWA du propriétaire
   Même identité que la caisse : indigo → violet, Inter, chiffres tabulaires.
   Thème clair / sombre via [data-theme] (par défaut : réglage du téléphone).
   ===================================================================================== */

@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("../vendor/inter/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("../vendor/inter/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("../vendor/inter/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("../vendor/inter/inter-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 800; font-display: swap; src: url("../vendor/inter/inter-latin-800-normal.woff2") format("woff2"); }

:root {
  --indigo: #4f46e5;
  --indigo-fonce: #4338ca;
  --violet: #7c3aed;
  --degrade: linear-gradient(135deg, #4f46e5 0%, #6d3df0 55%, #7c3aed 100%);

  --fond: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --survol: #eef0fb;
  --ligne: #e6e8f2;
  --ligne-forte: #d5d8e8;
  --texte: #161a33;
  --texte-2: #4a5072;
  --texte-3: #8288a8;
  --primaire: #4f46e5;
  --primaire-doux: #eef0ff;
  --primaire-texte: #3f37c9;

  --succes: #047857;   --succes-doux: #e3f6ee;
  --alerte: #b45309;   --alerte-doux: #fdf2df;
  --danger: #be123c;   --danger-doux: #fde8ed;
  --info: #0369a1;     --info-doux: #e3f1fb;

  --ombre-1: 0 1px 2px rgba(22, 26, 51, .05), 0 1px 3px rgba(22, 26, 51, .04);
  --ombre-2: 0 2px 4px rgba(22, 26, 51, .04), 0 8px 24px rgba(40, 44, 90, .07);
  --ombre-3: 0 12px 40px rgba(40, 36, 120, .18);
  --ombre-hero: 0 14px 34px -10px rgba(79, 70, 229, .55);

  --r-s: 8px; --r-m: 12px; --r-l: 18px; --r-xl: 24px;
  --sidebar: 252px;
  --topbar: 64px;
  --bottomnav: 64px;
  --police: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --fond: #0d0f1f;
  --surface: #161933;
  --surface-2: #1b1f3c;
  --survol: #222748;
  --ligne: #262b4d;
  --ligne-forte: #343a63;
  --texte: #eceefb;
  --texte-2: #b3b8d8;
  --texte-3: #7f86ac;
  --primaire: #8b85ff;
  --primaire-doux: #262a5c;
  --primaire-texte: #aaa6ff;
  --succes: #34d399;   --succes-doux: #10382e;
  --alerte: #fbbf24;   --alerte-doux: #3a2d10;
  --danger: #fb7185;   --danger-doux: #3f1624;
  --info: #38bdf8;     --info-doux: #0f2e44;
  --ombre-1: 0 1px 2px rgba(0, 0, 0, .3);
  --ombre-2: 0 2px 6px rgba(0, 0, 0, .25), 0 10px 28px rgba(0, 0, 0, .28);
  --ombre-3: 0 16px 48px rgba(0, 0, 0, .55);
  --ombre-hero: 0 16px 36px -12px rgba(79, 70, 229, .6);
  color-scheme: dark;
}

/* --- Base ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--police); font-size: 15px; line-height: 1.5; color: var(--texte);
  background: var(--fond); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
a { color: var(--primaire-texte); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.06rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: 0 0 .75em; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2.5px solid var(--primaire); outline-offset: 2px; border-radius: 6px; }
.num, table td.num, .kpi-valeur, .hero-valeur { font-variant-numeric: tabular-nums; }
.muted { color: var(--texte-3); }
.petit { font-size: .82rem; }
.fort { font-weight: 700; }
.nowrap { white-space: nowrap; }
.vert { color: var(--succes); } .rouge { color: var(--danger); } .orange { color: var(--alerte); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 14px; border-radius: 8px; }
.skip:focus { left: 8px; }
.pile > * + * { margin-top: 20px; }
.ligne-flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.espace { flex: 1; }

/* --- Structure : barre latérale, en-tête, contenu --------------------------------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 40;
  background: var(--surface); border-right: 1px solid var(--ligne);
  display: flex; flex-direction: column; padding: 18px 14px 14px;
}
.marque { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; color: var(--texte); }
.marque:hover { text-decoration: none; }
.marque img { width: 40px; height: 40px; border-radius: 12px; box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .7); }
.marque-nom { font-weight: 800; font-size: 1.02rem; letter-spacing: -.02em; line-height: 1.15; }
.marque-boutique { display: block; font-size: .78rem; font-weight: 500; color: var(--texte-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }

.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.nav-titre { font-size: .76rem; font-weight: 600; color: var(--texte-3); padding: 16px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--r-m);
  color: var(--texte-2); font-weight: 550; font-size: .93rem; position: relative;
}
.nav a i { font-size: 1.12rem; width: 20px; text-align: center; color: var(--texte-3); }
.nav a:hover { background: var(--survol); color: var(--texte); text-decoration: none; }
.nav a.actif { background: var(--primaire-doux); color: var(--primaire-texte); font-weight: 650; }
.nav a.actif i { color: var(--primaire); }
.nav .compteur { margin-left: auto; background: var(--alerte-doux); color: var(--alerte); font-size: .74rem;
  font-weight: 700; border-radius: 99px; padding: 1px 8px; }

.sidebar-pied { border-top: 1px solid var(--ligne); padding-top: 12px; margin-top: 8px; display: grid; gap: 10px; }
.sync-carte { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--r-m); background: var(--surface-2);
  border: 1px solid var(--ligne); font-size: .8rem; color: var(--texte-2); line-height: 1.35; }
.point { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--texte-3); }
.point.ok { background: #10b981; box-shadow: 0 0 0 4px rgba(16, 185, 129, .16); }
.point.retard { background: #f59e0b; box-shadow: 0 0 0 4px rgba(245, 158, 11, .16); }
.point.ancienne, .point.jamais { background: #f43f5e; box-shadow: 0 0 0 4px rgba(244, 63, 94, .14); }
.utilisateur { display: flex; align-items: center; gap: 10px; padding: 4px 6px; color: var(--texte); border-radius: var(--r-m); }
.utilisateur:hover { background: var(--survol); text-decoration: none; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--degrade); color: #fff; font-weight: 700; font-size: .82rem; }
.utilisateur small { display: block; color: var(--texte-3); font-size: .76rem; }

.coque { margin-left: var(--sidebar); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar); display: flex; align-items: center; gap: 14px;
  padding: 0 28px; background: color-mix(in srgb, var(--fond) 82%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar.ombre { border-bottom-color: var(--ligne); }
.topbar-titre { min-width: 0; }
.topbar-titre h1 { font-size: 1.22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-titre .sous { font-size: .8rem; color: var(--texte-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .burger { display: none; }
.contenu { padding: 8px 28px 48px; max-width: 1360px; }

.drawer-voile { display: none; }
.bottomnav { display: none; }

/* --- Boutons, badges ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: var(--r-m); border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .9rem;
  cursor: pointer; white-space: nowrap; color: var(--texte); background: var(--surface); text-decoration: none !important;
  transition: background .15s, box-shadow .15s, transform .05s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn i { font-size: 1.05em; }
.btn-primaire { background: var(--indigo); color: #fff; box-shadow: 0 6px 16px -8px rgba(79, 70, 229, .9); }
.btn-primaire:hover { background: var(--indigo-fonce); }
.btn-contour { border-color: var(--ligne-forte); background: var(--surface); }
.btn-contour:hover { background: var(--survol); }
.btn-doux { background: var(--primaire-doux); color: var(--primaire-texte); }
.btn-doux:hover { filter: brightness(.97); }
.btn-fantome { background: transparent; color: var(--texte-2); }
.btn-fantome:hover { background: var(--survol); color: var(--texte); }
.btn-danger { background: var(--danger-doux); color: var(--danger); }
.btn-danger:hover { filter: brightness(.96); }
.btn-icone { width: 40px; padding: 0; }
.btn-petit { min-height: 32px; padding: 0 11px; font-size: .82rem; border-radius: 10px; }
.btn-bloc { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: .76rem;
  font-weight: 650; white-space: nowrap; background: var(--surface-2); color: var(--texte-2); border: 1px solid var(--ligne); }
.badge.succes { background: var(--succes-doux); color: var(--succes); border-color: transparent; }
.badge.alerte { background: var(--alerte-doux); color: var(--alerte); border-color: transparent; }
.badge.danger { background: var(--danger-doux); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-doux); color: var(--info); border-color: transparent; }
.badge.primaire { background: var(--primaire-doux); color: var(--primaire-texte); border-color: transparent; }

.var { display: inline-flex; align-items: center; gap: 3px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.var i { font-size: .9em; }
.var-bon { color: var(--succes); } .var-mauvais { color: var(--danger); } .var-neutre { color: var(--texte-3); }

/* --- Cartes -------------------------------------------------------------------------- */
.carte { background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--r-l); box-shadow: var(--ombre-1); min-width: 0; }
.carte-tete { display: flex; align-items: center; gap: 10px; padding: 16px 20px 0; flex-wrap: wrap; }
.carte-tete h2 { flex: 1; min-width: 0; }
.carte-tete .lien { font-size: .84rem; font-weight: 600; white-space: nowrap; }
.carte-corps { padding: 16px 20px 20px; }
.carte-corps.serre { padding: 8px 8px 10px; }
.carte-note { padding: 12px 20px; border-top: 1px solid var(--ligne); font-size: .82rem; color: var(--texte-3); }

.grille { display: grid; gap: 20px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-principale { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }

/* --- Le bandeau « Aujourd'hui » : écho du bloc « Total à payer » de la caisse ------ */
.hero {
  position: relative; overflow: hidden; color: #fff; border-radius: var(--r-xl); padding: 24px 26px;
  background: var(--degrade); box-shadow: var(--ombre-hero);
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 2fr); gap: 24px; align-items: center;
}
.hero::after {   /* bord de ticket dentelé, en bas */
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 10px; opacity: .22;
  background: radial-gradient(circle at 8px 10px, transparent 6px, #fff 6.5px) 0 0 / 16px 10px repeat-x;
}
.hero-libelle { font-size: .9rem; font-weight: 600; opacity: .85; }
.hero-valeur { font-size: clamp(2rem, 4.2vw, 2.9rem); font-weight: 800; letter-spacing: -.035em; line-height: 1.05; margin: 4px 0 8px; }
.hero .var { background: rgba(255, 255, 255, .16); color: #fff; padding: 3px 9px; border-radius: 99px; }
.hero-compare { font-size: .82rem; opacity: .8; margin-left: 6px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.hero-stat { background: rgba(255, 255, 255, .11); border: 1px solid rgba(255, 255, 255, .14); border-radius: var(--r-l); padding: 12px 14px; min-width: 0; }
.hero-stat span { display: block; font-size: .78rem; opacity: .82; }
.hero-stat strong { display: block; font-size: 1.22rem; font-weight: 750; letter-spacing: -.02em; margin: 2px 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.hero-stat .var { padding: 1px 7px; font-size: .72rem; }

/* --- Indicateurs ----------------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 16px 18px; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; }
.kpi-icone { grid-row: span 2; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem;
  background: var(--primaire-doux); color: var(--primaire); }
.kpi-icone.vert { background: var(--succes-doux); color: var(--succes); }
.kpi-icone.orange { background: var(--alerte-doux); color: var(--alerte); }
.kpi-icone.rouge { background: var(--danger-doux); color: var(--danger); }
.kpi-icone.bleu { background: var(--info-doux); color: var(--info); }
.kpi-libelle { font-size: .8rem; color: var(--texte-3); font-weight: 550; min-width: 0; }
.kpi-valeur { font-size: 1.32rem; font-weight: 780; letter-spacing: -.025em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-pied { grid-column: 1 / -1; font-size: .78rem; color: var(--texte-3); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }

/* --- Navigation de période --------------------------------------------------------- */
.barre-outils { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.periode { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--ligne);
  border-radius: 14px; padding: 4px; box-shadow: var(--ombre-1); }
.periode .fleche { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--texte-2); }
.periode .fleche:hover { background: var(--survol); text-decoration: none; }
.periode .fleche.off { opacity: .3; pointer-events: none; }
.periode-libelle { font-weight: 700; padding: 0 10px; min-width: 128px; text-align: center; white-space: nowrap; font-size: .92rem; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--ligne); border-radius: 12px; padding: 3px; }
.seg a, .seg button { padding: 6px 13px; border-radius: 9px; font-size: .84rem; font-weight: 600; color: var(--texte-2); border: 0;
  background: none; cursor: pointer; font-family: inherit; white-space: nowrap; }
.seg a:hover { text-decoration: none; color: var(--texte); }
.seg .actif { background: var(--surface); color: var(--primaire-texte); box-shadow: var(--ombre-1); }

/* --- Filtres et champs --------------------------------------------------------------- */
.filtres { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.recherche { position: relative; flex: 1 1 240px; max-width: 380px; }
.recherche i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--texte-3); }
.recherche input[type=search] { padding-left: 40px; }
input[type=text], input[type=search], input[type=number], input[type=password], input[type=email], input[type=tel],
input[type=date], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 13px; font: inherit; font-size: .94rem; color: var(--texte);
  background: var(--surface); border: 1px solid var(--ligne-forte); border-radius: var(--r-m); transition: border-color .15s, box-shadow .15s;
}
select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238288a8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; }
.filtres select { width: auto; min-width: 150px; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primaire); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primaire) 18%, transparent); }
input::placeholder, textarea::placeholder { color: var(--texte-3); }
.champ { display: grid; gap: 6px; min-width: 0; }
.champ label, .champ-libelle { font-size: .84rem; font-weight: 600; color: var(--texte-2); }
.champ .aide { font-size: .78rem; color: var(--texte-3); }
.champ .erreur, .erreur-champ { font-size: .8rem; color: var(--danger); font-weight: 550; }
.champ.invalide input, .champ.invalide select { border-color: var(--danger); }
.form-grille { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grille .large { grid-column: 1 / -1; }
.interrupteur { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; font-size: .9rem; }
.interrupteur input { appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--ligne-forte); position: relative;
  cursor: pointer; transition: background .2s; flex: none; margin: 0; }
.interrupteur input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.interrupteur input:checked { background: var(--indigo); }
.interrupteur input:checked::after { transform: translateX(18px); }
.choix-cartes { display: grid; gap: 10px; }
.choix-cartes label { display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px; border: 1px solid var(--ligne-forte);
  border-radius: var(--r-m); cursor: pointer; font-size: .9rem; font-weight: 550; }
.choix-cartes label:has(input:checked) { border-color: var(--primaire); background: var(--primaire-doux); }
.choix-cartes input { accent-color: var(--indigo); margin-top: 3px; }
.actions-form { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding-top: 6px; }

/* --- Tableaux (deviennent des cartes sur téléphone) ------------------------------- */
.table-zone { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .76rem; font-weight: 650; color: var(--texte-3); padding: 10px 14px; border-bottom: 1px solid var(--ligne);
  white-space: nowrap; background: var(--surface); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--ligne); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr.cliquable { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num, .table th.num { text-align: right; white-space: nowrap; }
.table .titre-ligne { font-weight: 650; color: var(--texte); }
.table .sous-ligne { display: block; font-size: .78rem; color: var(--texte-3); font-weight: 450; }
.table tr.annulee td { color: var(--texte-3); }
.table tr.annulee .titre-ligne { text-decoration: line-through; }
.table tfoot td { font-weight: 750; border-top: 2px solid var(--ligne-forte); }

/* Listes compactes (tableau de bord) */
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--r-m); }
.liste li + li { border-top: 1px solid var(--ligne); }
.liste a.li { display: flex; align-items: center; gap: 12px; color: inherit; flex: 1; min-width: 0; }
.liste a.li:hover { text-decoration: none; }
.liste .corps { flex: 1; min-width: 0; }
.liste .corps strong { display: block; font-weight: 650; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.liste .corps span { display: block; font-size: .78rem; color: var(--texte-3); }
.liste .droite { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; font-size: .9rem; }
.liste .droite small { display: block; font-weight: 500; color: var(--texte-3); font-size: .76rem; }
.pastille { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; font-size: 1rem;
  background: var(--surface-2); color: var(--texte-2); border: 1px solid var(--ligne); }
.pastille.vert { background: var(--succes-doux); color: var(--succes); border-color: transparent; }
.pastille.rouge { background: var(--danger-doux); color: var(--danger); border-color: transparent; }
.pastille.orange { background: var(--alerte-doux); color: var(--alerte); border-color: transparent; }
.pastille.primaire { background: var(--primaire-doux); color: var(--primaire); border-color: transparent; }

/* Barres de classement */
.classement li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 12px; }
.classement .rang { font-weight: 800; color: var(--texte-3); font-size: .84rem; text-align: center; }
.classement .nom { font-weight: 620; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.classement .val { font-weight: 720; font-variant-numeric: tabular-nums; font-size: .9rem; text-align: right; white-space: nowrap; }
.classement .barre { grid-column: 2 / -1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.classement .barre span { display: block; height: 100%; border-radius: 99px; background: var(--degrade); }
.classement .detail { grid-column: 2 / -1; font-size: .76rem; color: var(--texte-3); margin-top: -2px; }
.classement li:first-child .rang { color: var(--primaire); }

/* Graphiques */
.graphique { position: relative; height: 280px; }
.graphique.bas { height: 220px; }
.legende { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8rem; color: var(--texte-2); }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* États vides */
.vide { text-align: center; padding: 38px 20px; color: var(--texte-3); }
.vide i { font-size: 2rem; display: block; margin-bottom: 8px; color: var(--ligne-forte); }
.vide strong { display: block; color: var(--texte-2); font-size: .98rem; margin-bottom: 4px; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--ligne);
  font-size: .84rem; color: var(--texte-3); flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 6px; }

/* Messages */
.messages { position: fixed; z-index: 90; right: 22px; top: 18px; display: grid; gap: 10px; width: min(420px, calc(100vw - 28px)); }
.message { display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px 13px 16px; border-radius: var(--r-m); background: var(--surface);
  border: 1px solid var(--ligne); box-shadow: var(--ombre-3); font-size: .9rem; animation: entree .3s ease-out; }
.message i.ico { font-size: 1.15rem; margin-top: 1px; }
.message.success i.ico { color: var(--succes); } .message.error i.ico { color: var(--danger); }
.message.warning i.ico { color: var(--alerte); } .message.info i.ico { color: var(--info); }
.message p { margin: 0; flex: 1; }
.message button { background: none; border: 0; color: var(--texte-3); cursor: pointer; padding: 0 2px; font-size: 1rem; }
.message.sortie { opacity: 0; transform: translateY(-6px); transition: .25s; }
@keyframes entree { from { opacity: 0; transform: translateY(-8px); } }

.encart { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r-m); font-size: .88rem; align-items: flex-start; }
.encart i { font-size: 1.1rem; margin-top: 1px; }
.encart.info { background: var(--info-doux); color: var(--info); }
.encart.alerte { background: var(--alerte-doux); color: var(--alerte); }
.encart.danger { background: var(--danger-doux); color: var(--danger); }
.encart.succes { background: var(--succes-doux); color: var(--succes); }
.encart p { margin: 0; color: var(--texte); }
.encart strong { display: block; margin-bottom: 2px; }

/* --- Fenêtres (dialog) : affichées seulement quand elles sont ouvertes ----------- */
dialog.fenetre { border: 0; padding: 0; border-radius: var(--r-xl); background: var(--surface); color: var(--texte);
  width: min(480px, calc(100vw - 24px)); box-shadow: var(--ombre-3); max-height: calc(100vh - 40px); }
dialog.fenetre[open] { display: flex; flex-direction: column; animation: fenetre .22s ease-out; }
dialog.fenetre::backdrop { background: rgba(14, 16, 40, .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
@keyframes fenetre { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.fenetre-tete { display: flex; align-items: center; gap: 10px; padding: 20px 22px 4px; }
.fenetre-tete h2 { flex: 1; font-size: 1.1rem; }
.fenetre-corps { padding: 14px 22px; overflow-y: auto; display: grid; gap: 14px; }
.fenetre-pied { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px 20px; flex-wrap: wrap; }

/* --- Le ticket (détail d'une vente) ------------------------------------------------ */
.ticket {
  background: #fff; color: #23252f; border-radius: 6px 6px 0 0; padding: 26px 26px 34px; position: relative; max-width: 440px; margin: 0 auto;
  box-shadow: var(--ombre-2); font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .86rem;
}
.ticket::after { content: ""; position: absolute; left: 0; right: 0; bottom: -10px; height: 10px;
  background: linear-gradient(-45deg, transparent 6px, #fff 6px) 0 0 / 12px 10px repeat-x,
              linear-gradient(45deg, transparent 6px, #fff 6px) 0 0 / 12px 10px repeat-x; }
.ticket h2 { font-family: var(--police); text-align: center; font-size: 1.05rem; font-weight: 800; }
.ticket .centre { text-align: center; color: #6b6f80; font-size: .8rem; }
.ticket hr { border: 0; border-top: 1.5px dashed #c9cbd6; margin: 14px 0; }
.ticket .l { display: flex; justify-content: space-between; gap: 12px; }
.ticket .l + .l { margin-top: 6px; }
.ticket .art span:first-child { flex: 1; }
.ticket .qte { color: #6b6f80; font-size: .78rem; display: block; }
.ticket .total { font-size: 1.15rem; font-weight: 800; font-family: var(--police); letter-spacing: -.01em; }
.ticket.annule { opacity: .75; }
.tampon { position: absolute; top: 46%; left: 50%; transform: translateX(-50%) rotate(-12deg); border: 3px solid #be123c; color: #be123c;
  font-family: var(--police); font-weight: 800; font-size: 1.4rem; padding: 4px 16px; border-radius: 8px; letter-spacing: .06em; opacity: .85; }

/* --- Connexion : fond entièrement aux couleurs de la marque ----------------------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--degrade); position: relative; overflow: hidden; }
.auth::before { content: ""; position: absolute; width: 900px; height: 900px; border-radius: 50%; right: -320px; top: -420px;
  background: radial-gradient(circle, rgba(255, 255, 255, .14), transparent 62%); }
.auth::after { content: ""; position: absolute; width: 700px; height: 700px; border-radius: 50%; left: -300px; bottom: -380px;
  background: radial-gradient(circle, rgba(16, 10, 70, .35), transparent 65%); }
.auth-boite { position: relative; z-index: 1; width: min(400px, 100%); text-align: center; color: #fff; }
.auth-boite img { width: 76px; height: 76px; border-radius: 22px; box-shadow: 0 18px 40px -14px rgba(10, 6, 60, .8); margin-bottom: 18px; }
.auth-boite h1 { font-size: 1.7rem; margin-bottom: 4px; }
.auth-boite > p { opacity: .82; margin-bottom: 26px; }
.auth-form { display: grid; gap: 12px; text-align: left; }
.auth-form input { min-height: 52px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .12);
  color: #fff; font-size: 1rem; padding: 12px 16px; }
.auth-form input::placeholder { color: rgba(255, 255, 255, .7); }
.auth-form input:focus { border-color: #fff; background: rgba(255, 255, 255, .18); box-shadow: 0 0 0 4px rgba(255, 255, 255, .18); }
.auth-form button { min-height: 52px; border-radius: 14px; border: 0; background: #fff; color: var(--indigo-fonce); font: inherit;
  font-weight: 750; font-size: 1rem; cursor: pointer; margin-top: 6px; box-shadow: 0 14px 30px -14px rgba(10, 6, 60, .9); }
.auth-form button:hover { background: #f1efff; }
.auth-erreur { background: rgba(255, 255, 255, .95); color: #be123c; border-radius: 12px; padding: 11px 14px; font-size: .88rem; font-weight: 600; }
.auth-pied { margin-top: 30px; font-size: .8rem; opacity: .7; }

/* --- Installation de l'application ---------------------------------------------- */
.installer-app { text-align: center; }
.installer-app img { width: 64px; height: 64px; border-radius: 18px; margin: 4px auto 6px; display: block; }
.etapes-ios { text-align: left; display: grid; gap: 8px; font-size: .9rem; color: var(--texte-2); margin: 0; padding-left: 20px; }

/* --- Pages d'erreur et hors ligne ----------------------------------------------- */
.page-message { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; }
.page-message .code { font-size: 5rem; font-weight: 800; letter-spacing: -.05em; background: var(--degrade); -webkit-background-clip: text;
  background-clip: text; color: transparent; line-height: 1; }
.page-message p { color: var(--texte-2); max-width: 420px; margin: 10px auto 22px; }

/* --- Relevé de trésorerie ----------------------------------------------------- */
.releve td.libelle { font-weight: 550; }
.releve tr.fort td { font-weight: 750; background: var(--surface-2); }
.releve tr.flux td.libelle { padding-left: 26px; color: var(--texte-2); }

.cle-affichee { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .95rem; padding: 14px; border-radius: var(--r-m);
  background: var(--surface-2); border: 1.5px dashed var(--primaire); word-break: break-all; user-select: all; }

/* --- Lignes de livraison ------------------------------------------------------ */
.lignes-livraison .ligne { display: grid; grid-template-columns: minmax(0, 1fr) 120px 140px 40px; gap: 10px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--ligne); }
.lignes-livraison .entete-lignes { padding: 8px 0 0; border: 0; }
.lignes-livraison .ligne .nom strong { display: block; font-size: .9rem; }
.lignes-livraison .ligne .nom small { color: var(--texte-3); font-size: .78rem; }
.selecteur { position: relative; }
.suggestions { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--ligne);
  border-radius: var(--r-m); box-shadow: var(--ombre-3); max-height: 300px; overflow-y: auto; padding: 6px; display: none; }
.suggestions.ouvert { display: block; }
.suggestions button { display: flex; width: 100%; text-align: left; gap: 10px; align-items: center; padding: 9px 12px; border: 0; background: none;
  border-radius: 9px; font: inherit; font-size: .9rem; color: var(--texte); cursor: pointer; }
.suggestions button:hover, .suggestions button.focus { background: var(--survol); }
.suggestions button small { margin-left: auto; color: var(--texte-3); white-space: nowrap; }

/* --- Rapport imprimable ------------------------------------------------------- */
.entete-impression { display: none; }

/* =====================================================================================
   Responsive
   ===================================================================================== */
@media (max-width: 1240px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-principale { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 18px; }
}

@media (max-width: 960px) {
  .sidebar { transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--ombre-3); width: min(300px, 86vw); }
  .menu-ouvert .sidebar { transform: none; }
  .drawer-voile { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(14, 16, 40, .45); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .menu-ouvert .drawer-voile { opacity: 1; pointer-events: auto; }
  .coque { margin-left: 0; }
  .topbar .burger { display: inline-flex; }
  .topbar { padding: 0 14px; gap: 8px; height: 58px; }
  .contenu { padding: 6px 14px calc(var(--bottomnav) + 28px + env(safe-area-inset-bottom)); }
  .g-2, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .grille { gap: 14px; }
  .pile > * + * { margin-top: 14px; }
  .masquer-mobile { display: none !important; }

  .bottomnav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    height: calc(var(--bottomnav) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border-top: 1px solid var(--ligne);
  }
  .bottomnav a, .bottomnav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: .7rem; font-weight: 600; color: var(--texte-3); background: none; border: 0; font-family: inherit; cursor: pointer; position: relative; }
  .bottomnav a:hover { text-decoration: none; }
  .bottomnav i { font-size: 1.28rem; line-height: 1; }
  .bottomnav .actif { color: var(--primaire); }
  .bottomnav .actif::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 4px 4px; background: var(--primaire); }

  .hero { padding: 20px; border-radius: var(--r-l); }
  .hero-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .hero-stat { padding: 10px; }
  .hero-stat strong { font-size: 1rem; }

  /* Tableaux → cartes empilées */
  table.table.empile thead { display: none; }
  table.table.empile, .table.empile tbody, .table.empile tr, .table.empile td { display: block; width: 100%; }
  .table.empile tbody tr { padding: 12px 14px; border-bottom: 1px solid var(--ligne); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; }
  .table.empile tbody tr:last-child { border-bottom: 0; }
  .table.empile td { padding: 0; border: 0; text-align: left !important; }
  .table.empile td[data-mobile="titre"] { grid-column: 1; }
  .table.empile td[data-mobile="montant"] { grid-column: 2; grid-row: 1; text-align: right !important; font-weight: 750; }
  .table.empile td[data-mobile="detail"] { grid-column: 1; font-size: .8rem; color: var(--texte-3); }
  .table.empile td[data-mobile="detail"]::before { content: attr(data-label) " : "; }
  .table.empile td[data-mobile="badge"] { grid-column: 2; grid-row: 2; text-align: right !important; align-self: start; }
  .table.empile td[data-mobile="cache"] { display: none; }
  .table.empile tfoot { display: none; }

  .lignes-livraison .ligne { grid-template-columns: minmax(0, 1fr) 1fr 40px; }
  .lignes-livraison .entete-lignes { display: none; }
  .lignes-livraison .ligne .nom { grid-column: 1 / -1; }
  .messages { top: auto; bottom: calc(var(--bottomnav) + 12px + env(safe-area-inset-bottom)); right: 14px; }
}

@media (max-width: 640px) {
  h1 { font-size: 1.3rem; }
  .topbar-titre h1 { font-size: 1.08rem; }
  .kpis { gap: 10px; }
  .kpi { padding: 13px; gap: 2px 10px; }
  .kpi-icone { width: 36px; height: 36px; font-size: 1.05rem; border-radius: 10px; }
  .kpi-valeur { font-size: 1.08rem; }
  .carte-tete { padding: 14px 16px 0; }
  .carte-corps { padding: 14px 16px 16px; }
  .form-grille { grid-template-columns: minmax(0, 1fr); }
  .barre-outils { gap: 8px; }
  .periode { width: 100%; justify-content: space-between; }
  .periode-libelle { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .seg { width: 100%; } .seg a, .seg button { flex: 1; text-align: center; padding: 7px 6px; }
  .filtres select { flex: 1 1 100%; min-width: 0; }
  .kpi-valeur { white-space: normal; overflow-wrap: anywhere; }
  .liste li { flex-wrap: wrap; }
  .liste .corps { flex: 1 1 150px; }
  .lignes-livraison .lbl-mobile { position: static; width: auto; height: auto; clip: auto; font-size: .75rem; color: var(--texte-3); }
  .recherche { max-width: none; flex-basis: 100%; }
  .hero-valeur { font-size: 2.2rem; }
  .hero-stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .hero-stat:last-child { grid-column: 1 / -1; }
  .graphique { height: 230px; }
  .ticket { padding: 22px 18px 30px; }
  .topbar .btn-texte { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =====================================================================================
   Impression (rapports, ticket)
   ===================================================================================== */
@media print {
  :root, [data-theme="dark"] { --fond: #fff; --surface: #fff; --surface-2: #f5f6fa; --texte: #111; --texte-2: #333; --texte-3: #666;
    --ligne: #ddd; --ligne-forte: #bbb; --primaire: #4338ca; --primaire-texte: #4338ca; }
  @page { size: A4; margin: 14mm 12mm; }
  body { background: #fff; font-size: 11.5px; }
  .sidebar, .topbar, .bottomnav, .barre-outils, .messages, .pas-imprimer, .drawer-voile, dialog { display: none !important; }
  .coque { margin: 0; }
  .contenu { padding: 0; max-width: none; }
  .entete-impression { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #4338ca; padding-bottom: 10px; margin-bottom: 16px; }
  .entete-impression h1 { font-size: 20px; }
  .carte, .hero { box-shadow: none !important; border: 1px solid #ddd; break-inside: avoid; }
  .hero { background: #fff !important; color: #111; border: 2px solid #4338ca; }
  .hero::after { display: none; }
  .hero .var, .hero-stat { background: #f5f6fa !important; color: #111 !important; border-color: #ddd !important; }
  .grille { gap: 12px; } .g-2 { grid-template-columns: 1fr 1fr; }
  .graphique { height: 200px; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  table.table.empile thead { display: table-header-group !important; }
  a { color: inherit; }
  .saut { break-before: page; }
}
