:root {
  --bg: #f4f5f7; --panel: #ffffff; --line: #dfe2e8; --text: #1b2230; --muted: #5d6676;
  --accent: #1f5fd1; --accent-text: #ffffff; --accent-soft: #e6eefc;
  --ok: #17803d; --off: #8a93a3; --danger: #c0312b; --warn: #a76200;
  --side: #17202e; --side-text: #c9d2e0; --side-active: #263449;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c; --panel: #1a202b; --line: #2c3442; --text: #e6e9ef; --muted: #98a2b3;
    --accent: #6ea0ff; --accent-text: #0c1320; --accent-soft: #1f2c44;
    --ok: #4cc27a; --off: #6c7686; --danger: #ff7a72; --warn: #e6a94a;
    --side: #0c1017; --side-text: #b3bdcc; --side-active: #1a2332;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 20px; margin: 0; font-weight: 650; }
h2 { font-size: 14px; margin: 0 0 12px; font-weight: 650; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }

/* Structure */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 18px 10px; display: flex; flex-direction: column; gap: 2px; }
.brand { color: #fff; font-weight: 650; font-size: 15px; padding: 4px 10px 16px; }
.side a { color: inherit; text-decoration: none; padding: 8px 10px; border-radius: 6px; display: block; }
.side a:hover { background: var(--side-active); }
.side a.on { background: var(--side-active); color: #fff; font-weight: 600; }
.side .grow { flex: 1; }
.side .who { padding: 10px; font-size: 13px; border-top: 1px solid var(--side-active); margin-top: 8px; }
.side .who button { margin-top: 8px; width: 100%; }
main { padding: 24px 28px 48px; min-width: 0; }
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head .sp { flex: 1; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; padding: 8px; }
  .brand, .side .grow { display: none; }
  .side .who { border: 0; margin: 0; padding: 0 6px; display: flex; align-items: center; gap: 8px; }
  .side .who button { margin: 0; width: auto; }
  main { padding: 16px; }
}

/* Contrôles */
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 6px 12px; border-radius: 6px; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { color: var(--danger); }
button.small { padding: 3px 8px; font-size: 13px; }
button:disabled { opacity: .55; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.field input:not([type=checkbox]), label.field textarea { width: 100%; }
label.check { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: var(--panel); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Panneaux et tuiles */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 14px; }
.tiles { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 14px; }
.tile .label { color: var(--muted); font-size: 13px; }
.tile .value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .sub { color: var(--muted); font-size: 12.5px; }
.cols2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); margin-top: 14px; }

/* Tableaux */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { margin-left: 4px; }
.empty { color: var(--muted); padding: 22px 4px; text-align: center; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--off); margin-right: 6px; }
.dot.on { background: var(--ok); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12.5px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.tag.live { background: transparent; border: 1px solid var(--ok); color: var(--ok); }
.tag.warn { background: transparent; border: 1px solid var(--warn); color: var(--warn); }
.tag.off { background: transparent; border: 1px solid var(--line); color: var(--muted); }

/* Graphique */
.chart svg { width: 100%; height: 190px; display: block; }
.chart .bar { fill: var(--accent); }
.chart .bar:hover { opacity: .75; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; }
.meter { height: 6px; background: var(--accent-soft); border-radius: 3px; min-width: 60px; }
.meter progress { display: none; }
progress.bar { width: 100%; height: 6px; appearance: none; border: 0; background: var(--accent-soft); border-radius: 3px; overflow: hidden; }
progress.bar::-webkit-progress-bar { background: var(--accent-soft); }
progress.bar::-webkit-progress-value { background: var(--accent); }
progress.bar::-moz-progress-bar { background: var(--accent); }

/* Connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 340px; }
.login h1 { margin-bottom: 4px; }
.login p { margin: 0 0 18px; }
.login button { width: 100%; padding: 8px; }
.error { color: var(--danger); margin: 0 0 12px; min-height: 1.4em; }

/* Dialogue et notification */
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); padding: 20px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { font-size: 16px; }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 6px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
#toast.show { opacity: 1; }

/* Déploiement */
.kv { display: grid; grid-template-columns: max-content 1fr max-content; gap: 8px 14px; align-items: center; }
.kv .v { overflow-wrap: anywhere; }
ol.steps { padding-left: 20px; margin: 0; }
ol.steps li { margin-bottom: 8px; }
.notice { border-left: 3px solid var(--warn); padding: 8px 12px; background: var(--panel); margin-bottom: 14px; border-radius: 0 6px 6px 0; }
