/* Forge — charte SHAU : fond #05070d, bleu #2f6bff, Inter. Sombre par défaut, clair au choix. */
:root {
  --bg: #05070d; --panel: #0c1220; --panel2: #111a2e; --line: #1c2741; --text: #e6ebf5; --muted: #8e99b0;
  --blue: #2f6bff; --blue2: #4d82ff; --violet: #a679f0; --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444;
  --grid: #1a2338; --shadow: 0 1px 0 rgba(255,255,255,.03), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #eef1f7; --panel: #ffffff; --panel2: #f5f7fb; --line: #dde3ee; --text: #0b1220; --muted: #5b667d;
  --grid: #e6ebf3; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 6px 18px rgba(15,23,42,.06);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--blue2); }
.muted { color: var(--muted); } .small { font-size: 12px; }
button { font: inherit; cursor: pointer; }

/* ---- en-tête */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: flex; gap: 18px; align-items: center;
  padding: 12px 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 800; letter-spacing: .06em; font-size: 18px; }
.brand span { color: var(--blue); }
nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
nav button { background: none; border: 0; color: var(--muted); padding: 7px 12px; border-radius: 9px; }
nav button:hover { color: var(--text); background: var(--panel2); }
nav button.on { color: var(--text); background: var(--panel2); box-shadow: inset 0 -2px 0 var(--blue); }
.tools { display: flex; gap: 8px; align-items: center; }
.tools form { margin: 0; }
.ghost { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 5px 10px; }

main { padding: 18px 20px 40px; max-width: 1500px; margin: 0 auto; }
.tab { display: none; } .tab.on { display: block; }

/* ---- grilles et cartes */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-bottom: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { margin: 0 0 10px; font-size: 14px; font-weight: 650; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.card h3 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.kpi { background: var(--panel2); border-radius: 10px; padding: 10px 12px; }
.kpi b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 9px; border-radius: 99px;
  background: var(--panel2); border: 1px solid var(--line); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); flex: 0 0 auto; margin-top: 5px; }
.pill .dot, .legend .dot, .tip .dot { margin-top: 0; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); } .dot.run { background: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 25%, transparent); }

/* ---- jauges */
.gauge { margin: 8px 0 12px; }
.gauge .lbl { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.gauge .bar { height: 10px; background: var(--panel2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.gauge .bar i { display: block; height: 100%; background: var(--blue); border-radius: 99px; transition: width .4s; }
.gauge .bar i.warn { background: var(--warn); } .gauge .bar i.bad { background: var(--bad); }

/* ---- alertes */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; background: var(--panel2); margin-bottom: 6px; }
.alert.critique { border-left: 3px solid var(--bad); } .alert.attention { border-left: 3px solid var(--warn); }
.none { color: var(--muted); font-style: italic; }

/* ---- tableaux */
.tbl { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:hover td { background: var(--panel2); }
td.num, th.num { text-align: right; white-space: nowrap; }
td.wrap { max-width: 520px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
pre.box { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto;
  font-size: 12px; line-height: 1.5; margin: 0; white-space: pre-wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.filters button, .seg button { background: var(--panel2); border: 1px solid var(--line); color: var(--muted); border-radius: 99px; padding: 4px 11px; font-size: 12px; }
.filters button.on, .seg button.on { color: #fff; background: var(--blue); border-color: var(--blue); }
.seg { display: inline-flex; gap: 4px; }

/* ---- graphiques */
svg.chart { width: 100%; display: block; }
svg.chart .grid line { stroke: var(--grid); }
svg.chart text { fill: var(--muted); font-size: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tip { position: fixed; pointer-events: none; z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; font-size: 12px; box-shadow: var(--shadow); max-width: 320px; }

/* ---- connexion */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-card .brand { font-size: 24px; }
.auth-card label { display: block; font-size: 13px; color: var(--muted); margin: 18px 0 6px; }
.auth-card input { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: inherit; }
.auth-card button { width: 100%; margin-top: 14px; padding: 11px; border: 0; border-radius: 10px; background: var(--blue); color: #fff; font-weight: 600; }
.auth-card button:hover { background: var(--blue2); }

textarea { width: 100%; font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; resize: vertical; }
button.primary, button.choose { margin-top: 8px; background: var(--blue); color: #fff; border: 0; border-radius: 9px; padding: 8px 14px; font-weight: 600; }
button.primary:hover, button.choose:hover { background: var(--blue2); }
details summary { cursor: pointer; color: var(--blue2); }
ul.small { padding-left: 18px; margin: 6px 0; } ul.small li { margin-bottom: 4px; }

/* ---- téléphone : onglets défilants, une colonne, colonnes secondaires masquées */
@media (max-width: 760px) {
  .grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .top { padding: 10px 14px 0; gap: 8px; }
  .brand { flex: 1; }
  nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 0 -14px; padding: 0 10px 8px; }
  nav::-webkit-scrollbar { display: none; }
  nav button { flex: 0 0 auto; padding: 7px 11px; font-size: 14px; }
  #maj { display: none; }
  main { padding: 12px 12px 32px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 14px 12px; border-radius: 12px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi b { font-size: 18px; }
  .hide-m { display: none; }
  td, th { padding: 7px 6px; }
  td.wrap { max-width: none; }
  .gauge .lbl { flex-wrap: wrap; gap: 2px 8px; }
  .tip { max-width: 85vw; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
