:root {
  --bg: #0b1220;
  --panel: #121b2e;
  --panel-2: #17233a;
  --text: #f7fbff;
  --muted: #9fb0c9;
  --line: rgba(255,255,255,.10);
  --primary: #2f7df6;
  --primary-2: #1ec7ff;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --shadow: 0 24px 80px rgba(0,0,0,.30);
}

html[data-theme="light"] {
  --bg: #eef3fb;
  --panel: #ffffff;
  --panel-2: #f7f9fd;
  --text: #111827;
  --muted: #667085;
  --line: rgba(15,23,42,.12);
  --shadow: 0 18px 50px rgba(15,23,42,.10);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(47,125,246,.25), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(30,199,255,.12), transparent 26rem),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
}
textarea { resize: vertical; }
label { display: block; font-weight: 700; margin-bottom: 8px; color: var(--text); }
small, .muted { color: var(--muted); }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 282px;
  padding: 22px;
  background: rgba(8, 13, 25, .86);
  border-right: 1px solid var(--line);
  position: fixed;
  inset: 0 auto 0 0;
  backdrop-filter: blur(18px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  transition: transform .24s ease;
}
html[data-theme="light"] .sidebar { background: rgba(255,255,255,.88); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand.big { margin-bottom: 32px; }
.brand-mark {
  width: 48px; height: 48px;
  border-radius: 18px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-weight: 900;
  box-shadow: 0 14px 38px rgba(47,125,246,.35);
}
.brand strong { display: block; letter-spacing: -.02em; }
.brand span { display: block; color: var(--muted); font-size: .82rem; }
.menu { margin-top: 28px; display: grid; gap: 8px; }
.menu a {
  padding: 13px 14px;
  border-radius: 14px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: .2s ease;
}
.menu a:hover, .menu a.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(47,125,246,.95), rgba(30,199,255,.75));
  box-shadow: 0 14px 40px rgba(47,125,246,.22);
}
html[data-theme="light"] .menu a:hover, html[data-theme="light"] .menu a.active { color: #fff; }
.menu-label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .10em; margin: 16px 6px 4px; }
.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.sidebar-footer span, .sidebar-footer small { display: block; }
.main-content { flex: 1; margin-left: 282px; padding: 24px; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 22px;
  background: rgba(18,27,46,.72);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  backdrop-filter: blur(16px);
}
html[data-theme="light"] .topbar { background: rgba(255,255,255,.72); }
.topbar h1 { margin: 0; font-size: clamp(1.3rem, 2vw, 2rem); }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.hamburger { display: none; border: 0; background: var(--panel-2); color: var(--text); border-radius: 12px; padding: 10px 13px; }

.panel, .stat-card {
  background: rgba(18,27,46,.82);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
html[data-theme="light"] .panel, html[data-theme="light"] .stat-card { background: rgba(255,255,255,.86); }
.panel { padding: 20px; margin-bottom: 22px; }
.panel h2 { margin-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { padding: 20px; overflow: hidden; position: relative; }
.stat-card::after { content: ''; position: absolute; inset: auto -20px -36px auto; width: 110px; height: 110px; border-radius: 999px; background: rgba(47,125,246,.16); }
.stat-card span { color: var(--muted); font-weight: 700; }
.stat-card strong { display: block; font-size: clamp(1.6rem, 3vw, 2.35rem); margin: 10px 0 4px; }
.danger-soft::after { background: rgba(239,68,68,.20); }
.content-grid { display: grid; gap: 22px; }
.content-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.btn, .theme-toggle {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 14px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .15s ease, opacity .15s ease;
}
.btn:hover, .theme-toggle:hover { transform: translateY(-1px); opacity: .95; }
.btn-primary { border: 0; color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); font-weight: 800; }
.btn-ghost { background: transparent; }
.btn-danger { background: rgba(239,68,68,.15); color: #fecaca; border-color: rgba(239,68,68,.35); }
.btn-sm { padding: 8px 10px; border-radius: 11px; font-size: .85rem; }
.full { width: 100%; }

.table-wrap { width: 100%; overflow-x: auto; border-radius: 18px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .80rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: rgba(255,255,255,.03); }
tr:last-child td { border-bottom: 0; }
.low-row { background: rgba(239,68,68,.14); }
.low-row td:first-child { border-left: 3px solid var(--danger); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }
.pill { display: inline-flex; padding: 6px 10px; border-radius: 999px; font-weight: 800; font-size: .78rem; }
.pill.ok { background: rgba(34,197,94,.14); color: #86efac; }
.pill.warn { background: rgba(245,158,11,.14); color: #fcd34d; }
.pill.danger { background: rgba(239,68,68,.14); color: #fecaca; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.stack-form { display: grid; gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; }
.full-col { grid-column: 1 / -1; }
.plan-box { padding: 15px; border-radius: 16px; background: var(--panel-2); border: 1px solid var(--line); }
.search-form { display: flex; gap: 10px; width: min(620px, 100%); }
.alert { border-radius: 16px; padding: 13px 15px; margin-bottom: 16px; border: 1px solid var(--line); }
.alert-success { background: rgba(34,197,94,.13); color: #bbf7d0; }
.alert-error { background: rgba(239,68,68,.13); color: #fecaca; }

.login-body { display: grid; place-items: center; padding: 24px; }
.login-grid { width: min(1120px, 100%); display: grid; grid-template-columns: 1.1fr .8fr; gap: 22px; align-items: stretch; }
.login-hero, .login-card, .offline-panel {
  background: rgba(18,27,46,.80);
  border: 1px solid var(--line);
  border-radius: 30px;
  box-shadow: var(--shadow);
  padding: clamp(24px, 4vw, 44px);
  backdrop-filter: blur(18px);
}
.login-hero h1 { font-size: clamp(2rem, 5vw, 4rem); line-height: 1.02; letter-spacing: -.05em; margin: 0 0 20px; }
.login-hero p { color: var(--muted); font-size: 1.08rem; max-width: 660px; }
.login-card h2 { margin: 0 0 8px; font-size: 1.8rem; }
.login-card form { display: grid; gap: 12px; margin: 20px 0; }
.hero-cards { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.hero-cards span { padding: 10px 13px; border-radius: 999px; background: rgba(47,125,246,.14); border: 1px solid rgba(47,125,246,.25); color: #dbeafe; }
.offline-body { padding: 20px; display: grid; place-items: start center; }
.offline-panel { width: min(920px, 100%); }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid.two, .login-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { transform: translateX(-105%); width: min(88vw, 320px); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 14px; }
  .hamburger { display: inline-flex; }
  .topbar { align-items: flex-start; padding: 14px; }
  .top-actions { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
  .stats-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .responsive-head { align-items: stretch; flex-direction: column; }
  .search-form { flex-direction: column; }
  .login-body { padding: 14px; }
  .login-hero, .login-card { padding: 22px; border-radius: 24px; }
  .hero-cards span { width: 100%; }
}
