* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
    margin-bottom: 20px;
}

.nav-menu {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.nav-link {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: white;
}

.nav-link.active {
    background: white;
    color: #667eea;
}

.nav-link.logout-link {
    background: rgba(220, 53, 69, 0.8);
    margin-left: auto;
}

.nav-link.logout-link:hover {
    background: rgba(220, 53, 69, 1);
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1em;
}

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

/* Панель фильтров */
.filters-panel {
    background: #f8f9fa;
    padding: 30px;
    border-bottom: 2px solid #e9ecef;
}

.filter-title {
    margin-bottom: 15px;
    color: #495057;
    font-size: 1.5em;
}

.help-text {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    font-size: 0.9em;
    line-height: 1.8;
}

.help-text strong {
    color: #856404;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group.highlight-group {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.filter-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #495057;
    font-size: 0.9em;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.filter-icon {
    font-size: 1.2em;
    margin-right: 5px;
}

.hint {
    color: #6c757d;
    font-size: 0.8em;
    font-style: italic;
    margin-top: 4px;
}

.filter-group select,
.filter-group input {
    padding: 10px 15px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
    background: white;
}

.important-select {
    font-weight: 600;
    border-color: #667eea !important;
    background: #f8f9ff !important;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.multiselect {
    min-height: 45px;
}

select[multiple] {
    min-height: 100px;
}

select[multiple] option {
    padding: 5px;
}

select[multiple] option:checked {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Активные фильтры */
.active-filters {
    margin-top: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.filter-tag {
    display: inline-block;
    background: #e7f3ff;
    color: #0056b3;
    padding: 5px 12px;
    margin: 5px 5px 5px 0;
    border-radius: 15px;
    font-size: 0.85em;
    border: 1px solid #b8daff;
}

.filter-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Кнопки */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-decoration: none !important;
}

a.btn {
    text-decoration: none !important;
}

a.btn:hover {
    text-decoration: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-2px);
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
    transform: translateY(-2px);
}

/* Сводные карточки */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 30px;
    background: #f8f9fa;
}

.card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.card h3 {
    font-size: 0.9em;
    color: #6c757d;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.amount {
    font-size: 2em;
    font-weight: 700;
    margin: 0;
}

.amount.positive {
    color: #28a745;
}

.amount.negative {
    color: #dc3545;
}

/* График */
.chart-container {
    padding: 30px;
    background: white;
}

#reportChart {
    max-height: 400px;
}

/* Таблица */
.table-container {
    padding: 30px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 14px;
}

thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

thead th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

tbody tr {
    border-bottom: 1px solid #dee2e6;
    transition: background-color 0.2s;
}

tbody tr:hover {
    background-color: #f8f9fa;
}

tbody td {
    padding: 12px 15px;
    text-align: center;
}

tbody td:first-child {
    text-align: left;
    font-weight: 500;
}

.group-name {
    color: #495057;
}

td.positive {
    color: #28a745;
}

td.negative {
    color: #dc3545;
}

td.total {
    background-color: #f8f9fa;
    font-weight: 700;
}

tfoot {
    background: #e9ecef;
    font-weight: 700;
}

tfoot td {
    padding: 15px;
}

.total-row td {
    border-top: 3px solid #495057;
}

/* Адаптивность */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    .filters-grid {
        grid-template-columns: 1fr;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
    }
    
    .filter-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    table {
        font-size: 12px;
    }
    
    thead th,
    tbody td,
    tfoot td {
        padding: 8px;
    }
    
    .amount {
        font-size: 1.5em;
    }
}

/* Прелоадер */
.loading {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.loading.active {
    display: flex;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Стили для печати */
@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .filters-panel,
    .filter-actions,
    .chart-container {
        display: none;
    }
    
    .container {
        box-shadow: none;
    }
    
    table {
        page-break-inside: auto;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
}

/* Детальный отчет - табличные стили */
.period-cell {
    background: #e7f3ff;
    font-weight: 700;
    vertical-align: top;
    border-right: 3px solid #667eea;
}

.category-cell {
    background: #f8f9fa;
    font-weight: 600;
    vertical-align: top;
    padding-left: 15px !important;
    border-right: 2px solid #dee2e6;
}

.subcategory-cell {
    padding-left: 30px !important;
    color: #6c757d;
}

.amount-cell {
    text-align: center !important;
    font-weight: 600;
}

.period-total-row {
    background: #e9ecef;
    font-weight: 700;
    border-top: 2px solid #495057;
}

.grand-total-row {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 700;
    font-size: 1.1em;
}

.grand-total-row td {
    padding: 15px !important;
}

.company-selector {
    background: white;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Кликабельные строки */
.clickable-row {
    transition: background-color 0.2s;
}

.clickable-row:hover {
    background: #e7f3ff !important;
    cursor: pointer;
}


/* Центрирование заголовков таблиц */
thead th {
    text-align: center !important;
}

/* Улучшенные кнопки экспорта */
.btn-success, .btn-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ГЛОБАЛЬНОЕ ЦЕНТРИРОВАНИЕ ЗАГОЛОВКОВ ТАБЛИЦ */
table thead th,
table thead td {
    text-align: center !important;
    vertical-align: middle !important;
}

/* Исключения для первого столбца если нужно */
table thead th:first-child {
    text-align: left !important;
}
