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

:root {
    --bg: #0a0a1a;
    --bg2: #0f0f2a;
    --glass: rgba(255,255,255,0.05);
    --glass-border: rgba(255,255,255,0.1);
    --glass-hover: rgba(255,255,255,0.08);
    --purple: #7c3aed;
    --purple-light: #a78bfa;
    --cyan: #06b6d4;
    --green: #10b981;
    --orange: #f59e0b;
    --red: #ef4444;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --sidebar-width: 240px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: -40%;
    left: -20%;
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, rgba(124,58,237,0.15) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -40%;
    right: -20%;
    width: 70%;
    height: 70%;
    background: radial-gradient(circle, rgba(6,182,212,0.1) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(15,15,42,0.8);
    border-right: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    padding: 24px 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px 24px;
    border-bottom: 1px solid var(--glass-border);
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--purple), var(--cyan));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.nav { padding: 16px 12px; flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 2px;
    text-decoration: none;
}

.nav-item:hover { background: var(--glass); color: var(--text); }
.nav-item.active { background: rgba(124,58,237,0.2); color: var(--purple-light); border: 1px solid rgba(124,58,237,0.3); }
.nav-icon { font-size: 16px; }

.sidebar-status {
    padding: 16px 20px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--green);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* MAIN */
.main {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px;
    max-width: calc(100vw - var(--sidebar-width));
}

.section { display: none; }
.section.active { display: block; }

.section-header { margin-bottom: 28px; }
.section-header h1 { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.section-header p { color: var(--text-muted); font-size: 14px; }

/* STATS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    backdrop-filter: blur(10px);
    transition: all 0.2s;
}

.stat-card:hover { background: var(--glass-hover); transform: translateY(-2px); }
.stat-card.highlight { border-color: rgba(124,58,237,0.4); background: rgba(124,58,237,0.1); }

.stat-icon { font-size: 28px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* CARDS */
.card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--glass-border);
}

.card-header h3 { font-size: 15px; font-weight: 600; }

.cards-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.list-container { padding: 12px; }
.empty-state { text-align: center; color: var(--text-muted); padding: 32px; font-size: 14px; }

/* SOURCES */
.sources-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.source-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 24px;
    backdrop-filter: blur(10px);
}

.source-icon { font-size: 32px; margin-bottom: 12px; }
.source-card h3 { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.source-card p { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.form-group small { display: block; font-size: 11px; color: var(--text-muted); margin-top: 4px; }

input, textarea {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 13px;
    transition: border-color 0.2s;
}

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

.source-actions { display: flex; gap: 10px; margin-bottom: 12px; }
.files-list { margin-top: 12px; }

/* BUTTONS */
.btn {
    padding: 9px 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--purple), #5b21b6);
    color: white;
}

.btn-primary:hover { opacity: 0.85; transform: translateY(-1px); }

.btn-secondary {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text);
}

.btn-secondary:hover { background: var(--glass-hover); }

.btn-success { background: linear-gradient(135deg, var(--green), #059669); color: white; }
.btn-danger { background: rgba(239,68,68,0.2); border: 1px solid rgba(239,68,68,0.3); color: var(--red); }

.btn-large { padding: 14px 32px; font-size: 15px; border-radius: 12px; }
.btn-link { background: none; border: none; cursor: pointer; color: var(--purple-light); font-size: 13px; }

/* ANALYSIS */
.analysis-run-card {
    text-align: center;
    padding: 48px;
    margin-bottom: 20px;
    border: 1px solid var(--glass-border);
    background: var(--glass);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

.analysis-icon { font-size: 48px; margin-bottom: 16px; }
.analysis-run-card h3 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.analysis-run-card p { color: var(--text-muted); font-size: 14px; max-width: 500px; margin: 0 auto 24px; }

.analysis-result { margin-top: 20px; }
.hidden { display: none !important; }

/* WEAK POINTS */
.filters { display: flex; gap: 8px; margin-bottom: 20px; }

.filter-btn {
    padding: 7px 16px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    background: var(--glass);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.filter-btn.active { background: rgba(124,58,237,0.2); border-color: var(--purple); color: var(--purple-light); }

.weak-points-list { display: flex; flex-direction: column; gap: 12px; }

.weak-point-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 18px 20px;
    backdrop-filter: blur(10px);
    transition: all 0.2s;
    cursor: pointer;
}

.weak-point-card:hover { background: var(--glass-hover); transform: translateY(-1px); }
.weak-point-card.resolved { opacity: 0.5; }

.wp-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.wp-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.wp-desc { color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.wp-badges { display: flex; gap: 8px; flex-shrink: 0; }

.badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-high { background: rgba(239,68,68,0.2); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.badge-medium { background: rgba(245,158,11,0.2); color: var(--orange); border: 1px solid rgba(245,158,11,0.3); }
.badge-low { background: rgba(16,185,129,0.2); color: var(--green); border: 1px solid rgba(16,185,129,0.3); }
.badge-category { background: rgba(124,58,237,0.15); color: var(--purple-light); border: 1px solid rgba(124,58,237,0.2); }

/* AUTOMATIONS */
.automations-list { display: flex; flex-direction: column; gap: 14px; }

.automation-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 20px;
    backdrop-filter: blur(10px);
    transition: all 0.2s;
}

.automation-card:hover { background: var(--glass-hover); }

.auto-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.auto-title { font-size: 15px; font-weight: 600; }
.auto-desc { color: var(--text-muted); font-size: 13px; margin-bottom: 14px; line-height: 1.5; }
.auto-meta { display: flex; align-items: center; gap: 16px; font-size: 12px; color: var(--text-muted); }
.auto-roi { color: var(--green); font-weight: 600; }
.auto-actions { display: flex; gap: 8px; margin-top: 14px; }

.status-badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.status-pending { background: rgba(245,158,11,0.15); color: var(--orange); }
.status-approved { background: rgba(6,182,212,0.15); color: var(--cyan); }
.status-deployed { background: rgba(16,185,129,0.15); color: var(--green); }
.status-failed { background: rgba(239,68,68,0.15); color: var(--red); }

/* MODAL */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal {
    background: #13132a;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--glass-border);
}

.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--glass-border); display: flex; gap: 10px; justify-content: flex-end; }

pre {
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 16px;
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.6;
    color: #a78bfa;
    max-height: 400px;
    white-space: pre-wrap;
}

/* TOAST */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }

.toast {
    background: #1a1a3a;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 18px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    min-width: 280px;
}

.toast-success { border-color: rgba(16,185,129,0.4); }
.toast-error { border-color: rgba(239,68,68,0.4); }
.toast-info { border-color: rgba(124,58,237,0.4); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* DETAIL SECTIONS */
.detail-section { margin-bottom: 20px; }
.detail-section h4 { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.detail-section p { font-size: 14px; line-height: 1.6; }

.solution-box {
    background: rgba(16,185,129,0.08);
    border: 1px solid rgba(16,185,129,0.2);
    border-radius: 10px;
    padding: 14px;
    font-size: 14px;
    line-height: 1.6;
}

/* FILE ITEMS */
.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    margin-bottom: 6px;
    font-size: 13px;
}

.file-item:hover { background: var(--glass-hover); }
.file-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-type { color: var(--text-muted); font-size: 11px; margin: 0 10px; }

/* LOADING */
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 14px; padding: 20px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--glass-border); border-top-color: var(--purple); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* PROGRESS BAR */
.progress-wrap {
    margin-top: 20px;
    width: 100%;
}

.progress-bar-track {
    background: rgba(255,255,255,0.08);
    border-radius: 100px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 100px;
    background: linear-gradient(90deg, var(--purple), var(--cyan));
    transition: width 0.6s ease;
    width: 0%;
}

.progress-step {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* SEARCH INPUT */
.search-input {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 8px 14px;
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--purple);
}

.search-input::placeholder {
    color: var(--text-muted);
}

/* PAGINATION */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    padding-bottom: 20px;
}

/* SIDEBAR OVERLAY — скрыт по умолчанию везде */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
}

.sidebar-overlay.visible { display: block; }

/* BTN GHOST */
.btn-ghost {
    background: transparent;
    border: 1px solid var(--glass-border);
    padding: 6px 10px;
    font-size: 14px;
}

.btn-ghost:hover {
    background: var(--glass-hover);
}

/* RESPONSIVE */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .cards-row { grid-template-columns: 1fr; }
    .sources-grid { grid-template-columns: 1fr; }
}

/* MOBILE */
@media (max-width: 768px) {
    :root { --sidebar-width: 0px; }

    .sidebar {
        position: fixed;
        left: -260px;
        width: 260px;
        transition: left 0.3s ease;
        z-index: 200;
    }

    .sidebar.open { left: 0; }

    .main {
        margin-left: 0 !important;
        padding: 16px;
    }

    .mobile-header {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 16px;
    }

    .burger-btn {
        display: flex;
        flex-direction: column;
        gap: 4px;
        background: var(--glass);
        border: 1px solid var(--glass-border);
        border-radius: 8px;
        padding: 8px;
        cursor: pointer;
    }

    .burger-btn span {
        width: 18px;
        height: 2px;
        background: var(--text);
        border-radius: 2px;
    }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .auto-actions { flex-wrap: wrap; }
    .section-header h1 { font-size: 22px; }
    .modal-content { max-width: 95vw; margin: 0 10px; }
    .toast-container { bottom: 12px; right: 12px; left: 12px; }
    .toast { min-width: unset; width: 100%; }
}
