:root {
  --ink: #15171C;
  --muted: #5B6170;
  --ground: #F4F5F7;
  --surface: #FFFFFF;
  --line: #E3E5EA;
  --line-soft: #ECEEF2;
  --accent: #2448C9;
  --accent-ink: #1F44B8;
  --accent-soft: #DCE4FA;
  --accent-pale: #C7D2F3;
  --warn: #C2410C;
  --warn-ink: #B4400B;
  --warn-dark: #8A3208;
  --warn-soft: #FBE3D3;
  --warn-pale: #FFF6F0;
  --warn-line: #F3C9AE;
  --side: #15171C;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: 'IBM Plex Sans', system-ui, sans-serif; font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
a:hover { color: #1A3596; }
h1, h2 { margin: 0; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.up { color: var(--accent-ink); font-weight: 600; }
.down { color: var(--warn-ink); font-weight: 600; }
.neutre { color: var(--muted); }

/* ---- Structure ---- */
.app { display: flex; min-height: 100vh; }
.sidebar { flex: 0 0 232px; background: var(--side); color: #E8EAEE; padding: 24px 16px; display: flex; flex-direction: column; gap: 4px; }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 8px; color: #C9CDD6; text-decoration: none; font-size: 14px; }
.sidebar a:hover { background: #20242C; color: #FFF; }
.sidebar a.active { background: #262A33; color: #FFF; font-weight: 500; }
.sidebar-foot { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid #2F343E; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #A3A9B6; }
.sidebar-foot a { padding: 6px 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; }
.brand span:last-child { display: flex; flex-direction: column; }
.brand small { font-size: 12px; color: #A3A9B6; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #FFF; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.brand.dark small { color: var(--muted); }

.main { flex: 1; min-width: 0; padding: 28px 40px 48px; display: flex; flex-direction: column; gap: 22px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
.eyebrow { font-size: 13px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }

.filtres { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.filtres label { font-size: 13px; color: var(--muted); }
select, input[type=text], input[type=email], input[type=password], input:not([type]) {
  height: 44px; padding: 0 12px; border: 1px solid #D5D8DF; border-radius: 8px; background: #FFF; font: inherit; font-size: 14px; color: var(--ink);
}
.btn { height: 44px; padding: 0 16px; border: 1px solid #D5D8DF; border-radius: 8px; background: #FFF; font: inherit; font-size: 14px; color: var(--ink); display: inline-flex; align-items: center; gap: 8px; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #AEB4C0; color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #FFF; font-weight: 600; }
.btn-primary:hover { background: #1A3596; color: #FFF; }

.flash { padding: 12px 16px; border-radius: 8px; font-size: 14px; background: var(--accent-soft); }
.flash-erreur { background: var(--warn-soft); color: var(--warn-dark); }

/* ---- Cartes ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.card.flush { padding: 0; gap: 0; overflow: hidden; }
.card h2 { font-size: 17px; font-weight: 600; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-head.pad { padding: 18px 22px; border-bottom: 1px solid var(--line-soft); }
.lien { font-size: 14px; font-weight: 500; align-self: flex-start; padding: 8px 0; }
.vide { align-items: flex-start; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }

/* Rang réseau */
.rang { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 24px; padding: 18px 22px; }
.rang-num .mono { font-size: 34px; font-weight: 600; }
.rang-num sup { font-size: 16px; color: var(--muted); }
.rang-barre { flex: 1 1 320px; display: flex; flex-direction: column; gap: 6px; }
.rang-barre .track { position: relative; height: 10px; border-radius: 5px; }
.rang-barre .fill { background: var(--accent-pale); border-radius: 5px; }
.rang-barre .mark { position: absolute; top: -5px; width: 4px; height: 20px; margin-left: -2px; border-radius: 2px; background: var(--accent); }
.rang-legende { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.rang p { margin: 0; max-width: 300px; }

/* Indicateurs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.kpi { gap: 10px; padding: 18px 20px; }
.kpi h2 { font-size: 13px; font-weight: 500; color: var(--muted); }
.kpi-val { font-size: 27px; font-weight: 600; }
.kpi-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.kpi-alerte { background: var(--warn-pale); border-color: var(--warn-line); }
.kpi-alerte h2 { color: var(--warn-dark); }

/* Barres horizontales */
.track { height: 14px; background: var(--line-soft); border-radius: 3px; overflow: visible; }
.fill { height: 100%; background: var(--accent); border-radius: 3px; }
.barres { display: grid; grid-template-columns: 120px minmax(0, 1fr) 96px 56px; gap: 10px 12px; align-items: center; font-size: 13px; }
td .track { height: 10px; }

/* Points d'attention */
.alertes { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.alertes li { display: flex; gap: 12px; padding: 12px 14px; border-radius: 8px; background: var(--warn-pale); }
.alertes li.alerte-up { background: #EEF2FC; }
.alertes li div { display: flex; flex-direction: column; gap: 2px; }
.alertes strong { font-size: 14px; }
.puce { flex: 0 0 8px; height: 8px; margin-top: 6px; border-radius: 4px; background: var(--warn); }
.alerte-up .puce { background: var(--accent); }

/* Stock */
.sparkbars { display: flex; align-items: flex-end; gap: 4px; height: 64px; }
.sparkbars div { flex: 1; background: var(--accent-pale); border-radius: 2px; min-height: 2px; }
.sparkbars div.courant { background: var(--accent); }
.mini { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; font-size: 13px; }
.mini dt { color: var(--muted); }
.mini dd { margin: 0; font-weight: 600; }
.colonnes { display: flex; gap: 10px; align-items: stretch; }
.col { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.col-zone { height: 220px; display: flex; align-items: flex-end; border-bottom: 1px solid #D5D8DF; padding-top: 20px; }
.col-barre { width: 100%; background: var(--accent-pale); border-radius: 4px 4px 0 0; display: flex; justify-content: center; min-height: 2px; }
.col-barre.courant { background: var(--accent); }
.col-barre span { font-size: 11px; margin-top: -18px; }
.col-label { font-size: 11px; color: var(--muted); text-align: center; }
.col-label.fort { color: var(--ink); font-weight: 600; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
.liste th, .liste td { padding: 10px 12px; text-align: left; border-top: 1px solid var(--line-soft); vertical-align: middle; }
.liste thead th { border-top: 0; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.liste tbody th { font-weight: 500; }
.liste .right { text-align: right; }
.w-34 { width: 34%; }

.matrice { min-width: 980px; }
.matrice thead th { background: #F7F8FA; padding: 14px 16px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; text-align: left; }
.matrice thead th.center { text-align: center; }
.matrice thead th.right { text-align: right; }
.matrice thead .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.matrice tbody tr { border-top: 1px solid var(--line-soft); }
.matrice tbody th { padding: 12px 16px; text-align: left; font-weight: 600; }
.matrice td { padding: 6px; font-family: var(--mono); font-size: 13px; }
.matrice td.right { padding: 12px 16px; text-align: right; }
.matrice tr.total { border-top: 2px solid var(--ink); background: #F7F8FA; }
.cell { border-radius: 6px; padding: 8px; text-align: center; background: #F1F2F5; white-space: nowrap; }
.cell .ref { color: var(--muted); }
.cell.n2 { background: var(--accent); color: #FFF; }
.cell.n1 { background: var(--accent-soft); }
.cell.n-1 { background: var(--warn-soft); }
.cell.n-2 { background: var(--warn); color: #FFF; }
.cell.n2 .ref, .cell.n-2 .ref { color: #FFF; opacity: 0.85; }
.cell.nx { color: var(--muted); }

.intro { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: center; }
.intro p { margin: 0; max-width: 640px; }
.legende { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--muted); }
.legende span { display: flex; align-items: center; gap: 6px; }
.legende i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.legende .n2 { background: var(--accent); }
.legende .n1 { background: var(--accent-soft); }
.legende .n-1 { background: var(--warn-soft); }
.legende .n-2 { background: var(--warn); }
.legende .l-mag { height: 3px; background: var(--accent); }
.legende .l-res { height: 0; border-top: 2px dashed #8A90A0; }

.courbe { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.courbe svg { width: 100%; height: auto; }
.serie-magasin { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.serie-reseau { fill: none; stroke: #8A90A0; stroke-width: 1.5; stroke-dasharray: 5 4; }
.pt-magasin { fill: var(--accent); }
.axe { font-size: 11px; fill: var(--muted); font-family: 'IBM Plex Sans', sans-serif; }

/* Import */
.depot { align-items: stretch; }
.depot-zone { border: 2px dashed #B7BECB; border-radius: 12px; padding: 28px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; cursor: pointer; color: var(--muted); }
.depot-zone strong { color: var(--ink); }
.depot input[type=file] { font: inherit; font-size: 14px; }
.depot .btn { align-self: flex-end; }
.fichiers { margin: 0; padding: 0; list-style: none; }
.fichiers li { display: grid; grid-template-columns: 28px minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 2fr); gap: 12px; align-items: center; padding: 12px 22px; border-top: 1px solid var(--line-soft); font-size: 14px; }
.fichiers .statut { width: 22px; height: 22px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: var(--accent-soft); color: #1A3596; }
.fichiers .st-alerte { background: var(--warn-pale); }
.fichiers .st-alerte .statut { background: var(--warn); color: #FFF; }
.fichiers .st-erreur .statut { background: #E8EAEE; color: var(--muted); }
.fichiers .resume { color: var(--muted); }
.fichiers .msg { font-size: 13px; color: var(--warn-dark); }
.actions { display: flex; justify-content: flex-end; gap: 12px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); }
.badge.st-alerte { background: var(--warn-soft); }
.badge.st-erreur { background: #E8EAEE; }

/* Admin */
.cases { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow: auto; }
.cases label, fieldset label, form.inline label { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; margin-right: 12px; }
.form { display: flex; flex-direction: column; gap: 6px; }
.form label { font-size: 13px; color: var(--muted); margin-top: 6px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; padding: 8px 12px; }
.form .btn { align-self: flex-start; margin-top: 8px; }
.recherche { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.row { display: flex; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.row-wrap label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.row input { flex: 1; }

/* Connexion */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login { width: 100%; max-width: 400px; }
.login .brand { padding: 0; }
.login form { display: flex; flex-direction: column; gap: 6px; }
.login label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.login .btn { margin-top: 16px; justify-content: center; }

/* Tableaux compacts, primes */
.matrice.compacte { min-width: 900px; }
.matrice.compacte td { padding: 4px 6px; }
.matrice.compacte tbody th { padding: 10px 16px; white-space: nowrap; }
.matrice tr.fort { background: #FAFBFD; }
.matrice tr.fort th { color: var(--accent-ink); }
.cell.nu { background: transparent; text-align: right; padding: 8px 4px; }
td.right .cell { text-align: right; }
.w-20 { width: 14%; min-width: 90px; }
.pad { padding: 18px 22px; }
.champs { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 18px; }
.champs div { display: flex; flex-direction: column; gap: 4px; }
.champs label { font-size: 13px; font-weight: 500; }
.champs input { width: 100%; }
.saisie input, .saisie select { height: 40px; width: 100%; min-width: 90px; }
.saisie td { padding: 6px 8px; }
input[type=month] { height: 44px; padding: 0 12px; border: 1px solid #D5D8DF; border-radius: 8px; font: inherit; }

.objectifs { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
.objectifs > div { display: flex; flex-direction: column; gap: 6px; }
.track.grand { height: 12px; border-radius: 6px; }
.fill-warn { background: var(--warn); }
@media (max-width: 860px) { .objectifs { grid-template-columns: 1fr; } }

/* Satisfaction */
.repartition { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--line-soft); }
.r-pro { background: var(--accent); } .r-pas { background: #B7BECB; } .r-det { background: var(--warn); }
.onglets { display: flex; gap: 4px; flex-wrap: wrap; }
.onglets a { padding: 8px 12px; border-radius: 999px; font-size: 13px; text-decoration: none; color: var(--muted); border: 1px solid var(--line); }
.onglets a.actif { background: var(--ink); color: #FFF; border-color: var(--ink); }
.verbatims { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.verbatims li { display: flex; gap: 14px; padding: 12px 14px; border-radius: 10px; background: #F7F8FA; border-left: 0; }
.verbatims li.v-det { background: var(--warn-pale); }
.verbatims p { margin: 4px 0 0; }
.v-note { flex: 0 0 36px; height: 36px; border-radius: 18px; display: flex; align-items: center; justify-content: center; font-weight: 600; background: var(--accent-soft); color: #1A3596; }
.v-det .v-note { background: var(--warn); color: #FFF; }
.v-pas .v-note { background: #E8EAEE; color: var(--ink); }

.bloc-sat { display: flex; flex-direction: column; gap: 16px; padding-top: 8px; scroll-margin-top: 16px; }
.titre-bloc { font-size: 21px; font-weight: 700; padding-bottom: 8px; border-bottom: 2px solid var(--ink); display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.card h3 { margin: 0; font-size: 16px; font-weight: 600; }
.sommaire { margin-bottom: -6px; }

/* ---- Téléphone ---- */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { flex: none; flex-direction: row; flex-wrap: wrap; padding: 10px 12px; gap: 2px; }
  .brand { padding: 0 8px 0 0; width: 100%; }
  .sidebar a { padding: 10px; font-size: 13px; }
  .sidebar-foot { display: none; }
  .main { padding: 20px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .barres { grid-template-columns: 90px minmax(0, 1fr) 50px; }
  .barres span.mono { display: none; }
  .fichiers li { grid-template-columns: 28px minmax(0, 1fr); }
  .fichiers .resume, .fichiers .msg { grid-column: 2; }
}

/* ---- Impression / export PDF (A4 paysage) ---- */
@page { size: A4 landscape; margin: 10mm; }
@media print {
  body { background: #FFF; font-size: 11px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sidebar, .no-print, .lien, .flash { display: none !important; }
  .main { padding: 0; gap: 10px; }
  .page-head h1 { font-size: 20px; }
  .card { padding: 12px; border-color: #CCC; break-inside: avoid; }
  .kpis { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .kpi-val { font-size: 18px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
  .matrice { min-width: 0; }
  .table-wrap { overflow: visible; }
}
