:root {
  --bg: #0b1120;
  --panel: #111a2e;
  --panel2: #17233b;
  --line: #263652;
  --text: #e6edf7;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent2: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at 15% -10%, #16305f 0, var(--bg) 42%);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: #93c5fd; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.shell { min-height: 100vh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--line); background: rgba(11,17,32,.86);
  position: sticky; top: 0; z-index: 5; backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg,#22c55e,#2563eb); display: grid; place-items: center; font-size: 16px; }
.brand small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-chip { color: var(--muted); font-size: 12px; }
.wrap { max-width: 1440px; margin: 0 auto; padding: 22px 24px 60px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.tab { background: transparent; color: var(--muted); border: 1px solid transparent; padding: 8px 12px; border-radius: 9px; }
.tab.active { color: #fff; background: var(--panel2); border-color: var(--line); }
.btn { border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: 8px 12px; border-radius: 9px; }
.btn:hover { border-color: #3d557c; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.success { background: #15803d; border-color: #15803d; color: white; }
.btn.danger { background: #7f1d1d; border-color: #991b1b; color: #fee2e2; }
.btn.small { padding: 5px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.card .v { font-size: 24px; font-weight: 750; margin-top: 4px; }
.card .s { color: var(--muted); font-size: 11px; margin-top: 2px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.panel-body { padding: 14px 16px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; color: var(--muted); font-weight: 600; padding: 9px 12px; background: #0f1728; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { padding: 10px 12px; border-bottom: 1px solid #1d2a43; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.active { color: #86efac; background: #052e16; }
.badge.pairing { color: #fde68a; background: #3a2604; }
.badge.error, .badge.logged_out { color: #fecaca; background: #3b0a0a; }
.badge.connecting, .badge.disconnected, .badge.stopped { color: #bfdbfe; background: #102846; }
.badge.pending, .badge.new, .badge.unassigned { color: #cbd5e1; background: #1f2937; }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; font-size: 13px; }
.actions { display: flex; gap: 5px; flex-wrap: wrap; }
.select { background: #0f1728; color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; max-width: 210px; }
.form-row { display: grid; gap: 10px; margin-bottom: 12px; }
.form-row label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.form-row input, .form-row select, .form-row textarea {
  background: #0f1728; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px;
}
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.login-card h1 { margin: 0 0 6px; font-size: 24px; }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.login-card .form-row { gap: 12px; }
.error-text { color: #fca5a5; font-size: 12px; margin-top: 10px; white-space: pre-wrap; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; padding: 20px; z-index: 20; }
.modal { width: min(620px, 100%); max-height: 90vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }
.qr-box { display: grid; place-items: center; gap: 12px; text-align: center; }
.qr-box img { width: 280px; height: 280px; background: white; padding: 10px; border-radius: 12px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; background: #14532d; color: #dcfce7; border: 1px solid #166534; padding: 10px 14px; border-radius: 10px; max-width: 420px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.error { background: #450a0a; color: #fecaca; border-color: #7f1d1d; }
.code-block { background: #0f1728; border: 1px solid var(--line); border-radius: 9px; padding: 12px; overflow: auto; font-family: ui-monospace, monospace; font-size: 12px; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.hint { color: var(--muted); font-size: 12px; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { flex: 1; }
@media (max-width: 720px) {
  .topbar, .wrap { padding-left: 12px; padding-right: 12px; }
  .hide-mobile { display: none; }
}
