:root {
  --bg: #f5f6fb;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --brand-soft: #eef2ff;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(17 24 39 / 4%), 0 8px 24px rgb(17 24 39 / 6%);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 8px 14px; font-weight: 600; font-size: 14px; cursor: pointer;
  transition: transform .12s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn:hover { border-color: #c7cbd6; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { box-shadow: 0 4px 14px rgb(79 70 229 / 35%); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgb(17 24 39 / 5%); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.plus { color: var(--ok); }
.btn.minus { color: var(--bad); }

input, select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(79 70 229 / 15%); }
input[type="color"] { padding: 2px; height: 42px; }
input[type="checkbox"] { width: auto; accent-color: var(--brand); }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: #374151; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: grid; gap: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }

/* ---- Authentification ---- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 500px at 20% -10%, #e0e7ff, transparent), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 32px; }
.auth-card .brand { margin-bottom: 22px; }
.error { color: var(--bad); font-size: 13px; min-height: 18px; }

/* ---- Structure ---- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; }
.brand img { width: 34px; height: 34px; }
header.top {
  position: sticky; top: 0; z-index: 5; backdrop-filter: blur(10px);
  background: rgb(245 246 251 / 85%); border-bottom: 1px solid var(--line);
}
.top-inner { max-width: 1180px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 16px; }
nav.tabs { display: flex; gap: 4px; margin-left: 12px; }
nav.tabs button { border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; font-weight: 600; color: var(--muted); cursor: pointer; }
nav.tabs button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.spacer { flex: 1; }
main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 16px; gap: 12px; flex-wrap: wrap; }
.section-head h2 { font-size: 22px; }

.pause-banner {
  display: flex; align-items: center; gap: 12px; background: var(--bad-soft); color: #991b1b;
  border: 1px solid #fecaca; padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 600;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgb(220 38 38 / 8%); } }

/* ---- Cartes enfant ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.child-head { display: flex; align-items: center; gap: 12px; }
.avatar { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px; flex: none; }
.child-head h3 { font-size: 18px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); }
.chip.ok { background: var(--ok-soft); color: #166534; }
.chip.warn { background: var(--warn-soft); color: #92400e; }
.chip.bad { background: var(--bad-soft); color: #991b1b; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.live .dot { animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }

.meter { display: flex; align-items: center; gap: 18px; margin: 18px 0; }
.ring { width: 112px; height: 112px; flex: none; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: #eef0f5; }
.ring .value { stroke-linecap: round; transition: stroke-dashoffset .8s cubic-bezier(.2,.8,.2,1), stroke .3s; }
.ring .label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .label b { font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; }
.ring .label span { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.facts { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.facts b { color: var(--ink); font-variant-numeric: tabular-nums; }

.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.devices-mini { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.dev { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 9px; border-radius: 8px; background: #f3f4f6; color: #374151; font-weight: 600; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; flex: none; }
.status-dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgb(22 163 74 / 15%); }
.status-dot.use { background: var(--brand); box-shadow: 0 0 0 3px rgb(79 70 229 / 18%); animation: blink 1.2s infinite; }
.status-dot.lock { background: var(--bad); }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 8px; }

/* ---- Tableaux ---- */
.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafafa; }
.table tr:last-child td { border-bottom: 0; }
.table select { padding: 6px 8px; width: auto; }
.auth-card .row { flex-wrap: nowrap; }
.auth-card select[data-lang] { width: auto; padding: 6px 8px; font-size: 13px; }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.amount.pos { color: var(--ok); }
.amount.neg { color: var(--bad); }

/* ---- Fenêtres ---- */
dialog { border: 0; border-radius: 20px; padding: 0; width: min(520px, calc(100% - 24px)); box-shadow: 0 30px 80px rgb(17 24 39 / 30%); }
dialog::backdrop { background: rgb(17 24 39 / 45%); backdrop-filter: blur(2px); }
dialog[open] { animation: rise .2s ease; }
.modal-body { padding: 24px; display: grid; gap: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 30px; font-weight: 800; letter-spacing: .12em; text-align: center; background: var(--brand-soft); color: var(--brand); padding: 14px; border-radius: 12px; }
pre.cmd { margin: 0; white-space: pre-wrap; word-break: break-all; background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 10px; font-size: 12px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; transition: .25s; z-index: 20; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--bad); }

.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; align-items: start; }

/* ---- Installation (PWA) ---- */
[hidden] { display: none !important; }
.btn.install { color: var(--brand); border-color: var(--brand-soft); background: var(--brand-soft); }
.auth-card .btn.install { justify-self: center; }
ol.steps { margin: 0; padding-left: 22px; display: grid; gap: 10px; line-height: 1.45; }
.key { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); text-align: center; font-weight: 700; }

@media (max-width: 760px) {
  .top-inner { flex-wrap: wrap; }
  nav.tabs { order: 3; width: 100%; margin: 0; overflow-x: auto; }
  .table .hide-sm { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
