:root {
    --bg: #090c16;
    --surface: #0d1220;
    --border: #232a3a;
    --border-soft: rgba(255,255,255,0.08);
    --text: #f2f4fa;
    --muted: #9aa2bd;
    --muted-dim: #6b7288;
    --accent: #a78bfa;
    --accent-ink: #0a0e1a;
    --teal: #5eead4;
    --danger: #ef4444;
    --danger-text: #ff6b6b;
    --ok: #4ade80;
    --font-head: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 700; letter-spacing: -0.01em; }

/* --- Top nav --- */
.nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 18px 40px;
    border-bottom: 1px solid var(--border-soft);
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg);
}

.logo {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
    text-decoration: none;
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.logo-mark { position: relative; width: 30px; height: 20px; display: inline-block; overflow: hidden; flex-shrink: 0; }
.logo-mark-sm { width: 22px; height: 15px; }
.logo-ring { position: absolute; left: 50%; border-radius: 50%; border: 2px solid var(--accent); transform: translateX(-50%); }
.logo-ring-1 { top: 45%; width: 24px; height: 24px; opacity: 0.28; }
.logo-ring-2 { top: 60%; width: 16px; height: 16px; opacity: 0.6; }
.logo-mark-sm .logo-ring-1 { width: 17px; height: 17px; }
.logo-mark-sm .logo-ring-2 { width: 12px; height: 12px; }
.logo-dot { position: absolute; top: 90%; left: 50%; width: 5px; height: 5px; border-radius: 50%; background: var(--text); transform: translateX(-50%); }
.logo-mark-sm .logo-dot { width: 3px; height: 3px; }
.logo-2 { color: var(--accent); }

.footer-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 8px; font-family: var(--font-head); font-weight: 700; font-size: 0.95rem; color: var(--text); }
.footer-tagline { font-family: var(--font-body); font-weight: 400; color: var(--muted-dim); font-size: 0.85rem; margin-left: 4px; }

.starfield {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.8;
    background-image:
        radial-gradient(1.5px 1.5px at 10% 8%, #fff 100%, transparent),
        radial-gradient(1px 1px at 22% 34%, #fff 100%, transparent),
        radial-gradient(1.5px 1.5px at 35% 12%, #fff 100%, transparent),
        radial-gradient(1px 1px at 48% 46%, #fff 100%, transparent),
        radial-gradient(1.5px 1.5px at 62% 18%, #fff 100%, transparent),
        radial-gradient(1px 1px at 75% 38%, #fff 100%, transparent),
        radial-gradient(1.5px 1.5px at 88% 10%, #fff 100%, transparent),
        radial-gradient(1px 1px at 95% 52%, #fff 100%, transparent),
        radial-gradient(1.5px 1.5px at 15% 60%, #fff 100%, transparent),
        radial-gradient(1px 1px at 40% 70%, #fff 100%, transparent),
        radial-gradient(1.5px 1.5px at 68% 62%, #fff 100%, transparent),
        radial-gradient(1px 1px at 5% 85%, #fff 100%, transparent),
        radial-gradient(1.5px 1.5px at 30% 90%, #fff 100%, transparent),
        radial-gradient(1px 1px at 55% 82%, #fff 100%, transparent),
        radial-gradient(1.5px 1.5px at 80% 88%, #fff 100%, transparent),
        radial-gradient(1px 1px at 92% 78%, #fff 100%, transparent);
}

.nav-center {
    display: flex;
    gap: 28px;
    justify-self: center;
}

.nav-right {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-self: end;
}

nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.95rem;
}

nav a:hover { color: var(--text); }

@media (max-width: 700px) {
    .nav { grid-template-columns: 1fr; justify-items: center; gap: 10px; }
    .nav-center, .nav-right { flex-wrap: wrap; justify-content: center; }
}

.btn-nav {
    background: var(--accent);
    color: var(--accent-ink) !important;
    padding: 9px 18px;
    border-radius: 9px;
    font-weight: 700;
}

main {
    max-width: 900px;
    margin: 0 auto;
    padding: 60px 20px;
}

/* --- Hero / plans (index) --- */
.hero h1 { font-size: 2.6rem; margin-bottom: 12px; line-height: 1.1; }
.hero p { color: var(--muted); font-size: 1.1rem; max-width: 520px; }

.cta {
    display: inline-block;
    margin-top: 24px;
    background: var(--accent);
    color: var(--accent-ink);
    padding: 14px 30px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
}

.plans {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-top: 50px;
}

.plan-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    padding: 26px;
}

.plan-card h3 { margin-top: 0; font-size: 1.2rem; }
.plan-card p { color: var(--teal); margin-bottom: 0; font-size: 0.9rem; }

/* --- Forms (shared) --- */
form { max-width: 380px; }

label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.9rem; }

input, textarea, select {
    width: 100%;
    padding: 11px 14px;
    margin-bottom: 16px;
    background: #05070d;
    border: 1px solid var(--border-soft);
    border-radius: 9px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
}

input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }

button {
    width: 100%;
    padding: 13px;
    background: var(--accent);
    border: none;
    border-radius: 9px;
    color: var(--accent-ink);
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
}

button:hover { filter: brightness(1.08); }

.error { color: var(--danger-text); margin-bottom: 16px; }

.conn-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 16px;
}

.conn-card code {
    display: block;
    word-break: break-all;
    background: #05070d;
    padding: 10px;
    border-radius: 8px;
    margin: 10px 0;
    font-size: 0.85rem;
    font-family: var(--font-mono);
}

footer {
    text-align: center;
    color: var(--muted-dim);
    padding: 30px;
    font-size: 0.85rem;
    border-top: 1px solid var(--border-soft);
}

/* --- Формы регистрации/входа --- */
.auth-wrap {
    display: flex;
    justify-content: center;
    padding-top: 40px;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    padding: 36px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.12), 0 0 48px rgba(167, 139, 250, 0.14);
}

.auth-card h2 {
    margin-top: 0;
    text-align: center;
    font-size: 1.4rem;
}

.field-icon-wrap {
    position: relative;
}

.field-icon-wrap input {
    padding-right: 70px;
}

.toggle-eye {
    position: absolute;
    right: 14px;
    top: 14px;
    cursor: pointer;
    color: var(--accent);
    user-select: none;
    font-size: 0.8rem;
    font-weight: 600;
}
.toggle-eye:hover { filter: brightness(1.15); }

.password-rules {
    list-style: none;
    padding: 0;
    margin: -10px 0 16px 0;
    font-size: 0.8rem;
    color: var(--muted-dim);
}
.password-rules li { margin-bottom: 2px; }
.password-rules li.ok { color: var(--ok); }
.password-rules li.bad { color: var(--danger-text); }

.field-hint {
    font-size: 0.8rem;
    margin: -10px 0 16px 0;
}
.field-hint.ok { color: var(--ok); }
.field-hint.bad { color: var(--danger-text); }

.auth-switch {
    text-align: center;
    margin-top: 16px;
    color: var(--muted);
    font-size: 0.9rem;
}
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }

/* --- Личный кабинет / админка: layout с сайдбаром --- */
.db-layout {
    display: grid;
    grid-template-columns: 230px 1fr;
    gap: 24px;
    align-items: start;
}

.db-sidebar {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    padding: 22px 14px;
    text-align: center;
    position: sticky;
    top: 90px;
}

.db-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-ink);
    margin: 0 auto 12px auto;
    box-shadow: 0 0 0 3px var(--bg), 0 0 0 4px var(--border-soft);
}

.db-nickname { font-weight: 700; margin-bottom: 20px; word-break: break-word; }

.db-nav { display: flex; flex-direction: column; gap: 4px; text-align: left; }

.db-nav a {
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
}

.db-nav a::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.55;
    margin-right: 10px;
    flex-shrink: 0;
}

.db-nav a:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.db-nav a.active { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.db-nav a.active::before { background: var(--accent-ink); opacity: 0.5; }

.db-mobile-toggle { display: none; }

.db-content { min-width: 0; }

.db-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 20px;
}

.db-muted { color: var(--muted); font-size: 0.9rem; }
.hint-ok { color: var(--ok); margin-bottom: 12px; }

.cta-big {
    display: block;
    text-align: center;
    font-size: 1.05rem;
    padding: 18px;
}

/* --- Трафик-бар --- */
.traffic-bar {
    background: #05070d;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    height: 12px;
    overflow: hidden;
    margin: 10px 0 8px 0;
}
.traffic-bar-fill { height: 100%; background: var(--teal); }
.traffic-label { color: var(--muted); font-size: 0.85rem; }

/* --- Аватар: выбор цвета --- */
.avatar-picker { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.avatar-option input { display: none; width: auto; margin: 0; }
.avatar-swatch {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s ease;
}
.avatar-swatch:hover { transform: scale(1.08); }
.avatar-option input:checked + .avatar-swatch { border-color: #fff; }

/* --- Тариф --- */
.plan-option {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    padding: 12px 14px;
    background: #05070d;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
}
.plan-option input { width: auto; margin: 0; accent-color: var(--accent); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; filter: none; }

/* --- Ключи подключения: замыленные до клика --- */
.key-row { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.key-qr-wrap { position: relative; cursor: pointer; flex-shrink: 0; border-radius: 12px; overflow: hidden; }
.key-qr-wrap img { display: block; border-radius: 12px; }
.key-text-wrap { flex: 1; min-width: 250px; }
.key-text { position: relative; cursor: pointer; }
.key-text code {
    display: block;
    word-break: break-all;
    background: #05070d;
    padding: 12px;
    border-radius: 9px;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    color: var(--muted);
    margin-bottom: 10px;
}

.blurred { filter: blur(8px); user-select: none; }
.blurred .reveal-hint { display: flex; }
.reveal-hint {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    color: var(--text);
    font-size: 0.8rem;
    text-align: center;
    background: rgba(5,7,13,0.35);
    filter: none;
    border-radius: 9px;
}
.key-qr-wrap:not(.blurred) .reveal-hint,
.key-text:not(.blurred) .reveal-hint { display: none; }

.copy-btn { background: var(--teal); width: auto; padding: 11px 22px; }
.copy-btn:hover { filter: brightness(1.08); }

.app-instructions { margin-bottom: 16px; }
.app-instructions h4 { margin-bottom: 4px; font-size: 0.95rem; }

@media (max-width: 800px) {
    .db-layout { grid-template-columns: 1fr; }
    .db-sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 260px;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 50;
        border-radius: 0;
        overflow-y: auto;
    }
    .db-sidebar.open { transform: translateX(0); }
    .db-mobile-toggle {
        display: block;
        width: auto;
        margin-bottom: 16px;
        background: var(--surface);
        border: 1px solid var(--border-soft);
        color: var(--text);
    }
}

/* --- FAQ / accordions (details/summary) --- */
details { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 14px; padding: 20px 24px; margin-bottom: 14px; }
summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; justify-content: space-between; }
summary::-webkit-details-marker { display: none; }
summary::after { content: '+'; color: var(--accent); font-size: 1.2rem; font-weight: 400; margin-left: 12px; }
details[open] summary::after { content: '\2212'; }
.faq-item summary:hover { color: var(--accent); }

.post-image { max-width: 100%; border-radius: 12px; margin: 14px 0; display: block; }
.admin-thumb { max-width: 200px; border-radius: 10px; margin-bottom: 10px; display: block; }

/* --- Админка: пользователи --- */
.users-table-head, .users-row {
    display: grid;
    grid-template-columns: 50px 1.2fr 1fr 0.8fr 1fr 1fr;
    gap: 10px;
    align-items: center;
}
.users-table-head {
    padding: 0 24px;
    color: var(--muted-dim);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}
.users-row { cursor: pointer; list-style: none; font-size: 0.9rem; }
.users-row::-webkit-details-marker { display: none; }
.users-row::after { content: '\203A'; color: var(--muted-dim); font-size: 1rem; }
.users-row-card { padding: 16px 24px; }

.user-card { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border-soft); }
.user-card-header { display: flex; gap: 16px; align-items: center; margin-bottom: 20px; }
.user-card h4 { margin-bottom: 8px; margin-top: 20px; font-size: 0.95rem; }

@media (max-width: 900px) {
    .users-table-head { display: none; }
    .users-row { grid-template-columns: 1fr; text-align: left; }
    .users-row span::before { content: attr(data-label) ": "; color: var(--muted-dim); }
}

/* --- Landing hero --- */
.hero-badge { display: inline-block; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border-soft); font-size: 0.8rem; color: var(--muted); margin-bottom: 20px; }
.hero-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 48px; align-items: center; margin-bottom: 60px; }
.hero-grid .hero h1 { font-size: 2.9rem; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.cta-secondary { display: inline-block; margin-top: 24px; border: 1px solid var(--border-soft); color: var(--text); padding: 14px 30px; border-radius: 10px; text-decoration: none; font-weight: 600; }
.cta-secondary:hover { border-color: rgba(255,255,255,0.35); }

.hero-visual { position: relative; aspect-ratio: 1/1; border-radius: 24px; background: var(--surface); border: 1px solid var(--border-soft); overflow: hidden; }
.hero-visual .moon-glow { position: absolute; width: 58%; aspect-ratio: 1/1; border-radius: 50%; top: 18%; right: 10%; background: radial-gradient(circle at 35% 30%, var(--accent), transparent 70%); filter: blur(2px); opacity: 0.55; }
.hero-visual .moon-body { position: absolute; width: 46%; aspect-ratio: 1/1; border-radius: 50%; top: 26%; right: 18%; background: var(--bg); box-shadow: -18px -6px 0 -4px var(--accent) inset; }
.hero-visual .vignette { position: absolute; left: 0; right: 0; bottom: 0; height: 38%; background: linear-gradient(180deg, transparent, #05070d 88%); }
.hero-visual .mascot { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 38%; height: 48%; }
.hero-visual .mascot-body { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; height: 68%; border-radius: 46% 46% 16% 16%; background: #05070d; }
.hero-visual .mascot-head { position: absolute; bottom: 58%; left: 50%; transform: translateX(-50%); width: 40%; aspect-ratio: 1/1; border-radius: 50%; background: #05070d; }
.hero-visual .mascot-laptop { position: absolute; bottom: 20%; left: 50%; transform: translateX(-50%); width: 36%; height: 7%; border-radius: 2px; background: linear-gradient(180deg, var(--accent), transparent); opacity: 0.9; }

/* --- Feature cards / platform pills --- */
.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 60px; }
.feature-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 16px; padding: 26px 22px; }
.feature-icon { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--accent); position: relative; margin-bottom: 18px; }
.feature-card h3 { font-size: 1.02rem; margin: 0 0 8px; }
.feature-card p { color: var(--muted); font-size: 0.9rem; line-height: 1.55; margin: 0; }

.platform-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 60px; }
.platform-pill { border: 1px solid var(--border-soft); border-radius: 999px; padding: 11px 22px; font-size: 0.95rem; font-weight: 600; color: #d7dbe9; background: var(--surface); }

/* --- Icon rail (dashboard / admin sidebars) --- */
.rail-layout { display: flex; align-items: flex-start; margin: -60px -20px 0; }
.rail-nav { position: sticky; top: 60px; width: 84px; flex-shrink: 0; height: calc(100vh - 60px); background: #0a0e1a; border-right: 1px solid var(--border-soft); display: flex; flex-direction: column; align-items: center; padding-top: 18px; gap: 8px; }
.rail-item { width: 56px; height: 56px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; text-decoration: none; color: var(--muted); }
.rail-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.rail-item.active { background: var(--accent); color: var(--accent-ink); }
.rail-item .rail-icon { width: 16px; height: 16px; border: 1.5px solid currentColor; }
.rail-label { font-size: 9px; letter-spacing: 0.03em; }
.rail-content { flex: 1; min-width: 0; padding: 40px; max-width: 820px; }

/* --- Stat cards --- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 10px; padding: 18px; }
.stat-card .stat-label { font-size: 0.75rem; color: var(--muted-dim); margin-bottom: 8px; }
.stat-card .stat-value { font-family: var(--font-head); font-size: 1.4rem; font-weight: 700; }

/* --- Plan tiles (dashboard/plan) --- */
.plan-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.plan-tile { background: var(--surface); border: 1.5px solid var(--border-soft); border-radius: 12px; padding: 18px; cursor: pointer; }
.plan-tile.active-plan { border-color: var(--accent); }
.plan-tile .plan-tile-name { font-weight: 700; font-size: 1rem; margin-bottom: 6px; }
.plan-tile .plan-tile-protocol { font-size: 0.8rem; color: var(--accent); }

/* --- Two-pane list + editor (admin content sections) --- */
.editor-layout { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }
.editor-list { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 12px; overflow: hidden; }
.editor-list a { display: block; padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,0.06); border-left: 3px solid transparent; color: var(--text); text-decoration: none; }
.editor-list a:last-child { border-bottom: none; }
.editor-list a:hover { background: rgba(255,255,255,0.03); }
.editor-list .item-title { font-size: 0.87rem; font-weight: 600; }
.editor-list .item-meta { font-size: 0.75rem; color: var(--muted-dim); margin-top: 3px; font-family: var(--font-mono); }
.editor-pane { display: none; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 12px; padding: 24px; }
.editor-pane:target, .editor-pane.editor-pane-default { display: block; }
.editor-list-wrap:has(.editor-pane:target) .editor-pane.editor-pane-default:not(:target) { display: none; }
.editor-list a.active-item { background: rgba(255,255,255,0.05); border-left-color: var(--accent); }

@media (max-width: 900px) {
    .rail-layout { flex-direction: column; }
    .rail-nav { position: static; width: 100%; height: auto; flex-direction: row; overflow-x: auto; padding: 10px; }
    .rail-nav.open { display: flex; }
    .hero-grid { grid-template-columns: 1fr; }
    .feature-grid { grid-template-columns: repeat(2, 1fr); }
    .editor-layout { grid-template-columns: 1fr; }
}
