/* The new dashboard tabs (Sales per hour, Reps, Overrides, Margin, Promotions, Stock KPIs top sellers). Global, prefixed dt- */

.dt-tab {
    --dt-border: var(--mud-palette-lines-default);
    --dt-muted: var(--mud-palette-text-secondary);
    --dt-green: #2e7d32;
    --dt-red: #c62828;
    --dt-orange: #ef6c00;
    --dt-blue: #1e63d6;
    --dt-purple: #7b3fd1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dt-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.dt-label {
    font-weight: 600;
    color: var(--dt-muted);
}

.dt-toolbar .dt-date {
    max-width: 210px;
    flex: 0 0 210px;
    margin: 0;
}

.dt-toolbar .dt-store {
    max-width: 240px;
    flex: 0 0 240px;
    margin: 0;
}

.dt-period {
    font-size: 0.8rem;
    color: var(--dt-muted);
}

.dt-empty {
    padding: 24px;
    color: var(--dt-muted);
    background: var(--mud-palette-surface);
    border: 1px dashed var(--mud-palette-lines-inputs);
    border-radius: 12px;
}

/* CARDS */
.dt-card {
    background: var(--mud-palette-surface);
    border: 1px solid var(--dt-border);
    border-left: 4px solid var(--dt-blue);
    border-radius: 12px;
    padding: 10px 14px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 8px rgba(16, 24, 40, 0.05);
    min-width: 0;
}

    .dt-card.green { border-left-color: var(--dt-green); }
    .dt-card.red { border-left-color: var(--dt-red); }
    .dt-card.orange { border-left-color: var(--dt-orange); }
    .dt-card.purple { border-left-color: var(--dt-purple); }
    .dt-card.grey { border-left-color: var(--mud-palette-lines-inputs); }

.dt-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    margin-bottom: 8px;
}

.dt-card-title {
    font-weight: 700;
}

.dt-card-sub {
    font-size: 0.78rem;
    color: var(--dt-muted);
    flex-basis: 100%;
}

.dt-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

/* KPI TILES */
.dt-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
}

.dt-kpi {
    background: var(--mud-palette-surface);
    border: 1px solid var(--dt-border);
    border-radius: 12px;
    padding: 10px 14px;
}

.dt-kpi-label {
    font-size: 0.78rem;
    color: var(--dt-muted);
}

.dt-kpi-value {
    font-size: 1.3rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.dt-kpi-sub {
    font-size: 0.78rem;
    color: var(--dt-muted);
}

/* TABLES */
.dt-wrap {
    overflow: auto;
    max-height: calc(100vh - 360px);
    min-height: 120px;
}

.dt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

    .dt-table th,
    .dt-table td {
        padding: 3px 8px;
        border-bottom: 1px solid var(--dt-border);
        text-align: right;
        white-space: nowrap;
    }

    .dt-table th {
        font-weight: 600;
        background: var(--mud-palette-background-gray);
        position: sticky;
        top: 0;
        z-index: 1;
    }

    .dt-table .name {
        text-align: left;
    }

    .dt-table td.wrap {
        white-space: normal;
        min-width: 220px;
    }

    .dt-table td.ellipsis {
        max-width: 340px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .dt-table .group-start {
        border-left: 2px solid var(--dt-border);
    }

    .dt-table tbody tr:hover td {
        background: rgba(30, 99, 214, 0.06);
    }

    .dt-table tbody tr.clickable {
        cursor: pointer;
    }

    .dt-table tbody tr.picked td {
        background: rgba(30, 99, 214, 0.12);
    }

    .dt-table tfoot td {
        font-weight: 700;
        border-top: 2px solid var(--dt-border);
        background: var(--mud-palette-background-gray);
        position: sticky;
        bottom: 0;
    }

    .dt-table td.muted,
    .dt-muted {
        color: var(--dt-muted);
    }

.dt-tab .down { color: var(--dt-red); }
.dt-tab .up { color: var(--dt-green); }
.dt-tab .warn { color: var(--dt-orange); }

/* HEAT MAP CELLS (sales per hour) */
.dt-table td.heat {
    position: relative;
}

.dt-heat-0 { background: transparent; }
.dt-heat-1 { background: rgba(30, 99, 214, 0.08); }
.dt-heat-2 { background: rgba(30, 99, 214, 0.16); }
.dt-heat-3 { background: rgba(30, 99, 214, 0.26); }
.dt-heat-4 { background: rgba(30, 99, 214, 0.38); }
.dt-heat-5 { background: rgba(30, 99, 214, 0.52); color: #fff; }

/* BADGES */
.dt-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 10px;
    padding: 1px 8px;
    background: rgba(30, 99, 214, 0.1);
    color: var(--dt-blue);
}

    .dt-badge.green { background: rgba(46, 125, 50, 0.12); color: var(--dt-green); }
    .dt-badge.red { background: rgba(198, 40, 40, 0.12); color: var(--dt-red); }
    .dt-badge.orange { background: rgba(239, 108, 0, 0.12); color: var(--dt-orange); }
    .dt-badge.grey { background: rgba(0, 0, 0, 0.06); color: var(--dt-muted); }

/* BAR CHART (promotion before / during / after) */
.dt-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 170px;
    padding: 8px 4px 0;
    border-bottom: 1px solid var(--dt-border);
}

.dt-bar {
    flex: 1 1 0;
    min-width: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--mud-palette-lines-inputs);
    position: relative;
}

    .dt-bar.before { background: rgba(120, 120, 120, 0.45); }
    .dt-bar.during { background: var(--dt-blue); }
    .dt-bar.after { background: rgba(123, 63, 209, 0.55); }
    .dt-bar.nodata { background: repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(0, 0, 0, 0.08) 3px, rgba(0, 0, 0, 0.08) 6px); height: 100% !important; }

.dt-bar-axis {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--dt-muted);
    padding: 2px 4px 0;
}

.dt-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--dt-muted);
}

    .dt-legend span::before {
        content: "";
        display: inline-block;
        width: 10px;
        height: 10px;
        border-radius: 2px;
        margin-right: 4px;
        vertical-align: -1px;
        background: var(--dt-swatch, #999);
    }

.dt-note {
    font-size: 0.75rem;
    color: var(--dt-muted);
}

@media (max-width: 1200px) {
    .dt-grid-2 {
        grid-template-columns: 1fr;
    }
}

/* CASH SUMMARY */
.dt-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
}

.dt-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.dt-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 16px;
    align-items: start;
}

.dt-table.dt-counts td {
    border-bottom: 1px dashed var(--dt-border);
}

.dt-table tr.dt-line.total td {
    font-weight: 600;
    border-top: 1px solid var(--mud-palette-text-secondary);
}

.dt-table tr.dt-line.grand td {
    font-weight: 700;
    border-top: 1px solid var(--mud-palette-text-primary);
    border-bottom: 3px double var(--mud-palette-text-primary);
}

.dt-table tr.dt-line.minus td.name {
    padding-left: 18px;
    color: var(--dt-muted);
}

.dt-tab .over {
    color: var(--dt-blue);
}

.dt-kpi.alert {
    background: rgba(198, 40, 40, 0.08);
    border-color: rgba(198, 40, 40, 0.45);
}

.dt-zero-toggle {
    display: flex;
    justify-content: flex-end;
    margin: -8px 0 -10px;
}

/* the four cash summary cards: same width and, with grid-auto-rows 1fr, the same height (the tallest one) */
.dt-grid-equal {
    grid-auto-rows: 1fr;
}

.dt-hidden-note {
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--dt-muted);
}

@media (max-width: 1400px) {
    .dt-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1000px) {
    .dt-grid-3,
    .dt-split {
        grid-template-columns: 1fr;
    }
}

/* BACK / CLOSE BUTTONS on the dashboard and its tabs: filled or outlined in the primary colour so they stand out */
.mud-button-root.dash-back {
    text-transform: none;
    font-weight: 600;
    border-radius: 8px;
    padding-left: 12px;
    padding-right: 14px;
}

/* ISSUE #31: AGEING CLICK-THROUGH */
.dt-table td.dt-click {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}

    .dt-table td.dt-click:hover {
        color: var(--dt-blue);
    }

.dt-drill {
    margin-top: 10px;
}

.dt-table.dt-counts tr.clickable {
    cursor: pointer;
}
