/* --- Специфичные стили для ипотечного калькулятора --- */
.calc-header { margin-bottom: 32px; }
.subtitle { color: var(--text-secondary); margin-top: 8px; }

/* Сетка */
.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 #E5E7EB; border-radius: 12px;
    outline: none; transition: border 0.2s, box-shadow 0.2s;
    font-family: var(--font-main);
}
.input-wrapper input:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

.currency, .suffix { position: absolute; right: 16px; color: var(--text-secondary); pointer-events: none; }
.helper-text { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
.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(0,0,0,0.04); }
@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; }

/* CSS 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); }
.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; }

/* --- МОДАЛЬНОЕ ОКНО --- */
.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: 24px; 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: 12px; 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: 24px; border-bottom-right-radius: 24px;
    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: 99px; font-weight: 600; cursor: pointer;
}
.btn--secondary:hover { background: #F9FAFB; border-color: #D1D5DB; }

@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: 12px; }
}

/* --- PRINT STYLES --- */
@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; }
    thead { display: table-header-group; } tfoot { display: table-footer-group; } tr { page-break-inside: avoid; }
    .modal-header { border-bottom: 2px solid #000 !important; padding-bottom: 10px !important; margin-bottom: 10px !important; display: block !important; text-align: center !important; }
    .modal-header h3 { font-size: 18pt !important; margin: 0 !important; }
    .modal-header button { display: none; }
    .schedule-summary {
        border: 1px solid #000 !important; background: none !important; margin-bottom: 15px !important;
        padding: 5px !important; display: flex !important; flex-direction: row !important;
        justify-content: space-around !important; gap: 10px !important;
    }
    .summary-card-small { margin: 0 !important; }
    .summary-card-small span { font-size: 8pt !important; color: #000 !important; }
    .summary-card-small strong { font-size: 10pt !important; color: #000 !important; }
}