:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --border: #2c313c;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --primary: #3b82f6;
  --primary-hover: #2f6fe0;
  --danger: #ef4444;
  --ok: #22c55e;
  --warn: #f59e0b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }

.nav { display: flex; align-items: center; gap: 1rem; }
.nav-user { color: var(--muted); font-size: 0.9rem; }
.inline { display: inline; margin: 0; }

.content { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.25rem; }

.muted { color: var(--muted); }
.error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--danger);
  color: #fca5a5;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
}
.btn:hover { background: var(--border); }
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: var(--border); }

.auth-card {
  max-width: 360px;
  margin: 4rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
}
.auth-card h1 { margin-top: 0; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.auth-form label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; color: var(--muted); }
.auth-form input {
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.auth-form input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

/* ── Admin panel ── */
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #d83a3a; }

.flash { padding: 0.6rem 0.9rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-error { background: rgba(239, 68, 68, 0.12); border: 1px solid var(--danger); color: #fca5a5; }
.flash-success { background: rgba(34, 197, 94, 0.12); border: 1px solid var(--ok); color: #86efac; }

.cards { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1.25rem 0; }
.card-tile {
  display: flex; flex-direction: column; gap: 0.25rem;
  min-width: 160px; padding: 1rem 1.25rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text);
}
.card-tile:hover { background: var(--surface-2); text-decoration: none; }
.card-tile.tile-warn { border-color: var(--warn); }
.tile-num { font-size: 1.8rem; font-weight: 700; }
.tile-label { color: var(--muted); font-size: 0.9rem; }

.tbl { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.tbl th, .tbl td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.tbl code { color: var(--text); background: var(--surface-2); padding: 0.1rem 0.35rem; border-radius: 5px; }
.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1rem 1.25rem; margin: 1.25rem 0;
}
.panel summary { cursor: pointer; font-weight: 600; }
.row-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.75rem; }
.row-form input[type=text], .row-form input[type=password], .row-form textarea {
  padding: 0.45rem 0.6rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; flex: 1; min-width: 160px;
}
.row-form textarea { width: 100%; resize: vertical; }
.chk { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--muted); font-size: 0.9rem; }

/* ── Lobby device cards ── */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}
.device-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; display: flex; flex-direction: column;
}
.device-card .preview {
  position: relative; aspect-ratio: 16 / 9; background: #000;
  display: flex; align-items: center; justify-content: center;
}
.device-card .preview img { width: 100%; height: 100%; object-fit: cover; }
.preview-empty { color: var(--muted); font-size: 0.85rem; }
.badge {
  position: absolute; top: 0.5rem; right: 0.5rem;
  padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
  color: #fff;
}
.badge-occupied { background: var(--warn); }
.badge-online { background: var(--ok); }
.badge-offline { background: #6b7280; }
.badge-unregistered { background: var(--primary); }
.device-body { padding: 0.75rem 0.9rem; display: flex; flex-direction: column; gap: 0.35rem; }
.device-name { font-weight: 600; }
.device-desc { color: var(--muted); font-size: 0.85rem; }
.device-meta { font-size: 0.8rem; }
.device-meta code { background: var(--surface-2); padding: 0.1rem 0.35rem; border-radius: 5px; }
.device-actions { margin-top: 0.4rem; }
.device-actions form { margin: 0; }
.status-offline .preview { opacity: 0.55; }
