/* ===== СБРОС ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root { --bg: #ffffff; --surface: #f8f9fa; --border: #e9ecef; --text: #212529; --text-secondary: #6c757d; --accent: #0052cc; --accent-hover: #0043a5; --success: #198754; --warning: #e6a817; --danger: #dc3545; --radius: 8px; --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
html { font-size: 15px; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.6; }
h1 { font-size: 1.8rem; font-weight: 700; }
h2 { font-size: 1.4rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
section { margin: 3rem 0; }
button { padding: 0.7rem 1.5rem; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); cursor: pointer; font-size: 1rem; width: 100%; }

/* ===== ЛЕНДИНГ ===== */
.landing { max-width: 720px; margin: 0 auto; padding: 3rem 1.5rem; }
.landing-header { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 3rem; }
.logo { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.header-sub { font-size: 0.85rem; color: var(--text-secondary); }
.hero { text-align: center; padding: 2rem 0 3rem; }
.hero-sub { font-size: 1.1rem; color: var(--text-secondary); margin-top: 0.5rem; }
.subscribe-box { display: flex; gap: 0.5rem; justify-content: center; margin-top: 1.5rem; }
.subscribe-box input { padding: 0.7rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 1rem; width: 260px; }
.subscribe-box button { padding: 0.7rem 1.5rem; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); cursor: pointer; font-size: 1rem; width: auto; }
.subscribe-msg { text-align: center; margin-top: 0.5rem; font-size: 0.9rem; color: var(--success); display: none; }
.subscribe-msg.visible { display: block; }
.steps { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }
.step { display: flex; align-items: flex-start; gap: 0.75rem; }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: var(--accent); color: #fff; border-radius: 50%; font-size: 0.85rem; flex-shrink: 0; }
.why-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 1rem; }
.why-grid ul { padding-left: 1.2rem; margin: 0.5rem 0; }
.note { font-size: 0.85rem; color: var(--text-secondary); margin-top: 0.5rem; }
.honest { background: var(--surface); padding: 1.5rem; border-radius: var(--radius); }
.get ul { padding-left: 1.2rem; }
.price { text-align: center; }
footer { text-align: center; font-size: 0.8rem; color: var(--text-secondary); margin-top: 4rem; padding-top: 2rem; border-top: 1px solid var(--border); }

/* ===== ЛОГИН ===== */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--surface); }
.login-box { background: #fff; padding: 2.5rem; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); width: 360px; text-align: center; }
.login-box h2 { margin: 1rem 0; }
.error { color: var(--danger); font-size: 0.85rem; margin-top: 0.5rem; }

/* ===== ФОРМЫ ===== */
.form-group { margin: 0.75rem 0; text-align: left; }
.form-group label { display: block; font-size: 0.85rem; margin-bottom: 0.25rem; color: var(--text-secondary); }
.form-group input[type="text"], .form-group input[type="password"], .form-group input[type="email"] { width: 100%; padding: 0.7rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 1rem; }
.form-group input[type="number"] { padding: 0.3rem 0.5rem; border: 1px solid var(--border); border-radius: 4px; font-size: 0.95rem; }
.radio { display: block; font-size: 0.9rem; margin: 0.25rem 0; cursor: pointer; }
.radio input { margin-right: 0.5rem; }
.radio-inline { display: block; font-size: 0.9rem; margin: 0.3rem 0; cursor: pointer; }
.radio-inline input { margin-right: 0.4rem; }

/* ===== ДАШБОРД ===== */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); background: #fff; }
.back { font-size: 0.9rem; }
.user-info { font-size: 0.85rem; color: var(--text-secondary); }
.dashboard-page { max-width: 900px; margin: 0 auto; }
.dashboard { padding: 2rem 1.5rem; }
.dashboard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.btn-primary { display: inline-block; padding: 0.6rem 1.2rem; background: var(--accent); color: #fff; border-radius: var(--radius); text-decoration: none; font-size: 0.9rem; border: none; cursor: pointer; width: auto; }
.empty { text-align: center; padding: 3rem; }

/* ===== ПРОЕКТЫ (МИНИМАЛИЗМ) ===== */
.card { background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); width: 100%; overflow: hidden; border: 1px solid var(--border); }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid #e9ecef; display: flex; justify-content: space-between; align-items: baseline; }
.card-header h2 { font-size: 1.1rem; font-weight: 600; margin: 0; }
.card-header span { font-size: 0.78rem; color: #adb5bd; }
.project-item { display: flex; align-items: center; justify-content: space-between; padding: 0.8rem 1.25rem; border-bottom: 1px solid #f1f3f5; cursor: pointer; transition: background 0.1s; }
.project-item:last-child { border-bottom: none; }
.project-item:hover { background: #f8f9fa; }
.project-info { flex: 1; min-width: 0; }
.project-title { font-weight: 500; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-url { font-size: 0.78rem; color: #868e96; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 0.1rem; }
.project-meta { text-align: right; flex-shrink: 0; margin-left: 1.5rem; }
.project-tokens { font-size: 0.73rem; color: #adb5bd; white-space: nowrap; }
.project-arrow { font-size: 0.8rem; color: #adb5bd; margin-left: 0.75rem; }

/* ===== СТАРТ ПРОЕКТА ===== */
.start-page { max-width: 800px; margin: 0 auto; }
.steps-container { padding: 2rem 1.5rem; }
.step-block { padding: 1.5rem; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1rem; background: #fff; }
.step-block h2 { margin-bottom: 0.25rem; }
.step-desc { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1rem; }
.step-block .form-group { margin: 0.75rem 0; }
.step-block button { width: auto; }
.step-block input[type="text"] { width: 100%; max-width: 500px; }

/* ===== ПАРСИНГ ===== */
.section-divider { border: none; border-top: 2px solid var(--accent); margin: 2rem 0; }
.loading { padding: 1rem; color: var(--accent); font-size: 0.95rem; }
.parsing-summary { background: var(--surface); padding: 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.parsing-summary strong { font-size: 1.1rem; }
.meta-badges { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 12px; font-size: 0.8rem; }
.badge-ok { background: #d4edda; color: #155724; }
.badge-warn { background: #fff3cd; color: #856404; }
.badge-row { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.badge-row .badge { font-size: 0.75rem; white-space: nowrap; }
.url-hint { font-size: 0.75rem; color: var(--text-secondary); word-break: break-all; }
.warn { color: var(--warning); font-size: 0.9rem; }

/* ===== КЛАССИФИКАТОР ===== */
.classifier-block { background: var(--surface); padding: 1rem; border-radius: var(--radius); margin: 1rem 0; }
.classifier-block h3 { margin-bottom: 0.5rem; font-size: 0.95rem; color: var(--text-secondary); }
.classifier-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.classifier-table td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.classifier-table td:first-child { color: var(--text-secondary); width: 35%; }

/* ===== RADIO-СПИСОК ===== */
.radio-list { display: flex; flex-direction: column; margin: 0.75rem 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.radio-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 1rem; cursor: pointer; font-size: 0.95rem; border-bottom: 1px solid var(--border); background: #fff; transition: background 0.15s; }
.radio-item:last-child { border-bottom: none; }
.radio-item:hover { background: #f8f9fa; }
.radio-item:has(input:checked) { background: #e8f0fe; }
.radio-item input[type="radio"] { flex-shrink: 0; width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

/* ===== ДЕБАГ ===== */
.debug-toggle { margin-top: 1rem; font-size: 0.8rem; color: var(--text-secondary); cursor: pointer; }
.debug-block { display: none; margin-top: 0.5rem; padding: 1rem; background: #f1f3f4; border-radius: 4px; font-size: 0.75rem; line-height: 1.6; font-family: 'SF Mono', 'Fira Code', monospace; white-space: pre-wrap; word-break: break-word; overflow-wrap: break-word; max-width: 100%; width: 100%; box-sizing: border-box; }
.debug-block.full-width { width: 100%; max-width: 100%; overflow-x: hidden; white-space: pre-wrap; font-size: 0.75rem; line-height: 1.6; padding: 1rem; }
.debug-block pre { white-space: pre-wrap; word-break: break-word; overflow-wrap: break-word; margin: 0; padding: 0; max-width: 100%; font-family: inherit; font-size: inherit; line-height: inherit; }

/* ===== ПРОГРЕСС-БАР ===== */
#progress-bar { margin: 1rem 0; }
.progress-track { width: 100%; height: 6px; background: #e9ecef; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 3px; transition: width 0.3s ease; }
.progress-text { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.3rem; }

/* ===== СПИННЕР ===== */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid #dee2e6; border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; margin-right: 6px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 1rem; color: var(--accent); font-size: 0.95rem; }

/* ===== ШАГ 3: СТРАТЕГИЯ ===== */
.strategy-card { background: #f0f7ff; border: 1px solid #b8d4f5; border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.5rem; }
.strategy-card h3 { margin-bottom: 0.5rem; font-size: 1.15rem; }
.strategy-reasoning { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 1rem; }
.strategy-details { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.detail-item { display: flex; justify-content: space-between; padding: 0.35rem 0; border-bottom: 1px dotted #dee2e6; font-size: 0.9rem; }
.detail-label { color: var(--text-secondary); }
.detail-value { font-weight: 500; }
.forecast-block { margin: 1.5rem 0; }
.forecast-block h3 { margin-bottom: 0.5rem; }
.alternatives-block { margin: 1.5rem 0; }
.alternatives-block h3 { margin-bottom: 0.5rem; }

/* ===== ШАГ 3: КЛЮЧИ ===== */
.selected-page-block { background: var(--surface); padding: 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.selected-page-block h3 { margin-bottom: 0.5rem; }
.page-text-preview { margin-top: 0.75rem; font-size: 0.8rem; }
.page-text-preview pre { white-space: pre-wrap; word-break: break-word; max-height: 200px; overflow-y: auto; background: #e9ecef; padding: 0.5rem; border-radius: 4px; font-family: inherit; font-size: 0.75rem; line-height: 1.5; }
.keywords-block { margin: 1.5rem 0; }
.keywords-block h3 { margin-bottom: 0.75rem; }
.kw-group { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 0.4rem; overflow: hidden; }
.kw-group-header { padding: 0.5rem 0.75rem; background: #f8f9fa; cursor: pointer; font-size: 0.9rem; font-weight: 500; user-select: none; }
.kw-group-header:before { content: '▸ '; font-size: 0.8rem; }
.kw-group.open .kw-group-header:before { content: '▾ '; }
.kw-group .kw-group-body { display: none; padding: 0.5rem 0.75rem; font-size: 0.85rem; }
.kw-group.open .kw-group-body { display: block; }
.kw-list { color: #495057; line-height: 1.7; }
.minus-words-block { margin: 1.5rem 0; }
.minus-words-block h3 { margin-bottom: 0.5rem; }
.debug-section { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed #dee2e6; }
.debug-section:last-child { border-bottom: none; }
.debug-section strong { display: block; margin-bottom: 0.4rem; font-size: 0.75rem; color: #868e96; text-transform: uppercase; letter-spacing: 0.5px; }
.debug-pre { white-space: pre-wrap; word-break: break-word; font-size: 0.7rem; line-height: 1.5; max-height: 400px; overflow-y: auto; background: #fff; padding: 0.5rem; border-radius: 3px; }

/* ===== МОДАЛЬНОЕ ОКНО ФРАЗ ===== */
.phrase-modal-overlay { position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.5); z-index:10000; display:flex; align-items:center; justify-content:center; }
.phrase-modal-box { background:#fff; border-radius:12px; max-width:95%; width:1050px; max-height:85vh; overflow:hidden; box-shadow:0 8px 30px rgba(0,0,0,0.2); }
.phrase-modal-header { display:flex; justify-content:space-between; align-items:center; padding:1rem 1.5rem; border-bottom:1px solid #dee2e6; background:#f8f9fa; }
.phrase-modal-header h3 { margin:0; font-size:1.1rem; }
.phrase-modal-body { padding:1rem 1.5rem; overflow-y:auto; max-height:calc(85vh - 70px); }
.link-underlined { text-decoration:underline; cursor:pointer; color:var(--accent); }
.phrase-table { width:100%; border-collapse:collapse; font-size:0.85rem; }
.phrase-table th { background:#f8f9fa; padding:0.5rem 0.75rem; text-align:left; font-weight:600; border-bottom:2px solid #dee2e6; position:sticky; top:0; }
.phrase-table td { padding:0.4rem 0.75rem; border-bottom:1px solid #e9ecef; }
.phrase-table tbody tr:hover { background:#f8f9fa; }
.phrase-table tfoot td { border-top:2px solid var(--accent); font-weight:600; background:#f0f7ff; }
/* ===== ШАГ 4: КРЕАТИВЫ ===== */
.step4-summary {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem 1rem;
    background: #f0f7ff;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    flex-wrap: wrap;
}

.verdict-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}
.verdict-достаточно { background: #d4edda; color: #155724; }
.verdict-недостаточно { background: #fff3cd; color: #856404; }
.verdict-критически\.мало,
.verdict-критически мало { background: #f8d7da; color: #721c24; }

/* Кластеры */
.clusters-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1rem 0;
}

.cluster-card {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.cluster-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    cursor: pointer;
    user-select: none;
    font-size: 0.9rem;
}
.cluster-card-header:hover { background: #e9ecef; }

.cluster-priority {
    display: inline-block;
    width: 28px; height: 28px; line-height: 28px;
    text-align: center; border-radius: 6px;
    color: #fff; font-weight: 600; font-size: 0.75rem;
    flex-shrink: 0;
}

.cluster-name { font-weight: 600; flex-shrink: 0; }
.cluster-stats { font-size: 0.75rem; color: #868e96; flex: 1; text-align: right; }

.cluster-card .cluster-card-body { display: none; padding: 0 1rem 0.75rem 1rem; }
.cluster-card.open .cluster-card-body { display: block; }

.cluster-theme { font-size: 0.9rem; color: #0052cc; padding: 0.5rem 0; border-bottom: 1px solid #e9ecef; margin-bottom: 0.5rem; }
.cluster-keywords { font-size: 0.8rem; color: #868e96; margin-bottom: 0.75rem; word-break: break-all; }

/* Переключатель [+]/[-] */
.toggle-icon { font-size: 0.8rem; color: #adb5bd; flex-shrink: 0; width: 30px; text-align: center; }
.toggle-icon::after { content: '[+]'; }
.open > .cluster-card-header .toggle-icon::after,
.open > .hypothesis-header .toggle-icon::after { content: '[-]'; }

/* Гипотезы */
.hypothesis-card {
    border: 1px solid #e9ecef;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    overflow: hidden;
    background: #f8f9fa;
}

.hypothesis-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.9rem;
}
.hypothesis-header:hover { background: #e9ecef; }

.hypothesis-segment { flex: 1; font-size: 0.8rem; color: #868e96; text-align: right; }

.hypothesis-card .hypothesis-body { display: none; padding: 0 0.75rem 0.75rem 0.75rem; }
.hypothesis-card.open .hypothesis-body { display: block; }

.hypothesis-value { font-size: 0.85rem; color: #495057; margin-bottom: 0.5rem; padding: 0.4rem 0; border-bottom: 1px solid #dee2e6; }

/* Креативы внутри гипотезы */
.creative-section { margin-bottom: 0.75rem; }
.creative-label { font-size: 0.75rem; font-weight: 600; color: #868e96; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.4rem; }
.creative-items { display: flex; flex-direction: column; gap: 0.3rem; }
.headline-item, .text-item { display: block; padding: 0.2rem 0; font-size: 0.9rem; }

.creative-actions { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }
.btn-secondary {
    padding: 0.4rem 0.8rem; background: #f8f9fa;
    border: 1px solid #dee2e6; border-radius: 6px;
    cursor: pointer; font-size: 0.8rem; color: #495057; width: auto;
}
.btn-secondary:hover { background: #e9ecef; }

/* Быстрые ссылки */
.quick-links-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.quick-link-item {
    display: inline-block; padding: 0.25rem 0.5rem;
    background: #e8f0fe; color: #0052cc;
    border-radius: 4px; font-size: 0.8rem; text-decoration: none;
}
.quick-link-item:hover { background: #d0e2ff; text-decoration: none; }
.goal-banner {
    background: #e8f0fe;
    border: 1px solid #b8d4f5;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}