:root {
  --vert: #1e7b34;
  --vert-fonce: #145a25;
  --vert-doux: #e3f0e5;
  --orange: #f28c1b;
  --rouge: #c62828;
  --rouge-doux: #fdecea;
  --ambre-doux: #fff4e5;
  --fond: #f4f7f4;
  --carte: #ffffff;
  --gris: #f1f4f1;
  --texte: #1b1f1c;
  --texte-2: #5f6b62;
  --texte-3: #8a968d;
  --bord: #e3e8e4;
  --grille: #edf1ee;
  --ombre: 0 2px 10px rgba(0, 0, 0, 0.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; background: var(--fond); color: var(--texte); font-size: 14px; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muet { color: var(--texte-2); }
.petit { font-size: 12px; }

/* Logo */
.logo { position: relative; width: 42px; height: 42px; display: inline-block; flex: none; }
.logo i { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--vert); }
.logo i:nth-child(1) { left: 0; top: 14px; background: var(--orange); }
.logo i:nth-child(2) { left: 14px; top: 0; }
.logo i:nth-child(3) { left: 28px; top: 14px; }
.logo i:nth-child(4) { left: 14px; top: 28px; }
.logo i:nth-child(5) { left: 14px; top: 14px; background: #7bb661; }
.logo.petit { transform: scale(0.7); margin: -6px; }

/* Connexion */
.connexion { max-width: 400px; margin: 0 auto; padding: 64px 16px; }
.marque { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.marque p { margin: 2px 0 0; color: var(--texte-2); }
.aide { color: var(--texte-3); font-size: 12px; text-align: center; }

/* Mise en page */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.menu { background: #fff; border-right: 1px solid var(--bord); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.menu-marque { display: flex; gap: 12px; align-items: center; padding: 18px 18px 14px; }
.menu-marque div { display: flex; flex-direction: column; }
.menu-marque small { color: var(--texte-2); }
#nav { display: flex; flex-direction: column; padding: 8px; gap: 2px; }
#nav a { padding: 10px 12px; border-radius: 10px; color: var(--texte-2); text-decoration: none; font-weight: 600; }
#nav a:hover { background: var(--gris); }
#nav a.actif { background: var(--vert-doux); color: var(--vert); }
.menu-pied { margin-top: auto; padding: 16px 18px; border-top: 1px solid var(--bord); display: flex; flex-direction: column; gap: 4px; }
.page { padding: 28px 32px 60px; max-width: 1280px; width: 100%; }
.entete-page { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.entete-page h1 { margin-right: auto; }
.bandeau { background: var(--ambre-doux); border: 1px solid #f6d7a8; color: #7a4a00; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .menu { position: static; height: auto; }
  #nav { flex-direction: row; overflow-x: auto; }
  #nav a { white-space: nowrap; }
  .menu-pied { flex-direction: row; justify-content: space-between; }
  .page { padding: 18px 16px 48px; }
}

/* Composants */
.carte { background: var(--carte); border-radius: 14px; padding: 18px; box-shadow: var(--ombre); }
.btn { border: 0; border-radius: 10px; padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer; background: var(--gris); color: var(--texte); }
.btn:hover { filter: brightness(0.97); }
.btn.primaire { background: var(--vert); color: #fff; }
.btn.danger { background: var(--rouge-doux); color: var(--rouge); }
.btn.large { width: 100%; padding: 13px; margin-top: 6px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.lien { background: none; border: 0; padding: 0; color: var(--vert); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
label { display: block; font-weight: 600; font-size: 13px; color: var(--texte-2); margin-bottom: 12px; }
input, select, textarea { display: block; width: 100%; margin-top: 5px; font: inherit; color: var(--texte); padding: 9px 11px; border: 1px solid var(--bord); border-radius: 9px; background: #fff; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--vert-doux); border-color: var(--vert); }
.filtres { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filtres label { margin: 0; min-width: 150px; }
.erreur { background: var(--rouge-doux); color: var(--rouge); padding: 9px 12px; border-radius: 9px; font-weight: 600; }
.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .grille-2 { grid-template-columns: 1fr; } }

/* Pastilles */
.pastille { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--gris); color: var(--texte-2); }
.pastille.ok { background: var(--vert-doux); color: var(--vert); }
.pastille.ko { background: var(--rouge-doux); color: var(--rouge); }
.pastille.promo { background: var(--orange); color: #fff; }

/* Tableaux */
.tableau-wrap { background: #fff; border-radius: 14px; box-shadow: var(--ombre); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--grille); text-align: left; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--texte-2); background: #fafbfa; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td select { margin: 0; padding: 5px 8px; width: auto; }
.vide { padding: 28px; text-align: center; color: var(--texte-3); }

/* Tuiles KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: #fff; border-radius: 14px; padding: 16px; box-shadow: var(--ombre); }
.kpi small { color: var(--texte-2); display: block; font-weight: 600; }
.kpi b { display: block; font-size: 24px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--texte-3); font-size: 12px; }
.graphes { display: grid; grid-template-columns: 3fr 2fr; gap: 14px; margin-bottom: 18px; }
@media (max-width: 1000px) { .graphes { grid-template-columns: 1fr; } }
.graphe h3 { margin-bottom: 2px; }
.graphe p { margin: 0 0 10px; color: var(--texte-2); font-size: 12px; }
.graphe svg { display: block; width: 100%; height: auto; overflow: visible; }
.graphe .barre { fill: var(--vert); }
.graphe .barre:hover, .graphe .cible:hover + .barre { fill: var(--vert-fonce); }
.graphe .axe { fill: var(--texte-2); font-size: 11px; }
.graphe .grille { stroke: var(--grille); }
.graphe .base { stroke: #cfd8d1; }
.graphe .valeur { fill: var(--texte); font-size: 11px; font-weight: 600; }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1000px) { .deux { grid-template-columns: 1fr; } }

.infobulle { position: fixed; z-index: 30; pointer-events: none; background: var(--texte); color: #fff; padding: 7px 10px; border-radius: 8px; font-size: 12px; line-height: 1.4; box-shadow: var(--ombre); }

/* Offres dans le formulaire */
.offre-ligne { display: grid; grid-template-columns: 2fr 1.1fr 0.9fr 2fr auto; gap: 8px; align-items: end; padding: 10px; background: var(--gris); border-radius: 10px; margin-bottom: 8px; }
.offre-ligne label { margin: 0; }
@media (max-width: 760px) { .offre-ligne { grid-template-columns: 1fr 1fr; } }
.communes { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.commune { display: inline-flex; gap: 6px; align-items: center; background: var(--gris); border-radius: 99px; padding: 4px 6px 4px 12px; }
.commune button { border: 0; background: #fff; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; color: var(--texte-2); }

/* Modale */
.modale { border: 0; border-radius: 16px; padding: 0; width: min(860px, calc(100% - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.modale::backdrop { background: rgba(0, 0, 0, 0.35); }
.modale-tete { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--bord); position: sticky; top: 0; background: #fff; z-index: 1; }
.modale-corps { padding: 18px 20px; }
.modale-pied { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--bord); position: sticky; bottom: 0; background: #fff; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 22px; background: var(--vert-doux); color: var(--vert-fonce); padding: 14px; border-radius: 10px; text-align: center; letter-spacing: 1px; user-select: all; }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--texte); color: #fff; padding: 12px 16px; border-radius: 10px; font-weight: 600; z-index: 40; }
