:root {
  --bg: #0b1220;
  --bg-elev: #121b2d;
  --bg-soft: #182338;
  --line: rgba(180, 205, 235, 0.12);
  --ink: #edf3fb;
  --muted: #8fa3bd;
  --accent: #2fbfa4;
  --accent-2: #4e8cff;
  --danger: #ef6b6b;
  --warn: #e3b341;
  --ok: #3ecf8e;
  --radius: 14px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --display: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 70% 45% at 0% 0%, rgba(47, 191, 164, 0.18), transparent 55%),
    radial-gradient(ellipse 55% 40% at 100% 10%, rgba(78, 140, 255, 0.16), transparent 50%),
    linear-gradient(180deg, #0d1526 0%, var(--bg) 40%, #090e18 100%);
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(10, 16, 28, 0.72);
  backdrop-filter: blur(10px);
  padding: 1.4rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.brand {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 1.35rem;
}

.brand span { color: var(--accent); }

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav button {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
}

.nav button.active,
.nav button:hover {
  background: var(--bg-soft);
  color: var(--ink);
}

.main {
  padding: 1.5rem 1.75rem 2.5rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.topbar h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 650;
}

.muted { color: var(--muted); }
.hidden { display: none !important; }

.panel {
  background: linear-gradient(180deg, rgba(24, 35, 56, 0.95), rgba(16, 24, 40, 0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}

.stat {
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
}

.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat .value { font-size: 1.55rem; font-weight: 700; margin-top: 0.25rem; }

.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }

label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; color: var(--muted); }
input, textarea, select {
  background: #0d1524;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  color: var(--ink);
}

textarea { min-height: 90px; resize: vertical; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 0.65rem 0.95rem;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #239e88);
  color: #04231d;
  font-weight: 650;
}

.btn.secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn.danger {
  background: rgba(239, 107, 107, 0.15);
  color: #ffb4b4;
  border: 1px solid rgba(239, 107, 107, 0.35);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.table th, .table td {
  text-align: left;
  padding: 0.65rem 0.4rem;
  border-bottom: 1px solid var(--line);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  border: 1px solid var(--line);
  color: var(--muted);
}

.badge.ok { color: var(--ok); border-color: rgba(62, 207, 142, 0.35); }
.badge.warn { color: var(--warn); border-color: rgba(227, 179, 65, 0.35); }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.auth-card {
  width: min(420px, 100%);
  padding: 1.6rem;
}

.auth-card h1 {
  margin: 0 0 0.4rem;
  font-size: 2rem;
}

.tg-login-slot {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.dev-login summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: #152238;
  border: 1px solid var(--line);
  padding: 0.8rem 1rem;
  border-radius: 10px;
  max-width: 360px;
  z-index: 20;
}

.list-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
