/* Lane K: compact one-row KPI strip for phones. Under 768px only; from 768px the pages keep their own desktop cards.
   Classes: .bl-kpi-strip (row), .bl-kpi-cell (cell) with <b class="bl-kpi-num"> over <span class="bl-kpi-label">.
   Modifiers: .is-on (selected), .is-zero (muted zero), .bl-kpi-cell--link (tappable). */
@property --kpi-fade-l { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --kpi-fade-r { syntax: '<length>'; inherits: false; initial-value: 0px; }

@media (min-width: 768px) {
    .bl-kpi-phone { display: none !important; }
}

@media (max-width: 767.98px) {
    .bl-kpi-desktop { display: none !important; }

    html body .bl-kpi-strip {
        display: flex;
        flex-wrap: nowrap;
        gap: 4px;
        margin: 0 0 14px;
        padding: 0 28px 0 0;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        /* Fallback: fade the right edge always; the padding above keeps the last cell clear of it */
        -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
        mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    }
    .bl-kpi-strip::-webkit-scrollbar { display: none; }

    /* Fade only when the row can scroll, and only on the side that has more. Without a scroll timeline the fallback above stays. */
    @supports (animation-timeline: scroll(self inline)) {
        html body .bl-kpi-strip {
            padding-inline-end: 0;
            -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--kpi-fade-l), #000 calc(100% - var(--kpi-fade-r)), transparent 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 var(--kpi-fade-l), #000 calc(100% - var(--kpi-fade-r)), transparent 100%);
            animation: bl-kpi-fade linear both;
            animation-timeline: scroll(self inline);
        }
    }

    html body .bl-kpi-strip .bl-kpi-cell {
        flex: 1 0 62px;
        min-height: 44px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1px;
        margin: 0;
        padding: 4px 6px;
        border: 1px solid var(--bl-line, #e5e3de);
        border-radius: 12px;
        background: #fff;
        color: var(--bl-navy, #1A2340);
        font-family: var(--font-body, 'Inter', sans-serif);
        text-align: center;
        text-decoration: none;
        scroll-snap-align: start;
    }
    /* Admin cells keep <p> and <strong> from the desktop cards; classes win over the tag rules (two-line clamp, fixed height, 175px card, one column at 600px) */
    html body .bl-kpi-strip .bl-kpi-cell { position: relative; overflow: visible; background-color: #fff; letter-spacing: normal; }
    html body .bl-kpi-strip .bl-kpi-cell .bl-kpi-num { font-family: var(--font-body, 'Inter', sans-serif); white-space: nowrap; overflow: visible; text-overflow: clip; margin: 0; height: auto; }
    html body .bl-kpi-strip .bl-kpi-cell .bl-kpi-label { height: auto; min-height: 0; margin: 0; padding: 0; letter-spacing: normal; text-transform: none; -webkit-line-clamp: unset; overflow: visible; }
    html body .bl-kpi-strip .bl-kpi-cell .bl-kpi-label a { color: inherit; text-decoration: none; }
    /* A link inside a cell: its tap area is the whole 44px cell */
    html body .bl-kpi-strip .bl-kpi-cell .bl-kpi-label a::after { content: ""; position: absolute; inset: 0; }
    html body .bl-kpi-strip .bl-kpi-caption { display: none; }
    button.bl-kpi-cell { cursor: pointer; -webkit-appearance: none; appearance: none; }
    html body .bl-kpi-strip .bl-kpi-cell .bl-kpi-num { display: block; font-size: 16px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--bl-navy, #1A2340); }
    html body .bl-kpi-strip .bl-kpi-cell .bl-kpi-label { display: block; font-size: 11px; font-weight: 500; line-height: 1.2; white-space: nowrap; color: var(--bl-navy, #1A2340); }
    html body .bl-kpi-strip .bl-kpi-cell.is-zero .bl-kpi-num { color: #6b7487; font-weight: 600; }
    html body .bl-kpi-strip .bl-kpi-cell.is-on { background: var(--bl-navy, #1A2340); border-color: var(--bl-navy, #1A2340); }
    html body .bl-kpi-strip .bl-kpi-cell.is-on .bl-kpi-label { color: #fff; }
    html body .bl-kpi-strip .bl-kpi-cell.is-on .bl-kpi-num, html body .bl-kpi-strip .bl-kpi-cell.is-on.is-zero .bl-kpi-num { color: var(--bl-lemon, #F5D53F); }
    .bl-kpi-cell:focus-visible { outline: 2px solid var(--bl-navy, #1A2340); outline-offset: 2px; }

    /* Dashboard: one short card instead of a strip of zeros */
    .bl-kpi-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 0 0 14px; padding: 14px 16px; border: 1px solid var(--bl-line, #e5e3de); border-radius: 16px; background: #fff; }
    .bl-kpi-empty strong { font-size: 16px; font-weight: 700; color: var(--bl-navy, #1A2340); }
    .bl-kpi-empty p { margin: 0; font-size: 14px; color: #3d475c; }
    .bl-kpi-empty a { display: inline-flex; align-items: center; min-height: 44px; margin-top: 6px; padding: 0 18px; border-radius: 999px; background: var(--bl-lemon, #F5D53F); color: var(--bl-navy, #1A2340); font-size: 14px; font-weight: 600; text-decoration: none; }
}

@media (min-width: 768px) {
    .bl-kpi-empty { display: none !important; }
}

@keyframes bl-kpi-fade {
    0% { --kpi-fade-l: 0px; --kpi-fade-r: 28px; }
    3% { --kpi-fade-l: 28px; }
    97% { --kpi-fade-r: 28px; }
    100% { --kpi-fade-l: 28px; --kpi-fade-r: 0px; }
}
