:root {
  color-scheme: dark;
  --bg: #08111f;
  --bg2: #0d1728;
  --panel: rgba(20, 31, 49, .92);
  --panel2: #111c2e;
  --line: rgba(148, 163, 184, .18);
  --text: #e5eefb;
  --muted: #94a3b8;
  --soft: #64748b;
  --accent: #38bdf8;
  --accent2: #f59e0b;
  --good: #22c55e;
  --warn: #facc15;
  --bad: #ef4444;
  --shadow: 0 24px 80px rgba(0, 0, 0, .35);
  --radius: 18px;
  --radius-sm: 12px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(circle at 10% 0%, rgba(56, 189, 248, .13), transparent 30%),
    radial-gradient(circle at 90% 8%, rgba(245, 158, 11, .10), transparent 25%),
    linear-gradient(135deg, var(--bg), #0a1020 60%, #070d18);
}

button, input, select {
  font: inherit;
}

button {
  border: 0;
}

.hidden { display: none !important; }

.auth-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(15, 23, 42, .78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.brand-block, .brand, .topbar, .topbar-actions, .row-actions {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 14px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  color: #06111f;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  box-shadow: 0 10px 30px rgba(56, 189, 248, .2);
}

.brand-block h1, .brand-block p {
  margin: 0;
}

.brand-block p, .auth-footer, .eyebrow, small, .muted {
  color: var(--muted);
}

.auth-card label {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 13px;
}

input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: rgba(8, 17, 31, .82);
  padding: 10px 12px;
  outline: none;
}

input:focus, select:focus {
  border-color: rgba(56, 189, 248, .7);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, .12);
}

.primary-btn, .ghost-btn, .danger-btn, .success-btn {
  min-height: 40px;
  padding: 9px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 800;
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
}

.primary-btn {
  color: #06111f;
  background: linear-gradient(135deg, var(--accent), #7dd3fc);
}

.success-btn {
  color: #04150a;
  background: linear-gradient(135deg, var(--good), #86efac);
}

.danger-btn {
  color: white;
  background: linear-gradient(135deg, #dc2626, var(--bad));
}

.ghost-btn {
  color: var(--text);
  background: rgba(148, 163, 184, .12);
  border: 1px solid var(--line);
}

.primary-btn:hover, .ghost-btn:hover, .danger-btn:hover, .success-btn:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: .55;
  cursor: wait;
  transform: none;
}

.full { width: 100%; }

.notice {
  padding: 12px 14px;
  border-radius: 12px;
  margin: 12px 0;
  font-size: 14px;
}

.notice.error {
  color: #fecaca;
  background: rgba(127, 29, 29, .45);
  border: 1px solid rgba(248, 113, 113, .35);
}

.notice.success {
  color: #bbf7d0;
  background: rgba(20, 83, 45, .45);
  border: 1px solid rgba(74, 222, 128, .35);
}

.auth-footer {
  text-align: center;
  font-size: 12px;
  margin: 18px 0 0;
}

.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px;
  background: rgba(8, 17, 31, .72);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(22px);
}

.brand {
  gap: 12px;
  color: inherit;
  text-decoration: none;
  margin-bottom: 22px;
}

.brand strong, .brand small {
  display: block;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  background: transparent;
  border-radius: 14px;
  padding: 11px 12px;
  cursor: pointer;
}

.nav button:hover, .nav button.active {
  color: var(--text);
  background: rgba(56, 189, 248, .12);
}

.nav button.active {
  border: 1px solid rgba(56, 189, 248, .25);
}

.sidebar-card {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 28, 46, .72);
}

.sidebar-card strong {
  display: block;
  margin: 5px 0 12px;
  overflow-wrap: anywhere;
}

.main {
  padding: 24px;
  min-width: 0;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
}

.topbar-actions {
  gap: 10px;
}

.search {
  width: min(300px, 36vw);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(20, 31, 49, .9), rgba(13, 23, 40, .9));
  box-shadow: 0 10px 35px rgba(0, 0, 0, .18);
}

.stat-card strong {
  display: block;
  font-size: 26px;
  color: var(--accent);
  margin-bottom: 3px;
}

.panel {
  min-height: 380px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 290px);
  border: 1px solid var(--line);
  border-radius: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th, td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: #0b1424;
  color: #bae6fd;
  z-index: 1;
}

tbody tr:hover {
  background: rgba(148, 163, 184, .08);
}

code {
  color: #fbbf24;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge.admin { color: #1f1300; background: #fbbf24; }
.badge.user { color: #dbeafe; background: rgba(59, 130, 246, .25); }
.badge.good { color: #052e16; background: #86efac; }
.badge.bad { color: #fee2e2; background: rgba(239, 68, 68, .55); }

.signal-high { color: #4ade80; font-weight: 800; }
.signal-mid { color: #fde047; font-weight: 800; }
.signal-low { color: #f87171; font-weight: 800; }

.empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--muted);
  text-align: center;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}

.info-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(8, 17, 31, .55);
}

.info-card h3 {
  margin: 0 0 10px;
}

.info-card p {
  color: var(--muted);
  margin: 6px 0;
}

.row-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.row-actions button {
  min-height: 32px;
  padding: 6px 9px;
  border-radius: 9px;
  font-size: 12px;
}

.modal {
  width: min(520px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 0;
  color: var(--text);
  background: var(--panel2);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(4px);
}

.modal-inner {
  padding: 20px;
}

.modal h2 {
  margin: 0 0 14px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

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

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    padding: 14px;
  }

  .sidebar-card {
    position: static;
    margin-top: 14px;
  }

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

  .main {
    padding: 14px;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .search {
    width: 100%;
  }

  .stats-grid, .grid-2 {
    grid-template-columns: 1fr;
  }
}
