:root {
  --primary: #a78bfa;
  --primary-hover: #8d6ee0;
  --secondary: #7c5ce7;
  --accent: #4aa3f0;
  --success: #00b894;
  --error: #e74c3c;
  --warning: #fdcb6e;
  --bg: #0a0a12;
  --card-bg: rgba(16, 16, 30, 0.65);
  --card-bg-solid: #14141f;
  --text: #f0f0ff;
  --text-muted: rgba(240, 240, 255, 0.6);
  --border: rgba(255, 255, 255, 0.08);
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  --sidebar-width: 240px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', 'Segoe UI', sans-serif;
}

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

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

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--card-bg-solid);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-brand {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 24px;
  padding: 0 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  transition: background .2s ease, color .2s ease;
}

.sidebar a:hover {
  background: rgba(167, 139, 250, 0.1);
  color: var(--text);
}

.sidebar a.active {
  background: rgba(167, 139, 250, 0.16);
  color: var(--primary);
}

.sidebar .spacer {
  flex: 1;
}

.main {
  flex: 1;
  padding: 28px 32px;
  max-width: 1200px;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 6px;
}

.page-sub {
  color: var(--text-muted);
  margin: 0 0 26px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 900px) {
  .grid-4, .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
  .sidebar {
    display: none;
  }
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.card h3 {
  margin: 0 0 4px;
  font-size: .95rem;
  color: var(--text-muted);
  font-weight: 500;
}

.card .value {
  font-size: 1.7rem;
  font-weight: 700;
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 8px;
}

.status-dot.ok {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-dot.down {
  background: var(--error);
  box-shadow: 0 0 8px var(--error);
}

.section {
  margin-top: 30px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-head h2 {
  font-size: 1.15rem;
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: .92rem;
}

th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  transition: all .2s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.btn-primary {
  background: linear-gradient(135deg, var(--secondary), var(--accent));
  border: none;
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-danger {
  border-color: rgba(231, 76, 60, 0.4);
  color: var(--error);
}

.btn-danger:hover {
  background: rgba(231, 76, 60, 0.12);
}

.btn-sm {
  padding: 6px 12px;
  font-size: .8rem;
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}

.badge.on {
  background: rgba(0, 184, 148, 0.15);
  color: var(--success);
}

.badge.off {
  background: rgba(231, 76, 60, 0.15);
  color: var(--error);
}

.badge.role-admin {
  background: rgba(167, 139, 250, 0.18);
  color: var(--primary);
}

.badge.role-user {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

label {
  display: block;
  font-size: .85rem;
  color: var(--text-muted);
  margin: 14px 0 6px;
}

input, select {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: .92rem;
  font-family: inherit;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

.form-row {
  display: flex;
  gap: 14px;
}

.form-row > * {
  flex: 1;
}

.hint {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--card-bg-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
}

.modal h3 {
  margin-top: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.token-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: monospace;
  font-size: .85rem;
  word-break: break-all;
  margin: 14px 0;
}

.toast-wrap {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast {
  background: var(--card-bg-solid);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  min-width: 240px;
  box-shadow: var(--shadow);
  font-size: .88rem;
  animation: toast-in .25s ease;
}

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

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

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

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

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-card .sidebar-brand {
  font-size: 1.4rem;
  text-align: center;
  margin-bottom: 22px;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  font-weight: 600;
  font-size: .9rem;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--primary);
}

.tab-panel {
  display: none;
}

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

.empty {
  color: var(--text-muted);
  font-size: .9rem;
  padding: 20px 0;
  text-align: center;
}

.doc-json {
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: monospace;
  font-size: .8rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 280px;
  overflow: auto;
}

.breadcrumb {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.breadcrumb a {
  color: var(--text-muted);
}

.breadcrumb a:hover {
  color: var(--primary);
}

.logs-console {
  background: var(--bg);
  color: #e6f0ff;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius-sm);
  max-height: 380px;
  overflow-y: auto;
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: .82rem;
  box-shadow: 0 0 18px rgba(167, 139, 250, 0.15);
}

.log-entry {
  border-bottom: 1px dashed var(--border);
  padding: 8px 0;
  transition: background .2s ease-in-out;
}

.log-entry:hover {
  background: rgba(167, 139, 250, 0.1);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-label {
  font-weight: bold;
  color: var(--accent);
}

.log-pagination {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: .85rem;
}
