:root {
  --bg: #0f1420; --bg2: #161c2b; --card: #1b2333; --card2: #222c40;
  --line: #2b3550; --text: #e6ebf5; --muted: #8b97b4; --accent: #4f8cff;
  --accent2: #6f6bff; --green: #35c46a; --red: #f0555a; --amber: #eab54a;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
button { cursor: pointer; border: 0; border-radius: 8px; padding: 8px 14px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
button.danger { background: var(--red); }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select { background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; width: 100%; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.err { color: var(--red); min-height: 18px; font-size: 13px; margin-top: 4px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero {
  position: relative; padding: 56px 48px; color: #fff; display: flex; flex-direction: column;
  justify-content: center; overflow: hidden;
  background: radial-gradient(1200px 500px at -10% -10%, #2a3ba6 0%, transparent 55%),
              radial-gradient(900px 500px at 110% 120%, #6f6bff33 0%, transparent 50%),
              linear-gradient(135deg, #131a2b 0%, #0d1220 100%);
}
.login-hero::after {
  content: ""; position: absolute; inset: 0; opacity: .06; pointer-events: none;
  background-image: linear-gradient(var(--text) 1px, transparent 1px), linear-gradient(90deg, var(--text) 1px, transparent 1px);
  background-size: 34px 34px;
}
.logo-mark { width: 58px; height: 58px; display: grid; place-items: center; font-size: 30px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); border-radius: 16px;
  box-shadow: 0 10px 30px #4f8cff44; margin-bottom: 22px; }
.login-hero h1 { margin: 0; font-size: 40px; font-weight: 800; letter-spacing: -.02em; }
.login-hero h1 span { color: var(--accent); }
.login-hero > p { margin: 6px 0 26px; color: var(--muted); font-size: 16px; }
.hero-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.hero-points li { position: relative; padding-left: 28px; color: #cdd6ea; }
.hero-points li::before { content: "✓"; position: absolute; left: 0; top: -1px;
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; background: #35c46a22; color: var(--green); }
.hero-foot { position: absolute; bottom: 22px; left: 48px; color: var(--muted); font-size: 12px; }
.login-form-wrap { display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-card { width: 340px; max-width: 92vw; display: grid; gap: 6px; }
.login-card h2 { margin: 0; font-size: 24px; }
.login-card > p { margin: 0 0 14px; }
.fl { display: grid; gap: 6px; margin-bottom: 12px; }
.fl span { font-size: 12px; color: var(--muted); }
#loginBtn { margin-top: 4px; padding: 11px; font-size: 15px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); }
@media (max-width: 820px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { padding: 40px 28px; }
  .login-hero h1 { font-size: 32px; }
}

/* ---------- header ---------- */
header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 20px; background: var(--bg2); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 17px; }
.brand .tag { color: var(--muted); font-weight: 500; font-size: 12px; }
.hstats { display: flex; gap: 8px; }
.hactions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.auto { color: var(--muted); font-size: 13px; display: flex; gap: 5px; align-items: center; }
.auto input { width: auto; }
.pill { padding: 4px 10px; border-radius: 999px; background: var(--card2); font-size: 12px; font-weight: 600; }
.pill.online { color: var(--green); } .pill.offline { color: var(--red); }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 12px 20px; background: var(--bg2); border-bottom: 1px solid var(--line);
  position: sticky; top: 57px; z-index: 4; }
.filters select { width: auto; min-width: 150px; }
.f-search { width: 260px; flex: 1 1 220px; max-width: 340px; }
#fCount { margin-left: auto; font-size: 12px; }

/* ---------- grid ---------- */
main { padding: 20px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.dev { padding: 16px; cursor: pointer; transition: border-color .15s, transform .05s; }
.dev:hover { border-color: var(--accent); }
.dev:active { transform: scale(.995); }
.dev-top { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.off { background: var(--red); }
.dev-name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-mac { color: var(--muted); font-size: 12px; margin-left: auto; font-family: ui-monospace, monospace; }
.dev-meta { color: var(--muted); font-size: 12px; margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--card2); color: #cdd6ea; }
.chip b { color: var(--muted); font-weight: 600; }
.dev-radios { margin-top: 12px; display: grid; gap: 6px; }
.radio-row { display: flex; align-items: center; gap: 8px; font-size: 13px;
  background: var(--bg2); border-radius: 8px; padding: 6px 10px; }
.band { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--card2); flex: none; }
.band.b5 { color: #c58cff; } .band.b24 { color: #6fc3ff; }
.ssid { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lock { margin-left: auto; color: var(--muted); font-size: 12px; flex: none; }
.clients-big { display: flex; align-items: baseline; gap: 6px; margin-top: 12px; }
.clients-big b { font-size: 24px; }
.empty { text-align: center; padding: 60px 20px; color: var(--text); }

/* ---------- drawer ---------- */
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-bg { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.drawer-panel { position: absolute; top: 0; right: 0; height: 100%; width: 460px; max-width: 96vw;
  border-radius: 0; border-right: 0; overflow-y: auto; padding: 22px; }
.close { position: absolute; top: 14px; right: 16px; background: transparent; color: var(--muted);
  font-size: 26px; padding: 0; line-height: 1; }
.d-title { font-size: 19px; font-weight: 700; margin: 0 34px 2px 0; }
.d-sub { color: var(--muted); font-size: 12px; font-family: ui-monospace, monospace; margin-bottom: 16px; }
.section { border-top: 1px solid var(--line); padding: 16px 0; }
.section h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.field { display: grid; gap: 6px; margin-bottom: 10px; }
.field label { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.row > button { flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }
.kv span:nth-child(even) { text-align: right; font-family: ui-monospace, monospace; }
.radio-block { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.radio-block .rh { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-weight: 600; }
.hist { display: grid; gap: 6px; max-height: 220px; overflow-y: auto; }
.hitem { font-size: 12px; background: var(--bg2); border-radius: 7px; padding: 7px 10px;
  display: flex; gap: 8px; align-items: center; }
.hitem .st { font-weight: 700; flex: none; }
.st.done { color: var(--green); } .st.failed { color: var(--red); }
.st.sent, .st.queued { color: var(--amber); } .st.expired { color: var(--muted); }
.hitem .msg { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hitem time { margin-left: auto; color: var(--muted); flex: none; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--card2); border: 1px solid var(--line); padding: 10px 18px;
  border-radius: 10px; z-index: 40; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.toast.ok { border-color: var(--green); } .toast.bad { border-color: var(--red); }

@media (max-width: 520px) {
  header { gap: 10px; } .hstats { order: 3; width: 100%; }
  .filters { top: 0; position: static; }
}
