:root {
  color-scheme: light dark;
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #e6e8eb;
  --text-dim: #9aa1ac;
  --accent: #5b8def;
  --danger: #e6553f;
  --success: #3fbf6f;
  --warn: #e6b83f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar .brand { font-weight: 700; padding: 1.25rem 1.25rem 0.5rem; }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; padding: 0.75rem 0.6rem; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.92rem;
}
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav a:hover { color: var(--text); background: var(--surface-2); }
.sidebar-nav a.active { color: var(--text); background: var(--surface-2); }

.sidebar-bottom {
  border-top: 1px solid var(--border);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.sidebar-user {
  color: var(--text-dim);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-actions { display: flex; gap: 0.5rem; }
.sidebar-actions form { margin: 0; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  text-decoration: none;
  padding: 0;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--text); border-color: var(--accent); filter: none; }

.container { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem; }
.app-shell .container { flex: 1; min-width: 0; margin: 0; }

h1 { margin-top: 0; }

.auth-card {
  max-width: 380px;
  margin: 4rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
}

form label { display: block; margin-bottom: 1rem; font-size: 0.9rem; color: var(--text-dim); }

input, select, button {
  font: inherit;
  color: var(--text);
}

input, select {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}

button {
  cursor: pointer;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1rem;
  color: white;
  font-weight: 600;
}

button:hover { filter: brightness(1.1); }

.inline-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  align-items: center;
}
.inline-form input, .inline-form select { width: auto; margin-top: 0; }

table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }

a { color: var(--accent); }

.meta { color: var(--text-dim); }
.empty { color: var(--text-dim); font-style: italic; }
.error { color: var(--danger); }

.stat-row { display: flex; gap: 1rem; margin-bottom: 2rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
}
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-label { color: var(--text-dim); font-size: 0.85rem; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.badge-active, .badge-success { color: var(--success); border-color: var(--success); }
.badge-pending, .badge-provisioning { color: var(--warn); border-color: var(--warn); }
.badge-failed { color: var(--danger); border-color: var(--danger); }

code { background: var(--surface-2); padding: 0.1rem 0.4rem; border-radius: 4px; }

.qr-wrap {
  background: #fff;
  display: inline-block;
  padding: 1rem;
  border-radius: 8px;
  margin: 0.75rem 0;
}
.qr-wrap svg { width: 200px; height: 200px; display: block; }
