:root {
  --bg: #06080f;
  --surface: rgba(15, 23, 42, 0.72);
  --surface-2: rgba(0, 0, 0, 0.35);
  --border: rgba(34, 211, 238, 0.12);
  --accent: #22d3ee;
  --accent-2: #3b82f6;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius: 16px;
  --shadow: 0 0 50px rgba(34, 211, 238, 0.06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'DM Sans', 'Space Grotesk', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(34, 211, 238, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(59, 130, 246, 0.08), transparent);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: rgba(8, 12, 22, 0.95);
  border-right: 1px solid var(--border);
  padding: 1.5rem;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}
.sidebar.open { transform: translateX(0); }
@media (min-width: 1024px) {
  .sidebar { transform: none; position: sticky; height: 100vh; }
  .main-wrap { margin-left: 0; }
}

.brand {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 2rem; padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(34,211,238,0.2), rgba(59,130,246,0.2));
  border: 1px solid var(--border);
  display: grid; place-items: center; font-size: 1.25rem;
}
.brand h1 { margin: 0; font-size: 1.1rem; font-weight: 700; }
.brand p { margin: 0; font-size: 0.7rem; color: var(--accent); letter-spacing: 0.08em; text-transform: uppercase; }

.nav { list-style: none; padding: 0; margin: 0; }
.nav li { margin-bottom: 0.25rem; }
.nav a {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.65rem 0.85rem; border-radius: 10px;
  color: var(--muted); font-size: 0.9rem; font-weight: 500;
  text-decoration: none; transition: all 0.15s;
}
.nav a:hover, .nav a.active {
  background: rgba(34, 211, 238, 0.08);
  color: var(--accent);
}
.nav a.logout { color: var(--danger); margin-top: 2rem; }
.nav a.logout:hover { background: rgba(248, 113, 113, 0.1); }

.main-wrap { flex: 1; min-width: 0; }
.main { padding: 1.25rem; max-width: 1280px; }
@media (min-width: 1024px) { .main { padding: 2rem 2.5rem; } }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap;
}
.menu-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-size: 1.25rem;
}
@media (min-width: 1024px) { .menu-btn { display: none; } }

.page-title { margin: 0; font-size: 1.75rem; font-weight: 700; }
.page-sub { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.85rem; }
.user-pill {
  padding: 0.5rem 1rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 0.85rem;
}

.glass {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section { margin-bottom: 2.5rem; scroll-margin-top: 1rem; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.section-head h2 { margin: 0; font-size: 1.25rem; font-weight: 600; }
.section-head p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.85rem; }

.stats-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  margin-bottom: 2rem;
}
.stat-card {
  padding: 1.25rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover { border-color: rgba(34,211,238,0.3); transform: translateY(-2px); }
.stat-card .label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .value { font-size: 1.75rem; font-weight: 700; margin-top: 0.35rem; }
.stat-card .value.green { color: var(--success); }
.stat-card .value.cyan { color: var(--accent); }

.module-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin-bottom: 2rem;
}
.module-card {
  padding: 1rem 1.25rem; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.module-card .name { font-weight: 600; font-size: 0.9rem; }
.module-card .status { font-size: 0.75rem; padding: 0.2rem 0.6rem; border-radius: 999px; }
.status-on { background: rgba(52,211,153,0.15); color: var(--success); }
.status-off { background: rgba(148,163,184,0.15); color: var(--muted); }

.form-grid { display: grid; gap: 1rem; }
@media (min-width: 768px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } }

.field, .toggle-field {
  padding: 1rem 1.25rem; border-radius: 14px;
  background: var(--surface-2); border: 1px solid rgba(255,255,255,0.05);
}
.toggle-field {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.toggle-field span { font-size: 0.9rem; }
.field label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.5rem; }

input[type="text"], input[type="number"], input[type="password"], textarea, select {
  width: 100%; padding: 0.75rem 1rem; border-radius: 10px;
  background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.08);
  color: var(--text); font: inherit; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }

input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 1.5rem; border-radius: 12px; border: none;
  font: inherit; font-weight: 600; cursor: pointer; transition: opacity 0.15s, transform 0.15s;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #000; }
.btn-secondary { background: rgba(59,130,246,0.2); color: #93c5fd; }
.btn-success { background: rgba(52,211,153,0.2); color: var(--success); }
.btn-danger { background: rgba(248,113,113,0.15); color: var(--danger); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; border-radius: 8px; }

.list-item {
  padding: 1rem 1.25rem; border-radius: 14px;
  background: var(--surface-2); border: 1px solid rgba(255,255,255,0.05);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem;
  margin-bottom: 0.75rem;
}
.list-item h3 { margin: 0 0 0.35rem; font-size: 0.95rem; }
.list-item .meta { font-size: 0.75rem; color: var(--muted); }
.list-item .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.alert {
  padding: 1rem 1.25rem; border-radius: 12px; font-size: 0.85rem;
  margin-bottom: 1.5rem; line-height: 1.5;
}
.alert-warning { background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.25); color: #fde68a; }
.alert-info { background: rgba(34,211,238,0.08); border: 1px solid var(--border); color: var(--muted); }

.hidden { display: none !important; }
.empty { text-align: center; padding: 2.5rem; color: var(--muted); }

.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 100;
  padding: 0.85rem 1.25rem; border-radius: 12px;
  background: rgba(15,23,42,0.95); border: 1px solid var(--success);
  color: var(--success); font-size: 0.9rem; font-weight: 500;
  transform: translateY(120%); transition: transform 0.3s ease;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
.toast.show { transform: translateY(0); }
.toast.error { border-color: var(--danger); color: var(--danger); }

code { font-size: 0.85em; padding: 0.15rem 0.4rem; border-radius: 6px; background: rgba(0,0,0,0.4); color: var(--accent); }

.overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 30;
}
.overlay.show { display: block; }
@media (min-width: 1024px) { .overlay { display: none !important; } }

.two-col { display: grid; gap: 1.5rem; }
@media (min-width: 1024px) { .two-col { grid-template-columns: 1fr 1fr; } }

.progress { height: 6px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; margin: 0.75rem 0; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.3s; width: 0; }

.telegram-hint {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem;
  border-radius: 14px; background: linear-gradient(135deg, rgba(34,211,238,0.08), rgba(59,130,246,0.08));
  border: 1px solid var(--border); margin-bottom: 2rem;
}
.telegram-hint strong { color: var(--accent); }
