:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --elevated: #334155;
  --border: rgba(51, 65, 85, 0.55);
  --accent: #6366f1;
  --accent-soft: #818cf8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #f8fafc;
  --muted: #94a3b8;
  --radius: 12px;
  --font: "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body.aether-body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(99, 102, 241, 0.18), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(16, 185, 129, 0.08), transparent 50%),
    var(--bg);
}

[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin-top: 10px; }
.glass {
  background: rgba(30, 41, 59, 0.62);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius);
}

.login-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(380px, 100%);
  padding: 28px;
  display: grid;
  gap: 14px;
}
.brand {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.field { display: grid; gap: 6px; }
.field span { color: var(--muted); font-size: 12px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.75);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.btn {
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  color: var(--text);
  background: var(--elevated);
  font: inherit;
}
.btn.primary { background: var(--accent); }
.btn.secondary { background: rgba(99, 102, 241, 0.22); border: 1px solid rgba(99, 102, 241, 0.35); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { background: rgba(239, 68, 68, 0.2); color: #fecaca; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100%;
}
.sidebar {
  margin: 12px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-radius: 16px;
}
.sidebar-brand {
  font-size: 20px;
  font-weight: 700;
  padding: 4px 10px 12px;
}
.nav { display: grid; gap: 4px; flex: 1; }
.nav-item {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active {
  background: rgba(99, 102, 241, 0.18);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.25);
}
.pill {
  background: var(--danger);
  color: white;
  border-radius: 999px;
  min-width: 18px;
  padding: 1px 6px;
  font-size: 11px;
  text-align: center;
}
.logout { margin-top: auto; }

.main { padding: 16px 20px 28px 8px; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
}
.topbar h1 { margin: 0; font-size: 24px; font-weight: 600; }
.topbar-actions { display: flex; gap: 8px; }

.view { display: grid; gap: 14px; }
.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.stat-card {
  padding: 14px 16px;
}
.stat-card .label { color: var(--muted); font-size: 12px; }
.stat-card .value { font-size: 22px; font-weight: 650; margin-top: 6px; }

.card { padding: 16px; }
.card h2, .card h3 { margin: 0 0 10px; font-size: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  vertical-align: top;
}
.table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(148, 163, 184, 0.18);
}
.badge.live, .badge.active, .badge.success { background: rgba(16,185,129,0.18); color: #6ee7b7; }
.badge.warning, .badge.paused { background: rgba(245,158,11,0.18); color: #fcd34d; }
.badge.danger, .badge.error, .badge.critical { background: rgba(239,68,68,0.18); color: #fca5a5; }
.badge.info { background: rgba(99,102,241,0.18); color: #c7d2fe; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.media-item {
  overflow: hidden;
  padding: 0;
}
.media-item img, .media-item video {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  background: #0b1220;
}
.media-meta { padding: 8px 10px 10px; display: grid; gap: 6px; }
.media-meta a { color: var(--accent-soft); text-decoration: none; word-break: break-all; font-size: 12px; }

.chart {
  width: 100%;
  height: 180px;
  display: block;
}

.toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 50;
}
.toast {
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(30,41,59,0.95);
  border: 1px solid rgba(255,255,255,0.08);
  min-width: 220px;
  animation: slide 0.2s ease;
}
@keyframes slide {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.modal-root {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 20px;
}
.modal {
  width: min(640px, 100%);
  max-height: min(80vh, 720px);
  overflow: auto;
  padding: 20px;
}
.modal h2 { margin: 0 0 8px; }
.alert-list { display: grid; gap: 8px; margin: 14px 0; }
.alert-item {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(15,23,42,0.55);
  border: 1px solid rgba(255,255,255,0.05);
}
.alert-item .title { font-weight: 600; }
.stack { display: grid; gap: 10px; }
.form-grid { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }

.ai-out {
  white-space: pre-wrap;
  line-height: 1.45;
  background: rgba(15,23,42,0.5);
  border-radius: 8px;
  padding: 12px;
  min-height: 120px;
}

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { margin: 8px 8px 0; }
  .nav { grid-template-columns: repeat(2, 1fr); }
  .grid-stats { grid-template-columns: 1fr 1fr; }
  .main { padding: 12px; }
  .form-grid { grid-template-columns: 1fr; }
}
