/* AMP-Accueil — système visuel commun.
   Dense, lisible, sans espace perdu : grilles auto-ajustées, composants compacts, clair/sombre. */
:root {
  color-scheme: light;
  --fond: #f4f5f7;
  --fond-2: #eceef2;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #f0f2f5;
  --ligne: #e3e6eb;
  --ligne-forte: #cfd4dc;
  --encre: #0d1321;
  --encre-2: #4a5263;
  --encre-3: #7c8496;
  --accent: #0f766e;
  --accent-2: #0d9488;
  --accent-doux: #ccfbf1;
  --accent-encre: #ffffff;
  --bon: #0b8a0b;
  --bon-doux: #dcfce7;
  --attention: #b45309;
  --attention-doux: #fef3c7;
  --serieux: #c2410c;
  --critique: #c62828;
  --critique-doux: #fee2e2;
  --info: #1d4ed8;
  --info-doux: #dbeafe;
  --ombre-1: 0 1px 2px rgba(13, 19, 33, .06), 0 1px 1px rgba(13, 19, 33, .04);
  --ombre-2: 0 6px 24px -6px rgba(13, 19, 33, .14), 0 2px 6px rgba(13, 19, 33, .06);
  --ombre-3: 0 24px 64px -12px rgba(13, 19, 33, .28);
  --rayon: 10px;
  --rayon-s: 7px;
  --rayon-l: 16px;
  --police: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --serie-1: #2a78d6; --serie-2: #eb6834; --serie-3: #1baf7a; --serie-4: #eda100;
  --serie-5: #e87ba4; --serie-6: #008300; --serie-7: #6250d6; --serie-8: #e34948;
  --seq-0: #f0f4fa; --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95; --seq-7: #0d366b;
  --grille: #e7e9ee;
  --axe: #c3c7cf;
  --transition: 160ms cubic-bezier(.2, .7, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fond: #0b0f17; --fond-2: #0f1520; --surface: #121925; --surface-2: #161e2b; --surface-3: #1b2433;
    --ligne: #232d3d; --ligne-forte: #303c50; --encre: #eef1f6; --encre-2: #b4bccb; --encre-3: #7f8a9e;
    --accent: #2dd4bf; --accent-2: #14b8a6; --accent-doux: #0f3a37; --accent-encre: #04201d;
    --bon: #22c55e; --bon-doux: #0f2e1b; --attention: #f59e0b; --attention-doux: #33260b; --serieux: #fb923c;
    --critique: #f05252; --critique-doux: #3a1414; --info: #60a5fa; --info-doux: #13243f;
    --ombre-1: 0 1px 2px rgba(0, 0, 0, .4); --ombre-2: 0 8px 28px -8px rgba(0, 0, 0, .6); --ombre-3: 0 28px 70px -10px rgba(0, 0, 0, .7);
    --serie-1: #3987e5; --serie-2: #d95926; --serie-3: #199e70; --serie-4: #c98500; --serie-5: #d55181; --serie-6: #1f9d1f; --serie-7: #9085e9; --serie-8: #e66767;
    --seq-0: #141c29; --seq-1: #13305a; --seq-2: #184f95; --seq-3: #1c5cab; --seq-4: #2a78d6; --seq-5: #5598e7; --seq-6: #86b6ef; --seq-7: #cde2fb;
    --grille: #1f2837; --axe: #354155;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --fond: #0b0f17; --fond-2: #0f1520; --surface: #121925; --surface-2: #161e2b; --surface-3: #1b2433;
  --ligne: #232d3d; --ligne-forte: #303c50; --encre: #eef1f6; --encre-2: #b4bccb; --encre-3: #7f8a9e;
  --accent: #2dd4bf; --accent-2: #14b8a6; --accent-doux: #0f3a37; --accent-encre: #04201d;
  --bon: #22c55e; --bon-doux: #0f2e1b; --attention: #f59e0b; --attention-doux: #33260b; --serieux: #fb923c;
  --critique: #f05252; --critique-doux: #3a1414; --info: #60a5fa; --info-doux: #13243f;
  --ombre-1: 0 1px 2px rgba(0, 0, 0, .4); --ombre-2: 0 8px 28px -8px rgba(0, 0, 0, .6); --ombre-3: 0 28px 70px -10px rgba(0, 0, 0, .7);
  --serie-1: #3987e5; --serie-2: #d95926; --serie-3: #199e70; --serie-4: #c98500; --serie-5: #d55181; --serie-6: #1f9d1f; --serie-7: #9085e9; --serie-8: #e66767;
  --seq-0: #141c29; --seq-1: #13305a; --seq-2: #184f95; --seq-3: #1c5cab; --seq-4: #2a78d6; --seq-5: #5598e7; --seq-6: #86b6ef; --seq-7: #cde2fb;
  --grille: #1f2837; --axe: #354155;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--encre); font-family: var(--police);
  font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0 0 .5em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
.num, .tab { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.muet { color: var(--encre-3); }
.doux { color: var(--encre-2); }
.petit { font-size: 12px; }
.tres-petit { font-size: 11px; }
.gras { font-weight: 650; }
.cache { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---- disposition ---- */
.ligne { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ligne.haut { align-items: flex-start; }
.ligne.entre { justify-content: space-between; }
.ligne.env { flex-wrap: wrap; }
.colonne { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pousse { flex: 1 1 auto; min-width: 0; }
.grille { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(var(--min, 260px), 1fr)); }
.grille.serree { gap: 8px; }
.grille.tuiles { --min: 150px; }
.g2 { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .g2, .g3 { grid-template-columns: 1fr; } }
.ellipse { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- cartes ---- */
.carte {
  background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--rayon);
  box-shadow: var(--ombre-1); padding: 14px; min-width: 0;
}
.carte.plate { box-shadow: none; }
.carte > .titre { display: flex; align-items: center; gap: 8px; margin: -2px 0 10px; min-height: 24px; }
.carte > .titre h2, .carte > .titre h3 { flex: 1; min-width: 0; }
.carte .sous { color: var(--encre-3); font-size: 12px; font-weight: 450; }
.carte.compacte { padding: 10px 12px; }
.separateur { height: 1px; background: var(--ligne); margin: 10px 0; }

/* ---- tuiles chiffrées ---- */
.tuile { background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 11px 13px; min-width: 0; box-shadow: var(--ombre-1); }
.tuile .lib { color: var(--encre-2); font-size: 12px; font-weight: 550; display: flex; gap: 6px; align-items: center; }
.tuile .val { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; line-height: 1.1; }
.tuile .val small { font-size: 13px; font-weight: 550; color: var(--encre-2); margin-left: 2px; letter-spacing: 0; }
.tuile .pied { margin-top: 4px; font-size: 12px; color: var(--encre-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.delta { font-size: 12px; font-weight: 650; padding: 1px 6px; border-radius: 99px; display: inline-flex; align-items: center; gap: 3px; }
.delta.bon { color: var(--bon); background: var(--bon-doux); }
.delta.mauvais { color: var(--critique); background: var(--critique-doux); }
.delta.neutre { color: var(--encre-2); background: var(--surface-3); }

/* ---- boutons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 13px;
  border-radius: var(--rayon-s); border: 1px solid var(--ligne-forte); background: var(--surface); color: var(--encre);
  font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; user-select: none;
  transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn:hover { background: var(--surface-2); border-color: var(--encre-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primaire { background: var(--accent); border-color: var(--accent); color: var(--accent-encre); box-shadow: 0 1px 0 rgba(255,255,255,.15) inset, var(--ombre-1); }
.btn.primaire:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--critique); border-color: color-mix(in srgb, var(--critique) 40%, var(--ligne)); }
.btn.danger:hover { background: var(--critique-doux); }
.btn.fantome { border-color: transparent; background: transparent; }
.btn.fantome:hover { background: var(--surface-3); }
.btn.petit { height: 28px; padding: 0 9px; font-size: 12px; }
.btn.grand { height: 46px; padding: 0 20px; font-size: 15px; border-radius: var(--rayon); }
.btn.icone { width: 34px; padding: 0; }
.btn.petit.icone { width: 28px; }
.btn svg { width: 16px; height: 16px; flex: none; }
.groupe-btn { display: inline-flex; border: 1px solid var(--ligne-forte); border-radius: var(--rayon-s); overflow: hidden; background: var(--surface); }
.groupe-btn > button { border: 0; background: transparent; height: 30px; padding: 0 11px; font-weight: 600; font-size: 12.5px; cursor: pointer; color: var(--encre-2); }
.groupe-btn > button + button { border-left: 1px solid var(--ligne); }
.groupe-btn > button.actif { background: var(--accent-doux); color: var(--accent); }
:root[data-theme="dark"] .groupe-btn > button.actif { color: var(--accent); }

/* ---- champs ---- */
.champ { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.champ > label, .champ > .lib { font-size: 12px; font-weight: 600; color: var(--encre-2); }
.champ .aide { font-size: 11.5px; color: var(--encre-3); }
.entree, select.entree, textarea.entree {
  height: 34px; padding: 0 10px; border-radius: var(--rayon-s); border: 1px solid var(--ligne-forte); background: var(--surface);
  min-width: 0; width: 100%; transition: border-color var(--transition), box-shadow var(--transition);
}
textarea.entree { height: auto; padding: 8px 10px; resize: vertical; }
.entree:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.entree.court { width: 90px; }
input[type="color"].entree { padding: 2px; width: 46px; }
.interrupteur { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 550; user-select: none; }
.interrupteur input { appearance: none; width: 34px; height: 20px; border-radius: 99px; background: var(--ligne-forte); position: relative; cursor: pointer; transition: background var(--transition); flex: none; margin: 0; }
.interrupteur input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--ombre-1); transition: transform var(--transition); }
.interrupteur input:checked { background: var(--accent); }
.interrupteur input:checked::after { transform: translateX(14px); }
.reglage { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--ligne); }
.reglage:last-child { border-bottom: 0; }
.reglage .t { font-weight: 600; }
.reglage .d { grid-column: 1; color: var(--encre-3); font-size: 12px; }
.reglage > .c { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 6px; align-items: center; }

/* ---- pastilles ---- */
.pastille { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--encre-2); white-space: nowrap; }
.pastille .point { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.pastille.bon { background: var(--bon-doux); color: var(--bon); }
.pastille.attention { background: var(--attention-doux); color: var(--attention); }
.pastille.critique { background: var(--critique-doux); color: var(--critique); }
.pastille.info { background: var(--info-doux); color: var(--info); }
.pastille.accent { background: var(--accent-doux); color: var(--accent); }
.code-ticket { font-family: var(--mono); font-weight: 750; letter-spacing: .02em; }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--ligne-forte); border-bottom-width: 2px; background: var(--surface-2); color: var(--encre-2); }

/* ---- tableaux ---- */
.tableau { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tableau th { text-align: left; font-weight: 600; font-size: 11.5px; color: var(--encre-3); text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px; border-bottom: 1px solid var(--ligne); background: var(--surface); position: sticky; top: 0; z-index: 1; }
.tableau td { padding: 7px 8px; border-bottom: 1px solid var(--ligne); vertical-align: middle; }
.tableau tr:last-child td { border-bottom: 0; }
.tableau tbody tr:hover td { background: var(--surface-2); }
.tableau .d { text-align: right; font-variant-numeric: tabular-nums; }
.defile { overflow: auto; min-height: 0; }

/* ---- onglets ---- */
.onglets { display: flex; gap: 2px; border-bottom: 1px solid var(--ligne); overflow-x: auto; scrollbar-width: none; }
.onglets button { border: 0; background: none; padding: 9px 12px; font-weight: 600; color: var(--encre-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 13px; }
.onglets button:hover { color: var(--encre); }
.onglets button.actif { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- notifications, fenêtres ---- */
#toasts { position: fixed; z-index: 1000; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 460px); }
.toast { pointer-events: auto; background: var(--encre); color: var(--surface); padding: 10px 14px; border-radius: var(--rayon); box-shadow: var(--ombre-3); font-weight: 550; display: flex; gap: 10px; align-items: center; animation: entree .22s ease-out; max-width: 100%; }
.toast.erreur { background: var(--critique); color: #fff; }
.toast.ok { background: var(--bon); color: #fff; }
@keyframes entree { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.voile { position: fixed; inset: 0; background: rgba(8, 12, 20, .5); backdrop-filter: blur(3px); z-index: 900; display: grid; place-items: center; padding: 16px; animation: fondu .15s ease-out; }
@keyframes fondu { from { opacity: 0; } }
.fenetre { background: var(--surface); border-radius: var(--rayon-l); box-shadow: var(--ombre-3); width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: entree .2s ease-out; border: 1px solid var(--ligne); }
.fenetre.large { width: min(900px, 100%); }
.fenetre > header { padding: 14px 16px 10px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--ligne); }
.fenetre > header h2 { flex: 1; }
.fenetre > .corps { padding: 14px 16px; overflow: auto; }
.fenetre > footer { padding: 10px 16px 14px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--ligne); }

/* ---- infobulle des graphiques ---- */
.bulle { position: fixed; z-index: 950; pointer-events: none; background: var(--surface); color: var(--encre); border: 1px solid var(--ligne-forte); box-shadow: var(--ombre-2); border-radius: 8px; padding: 7px 9px; font-size: 12px; min-width: 120px; max-width: 280px; transition: opacity .08s; }
.bulle .t { font-weight: 650; margin-bottom: 3px; }
.bulle .l { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.bulle .l .k { display: inline-flex; align-items: center; gap: 5px; color: var(--encre-2); }
.bulle .l .v { font-weight: 650; font-variant-numeric: tabular-nums; }
.bulle .m { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }

/* ---- graphiques ---- */
.graphe { position: relative; width: 100%; min-height: 120px; }
.graphe svg { overflow: visible; }
.graphe .axe text, .graphe text.axe { fill: var(--encre-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.graphe .grille-l { stroke: var(--grille); stroke-width: 1; }
.graphe .base-l { stroke: var(--axe); stroke-width: 1; }
.legende { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--encre-2); margin-bottom: 6px; }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.legende i.carre { width: 10px; height: 10px; border-radius: 3px; }
.legende i.tirets { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px) !important; }

/* ---- squelettes ---- */
.squelette { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: luire 1.2s linear infinite; border-radius: 6px; min-height: 14px; }
@keyframes luire { to { background-position: -200% 0; } }

.vide { padding: 22px 12px; text-align: center; color: var(--encre-3); font-size: 13px; }
.vide svg { width: 30px; height: 30px; margin: 0 auto 6px; opacity: .6; }

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