:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --bg-2: #0f1319;
  --panel: #151a22;
  --panel-2: #1b212b;
  --border: #262d3a;
  --border-strong: #35405280;
  --text: #e8ebf0;
  --muted: #949cad;
  --faint: #6b7385;
  --accent: #5b8cff;
  --accent-hover: #6f9bff;
  --accent-dim: #5b8cff1a;
  --ok: #3ecf6a;
  --danger: #f0555a;
  --danger-dim: #f0555a1a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.25);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  background:
    radial-gradient(1200px 600px at 100% -10%, #16233f22, transparent),
    radial-gradient(900px 500px at -10% 0%, #1c2a2422, transparent),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  min-height: 100vh;
  padding: 28px clamp(16px, 4vw, 48px) 60px;
}

body.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---------- header ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto 28px;
  flex-wrap: wrap;
}
header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
header .actions-inline { display: flex; gap: 10px; align-items: center; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}
.back-link:hover { color: var(--text); }

/* ---------- layout ---------- */
main, .wrap { max-width: 1200px; margin: 0 auto; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin: 0 auto 18px;
  max-width: 1200px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 4px; font-size: 15px; font-weight: 620; letter-spacing: -0.01em; }
.card > p { color: var(--muted); margin-top: 0; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; max-width: 1200px; margin: 0 auto 18px; }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } }

hr { border: none; border-top: 1px solid var(--border); margin: 22px 0; }

/* ---------- tables ---------- */
.table-wrap {
  max-width: 1200px;
  margin: 0 auto 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  font-weight: 600;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #ffffff06; }

/* ---------- buttons ---------- */
button, .btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 550;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .05s;
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }

button.ghost, .btn.ghost {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--border);
}
button.ghost:hover, .btn.ghost:hover { background: #232a36; border-color: var(--border-strong); }

button.danger { background: var(--danger-dim); color: var(--danger); border-color: #f0555a55; }
button.danger:hover { background: #f0555a2e; }

button.sm { padding: 6px 11px; font-size: 12px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* ---------- forms ---------- */
label.field { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=password], input[type=url], input:not([type]) {
  display: block;
  width: 100%;
  padding: 10px 12px;
  margin-top: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color .12s, box-shadow .12s;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

/* ---------- login ---------- */
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-size: 20px; margin: 0 0 20px; letter-spacing: -0.02em; }
.login-card button { width: 100%; margin-top: 4px; padding: 11px; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-brand .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7d5bff);
  display: grid; place-items: center; font-size: 18px;
}

/* ---------- status dot ---------- */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 3px transparent; }
.dot.online { background: var(--ok); box-shadow: 0 0 0 3px #3ecf6a26; }
.dot.offline { background: #4a5163; }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
}
.pill.online { background: #3ecf6a1f; color: var(--ok); }
.pill.offline { background: #4a51631f; color: var(--muted); }

.battery { display: inline-flex; align-items: center; gap: 6px; }
.battery-bar { width: 34px; height: 7px; border-radius: 4px; background: #2a313e; overflow: hidden; }
.battery-bar > span { display: block; height: 100%; background: var(--ok); }
.battery-bar.low > span { background: #f0a23c; }
.battery-bar.crit > span { background: var(--danger); }

/* ---------- definition list ---------- */
dl { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 9px 16px; margin: 0; }
dt { color: var(--faint); font-size: 12.5px; }
dd { margin: 0; font-variant-numeric: tabular-nums; }

/* ---------- feature checklist (build page) ---------- */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 6px;
  margin: 0 0 16px;
  background: var(--bg-2);
}
legend {
  color: var(--accent);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: 700;
  padding: 0 8px;
}

.feature-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.feature-row:hover { border-color: var(--border-strong); background: var(--panel-2); }
.feature-row:has(input:checked) { border-color: #5b8cff66; background: linear-gradient(180deg, #5b8cff12, var(--panel)); }
.feature-row .meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.feature-row .meta strong { font-size: 13.5px; font-weight: 600; }
.feature-row .meta small { color: var(--muted); font-size: 12px; line-height: 1.35; }

/* checkbox + switch */
input[type=checkbox] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  background: var(--bg);
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: background .12s, border-color .12s;
}
input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
input[type=checkbox]:checked::after {
  content: "";
  width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-0.5px, -1px);
}
input[type=checkbox]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-dim); }

/* toggle-switch variant for the per-device runtime flags */
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border);
}
.switch-row:last-child { border-bottom: none; }
.switch-row .name { font-size: 13.5px; }
.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: #333b49; transition: background .15s;
}
.switch .track::before {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::before { transform: translateX(18px); }

/* ---------- misc ---------- */
.error { color: var(--danger); min-height: 1.2em; font-size: 13px; margin: 8px 0 0; }
.hint { color: var(--muted); font-size: 12.5px; }
.ok-text { color: var(--ok); font-size: 13px; }

code {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 12.5px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

ol { padding-left: 20px; color: var(--muted); }
ol li { margin: 6px 0; }
ol code { color: var(--text); }

dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 420px;
  width: calc(100vw - 32px);
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
dialog h2 { margin: 0 0 16px; font-size: 17px; }
dialog::backdrop { background: rgba(0,0,0,.62); backdrop-filter: blur(2px); }
#pairing-result img { width: 180px; height: 180px; border-radius: 8px; background: #fff; padding: 8px; margin: 8px 0; }
#pairing-code {
  font-family: "SF Mono", ui-monospace, monospace;
  font-size: 20px; letter-spacing: .12em; color: var(--accent);
}

.empty {
  text-align: center; color: var(--faint);
  padding: 40px 20px; font-size: 14px;
}
