:root {
  --bg: #f5f6f8; --surface: #fff; --surface-2: #eef0f3; --fg: #14161a; --muted: #6b7280;
  --line: #e2e5ea; --accent: #2f7cf6; --accent-fg: #fff; --ok: #12a150; --warn: #d97706; --bad: #dc2626;
  --radius: 14px; --tabs-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --surface: #171a21; --surface-2: #1f232c; --fg: #e8eaee; --muted: #8b93a1;
          --line: #2a2f3a; --accent: #4b8ef8; --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
       -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
h2 { font-size: 15px; margin: 0 0 10px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.err { color: var(--bad); min-height: 1.4em; margin: 0; }

/* boutons & champs */
.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 10px;
       padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; min-height: 42px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; }
.icon-btn { background: none; border: 0; color: var(--fg); padding: 8px; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; color: var(--fg); background: var(--surface-2);
       border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
textarea { font-family: ui-monospace, Menlo, monospace; font-size: 14px; resize: vertical; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 600; }
.switch input { width: 46px; height: 28px; appearance: none; background: var(--line); border-radius: 99px; position: relative;
       border: 0; padding: 0; cursor: pointer; flex: none; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
       background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }

.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
/* connexion */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
       padding: 24px; display: grid; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; }

/* structure */
#app { min-height: 100%; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
       padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
       backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
main { max-width: 880px; margin: 0 auto; padding: 16px 16px calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom)); }
.view { display: grid; gap: 14px; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(7, 1fr);
       background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; font-size: 10px; font-weight: 600; display: grid;
       justify-items: center; gap: 3px; padding: 9px 0; height: var(--tabs-h); cursor: pointer; }
.tabs button.active { color: var(--accent); }
@media (min-width: 900px) {
  .tabs { top: 0; bottom: 0; right: auto; width: 92px; grid-template-columns: 1fr; grid-auto-rows: 72px; align-content: start;
          padding-top: 70px; border-top: 0; border-right: 1px solid var(--line); }
  .tabs button { height: auto; }
  .top { padding-left: 108px; }
  main { padding-left: 108px; padding-bottom: 32px; max-width: 1000px; }
}

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-gap { display: flex; gap: 10px; flex-wrap: wrap; } .row-gap > * { flex: 1 1 160px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.stack { display: grid; gap: 10px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px;
        background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.pill.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }

/* utilisateurs */
.user { display: grid; gap: 12px; }
.user .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.user .name { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.stat b { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); }
.user .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* QR */
/* Les modules du QR sont des traits : on annule le style des icônes (traits épais, bouts ronds) */

/* historique */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--surface-2); border-radius: 99px; padding: 4px 10px; font-size: 13px; }
.chip b { color: var(--muted); font-weight: 600; margin-left: 4px; }
.list { display: grid; gap: 2px; max-height: 60vh; overflow: auto; }
.list .it { display: flex; justify-content: space-between; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--line); }
.list .it span:first-child { overflow-wrap: anywhere; }
.list .it span:last-child { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }

/* serveur */
.meter { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter i.warn { background: var(--warn); } .meter i.bad { background: var(--bad); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; }

/* terminal */
.term-view { position: fixed; inset: calc(53px + env(safe-area-inset-top)) 0 calc(var(--tabs-h) + env(safe-area-inset-bottom)) 0;
       display: flex !important; flex-direction: column; gap: 0; padding: 0; background: #0b0d10; }
.term-view[hidden] { display: none !important; }
.term-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: #12151a; }
.term { flex: 1; min-height: 0; padding: 4px 0 0 6px; }
.keys { display: flex; gap: 6px; overflow-x: auto; padding: 6px 8px; background: #12151a; scrollbar-width: none; }
.keys button { flex: none; min-width: 44px; height: 36px; border-radius: 8px; border: 1px solid #2a2f3a; background: #1c2028;
       color: #e8eaee; font: 600 14px ui-monospace, Menlo, monospace; cursor: pointer; }
.keys button.on { background: var(--accent); border-color: var(--accent); }
@media (min-width: 900px) { .term-view { inset: 53px 0 0 92px; } }

/* modale & toast */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0;
       padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }
@media (min-width: 600px) { .modal { align-items: center; } .sheet { border-radius: 18px; } }
.sheet h2 { font-size: 18px; margin: 0; }
.sheet .foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom));
       z-index: 30; background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; max-width: 90vw; }
.toast.bad { background: var(--bad); color: #fff; }
.link-text { font: 12px ui-monospace, Menlo, monospace; word-break: break-all; background: var(--surface-2); padding: 8px; border-radius: 8px;
       user-select: all; -webkit-user-select: all; max-height: 90px; overflow: auto; width: 100%; text-align: left; }

/* ---- statistiques */
:root { --series-1: #2a78d6; --series-2: #eb6834; --grid: #eceef1; --axis: #c9cdd4; }
@media (prefers-color-scheme: dark) { :root { --series-1: #3987e5; --series-2: #d95926; --grid: #232731; --axis: #39404d; } }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters select { flex: 1 1 180px; width: auto; }
.seg { display: inline-grid; grid-auto-flow: column; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; font-size: 14px; padding: 7px 12px; border-radius: 7px; cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.tiles { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.tiles .tile:last-child { grid-column: 1 / -1; }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(3, 1fr); } .tiles .tile:last-child { grid-column: auto; } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 2px; }
.tile .lbl { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tile b { font-size: 21px; white-space: nowrap; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.tile .sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; vertical-align: -1px; }
.sw.s1 { background: var(--series-1); } .sw.s2 { background: var(--series-2); }
.chart-head { display: grid; gap: 4px; } .chart-head h2 { margin: 0; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); font-weight: 600; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart { position: relative; margin: 6px 0 4px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart-svg { display: block; overflow: visible; width: 100%; height: auto; stroke: none; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .base { stroke: var(--axis); stroke-width: 1; }
.chart-svg .ax { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-svg .ax.unit { font-weight: 600; }
.chart-svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .line.s1 { stroke: var(--series-1); } .chart-svg .line.s2 { stroke: var(--series-2); }
.chart-svg .dot.s1 { fill: var(--series-1); } .chart-svg .dot.s2 { fill: var(--series-2); }
.chart-svg .dot.ring { stroke: var(--surface); stroke-width: 2; }
.chart-svg .bar.s1 { fill: var(--series-1); } .chart-svg .bar.s2 { fill: var(--series-2); }
.chart-svg .dl { font-size: 11px; fill: var(--fg); } .chart-svg .dl.name { font-weight: 700; } .chart-svg .dl.val { fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart-svg .cross { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-svg .hit { fill: transparent; cursor: crosshair; }
.tip { position: absolute; z-index: 3; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
       box-shadow: 0 6px 20px rgba(0,0,0,.18); padding: 8px 10px; font-size: 12px; min-width: 150px; }
.tip .tt { font-weight: 700; margin-bottom: 4px; }
.tip .tr { display: flex; align-items: center; gap: 6px; } .tip .tr b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; margin-top: 8px; }
.tbl th, .tbl td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); } .tbl th { color: var(--muted); font-weight: 600; }
.urow { cursor: pointer; align-items: center; } .urow.sel span:first-child { font-weight: 700; color: var(--accent); }
.urow span:last-child { display: inline-flex; align-items: center; gap: 4px; }

/* ---- flotte */
.tiles4 { grid-template-columns: 1fr 1fr; } .tiles4 .tile:last-child { grid-column: auto; }
@media (min-width: 900px) { .tiles4 { grid-template-columns: repeat(4, 1fr); } }
.node { display: grid; gap: 10px; } .node.off { opacity: .75; }
.nname { display: flex; align-items: center; gap: 8px; font-size: 16px; } .flag { font-size: 20px; line-height: 1; }
.nstats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
@media (min-width: 560px) { .nstats { grid-template-columns: repeat(4, 1fr); } }
.nstats .stat b { font-size: 13px; }
.spark { width: 100%; height: 44px; display: block; background: var(--surface-2); border-radius: 8px; }
.spark .sl { fill: none; stroke-width: 1.5; vector-effect: non-scaling-stroke; } .spark .s1 { stroke: var(--series-1); } .spark .s2 { stroke: var(--series-2); }
.node .actions { display: flex; gap: 8px; justify-content: flex-end; }
.node .meter { margin-top: -4px; }

/* ---- détection des blocages */
.bkrow { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); line-height: 1.6; }
.bkrow:last-of-type { border-bottom: 0; }
.bkrow .pill { margin-left: 6px; vertical-align: 1px; }
.bkrow .chips { margin-top: 8px; }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); } .chip.bad { color: var(--bad); }

/* ---- sessions en cours */
.sessions { display: grid; gap: 4px; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.sess { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); }

/* Packs */
.offre { margin: 4px 0 8px; } .offre .meter { margin-top: 6px; } .offre > div:last-child { margin-top: 4px; }
.pill.pack-essai { color: var(--muted); background: var(--surface-2); }
.pill.pack-silver { color: #9aa6b8; background: color-mix(in srgb, #9aa6b8 16%, transparent); }
.pill.pack-gold { color: #e0a526; background: color-mix(in srgb, #e0a526 16%, transparent); }
.pill.pack-platinum { color: #a78bfa; background: color-mix(in srgb, #a78bfa 18%, transparent); }
.demande { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 4px 0 8px; }
.demande .btn.small { padding: 4px 10px; }
.avatar { width: 34px; height: 34px; border-radius: 99px; object-fit: cover; flex: none; margin-right: 10px; }
.avatar.vide { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; background: var(--accent); }
.user .head .name { flex: 1; min-width: 0; }

/* Accès : tableau des utilisateurs */
/* Onglet Accès : page plus large sur grand écran pour que le tableau tienne sans défiler */
@media (min-width: 900px) { main:has(> .view[data-view="users"]:not([hidden])) { max-width: 1500px; } }
#users { min-width: 0; } /* élément de grille : sans cela, le tableau élargit toute la page sur mobile */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.utable { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 1260px; table-layout: fixed; }
.utable td, .utable th { overflow: hidden; text-overflow: ellipsis; }
.utable th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.utable td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.utable tbody tr:last-child td { border-bottom: 0; }
.utable tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.utable .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.utable .act { white-space: nowrap; text-align: right; }
.utable .qui { display: flex; align-items: center; }
.utable .qui > div { min-width: 0; }
.utable .qui b, .utable .qui .small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.utable .proto { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.utable .meter { height: 5px; margin-top: 4px; max-width: 140px; }
.utable .demande { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.appareils { margin: 4px 0 8px; display: grid; gap: 6px; }
.appareil { display: flex; align-items: center; gap: 8px; } .appareil > span:nth-child(2) { flex: 1; min-width: 0; }
.appareil .btn.small { padding: 3px 9px; }
/* Identité des packs : mêmes dégradés que l'application */
.pill.pack-silver, .pill.pack-gold, .pill.pack-platinum, .pill.pack-essai, .pill.pack-illimite { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; }
.pill.pack-silver { color: #2e3644; background: linear-gradient(90deg, #eef1f6, #9aa6b8); }
.pill.pack-gold { color: #5a3a00; background: linear-gradient(90deg, #ffe89a, #e09f1f); }
.pill.pack-platinum { color: #fff; background: linear-gradient(90deg, #c9b8ff, #6d4ae8); }
.pill.pack-essai { color: #4a5263; background: linear-gradient(90deg, #e6e9ef, #d3d8e1); }
.pill.pack-illimite { color: #04361f; background: linear-gradient(90deg, #b6f5d2, #22c55e); }
.switch:has(input:disabled) { opacity: .45; }
.utable th { white-space: normal; }
.utable td, .utable th { padding-left: 8px; padding-right: 8px; }
.utable td:first-child, .utable th:first-child { padding-left: 14px; }
.utable .act { overflow: visible; }
.utable .pills { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.utable .quota { white-space: nowrap; font-variant-numeric: tabular-nums; }
.utable .pill { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.utable td { vertical-align: middle; }
