/* ================= VARIABLES & RESET ================= */
:root {
    --bg-primary: #0b1120;
    --bg-card: #151e32;
    --bg-input: #0f172a;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --border: #334155;
    --success: #10b981;
    --danger: #ef4444;
    --radius: 10px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ── Light theme ── */
[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --border: #cbd5e1;
    --success: #059669;
    --danger: #dc2626;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { text-decoration: none; transition: 0.2s; }

/* ================= HEADER ================= */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}
.logo { font-size: 1.2rem; font-weight: 700; color: var(--text-main); white-space: nowrap; }
.site-title {
    position: absolute;
    left: 50%; transform: translateX(-50%);
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 0.03em;
    pointer-events: none;
    white-space: nowrap;
}
header nav { display: flex; gap: 12px; }

/* ================= BUTTONS ================= */
.btn {
    padding: 10px 20px;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    display: inline-block;
    text-align: center;
}
.btn:hover { background: var(--bg-input); border-color: var(--accent); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-full { width: 100%; margin-top: 8px; }
.btn-outline { background: transparent; color: var(--text-muted); border-color: var(--border); padding: 8px 16px; font-size: 0.9rem; }
.btn-outline:hover { border-color: var(--danger); color: var(--danger); background: rgba(239, 68, 68, 0.1); }
.btn-success { background: var(--success); color: #fff; border: none; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; border: none; }
.btn-danger:hover { background: #dc2626; }
.btn-danger:disabled { background: #7f1d1d; cursor: not-allowed; opacity: 0.7; }

/* ================= HERO (ГЛАВНАЯ) ================= */
.hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 40px 20px;
    gap: 16px;
}
.hero h1 { font-size: 2.5rem; font-weight: 700; }
.hero p { font-size: 1.2rem; color: var(--text-muted); max-width: 600px; }
.hero-buttons { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

/* ================= AUTH PAGES ================= */
.auth-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 24px;
}
.auth-container h2 { text-align: center; margin: 0; font-size: 1.8rem; }
form {
    width: 100%; max-width: 420px;
    background: var(--bg-card); padding: 32px;
    border-radius: var(--radius); box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
form div { margin-bottom: 16px; }
label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--text-muted); font-size: 0.9rem; }
input[type="text"], input[type="password"] {
    width: 100%; padding: 12px; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text-main); font-size: 1rem; transition: 0.2s;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
#captcha-container { background: var(--bg-input); padding: 12px; border-radius: var(--radius); border: 1px dashed var(--border); text-align: center; color: var(--text-muted); }
.field-hint {
    margin-top: 5px;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.field-hint code {
    font-family: monospace;
    background: var(--bg-input);
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px solid var(--border);
}
.field-hint--warn {
    color: var(--warning, #f59e0b);
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 6px;
    padding: 6px 10px;
    margin-top: 6px;
}

/* ================= DASHBOARD LAYOUT ================= */
#dashboard-header { padding: 16px 24px; }
.user-panel { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.user-greeting { color: var(--text-muted); font-size: 0.9rem; white-space: nowrap; margin-right: 4px; }

#dashboard-content {
    display: grid;
    grid-template-columns: 2fr 1.4fr;
    gap: 24px;
    padding: 40px 24px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    align-items: start;
    flex: 1;
}

#tariffs {
    grid-column: 2; grid-row: 1 / span 4;
    height: 100%; min-height: 400px;
    background: var(--bg-card); padding: 24px;
    border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow);
}
#tariffs h2 { margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
#tariffs article {
    margin-bottom: 12px; padding: 14px 16px; background: var(--bg-input);
    border-radius: 8px; display: flex; flex-direction: column; gap: 8px;
    border: 2px solid transparent; cursor: pointer; transition: border-color 0.2s;
}
#tariffs article:hover { border-color: var(--border); }
#tariffs article.selected { border-color: var(--accent); background: rgba(59,130,246,0.08); }
#tariffs article h3 { color: var(--accent); margin: 0; }
#tariffs article p { color: var(--text-muted); font-size: 0.95rem; }

#subscription-info, #referral-section, #vpn-access, #link-tg-section {
    grid-column: 1;
    background: var(--bg-card); padding: 24px;
    border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow);
}
#subscription-info { grid-row: 1; text-align: center; }
#subscription-info h2 { margin-bottom: 16px; }
#subscription-info p { font-size: 1.1rem; margin-bottom: 8px; }
#subscription-info strong { color: var(--success); }

#vpn-access { grid-row: 2; text-align: center; }
#vpn-access h2 { margin-bottom: 12px; }
#vpn-access p { color: var(--text-muted); margin-bottom: 16px; }

#referral-section { grid-row: 3; }
#referral-section h2 { margin-bottom: 12px; font-size: 1.3rem; }
#referral-section p { color: var(--text-muted); margin-bottom: 8px; }

#link-tg-section { grid-row: 4; }

#ref-link {
    display: block; margin-top: 10px; padding: 10px;
    background: var(--bg-input); border: 1px dashed var(--accent);
    border-radius: 8px; color: var(--accent); text-align: center;
    font-family: monospace; word-break: break-all;
}

/* ================= TOAST ================= */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    z-index: 9999;
    box-shadow: var(--shadow);
    animation: fadeIn 0.2s ease;
}
.toast-info    { background: var(--bg-card); border: 1px solid var(--border); color: var(--text-main); }
.toast-success { background: var(--success); color: #fff; }
.toast-error   { background: var(--danger);  color: #fff; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ================= ADMIN BADGE ================= */
.admin-badge {
    background: var(--accent);
    color: #fff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* ================= ADMIN PANEL ================= */
.admin-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    padding: 32px 24px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}
.admin-sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    height: fit-content;
}
.admin-sidebar h3 { margin-bottom: 16px; color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
.admin-nav-item {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-main);
    cursor: pointer;
    margin-bottom: 4px;
    transition: 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.95rem;
}
.admin-nav-item:hover, .admin-nav-item.active { background: var(--bg-input); color: var(--accent); }
.admin-main { min-height: 60vh; }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-card .stat-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }
.admin-table-wrap { overflow-x: auto; }
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.admin-table th, .admin-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.admin-table th { color: var(--text-muted); font-weight: 500; }
.admin-table tr:hover td { background: var(--bg-input); cursor: pointer; }
.badge-active  { color: var(--success); font-weight: 600; }
.badge-expired { color: var(--danger); }
.badge-none    { color: var(--text-muted); }
.pagination { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    max-width: 520px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}
.modal h2 { margin-bottom: 16px; }
.modal .field { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.modal .field span:first-child { color: var(--text-muted); }
.modal-close { margin-top: 16px; }
@media (max-width: 900px) {
    .admin-layout { grid-template-columns: 1fr; }
}

/* ================= OFFER PAGE ================= */
.offer-page {
    flex: 1;
    padding: 40px 20px;
    display: flex;
    justify-content: center;
}
.offer-container {
    max-width: 860px;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px;
}
.offer-container h1 {
    font-size: 2rem;
    margin-bottom: 12px;
}
.offer-intro {
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.7;
}
.offer-container section {
    margin-top: 28px;
}
.offer-container h2 {
    font-size: 1.15rem;
    color: var(--accent);
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.offer-container p {
    margin-bottom: 10px;
    line-height: 1.7;
}
.offer-container ul {
    margin: 8px 0 10px 24px;
    line-height: 1.7;
    color: var(--text-muted);
}
.offer-footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border);
}
.offer-footer a {
    color: var(--accent);
}
.offer-footer a:hover {
    text-decoration: underline;
}

/* ================= RESPONSIVE ================= */
@media (max-width: 900px) {
    #dashboard-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    #tariffs { grid-column: auto; grid-row: auto; min-height: auto; }
    #subscription-info, #referral-section, #vpn-access, #link-tg-section {
        grid-column: auto; grid-row: auto;
    }
    .user-panel { flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
    .hero h1 { font-size: 2rem; }
}

@media (max-width: 600px) {
    /* Header — убираем абсолютный центр, перестраиваем в колонку */
    header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 10px;
    }
    .site-title {
        position: static;
        transform: none;
        font-size: 1.1rem;
        order: -1;
        width: 100%;
        text-align: center;
        pointer-events: auto;
    }
    .logo { font-size: 1rem; }
    header nav { gap: 8px; }

    /* Hero */
    .hero h1 { font-size: 1.5rem; }
    .hero p { font-size: 1rem; }
    .hero-buttons { flex-direction: column; align-items: center; }
    .hero-buttons .btn { width: 100%; max-width: 320px; }

    /* Dashboard */
    #dashboard-content { padding: 12px; gap: 12px; }
    #dashboard-header { padding: 12px 16px; }

    /* Admin */
    .admin-layout { padding: 12px; gap: 12px; }
    .modal { padding: 16px; width: 95%; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .admin-table th, .admin-table td { padding: 8px 6px; font-size: 0.82rem; }

    /* User panel */
    .user-panel { flex-direction: column; align-items: flex-end; gap: 6px; }
    .user-greeting { font-size: 0.85rem; }

    /* Buttons */
    .btn { padding: 8px 14px; font-size: 0.9rem; }

    /* Forms */
    form { padding: 20px 16px; }

    /* Offer */
    .offer-container { padding: 20px 16px; }
    .offer-container h1 { font-size: 1.5rem; }

    /* Toast */
    .toast { left: 16px; right: 16px; bottom: 16px; text-align: center; }
}

@media (max-width: 400px) {
    .hero h1 { font-size: 1.3rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .btn { padding: 8px 10px; font-size: 0.85rem; }
    .admin-table { font-size: 0.78rem; }
    .admin-table th, .admin-table td { padding: 6px 4px; }
}

/* ================= INVOICE ROW ================= */
.invoice-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
.invoice-row:last-child { border-bottom: none; }

/* ================= PURCHASE PANEL ================= */
#purchase-panel {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    display: none;
}
#purchase-panel.open { display: block; }
#purchase-panel h4 { font-size: 1rem; margin-bottom: 12px; color: var(--accent); }
.purchase-promo-row {
    display: flex; gap: 8px; margin-bottom: 10px;
}
.purchase-promo-row input {
    flex: 1; padding: 8px 10px; font-size: 0.9rem;
    text-transform: uppercase;
}
.purchase-price-summary {
    font-size: 1rem; margin-bottom: 12px; color: var(--text-muted);
}
.purchase-price-summary b { color: var(--text-main); font-size: 1.15rem; }
.purchase-price-summary s { color: var(--text-muted); font-size: 0.9rem; }

/* ================= THEME TOGGLE ================= */
.theme-toggle { font-size: 1rem; padding: 8px 12px; }

/* ================= RESPONSIVE ================= */
@media (max-width: 768px) {
    #dashboard-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    #tariffs { grid-column: 1; grid-row: auto; }
    #subscription-info, #referral-section, #vpn-access { grid-column: 1; }
}
