:root {
  --bg: #06111f;
  --bg-soft: #0a1a2b;
  --surface: rgba(12, 31, 49, .9);
  --surface-2: #102840;
  --border: rgba(151, 190, 222, .16);
  --text: #f3f8fc;
  --muted: #91a8bc;
  --green: #29e2a6;
  --green-dark: #0b9d73;
  --blue: #32aef4;
  --red: #ff6b7b;
  --amber: #ffc857;
  --shadow: 0 24px 70px rgba(0, 0, 0, .28);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 85% 0%, rgba(34, 169, 255, .16), transparent 34%),
    radial-gradient(circle at 10% 90%, rgba(41, 226, 166, .11), transparent 34%),
    var(--bg);
  font-family: Tahoma, Arial, sans-serif;
  line-height: 1.75;
}
button, input, textarea, select { font: inherit; }
a { color: inherit; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: rgba(5, 18, 31, .88);
  border-left: 1px solid var(--border);
  backdrop-filter: blur(22px);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 24px; }
.brand img { width: 48px; height: 48px; filter: drop-shadow(0 10px 22px rgba(41,226,166,.22)); }
.brand strong { display: block; font-size: 17px; }
.brand small { color: var(--muted); font-size: 12px; }
.nav { display: grid; gap: 7px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: #b9c9d7;
  padding: 11px 13px; border-radius: 13px;
  transition: .18s ease;
}
.nav a:hover, .nav a.active { background: rgba(41,226,166,.09); color: var(--green); }
.nav-icon { width: 9px; height: 9px; border-radius: 50%; background: currentColor; box-shadow: 0 0 14px currentColor; }
.sidebar-bottom { position: absolute; right: 18px; left: 18px; bottom: 22px; }
.logout-button { width: 100%; }

.main { min-width: 0; padding: 30px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 28px; }
.eyebrow { color: var(--green); font-size: 12px; letter-spacing: 1.2px; font-weight: 700; }
h1 { margin: 3px 0 0; font-size: clamp(25px, 3vw, 38px); letter-spacing: -.5px; }
h2 { margin: 0; font-size: 20px; }
h3 { margin: 0; font-size: 16px; }
p { margin: 0; }
.muted { color: var(--muted); }
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card {
  background: linear-gradient(145deg, rgba(16, 40, 64, .92), rgba(8, 25, 42, .92));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 22px; }
.section { margin-bottom: 28px; scroll-margin-top: 20px; }
.section-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-end; margin-bottom: 14px; }
.section-head p { color: var(--muted); margin-top: 5px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { padding: 18px; position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; width: 90px; height: 90px; border-radius: 50%; background: currentColor; opacity: .05; left: -26px; top: -30px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-weight: 800; font-size: 28px; margin-top: 5px; }
.stat-meta { color: #b8c9d7; font-size: 12px; margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 8px; color: #dce9f3; }
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  display: block; width: 100%; min-height: 46px;
  border: 1px solid rgba(157, 193, 220, .2);
  border-radius: 13px;
  color: var(--text);
  background: rgba(3, 14, 25, .48);
  padding: 11px 13px;
  outline: none;
  transition: .18s ease;
}
textarea { min-height: 120px; resize: vertical; direction: rtl; }
.code-input { direction: ltr; text-align: left; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(41,226,166,.1); }
.hint { color: var(--muted); font-size: 12px; margin-top: 7px; }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 12px 0; }
.switch-row + .switch-row { border-top: 1px solid var(--border); }
.switch-copy strong { display: block; }
.switch-copy span { color: var(--muted); font-size: 12px; }
.switch { position: relative; width: 50px; height: 28px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: absolute; inset: 0; background: #243d51; border-radius: 999px; cursor: pointer; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 20px; height: 20px; right: 4px; top: 4px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--green-dark); }
.switch input:checked + span::after { transform: translateX(-22px); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 43px; border: 0; border-radius: 13px; padding: 9px 16px;
  color: #03130e; background: linear-gradient(135deg, var(--green), #65f0c7);
  font-weight: 800; text-decoration: none; cursor: pointer;
  box-shadow: 0 10px 28px rgba(41,226,166,.16);
  transition: transform .15s ease, opacity .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-secondary { color: var(--text); background: rgba(114, 158, 191, .12); box-shadow: none; border: 1px solid var(--border); }
.btn-danger { color: #ffdfe3; background: rgba(255,107,123,.13); box-shadow: none; border: 1px solid rgba(255,107,123,.25); }
.btn-small { min-height: 36px; padding: 6px 11px; font-size: 12px; }
.actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 18px; }

.notice { padding: 13px 16px; border-radius: 14px; margin-bottom: 16px; border: 1px solid; }
.notice-success { color: #b8ffe9; background: rgba(41,226,166,.09); border-color: rgba(41,226,166,.22); }
.notice-error { color: #ffd1d7; background: rgba(255,107,123,.09); border-color: rgba(255,107,123,.25); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge-green { color: #aaffdf; background: rgba(41,226,166,.11); }
.badge-red { color: #ffd4d9; background: rgba(255,107,123,.12); }
.badge-blue { color: #cbeeff; background: rgba(50,174,244,.12); }
.badge-amber { color: #ffe6ac; background: rgba(255,200,87,.12); }

.api-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.endpoint { padding: 17px; }
.endpoint code { direction: ltr; display: block; color: #d7edf9; background: rgba(0,0,0,.22); padding: 10px; border-radius: 10px; margin: 10px 0; overflow-wrap: anywhere; }
.key-box { direction: ltr; text-align: left; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: #a9c4d8; background: rgba(0,0,0,.24); padding: 12px; border-radius: 12px; overflow-wrap: anywhere; max-height: 110px; overflow: auto; }
pre { direction: ltr; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; color: #bbd3e3; background: rgba(0,0,0,.25); border: 1px solid var(--border); padding: 16px; border-radius: 14px; max-height: 520px; overflow: auto; }

.special-list { display: grid; gap: 12px; margin-top: 16px; }
.special-item { border: 1px solid var(--border); border-radius: 16px; background: rgba(4,16,28,.35); overflow: hidden; }
.special-summary { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 16px; }
.special-title { display: flex; gap: 10px; align-items: center; min-width: 0; }
.special-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.special-body { padding: 0 16px 16px; }
details summary { list-style: none; cursor: pointer; }
details summary::-webkit-details-marker { display: none; }

.audit { width: 100%; border-collapse: collapse; }
.audit th, .audit td { padding: 11px 9px; text-align: right; border-bottom: 1px solid var(--border); font-size: 12px; vertical-align: top; }
.audit th { color: var(--muted); font-weight: 700; }
.audit code { direction: ltr; display: inline-block; color: #b6cddd; }
.empty { text-align: center; padding: 30px; color: var(--muted); }

.login-page { display: grid; place-items: center; padding: 24px; }
.login-wrap { width: min(940px, 100%); display: grid; grid-template-columns: 1.15fr .85fr; min-height: 580px; overflow: hidden; }
.login-hero { padding: 58px; display: flex; flex-direction: column; justify-content: space-between; background: linear-gradient(155deg, rgba(41,226,166,.12), rgba(50,174,244,.06)); }
.login-logo { width: 86px; height: 86px; }
.login-hero h1 { max-width: 500px; margin-top: 26px; }
.login-points { display: grid; gap: 9px; color: #c3d5e3; }
.login-points span::before { content: "✓"; color: var(--green); margin-left: 8px; }
.login-form { padding: 48px; display: flex; flex-direction: column; justify-content: center; background: rgba(6,20,34,.92); }
.login-form h2 { font-size: 25px; margin-bottom: 6px; }
.login-form .btn { width: 100%; margin-top: 7px; }

.mobile-menu { display: none; }
@media (max-width: 1050px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { display: block; }
  .sidebar { position: fixed; right: 0; transform: translateX(105%); width: 270px; transition: .2s; box-shadow: var(--shadow); }
  body.menu-open .sidebar { transform: translateX(0); }
  .main { padding: 20px 15px; }
  .mobile-menu { display: inline-flex; }
  .grid-2, .api-grid { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-form { padding: 34px 24px; min-height: 520px; }
  .topbar { align-items: flex-start; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .special-summary { align-items: flex-start; flex-direction: column; }
  .audit { display: block; overflow-x: auto; }
}
