/* Thème unique : fond bleu marine, accent bordeaux.
   --accent (bordeaux foncé) sert de FOND (boutons) ; --accent-ink (bordeaux éclairci) sert au texte et aux traits,
   le bordeaux foncé n'étant pas assez contrasté sur le marine. Séries des graphiques validées
   (validate_palette.js, mode sombre, surface #12264a) : #e0607e / #4a8ee6. */
:root {
  color-scheme: dark;
  --page: #0a1630; --surface: #0e1d3d; --card: #12264a;
  --ink: #eef2fa; --ink-2: #c3cde0; --muted: #8a9bbd;
  --grid: #1d3460; --axis: #2c4675; --ring: rgba(255,255,255,.10);
  --s1: #e0607e; --s2: #4a8ee6; --track: #1d3460;
  --meter: #4a8ee6;
  --good: #0ca30c; --good-text: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --accent: #8c1c3a; --accent-ink: #e0607e;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page); color: var(--ink);
  padding: max(12px, env(safe-area-inset-top)) 14px calc(78px + env(safe-area-inset-bottom));
  max-width: 900px; margin: 0 auto;
}
code { font-size: 13px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px;
  padding-bottom: 10px; border-bottom: 2px solid var(--accent); }
h1 { font-size: 20px; margin: 0; }
.sub { color: var(--ink-2); font-size: 13px; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); margin: 0 0 10px; }
.card { background: var(--card); border: 1px solid var(--ring); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.note { color: var(--muted); font-size: 13px; margin: 4px 2px 12px; }

.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--ring); white-space: nowrap; color: var(--ink-2); }
.pill.ok::before, .pill.bad::before { content: "●"; margin-right: 6px; }
.pill.ok::before { color: var(--good); }
.pill.bad::before { color: var(--critical); }

.tab { display: none; }
.tab.active { display: block; }

/* tuiles */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--card); border: 1px solid var(--ring); border-radius: 12px; padding: 12px; }
.tile .lbl { font-size: 13px; color: var(--ink-2); }
.tile .val { font-size: 28px; font-weight: 600; margin: 2px 0 6px; }
.tile .val small { font-size: 14px; font-weight: 400; color: var(--ink-2); }
.tile .foot { font-size: 12px; color: var(--muted); margin-top: 6px; min-height: 1em; }

/* barres de jauge */
.meter { height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: var(--meter); transition: width .4s; }
.meter.warning > i { background: var(--warning); }
.meter.critical > i { background: var(--critical); }
.lvl { font-size: 12px; font-weight: 600; margin-left: 6px; }
.lvl.warning { color: var(--ink); } .lvl.warning::before { content: "▲ "; color: var(--warning); }
.lvl.critical { color: var(--ink); } .lvl.critical::before { content: "✖ "; color: var(--critical); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt, .kv .k { color: var(--ink-2); }
.kv .v { text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; margin-top: 12px; }
.core { font-size: 12px; color: var(--ink-2); }
.core b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.core .meter { margin-top: 3px; height: 6px; }

.line { padding: 8px 0; border-top: 1px solid var(--grid); }
.line:first-child { border-top: 0; padding-top: 0; }
.line .head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 5px; font-size: 14px; }
.line .head span:last-child { color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; }

/* listes d'appareils */
.row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--grid); }
.row:first-child { border-top: 0; padding-top: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--axis); }
.dot.ok { background: var(--good); } .dot.bad { background: var(--critical); } .dot.warn { background: var(--warning); }
.row .name { flex: 1; min-width: 0; }
.row .name small { display: block; color: var(--ink-2); font-size: 12px; overflow-wrap: anywhere; }
.row .state { font-size: 13px; color: var(--ink-2); text-align: right; }
.empty { color: var(--muted); font-size: 14px; }

/* processus */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px; padding: 0 4px 6px; border-bottom: 1px solid var(--axis); }
td { padding: 7px 4px; border-bottom: 1px solid var(--grid); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.name { max-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* sélecteurs segmentés */
.seg { display: flex; gap: 4px; background: var(--track); padding: 3px; border-radius: 10px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; color: var(--ink-2); padding: 8px; border-radius: 8px; font: inherit; font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }

/* graphiques */
.chart h3 { font-size: 15px; margin: 0; }
.chart .legend { display: flex; gap: 14px; font-size: 13px; color: var(--ink-2); margin: 4px 0 8px; flex-wrap: wrap; }
.chart .legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.chart .plot { position: relative; height: 170px; touch-action: pan-y; }
.chart canvas { width: 100%; height: 100%; display: block; }
.chart .stats { font-size: 12px; margin-top: 8px; }
.chart .stats td { padding: 3px 4px; }
.tip {
  position: fixed; z-index: 10; pointer-events: none; background: var(--card); color: var(--ink);
  border: 1px solid var(--ring); border-radius: 8px; padding: 6px 9px; font-size: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,.18); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tip i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

/* alertes */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--ring); margin-bottom: 8px; background: var(--card); }
.alert .ic { font-weight: 700; }
.alert.critical .ic { color: var(--critical); } .alert.warning .ic { color: var(--warning); }
.alert small { display: block; color: var(--ink-2); }

.btn { display: block; width: 100%; text-align: center; background: var(--accent); color: #fff; text-decoration: none; padding: 12px; border-radius: 10px; font: inherit; font-weight: 600; margin-top: 10px; border: 0; cursor: pointer; }
.btn.ghost { background: none; color: var(--accent-ink); box-shadow: inset 0 0 0 1.5px var(--accent); }
.btn:disabled { opacity: .5; }
.mini { border: 0; background: var(--accent); color: #fff; font: inherit; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.mini.x { background: none; color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent); padding: 3px 8px; }
.input { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--axis); background: var(--surface); color: var(--ink); font: inherit; }
.banner { display: flex; align-items: center; gap: 10px; justify-content: space-between; background: var(--accent); color: #fff; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; }
.banner .mini { background: #fff; color: var(--accent); }
.qr { background: #fff; border-radius: 10px; padding: 8px; width: 220px; max-width: 100%; margin: 6px auto 0; }
.qr svg { display: block; width: 100%; height: auto; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; color: var(--ink-2); }

/* boîte de confirmation et messages */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal .box { background: var(--card); border: 1px solid var(--ring); border-radius: 14px; padding: 18px; width: 100%; max-width: 420px; margin-bottom: env(safe-area-inset-bottom); }
.modal h3 { margin: 0 0 6px; font-size: 17px; }
.modal p { margin: 0; color: var(--ink-2); }
.modal .row2 { display: flex; gap: 10px; }
.modal .row2 .btn { flex: 1; }
.toast { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--page); padding: 10px 14px; border-radius: 10px; font-size: 14px; max-width: 90vw; }
.toast[hidden] { display: none; }

/* navigation basse */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--ring);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabs button {
  flex: 1; max-width: 140px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px; cursor: pointer; position: relative;
}
.tabs .ico { font-size: 18px; line-height: 1.2; }
.tabs button.on { color: var(--accent-ink); font-weight: 600; }
.tabs button.on::before { content: ""; position: absolute; top: -6px; left: 25%; right: 25%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent-ink); }
.badge { position: absolute; top: 0; right: calc(50% - 22px); background: var(--critical); color: #fff; border-radius: 999px; font-size: 10px; padding: 0 5px; line-height: 16px; min-width: 16px; }
