:root {
  --bg: #12181f;
  --panel: #1b2430;
  --panel-2: #222d3b;
  --line: #2e3a4a;
  --text: #e8edf3;
  --muted: #93a2b4;
  --accent: #4da3ff;
  --ok: #35c48a;
  --warn: #e8a33d;
  --danger: #ef5f5f;
  --radius: 10px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9;
    --panel: #ffffff;
    --panel-2: #eef2f7;
    --line: #d8e0ea;
    --text: #16202b;
    --muted: #5c6b7d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* ---------- Barre de navigation ---------- */

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}

.brand {
  font-weight: 700; text-decoration: none; color: var(--text);
  display: inline-flex; align-items: center; gap: 8px;
}
.brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
}

.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a {
  color: var(--muted); text-decoration: none; padding: 8px 12px;
  border-radius: var(--radius); font-size: 15px;
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.on { background: var(--panel-2); color: var(--text); font-weight: 600; }

.badge {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}

/* ---------- Mise en page ---------- */

.page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 64px; }
h1 { font-size: 26px; margin: 8px 0 20px; }
h2 { font-size: 19px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 22px 0 8px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.card.narrow, .narrow { max-width: 520px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.muted { color: var(--muted); }
.quote { color: var(--muted); font-style: italic; }

/* ---------- Etats ---------- */

.alert, .ok, .warn {
  padding: 10px 14px; border-radius: var(--radius); margin: 0 0 16px;
  border: 1px solid transparent;
}
.alert { background: rgba(239, 95, 95, .12); border-color: var(--danger); }
.ok    { background: rgba(53, 196, 138, .12); border-color: var(--ok); }
.warn  { background: rgba(232, 163, 61, .12); border-color: var(--warn); }

.status { font-size: 12px; padding: 2px 9px; border-radius: 999px; font-weight: 600; }
.status.on  { background: rgba(53, 196, 138, .18); color: var(--ok); }
.status.off { background: rgba(147, 162, 180, .18); color: var(--muted); }

.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.tag.block { background: rgba(239, 95, 95, .18); color: var(--danger); }
.tag.allow { background: rgba(53, 196, 138, .18); color: var(--ok); }
.tag.warn  { background: rgba(232, 163, 61, .18); color: var(--warn); }

tr.sev-alert td { background: rgba(239, 95, 95, .07); }
tr.sev-warn td  { background: rgba(232, 163, 61, .07); }
li.bad  { color: var(--danger); }
li.good { color: var(--muted); }

/* ---------- Formulaires ---------- */

label { display: block; margin: 14px 0 4px; font-size: 14px; color: var(--muted); }
label.check { display: flex; align-items: baseline; gap: 8px; color: var(--text); }
label.check input { width: auto; margin: 0; }

input, select, textarea {
  width: 100%; padding: 10px 12px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; font-size: 16px; /* 16px evite le zoom automatique sur iOS */
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; }
input.mini { width: 90px; }

button, .button {
  display: inline-block; padding: 10px 16px; margin-top: 12px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  min-height: 44px; /* cible tactile confortable */
}
button:hover, .button:hover { border-color: var(--accent); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #08121d; }
button.danger { color: var(--danger); }
button.link {
  background: none; border: none; padding: 4px 0; min-height: 0;
  color: var(--muted); text-decoration: underline; font-weight: 400;
}
button.link.danger { color: var(--danger); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.actions form { display: flex; gap: 8px; align-items: flex-end; margin: 0; }
.actions.wrap { gap: 8px; }
.inline-form { display: inline-block; margin-left: 12px; }

.row { display: flex; flex-wrap: wrap; gap: 12px; }
.row label { flex: 1 1 160px; }
.row-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 12px; }
.row-form input { flex: 1 1 220px; }

.quota-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.quota-grid label span { display: block; margin-bottom: 4px; }

/* ---------- Onglets & perimetres ---------- */

.tabs, .scopes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.tabs a, .scopes a {
  padding: 8px 14px; border-radius: var(--radius); text-decoration: none;
  color: var(--muted); background: var(--panel); border: 1px solid var(--line);
}
.tabs a.on, .scopes a.on { background: var(--accent); border-color: var(--accent); color: #08121d; font-weight: 700; }
.scopes { align-items: center; }

/* ---------- Tableaux ---------- */

table { width: 100%; border-collapse: collapse; margin-top: 8px; display: block; overflow-x: auto; }
thead th {
  text-align: left; font-size: 13px; color: var(--muted);
  border-bottom: 1px solid var(--line); padding: 8px 10px; white-space: nowrap;
}
tbody td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
table.editable td { padding: 4px; }
table.editable input, table.editable select { margin: 0; }
table form { margin: 0; }
table button { margin-top: 0; }

code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; }

/* ---------- Blocs specifiques ---------- */

.facts { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; }

.device header { margin-bottom: 12px; }
.device h2 { margin: 6px 0 2px; font-size: 18px; }
.device h2 a { color: var(--text); text-decoration: none; }

.request {
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between;
  align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--line);
}
.request:last-child { border-bottom: none; }

ul.plain { list-style: none; padding: 0; margin: 8px 0; }
ul.plain li { padding: 4px 0; }

ul.codes { list-style: none; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
ul.codes li { background: var(--panel-2); padding: 8px; border-radius: var(--radius); text-align: center; }

.code-big {
  font-family: ui-monospace, monospace; font-size: 34px; font-weight: 700;
  letter-spacing: .12em; text-align: center; padding: 18px;
  background: var(--panel-2); border-radius: var(--radius); margin: 16px 0 6px;
}
.qr { display: block; margin: 16px auto; border-radius: var(--radius); background: #fff; padding: 8px; }

ol { padding-left: 22px; }
ol li { margin-bottom: 8px; }
