/* ============================================================
   ATLAS Routes — design system
   Dark sidebar, light canvas, near-black actions, ATLAS red
   reserved as the brand accent.
   ============================================================ */

:root {
    --atlas-red: #E8261D;
    --atlas-red-deep: #C41F17;
    --atlas-red-soft: #FDEEED;

    --ink-950: #0B0B0D;
    --ink-900: #141417;
    --ink-800: #1D1D21;
    --ink-600: #4B4F56;
    --ink-500: #6E727A;
    --ink-400: #9A9EA6;

    --line: #E8E9EC;
    --line-soft: #F1F2F4;
    --surface: #FFFFFF;
    --canvas: #F7F7F8;

    --success: #0E8A55;
    --success-soft: #E8F5EF;
    --warning: #9A6700;
    --warning-soft: #FFF6E0;
    --danger: #D5382E;
    --danger-soft: #FDF0EF;
    --info-soft: #EEF4FB;
    --info: #23527A;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(11, 11, 13, .05), 0 1px 1px rgba(11, 11, 13, .03);
    --shadow-md: 0 12px 32px rgba(11, 11, 13, .10);
    --font: 'Inter', -apple-system, 'Segoe UI Variable Text', 'Segoe UI', system-ui, sans-serif;
}

html, body {
    font-family: var(--font);
    background: var(--canvas);
    color: var(--ink-800);
    font-size: 14px;
    letter-spacing: -0.006em;
    -webkit-font-smoothing: antialiased;
}

/* ---------- typography ---------- */

h1 {
    font-size: 26px;
    font-weight: 650;
    letter-spacing: -0.022em;
    color: var(--ink-950);
    margin-bottom: 6px;
}

h1:focus {
    outline: none;
}

h1 + p, p.lead {
    color: var(--ink-500);
    font-size: 14.5px;
    font-weight: 400;
    max-width: 72ch;
}

h5, .h5 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ink-600);
    margin: 8px 0 12px;
}

h3, .h3 {
    font-weight: 650;
    letter-spacing: -0.015em;
    color: var(--ink-950);
}

a, .btn-link {
    color: var(--ink-900);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--ink-400);
    transition: color .12s ease;
}

    a:hover, .btn-link:hover {
        color: var(--atlas-red-deep);
        text-decoration-color: currentColor;
    }

.text-muted {
    color: var(--ink-500) !important;
}

/* ---------- buttons ---------- */

.btn {
    font-weight: 550;
    font-size: 13.5px;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    letter-spacing: -0.006em;
    text-decoration: none;
    transition: background .13s ease, color .13s ease, border-color .13s ease, box-shadow .13s ease;
}

.btn-primary {
    color: #fff;
    background: var(--ink-900);
    border: 1px solid var(--ink-900);
}

    .btn-primary:hover, .btn-primary:focus, .btn-primary:active {
        background: var(--ink-950) !important;
        border-color: var(--ink-950) !important;
        color: #fff;
    }

    .btn-primary:disabled {
        background: var(--ink-400);
        border-color: var(--ink-400);
        opacity: 1;
    }

.btn-outline-primary, .btn-outline-secondary {
    color: var(--ink-800);
    background: var(--surface);
    border: 1px solid var(--line);
}

    .btn-outline-primary:hover, .btn-outline-secondary:hover,
    .btn-outline-primary:active, .btn-outline-secondary:active {
        color: var(--ink-950) !important;
        background: var(--line-soft) !important;
        border-color: var(--line) !important;
    }

    .btn-outline-primary:disabled, .btn-outline-secondary:disabled {
        color: var(--ink-400);
        background: var(--surface);
        border-color: var(--line);
        opacity: 1;
    }

.btn-outline-danger {
    color: var(--danger);
    background: transparent;
    border: 1px solid transparent;
}

    .btn-outline-danger:hover {
        color: var(--danger) !important;
        background: var(--danger-soft) !important;
        border-color: transparent !important;
    }

.btn-sm {
    padding: 4px 10px;
    font-size: 12.5px;
    border-radius: 7px;
}

.btn:focus-visible, .form-control:focus-visible, .form-select:focus-visible {
    box-shadow: 0 0 0 3px rgba(232, 38, 29, .25) !important;
    outline: none;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus {
    box-shadow: 0 0 0 3px rgba(11, 11, 13, .10);
}

/* ---------- cards & KPIs ---------- */

.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
}

.card-body {
    padding: 20px 22px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin: 26px 0;
}

.kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px 16px;
}

    .kpi .kpi-value {
        font-size: 30px;
        font-weight: 650;
        letter-spacing: -0.025em;
        color: var(--ink-950);
        font-variant-numeric: tabular-nums;
        line-height: 1.15;
    }

    .kpi .kpi-label {
        font-size: 11.5px;
        font-weight: 550;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--ink-500);
        margin-top: 4px;
    }

/* ---------- tables ---------- */

.table {
    --bs-table-hover-bg: #FAFBFC;
    width: 100%;
    margin-bottom: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 13px;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(16, 17, 20, .035), 0 1px 1px rgba(16, 17, 20, .02);
    font-size: 13px;
    color: var(--ink-800);
}

    .table thead th, .table > :not(caption) > * > th {
        font-size: 10.5px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--ink-400);
        background: var(--surface);
        border-bottom: 1px solid var(--line);
        padding: 15px 18px 12px;
        white-space: nowrap;
        vertical-align: bottom;
    }

    .table td, .table > :not(caption) > * > td {
        /* !important defeats QuickGrid's tighter scoped cell padding, so every table (plain or
           grid) shares the same comfortable rhythm. */
        padding: 14px 18px !important;
        border-bottom: 1px solid var(--line-soft);
        color: var(--ink-700, #3C4149);
        font-variant-numeric: tabular-nums;
        font-feature-settings: "tnum" 1;
        vertical-align: middle;
        line-height: 1.5;
    }

    /* Generous breathing room at the table edges — the premium detail. */
    .table th:first-child, .table td:first-child { padding-left: 24px !important; }
    .table th:last-child, .table td:last-child { padding-right: 24px !important; }

    /* The row's leading label reads a touch stronger than its data. */
    .table tbody td.fw-bold, .table tbody td:first-child {
        color: var(--ink-900);
    }

    .table tbody tr {
        transition: background .12s ease;
    }

    .table tbody tr:hover td {
        background: #FAFBFC;
    }

    .table tbody tr:last-child td {
        border-bottom: none;
    }

    .table tfoot td {
        background: #FCFCFD;
        border-top: 1px solid var(--line);
        border-bottom: none;
        font-weight: 650;
        color: var(--ink-900);
    }

    .table .col-options-button, .table button.col-title {
        color: inherit;
    }

/* QuickGrid sort buttons inherit the header look. */
.table button.col-title {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-400);
    padding: 0;
}

.table button.col-title:hover {
    color: var(--ink-700);
}

/* QuickGrid header row + sort chevrons align cleanly with the padded cells. */
.table .col-header-content { gap: 5px; }
.table .col-sort-indicator { opacity: 0.6; }

/* Row action buttons — Linear-style chips: a visible soft fill, hairline border and crisp hover.
   Neutral by default; destructive actions are a soft red that fills solid red on hover; primary
   actions are a dark chip. */
.table td .btn-sm {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 540;
    line-height: 1.35;
    border-radius: 7px;
    color: var(--ink-800);
    background: #F4F5F7;
    border: 1px solid var(--line);
    box-shadow: 0 1px 1.5px rgba(16, 17, 20, .04);
    transition: background .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease;
}

    .table td .btn-sm + .btn-sm {
        margin-left: 6px;
    }

    .table td .btn-sm:hover {
        color: var(--ink-950) !important;
        background: #EBEDF0 !important;
        border-color: #D6D9DF !important;
        box-shadow: 0 1px 2px rgba(16, 17, 20, .08) !important;
    }

    .table td .btn-sm:active {
        background: #E2E4E9 !important;
        box-shadow: none !important;
    }

    .table td .btn-primary.btn-sm {
        color: #fff;
        background: var(--ink-900);
        border-color: var(--ink-900);
    }

        .table td .btn-primary.btn-sm:hover {
            color: #fff !important;
            background: var(--ink-950) !important;
            border-color: var(--ink-950) !important;
        }

    .table td .btn-outline-danger.btn-sm {
        color: var(--danger);
        background: var(--danger-soft);
        border-color: rgba(213, 56, 46, .22);
    }

        .table td .btn-outline-danger.btn-sm:hover {
            color: #fff !important;
            background: var(--danger) !important;
            border-color: var(--danger) !important;
            box-shadow: 0 1px 3px rgba(213, 56, 46, .28) !important;
        }

/* ---------- badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    font-weight: 550;
    font-size: 10.5px;
    letter-spacing: 0.015em;
    padding: 3px 9px;
    border-radius: 999px;
    vertical-align: middle;
}

    .badge.bg-success {
        background: var(--success-soft) !important;
        color: var(--success);
    }

    .badge.bg-danger {
        background: var(--danger-soft) !important;
        color: var(--danger);
    }

    .badge.bg-secondary {
        background: var(--line-soft) !important;
        color: var(--ink-500);
    }

/* ---------- alerts ---------- */

.alert {
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    padding: 12px 16px;
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
}

.alert-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.alert-warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.alert-info {
    background: var(--info-soft);
    color: var(--info);
}

/* ---------- forms ---------- */

.form-control, .form-select {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--ink-900);
    padding: 8px 12px;
    background-color: var(--surface);
    transition: border-color .13s ease, box-shadow .13s ease;
}

    .form-control:focus, .form-select:focus {
        border-color: var(--ink-800);
        box-shadow: 0 0 0 3px rgba(11, 11, 13, .07);
    }

    .form-control::placeholder {
        color: var(--ink-400);
    }

.form-label, .col-form-label {
    font-size: 12.5px;
    font-weight: 550;
    color: var(--ink-600);
}

.form-floating > label {
    color: var(--ink-500);
    font-size: 13px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--ink-400);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ---------- QuickGrid paginator ---------- */

nav[aria-label='pagination'], .paginator {
    font-size: 13px;
    color: var(--ink-500);
}

.paginator {
    padding: 10px 2px;
}

    .paginator button {
        border: 1px solid var(--line);
        background: var(--surface);
        border-radius: 7px;
        color: var(--ink-800);
    }

        .paginator button:hover:not(:disabled) {
            background: var(--line-soft);
        }

/* ---------- map container ---------- */

.map-frame {
    height: min(78vh, 860px);
    min-height: 620px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.territory-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    vertical-align: -2px;
}

/* ---------- distribution-center summary cards ---------- */

.dc-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    max-width: 1280px;
}

.dc-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.dc-card-name {
    font-weight: 600;
    font-size: 14.5px;
    letter-spacing: -0.008em;
    color: var(--ink-900);
    margin-bottom: 8px;
}

.dc-card-vans {
    font-size: 29px;
    font-weight: 680;
    line-height: 1.05;
    letter-spacing: -0.03em;
    color: var(--ink-950);
    font-variant-numeric: tabular-nums;
}

.dc-card-vans span {
    font-size: 12px;
    font-weight: 550;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-400);
    margin-left: 6px;
}

.dc-card-stats {
    margin: 14px 0 0;
    display: grid;
    gap: 7px;
}

.dc-card-stats > div {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.dc-card-stats dt {
    color: var(--muted, #6b7280);
    font-weight: 400;
    margin: 0;
}

.dc-card-stats dd {
    margin: 0;
    font-weight: 600;
}

.dc-card-warn dt,
.dc-card-warn dd {
    color: #b45309;
}

/* ---------- app-depots panel (network studio) ---------- */

.app-depots-panel {
    max-width: 920px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    padding: 15px 17px;
    box-shadow: var(--shadow-sm);
}

.app-depots-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.app-depots-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.006em;
    color: var(--ink-900);
}

.app-depots-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--atlas-red);
    box-shadow: 0 0 0 3px var(--atlas-red-soft);
    flex-shrink: 0;
}

.app-depots-meta {
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-400);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.app-depots-empty {
    font-size: 13px;
    color: var(--ink-500);
    margin-top: 10px;
}

.depot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(216px, 1fr));
    gap: 7px;
    margin-top: 13px;
}

.depot-chip {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--canvas);
    transition: border-color .12s ease, background .12s ease;
}

.depot-chip:hover {
    border-color: #D9DBDF;
    background: #fff;
}

.depot-chip-name {
    font-size: 12.5px;
    font-weight: 550;
    letter-spacing: -0.004em;
    color: var(--ink-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.depot-chip-coord {
    font-size: 11px;
    color: var(--ink-400);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ---------- validation / framework ---------- */

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--success);
}

.invalid {
    outline: 1px solid var(--danger);
}

.validation-message {
    color: var(--danger);
    font-size: 12.5px;
    margin-top: 4px;
}

.blazor-error-boundary {
    background: var(--danger);
    padding: 1rem;
    color: white;
    border-radius: var(--radius-sm);
}

    .blazor-error-boundary::after {
        content: "An error has occurred.";
    }

#blazor-error-ui {
    color-scheme: light only;
    background: var(--ink-950);
    color: #fff;
    bottom: 0;
    box-shadow: var(--shadow-md);
    display: none;
    left: 0;
    padding: 0.8rem 1.2rem 0.9rem 1.2rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: 13.5px;
}

    #blazor-error-ui .reload {
        color: #fff;
    }

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.darker-border-checkbox.form-check-input {
    border-color: var(--ink-400);
}

/* ---------- loading & motion ---------- */

@keyframes atlas-spin {
    to { transform: rotate(360deg); }
}

@keyframes atlas-halo {
    0% { transform: scale(0.7); opacity: 0.85; }
    70% { transform: scale(1.55); opacity: 0; }
    100% { transform: scale(1.55); opacity: 0; }
}

@keyframes atlas-breathe {
    0%, 100% { transform: scale(0.9); }
    50% { transform: scale(1.03); }
}

@keyframes atlas-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Inline button spinner */
.spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255, 255, 255, 0.28);
    border-top-color: #fff;
    border-radius: 50%;
    animation: atlas-spin 0.7s linear infinite;
    vertical-align: -2px;
    margin-right: 8px;
}

.spinner-dark {
    border-color: rgba(11, 11, 13, 0.15);
    border-top-color: var(--ink-800);
}

/* Branded loader: the ATLAS globe with a soft pulsing glow — no ring, fully borderless. */
.atlas-loader {
    --loader-size: 56px;
    position: relative;
    width: var(--loader-size);
    height: var(--loader-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

    /* A soft glow that expands and fades outward (sonar), instead of a hard border ring. */
    .atlas-loader .halo {
        position: absolute;
        inset: -8%;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(232, 38, 29, 0.35) 0%, rgba(232, 38, 29, 0) 68%);
        animation: atlas-halo 1.9s ease-out infinite;
    }

    .atlas-loader svg {
        position: relative;
        width: calc(var(--loader-size) * 0.72);
        height: calc(var(--loader-size) * 0.72);
        filter: drop-shadow(0 2px 7px rgba(232, 38, 29, 0.40));
        animation: atlas-breathe 1.9s ease-in-out infinite;
    }

.loader-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 48px 0;
    color: var(--ink-500);
    font-size: 13.5px;
}

/* Skeleton shimmer */
.skeleton {
    background: linear-gradient(90deg, #EDEDEF 25%, #F6F6F7 50%, #EDEDEF 75%);
    background-size: 200% 100%;
    animation: atlas-shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
    color: transparent;
    user-select: none;
}

@media (prefers-reduced-motion: reduce) {
    .spinner, .atlas-loader .halo, .atlas-loader svg, .skeleton {
        animation-duration: 8s;
    }
}

/* ---- Help-tip popover: renders in the browser top layer, so tables can't clip it ---- */
.help-tip-popover {
    position: fixed;
    inset: unset;
    margin: 0;
    max-width: 320px;
    width: max-content;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: #1f2024;
    color: #f4f5f7;
    box-shadow: 0 12px 38px rgba(0, 0, 0, 0.34);
    overflow: visible;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.14s ease, transform 0.14s ease, overlay 0.14s ease allow-discrete, display 0.14s ease allow-discrete;
}

.help-tip-popover:popover-open {
    opacity: 1;
    transform: translateY(0);
}

@starting-style {
    .help-tip-popover:popover-open {
        opacity: 0;
        transform: translateY(-4px);
    }
}

.help-tip-popover::backdrop {
    background: transparent;
}

.help-tip-text {
    display: block;
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    text-transform: none;
    letter-spacing: normal;
    white-space: normal;
}

.help-tip-arrow {
    position: absolute;
    top: -5px;
    left: var(--arrow-x, 50%);
    transform: translateX(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    background: #1f2024;
    border-radius: 2px;
}

.help-tip-popover.flip-up .help-tip-arrow {
    top: auto;
    bottom: -5px;
}

/* ---------- top navigation progress bar ---------- */
/* Progress is a compositor-driven scaleX transform (not width), so it keeps animating
   smoothly even while Blazor blocks the main thread rendering the incoming page. */
#atlas-progress {
    position: fixed;
    inset: 0 0 auto 0;
    height: 2.5px;
    z-index: 100000;
    pointer-events: none;
    opacity: 0;
    will-change: opacity;
}

#atlas-progress.active {
    opacity: 1;
}

#atlas-progress.active.done {
    opacity: 0;
    transition: opacity .32s ease;
}

.atlas-progress-inner {
    height: 100%;
    width: 100%;
    transform: scaleX(0);
    transform-origin: left center;
    background: linear-gradient(90deg, var(--atlas-red-deep), var(--atlas-red) 55%, #FF6A62);
    box-shadow: 0 0 10px rgba(232, 38, 29, .55), 0 1px 5px rgba(232, 38, 29, .4);
    will-change: transform;
}

/* Trickle that advances fast then decelerates toward ~92% and waits there for completion.
   Runs on the compositor, so it never freezes during the page's heavy render. */
#atlas-progress.active .atlas-progress-inner {
    animation: atlasTrickle 20s cubic-bezier(0, .8, .15, 1) forwards;
}

#atlas-progress.active.finishing .atlas-progress-inner {
    animation: none;
    transform: scaleX(1);
    transition: transform .22s ease;
}

@keyframes atlasTrickle {
    0%   { transform: scaleX(.05); }
    100% { transform: scaleX(.92); }
}

/* Gentle content settle on each navigation so a page never flashes half-rendered. */
.atlas-page-in {
    animation: atlasPageIn .26s ease;
}

@keyframes atlasPageIn {
    from { opacity: .35; }
    to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .atlas-page-in { animation: none; }
    #atlas-progress.active .atlas-progress-inner { animation-duration: 0s; transform: scaleX(.85); }
}

/* =====================================================================
   Page vertical rhythm
   One consistent spacing scale for every page. Blocks flow with bottom
   margins only — top margins on .content's direct children are reset — so
   the ad-hoc mt-*/mb-* utilities the pages accumulated can't create uneven
   gaps. Section headings get extra separation above; everything else lines
   up on the same scale, page to page.
   ===================================================================== */
.content > * { margin-top: 0 !important; }
.content > *:last-child { margin-bottom: 0; }

.content > h1 { margin-bottom: 16px; }

/* section headings — uniform generous gap above, tight lead-in below */
.content > h5,
.content > .h5,
.content > h6 { margin-top: 34px !important; margin-bottom: 14px !important; }

/* the first section directly under the page title sits closer to it */
.content > h1 + h5,
.content > h1 + .h5,
.content > h1 + h6 { margin-top: 10px !important; }

/* intro / description text */
.content > p { margin-bottom: 18px; max-width: 84ch; }

/* data + layout blocks — one uniform bottom rhythm */
.content > .table,
.content > table.table { margin-bottom: 28px !important; }
.content > .kpi-grid { margin-bottom: 28px !important; }
.content > .dc-cards,
.content > .app-depots-panel { margin-bottom: 26px !important; }
.content > .card { margin-bottom: 24px !important; }
.content > .alert { margin-bottom: 22px !important; }

/* toolbars: filter + action rows */
.content > .d-flex { margin-bottom: 22px !important; }

/* major section divider between page zones */
.content > .section-divider,
.content > div[style*="border-top"] {
    margin-top: 40px !important;
    padding-top: 26px !important;
    border-top: 1px solid var(--line);
}

/* a grid's paginator belongs to it — hug the table instead of floating a full gap away */
.content > .table:has(+ .paginator) { margin-bottom: 12px !important; }
.content > .paginator { margin-bottom: 6px; }

/* ---------- chart legend (peak / average) ---------- */
/* HTML, not baked into the SVG at fixed coordinates, so localized labels never overlap. */
.chart-legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    max-width: 760px;
    margin: 4px 0 8px;
    font-size: 12px;
    color: var(--ink-500);
}

.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.chart-legend-dot {
    width: 11px;
    height: 11px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}

/* =====================================================================
   Responsive — narrow / mobile (matches the layout breakpoint)
   ===================================================================== */
@media (max-width: 900.98px) {
    /* Wide data tables scroll horizontally inside their own box instead of overflowing the page,
       so no column is ever cut off on a phone. (Validated: 8-col table → internal scroll.) */
    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    /* Tables carry an inline desktop max-width; let them use the full width on mobile. */
    .content .table,
    .content table.table {
        max-width: 100% !important;
    }

    /* Charts and the stacked bar are already fluid (max-width + 100%); keep them from forcing width. */
    .content svg,
    .app-depots-panel,
    .dc-cards { max-width: 100% !important; }

    .card-body { padding: 16px 16px; }

    /* Big KPI numbers never overflow their card on a narrow screen. */
    .kpi { padding: 16px 16px 14px; }
    .kpi .kpi-value { font-size: 25px; }

    /* Tooltip popovers fit within the viewport. */
    .help-tip-popover { max-width: calc(100vw - 28px); }

    /* Form fields stack full-width instead of two cramped columns per row. */
    .card-body .col-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}
