/* --- Специфичные стили для ипотечного калькулятора --- */
.calc-header { margin-bottom: 32px; }
.subtitle { color: var(--text-secondary); margin-top: 8px; font-weight: 500; }

/* Сетка */
.calc-grid { display: grid; grid-template-columns: 1fr; gap: 24px; align-items: start; }
@media (min-width: 900px) { .calc-grid { grid-template-columns: 1.2fr 0.8fr; } }

/* Поля ввода */
.calc-inputs { gap: 24px; }
.input-group { margin-bottom: 24px; }
.input-group label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }
.input-wrapper { position: relative; display: flex; align-items: center; }

.input-wrapper input {
    width: 100%; padding: 16px; padding-right: 40px;
    font-size: 18px; font-weight: 500;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 14px;
    outline: none; transition: border 0.2s, box-shadow 0.2s;
    font-family: var(--font-main);
    background: #fff;
}
.input-wrapper input:focus { 
    border-color: var(--accent-blue); 
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1); 
}

.currency, .suffix { position: absolute; right: 16px; color: var(--text-secondary); pointer-events: none; }
.helper-text { font-size: 13px; color: var(--text-secondary); margin-top: 8px; }
.row-2-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Range Slider */
.range-slider {
    width: 100%; margin-top: 12px; -webkit-appearance: none; height: 6px;
    background: #E5E7EB; border-radius: 5px; outline: none; cursor: pointer;
}
.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent-blue); cursor: pointer; border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2); transition: transform 0.1s;
}
.range-slider::-webkit-slider-thumb:hover { transform: scale(1.1); }

/* Результаты */
.card--result { 
    background: #fff; 
    border: 1px solid rgba(255,255,255,0.5);
    box-shadow: var(--shadow-soft);
    border-radius: var(--radius-lg);
}
@media (min-width: 900px) { .sticky-card { position: sticky; top: 24px; } }

.card--result h2 { font-size: 16px; color: var(--text-secondary); font-weight: 500; margin-bottom: 8px; }
.payment-amount { font-size: 36px; font-weight: 800; color: var(--accent-blue); letter-spacing: -0.02em; margin-bottom: 24px; }

/* Donut Chart */
.chart-container {
    display: flex; align-items: center; gap: 24px; margin-bottom: 32px;
    padding: 20px; background: var(--bg-color); border-radius: 16px;
}
.donut-chart {
    width: 100px; height: 100px; border-radius: 50%;
    background: conic-gradient(var(--accent-blue) var(--percent, 0%), #E5E7EB 0);
    position: relative; flex-shrink: 0;
}
.chart-center {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 70%; height: 70%; background: var(--bg-color); border-radius: 50%;
}
.chart-legend { display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot--base { background-color: #E5E7EB; }
.dot--accent { background-color: var(--accent-blue); }

.summary-list { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }
.summary-item { display: flex; justify-content: space-between; font-size: 14px; }
.summary-divider { height: 1px; background: #E5E7EB; margin: 4px 0; }
.highlight-red { color: #EF4444; }
.btn--full { width: 100%; justify-content: center; }


/* --- НОВЫЕ ИНФОРМАЦИОННЫЕ БЛОКИ --- */

.info-wrapper {
    padding: 60px 0 0 0;
    margin-top: 60px;
    border-top: 1px solid rgba(0,0,0,0.06);
}

.info-wrapper .container {
    max-width: 800px;
    margin: 0 auto;
    /* Убрал padding: 0, чтобы наследовался дефолтный (0 20px) из style.css */
}

/* Заголовки с иконками */
.icon-heading {
    display: flex;
    align-items: flex-start; /* Чтобы текст не центрировался по высоте, если он длинный */
    gap: 16px;
    margin-bottom: 24px;
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.3;
}

.header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
    flex-shrink: 0; /* Чтобы иконка не сжималась */
    margin-top: -4px; /* Визуальная компенсация высоты строки */
}

.header-icon svg {
    width: 24px;
    height: 24px;
    stroke-width: 2px;
}

/* Цвета иконок */
.blue-icon svg { color: var(--accent-blue); }
.orange-icon svg { color: #F59E0B; }
.green-icon svg { color: #10B981; }
.red-icon svg { color: #EF4444; }

/* Маленькие подзаголовки */
.small-heading {
    margin-top: 40px;
    margin-bottom: 16px;
    font-size: 20px;
}
.small-heading .header-icon {
    width: 40px;
    height: 40px;
}
.small-heading .header-icon svg {
    width: 20px;
    height: 20px;
}

.intro-text {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.6;
}

/* --- Секция Формул --- */
.formulas-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 48px;
}

.formula-card {
    background: #fff;
    border: 1px solid rgba(0,0,0,0.04);
    box-shadow: var(--shadow-soft);
    border-radius: var(--radius-lg); 
    padding: 24px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
}
.formula-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.formula-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Чтобы бейдж не растягивал высоту */
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap; /* Позволяет перенос на очень узких экранах */
}

.formula-card h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.badge {
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fff;
    order: 2; /* Бейдж всегда справа или внизу */
}
.badge--blue { background: var(--gradient-blue); }
.badge--mint { background: var(--gradient-mint); color: #064E3B; }

.formula-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
    font-weight: 500;
}

.math-expression {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 700;
    color: var(--accent-blue);
    text-align: center;
    margin-bottom: 16px;
    font-size: 15px;
}

/* Разделитель */
.soft-divider {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, #E5E7EB, transparent);
    margin: 48px 0;
}

/* Описание */
.calc-description p {
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 24px;
}
.calc-description strong { color: var(--text-primary); }

/* FAQ */
.faq-mortgage-style .faq-item { margin-bottom: 12px; }
.faq-mortgage-style .faq-item[open] { border-color: var(--accent-blue); box-shadow: 0 4px 20px rgba(37, 99, 235, 0.08); }
.faq-mortgage-style .faq-item[open] summary { color: var(--accent-blue); background: #F3F8FF; }
.faq-question .icon-plus { display: none; }

/* --- МОДАЛЬНОЕ ОКНО --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(17, 24, 39, 0.6); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; visibility: hidden; transition: all 0.3s ease;
}
.modal-overlay.is-open { opacity: 1; visibility: visible; }
.modal-window {
    background: #fff; width: 100%; max-width: 800px; max-height: 90vh;
    border-radius: var(--radius-lg); box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    display: flex; flex-direction: column;
    transform: translateY(20px); transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.modal-overlay.is-open .modal-window { transform: translateY(0); }
.modal-header { padding: 24px; border-bottom: 1px solid #E5E7EB; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.modal-header h3 { font-size: 20px; font-weight: 700; margin: 0; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-secondary); padding: 4px; border-radius: 8px; transition: background 0.2s; display: flex; }
.modal-close:hover { background: #F3F4F6; color: var(--text-primary); }
.modal-body { padding: 24px; overflow-y: hidden; display: flex; flex-direction: column; flex-grow: 1; min-height: 0; }
.schedule-summary { display: flex; gap: 20px; margin-bottom: 24px; flex-shrink: 0; background: #F9FAFB; padding: 16px; border-radius: 14px; flex-wrap: wrap; }
.summary-card-small span { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.summary-card-small strong { font-size: 18px; color: var(--text-primary); white-space: nowrap; }
.table-container { border: 1px solid #E5E7EB; border-radius: 12px; overflow: auto; flex-grow: 1; position: relative; -webkit-overflow-scrolling: touch; }
.schedule-table { width: 100%; border-collapse: collapse; font-size: 14px; text-align: left; min-width: 600px; }
.schedule-table th { background: #F9FAFB; padding: 12px 16px; font-weight: 600; color: var(--text-secondary); border-bottom: 1px solid #E5E7EB; position: sticky; top: 0; z-index: 10; }
.schedule-table td { padding: 12px 16px; border-bottom: 1px solid #F3F4F6; color: var(--text-primary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.schedule-table tr:last-child td { border-bottom: none; }
.modal-footer { padding: 20px 24px; border-top: 1px solid #E5E7EB; background: #fff; border-bottom-left-radius: var(--radius-lg); border-bottom-right-radius: var(--radius-lg); display: flex; justify-content: flex-end; flex-shrink: 0; }
.btn--secondary { background: #fff; border: 1px solid #E5E7EB; color: var(--text-primary); display: flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: var(--radius-pill); font-weight: 600; cursor: pointer; }
.btn--secondary:hover { background: #F9FAFB; border-color: #D1D5DB; }

/* --- МОБИЛЬНАЯ АДАПТАЦИЯ (ФИНАЛЬНЫЕ ПРАВКИ) --- */
@media (max-width: 768px) {
    /* Формулы в 1 колонку */
    .formulas-grid { grid-template-columns: 1fr; gap: 16px; margin-bottom: 32px; }
    
    /* Уменьшаем отступы и шрифты */
    .icon-heading { font-size: 20px; gap: 12px; margin-bottom: 20px; }
    .header-icon { width: 40px; height: 40px; border-radius: 12px; }
    .header-icon svg { width: 20px; height: 20px; }
    
    .formula-card { padding: 20px; }
    
    /* Улучшаем перенос в хедере карточки */
    .formula-header { flex-wrap: wrap; gap: 8px; }
    .badge { margin-left: auto; order: 2; } /* Бейдж прижимается вправо */
    
    .info-wrapper { margin-top: 40px; padding-top: 40px; }
}

@media (max-width: 600px) {
    .modal-window { max-height: 100vh; height: 100%; border-radius: 0; }
    .modal-footer { border-radius: 0; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
    .schedule-table th, .schedule-table td { padding: 10px 8px; font-size: 13px; }
}

@media print {
    @page { size: A4 landscape; margin: 5mm; }
    body * { visibility: hidden; height: 0; overflow: hidden; }
    .modal-overlay, .modal-overlay * { visibility: visible; height: auto; overflow: visible; }
    .modal-overlay { position: absolute !important; left: 0 !important; top: 0 !important; width: 100% !important; background: white !important; display: block !important; z-index: 9999; padding: 0 !important; margin: 0 !important; }
    .modal-window { box-shadow: none !important; border: none !important; width: 100% !important; max-width: 100% !important; margin: 0 !important; transform: none !important; }
    .modal-close, .modal-footer, .header, .back-link, .btn { display: none !important; }
    .modal-body { padding: 0 !important; display: block !important; }
    .table-container { border: none !important; overflow: visible !important; display: block !important; }
    .schedule-table { width: 100% !important; min-width: 0 !important; font-size: 9pt !important; border-collapse: collapse !important; }
    .schedule-table th, .schedule-table td { border: 1px solid #000 !important; color: #000 !important; padding: 4px 2px !important; white-space: normal !important; word-wrap: break-word !important; }
    .schedule-table th { background-color: #eee !important; font-weight: bold !important; font-size: 8pt !important; }
}
