:root {
  --bg: #0a0a0e;
  --bg-soft: #121017;
  --surface: #17151f;
  --surface-2: #1d1a27;
  --border: #2a2635;
  --border-soft: #221f2c;
  --text: #eceaf2;
  --text-dim: #9c97ad;
  --text-faint: #6b667a;
  --purple: #8b5cf6;
  --purple-light: #a78bfa;
  --purple-dark: #6d28d9;
  --purple-glow: rgba(139, 92, 246, 0.35);
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --blue: #60a5fa;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: radial-gradient(120% 120% at 15% 0%, #1a1424 0%, var(--bg) 45%, #08070b 100%);
  color: var(--text);
  font-family: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

::selection {
  background: var(--purple-dark);
  color: #fff;
}

a {
  color: var(--purple-light);
}

button {
  font-family: inherit;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--surface-2);
  border-radius: 10px;
  border: 2px solid var(--bg);
}

/* ---------- Layout genérico ---------- */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(15, 13, 20, 0.7);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset, 0 8px 24px var(--purple-glow);
}

.brand-text h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.5px;
  font-weight: 800;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

.container {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 28px;
  flex: 1;
}

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad {
  padding: 20px;
}

/* ---------- Status grid ---------- */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.status-card {
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.status-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120px 60px at 100% 0%, var(--purple-glow), transparent 70%);
  opacity: 0.5;
  pointer-events: none;
}

.status-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
  margin: 0 0 10px;
  font-weight: 700;
}

.status-value {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-sub {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px transparent;
}

.dot.green {
  background: var(--green);
  box-shadow: 0 0 10px 1px var(--green);
  animation: pulse 2s infinite;
}
.dot.amber {
  background: var(--amber);
  box-shadow: 0 0 10px 1px var(--amber);
  animation: pulse 1.4s infinite;
}
.dot.red {
  background: var(--red);
}
.dot.gray {
  background: var(--text-faint);
}
.dot.purple {
  background: var(--purple-light);
  box-shadow: 0 0 10px 1px var(--purple);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
  100% {
    opacity: 1;
  }
}

/* ---------- Botões ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--purple);
  box-shadow: 0 0 0 1px var(--purple) inset;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 24px var(--purple-glow);
}
.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 8px 30px var(--purple-glow);
}

.btn-danger {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
.btn-danger:hover {
  border-color: var(--red);
  box-shadow: 0 0 0 1px var(--red) inset;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-soft);
  color: var(--text-dim);
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border-soft);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--purple-light);
  border-bottom-color: var(--purple);
}

.tab-panel {
  display: none;
  animation: fadein 0.2s ease;
}

.tab-panel.active {
  display: block;
}

@keyframes fadein {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Formulários ---------- */
.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 7px;
}

.field .hint {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 6px;
}

.input,
select.input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-glow);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}

.switch-row:last-child {
  border-bottom: none;
}

.switch-row .label-block strong {
  display: block;
  font-size: 14px;
}

.switch-row .label-block span {
  font-size: 12.5px;
  color: var(--text-faint);
}

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.switch .slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.2s ease, background 0.2s ease;
}

.switch input:checked + .slider {
  background: var(--purple-dark);
  border-color: var(--purple);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
  background: #fff;
}

/* ---------- Badges de status textual ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.badge.green {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.3);
}
.badge.amber {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}
.badge.red {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}
.badge.gray {
  background: rgba(156, 151, 173, 0.12);
  color: var(--text-dim);
  border-color: var(--border);
}
.badge.purple {
  background: rgba(139, 92, 246, 0.14);
  color: var(--purple-light);
  border-color: rgba(139, 92, 246, 0.35);
}

/* ---------- QR Code ---------- */
.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  min-height: 260px;
}

.qr-box img {
  width: 240px;
  height: 240px;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  box-shadow: 0 0 0 1px var(--border), 0 0 40px var(--purple-glow);
}

/* ---------- Toast ---------- */
#toast-stack {
  position: fixed;
  bottom: 22px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
}

.toast {
  min-width: 260px;
  max-width: 360px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  animation: toast-in 0.2s ease;
  border-left: 3px solid var(--purple);
}

.toast.success {
  border-left-color: var(--green);
}
.toast.error {
  border-left-color: var(--red);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Modal de confirmação ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 4, 8, 0.65);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.modal {
  width: 100%;
  max-width: 420px;
  padding: 24px;
  animation: toast-in 0.18s ease;
}

.modal h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.modal p {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
}

.modal .btn-group {
  justify-content: flex-end;
}

.hidden {
  display: none !important;
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 34px 30px;
  text-align: center;
}

.login-card .brand-mark {
  margin: 0 auto 18px;
  width: 56px;
  height: 56px;
  font-size: 22px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.login-card p.subtitle {
  margin: 0 0 26px;
  color: var(--text-dim);
  font-size: 13px;
}

.login-card form {
  text-align: left;
}

.login-error {
  color: #f87171;
  font-size: 13px;
  margin-top: 14px;
  min-height: 16px;
}

.footer-note {
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  padding: 20px;
}

@media (max-width: 640px) {
  .container {
    padding: 18px;
  }
  .topbar {
    padding: 14px 18px;
  }
}
