:root {
    --bg: #f4efe8;
    --surface: #fffdf9;
    --surface-2: #eee5da;
    --border: #ded2c4;
    --text: #2d2925;
    --muted: #7d746b;
    --accent: #8a6748;
    --accent-hover: #735338;
    --accent-soft: #e9ddd0;
    --danger: #b84d43;
    --danger-soft: #f8e8e5;
    --success: #487357;
    --success-soft: #e8f1ea;
    --shadow: 0 12px 34px rgba(80, 58, 39, .08);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background:
        radial-gradient(circle at 15% 0%, rgba(169,132,97,.10), transparent 28%),
        var(--bg);
    color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 68px;
    padding: 0 32px;
    background: rgba(244,239,232,.92);
    border-bottom: 1px solid rgba(138,103,72,.16);
    backdrop-filter: blur(14px);
}
.brand { display:flex; align-items:center; gap:10px; min-width:0; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 11px;
    display:grid; place-items:center;
    background: var(--accent); color:#fff;
    font-size:16px; font-weight:800;
    box-shadow: 0 7px 16px rgba(113,80,53,.18);
}
.topbar .logo { color: var(--text) !important; font-weight: 800; font-size: 17px; letter-spacing:-.02em; }
.topbar nav { display:flex; align-items:center; gap:8px; }
.topbar nav a { color: var(--muted) !important; padding:8px 10px; border-radius:10px; font-size:14px; }
.topbar nav a:hover { color: var(--text) !important; background:rgba(138,103,72,.08); }
.user-email { color: var(--muted); margin-right: 4px; font-size:13px; max-width:240px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.container { max-width: 1040px; margin: 0 auto; padding: 42px 22px 56px; }
.page-head { display:flex; justify-content:space-between; gap:24px; align-items:flex-end; margin-bottom:24px; }
.eyebrow { color:var(--accent); text-transform:uppercase; letter-spacing:.12em; font-size:11px; font-weight:800; margin-bottom:8px; }
h1 { font-size: 30px; line-height:1.15; letter-spacing:-.035em; margin: 0 0 8px; }
h2 { font-size: 19px; margin:0 0 10px; letter-spacing:-.02em; }
p { line-height:1.55; }
.card {
    background: rgba(255,253,249,.94);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 26px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}
.card-flat { box-shadow:none; }
.dashboard-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; margin-bottom:18px; }
.stat-card { background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:18px; min-width:0; }
.stat-label { font-size:12px; color:var(--muted); margin-bottom:7px; }
.stat-value { font-size:20px; font-weight:800; letter-spacing:-.025em; overflow:hidden; text-overflow:ellipsis; }
.stat-note { font-size:12px; color:var(--muted); margin-top:5px; }
.status-dot { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:7px; background:var(--success); box-shadow:0 0 0 4px var(--success-soft); }
.section-grid { display:grid; grid-template-columns:minmax(0,1.35fr) minmax(280px,.65fr); gap:18px; align-items:start; }
.steps { display:grid; gap:12px; margin-top:18px; }
.step { display:grid; grid-template-columns:34px 1fr; gap:12px; align-items:start; }
.step-num { width:34px;height:34px;border-radius:10px;background:var(--accent-soft);color:var(--accent);display:grid;place-items:center;font-weight:800;font-size:13px; }
.step strong { display:block; margin:2px 0 4px; }
.step p { margin:0; color:var(--muted); font-size:13px; }
label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 13px; font-weight:600; }
input[type=email], input[type=password], input[type=text], input[type=number] {
    width: 100%; padding: 12px 13px; background: #fff;
    border: 1px solid var(--border); border-radius: 11px; color: var(--text);
    margin-bottom: 16px; font-size: 15px; outline:none;
    transition: border-color .16s, box-shadow .16s;
}
input:focus { border-color:#b49272; box-shadow:0 0 0 4px rgba(138,103,72,.10); }
.btn {
    display: inline-flex; align-items:center; justify-content:center; gap:8px;
    background: var(--accent); color: white !important; border: 1px solid var(--accent);
    padding: 11px 18px; border-radius: 11px; cursor: pointer; text-decoration: none;
    font-size: 14px; font-weight:700; transition: transform .15s, background .15s, border-color .15s;
}
.btn:hover { background: var(--accent-hover); border-color:var(--accent-hover); text-decoration:none; transform:translateY(-1px); }
.btn-large { padding: 13px 22px; font-size: 15px; }
.btn-danger { background: transparent; border-color:#d9aaa5; color:var(--danger) !important; }
.btn-danger:hover { background:var(--danger-soft); border-color:#ca8d86; }
.btn-secondary { background: var(--surface-2); border-color:var(--border); color:var(--text) !important; }
.btn-secondary:hover { background:#e4d7c8; border-color:#d0bfad; }
.happ-connect {
    display:grid;
    gap:9px;
    margin-top:16px;
}
.btn-happ {
    width:100%;
    min-height:48px;
}
.actions-row { display:flex; flex-wrap:wrap; gap:10px; margin-top:18px; }
.actions-row form { margin:0; }
.alert { padding: 13px 15px; border-radius: 12px; margin-bottom: 16px; font-size: 14px; border:1px solid; }
.alert-error { background: var(--danger-soft); color:#8e3d36; border-color:#e8c5c1; }
.alert-success { background: var(--success-soft); color:#365c43; border-color:#cbdccc; }
.mono {
    font-family: "SFMono-Regular", Consolas, monospace;
    background: #f7f1ea; border: 1px dashed #cfbca8; padding: 14px;
    border-radius: 12px; word-break: break-all; font-size: 12px; color:#654a34;
    line-height:1.55;
}
.key-box { position:relative; }
.key-box .mono { padding-right:120px; min-height:70px; }
.key-copy { position:absolute; right:10px; top:10px; }
table { width:100%; border-collapse:collapse; min-width:680px; }
th,td { text-align:left; padding:12px 13px; border-bottom:1px solid #eadfd4; font-size:13px; white-space:nowrap; }
th { color:var(--muted); font-weight:700; background:#faf6f1; }
tr:last-child td { border-bottom:0; }
.table-scroll { overflow-x:auto; -webkit-overflow-scrolling:touch; border:1px solid var(--border); border-radius:13px; }
.badge { display:inline-flex; align-items:center; padding:4px 8px; border-radius:999px; font-size:11px; font-weight:700; }
.badge-ok { background:var(--success-soft); color:#356043; }
.badge-banned { background:var(--danger-soft); color:#963e36; }
.badge-warning { background:#fff0c9; color:#7a5518; }
.row-actions a,.row-actions button { font-size:13px; margin-right:8px; }
.muted { color: var(--muted); font-size: 14px; }
.auth-wrap { max-width:920px; margin:10px auto 0; display:grid; grid-template-columns:1fr 420px; gap:28px; align-items:center; }
.auth-intro { padding:34px 18px; }
.auth-intro h1 { font-size:40px; }
.auth-card { margin:0; }
.auth-points { display:grid; gap:11px; margin-top:22px; }
.auth-point { display:flex; align-items:center; gap:10px; color:var(--muted); font-size:14px; }
.auth-point:before { content:'✓'; width:23px;height:23px;border-radius:8px;background:var(--accent-soft);color:var(--accent);display:grid;place-items:center;font-weight:900;font-size:12px; }
.footer { max-width:1040px; margin:0 auto; padding:0 22px 34px; color:var(--muted); font-size:12px; display:flex; justify-content:space-between; gap:20px; }
@media (max-width: 780px) {
    .topbar { padding:0 16px; min-height:62px; }
    .user-email { display:none; }
    .topbar nav { gap:2px; }
    .topbar nav a { padding:8px; }
    .container { padding:28px 15px 42px; }
    h1 { font-size:27px; }
    .dashboard-grid { grid-template-columns:1fr; }
    .section-grid { grid-template-columns:1fr; }
    .auth-wrap { display:block; max-width:460px; }
    .auth-intro { padding:12px 6px 24px; }
    .auth-intro h1 { font-size:32px; }
    .card { padding:20px; border-radius:15px; }
    .key-box .mono { padding-right:14px; padding-bottom:62px; }
    .key-copy { top:auto; bottom:10px; left:10px; right:10px; }
    .key-copy .btn { width:100%; }
    .actions-row { display:grid; grid-template-columns:1fr; }
    .actions-row form,.actions-row .btn { width:100%; }
    .footer { padding:0 15px 26px; display:block; }
}

/* Billing / anonymous accounts */
.dashboard-grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.alert-warning { background:#fff5dd; color:#72531e; border-color:#ead19c; }
.field-note { color:var(--muted); font-size:12px; margin:-10px 0 16px; }
select {
    width:100%; max-width:420px; padding:12px 13px; background:#fff;
    border:1px solid var(--border); border-radius:11px; color:var(--text);
    margin-bottom:16px; font-size:15px; outline:none;
}
.payment-details { display:grid; gap:14px; padding:18px; border:1px solid var(--border); border-radius:14px; background:#faf6f1; }
.payment-value { font-family:"SFMono-Regular",Consolas,monospace; font-size:22px; font-weight:800; letter-spacing:.04em; word-break:break-all; }
.payment-row { display:flex; justify-content:space-between; gap:18px; padding:10px 0; border-bottom:1px solid var(--border); }
.payment-row:last-of-type { border-bottom:0; }
.notice-box { margin-top:16px; padding:14px 16px; border-radius:12px; background:var(--accent-soft); color:var(--text); font-size:14px; }
.amount-plus { color:var(--success); font-weight:800; }
.amount-minus { color:var(--danger); font-weight:800; }
.small-stat { font-size:16px; }
.page-head-actions { margin-top:0; }
.dashboard-grid-3 { grid-template-columns:repeat(3,minmax(0,1fr)); }
.partner-intro p { margin-bottom:0; }
.referral-head { align-items:center; margin-bottom:16px; }
.referral-note { margin:14px 0 0; }
.compact-actions { margin-top:0; flex-wrap:nowrap; }
.mono-cell { font-family:"SFMono-Regular",Consolas,monospace; font-size:12px; }
.btn:disabled { opacity:.5; cursor:not-allowed; transform:none; }
.partner-label-short { display:none; }
.referral-users-card { color:var(--text); transition:transform .15s, border-color .15s, background .15s; }
.referral-users-card:hover { color:var(--text); border-color:#c8b39e; background:var(--accent-soft); transform:translateY(-1px); }
.pagination { display:flex; align-items:center; justify-content:center; gap:12px; margin-top:20px; }
.pagination-current { color:var(--muted); font-size:13px; }
@media (max-width: 900px) { .dashboard-grid-4 { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media (max-width: 560px) { .dashboard-grid-4,.dashboard-grid-3 { grid-template-columns:1fr; } .payment-row { display:block; } .payment-row strong { display:block; margin-top:4px; } }


.subscription-topup-btn {
    margin-top: 24px;
}

/* Отступ под кнопкой "Я оплатил" */
.payment-confirm-btn {
    margin-bottom: 24px;
}

.payment-confirm-btn {
    margin-bottom: 48px !important;
}

.payment-note {
    display: block;
    margin-top: 18px !important;
    line-height: 1.5;
}
body.modal-open {
    overflow: hidden;
}

.site-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.site-modal.is-open {
    display: flex;
}

.site-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(45, 34, 27, 0.48);
    backdrop-filter: blur(3px);
}

.site-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(440px, 100%);
    background: #fffaf6;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px;
    box-shadow: 0 25px 70px rgba(45, 34, 27, 0.22);
    text-align: center;
}

.site-modal-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #efe2d8;
    color: #6f4f3d;
    font-size: 26px;
    font-weight: 700;
}

.site-modal-dialog h3 {
    margin: 0 0 12px;
    font-size: 22px;
}

.site-modal-dialog p {
    margin: 0;
    line-height: 1.55;
    color: var(--muted);
}

.site-modal-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 24px;
}

.site-modal-actions .btn {
    min-width: 130px;
}

@media (max-width: 560px) {
    .site-modal {
        padding: 14px;
    }

    .site-modal-dialog {
        padding: 22px 18px;
        border-radius: 16px;
    }

    .site-modal-actions {
        flex-direction: column;
    }

    .site-modal-actions .btn {
        width: 100%;
    }
}

/* Public pages / payment-provider review */
.landing-hero { max-width:820px; padding:34px 0 42px; }
.landing-hero h1 { font-size:46px; max-width:760px; }
.landing-lead { max-width:680px; color:var(--muted); font-size:17px; line-height:1.65; }
.public-section { margin-top:8px; }
.public-tariffs { margin:20px 0 0; }
.public-grid { display:grid; grid-template-columns:1fr 1fr; gap:18px; }
.public-links { display:grid; gap:10px; margin-top:20px; }
.public-links a { display:block; padding:12px 14px; border:1px solid var(--border); border-radius:11px; background:#faf6f1; }
.legal-page { max-width:820px; margin:0 auto; }
.legal-page h1 { margin-bottom:6px; }
.legal-page h2 { margin-top:28px; }
.legal-page p { color:#514a44; }
.support-card { max-width:720px; margin:0 auto; }
.support-contact { margin:24px 0; padding:18px; border:1px solid var(--border); border-radius:14px; background:#faf6f1; }
.support-contact span { display:block; color:var(--muted); font-size:12px; margin-bottom:7px; }
.support-contact a { font-size:18px; font-weight:800; word-break:break-all; }
.footer-full { align-items:flex-start; }
.footer-full > div:first-child { display:grid; gap:5px; }
.footer-links { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:12px; }
.footer-links a { color:var(--muted); }
.review-code { opacity:.35; font-size:9px; align-self:flex-end; }
@media (max-width:780px) {
    .landing-hero { padding:16px 0 30px; }
    .landing-hero h1 { font-size:34px; }
    .public-grid { grid-template-columns:1fr; gap:0; }
    .footer-full { display:grid; gap:14px; }
    .footer-links { display:grid; justify-content:start; gap:8px; }
    .review-code { align-self:auto; }
}

/* Compact dashboard on mobile */
@media (max-width: 700px) {
    .dashboard-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }

    .stat-card {
        padding: 11px !important;
        min-height: 0 !important;
    }

    .stat-label {
        font-size: 11px !important;
        margin-bottom: 4px !important;
    }

    .stat-value {
        font-size: 18px !important;
        line-height: 1.15 !important;
    }

    .stat-note {
        font-size: 11px !important;
        line-height: 1.25 !important;
        margin-top: 4px !important;
    }

    .section-grid {
        gap: 10px !important;
        margin-top: 10px !important;
    }

    .section-grid > div > .card:first-child {
        padding: 14px !important;
    }

    .section-grid > div > .card:first-child h2 {
        font-size: 20px !important;
        margin-bottom: 6px !important;
    }

    .section-grid > div > .card:first-child > .muted {
        font-size: 12px !important;
        line-height: 1.35 !important;
        margin-bottom: 10px !important;
    }

    .section-grid > div > .card:first-child .dashboard-grid-4 {
        margin-top: 10px !important;
    }

    .section-grid > div > .card:first-child .stat-card {
        padding: 10px !important;
    }

    .section-grid > div > .card:first-child form {
        margin-top: 7px !important;
    }

    .section-grid > div > .card:first-child .btn-large {
        padding: 9px 8px !important;
        min-height: 0 !important;
        font-size: 13px !important;
    }

    .subscription-topup-btn {
        margin-top: 10px !important;
        padding: 9px 12px !important;
    }
}

.extra-actions {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.extra-actions .muted {
    margin: 4px 0 12px;
    font-size: 13px;
}

.vless-details > summary {
    cursor: pointer;
    list-style: none;
    display: inline-flex;
}

.vless-details > summary::-webkit-details-marker {
    display: none;
}

@media (max-width:700px) {
    .extra-actions {
        margin-top: 16px;
        padding-top: 14px;
    }

    .vless-details > summary {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width:700px) {
    .page-head { align-items:flex-start; }
    .page-head-actions { width:100%; display:block; }
    .page-head-actions .btn { width:100%; }
    .referral-head { display:block; }
    .referral-head .btn { width:100%; margin-top:12px; }
    .dashboard-page-head { display:flex; align-items:flex-start; gap:8px; }
    .dashboard-page-head > div:first-child { min-width:0; flex:1; }
    .dashboard-page-head h1 { font-size:25px; white-space:nowrap; }
    .dashboard-page-head .page-head-actions { width:auto; flex:0 0 auto; margin:0; }
    .partner-entry-btn { padding:7px 9px; font-size:11px; border-radius:9px; }
    .partner-label-full { display:none; }
    .partner-label-short { display:inline; }
    .partner-stats { grid-template-columns:repeat(2,minmax(0,1fr)) !important; }
    .partner-stats .referral-users-card { grid-column:1 / -1; }
    .pagination { justify-content:space-between; }
    .pagination .btn { width:auto; }
}

@media (max-width:700px) {
    .extra-actions .actions-row,
    .extra-actions .actions-row form {
        width: 100%;
    }

    .extra-actions .actions-row .btn,
    .vless-details > summary {
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
    }
}
