:root {
  --bg: #0c0a10;
  --panel: #14101c;
  --card: #1a1524;
  --border: #2a2438;
  --text: #f2eef8;
  --muted: #9a91ab;
  --accent: #a78bfa;
  --accent2: #f0b429;
  --danger: #f87171;
  --ok: #4ade80;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, #2a1540 0%, transparent 50%),
    radial-gradient(800px 400px at 100% 0%, #1a1030 0%, transparent 40%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.hidden { display: none !important; }
.view { min-height: 100vh; }

/* Login */
#view-login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 24px 80px #0008;
}
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 22px; }
.brand h1 { margin: 0; font-size: 1.35rem; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }
.logo {
  width: 48px; height: 48px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: grid; place-items: center; font-weight: 700; font-size: 1.1rem;
}
.brand.compact .logo { width: 36px; height: 36px; font-size: 0.9rem; }
label { display: block; font-size: 0.8rem; color: var(--muted); margin: 12px 0 6px; }
input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
input:focus { outline: 2px solid #a78bfa55; border-color: var(--accent); }
.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  border: none;
  width: 100%;
  margin-top: 16px;
}
.btn.primary.small { width: auto; margin: 0; padding: 6px 10px; font-size: 0.8rem; }
.btn.danger { color: var(--danger); border-color: #f8717144; }
.btn.ghost { background: transparent; width: 100%; margin-top: auto; }
.hint { color: var(--muted); font-size: 0.78rem; margin-top: 14px; }
.hint code { font-family: var(--mono); font-size: 0.75rem; }
.error { color: var(--danger); font-size: 0.9rem; }

/* Shell */
#view-app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; margin-top: 18px; flex: 1; }
.nav {
  text-align: left;
  background: transparent;
  border: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.nav:hover, .nav.active { background: #a78bfa22; color: var(--text); }
.content { flex: 1; padding: 22px 28px 40px; max-width: 1200px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.topbar h2 { margin: 0; font-size: 1.4rem; }
.badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: #4ade8022;
  color: var(--ok);
  border: 1px solid #4ade8044;
}
.grid.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 900px) {
  #view-app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar nav { flex-direction: row; flex: none; margin: 0; }
  .grid.stats { grid-template-columns: repeat(2, 1fr); }
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.card h3 { margin: 0 0 10px; font-size: 1rem; }
.stat .label { display: block; color: var(--muted); font-size: 0.8rem; }
.stat strong { font-size: 1.6rem; }
.mono {
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-all;
  color: #d4cce8;
  background: var(--bg);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.row.between { justify-content: space-between; align-items: center; margin-bottom: 10px; }
.muted { color: var(--muted); margin: 0; }
.table-wrap { overflow: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:hover td { background: #ffffff06; }
.star { color: var(--accent2); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: #1e1830; border: 1px solid var(--border);
  padding: 12px 16px; border-radius: 10px;
  box-shadow: 0 12px 40px #0008; z-index: 50;
  max-width: 360px;
}
