:root {
  --bg: #f4f6fb; --card: #fff; --text: #1b2333; --muted: #5d6779; --line: #dde2ec;
  --accent: #1d4ed8; --accent2: #0f2a6b; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1420; --card: #182030; --text: #e7ebf3; --muted: #9aa5b8; --line: #2a3446;
          --accent: #6b8cff; --accent2: #3b5bdb; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, sans-serif; background: var(--bg); color: var(--text); }
header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: #fff;
         background: linear-gradient(90deg, var(--accent2), var(--accent)); }
header h1 { font-size: 18px; margin: 0; flex: 1; }
header .ghost { color: #fff; border-color: rgba(255,255,255,.6); }
main { max-width: 1118px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.narrow { max-width: 380px; margin: 40px auto; display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
input, select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
                background: var(--bg); color: var(--text); }
button { font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--accent);
         background: var(--accent); color: #fff; cursor: pointer; }
button.ghost { background: transparent; color: var(--accent); }
button.danger { border-color: var(--bad); color: var(--bad); }
button.active { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.code { font: 600 20px/1 ui-monospace, monospace; letter-spacing: 3px; padding: 10px 14px;
        background: var(--card); border: 1px dashed var(--accent); border-radius: 10px; }
.code small { display: block; font: 12px system-ui, sans-serif; letter-spacing: 0; color: var(--muted); margin-top: 6px; }
.device .head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.device h2 { margin: 0; font-size: 18px; }
.meta, .muted { color: var(--muted); font-size: 13px; }
.badge { padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.badge.open { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.allowlist { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.cut { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.modes { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.stats { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 12px; font-size: 14px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; }
details { margin: 8px 0; }
summary { cursor: pointer; color: var(--accent); }
.services .list { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px 12px;
                  max-height: 260px; overflow: auto; margin: 8px 0; padding: 4px; }
.services .list label { display: flex; gap: 6px; align-items: center; color: var(--text); }
.services .filter { width: 100%; margin-top: 8px; }
.events ul { margin: 8px 0; padding-left: 18px; font-size: 13px; }
.error { color: var(--bad); min-height: 1em; margin: 0; }
.online { color: var(--ok); } .offline { color: var(--bad); }
@media (max-width: 560px) { .device .head { flex-direction: column; } }
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text);
         max-width: 420px; width: calc(100% - 32px); padding: 20px; }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h2 { margin-top: 0; font-size: 18px; }
dialog img { display: block; margin: 12px auto; background: #fff; border-radius: 8px; max-width: 100%; height: auto; }
dialog ol { padding-left: 20px; }
.warn { color: var(--warn); font-size: 14px; }
.dialog-actions, .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; margin-top: 8px; }
a.button { display: inline-block; text-decoration: none; padding: 8px 14px; border-radius: 8px;
           border: 1px solid var(--accent); color: var(--accent); }
.grid { display: grid; gap: 10px; }
.update { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; padding: 10px 12px;
          border-radius: 10px; background: color-mix(in srgb, var(--accent) 10%, transparent); font-size: 14px; }
.update-text { flex: 1; }
.remote { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
dialog.wide { max-width: 480px; }
#screen-img { display: block; margin: 8px auto; max-height: 70vh; max-width: 100%; border-radius: 12px;
              background: #000; min-height: 120px; }
.history-list, .audit-list { max-height: 300px; overflow: auto; margin: 8px 0; font-size: 13px;
                              border: 1px solid var(--line); border-radius: 8px; }
.history-list table, .audit-list table { width: 100%; border-collapse: collapse; }
.history-list td, .audit-list td { padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.history-list tr:last-child td, .audit-list tr:last-child td { border-bottom: none; }
.blocked { color: var(--bad); }
.st-done { color: var(--ok); } .st-failed { color: var(--bad); } .st-sent, .st-delivered { color: var(--muted); }

/* Onglets */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tab { background: transparent; color: var(--muted); border: none; border-bottom: 2px solid transparent;
       border-radius: 8px 8px 0 0; padding: 8px 16px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
label.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--muted); }

/* Statistiques : diagrammes à barres */
.card h3 { font-size: 14px; color: var(--muted); margin: 16px 0 8px; font-weight: 600; }
.bars { display: grid; gap: 6px; }
.barrow { display: grid; grid-template-columns: minmax(90px, 160px) 1fr max-content; gap: 10px; align-items: center;
          font-size: 13px; }
.barlabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bartrack { background: color-mix(in srgb, var(--muted) 18%, transparent); border-radius: 6px; height: 16px; }
.barfill { display: block; height: 100%; border-radius: 6px; min-width: 2px;
           background: linear-gradient(90deg, var(--accent2), var(--accent)); }
.barfill.dim { opacity: .55; }
.barval { color: var(--muted); white-space: nowrap; }

/* Utilisateurs */
ul.users { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
ul.users li { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center;
              padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.user-actions { display: flex; gap: 8px; }
.role { padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
        background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted); }
.role.owner { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
