/* ============ СТАТИСТИКА PRO ============ */

/* Основной контейнер (полноэкранный) */
.stats-app {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10002;
    background: #f5f7fa;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Шапка */
.stats-header {
    padding: 16px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 12px;
}
.stats-header h2 {
    margin: 0;
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.stats-header .close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.stats-header .close-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Панель управления (даты, пресеты, тип услуг) */
.stats-controls {
    padding: 12px 24px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
}
.stats-controls .preset-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.stats-controls .preset-btn {
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.stats-controls .preset-btn:hover {
    background: #f0f0f0;
}
.stats-controls .preset-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}
.stats-controls .date-picker {
    display: flex;
    gap: 8px;
    align-items: center;
}
.stats-controls .date-picker input[type="date"] {
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #ddd;
    font-size: 13px;
}
.stats-controls .date-picker .apply-btn {
    padding: 6px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.stats-controls .service-type-select {
    margin-left: auto;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #ddd;
    font-size: 13px;
}

/* Вкладки */
.stats-tabs {
    display: flex;
    gap: 4px;
    padding: 0 24px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    overflow-x: auto;
}
.stats-tabs .stat-tab {
    background: none;
    border: none;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}
.stats-tabs .stat-tab:hover {
    color: #667eea;
}
.stats-tabs .stat-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

/* Контентная область */
.stats-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #f5f7fa;
}

/* Метрики (карточки) */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.metric-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.metric-card .metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #888;
}
.metric-card .metric-value {
    font-size: 28px;
    font-weight: 700;
    margin-top: 8px;
}

/* Графики */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}
.chart-container {
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.chart-container h4 {
    margin-top: 0;
    margin-bottom: 12px;
}
.chart-container canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 250px;
}

/* Таблицы */
/* Таблицы */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 16px;
}
.table-container table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}
.table-container th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}
.table-container td {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
}
.table-container .total-row {
    font-size: 18px;
    font-weight: 700;
    text-align: right;
    padding: 16px 12px;
}
.mb-16 { margin-bottom: 16px; }

.stats-controls-hidden {
    display: none !important;
}

/* Пагинация внутри статистики */
.stats-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}
.stats-pagination button {
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
}
.stats-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.stats-pagination .page-info {
    padding: 6px 12px;
    color: #555;
}

/* Прогноз */
.forecast-box {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 24px;
    text-align: center;
}
.forecast-box .label {
    font-size: 14px;
    opacity: 0.9;
}
.forecast-box .value {
    font-size: 36px;
    font-weight: 700;
}
.forecast-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
@media (max-width: 768px) {
    .forecast-grid {
        grid-template-columns: 1fr;
    }
}
.forecast-card {
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.forecast-card h4 {
    margin-top: 0;
    margin-bottom: 12px;
}
.forecast-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}
.forecast-item:last-child {
    border-bottom: none;
}

/* Топ-клиенты */
.top-clients-list .client-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}
.top-clients-list .client-item:last-child {
    border-bottom: none;
}

/* Общие утилиты */
.text-muted {
    color: #999;
}
.text-center {
    text-align: center;
}
.mt-16 {
    margin-top: 16px;
}
.mb-16 {
    margin-bottom: 16px;
}

/* Адаптивность для маленьких экранов */
@media (max-width: 600px) {
    .stats-header {
        padding: 12px 16px;
    }
    .stats-header h2 {
        font-size: 16px;
    }
    .stats-controls {
        padding: 8px 16px;
        align-items: stretch;
        font-size: 9px;
    }
    .stats-controls .preset-group {
        justify-content: center;
        font-size: 9px;
    }
    .stats-controls .date-picker {
        justify-content: center;
        font-size: 9px;
    }
    .stats-controls .preset-btn {
        font-size: 9px;
        padding: 6px 10px;
    }
    .stats-controls .date-picker input[type="date"] {
       font-size: 9px; 
    }
    .stats-controls .date-picker .apply-btn {
       font-size: 9px;  
    }

    .stats-tabs {
        padding: 0 12px;
    }
    .stats-tabs .stat-tab {
        padding: 8px 10px;
        font-size: 11px;
    }
    .stats-content {
        padding: 16px;
    }
    .metrics-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    .metric-card .metric-value {
        font-size: 22px;
    }
    .chart-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .forecast-grid {
        grid-template-columns: 1fr;
    }
}
