:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --primary: #25d366;
  --primary-dark: #1da851;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
  --font: system-ui, -apple-system, Segoe UI, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--primary); }
.nav-links { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.nav-links a { color: var(--muted); font-size: 0.9rem; }
.nav-links a:hover { color: var(--text); }

.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }
h1 { font-size: 1.75rem; margin-bottom: 1rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 1rem; }
h3 { font-size: 1rem; margin-bottom: 0.75rem; }
.muted { color: var(--muted); font-size: 0.9rem; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem;
}
.empty { text-align: center; padding: 2rem; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }

.stat { display: flex; flex-direction: column; gap: 0.25rem; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }

.form { display: flex; flex-direction: column; gap: 0.5rem; }
.form label { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
.form input, .form select {
  padding: 0.65rem 0.75rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 0.95rem;
}
.inline-form { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.inline-form input, .inline-form select { flex: 1; min-width: 140px; }

.btn {
  display: inline-block; padding: 0.55rem 1rem; border-radius: 8px; border: none;
  font-size: 0.9rem; cursor: pointer; font-weight: 600; text-align: center;
}
.btn-primary { background: var(--primary); color: #000; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8rem; }
.btn-link { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.9rem; }
.inline { display: inline; }
.mt { margin-top: 1rem; }

.table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.9rem; }
.table th, .table td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
.actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.badge {
  display: inline-block; padding: 0.2rem 0.55rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
}
.badge-connected { background: #14532d; color: #86efac; }
.badge-qr, .badge-activating { background: #713f12; color: #fde68a; }
.badge-pending { background: #1e3a5f; color: #93c5fd; }
.badge-disconnected { background: #450a0a; color: #fca5a5; }

.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: #450a0a; color: #fca5a5; border: 1px solid #7f1d1d; }
.alert-success { background: #14532d; color: #86efac; border: 1px solid #166534; }

.auth-card {
  max-width: 400px; margin: 4rem auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem;
}
.auth-card h1 { margin-bottom: 0.25rem; }
.otp-input { font-size: 1.5rem; letter-spacing: 0.5rem; text-align: center; }

.qr-card { text-align: center; }
.qr-wrap { min-height: 300px; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.qr-img { width: 280px; height: 280px; max-width: 100%; border-radius: 8px; margin: 1rem 0; background: #fff; padding: 12px; object-fit: contain; }

.code-block {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 1rem; overflow-x: auto; font-size: 0.85rem; margin-top: 0.5rem;
}
.copy-block { display: block; word-break: break-all; margin: 0.5rem 0; }

.endpoint-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.method { font-size: 0.75rem; font-weight: 700; padding: 0.2rem 0.5rem; border-radius: 4px; }
.method-GET { background: #1e3a5f; color: #93c5fd; }
.method-POST { background: #14532d; color: #86efac; }

code { background: var(--bg); padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.85em; }

.mb { margin-bottom: 1rem; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.history-head h3 { margin: 0; }
.empty-inline { padding: 1rem 0; }
.msg-body { max-width: 320px; word-break: break-word; }

@media (max-width: 600px) {
  .nav { flex-direction: column; gap: 0.75rem; }
  .inline-form { flex-direction: column; align-items: stretch; }
}
