* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

body {
    background-color: #f0f2f5;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

h1 {
    color: #1a2634;
    margin-bottom: 25px;
    font-size: 28px;
    text-align: center;
}

h2 {
    color: #2c3e50;
    font-size: 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card {
    background: white;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid #e9ecef;
}

/* Статус бар */
.status-bar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px;
    padding: 15px 25px;
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.auto-save {
    font-size: 14px;
    opacity: 0.9;
    animation: pulse 1.5s infinite;
}

.auto-save.hidden {
    display: none;
}

@keyframes pulse {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 0.5; }
}

/* Две колонки */
.two-columns {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 25px;
    margin-bottom: 25px;
}

.left-column, .right-column {
    min-width: 0;
}

/* Кнопки */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    background-color: #f1f3f5;
    color: #2c3e50;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    background-color: #e9ecef;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.btn-success {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
}

.btn-small {
    padding: 4px 8px;
    font-size: 12px;
}

/* Формы */
.form-input {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
    background: white;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-input.money-input {
    text-align: right;
    font-weight: 500;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.input-group label {
    font-weight: 500;
    color: #2c3e50;
    min-width: 100px;
}

/* Период */
.period-inputs {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    flex-wrap: wrap;
}

/* Статьи расходов */
.expenses-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.expenses-summary {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    gap: 30px;
    font-weight: 500;
}

.expenses-list {
    max-height: 600px;
    overflow-y: auto;
    padding-right: 10px;
}

/* Группы и статьи */
.expense-group {
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background-color: #f8f9fa;
    border-bottom: 2px solid;
    cursor: pointer;
}

.group-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.group-toggle {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.group-color-indicator {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.group-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.group-name-input {
    font-size: 14px;
    font-weight: 600;
    padding: 4px 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: white;
}

.group-stats {
    color: #666;
    font-size: 13px;
}

.group-header-right {
    display: flex;
    gap: 5px;
}

.expense-item {
    padding: 12px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #667eea;
}

/* РИДы */
.rids-container {
    max-height: 800px;
    overflow-y: auto;
    padding-right: 10px;
}

.rid-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #dee2e6;
}

.rid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.rid-name-input {
    font-size: 16px;
    font-weight: 600;
    padding: 5px 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    width: 300px;
}

.rid-total {
    font-size: 18px;
    font-weight: 600;
    color: #27ae60;
}

/* Интервалы */
.intervals-section {
    margin-top: 15px;
}

.intervals-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 600;
}

.interval-item {
    background: white;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid #dee2e6;
}

.interval-dates {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.interval-expenses-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px;
    background: #f1f3f5;
    border-radius: 4px;
}

.interval-actions {
    display: flex;
    gap: 10px;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 25px;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 2px solid #f1f3f5;
    margin-bottom: 20px;
}

.modal-header h3 {
    color: #2c3e50;
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
}

.modal-close:hover {
    color: #dc3545;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
}

.expenses-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.expense-checkbox-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

.expense-checkbox-item input[type="checkbox"] {
    margin-right: 15px;
    width: 20px;
    height: 20px;
}

.expense-checkbox-info {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.expense-checkbox-code {
    font-weight: 600;
    min-width: 80px;
}

.expense-checkbox-group {
    font-size: 11px;
    color: #6c757d;
}

.expense-checkbox-amount {
    font-weight: 600;
    color: #27ae60;
    margin-left: auto;
}

.modal-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #f1f3f5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-summary {
    display: flex;
    gap: 20px;
    font-weight: 500;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

/* Сводка - ИСПРАВЛЕННЫЙ БЛОК */
.summary-block {
    background: white;
    overflow-x: auto;
    width: 100%;
}

.summary-content {
    width: 100%;
    overflow-x: auto;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    min-width: 800px; /* Минимальная ширина для таблицы */
}

.summary-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    padding: 12px 15px;
    text-align: left;
    border-right: 1px solid rgba(255,255,255,0.2);
    white-space: nowrap;
}

.summary-table th:last-child {
    border-right: none;
}

.summary-table td {
    padding: 10px 15px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
}

.summary-table tbody tr:hover {
    background-color: #f8f9fa;
}

.summary-table .expense-code {
    font-weight: 600;
    color: #667eea;
    font-size: 12px;
    white-space: nowrap;
}

.summary-table .expense-name {
    font-weight: 500;
    color: #2c3e50;
}

.summary-table .expense-total {
    font-weight: 600;
    color: #2c3e50;
    background-color: #f1f3f5;
}

.summary-table .rid-total-row {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    font-weight: 600;
}

.summary-table .rid-total-row td {
    padding: 12px 15px;
    border-top: 2px solid #dee2e6;
}

.summary-table .amount {
    text-align: right;
    font-family: monospace;
    font-weight: 500;
    white-space: nowrap;
}

.summary-table .amount.positive {
    color: #27ae60;
}

.summary-table .amount.zero {
    color: #6c757d;
    opacity: 0.7;
}

.summary-table .percentage {
    font-size: 11px;
    color: #6c757d;
    display: block;
    text-align: right;
}

.summary-wrapper {
    overflow-x: auto;
    margin-top: 15px;
    border-radius: 8px;
    width: 100%;
}

/* Группы в сводке */
.summary-groups {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.summary-group-item {
    padding: 10px;
    border-left: 3px solid;
    border-radius: 4px;
    background: #f8f9fa;
}

.summary-group-name {
    font-weight: 600;
    margin-bottom: 5px;
}

.summary-group-amount {
    font-size: 16px;
    font-weight: 500;
}

.summary-group-stats {
    font-size: 12px;
    color: #666;
}

/* Вспомогательные классы */
.text-muted {
    color: #6c757d;
    font-size: 13px;
}

.warning {
    background: #fff3cd;
    color: #856404;
    padding: 12px;
    border-radius: 6px;
    margin: 10px 0;
    border: 1px solid #ffeeba;
}

/* Скроллбар */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f3f5;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Адаптивность */
@media (max-width: 1200px) {
    .two-columns {
        grid-template-columns: 1fr;
    }
}