:root {
    --bg: #07090d;
    --bg-elev: #0d1117;
    --bg-card: #11151c;
    --bg-hover: #1a1f29;
    --border: #1e2530;
    --border-light: #2a3442;
    --text: #e6edf3;
    --text-muted: #7d8794;
    --text-dim: #5a6572;
    --primary: #7cc6ff;
    --primary-soft: #b8dcff;
    --primary-dark: #4a9eff;
    --success: #7ee0a8;
    --danger: #ff9aa2;
    --warning: #ffd88a;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-pill: 999px;
    --transition: all .2s cubic-bezier(.4,0,.2,1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    position: relative;
    overflow-x: hidden;
}




    33% { transform: translate(2%, -2%) scale(1.02); }
    66% { transform: translate(-2%, 2%) scale(1.01); }
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-soft); }

/* ==== Формы и инпуты ==== */
input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124,198,255,0.15);
    outline: none;
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237d8794' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px !important;
}

/* ==== Кнопки ==== */
.btn-primary {
    padding: 10px 22px;
    background: var(--primary);
    color: #07090d;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-primary:hover {
    background: var(--primary-soft);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(124,198,255,0.2);
}
.btn-primary:active { transform: translateY(0) scale(0.98); }

.btn-small {
    padding: 7px 16px;
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-small:hover { border-color: var(--primary); color: var(--primary); }
.btn-small:active { transform: scale(0.96); }

.btn-danger { border-color: rgba(255,154,162,0.4); color: var(--danger); }
.btn-danger:hover { background: rgba(255,154,162,0.08); border-color: var(--danger); }

/* ==== Авторизация ==== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.auth-container { width: 100%; max-width: 440px; }
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.5);
    animation: authFadeIn 0.4s cubic-bezier(.34,1.1,.64,1);
}
@keyframes authFadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
}
.auth-header p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.auth-form .form-group { margin-bottom: 18px; text-align: left; }
.auth-form { text-align: center; }
.auth-form label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--text); font-size: 13px; }
.auth-form .btn-primary { margin: 6px auto 0 auto; width: 100%; }
.auth-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
}

/* ==== Каркас приложения (Дашборд, Админка) ==== */
.app { display: flex; min-height: 100vh; width: 100%; }

.sidebar {
    width: 220px;
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
}
.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px 10px 8px 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 20px 12px;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.folder-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    transition: var(--transition);
    margin-bottom: 2px;
    position: relative;
}
.folder-link:hover { background: var(--bg-hover); color: var(--text); transform: translateX(2px); }
.folder-link.active { background: rgba(124,198,255,0.1); color: var(--primary); }
.folder-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 8px; bottom: 8px;
    width: 3px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}
.folder-icon { display: flex; align-items: center; justify-content: center; min-width: 20px; }
.folder-name { flex: 1; }

/* Блок аккаунтов внизу сайдбара */
.accounts-wrapper {
    flex-shrink: 0;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-elev);
}
.logout-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 12px;
    color: var(--danger);
    font-size: 12px;
    border-radius: var(--radius-sm);
    background: rgba(255,154,162,0.06);
    border: 1px solid rgba(255,154,162,0.15);
    transition: var(--transition);
}
.logout-all:hover { background: rgba(255,154,162,0.12); border-color: rgba(255,154,162,0.3); color: var(--danger); }

/* Основной контент */
.main-content {
    flex: 1;
    margin-left: 220px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - 220px);
}
.content-header {
    padding: 18px 32px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}
.content-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
}
.user-header { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.user-email { color: var(--text-muted); }
#header-balance { color: var(--primary); font-weight: 600; }

/* Страницы */
.page { display: none; padding: 24px 32px 40px 32px; animation: pageFadeIn .3s ease-out; flex: 1; }
.page.active { display: block; }
@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==== Дашборд: Главная ==== */
.home-hero { margin-bottom: 24px; }
.home-hero h1 { font-size: 24px; margin-bottom: 4px; }
.home-hero p { color: var(--text-muted); font-size: 14px; }

.home-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.home-stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; align-items: center; gap: 16px; }
.home-stat-icon { width: 44px; height: 44px; border-radius: 12px; background: rgba(124,198,255,0.1); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.home-stat-value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.home-stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }

.home-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.home-column { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.home-column-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.home-column-header h3 { font-size: 15px; font-weight: 600; }
.home-column-link { font-size: 13px; color: var(--primary); text-decoration: none; }
.home-list { display: flex; flex-direction: column; gap: 8px; }
.home-list-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); text-decoration: none; color: var(--text); transition: var(--transition); }
.home-list-item:hover { border-color: var(--primary); transform: translateX(2px); }
.home-list-item-title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-list-item-status { padding: 2px 8px; border-radius: var(--radius-pill); font-size: 10px; font-weight: 700; flex-shrink: 0; }
.home-list-item-status.active { background: rgba(126,224,168,0.12); color: var(--success); }
.home-list-item-status.inactive { background: rgba(255,154,162,0.12); color: var(--danger); }
.home-list-empty { text-align: center; padding: 20px; color: var(--text-dim); font-size: 13px; }

/* ==== Дашборд: Заголовки и карточки ==== */
.actions-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.actions-bar h2 { font-size: 20px; font-weight: 600; }
.section-subtitle { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; margin-bottom: 4px; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 8px; }
.subdomain-card { background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); padding: 20px; transition: var(--transition); }
.subdomain-card:hover { border-color: var(--border-light); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.subdomain-name { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 10px; word-break: break-all; }
.subdomain-status { display: inline-block; padding: 2px 10px; border-radius: var(--radius-pill); font-size: 10px; font-weight: 700; letter-spacing: 0.3px; }
.subdomain-status.active { background: rgba(126,224,168,0.12); color: var(--success); }
.subdomain-status.inactive { background: rgba(255,154,162,0.12); color: var(--danger); }
.subdomain-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* ==== Настройки ==== */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin-top: 16px; }
.settings-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.settings-card h3 { margin-bottom: 16px; font-size: 15px; color: var(--primary); border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.settings-card .form-group { margin-bottom: 16px; }
.settings-card label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.code-block { background: #0d1117; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; font-family: monospace; font-size: 13px; color: #c9d1d9; line-height: 1.6; }

/* ==== Модальные окна ==== */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(7,9,13,0.85); backdrop-filter: blur(6px); z-index: 1000; align-items: center; justify-content: center; }
.modal.active { display: flex; animation: fadeIn .2s; }
.modal-content { background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius); max-width: 520px; width: 90%; max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 48px rgba(0,0,0,0.6); animation: modalPop 0.25s cubic-bezier(.34,1.56,.64,1); }
.modal-fullscreen { max-width: 95%; width: 95%; height: 90vh; }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 16px; color: var(--primary); }
.modal-close { background: transparent; border: 1px solid var(--border-light); width: 30px; height: 30px; border-radius: var(--radius-pill); color: var(--text-muted); cursor: pointer; font-size: 16px; transition: var(--transition); display: flex; align-items: center; justify-content: center; }
.modal-close:hover { border-color: var(--danger); color: var(--danger); transform: rotate(90deg); }
.modal-body { padding: 24px; overflow-y: auto; }
@keyframes modalPop { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ==== Уведомления ==== */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 1100; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 12px 20px; min-width: 240px; color: var(--text); box-shadow: 0 8px 24px rgba(0,0,0,0.5); animation: toastSlide 0.3s cubic-bezier(.34,1.56,.64,1); font-size: 13px; }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
@keyframes toastSlide { from { opacity: 0; transform: translateX(30px) scale(0.9); } to { opacity: 1; transform: translateX(0) scale(1); } }

/* ==== Футер ==== */
.app-footer { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 18px 24px; color: var(--text-dim); font-size: 12px; border-top: 1px solid var(--border); margin-top: auto; flex-shrink: 0; }
.app-footer svg { opacity: 0.7; }
.app-footer a { color: var(--text-muted); margin: 0 4px; }
.app-footer a:hover { color: var(--primary); }

/* ==== Адаптивность ==== */
@media (max-width: 900px) {
    .sidebar { width: 64px; }
    .sidebar .logo { font-size: 0; padding: 10px; justify-content: center; }
    .folder-name { display: none; }
    .folder-link { justify-content: center; padding: 10px; }
    .main-content { margin-left: 64px; width: calc(100% - 64px); }
    .content-header { padding: 14px 16px; }
    .content-header h1 { font-size: 18px; }
    .page { padding: 16px 14px 30px 14px; }
    .cards-grid, .settings-grid, .home-stats, .home-columns { grid-template-columns: 1fr; }
    .auth-card { padding: 28px 20px; }
    .auth-header h1 { font-size: 24px; }
    .actions-bar { flex-direction: column; align-items: flex-start; }
}

/* Accounts block in sidebar */
.accounts-wrapper {
    flex-shrink: 0;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-elev);
}
.accounts-block {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.accounts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
}
.accounts-header:hover { background: var(--bg-hover); }
.accounts-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}
.accounts-count {
    background: var(--bg-elev);
    color: var(--primary);
    font-size: 10px;
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    font-weight: 700;
}
.accounts-toggle {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    padding: 2px;
    transition: transform .2s;
}
.accounts-list {
    padding: 6px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 300px;
    overflow-y: auto;
    transition: max-height .25s ease, opacity .2s ease, padding .25s ease;
}
.accounts-list.collapsed {
    max-height: 0;
    padding: 0 6px;
    opacity: 0;
    overflow: hidden;
    border-top-color: transparent;
}
.account-item {
    display: flex;
    align-items: center;
    gap: 4px;
    border-radius: var(--radius-sm);
    transition: background .15s, transform .15s;
}
.account-item:hover { background: var(--bg-hover); transform: translateX(2px); }
.account-item.active { background: rgba(124,198,255,0.1); }
.account-link {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    color: var(--text-muted);
    font-size: 12px;
    text-decoration: none;
}
.account-item.active .account-link { color: var(--primary); }
.account-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--bg-elev);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}
.account-item.active .account-avatar { background: var(--primary); color: #0a121e; }
.account-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.account-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    color: var(--text-dim);
    flex-shrink: 0;
    margin-right: 8px;
    text-decoration: none;
}
.account-remove:hover { background: rgba(255,154,162,0.15); color: var(--danger); }
.account-add {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-top: 4px;
    color: var(--primary);
    font-size: 12px;
    text-decoration: none;
    border-radius: 6px;
    border: 1px dashed rgba(124,198,255,0.3);
}
.account-add:hover { background: rgba(124,198,255,0.08); border-style: solid; }

@media (max-width: 900px) {
    .accounts-wrapper { display: none; }
}

/* Скрываем мобильное меню аккаунтов на ПК */
.mobile-accounts-menu { display: none; }

@media (max-width: 900px) {
    .mobile-accounts-menu { display: block; position: relative; }
    .mobile-accounts-toggle {
        background: var(--bg-card);
        border: 1px solid var(--border-light);
        color: var(--text);
        border-radius: 6px;
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }
    .mobile-accounts-list {
        position: absolute;
        top: 38px;
        right: 0;
        min-width: 240px;
        background: var(--bg-card);
        border: 1px solid var(--border-light);
        border-radius: var(--radius-sm);
        padding: 6px;
        z-index: 1000;
        display: none;
        flex-direction: column;
        gap: 2px;
        box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    }
    .mobile-accounts-list.open { display: flex; }
    .mobile-account-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 10px;
        color: var(--text-muted);
        font-size: 12px;
        text-decoration: none;
        border-radius: 6px;
    }
    .mobile-account-item:hover { background: var(--bg-hover); color: var(--text); }
    .mobile-account-item.active { background: rgba(124,198,255,0.1); color: var(--primary); }
    .mobile-account-add, .mobile-account-logout {
        display: block;
        padding: 8px 10px;
        margin-top: 4px;
        font-size: 12px;
        border-radius: 6px;
        text-decoration: none;
        text-align: center;
    }
    .mobile-account-add { color: var(--primary); border: 1px dashed rgba(124,198,255,0.3); }
    .mobile-account-logout { color: var(--danger); background: rgba(255,154,162,0.06); border: 1px solid rgba(255,154,162,0.15); }
}

/* Фон с геометрией */
.bg-shapes { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: -1; overflow: hidden; background: var(--bg); pointer-events: none; }
.bg-shapes .shape { position: absolute; background: rgba(124, 198, 255, 0.03); border: 1px solid rgba(124, 198, 255, 0.1); animation: floatShape 25s infinite linear; will-change: transform; }
.bg-shapes .square { width: 120px; height: 120px; border-radius: 20px; }
.bg-shapes .square.s1 { top: 10%; left: 10%; animation-duration: 30s; }
.bg-shapes .square.s2 { top: 60%; left: 80%; width: 200px; height: 200px; animation-duration: 40s; animation-direction: reverse; }
.bg-shapes .square.s3 { top: 80%; left: 20%; width: 80px; height: 80px; animation-duration: 20s; }
.bg-shapes .triangle { width: 150px; height: 150px; background: rgba(74, 158, 255, 0.04); border: none; clip-path: polygon(50% 0%, 0% 100%, 100% 100%); }
.bg-shapes .triangle.t1 { top: 20%; left: 70%; animation-duration: 35s; }
.bg-shapes .triangle.t2 { top: 70%; left: 40%; width: 250px; height: 250px; animation-duration: 45s; animation-direction: reverse; }
.bg-shapes .triangle.t3 { top: 40%; left: -5%; width: 100px; height: 100px; animation-duration: 25s; }
.bg-shapes .circle { border-radius: 50%; }
.bg-shapes .circle.c1 { top: 85%; left: 60%; width: 300px; height: 300px; background: radial-gradient(circle, rgba(124, 198, 255, 0.05) 0%, transparent 70%); border: none; animation-duration: 50s; }
@keyframes floatShape {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); }
    33% { transform: translate(40px, -50px) rotate(120deg) scale(1.1); }
    66% { transform: translate(-30px, 30px) rotate(240deg) scale(0.9); }
    100% { transform: translate(0, 0) rotate(360deg) scale(1); }
}

/* Фикс логотипа в сайдбаре */
.sidebar .logo {
    padding: 20px 16px 12px 20px !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
}
.sidebar .logo svg {
    margin: 0 !important;
    flex-shrink: 0 !important;
}
.sidebar .logo h2, .sidebar .logo span {
    font-size: 17px !important;
    font-weight: 700 !important;
    color: var(--primary) !important;
    line-height: 1 !important;
}
.folder-link { text-decoration: none !important; }
