/* ── Сброс и базовые стили ─────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --bg: #f5f6fa;
    --card-bg: #fff;
    --primary: #4c8bf5;
    --primary-hover: #3a70d4;
    --text: #2c3e50;
    --text-muted: #7f8c8d;
    --border: #e1e5eb;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}
.app { max-width: 1280px; margin: 0 auto; padding: 16px; }

/* ── Шапка ─────────────────────────────────────── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.header__title { font-size: 20px; font-weight: 700; }
.header__status { display: flex; gap: 12px; align-items: center; }

/* ── Бейджи ────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 600;
}
.badge--ok { background: #e8f5e9; color: var(--success); }
.badge--error { background: #fdecea; color: var(--danger); }
.badge--loading { background: #fff3e0; color: var(--warning); }

/* ── Кнопки ────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--card-bg);
    cursor: pointer; font-size: 14px; font-weight: 500;
    transition: all 0.15s;
}
.btn:hover { background: #f0f2f5; }
.btn--sm { padding: 4px 10px; font-size: 12px; }
.btn--primary {
    background: var(--primary); color: #fff; border-color: var(--primary);
}
.btn--primary:hover { background: var(--primary-hover); }

/* ── Инпуты ────────────────────────────────────── */
.input {
    padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 14px;
    background: var(--card-bg); color: var(--text);
    outline: none; transition: border-color 0.15s;
}
.input:focus { border-color: var(--primary); }
.input--sm { padding: 4px 8px; font-size: 13px; }

/* ── Фильтры ───────────────────────────────────── */
.filters {
    display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap;
    padding: 16px 24px; background: var(--card-bg);
    border-radius: var(--radius); box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.filters__group { display: flex; flex-direction: column; gap: 6px; }
.filters__group label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.filters__dates { display: flex; gap: 8px; align-items: center; }

/* ── Мультиселект пользователей ─────────────────── */
.users-select {
    display: flex; gap: 6px; flex-wrap: wrap;
    max-width: 500px;
}
.user-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 16px;
    border: 1px solid var(--border); font-size: 13px;
    cursor: pointer; transition: all 0.15s;
    user-select: none;
}
.user-chip:hover { border-color: var(--primary); }
.user-chip--active {
    background: var(--primary); color: #fff;
    border-color: var(--primary);
}

/* ── Табы ──────────────────────────────────────── */
.tabs {
    display: flex; gap: 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
}
.tab {
    padding: 10px 20px; border: none; background: none;
    cursor: pointer; font-size: 14px; font-weight: 600;
    color: var(--text-muted); border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab--active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Контент табов ─────────────────────────────── */
.tab-content { display: none; }
.tab-content--active { display: block; }
.content { display: flex; flex-direction: column; gap: 16px; }

/* ── Карточки ──────────────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
}
.card__title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.card__header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 16px;
}
.card__header .card__title { margin-bottom: 0; }
.card__controls { display: flex; gap: 8px; align-items: center; font-size: 13px; }

/* ── Графики ───────────────────────────────────── */
.chart-container { position: relative; height: 320px; width: 100%; }

/* ── Таблицы ───────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%; border-collapse: collapse;
    font-size: 13px;
}
.table th, .table td {
    padding: 10px 12px; text-align: left;
    border-bottom: 1px solid var(--border);
}
.table th {
    background: #f8f9fb; font-weight: 600;
    color: var(--text-muted); font-size: 12px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.table tr:hover td { background: #f8f9fb; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Конверсия ─────────────────────────────────── */
.conversion-stats {
    display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.stat-card {
    flex: 1; min-width: 120px; padding: 12px 16px;
    background: #f8f9fb; border-radius: var(--radius);
    text-align: center;
}
.stat-card__value { font-size: 24px; font-weight: 700; color: var(--primary); }
.stat-card__label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Загрузка ──────────────────────────────────── */
.loading-overlay {
    position: fixed; inset: 0; background: rgba(255,255,255,0.8);
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 12px; z-index: 999;
    font-size: 14px; color: var(--text-muted);
}
.spinner {
    width: 32px; height: 32px; border: 3px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.text-muted { color: var(--text-muted); font-size: 13px; }

/* ── Адаптив ───────────────────────────────────── */
@media (max-width: 768px) {
    .header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .filters { flex-direction: column; align-items: stretch; }
    .users-select { max-width: 100%; }
    .tabs { overflow-x: auto; }
    .tab { white-space: nowrap; }
}
