.dashboard-page {
    display: grid;
    gap: 1.5rem;
}

.dashboard-page > .mb-4,
.dashboard-page > .mb-3,
.dashboard-page > .mb-2 {
    margin-bottom: 0 !important;
}

.dashboard-widget {
    background: var(--surface-color);
    border: 1px solid var(--form-border);
    border-radius: 0.875rem;
    overflow: hidden;
    padding: 0;
}

.dashboard-widget__header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border-bottom: 0;
    margin-bottom: 0;
}

.dashboard-widget__title {
    color: var(--header-color);
    font-size: 1.08rem;
    font-weight: 800;
    line-height: 1.2;
}

.dashboard-widget__subtitle {
    color: var(--sub-title-color);
    font-size: 0.92rem;
    line-height: 1.4;
}

.dashboard-widget__cta {
    white-space: nowrap;
    padding: 0.65rem 1rem;
    font-weight: 600;
}

.dashboard-widget__body {
    margin: 0;
}

.dashboard-panel {
    position: relative;
}

.dashboard-panel--bordered::before {
    content: "";
    position: absolute;
    top: 1.5rem;
    bottom: 1.5rem;
    left: 0;
    width: 1px;
    background: var(--form-border);
}

.dashboard-panel__inner {
    padding: 1rem;
}

.dashboard-panel__header {
    margin-bottom: 0.65rem;
}

.dashboard-panel__title {
    color: var(--header-color) !important;
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.25;
}

.home-kpi-tabs {
    gap: 0.5rem;
}

.home-kpi-tab,
.dashboard-comparison-tab {
    border: 0;
    border-radius: calc(var(--form-border-radius) - 0.2rem);
    background: transparent;
    color: var(--header-color);
    cursor: pointer;
    font-weight: 600;
    line-height: 1.1;
    padding: 0.58rem 0.9rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.home-kpi-tab:hover,
.home-kpi-tab.active,
.dashboard-comparison-tab:hover,
.btn-check:focus + .dashboard-comparison-tab,
.btn-check:checked + .dashboard-comparison-tab {
    background: var(--control-active-bg);
    color: var(--primary-color);
}

.btn-check:focus + .dashboard-comparison-tab {
    box-shadow: var(--control-focus-ring);
}

.home-kpi-chart {
    position: relative;
    min-height: 216px;
    border: 1px dashed var(--form-border);
    border-radius: var(--surface-radius-sm);
    background: var(--surface-muted-color);
    padding: 0.85rem;
}

.home-kpi-chart__empty {
    position: absolute;
    inset: 0.85rem;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--sub-title-color);
    font-size: 0.9rem;
    line-height: 1.35;
    text-align: center;
}

.home-kpi-chart.is-empty canvas {
    display: none !important;
}

.home-kpi-chart.is-empty .home-kpi-chart__empty {
    display: flex;
}

.home-kpi-chart canvas {
    width: 100% !important;
    height: 188px !important;
}

.home-kpi-setup {
    align-items: flex-start;
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.08), rgba(13, 110, 253, 0.02));
    display: flex;
    gap: 1rem;
    margin: 1rem;
    padding: 1.15rem;
    border: 1px solid rgba(13, 110, 253, 0.16);
    border-radius: var(--surface-radius-sm);
}

.home-kpi-setup__icon {
    align-items: center;
    background: var(--surface-color);
    border: 1px solid rgba(13, 110, 253, 0.18);
    border-radius: 999px;
    color: var(--primary-color);
    display: inline-flex;
    flex: 0 0 2.5rem;
    height: 2.5rem;
    justify-content: center;
    width: 2.5rem;
}

.home-kpi-setup__title {
    color: var(--header-color);
    font-size: 1rem;
    font-weight: 800;
    margin: 0 0 0.35rem;
}

.home-kpi-setup__copy {
    color: var(--sub-title-color);
    margin: 0 0 0.85rem;
    max-width: 56rem;
}

.dashboard-chart-wrap canvas {
    width: 100% !important;
    height: 320px !important;
}

@media (max-width: 991.98px) {
    .home-kpi-widget {
        margin-left: 0;
        margin-right: 0;
    }

    .dashboard-widget__header {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-panel--bordered::before {
        display: none;
    }

    .dashboard-panel {
        border-top: 1px solid var(--form-border);
    }

    .dashboard-panel:first-child {
        border-top: 0;
    }

    .home-kpi-setup {
        flex-direction: column;
    }
}

.dashboard-stat__value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--header-color);
    line-height: 1.1;
}

.dashboard-stat__meta {
    font-size: 0.9rem;
    color: var(--sub-title-color);
    margin-top: 0.25rem;
}

.dashboard-stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.dashboard-stat-card {
    display: flex;
    gap: 0.8rem;
    min-width: 0;
    min-height: 7.25rem;
    align-items: flex-start;
    border: 1px solid var(--form-border);
    border-radius: var(--form-border-radius);
    background: var(--surface-color);
    padding: 0.9rem;
}

.dashboard-stat-card__icon {
    display: inline-flex;
    flex: 0 0 2.25rem;
    width: 2.25rem;
    height: 2.25rem;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: rgba(81, 39, 155, 0.1);
    color: var(--primary-color);
}

.dashboard-stat-card__content {
    min-width: 0;
}

.dashboard-stat-card__label {
    color: var(--sub-title-color);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.2;
}

.dashboard-stat-card__value {
    margin-top: 0.25rem;
    color: var(--header-color);
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1.05;
}

.dashboard-stat-card__meta {
    margin-top: 0.3rem;
    color: var(--sub-title-color);
    font-size: 0.82rem;
    line-height: 1.35;
}

.dashboard-stat-card--success .dashboard-stat-card__icon {
    background: var(--valid-background);
    color: var(--valid-color);
}

.dashboard-stat-card--danger .dashboard-stat-card__icon {
    background: var(--invalid-background);
    color: var(--invalid-color);
}

.dashboard-stat-card--warning .dashboard-stat-card__icon {
    background: var(--pending-background);
    color: var(--pending-color);
}

.dashboard-stat-card--info .dashboard-stat-card__icon {
    background: rgba(13, 110, 253, 0.12);
    color: #0d6efd;
}

.dashboard-stat-card--empty {
    grid-column: 1 / -1;
    min-height: 0;
    color: var(--sub-title-color);
}

@media (max-width: 991.98px) {
    .dashboard-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .dashboard-stat-grid {
        grid-template-columns: 1fr;
    }
}

.dashboard-pivot-widget .dashboard-widget__body {
    padding: 0;
}

.dashboard-pivot {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.dashboard-pivot__toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
    padding: 0.75rem 0.75rem 0;
}

.dashboard-pivot__table {
    padding: 0.75rem 0.5rem 0.25rem;
}

.dashboard-pivot-table {
    min-width: 920px;
    margin-bottom: 0;
    --pivot-location-bg: #f1f5f9;
    --pivot-group-bg: #f8fafc;
    --pivot-product-bg: #ffffff;
    --pivot-guide: #cbd5e1;
    --pivot-guide-strong: var(--primary-color);
}

.dashboard-pivot-table thead th {
    color: var(--header-color);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0;
}

.dashboard-pivot-table td,
.dashboard-pivot-table th {
    vertical-align: middle;
}

.dashboard-pivot-table .pivot-row > td:first-child,
.dashboard-pivot-table .pivot-row > td:nth-child(2),
.dashboard-pivot-table .pivot-row > td:nth-child(3) {
    position: relative;
}

.dashboard-pivot-table .pivot-row--location > td {
    background: var(--pivot-location-bg);
    border-top: 2px solid var(--form-border);
    font-weight: 800;
}

.dashboard-pivot-table .pivot-row--location > td:first-child {
    border-left: 4px solid var(--pivot-guide-strong);
}

.dashboard-pivot-table .pivot-row--group > td {
    background: var(--pivot-group-bg);
    font-weight: 700;
}

.dashboard-pivot-table .pivot-row--group > td:nth-child(2) {
    padding-left: 1.25rem;
}

.dashboard-pivot-table .pivot-row--group > td:nth-child(2)::before,
.dashboard-pivot-table .pivot-row--product > td:nth-child(3)::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0.55rem;
    width: 2px;
    background: var(--pivot-guide);
}

.dashboard-pivot-table .pivot-row--product > td {
    background: var(--pivot-product-bg);
}

.dashboard-pivot-table .pivot-row--product > td:nth-child(3) {
    padding-left: 1.75rem;
}

.dashboard-pivot-table .pivot-row--product > td:nth-child(3)::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0.55rem;
    width: 0.75rem;
    height: 2px;
    background: var(--pivot-guide);
}

.dashboard-pivot-table .aggregate-row td {
    font-weight: 700;
}

.dashboard-pivot-table tbody tr:hover > * {
    --bs-table-bg: var(--table-hover);
    --bs-table-accent-bg: var(--table-hover);
    background-color: var(--table-hover) !important;
}

.dashboard-pivot-table [data-pivot-row] {
    cursor: pointer;
}

.dashboard-pivot-table tr[hidden] {
    display: none;
}

.pivot-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 0;
    background: transparent;
    color: var(--header-color);
    font: inherit;
    font-weight: 700;
    padding: 0;
    text-align: left;
}

.pivot-toggle--group {
    font-weight: 600;
}

.pivot-toggle i {
    display: inline-flex;
    width: 1.35rem;
    height: 1.35rem;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(81, 39, 155, 0.16);
    border-radius: 999px;
    background: rgba(81, 39, 155, 0.08);
    color: var(--primary-link-color);
    font-size: 0.68rem;
}

.pivot-toggle:hover i,
.pivot-toggle:focus-visible i {
    background: var(--primary-color);
    color: var(--surface-color);
}

@media (max-width: 575.98px) {
    .dashboard-pivot__toolbar {
        justify-content: flex-start;
    }
}
