:root {
    --bg: #0a0713;
    --card: rgba(28, 20, 48, 0.6);
    --card-border: rgba(140, 100, 255, 0.16);
    --text: #ede9ff;
    --muted: #9a92bd;
    --accent: #a06bff;
    --accent-2: #7c4dff;
    --radius: 20px;
    --radius-sm: 12px;
    --danger: #ff6b6b;
    --success: #4ade80;
    --sidebar-w: 240px;
    --topbar-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
}

.app {
    display: flex;         /* Делает сайдбар и контент в ряд */
    min-height: 100vh;
    width: 100%;
}

.sidebar {
    width: 260px;          /* Фиксированная ширина сайдбара */
    flex-shrink: 0;        /* Запрещает сжимать сайдбар */
    background: rgba(15, 10, 25, 0.7);
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
}

.app-main {
    flex-grow: 1;          /* Контент занимает всё оставшееся место */
    min-width: 0;          /* Важно, чтобы flex-элемент не вылезал за пределы */
    display: flex;
    flex-direction: column;
}

.content {
    flex-grow: 1;          /* Контент растягивается, прижимая футер к низу */
    padding: 32px 24px 0;
    max-width: 900px;
    margin: 0 auto;        /* Центрирует контент */
    width: 100%;
}


.sidebar {
    background: rgba(15, 10, 25, 0.7);
    border-right: 1px solid var(--card-border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(20px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 32px;
    padding-left: 8px;
}

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label {
    font-size: 11px; text-transform: uppercase; color: var(--muted);
    letter-spacing: 1px; padding: 8px;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--muted); text-decoration: none; font-size: 14px;
    transition: all .2s;
}
.nav-item:hover { background: rgba(160,107,255,0.08); color: var(--text); }
.nav-item.is-active { background: rgba(160,107,255,0.15); color: var(--accent); }
.nav-item i { font-size: 20px; }

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--card-border); }

.app-main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: var(--topbar-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--card-border);
    background: rgba(10, 7, 19, 0.6);
    backdrop-filter: blur(20px);
    position: sticky; top: 0; z-index: 10;
}

.topbar-brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.content { padding: 32px 24px 80px; max-width: 900px; margin: 0 auto; width: 100%; }

/* Кнопки */
.btn { display: inline-flex; align-items: center; gap: 8px; border: none; border-radius: var(--radius-sm); cursor: pointer; font-family: inherit; text-decoration: none; transition: all .2s; }
.btn-primary { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #fff; font-weight: 600; padding: 10px 18px; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(124,77,255,0.4); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-ghost { background: transparent; border: 1px solid var(--card-border); color: var(--muted); }

/* Карточки */
.card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); backdrop-filter: blur(20px); overflow: hidden; }
.module-card { padding: 28px; }

/* Формы */
.select, .text-input, .input { width: 100%; background: rgba(10,7,19,0.5); border: 1px solid rgba(160,107,255,0.15); border-radius: var(--radius-sm); color: var(--text); padding: 10px 12px; font-family: inherit; font-size: 14px; outline: none; transition: border-color .2s; }
.select:focus, .text-input:focus, .input:focus { border-color: var(--accent); }

/* Сетка настроек */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.setting { display: flex; flex-direction: column; gap: 6px; }
.setting-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* Прогресс */
.progress-card { padding: 28px; margin-top: 24px; }
.progress-head { display: flex; align-items: center; gap: 16px; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid rgba(160,107,255,0.15); border-top-color: var(--accent); animation: spin 1s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Скрытый */
.hidden { display: none !important; }

/* Адаптив */
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .3s; z-index: 100; }
    .sidebar.open { transform: translateX(0); }
    .topbar-brand .brand-text { display: none; }
    .brand-text { display: none; }
    .burger { display: flex; background: transparent; border: none; color: var(--text); font-size: 24px; margin-right: 12px; }
    .settings-grid { grid-template-columns: 1fr; }
}
@media (min-width: 901px) { .burger { display: none; } }

/* --- TOPBAR USER DROP --- */
.user-drop { position: relative; cursor: pointer; }
.user-drop .avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(160,107,255,0.3); }
.user-drop .avatar-empty { display: grid; place-items: center; background: var(--accent-2); color: #fff; font-weight: 600; }
.user-menu {
    position: absolute; right: 0; top: 100%; margin-top: 8px;
    background: #1a1030; border: 1px solid var(--card-border); border-radius: var(--radius-sm);
    min-width: 160px; display: none; flex-direction: column; padding: 6px; z-index: 50;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.user-drop.open .user-menu { display: flex; }
.user-menu a, .user-menu .link-btn {
    padding: 8px 12px; color: var(--text); text-decoration: none; border-radius: 6px;
    font-size: 14px; transition: background .2s; text-align: left;
    background: transparent; border: none; cursor: pointer; font-family: inherit;
}
.user-menu a:hover, .user-menu .link-btn:hover { background: rgba(160,107,255,0.15); }

/* --- FLASH TOAST --- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 14px; }
.flash-info { background: rgba(160,107,255,0.1); border: 1px solid rgba(160,107,255,0.3); }
.flash-error { background: rgba(255,107,107,0.1); border: 1px solid rgba(255,107,107,0.3); color: #ff9999; }
.flash-success { background: rgba(74,222,128,0.1); border: 1px solid rgba(74,222,128,0.3); color: #bcf0d0; }

/* --- BALANCE --- */
.balance {
    display: flex; align-items: center; gap: 6px; text-decoration: none; color: var(--accent);
    background: rgba(160,107,255,0.1); padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 14px;
    transition: all .2s;
}
.balance:hover { background: rgba(160,107,255,0.2); }

/* --- МОДУЛИ --- */
.module-head { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.module-head i { font-size: 32px; color: var(--accent); }
.module-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.module-desc { color: var(--muted); font-size: 14px; }

/* Dropzone */
.dropzone {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    border: 2px dashed rgba(160,107,255,0.3); border-radius: var(--radius);
    padding: 40px 20px; background: rgba(10,7,19,0.3); cursor: pointer; transition: all .2s;
    margin-bottom: 24px; text-align: center;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: rgba(160,107,255,0.05); }
.dropzone input[type=file] { display: none; }
.dz-icon { font-size: 32px; color: var(--accent); }
.dz-text { font-weight: 500; font-size: 15px; }
.dz-hint { font-size: 12px; color: var(--muted); }

/* Cost bar */
.cost-bar {
    display: flex; justify-content: space-between; align-items: center; padding-top: 16px;
    border-top: 1px solid var(--card-border); gap: 16px; flex-wrap: wrap;
}
.cost-bar b { color: var(--accent); }

/* Кнопка generate */
.btn-generate {
    padding: 14px 24px; background: linear-gradient(135deg, var(--accent-2), var(--accent));
    border: none; border-radius: var(--radius-sm); color: #fff; font-family: inherit;
    font-size: 15px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
    box-shadow: 0 4px 24px rgba(124,77,255,0.4); transition: all .2s;
}
.btn-generate:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(124,77,255,0.6); }
.btn-generate:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* Результат */
.result { text-align: center; padding: 32px; }
.result-inner i { font-size: 48px; color: var(--success); margin-bottom: 12px; }
.result-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
/* --- HERO (Главная) --- */
.hero { text-align: center; margin-bottom: 48px; padding-top: 20px; }
.hero h1 { font-size: clamp(28px, 5vw, 48px); line-height: 1.1; font-weight: 800; letter-spacing: -1px; margin-bottom: 16px; }
.grad { background: linear-gradient(120deg, #b07dff 0%, #ff6bd6 50%, #6bc4ff 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { color: var(--muted); font-size: 16px; max-width: 500px; margin: 0 auto; line-height: 1.55; }

.modules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.module-card-link { text-decoration: none; color: inherit; display: block; }
.module-tile { padding: 24px; height: 100%; display: flex; flex-direction: column; transition: all .3s; border: 1px solid var(--card-border); }
.module-card-link:hover .module-tile { border-color: rgba(160,107,255,0.4); transform: translateY(-4px); box-shadow: 0 10px 30px rgba(0,0,0,0.3); background: rgba(28,20,48,0.8); }
.tile-icon { width: 48px; height: 48px; border-radius: 12px; background: rgba(160,107,255,0.1); display: grid; place-items: center; font-size: 24px; color: var(--accent); margin-bottom: 16px; }
.tile-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.tile-desc { color: var(--muted); font-size: 14px; line-height: 1.5; margin-bottom: 24px; flex-grow: 1; }
.tile-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.badge { background: rgba(160,107,255,0.1); color: var(--accent); padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.badge-free { background: rgba(74,222,128,0.1); color: var(--success); }
.tile-arrow { color: var(--muted); transition: transform .2s; }
.module-card-link:hover .tile-arrow { transform: translateX(4px); color: var(--accent); }

/* --- PROFILE --- */
.profile-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 32px; background: var(--card); padding: 24px; border-radius: var(--radius); border: 1px solid var(--card-border); }
.profile-info { display: flex; align-items: center; gap: 20px; }
.profile-avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(160,107,255,0.4); }
.profile-info h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.muted { color: var(--muted); font-size: 14px; }
.profile-balance-box { background: rgba(10,7,19,0.4); padding: 16px 24px; border-radius: var(--radius-sm); border: 1px solid rgba(160,107,255,0.15); text-align: center; min-width: 200px; }
.balance-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.balance-value { font-size: 32px; font-weight: 800; color: var(--accent); }
.tokens-label { font-size: 14px; font-weight: 500; color: var(--muted); }

/* --- TABLE --- */
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--card-border); }
.card-head h2 { font-size: 18px; font-weight: 600; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 14px 24px; text-align: left; border-bottom: 1px solid rgba(160,107,255,0.06); font-size: 14px; }
.table th { font-size: 12px; text-transform: uppercase; color: var(--muted); font-weight: 500; letter-spacing: 0.5px; }
.table tbody tr:hover { background: rgba(160,107,255,0.04); }
.table tbody tr:last-child td { border-bottom: none; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
/* --- FOOTER --- */
.site-footer {
    background: rgba(15, 10, 25, 0.4);
    border-top: 1px solid var(--card-border);
    padding: 48px 24px 24px;
    margin-top: 60px; /* Отступ от контента */
}

.footer-content {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 40px;
    margin-bottom: 40px;
}

.footer-brand {
    max-width: 250px;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 18px;
    text-decoration: none;
    margin-bottom: 12px;
}

.footer-desc {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.footer-links {
    display: flex;
    gap: 60px;
}

.footer-col h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}

.footer-col a {
    display: block;
    color: var(--muted);
    font-size: 13px;
    text-decoration: none;
    margin-bottom: 10px;
    transition: color 0.2s;
}

.footer-col a:hover {
    color: var(--accent);
}

.footer-bottom {
    max-width: 1000px;
    margin: 0 auto;
    padding-top: 24px;
    border-top: 1px solid rgba(160, 107, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    color: var(--muted);
    font-size: 12px;
}

/* Центровка контента */
.content {
    padding: 32px 24px 0; /* Убрали большой нижний отступ, его теперь делает футер */
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 640px) {
    .footer-content { flex-direction: column; gap: 32px; }
    .footer-links { gap: 32px; flex-direction: column; }
    .footer-bottom { flex-direction: column; text-align: center; }
}
/* --- TOPBAR TITLE --- */
.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    display: flex;
    align-items: center;
}

.topbar-title .muted {
    color: var(--muted);
    font-weight: 400;
}

.topbar-title i {
    color: var(--muted);
}
/* Ссылка в хлебных крошках */
.breadcrumb-link {
    color: var(--muted);
    text-decoration: none;
    font-weight: 400;
    transition: color 0.2s;
}

.breadcrumb-link:hover {
    color: var(--accent);
}
/* === ЛОГО В САЙДБАРЕ === */
.brand {
    display: flex;
    align-items: center;
    justify-content: center; /* Центрируем по горизонтали */
    gap: 12px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 20px; /* Чуть увеличили шрифт */
    margin-bottom: 32px;
    padding: 12px 0; /* Отступы сверху и снизу */
    border-bottom: 1px solid rgba(160, 107, 255, 0.1); /* Красивая линия под лого */
}

.brand-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

/* === ХЛЕБНЫЕ КРОШКИ (ДЕСКТОП) === */
.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    display: flex;
    align-items: center;
}

.breadcrumb-link {
    color: var(--muted);
    text-decoration: none;
    font-weight: 400;
    transition: color 0.2s;
}

.breadcrumb-link:hover {
    color: var(--accent);
}

/* === МОБИЛЬНЫЙ ЛОГОТИП (скрыт на десктопе) === */
.topbar-mobile-logo {
    display: none; /* Прячем по умолчанию */
    align-items: center;
    text-decoration: none;
}

/* =========================================
   МОБИЛЬНАЯ ВЕРСИЯ (АДАПТИВ)
   ========================================= */
/* =========================================
   МОБИЛЬНАЯ ВЕРСИЯ (АДАПТИВ - ВЫЕЗЖАЮЩЕЕ МЕНЮ)
   ========================================= */
@media (max-width: 900px) {

    /* Сайдбар прячется за левый край экрана */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 260px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        background: #0a0713; /* Плотный фон */
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    }

    /* Когда JS добавляет класс .open, меню выезжает */
    .sidebar.open {
        transform: translateX(0);
    }

    /* Показываем бургер */
    .burger {
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--text);
        font-size: 24px;
        cursor: pointer;
        padding: 8px;
        margin-right: 8px;
    }

    /* Прячем крошки, показываем мобильный логотип по центру */
    .topbar-title {
        display: none;
    }

    .topbar-mobile-logo {
        display: flex;
        margin: 0 auto;
    }

    /* Прячем текст кнопки "Пополнить", оставляем только иконку */
    .topbar-right .btn-primary {
        padding: 6px 10px;
        font-size: 0;
    }
    .topbar-right .btn-primary i {
        font-size: 16px;
        margin: 0;
    }

    .topbar {
        padding: 0 16px;
    }
}

/* На десктопе бургер и мобильный логотип скрыты */
@media (min-width: 901px) {
    .burger {
        display: none;
    }
    .topbar-mobile-logo {
        display: none;
    }
}