/* Общие карточки статистики (склад, баланс, статистика) */

.dash-stats {
    display: grid;
    grid-template-columns: repeat(var(--dash-cols, 4), minmax(0, 1fr));
    gap: 14px;
    width: 100%;
    margin-bottom: 24px;
}

.dash-stats--3 {
    --dash-cols: 3;
}

.dash-stats--5 {
    --dash-cols: 5;
}

.dash-stats--6 {
    --dash-cols: 6;
}

.dash-stat-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 92px;
    padding: 18px 20px;
    overflow: hidden;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.02) 55%, transparent 100%),
        var(--glass-bg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.14);
    backdrop-filter: blur(14px);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.dash-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.12);
}

.dash-stat-card__icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.dash-stat-card__body {
    min-width: 0;
    flex: 1;
}

.dash-stat-card__value {
    font-family: var(--font-head);
    font-size: clamp(1.2rem, 1.8vw, 1.75rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-stat-card__label {
    margin-top: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    line-height: 1.3;
}

.dash-stat-card__sub {
    margin-top: 4px;
    font-size: 0.76rem;
    color: var(--text-muted);
    opacity: 0.85;
    line-height: 1.3;
}

/* Variants — цвет иконок */
.dash-stat-card--violet .dash-stat-card__icon { color: #a78bfa; background: rgba(99, 102, 241, 0.16); }
.dash-stat-card--green .dash-stat-card__icon { color: #34d399; background: rgba(16, 185, 129, 0.14); }
.dash-stat-card--blue .dash-stat-card__icon { color: #38bdf8; background: rgba(14, 165, 233, 0.14); }
.dash-stat-card--amber .dash-stat-card__icon { color: #fbbf24; background: rgba(245, 158, 11, 0.14); }
.dash-stat-card--red .dash-stat-card__icon { color: #f87171; background: rgba(239, 68, 68, 0.14); }
.dash-stat-card--indigo .dash-stat-card__icon { color: #818cf8; background: rgba(79, 70, 229, 0.14); }
.dash-stat-card--pink .dash-stat-card__icon { color: #f472b6; background: rgba(219, 39, 119, 0.14); }
.dash-stat-card--teal .dash-stat-card__icon { color: #2dd4bf; background: rgba(13, 148, 136, 0.14); }

.dash-stat-card__value.is-cash,
.dash-stat-card__value.is-income { color: var(--success); }

.dash-stat-card__value.is-noncash { color: var(--primary); }

.dash-stat-card__value.is-expense { color: var(--danger); }

body:not(.dark-theme) .dash-stat-card {
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.9) 100%);
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.08);
}

@media (max-width: 1200px) {
    .dash-stats--6 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 1100px) {
    .dash-stats:not(.dash-stats--6) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .dash-stats--3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .dash-stats,
    .dash-stats--6 {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .dash-stat-card {
        min-height: 76px;
        padding: 14px 16px;
    }

    .dash-stat-card__icon {
        width: 42px;
        height: 42px;
    }
}

/* ── Мобильные сворачиваемые блоки статистики ── */
.section-stats-panel {
    margin-bottom: 20px;
}

.section-stats-toggle {
    display: none;
}

.section-stats-chevron {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

@media (min-width: 901px) {
    .section-stats-body {
        display: block;
    }
}

@media (max-width: 900px) {
    .section-stats-panel--mobile .section-stats-toggle {
        display: flex;
        width: 100%;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 12px 16px;
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-widget);
        background: var(--glass-bg);
        color: var(--text-main);
        font: inherit;
        font-weight: 600;
        font-size: 0.95rem;
        cursor: pointer;
        text-align: left;
        transition: border-color 0.15s ease, background 0.15s ease;
    }

    .section-stats-panel--mobile .section-stats-toggle:hover {
        border-color: rgba(99, 102, 241, 0.35);
        background: var(--glass-bg-hover, rgba(99, 102, 241, 0.06));
    }

    .section-stats-panel--mobile:not(.open) .section-stats-body {
        display: none;
    }

    .section-stats-panel--mobile.open .section-stats-toggle {
        border-radius: var(--radius-widget) var(--radius-widget) 0 0;
        margin-bottom: 0;
        border-bottom-color: transparent;
    }

    .section-stats-panel--mobile.open .section-stats-chevron {
        transform: rotate(180deg);
    }

    .section-stats-panel--mobile.open .section-stats-body {
        display: block;
        padding: 12px;
        border: 1px solid var(--glass-border);
        border-top: none;
        border-radius: 0 0 var(--radius-widget) var(--radius-widget);
        background: var(--glass-bg);
        margin-bottom: 4px;
    }

    .section-stats-panel--mobile .section-stats-body .dash-stats,
    .section-stats-panel--mobile .section-stats-body .clients-stats {
        margin-bottom: 12px;
    }

    .section-stats-panel--mobile .section-stats-body .dash-stats:last-child,
    .section-stats-panel--mobile .section-stats-body .clients-stats:last-child,
    .section-stats-panel--mobile .section-stats-body .chart-container:last-child {
        margin-bottom: 0;
    }

    .section-stats-panel--mobile .section-stats-body .stats-controls {
        margin-bottom: 12px;
    }
}
