*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #0c0e14;
  --bg-gradient: radial-gradient(ellipse 80% 50% at 50% -10%, #1a2035 0%, var(--bg) 55%);
  --surface: #161922;
  --surface-2: #1e2330;
  --border: #2a3142;
  --text: #eef0f4;
  --muted: #8892a8;
  --accent: #f7931a;
  --accent-hover: #ffa940;
  --accent-glow: rgba(247, 147, 26, 0.25);
  --radius: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg-gradient);
  background-color: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

.page--wide { max-width: 540px; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent) 0%, #e67e00 100%);
  border-radius: 10px;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px var(--accent-glow);
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card-section {
  padding-top: 1.25rem;
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.card-section:first-child {
  padding-top: 0;
  margin-top: 0;
  border-top: none;
}

.card-section h2 {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="date"],
select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  margin-bottom: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder { color: #5c6578; }

select option {
  background: var(--surface-2);
  color: var(--text);
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0.2rem 0 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.checkbox-row span {
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.45;
}

.hint {
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

button {
  padding: 0.65rem 1.25rem;
  background: var(--accent);
  color: #111;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

button:hover:not(:disabled) { background: var(--accent-hover); }
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover:not(:disabled) {
  background: #252b3a;
  border-color: #3d4659;
}

button.full-width { width: 100%; }

a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s;
}

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

.link-btn {
  display: inline-block;
  padding: 0.5rem 0.85rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}

.link-btn:hover {
  background: #252b3a;
  border-color: #3d4659;
  color: var(--text);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.nav-links .sep { color: var(--border); }

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--surface-2);
  border-radius: 10px;
  margin-bottom: 1rem;
}

.tab-btn {
  flex: 1;
  padding: 0.6rem 0.75rem;
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.875rem;
}

.tab-btn:hover:not(.active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  background: var(--accent);
  color: #111;
  font-weight: 600;
}

.node-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 1.25rem;
  padding: 0.4rem 0.75rem;
  background: var(--surface-2);
  border-radius: 999px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.node-badge strong { color: var(--text); font-weight: 600; }

.node-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.message, .msg {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  display: none;
}

.message.error, .msg.err {
  background: #2d1518;
  color: #fca5a5;
  border: 1px solid #5c2028;
}

.message.info, .msg.ok {
  background: #152238;
  color: #93c5fd;
  border: 1px solid #1e3a5f;
}

#step2fa { display: none; }

#usersList {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0.25rem 0;
}

#qrBox {
  display: none;
  margin: 1rem 0;
  padding: 1rem;
  background: #fff;
  border-radius: 8px;
  text-align: center;
}

#qrBox p { color: #333; margin: 0.5rem 0; }
#qrBox img { max-width: 180px; border-radius: 4px; }
#qrBox input { margin-bottom: 0.75rem; }

.status-text {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.page--login {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.page--login .brand { justify-content: center; }
.page--login .subtitle { text-align: center; margin-bottom: 1.25rem; }

#adminSection { display: none; }

#changePasswordBox,
#disableBox {
  margin-top: 0.75rem;
}

.user-table-wrap {
  overflow-x: auto;
  margin: 0.75rem 0 1rem;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.user-table th,
.user-table td {
  padding: 0.65rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.user-table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.user-table tr:last-child td { border-bottom: none; }

.user-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-admin {
  background: rgba(247, 147, 26, 0.15);
  color: var(--accent);
  border: 1px solid rgba(247, 147, 26, 0.35);
}

.badge-2fa {
  background: rgba(74, 222, 128, 0.1);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.25);
}

.badge-warn {
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.25);
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

button.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8125rem;
}

button.btn-danger {
  background: #7f1d1d;
  color: #fecaca;
  border: 1px solid #991b1b;
}

button.btn-danger:hover:not(:disabled) {
  background: #991b1b;
}

button.btn-danger:disabled {
  opacity: 0.4;
}

.set-password-panel {
  display: none;
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.set-password-panel.open { display: block; }

.set-password-panel h3 {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.admin-only-note {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}
