:root {
  --bg0: #05070d;
  --bg1: #0a1220;
  --bg2: #0f1a2e;
  --card: #121c2e;
  --line: rgba(56, 152, 255, 0.22);
  --text: #f2f6ff;
  --muted: #8fa3c4;
  --blue: #2f9bff;
  --blue-dark: #1a7de0;
  --blue-soft: rgba(47, 155, 255, 0.16);
  --glow: 0 0 40px rgba(47, 155, 255, 0.22);
  --danger: #ff5c6c;
  --warn: #f0b429;
  --ok: #3dd68c;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { overflow-x: hidden; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 420px at 15% -10%, rgba(47, 155, 255, 0.22), transparent 60%),
    radial-gradient(700px 380px at 90% 0%, rgba(47, 155, 255, 0.12), transparent 55%),
    linear-gradient(180deg, var(--bg0) 0%, var(--bg1) 48%, var(--bg2) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; color: #7ec4ff; }
code, .code { font-family: ui-monospace, Consolas, monospace; font-size: 0.85em; }
code.tiny { font-size: 0.72rem; word-break: break-all; }
.muted { color: var(--muted); }

.logo-img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 14px;
  display: block;
  background: #000;
  border: 1px solid var(--line);
  box-shadow: var(--glow);
}
.logo-img.sm { width: 44px; height: 44px; border-radius: 10px; }

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(400px, 100%);
  padding: 36px 32px 32px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(18, 28, 46, 0.98), rgba(10, 18, 32, 0.98));
  box-shadow: var(--shadow), var(--glow);
  border: 1px solid var(--line);
  text-align: center;
}
.auth-card .logo-img {
  margin: 0 auto 14px;
  width: 112px;
  height: 112px;
  border-radius: 18px;
}
.auth-card h1 {
  margin: 0 0 6px;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.auth-card h1 .pk { color: var(--blue); }
.auth-card .sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 0.95rem;
}
.auth-card form { text-align: left; }
.auth-card label { display: block; margin-bottom: 14px; font-size: 0.9rem; color: var(--muted); }
.auth-card input {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0a1220;
  color: var(--text);
  font: inherit;
}
.auth-card input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}
.auth-card .btn { width: 100%; margin-top: 4px; justify-content: center; }

.app-body { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side {
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: rgba(8, 14, 26, 0.94);
  backdrop-filter: blur(10px);
  display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh; z-index: 40;
}
.side-brand { display: flex; gap: 12px; align-items: center; padding: 4px 6px; position: relative; }
.side-brand strong { display: block; font-size: 0.95rem; font-weight: 800; line-height: 1.2; }
.side-brand small { color: var(--muted); font-size: 0.78rem; }
.side-close, .menu-btn {
  display: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  width: 42px; height: 42px;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.side-close {
  margin-left: auto;
  width: 36px; height: 36px;
}
.side nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side nav a {
  color: var(--text); padding: 11px 12px; border-radius: 12px;
  text-decoration: none; font-weight: 600; font-size: 0.92rem;
}
.side nav a.on, .side nav a:hover {
  background: var(--blue-soft);
  color: #9fd0ff;
  text-decoration: none;
}
.side-out { color: var(--muted); font-size: 0.9rem; padding: 8px 12px; }
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
  z-index: 35;
}

.main {
  padding: 24px 28px 48px;
  min-width: 0;
  width: 100%;
  overflow-x: hidden;
}
.top {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between; margin-bottom: 18px;
}
.top-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top h1 { margin: 0; font-size: 1.45rem; font-weight: 800; line-height: 1.2; }
.pill {
  font-size: 0.78rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
  background: rgba(18, 28, 46, 0.8); max-width: min(100%, 420px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.card {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}
.card h2 { margin: 0 0 12px; font-size: 1.05rem; font-weight: 800; }
.form-narrow { max-width: 560px; width: 100%; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
  padding: 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--card);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}
.stat span { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.stat strong { display: block; font-size: 1.55rem; margin-top: 4px; font-weight: 800; }
.stat.ok strong { color: var(--ok); }
.stat.warn strong { color: var(--warn); }
.stat.bad strong { color: var(--danger); }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--muted); font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: #0a1220; color: var(--text);
  font: inherit; font-weight: 500;
  max-width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}
textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: 0.82rem; background: #081018; min-height: 220px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 11px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: #162338; color: var(--text); font: inherit; cursor: pointer;
  text-decoration: none; width: fit-content; font-weight: 700;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn-primary {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 8px 24px rgba(47, 155, 255, 0.28);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-danger { background: rgba(255, 92, 108, 0.12); border-color: rgba(255, 92, 108, 0.35); color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

.files-list { display: flex; flex-direction: column; gap: 14px; }
.file-block {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(8, 16, 28, 0.65);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.file-block-head {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.file-block-head .grow { flex: 1; min-width: 0; }
.btn-sm { padding: 8px 12px; font-size: 0.82rem; white-space: nowrap; }
.file-name-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}
.file-name-list code { color: var(--text); }
.paywall-preview {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.alert {
  padding: 12px 14px; border-radius: 12px; margin-bottom: 16px;
  border: 1px solid var(--line); background: var(--card); font-weight: 600;
}
.alert-ok, .alert-success { background: rgba(61, 214, 140, 0.12); border-color: rgba(61, 214, 140, 0.35); color: #7dffb8; }
.alert-danger { background: rgba(255, 92, 108, 0.12); border-color: rgba(255, 92, 108, 0.35); color: var(--danger); }

.badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700;
  background: rgba(143, 163, 196, 0.15); color: var(--muted);
}
.badge-active { background: rgba(61, 214, 140, 0.16); color: #7dffb8; }
.badge-expired { background: rgba(240, 180, 41, 0.16); color: #ffd56a; }
.badge-suspended, .badge-revoked { background: rgba(255, 92, 108, 0.16); color: #ff8a96; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 640px; }
th, td { text-align: left; padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .03em; }
.row-actions { display: flex; gap: 10px; white-space: nowrap; }
.toolbar { margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 0.9fr; gap: 16px; align-items: start; }
.steps { margin: 0; padding-left: 18px; color: var(--muted); line-height: 1.55; }
.steps li { margin-bottom: 8px; }
.steps strong { color: var(--text); }

@media (max-width: 980px) {
  .app-body { grid-template-columns: 1fr; }
  .menu-btn { display: inline-flex; }
  .side-close { display: inline-flex; }
  .side {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: min(300px, 86vw);
    height: 100%;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 12px 0 40px rgba(0,0,0,.35);
    border-right: 1px solid var(--line);
  }
  body.nav-open .side { transform: translateX(0); }
  body.nav-open .sidebar-backdrop { display: block; }
  .main { padding: 16px 14px 36px; }
  .top h1 { font-size: 1.2rem; }
  .pill { max-width: 100%; font-size: 0.7rem; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .card { padding: 16px; border-radius: 14px; }
  .btn { width: 100%; }
  .btn-row .btn { width: auto; flex: 1 1 auto; }
  .auth-body { padding: 16px; }
  .auth-card { padding: 28px 20px 22px; border-radius: 18px; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
  .stat strong { font-size: 1.35rem; }
  table { font-size: 0.85rem; min-width: 560px; }
  .logo-img { width: 76px; height: 76px; }
  .auth-card .logo-img { width: 96px; height: 96px; }
}
