:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f8fafc;
  --text-dim: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Login ──────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-container {
  width: 100%;
  max-width: 400px;
}

.login-card {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-header .logo {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.login-header h1 {
  font-size: 1.3rem;
  margin-bottom: 0.3rem;
}

.login-header p {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.login-form .form-group {
  margin-bottom: 1rem;
}

.login-form label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.login-form input {
  width: 100%;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--surface-2);
  background: #0b1220;
  color: var(--text);
  font-size: 1rem;
}

.login-form input:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

.error-message {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
}

.btn-block {
  width: 100%;
}

/* ── Navbar ──────────────────────── */
.navbar {
  background: var(--surface);
  padding: 0.8rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--surface-2);
}

.navbar h1 {
  font-size: 1.1rem;
}

/* ── Container & Cards ───────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.2rem;
  display: grid;
  gap: 1.2rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1.05rem;
  margin-bottom: 0.8rem;
}

/* ── Status ──────────────────────── */
.status-area {
  width: 100%;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.8rem;
}

.status-item {
  background: #0b1220;
  padding: 0.8rem;
  border-radius: 8px;
  text-align: center;
}

.status-item .label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 0.2rem;
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-connected {
  background: rgba(34, 197, 94, 0.18);
  color: var(--success);
}

.status-disconnected {
  background: rgba(239, 68, 68, 0.18);
  color: var(--danger);
}

/* ── QR Code ─────────────────────── */
.qr-container {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
}

.qr-container canvas,
.qr-container img {
  border-radius: 8px;
}

.hint {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

/* ── Actions Grid ────────────────── */
.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
}

/* ── Buttons ─────────────────────── */
.btn {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: #fff;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); }
.btn-success { background: var(--success); }
.btn-warning { background: var(--warning); color: #111; }
.btn-danger { background: var(--danger); }

/* ── Forms ───────────────────────── */
.form-inline {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.form-inline input {
  flex: 1 1 200px;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--surface-2);
  background: #0b1220;
  color: var(--text);
  font-size: 0.95rem;
}

.form-inline input:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

/* ── Output Box ──────────────────── */
.output-box {
  background: #0b1220;
  border: 1px solid var(--surface-2);
  border-radius: 8px;
  padding: 0.8rem;
  margin-top: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  color: var(--text-dim);
  white-space: pre-wrap;
  min-height: 2rem;
  max-height: 280px;
  overflow-y: auto;
}

/* ── Footer ──────────────────────── */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* ── Utilities ───────────────────── */
.hidden { display: none !important; }