:root {
  --bg: #0b120e;
  --surface: #121b15;
  --surface-2: #182419;
  --line: #223326;
  --green: #34d17b;
  --green-soft: rgba(52, 209, 123, 0.14);
  --green-dim: #1f7a4d;
  --text: #e9f5ec;
  --muted: #8fa89a;
  --amber: #f0b429;
  --red: #ef5350;
  --radius: 16px;
  --font-ui: "Manrope", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(700px 400px at 85% -10%, rgba(52, 209, 123, 0.08), transparent 60%),
    radial-gradient(600px 500px at -10% 100%, rgba(52, 209, 123, 0.05), transparent 60%);
}

a { color: var(--green); text-decoration: none; }
h1, h2, h3 { font-weight: 800; letter-spacing: -0.02em; }
h1 { font-size: 1.6rem; margin-bottom: 4px; }
h2 { font-size: 1.15rem; margin-bottom: 12px; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-size: 0.85em; }
.page-sub { color: var(--muted); margin-bottom: 24px; font-size: 0.95rem; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  display: flex; flex-direction: column; gap: 4px;
  background: rgba(11, 18, 14, 0.7);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; padding: 0 8px; }
.brand-badge {
  width: 40px; height: 40px; border-radius: 12px; position: relative;
  background: linear-gradient(135deg, var(--green), var(--green-dim));
  display: grid; place-items: center; font-size: 20px;
  box-shadow: 0 0 24px rgba(52, 209, 123, 0.35);
}
.brand-badge::after {
  content: ""; position: absolute; inset: -5px; border-radius: 16px;
  border: 1px solid rgba(52, 209, 123, 0.4);
  animation: ring 2.6s ease-out infinite;
}
@keyframes ring {
  0% { transform: scale(0.85); opacity: 1; }
  100% { transform: scale(1.35); opacity: 0; }
}
.brand b { font-size: 1.05rem; }
.brand small { display: block; color: var(--muted); font-size: 0.72rem; }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 12px;
  color: var(--muted); font-weight: 600; font-size: 0.93rem;
  transition: background 0.18s, color 0.18s, transform 0.18s;
}
.nav-link:hover { color: var(--text); background: var(--surface); transform: translateX(2px); }
.nav-link.active { color: var(--green); background: var(--green-soft); }
.nav-spacer { flex: 1; }

.main { flex: 1; padding: 32px clamp(16px, 4vw, 48px) 96px; max-width: 1160px; width: 100%; margin: 0 auto; }

/* мобильная навигация */
.mobile-top { display: none; }
.bottom-nav { display: none; }

@media (max-width: 820px) {
  .sidebar { display: none; }
  .mobile-top {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 30;
    padding: 12px 16px; border-bottom: 1px solid var(--line);
    background: rgba(11, 18, 14, 0.85); backdrop-filter: blur(12px);
  }
  .main { padding: 20px 16px 100px; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: rgba(14, 22, 17, 0.92); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    flex: 1; text-align: center; color: var(--muted);
    font-size: 0.68rem; font-weight: 700; padding: 6px 2px; border-radius: 10px;
  }
  .bottom-nav a span { display: block; font-size: 1.25rem; margin-bottom: 1px; }
  .bottom-nav a.active { color: var(--green); }
}

/* ---------- cards ---------- */
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  position: relative; overflow: hidden;
  animation: rise 0.45s ease both;
}
.card + .card, .section { margin-top: 16px; }
.card.accent::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--green), transparent);
  background-size: 200% 100%;
  animation: scan 3s linear infinite;
}
@keyframes scan { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: rise 0.45s ease both; }
.stagger > *:nth-child(2) { animation-delay: 0.06s; }
.stagger > *:nth-child(3) { animation-delay: 0.12s; }
.stagger > *:nth-child(4) { animation-delay: 0.18s; }
.stagger > *:nth-child(5) { animation-delay: 0.24s; }
.stagger > *:nth-child(6) { animation-delay: 0.3s; }

.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1000px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 820px) {
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }

.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.stat .value { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 700; margin-top: 4px; color: var(--text); }
.stat .value small { font-size: 0.85rem; color: var(--muted); }

/* ---------- статусные точки ---------- */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.dot.ok { background: var(--green); box-shadow: 0 0 0 0 rgba(52, 209, 123, 0.5); animation: pulse 2s infinite; }
.dot.warn { background: var(--amber); }
.dot.bad { background: var(--red); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 209, 123, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(52, 209, 123, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 209, 123, 0); }
}

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 700;
}
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: rgba(240, 180, 41, 0.14); color: var(--amber); }
.badge.bad { background: rgba(239, 83, 80, 0.14); color: var(--red); }

/* ---------- формы и кнопки ---------- */
label.field { display: block; margin-bottom: 12px; font-size: 0.85rem; font-weight: 700; color: var(--muted); }
input, select, textarea {
  width: 100%; margin-top: 5px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 14px; font: inherit; font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(52, 209, 123, 0.18);
}
input[type="checkbox"] { width: auto; }

/* ---------- диалоги ---------- */
.chat-layout { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 18px; }
.chat-users, .chat-panel { padding: 18px; }
.chat-user-list { max-height: 650px; overflow-y: auto; }
.chat-user { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px; border-radius: 12px; color: var(--text); text-decoration: none; }
.chat-user:hover, .chat-user.active { background: var(--green-soft); }
.chat-user span { min-width: 0; }
.chat-user b, .chat-user small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-user small { color: var(--muted); margin-top: 3px; }
.chat-user i { min-width: 24px; height: 24px; padding: 0 7px; display: grid; place-items: center; border-radius: 99px; background: var(--green); color: #06130b; font-style: normal; font-size: .75rem; font-weight: 800; }
.chat-panel { display: flex; flex-direction: column; min-height: 620px; }
.chat-head { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.chat-history { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 18px 4px; max-height: 520px; overflow-y: auto; }
.chat-message { max-width: 76%; padding: 10px 13px; border-radius: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message.incoming { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.chat-message.outgoing { align-self: flex-end; background: var(--green-soft); border: 1px solid var(--green-dim); border-bottom-right-radius: 4px; }
.chat-message small { display: block; margin-top: 5px; color: var(--muted); font-size: .7rem; text-align: right; }
.chat-empty { margin: auto; color: var(--muted); text-align: center; }
.chat-compose { display: flex; align-items: end; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.chat-compose textarea { margin: 0; resize: vertical; }
@media (max-width: 760px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-user-list { max-height: 240px; }
  .chat-panel { min-height: 520px; }
  .chat-message { max-width: 88%; }
  .chat-compose { flex-direction: column; align-items: stretch; }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 700; font-size: 0.92rem; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--green-dim); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(135deg, var(--green), #24b467);
  border: none; color: #06130b;
  box-shadow: 0 6px 20px rgba(52, 209, 123, 0.28);
}
.btn.primary:hover { box-shadow: 0 8px 26px rgba(52, 209, 123, 0.4); }
.btn.danger { color: var(--red); border-color: rgba(239, 83, 80, 0.35); }
.btn.danger:hover { background: rgba(239, 83, 80, 0.1); border-color: var(--red); }
.btn.sm { padding: 7px 13px; font-size: 0.82rem; border-radius: 10px; }
.btn.block { width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- таблицы / списки ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
tr.rowlink { cursor: pointer; transition: background 0.15s; }
tr.rowlink:hover { background: var(--green-soft); }

.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; padding: 32px 28px; }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .brand-badge { margin: 0 auto 14px; width: 56px; height: 56px; border-radius: 18px; font-size: 28px; }
.tabs { display: flex; gap: 6px; background: var(--bg); padding: 5px; border-radius: 12px; margin-bottom: 20px; }
.tabs button {
  flex: 1; padding: 9px; border: none; border-radius: 9px; cursor: pointer;
  background: transparent; color: var(--muted); font: inherit; font-weight: 700; font-size: 0.88rem;
  transition: background 0.15s, color 0.15s;
}
.tabs button.active { background: var(--surface-2); color: var(--text); }

/* ---------- toast ---------- */
.toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 100; max-width: min(480px, calc(100vw - 32px));
  padding: 13px 20px; border-radius: 14px; font-weight: 600; font-size: 0.92rem;
  border: 1px solid var(--line); background: var(--surface-2);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.35s ease both;
}
.toast.success { border-color: var(--green-dim); color: var(--green); }
.toast.error { border-color: rgba(239, 83, 80, 0.5); color: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -14px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- modal (QR) ---------- */
.modal-bg {
  position: fixed; inset: 0; z-index: 90; display: none;
  background: rgba(4, 8, 6, 0.75); backdrop-filter: blur(6px);
  place-items: center; padding: 20px;
}
.modal-bg.open { display: grid; }
.modal { max-width: 360px; width: 100%; text-align: center; animation: rise 0.3s ease; }
.qr-box { background: #fff; border-radius: 14px; padding: 14px; display: inline-block; margin: 14px 0; }

/* ---------- прогресс подписки ---------- */
.progress { height: 8px; border-radius: 99px; background: var(--bg); overflow: hidden; margin-top: 10px; }
.progress i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--green-dim), var(--green));
  transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* скриншоты платежей */
.shot { width: 92px; height: 92px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); cursor: zoom-in; transition: transform 0.15s; }
.shot:hover { transform: scale(1.04); }

details.folder { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
details.folder summary { padding: 16px 20px; cursor: pointer; font-weight: 700; list-style: none; }
details.folder summary::before { content: "＋ "; color: var(--green); }
details.folder[open] summary::before { content: "－ "; }
details.folder .inner { padding: 4px 20px 20px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
