/* Портфель-билдер - базовая структура */
.portfolio-builder {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Заголовок */
.builder-header {
    margin-bottom: 30px;
}

.page-title {
    font-size: 28px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-title i {
    color: #4a6cf7;
}

.page-subtitle {
    font-size: 16px;
    color: #666;
    line-height: 1.5;
}

/* ========== НОВАЯ СТРУКТУРА ФИЛЬТРОВ ========== */
.filters-panel-top {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.filters-title {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.filters-title i {
    color: #4a6cf7;
}

.filters-actions {
    display: flex;
    gap: 12px;
}

/* Сетка фильтров */
.filters-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.filter-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.filter-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
}

.filter-card h4 {
    font-size: 16px;
    font-weight: 600;
    color: #495057;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-card h4 i {
    color: #6c757d;
}

/* ========== РЕЗУЛЬТАТЫ ========== */
.results-panel-full {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* ========== КОМПОНЕНТЫ ФОРМ ========== */

/* Общие стили для групп формы */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #6b7280;
}

.form-hint i {
    margin-right: 4px;
}

/* Поля ввода */
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    background: #f9fafb;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #4a6cf7;
    box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.1);
    background: #ffffff;
}

.form-control.half {
    width: calc(50% - 5px);
}

.range-inputs {
    display: flex;
    gap: 10px;
}

/* Селекты */
.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    background: #f9fafb url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E") no-repeat right 12px center;
    background-size: 12px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: #4a6cf7;
    box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.1);
    background-color: #ffffff;
}

/* Ползунки */
.range-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.form-range {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    outline: none;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #4a6cf7;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.form-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #4a6cf7;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.range-value {
    min-width: 40px;
    font-weight: 600;
    color: #4a6cf7;
    font-size: 14px;
}

/* Чекбоксы */
.checkbox-group,
.checkbox-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked {
    background-color: #4a6cf7;
    border-color: #4a6cf7;
}

/* Кнопки */
.btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: #4a6cf7;
    color: white;
}

.btn-primary:hover {
    background: #3a56d4;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 108, 247, 0.3);
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* ========== СВОДКА ПОРТФЕЛЯ ========== */
.portfolio-summary {
    background: linear-gradient(135deg, #4a6cf7 0%, #3a56d4 100%);
    color: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
}

.portfolio-summary h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 15px;
}

.summary-item {
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.summary-label {
    font-size: 12px;
    opacity: 0.9;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-value {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    line-height: 1;
}

.text-positive {
    color: #10b981 !important;
}

.text-warning {
    color: #f59e0b !important;
}

.date-hint {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 4px;
}

/* ========== ТАБЛИЦА ПОРТФЕЛЯ ========== */
.portfolio-details {
    margin-top: 30px;
}

.portfolio-details h4 {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.emitter-section {
    margin: 25px 0;
    padding: 20px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #f9fafb;
}

.emitter-header {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.emitter-header h5 {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.emitter-amount {
    color: #4a6cf7;
    font-weight: 600;
    font-size: 18px;
}

/* Таблица */
.emitter-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.portfolio-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    min-width: 1200px;
}

.portfolio-table th {
    background: #f3f4f6;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}

.portfolio-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 13px;
    color: #4b5563;
    vertical-align: middle;
}

.portfolio-table tr:hover {
    background: #f8fafc;
}

/* Компактные ячейки */
.bond-cell {
    min-width: 200px;
}

.currency-cell,
.coupon-cell {
    width: 80px;
    text-align: center;
}

.bond-link {
    color: #4a6cf7;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    display: block;
}

.bond-link:hover {
    text-decoration: underline;
}

.bond-name {
    font-size: 11px;
    color: #6b7280;
    margin-top: 4px;
    line-height: 1.3;
}

/* Бейджи */
.rating-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    min-width: 45px;
    text-align: center;
}

.rating-aaa { background: #10b981; color: white; }
.rating-aa { background: #3b82f6; color: white; }
.rating-a { background: #8b5cf6; color: white; }
.rating-bbb { background: #06b6d4; color: white; }
.rating-bb { background: #f59e0b; color: #1f2937; }
.rating-b { background: #ef4444; color: white; }
.rating-default { background: #6b7280; color: white; }

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-secondary {
    background: #f3f4f6;
    color: #374151;
}

/* Валютные бейджи */
.currency-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    display: inline-block;
    min-width: 40px;
    text-align: center;
}

.currency-sur { background: #4CAF50; color: white; }
.currency-usd { background: #2196F3; color: white; }
.currency-eur { background: #FF9800; color: white; }
.currency-cny { background: #f44336; color: white; }

/* Период купона */
.coupon-period {
    font-size: 11px;
    padding: 3px 8px;
    background: #e3f2fd;
    border-radius: 4px;
    color: #1565c0;
    display: inline-block;
}

.offer-days {
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
}

.price-with-nkd {
    font-weight: 600;
}

/* Иконки */
.fa-coins {
    margin-right: 5px;
    color: #f59e0b;
}

/* ========== ПУСТОЕ СОСТОЯНИЕ ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 64px;
    color: #d1d5db;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 24px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 12px;
}

.empty-state p {
    color: #6b7280;
    max-width: 500px;
    margin: 0 auto 30px;
    line-height: 1.6;
}

.features-grid {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 40px;
}

.feature-item {
    text-align: center;
    padding: 20px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    min-width: 140px;
    background: #ffffff;
}

.feature-value {
    font-size: 28px;
    font-weight: 700;
    color: #4a6cf7;
    line-height: 1;
    margin-bottom: 8px;
}

.feature-label {
    font-size: 14px;
    color: #6b7280;
}

/* ========== АЛЕРТЫ ========== */
.alert {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert-error {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.alert i {
    font-size: 18px;
    flex-shrink: 0;
}

/* ========== СТРАТЕГИЯ ========== */
.strategy-explanation {
    background: #e7f3ff;
    border-left: 4px solid #4a6cf7;
    padding: 16px 20px;
    margin: 20px 0;
    border-radius: 0 8px 8px 0;
}

.strategy-explanation h5 {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.strategy-explanation p {
    margin: 0;
    color: #374151;
    line-height: 1.5;
    font-size: 14px;
}

/* ========== МОБИЛЬНАЯ АДАПТАЦИЯ ========== */

/* Планшеты (768px - 1024px) */
@media (max-width: 1200px) {
    .filters-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Большие телефоны (576px - 768px) */
@media (max-width: 768px) {
    .portfolio-builder {
        padding: 16px;
    }
    
    .page-title {
        font-size: 24px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .filters-panel-top {
        padding: 20px;
    }
    
    .filters-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .filters-actions {
        flex-direction: column;
    }
    
    .filters-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .filter-column {
        gap: 20px;
    }
    
    .results-panel-full {
        padding: 20px;
    }
    
    .portfolio-summary {
        padding: 20px;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .summary-item {
        padding: 12px;
    }
    
    .summary-value {
        font-size: 20px;
    }
    
    .emitter-section {
        padding: 16px;
        margin: 20px 0;
    }
    
    .emitter-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .emitter-header h5 {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .portfolio-table th,
    .portfolio-table td {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .empty-state {
        padding: 40px 16px;
    }
    
    .empty-icon {
        font-size: 48px;
    }
    
    .features-grid {
        gap: 12px;
    }
    
    .feature-item {
        min-width: 120px;
        padding: 16px;
    }
    
    .feature-value {
        font-size: 24px;
    }
}

/* Маленькие телефоны (до 576px) */
@media (max-width: 576px) {
    .portfolio-builder {
        padding: 12px;
    }
    
    .page-title {
        font-size: 20px;
    }
    
    .page-subtitle {
        font-size: 14px;
    }
    
    .filters-panel-top {
        padding: 16px;
    }
    
    .filter-card {
        padding: 16px;
    }
    
    .checkbox-grid {
        grid-template-columns: 1fr;
    }
    
    .range-inputs {
        flex-direction: column;
        gap: 8px;
    }
    
    .form-control.half {
        width: 100%;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .results-panel-full {
        padding: 16px;
    }
    
    .portfolio-summary h3,
    .portfolio-details h4 {
        font-size: 18px;
    }
    
    .strategy-explanation {
        padding: 12px 16px;
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .feature-item {
        min-width: auto;
        padding: 12px;
    }
    
    .feature-value {
        font-size: 20px;
    }
    
    .feature-label {
        font-size: 12px;
    }
    
    /* Улучшаем отображение таблицы на маленьких экранах */
    .portfolio-table {
        min-width: 1000px;
    }
    
    .portfolio-table th,
    .portfolio-table td {
        padding: 8px 10px;
        font-size: 11px;
    }
    
    .bond-cell {
        min-width: 150px;
    }
    
    .currency-cell,
    .coupon-cell {
        width: 60px;
    }
}

/* Очень маленькие экраны (до 360px) */
@media (max-width: 360px) {
    .portfolio-builder {
        padding: 10px;
    }
    
    .page-title {
        font-size: 18px;
    }
    
    .filters-panel-top,
    .results-panel-full {
        padding: 12px;
        border-radius: 8px;
    }
    
    .filter-card {
        padding: 12px;
    }
    
    .summary-value {
        font-size: 18px;
    }
    
    .emitter-section {
        padding: 12px;
    }
    
    .empty-state h3 {
        font-size: 20px;
    }
    
    .empty-state p {
        font-size: 14px;
    }
}

/* Стиль для поля суммы в портфель-билдере */
.filters-panel-top input[name="investmentAmount"],
.filter-card input[name="investmentAmount"] {
    max-width: 180px;
    width: auto;
    display: block;
}

/* На мобильных - полная ширина */
@media (max-width: 768px) {
    .filters-panel-top input[name="investmentAmount"],
    .filter-card input[name="investmentAmount"] {
        max-width: 100%;
        width: 100%;
    }
}

/* Фикс для поля дней до оферты */
input[name="minAmortizationDays"] {
    max-width: 180px;
    width: 100%;
}

/* На мобильных - полная ширина */
@media (max-width: 768px) {
    input[name="minAmortizationDays"] {
        max-width: 100%;
    }
}

/* Общий стиль для всех числовых полей ввода (опционально) */
input[type="number"].form-control {
    max-width: 180px;
}

@media (max-width: 768px) {
    input[type="number"].form-control {
        max-width: 100%;
    }
}