:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --panel2: #232732;
  --border: #2c313d;
  --text: #e6e8ee;
  --muted: #8b91a0;
  --accent: #25d366;
  --accent2: #2f6fed;
  --red: #e5484d;
  --amber: #f5a623;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--red); min-height: 18px; font-size: 14px; }

/* LOGIN */
.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 32px; width: 340px; display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { margin: 0; font-size: 22px; }
input, select, button { font-size: 14px; }
input, select {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 10px 12px; outline: none;
}
input:focus, select:focus { border-color: var(--accent2); }
button {
  background: var(--accent); color: #07210f; border: none; border-radius: 9px;
  padding: 10px 14px; font-weight: 600; cursor: pointer;
}
button:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sec { background: var(--accent2); color: #fff; }

/* TOPBAR */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.brand { font-weight: 700; font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.summary { font-size: 13px; color: var(--muted); }
main { padding: 22px; max-width: 1100px; margin: 0 auto; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }

/* ADD FORM */
.add-form { display: flex; gap: 8px; flex-wrap: wrap; }
.add-form input { flex: 1; min-width: 150px; }
.add-form button { white-space: nowrap; }

/* GRID */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; }
.card-title { font-weight: 700; font-size: 16px; }
.card-sub { font-size: 12px; color: var(--muted); }
.badge {
  font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 20px; text-transform: uppercase;
}
.badge.connected { background: rgba(37,211,102,.15); color: var(--accent); }
.badge.qr, .badge.connecting { background: rgba(245,166,35,.15); color: var(--amber); }
.badge.disconnected, .badge.pending { background: rgba(139,145,160,.15); color: var(--muted); }
.badge.logged_out { background: rgba(229,72,77,.15); color: var(--red); }
.kv { font-size: 13px; display: flex; gap: 6px; }
.kv b { color: var(--muted); font-weight: 600; min-width: 70px; }
.token-row { display: flex; align-items: center; gap: 6px; }
.token { font-family: monospace; font-size: 11px; background: var(--panel2); padding: 5px 8px;
  border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.card-actions button { padding: 7px 10px; font-size: 12px; }
.dot { display:inline-block; width:8px;height:8px;border-radius:50%;background:var(--accent);margin-left:6px;opacity:0;transition:opacity .3s; }
.dot.on { opacity: 1; }

/* MODAL */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 26px; width: 360px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.qr-img { width: 260px; height: 260px; background: #fff; border-radius: 10px; padding: 8px; }
.pair-code { font-family: monospace; font-size: 30px; letter-spacing: 4px; background: var(--panel2);
  padding: 14px; border-radius: 10px; }
