:root {
  color-scheme: dark;
  --bg: #0a0d13;
  --bg-elevated: #0e1219;
  --panel: #121722;
  --panel-hover: #151b28;
  --panel-border: #232b3a;
  --panel-border-soft: #1a2130;
  --text: #e8eaed;
  --muted: #8b95a5;
  --muted-soft: #5f6b7d;
  --accent: #3b82f6;
  --accent-hover: #559bfb;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, 0.14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --crit: #ef4444;
  --crit-soft: rgba(239, 68, 68, 0.14);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.32);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}

* { box-sizing: border-box; }

::selection { background: var(--accent); color: white; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-soft); }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(59, 130, 246, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.85rem 2.5rem;
  background: rgba(14, 18, 25, 0.85);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--panel-border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 650; letter-spacing: 0.01em; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: white;
  font-size: 0.8rem;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}
.topbar nav { display: flex; gap: 0.25rem; flex: 1; }
.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background-color 0.15s ease;
}
.topbar nav a:hover { color: var(--text); background: var(--panel-hover); }
.topbar-right { display: flex; align-items: center; gap: 0.9rem; }
.topbar .user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}
.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  background: var(--panel-hover);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.container { width: 100%; margin: 0; padding: 1.75rem 2.5rem; }

.page-header { margin-bottom: 1.25rem; }
.page-header h1 { margin: 0 0 0.2rem; font-size: 1.4rem; letter-spacing: -0.01em; }
.page-header p { margin: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1.1rem;
}

.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-elevated));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}
.panel h2 {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.panel-danger { border-color: rgba(239, 68, 68, 0.35); }
.panel-danger h2::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 999px; background: var(--crit); box-shadow: 0 0 0 3px var(--crit-soft); }

.auth-shell { min-height: calc(100vh - 0px); display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card {
  width: 100%;
  max-width: 380px;
  margin: 4rem auto;
  background: linear-gradient(180deg, var(--panel), var(--bg-elevated));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.auth-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #6366f1);
}
.auth-card-danger::before { background: linear-gradient(90deg, var(--crit), #f97316); }
.auth-card .brand-mark { margin-bottom: 0.9rem; }
.auth-card h1 { font-size: 1.25rem; margin: 0 0 0.3rem; letter-spacing: -0.01em; }
.auth-card > p.muted { margin-top: 0; margin-bottom: 1.4rem; }
.auth-card p:last-child { margin-bottom: 0; }

form label { display: block; margin: 0.9rem 0 0.35rem; font-size: 0.85rem; font-weight: 500; color: var(--muted); }
input[type=text], input[type=password] {
  width: 100%;
  padding: 0.65rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type=text]:focus, input[type=password]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn-primary { margin-top: 1.4rem; width: 100%; }
.btn-ghost { background: transparent; border-color: var(--panel-border); color: var(--muted); }
.btn-ghost:hover { background: var(--panel-hover); border-color: var(--muted-soft); color: var(--text); }
.btn-danger { background: var(--crit); border-color: var(--crit); }
.btn-danger:hover { background: #f65a5a; border-color: #f65a5a; }
.btn-small { padding: 0.35rem 0.65rem; font-size: 0.78rem; margin-right: 0.35rem; font-weight: 500; }
.inline-form { display: inline; }

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

.flash { padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.1rem; font-size: 0.88rem; font-weight: 500; }
.flash-ok { background: var(--ok-soft); border: 1px solid rgba(34, 197, 94, 0.4); color: #86efac; }
.flash-error { background: var(--crit-soft); border: 1px solid rgba(239, 68, 68, 0.4); color: #fca5a5; }

.alerts-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.1rem; }
.alert { padding: 0.65rem 1rem; border-radius: var(--radius-sm); font-size: 0.88rem; font-weight: 500; border-left: 3px solid transparent; }
.alert-critical { background: var(--crit-soft); border-left-color: var(--crit); color: #fca5a5; }
.alert-warning { background: var(--warn-soft); border-left-color: var(--warn); color: #fcd34d; }
.alert-ok { background: var(--ok-soft); border-left-color: var(--ok); color: #86efac; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  border: 1px solid var(--panel-border);
  background: var(--panel-hover);
}
.badge::before { content: ""; width: 0.4rem; height: 0.4rem; border-radius: 999px; background: currentColor; }
.badge-ok { color: var(--ok); border-color: rgba(34, 197, 94, 0.35); background: var(--ok-soft); }
.badge-warn { color: var(--warn); border-color: rgba(245, 158, 11, 0.35); background: var(--warn-soft); }
.badge-crit { color: var(--crit); border-color: rgba(239, 68, 68, 0.35); background: var(--crit-soft); }

.metric-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.metric-label { color: var(--muted); font-size: 0.87rem; }
.metric-value { font-weight: 700; font-variant-numeric: tabular-nums; }

.meter { height: 6px; background: var(--panel-border-soft); border-radius: 999px; margin-top: 0.35rem; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--ok), #4ade80); transition: width 0.4s ease; }
.meter-fill.meter-warn { background: linear-gradient(90deg, var(--warn), #fbbf24); }
.meter-fill.meter-crit { background: linear-gradient(90deg, var(--crit), #f87171); }

.table-wrap {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  overflow: auto;
  background: linear-gradient(180deg, var(--panel), var(--bg-elevated));
  box-shadow: var(--shadow-sm);
}
.table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.table th {
  text-align: left;
  padding: 0.75rem 1rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.015);
  position: sticky;
  top: 0;
}
.table td { text-align: left; padding: 0.7rem 1rem; border-bottom: 1px solid var(--panel-border-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

.code-block {
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 0.8rem;
  overflow-x: auto;
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 0.75rem; padding: 0.75rem 1.1rem; }
  .container { padding: 1.1rem 1.1rem; }
  .grid { grid-template-columns: 1fr; }
}
