.analytics-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 4.75rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    border: 1px solid transparent;
}

.analytics-status-ok {
    color: var(--ut-ok);
    background: #f3fbf7;
    border-color: #bfe8cf;
}

.analytics-status-info {
    color: #087990;
    background: #f5fdff;
    border-color: #b6effb;
}

.analytics-status-stale {
    color: var(--ut-text-secondary);
    background: var(--ut-surface);
    border-color: var(--ut-border);
}

/* Long unit names truncate instead of pushing into neighbouring columns. */
.tracking-unit-table .unit-name-col {
    max-width: 260px;
}

.analytics-status-warning {
    color: #997404;
    background: #fff8e1;
    border-color: #ffe69c;
}

.analytics-status-alarm {
    color: #b02a37;
    background: #fff5f5;
    border-color: #f1aeb5;
}

/* ---- Analytics unit page: map | drag bar | chart column ---- */
/* Fills what's left of the viewport below the header, but never shrinks under 500px - on short screens the
   page scrolls instead (flex-basis 0 so the chart column's content doesn't set the height). */
.analytics-workspace {
    display: flex;
    gap: 6px;
    flex: 1 1 0;
    min-height: 500px;
}

.analytics-map-panel {
    flex: 1 1 auto;
    min-width: 200px;
    position: relative;
}

.analytics-charts-panel {
    flex: 0 0 var(--analytics-charts-width, 45%);
    width: var(--analytics-charts-width, 45%);
    min-width: 320px;
    max-width: 75vw;
    overflow-y: auto;
    padding-right: 4px;
}

/* Unit name next to the period controls: gives way (truncates) before the controls wrap. */
.analytics-unit-title {
    flex: 1 1 8rem;
    min-width: 0;
}

/* Chart reordering: drag the grip in the header onto another chart. */
.analytics-chart-grip {
    cursor: grab;
    font-size: 1rem;
    margin-left: -0.35rem;
}

    .analytics-chart-grip:active {
        cursor: grabbing;
    }

.analytics-chart-card.is-dragging {
    opacity: 0.45;
}

.analytics-chart-card.is-drop-target:not(.is-dragging) {
    outline: 2px dashed var(--ut-accent);
    outline-offset: 2px;
}

/* User-resizable chart box (drag the bottom-right corner); the chart fills it. */
.analytics-chart-box {
    height: 280px;
    min-height: 160px;
    max-height: 900px;
    resize: vertical;
    overflow: hidden;
}

.analytics-overlay-menu {
    min-width: 300px;
    max-height: 420px;
    overflow-y: auto;
}

@media (max-width: 991.98px) {
    /* Not enough room side by side: stack map over charts. */
    .analytics-workspace {
        flex-direction: column;
        flex: 0 0 auto;
    }

    .analytics-map-panel {
        min-height: 360px;
    }

    .analytics-resizer {
        display: none;
    }

    .analytics-charts-panel {
        flex: 0 0 auto;
        width: 100%;
        max-width: none;
        min-width: 0;
        overflow-y: visible;
    }
}
