:root {
  --bg0: #020617;
  --bg1: #06102a;
  --bg2: #0a1838;
  --panel: rgba(12, 24, 52, 0.55);
  --panel-hi: rgba(16, 32, 68, 0.72);
  --line: rgba(100, 170, 255, 0.14);
  --line-hi: rgba(100, 170, 255, 0.34);
  --text: #eef4ff;
  --muted: #8aa0c4;
  --accent: #4aa3ff;
  --accent-deep: #1d6fd6;
  --teal: #2ec4b6;
  --glow: rgba(74, 163, 255, 0.32);
  --danger: #ff5d6c;
  --warn: #ffc14d;
  --ok: #3dd68c;
  --radius: 20px;
  --radius-sm: 12px;
  --sidebar-w: 268px;
  --font: "Segoe UI", "Avenir Next", "Century Gothic", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-family: var(--font);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(1200px 640px at 6% -18%, rgba(48, 110, 240, 0.48), transparent 58%),
    radial-gradient(900px 520px at 100% 0%, rgba(46, 196, 182, 0.16), transparent 50%),
    radial-gradient(700px 480px at 75% 110%, rgba(74, 163, 255, 0.12), transparent 55%),
    linear-gradient(168deg, var(--bg1) 0%, var(--bg0) 52%, #01040d 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.32;
  background-image:
    linear-gradient(rgba(120, 175, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 175, 255, 0.05) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(ellipse at 35% 15%, #000 25%, transparent 72%);
}

body::after {
  content: "";
  position: fixed;
  right: -8%;
  bottom: -18%;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(46, 196, 182, 0.1), transparent 68%);
  pointer-events: none;
  z-index: 0;
  filter: blur(12px);
}

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

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  gap: 0;
}

/* ——— Sidebar ——— */
.sidebar {
  position: sticky;
  top: 16px;
  align-self: start;
  margin: 16px 0 16px 16px;
  padding: 22px 16px 16px;
  min-height: calc(100vh - 32px);
  border-radius: 24px;
  background:
    linear-gradient(165deg, rgba(22, 40, 82, 0.72), rgba(8, 16, 38, 0.78));
  border: 1px solid var(--line);
  backdrop-filter: blur(26px) saturate(1.25);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 0 0 1px rgba(74, 163, 255, 0.05);
  display: flex;
  flex-direction: column;
}

.brand-wrap {
  padding: 2px 10px 18px;
  border-bottom: 1px solid rgba(100, 170, 255, 0.12);
  margin-bottom: 16px;
}

.brand-mark-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  background: linear-gradient(145deg, #4aa3ff, #1d6fd6 55%, #2ec4b6);
  box-shadow: 0 8px 22px rgba(74, 163, 255, 0.35);
  flex-shrink: 0;
}

.sidebar .brand {
  margin: 0;
  font-size: 15px;
  font-weight: 780;
  letter-spacing: -0.03em;
  line-height: 1.2;
  background: linear-gradient(100deg, #ffffff 8%, #8ec8ff 55%, #5eead4 125%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sidebar .brand-sub {
  margin: 0;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 650;
}

.sidebar .nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 13px;
  color: var(--muted);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 560;
  transition: background .16s, color .16s, box-shadow .16s, border-color .16s, transform .12s;
}

.sidebar a .ico {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: rgba(4, 10, 24, 0.6);
  border: 1px solid rgba(100, 170, 255, 0.12);
  font-size: 13px;
  opacity: 0.92;
}

.sidebar a:hover {
  background: rgba(74, 163, 255, 0.09);
  border-color: var(--line);
  color: var(--text);
}

.sidebar a.active {
  background: linear-gradient(135deg, rgba(74, 163, 255, 0.22), rgba(46, 196, 182, 0.1));
  border-color: var(--line-hi);
  color: #fff;
  box-shadow: 0 0 32px rgba(74, 163, 255, 0.2);
}

.sidebar a.active .ico {
  background: rgba(74, 163, 255, 0.22);
  border-color: rgba(74, 163, 255, 0.4);
  color: #9fd0ff;
}

.side-foot {
  margin-top: 18px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(2, 8, 20, 0.58);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.55;
}

.side-foot strong {
  color: var(--teal);
  font-weight: 700;
}

/* ——— Main ——— */
.main {
  padding: 30px 34px 60px;
  max-width: 1280px;
}

.page-head { margin-bottom: 10px; }
.page-head h1 {
  margin: 0 0 8px;
  font-size: 30px;
  letter-spacing: -0.04em;
  font-weight: 760;
  line-height: 1.12;
}
.page-head .muted { margin: 0; max-width: 56ch; }
.page-head.with-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: 999px;
  background: rgba(6, 14, 32, 0.75);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  backdrop-filter: blur(10px);
}
.chip .live {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ——— Glass ——— */
.glass, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  backdrop-filter: blur(20px) saturate(1.2);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.055);
  position: relative;
  overflow: hidden;
}

.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(140deg, rgba(255,255,255,0.055), transparent 42%);
}

.glass + .glass, .card + .card { margin-top: 16px; }

.glass h2, .section-title {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 720;
  letter-spacing: -0.01em;
  position: relative;
}

.glass-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  position: relative;
}
.glass-head h2 { margin: 0; }

/* ——— Stats ——— */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0 20px;
}

.stat {
  padding: 18px 18px 16px;
  border-radius: 16px;
  background: linear-gradient(165deg, rgba(16, 32, 68, 0.9), rgba(6, 14, 32, 0.82));
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  transition: border-color .15s, transform .12s;
}
.stat:hover {
  border-color: var(--line-hi);
  transform: translateY(-1px);
}

.stat::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -32px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74, 163, 255, 0.2), transparent 70%);
}

.stat .k {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 680;
  position: relative;
}
.stat .v {
  font-size: 30px;
  font-weight: 800;
  margin-top: 8px;
  color: #c4e0ff;
  letter-spacing: -0.035em;
  position: relative;
}
.stat .hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  position: relative;
}

/* ——— Tool cards ——— */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
  position: relative;
}

.tool-card {
  padding: 18px 16px 15px;
  border-radius: 16px;
  background: rgba(4, 12, 28, 0.62);
  border: 1px solid var(--line);
  transition: border-color .15s, box-shadow .15s, transform .12s;
  position: relative;
  overflow: hidden;
}
.tool-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(74,163,255,0.55), transparent);
  opacity: 0;
  transition: opacity .15s;
}
.tool-card:hover {
  border-color: var(--line-hi);
  box-shadow: 0 0 32px rgba(74, 163, 255, 0.14);
  transform: translateY(-2px);
}
.tool-card:hover::before { opacity: 1; }

.tool-card .tc-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.tool-card .tc-name {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 720;
  letter-spacing: -0.025em;
}
.tool-card .tc-slug {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.tool-card .tc-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}
.tool-card .tc-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ——— Forms ——— */
.muted { color: var(--muted); font-size: 14px; line-height: 1.55; }

label {
  display: block;
  margin: 14px 0 6px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 680;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
label:first-child { margin-top: 0; }

input, textarea, select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(2, 8, 20, 0.9);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: var(--font);
}
input:focus, textarea:focus, select:focus {
  border-color: rgba(74, 163, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(74, 163, 255, 0.18);
}
textarea {
  min-height: 130px;
  font-family: var(--mono);
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.form-grid .full { grid-column: 1 / -1; }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.check-row input { width: auto; }

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  line-height: 1.2;
  transition: transform .12s, box-shadow .15s, opacity .15s, border-color .15s, background .15s;
  font-family: var(--font);
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn.primary {
  background: linear-gradient(135deg, #4aa3ff, #1d6fd6);
  color: #fff;
  box-shadow: 0 10px 30px var(--glow);
}
.btn.primary:hover { color: #fff; }
.btn.success { background: var(--ok); color: #062416; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost {
  background: rgba(6, 14, 32, 0.5);
  border: 1px solid var(--line);
  color: var(--text);
}
.btn.ghost:hover {
  border-color: rgba(74, 163, 255, 0.5);
  color: #fff;
  background: rgba(74, 163, 255, 0.1);
}
.btn.sm { padding: 7px 12px; font-size: 12px; }

/* ——— Tables ——— */
table { width: 100%; border-collapse: collapse; font-size: 14px; position: relative; }
th, td {
  text-align: left;
  padding: 13px 10px;
  border-bottom: 1px solid rgba(80, 140, 255, 0.1);
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 720;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(74, 163, 255, 0.045); }

.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
  font-size: 14px;
}

/* ——— Badges / banners ——— */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0.02em;
}
.badge.on {
  background: rgba(61, 214, 140, 0.14);
  color: var(--ok);
  border: 1px solid rgba(61, 214, 140, 0.3);
}
.badge.off {
  background: rgba(255, 93, 108, 0.12);
  color: #ff9aa4;
  border: 1px solid rgba(255, 93, 108, 0.26);
}
.badge.warn {
  background: rgba(255, 193, 77, 0.12);
  color: #ffd27a;
  border: 1px solid rgba(255, 193, 77, 0.26);
}

.banner {
  padding: 13px 16px;
  border-radius: 13px;
  margin: 0 0 16px;
  font-size: 13px;
  border: 1px solid transparent;
  line-height: 1.5;
  position: relative;
}
.banner.warn {
  background: rgba(255, 193, 77, 0.09);
  color: #ffd27a;
  border-color: rgba(255, 193, 77, 0.22);
}
.banner.ok {
  background: rgba(61, 214, 140, 0.09);
  color: #8dffc2;
  border-color: rgba(61, 214, 140, 0.22);
}
.banner.err {
  background: rgba(255, 93, 108, 0.09);
  color: #ff9b9b;
  border-color: rgba(255, 93, 108, 0.22);
}
.banner.info {
  background: rgba(74, 163, 255, 0.1);
  color: #9fd0ff;
  border-color: rgba(74, 163, 255, 0.24);
}

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; position: relative; }

/* ——— Login ——— */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  position: relative;
  z-index: 1;
}

.login-wrap {
  width: min(430px, 100%);
  padding: 34px 30px 30px;
}

.login-wrap .brand-mark {
  margin: 0 0 6px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(100deg, #fff, #8ec8ff 60%, #5eead4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login-wrap h1 {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: -0.035em;
}

.login-wrap .btn { width: 100%; margin-top: 20px; }

.login-seal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(2, 8, 20, 0.55);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-weight: 680;
}

code {
  background: rgba(2, 8, 20, 0.92);
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-family: var(--mono);
  word-break: break-all;
}
code.block {
  display: block;
  padding: 10px 12px;
  margin-top: 6px;
}

.gate {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  min-height: 100vh;
}
.gate-card { width: min(440px, 100%); }

.kv { width: 100%; }
.kv td:first-child { width: 38%; color: var(--muted); font-size: 13px; }

.pill-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  margin-right: 6px;
}

ol.steps {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
  font-size: 14px;
  position: relative;
}
ol.steps li { margin-bottom: 2px; }
ol.steps strong, ol.steps code { color: var(--text); }

.split-2 {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
  align-items: start;
}

.hero-panel {
  margin-bottom: 18px;
  padding: 22px 24px;
  border-radius: var(--radius);
  background: linear-gradient(120deg, rgba(74, 163, 255, 0.14), rgba(46, 196, 182, 0.06) 50%, rgba(12, 24, 52, 0.4));
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.hero-panel::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -50px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74,163,255,0.25), transparent 70%);
}
.hero-panel h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.04em;
  position: relative;
}
.hero-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 52ch;
  position: relative;
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-2 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    top: 0;
    min-height: 0;
    margin: 12px 12px 0;
    padding: 16px;
  }
  .sidebar .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar a { flex: 1 1 auto; }
  .side-foot { display: none; }
  .main { padding: 18px 14px 40px; }
  .form-grid { grid-template-columns: 1fr; }
  .page-head.with-actions { flex-direction: column; }
  .stats { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr; }
}
