/* ============================================================
   VIManager — single global stylesheet (no scoped .razor.css)
   All rules namespaced under .vi-root so nothing leaks to the
   rest of the app and Bootstrap/Mud can't reach in.
   Link once from the host page:  <link href="css/vimanager.css" />
   Palette lifted from the client's BlueGold theme.
   ============================================================ */

:root {
    --vi-primary: #1E3A8A;
    --vi-primary-dark: #152C68;
    --vi-gold: #FFD700;
    --vi-gold-muted: #C4B998;
    --vi-ground: #FDF8E4;
    --vi-surface: #FFFFFF;
    --vi-surface-alt: #FAF6E8;
    --vi-text: #1A1A1A;
    --vi-text-secondary: #5A5A52;
    --vi-text-on-primary: #FFFFFF;
    --vi-success: #28A745;
    --vi-warning: #FFC107;
    --vi-error: #DC3545;
    --vi-info: #17A2B8;
    --vi-font-body: "Roboto", system-ui, sans-serif;
    --vi-font-data: "Roboto Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
    --vi-radius: 6px;
    --vi-radius-sm: 4px;
    --vi-gap: 12px;
    --vi-gap-lg: 20px;
    --vi-shadow: 0 1px 3px rgba(30, 58, 138, 0.10);
    --vi-shadow-lg: 0 4px 14px rgba(30, 58, 138, 0.14);
}

/* ---------- root + base ---------- */
.vi-root {
    font-family: var(--vi-font-body);
    color: var(--vi-text);
    background: var(--vi-ground);
    height: 100%;
    box-sizing: border-box;
}

    .vi-root *,
    .vi-root *::before,
    .vi-root *::after {
        box-sizing: inherit;
    }

    .vi-root .vi-data {
        font-family: var(--vi-font-data);
        letter-spacing: -0.01em;
    }

    /* ---------- buttons ---------- */
    .vi-root .vi-btn {
        font-family: var(--vi-font-body);
        font-weight: 600;
        font-size: 0.9rem;
        line-height: 1.2;
        border: none;
        border-radius: var(--vi-radius-sm);
        padding: 9px 18px;
        cursor: pointer;
        background: var(--vi-primary);
        color: var(--vi-text-on-primary);
        transition: background 0.12s ease;
    }

        .vi-root .vi-btn:hover {
            background: var(--vi-primary-dark);
        }

        .vi-root .vi-btn:focus-visible {
            outline: 3px solid var(--vi-gold);
            outline-offset: 1px;
        }

    .vi-root .vi-btn--ghost {
        background: transparent;
        color: var(--vi-primary);
        border: 1px solid var(--vi-primary);
    }

        .vi-root .vi-btn--ghost:hover {
            background: rgba(30, 58, 138, 0.06);
        }

    .vi-root .vi-btn:disabled {
        opacity: 0.6;
        cursor: default;
    }

    /* ---------- shell: top bar ---------- */
    .vi-root .bar {
        display: flex;
        align-items: center;
        gap: 16px;
        padding: 14px 20px;
        background: var(--vi-surface);
        border-bottom: 2px solid var(--vi-gold);
        box-shadow: var(--vi-shadow);
        position: sticky;
        top: 0;
        z-index: 10;
    }

        .vi-root .bar h1 {
            font-size: 1.15rem;
            font-weight: 700;
            color: var(--vi-primary);
            margin: 0;
        }

    .vi-root .edit-title {
        flex: 1;
    }

    .vi-root .muted {
        color: var(--vi-text-secondary);
        padding: 24px 20px;
    }

    .vi-root .empty {
        text-align: center;
        padding: 60px 20px;
        color: var(--vi-text-secondary);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 14px;
    }

    .vi-root .banner {
        margin: 12px 20px 0;
        padding: 10px 14px;
        border-radius: var(--vi-radius-sm);
        font-size: 0.88rem;
    }

        .vi-root .banner.error {
            background: rgba(220, 53, 69, 0.10);
            border: 1px solid var(--vi-error);
            color: var(--vi-error);
        }

    /* ---------- list table ---------- */
    .vi-root .table-wrap {
        padding: 16px 20px;
        overflow-x: auto;
    }

    .vi-root table.list {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
        background: var(--vi-surface);
    }

        .vi-root table.list thead th {
            text-align: left;
            font-size: 0.72rem;
            font-weight: 700;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            color: var(--vi-text-on-primary);
            background: var(--vi-primary);
            padding: 10px 14px;
            white-space: nowrap;
        }

            .vi-root table.list thead th.num {
                text-align: right;
            }

        .vi-root table.list tbody td {
            padding: 9px 14px;
            border-bottom: 1px solid rgba(196, 185, 152, 0.4);
            font-size: 0.9rem;
        }

            .vi-root table.list tbody td.num {
                text-align: right;
            }

        .vi-root table.list tbody tr:nth-child(even) {
            background: var(--vi-surface-alt);
        }

        .vi-root table.list tbody tr:hover {
            background: rgba(255, 215, 0, 0.10);
        }

    .vi-root td.actions {
        text-align: right;
        white-space: nowrap;
    }

    /* ---------- Core section ---------- */
    .vi-root .core {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 320px;
        gap: var(--vi-gap-lg);
        align-items: start;
        padding: 20px;
    }

    .vi-root .editable {
        min-width: 0;
    }

    .vi-root .eyebrow {
        font-size: 0.72rem;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--vi-primary);
        margin: 0 0 10px;
        padding-bottom: 6px;
        border-bottom: 2px solid var(--vi-gold);
    }

        .vi-root .eyebrow:not(:first-child) {
            margin-top: 24px;
        }

    .vi-root .grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
        gap: var(--vi-gap);
    }

    .vi-root .field {
        display: flex;
        flex-direction: column;
        gap: 4px;
        min-width: 0;
    }

        .vi-root .field.wide {
            grid-column: 1 / -1;
        }

        .vi-root .field > span {
            font-size: 0.72rem;
            font-weight: 600;
            color: var(--vi-text-secondary);
            letter-spacing: 0.02em;
        }

        /* inputs — specificity (.vi-root .field tag) beats Bootstrap's bare element rules */
        .vi-root .field input,
        .vi-root .field select,
        .vi-root .field textarea {
            font-family: var(--vi-font-body);
            font-size: 0.92rem;
            color: var(--vi-text);
            background: var(--vi-surface);
            border: 1px solid var(--vi-gold-muted);
            border-radius: var(--vi-radius-sm);
            padding: 8px 10px;
            width: 100%;
            transition: border-color 0.12s ease, box-shadow 0.12s ease;
        }

            .vi-root .field input.vi-data {
                font-family: var(--vi-font-data);
            }

            .vi-root .field input.upper {
                text-transform: uppercase;
            }

            .vi-root .field input:focus,
            .vi-root .field select:focus,
            .vi-root .field textarea:focus {
                outline: none;
                border-color: var(--vi-primary);
                box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.15);
            }

    .vi-root .notes {
        margin-top: 16px;
    }

        .vi-root .notes textarea {
            resize: vertical;
        }

    /* ---------- DVLA spec plate ---------- */
    .vi-root .plate {
        position: sticky;
        top: 12px;
        background: var(--vi-surface-alt);
        border: 2px solid var(--vi-gold-muted);
        border-radius: var(--vi-radius);
        box-shadow: var(--vi-shadow);
        overflow: hidden;
    }

    .vi-root .plate-head {
        display: flex;
        flex-direction: column;
        gap: 2px;
        padding: 10px 14px;
        background: var(--vi-primary);
        color: var(--vi-text-on-primary);
    }

    .vi-root .plate-title {
        font-size: 0.78rem;
        font-weight: 700;
        letter-spacing: 0.1em;
        text-transform: uppercase;
    }

    .vi-root .plate-note {
        font-size: 0.66rem;
        opacity: 0.75;
    }

    .vi-root .plate-grid {
        margin: 0;
        padding: 6px 0;
    }

    .vi-root .plate-row {
        display: flex;
        justify-content: space-between;
        gap: 10px;
        padding: 5px 14px;
    }

        .vi-root .plate-row:nth-child(odd) {
            background: rgba(196, 185, 152, 0.12);
        }

        .vi-root .plate-row dt {
            font-size: 0.72rem;
            color: var(--vi-text-secondary);
            white-space: nowrap;
        }

        .vi-root .plate-row dd {
            margin: 0;
            font-size: 0.78rem;
            color: var(--vi-text);
            text-align: right;
            word-break: break-word;
        }

/* ---------- responsive ---------- */
@media (max-width: 880px) {
    .vi-root .core {
        grid-template-columns: 1fr;
    }

    .vi-root .plate {
        position: static;
    }
}

@media (prefers-reduced-motion: reduce) {
    .vi-root * {
        transition: none !important;
        animation: none !important;
    }
}

/* ---------- transient "Saved" confirmation (edit header) ---------- */
.vi-root .saved-flash {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--vi-success);
    padding: 4px 10px;
    border: 1px solid var(--vi-success);
    border-radius: var(--vi-radius-sm);
    background: rgba(40, 167, 69, 0.08);
    animation: vi-fade-in 0.15s ease;
}

@keyframes vi-fade-in {
    from {
        opacity: 0;
        transform: translateY(-2px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- list: sortable headers ---------- */
.vi-root table.list thead th.sortable {
    cursor: pointer;
    user-select: none;
}

    .vi-root table.list thead th.sortable:hover {
        background: var(--vi-primary-dark);
    }

.vi-root .sort-arrow {
    margin-left: 4px;
    color: var(--vi-gold);
}

/* ---------- list: bool icons ---------- */
.vi-root .icon {
    font-weight: 700;
}

    .vi-root .icon.ok {
        color: var(--vi-success);
    }

    .vi-root .icon.no {
        color: var(--vi-error);
    }

/* ---------- list: chips (MOT result, days) ---------- */
.vi-root .chip {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    color: #fff;
    white-space: nowrap;
}

.vi-root .chip-ok {
    background: var(--vi-success);
}

.vi-root .chip-warn {
    background: var(--vi-warning);
    color: #4a3a00;
}

.vi-root .chip-bad {
    background: var(--vi-error);
}

/* UKVD pull-age chips (table): fresh ≤7d green, stale ≤30d yellow, old >30d orange, never grey */
.vi-root .chip-age-fresh {
    background: #16A34A;
    color: #fff;
}

.vi-root .chip-age-stale {
    background: #FACC15;
    color: #4a3a00;
}

.vi-root .chip-age-old {
    background: #C2410C;
    color: #fff;
}

.vi-root .chip-age-never {
    background: #9CA3AF;
    color: #fff;
}

/* ===== ContactEditor (native supplier/buyer picker) ===== */
.vi-root .contact-editor {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.vi-root .ce-search {
    position: relative;
}

.vi-root .ce-search-box {
    position: relative;
    display: flex;
    align-items: center;
}

    .vi-root .ce-search-box input {
        width: 100%;
        padding-right: 28px;
    }

.vi-root .ce-clear {
    position: absolute;
    right: 6px;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: var(--vi-text-secondary);
    font-size: 0.85rem;
    line-height: 1;
    padding: 2px 4px;
}

    .vi-root .ce-clear:hover {
        color: var(--vi-error);
    }

.vi-root .ce-results {
    position: absolute;
    z-index: 30;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--vi-surface);
    border: 1px solid var(--vi-gold-muted);
    border-radius: var(--vi-radius-sm);
    box-shadow: 0 6px 20px rgba(0,0,0,0.14);
    max-height: 280px;
    overflow: auto;
}

.vi-root .ce-result {
    display: flex;
    flex-direction: column;
    gap: 1px;
    width: 100%;
    text-align: left;
    border: 0;
    border-bottom: 1px solid var(--vi-surface-alt);
    background: transparent;
    padding: 8px 12px;
    cursor: pointer;
    font-family: var(--vi-font-body);
}

    .vi-root .ce-result:last-child {
        border-bottom: 0;
    }

    .vi-root .ce-result:hover {
        background: var(--vi-surface-alt);
    }

.vi-root .ce-result-name {
    font-weight: 600;
    color: var(--vi-text);
    font-size: 0.86rem;
}

.vi-root .ce-result-sub {
    font-size: 0.74rem;
    color: var(--vi-text-secondary);
}

    .vi-root .ce-result-sub.muted {
        opacity: 0.8;
    }

.vi-root .ce-result-add {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    color: var(--vi-primary);
    font-weight: 600;
    background: var(--vi-surface-alt);
}

    .vi-root .ce-result-add strong {
        font-weight: 800;
    }

.vi-root .ce-add-plus {
    font-weight: 800;
}

.vi-root .ce-fields {
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 10px;
}

    .vi-root .ce-fields .ce-wide {
        grid-column: 1 / -1;
    }

.vi-root .ce-hint {
    font-size: 0.68rem;
}

    .vi-root .ce-hint.muted {
        color: var(--vi-text-secondary);
    }

.vi-root .ce-bank .ce-collapse {
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font: inherit;
}

.vi-root .ce-chev {
    color: var(--vi-text-secondary);
}

.vi-root .ce-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 18px;
}

.vi-root .ce-saved {
    color: var(--vi-success);
    font-size: 0.78rem;
    font-weight: 600;
}

.vi-root .ce-err {
    color: var(--vi-error);
    font-size: 0.78rem;
}

@media (max-width: 768px) {
    .vi-root .ce-fields {
        grid-template-columns: 1fr;
    }
}

/* ===== inline toggle switch (list Received column) ===== */
.vi-root .vi-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

    .vi-root .vi-switch input {
        position: absolute;
        opacity: 0;
        width: 0;
        height: 0;
    }

.vi-root .vi-switch-track {
    width: 34px;
    height: 18px;
    border-radius: 999px;
    background: #C7C7C0;
    transition: background 0.15s ease;
    position: relative;
    display: inline-block;
}

    .vi-root .vi-switch-track::after {
        content: "";
        position: absolute;
        top: 2px;
        left: 2px;
        width: 14px;
        height: 14px;
        border-radius: 50%;
        background: #fff;
        transition: transform 0.15s ease;
        box-shadow: 0 1px 2px rgba(0,0,0,0.3);
    }

.vi-root .vi-switch input:checked + .vi-switch-track {
    background: var(--vi-success, #16A34A);
}

    .vi-root .vi-switch input:checked + .vi-switch-track::after {
        transform: translateX(16px);
    }

.vi-root .vi-switch input:focus-visible + .vi-switch-track {
    outline: 2px solid var(--vi-primary);
    outline-offset: 1px;
}

/* ---------- search bar ---------- */
.vi-root .searchbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px 0;
    flex-wrap: wrap;
}

.vi-root .search-field {
    position: relative;
    flex: 1;
    min-width: 260px;
    max-width: 560px;
}

    .vi-root .search-field input {
        width: 100%;
        font-family: var(--vi-font-body);
        font-size: 0.95rem;
        text-transform: uppercase;
        padding: 9px 36px 9px 12px;
        border: 1px solid var(--vi-gold-muted);
        border-radius: var(--vi-radius-sm);
        background: var(--vi-surface);
    }

        .vi-root .search-field input:focus {
            outline: none;
            border-color: var(--vi-primary);
            box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.15);
        }

.vi-root .search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--vi-primary);
    font-size: 1.1rem;
    line-height: 1;
    padding: 4px 6px;
}

.vi-root .dvla-btn {
    background: var(--vi-gold);
    color: #3a2f00;
}

    .vi-root .dvla-btn:hover {
        background: #e6c200;
    }

/* ---------- classification tabs ---------- */
.vi-root .tabs {
    display: flex;
    gap: 2px;
    padding: 12px 20px 0;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--vi-gold-muted);
}

.vi-root .tab {
    border: none;
    background: transparent;
    font-family: var(--vi-font-body);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--vi-text-secondary);
    padding: 8px 16px;
    cursor: pointer;
    border-radius: var(--vi-radius-sm) var(--vi-radius-sm) 0 0;
    border-bottom: 3px solid transparent;
}

    .vi-root .tab:hover {
        color: var(--vi-primary);
        background: rgba(30,58,138,0.05);
    }

    .vi-root .tab.active {
        color: var(--vi-primary);
        border-bottom-color: var(--vi-gold);
        background: var(--vi-surface);
    }

    .vi-root .tab .count {
        opacity: 0.6;
        font-weight: 400;
        margin-left: 4px;
    }

.vi-root .toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 12px 20px 0;
}

    .vi-root .toolbar .spacer {
        flex: 1;
    }

.vi-root .toggle-on {
    background: var(--vi-warning);
    color: #4a3a00;
}



/* When VIManager owns the page, remove MudMainContent's top padding so the shell's
   calc(100vh - appbar) maps exactly to the visible area and nothing overflows.
   Targets Mud's main content wrapper. If your app bar isn't 64px, change both numbers. */
.mud-main-content:has(.vi-list-shell),
.mud-main-content:has(.vi-edit-shell) {
    padding-top: 64px; /* keep clearing the app bar */
    height: 100vh;
    box-sizing: border-box;
    overflow: hidden;
}

/* ---- MainLayout host: bound MudMainContent so pages fill it (no page scroll) ---- */
.vi-main-content {
    height: 100vh;
    box-sizing: border-box;
    overflow: hidden;
}

    .vi-main-content .vi-body-host {
        height: 100%;
        overflow: hidden;
    }

/* ============================================================
   LAYOUT v2 — sticky ribbon + sticky tabs + scrolling list
   ============================================================ */

/* list shell fills the viewport below the app bar; only .list-scroll scrolls */
.vi-root .vi-list-shell,
.vi-root .vi-edit-shell {
    display: flex;
    flex-direction: column;
    /* parent .mud-main-content is bounded to 100vh (border-box) with 64px top
       padding, so its content box = 100vh - 64px. We fill it. */
    height: 100%;
    overflow: hidden;
}

/* ---- command ribbon ---- */
.vi-root .ribbon {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--vi-surface);
    border-bottom: 2px solid var(--vi-gold);
    box-shadow: var(--vi-shadow);
    flex: 0 0 auto;
    z-index: 20;
}

/* mobile: let the ribbon break into two rows — context on top, actions below */
@media (max-width: 768px) {
    .vi-root .ribbon {
        flex-wrap: wrap;
        row-gap: 8px;
    }
        /* the spacer becomes a full-width line break, pushing the action buttons to row 2 */
        .vi-root .ribbon .ribbon-spacer {
            flex-basis: 100%;
            height: 0;
        }
        /* action buttons share row 2 evenly and stay tappable */
        .vi-root .ribbon .dvla-btn,
        .vi-root .ribbon .vi-btn {
            flex: 1 1 auto;
            white-space: nowrap;
        }
        /* Back sits alone on row 1 — don't let it stretch across the row */
        .vi-root .ribbon > .vi-btn:first-child {
            flex: 0 0 auto;
        }
        /* keep the title from forcing a wrap mid-context-row */
        .vi-root .ribbon .ribbon-title {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
        }
}

.vi-root .ribbon-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--vi-primary);
    white-space: nowrap;
}

.vi-root .ribbon-spacer {
    flex: 1;
}

.vi-root .ribbon-search {
    position: relative;
    flex: 1 1 320px;
    max-width: 520px;
    min-width: 180px;
}

    .vi-root .ribbon-search input {
        width: 100%;
        font-family: var(--vi-font-body);
        font-size: 0.92rem;
        text-transform: uppercase;
        padding: 8px 34px 8px 12px;
        border: 1px solid var(--vi-gold-muted);
        border-radius: var(--vi-radius-sm);
        background: var(--vi-surface);
    }

        .vi-root .ribbon-search input:focus {
            outline: none;
            border-color: var(--vi-primary);
            box-shadow: 0 0 0 3px rgba(30,58,138,0.15);
        }

.vi-root .search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--vi-primary);
    font-size: 1rem;
    padding: 4px 6px;
}

.vi-root .dvla-btn {
    background: var(--vi-gold);
    color: #3a2f00;
}

    .vi-root .dvla-btn:hover {
        background: #e6c200;
    }

.vi-root .toggle-on {
    background: var(--vi-warning);
    color: #4a3a00;
}

/* overflow menu */
.vi-root .ribbon-menu {
    position: relative;
}

.vi-root .menu-pop {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--vi-surface);
    border: 1px solid var(--vi-gold-muted);
    border-radius: var(--vi-radius-sm);
    box-shadow: var(--vi-shadow-lg);
    z-index: 40;
    min-width: 220px;
}

    .vi-root .menu-pop button {
        display: block;
        width: 100%;
        text-align: left;
        border: none;
        background: transparent;
        cursor: pointer;
        padding: 10px 14px;
        font-size: 0.88rem;
        color: var(--vi-text);
    }

        .vi-root .menu-pop button:hover {
            background: rgba(30,58,138,0.06);
        }

/* ---- sticky tab row ---- */
.vi-root .tabs {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    padding: 0 16px;
    background: var(--vi-ground);
    border-bottom: 2px solid var(--vi-gold-muted);
    flex: 0 0 auto;
    z-index: 15;
}

.vi-root .tab {
    border: none;
    background: transparent;
    font-family: var(--vi-font-body);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--vi-text-secondary);
    padding: 9px 16px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
}

    .vi-root .tab:hover {
        color: var(--vi-primary);
    }

    .vi-root .tab.active {
        color: var(--vi-primary);
        border-bottom-color: var(--vi-gold);
        background: var(--vi-surface);
    }

    .vi-root .tab .count {
        opacity: 0.6;
        font-weight: 400;
        margin-left: 4px;
    }

/* ---- scrolling list container ---- */
.vi-root .list-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 0;
}
    /* table header sticks within the scroll container */
    .vi-root .list-scroll table.list {
        border-collapse: separate;
        border-spacing: 0;
    }

        .vi-root .list-scroll table.list thead th {
            position: -webkit-sticky;
            position: sticky;
            top: 0;
            z-index: 5;
            background: var(--vi-primary); /* opaque so rows don't show through while scrolling */
        }

    .vi-root .list-scroll .table-wrap {
        padding: 0;
        overflow: visible;
        background: var(--vi-surface);
        border-radius: var(--vi-radius);
        box-shadow: var(--vi-shadow);
    }

/* ---- edit scroll ---- */
.vi-root .edit-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 0 20px 16px;
}

.vi-root .cfg-block {
    margin-bottom: 18px;
}

.vi-root .cfg-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--vi-primary);
    margin-bottom: 8px;
}

/* ============================================================
   CONFIG CARDS (selector + filter grid)
   ============================================================ */
.vi-root .cfg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 8px;
}

    .vi-root .cfg-grid.compact {
        grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    }

.vi-root .cfg-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 6px;
    background: var(--vi-surface);
    border: 1px solid var(--vi-gold-muted);
    border-radius: var(--vi-radius);
    cursor: pointer;
    transition: border-color 0.12s, box-shadow 0.12s, transform 0.08s;
}

    .vi-root .cfg-card:hover {
        border-color: var(--vi-primary);
        transform: translateY(-1px);
    }

    .vi-root .cfg-card img {
        width: 48px;
        height: 48px;
        object-fit: contain;
    }

.vi-root .cfg-grid.compact .cfg-card img {
    width: 36px;
    height: 36px;
}

.vi-root .cfg-card span {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--vi-text-secondary);
    text-align: center;
    line-height: 1.1;
}

.vi-root .cfg-card.chosen {
    border-color: var(--vi-primary);
    box-shadow: 0 0 0 2px var(--vi-gold) inset;
    background: var(--vi-surface-alt);
}

.vi-root .cfg-card.single {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    max-width: 320px;
    padding: 12px 16px;
}

    .vi-root .cfg-card.single img {
        width: 40px;
        height: 40px;
    }

    .vi-root .cfg-card.single span {
        font-size: 0.95rem;
        color: var(--vi-text);
    }

.vi-root .cfg-change {
    margin-left: auto;
    font-size: 0.7rem !important;
    color: var(--vi-primary) !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============================================================
   FILTER DRAWER
   ============================================================ */
.vi-root .drawer-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s;
    z-index: 90;
}

    .vi-root .drawer-scrim.open {
        opacity: 1;
        pointer-events: auto;
    }

.vi-root .drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 360px;
    max-width: 90vw;
    background: var(--vi-ground);
    border-left: 2px solid var(--vi-gold);
    box-shadow: var(--vi-shadow-lg);
    transform: translateX(100%);
    transition: transform 0.2s ease;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

    .vi-root .drawer.open {
        transform: translateX(0);
    }

.vi-root .drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--vi-primary);
    color: #fff;
    font-weight: 700;
    flex: 0 0 auto;
}

.vi-root .drawer-x {
    border: none;
    background: transparent;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
}

.vi-root .drawer-body {
    flex: 1 1 auto;
    overflow: auto;
    padding: 16px;
}

    .vi-root .drawer-body section {
        margin-bottom: 22px;
    }

    .vi-root .drawer-body h4 {
        font-size: 0.74rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--vi-primary);
        margin: 0 0 10px;
    }

.vi-root .drawer-search {
    width: 100%;
    padding: 7px 10px;
    margin-bottom: 8px;
    border: 1px solid var(--vi-gold-muted);
    border-radius: var(--vi-radius-sm);
}

.vi-root .supplier-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 260px;
    overflow: auto;
}

.vi-root .supplier-row {
    text-align: left;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 7px 10px;
    border-radius: var(--vi-radius-sm);
    font-size: 0.85rem;
    color: var(--vi-text);
}

    .vi-root .supplier-row:hover {
        background: rgba(30,58,138,0.06);
    }

    .vi-root .supplier-row.chosen {
        background: var(--vi-primary);
        color: #fff;
    }

.vi-root .drawer-foot {
    flex: 0 0 auto;
    padding: 12px 16px;
    border-top: 1px solid var(--vi-gold-muted);
}

/* ============================================================
   CORE SECTION v2 — image aside + collapsible spec cards
   ============================================================ */
.vi-root .core2 {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: var(--vi-gap-lg);
    align-items: start;
    padding: 4px;
}

/* ---- left aside: image + headline ---- */
.vi-root .core-aside {
    position: sticky;
    top: 4px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.vi-root .img-wrap {
    position: relative;
    border: 2px solid var(--vi-gold-muted);
    border-radius: var(--vi-radius);
    overflow: hidden;
    background: var(--vi-surface);
    box-shadow: var(--vi-shadow);
}

.vi-root .vehicle-img {
    display: block;
    width: 100%;
    height: 200px;
    object-fit: cover;
}

    .vi-root .vehicle-img.placeholder {
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--vi-text-secondary);
        background: var(--vi-surface-alt);
        font-size: 0.85rem;
    }

.vi-root .img-change {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border: none;
    cursor: pointer;
    background: rgba(30,58,138,0.85);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 7px;
    transition: background 0.12s;
}

    .vi-root .img-change:hover {
        background: var(--vi-primary);
    }

.vi-root .headline {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 12px;
    background: var(--vi-surface);
    border: 1px solid var(--vi-gold-muted);
    border-radius: var(--vi-radius);
}

.vi-root .hl-make {
    font-size: 1.0rem;
    font-weight: 700;
    color: var(--vi-primary);
}

.vi-root .hl-reg {
    font-size: 0.85rem;
    color: var(--vi-text-secondary);
}

/* ---- right: collapsible cards ---- */
.vi-root .core-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.vi-root .card {
    border: 1px solid var(--vi-gold-muted);
    border-radius: var(--vi-radius);
    background: var(--vi-surface);
    box-shadow: var(--vi-shadow);
    overflow: hidden;
}

.vi-root .card-head {
    width: 100%;
    text-align: left;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--vi-primary);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 10px 14px;
}

    .vi-root .card-head:hover {
        background: var(--vi-primary-dark);
    }

.vi-root .card-chevron {
    color: var(--vi-gold);
    font-size: 0.9rem;
}

.vi-root .card-body {
    padding: 14px;
}

/* ---- field grid (shared by editable + readonly) ---- */
.vi-root .core2 .grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.vi-root .core2 .field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

    .vi-root .core2 .field.wide {
        grid-column: 1 / -1;
    }

    .vi-root .core2 .field > span {
        font-size: 0.7rem;
        font-weight: 600;
        color: var(--vi-text-secondary);
        letter-spacing: 0.02em;
    }

    .vi-root .core2 .field input,
    .vi-root .core2 .field select,
    .vi-root .core2 .field textarea {
        font-family: var(--vi-font-body);
        font-size: 0.9rem;
        color: var(--vi-text);
        background: var(--vi-surface);
        border: 1px solid var(--vi-gold-muted);
        border-radius: var(--vi-radius-sm);
        padding: 7px 9px;
        width: 100%;
        transition: border-color 0.12s, box-shadow 0.12s;
    }

        .vi-root .core2 .field input.vi-data {
            font-family: var(--vi-font-data);
        }

        .vi-root .core2 .field input.upper {
            text-transform: uppercase;
        }

        .vi-root .core2 .field input:focus,
        .vi-root .core2 .field select:focus,
        .vi-root .core2 .field textarea:focus {
            outline: none;
            border-color: var(--vi-primary);
            box-shadow: 0 0 0 3px rgba(30,58,138,0.15);
        }

    .vi-root .core2 .field textarea {
        resize: vertical;
    }

    /* ---- readonly (DVLA/UKVD) fields: the "stamped" treatment ---- */
    .vi-root .core2 .field.readonly .ro-value {
        font-size: 0.88rem;
        color: var(--vi-text);
        background: var(--vi-surface-alt);
        border: 1px dashed var(--vi-gold-muted);
        border-radius: var(--vi-radius-sm);
        padding: 7px 9px;
        min-height: 34px;
    }

@media (max-width: 820px) {
    .vi-root .core2 {
        grid-template-columns: 1fr;
    }

    .vi-root .core-aside {
        position: static;
        flex-direction: row;
    }

    .vi-root .img-wrap {
        flex: 1;
    }

    .vi-root .headline {
        flex: 1;
    }
}

/* ============================================================
   PLATE HISTORY — UK number-plate styled chips
   ============================================================ */
.vi-root .plate-history {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.vi-root .plate-row-hist {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* the plate itself: yellow ground, black FE-Schrift-like bold, blue GB band */
.vi-root .uk-plate {
    position: relative;
    display: inline-flex;
    align-items: center;
    background: #FFD400; /* UK rear-plate yellow */
    color: #111;
    font-family: var(--vi-font-data);
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: 0.06em;
    padding: 6px 12px 6px 26px; /* extra left for the band */
    border: 2px solid #111;
    border-radius: 6px;
    text-transform: uppercase;
    box-shadow: 0 1px 2px rgba(0,0,0,0.25);
    white-space: nowrap;
}
    /* blue GB band on the left edge */
    .vi-root .uk-plate::before {
        content: "GB";
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 18px;
        background: #063298; /* GB band blue */
        color: #FFD400;
        font-size: 0.5rem;
        font-weight: 700;
        display: flex;
        align-items: flex-end;
        justify-content: center;
        padding-bottom: 3px;
        border-radius: 3px 0 0 3px;
        letter-spacing: 0;
    }
    /* previous plate slightly muted so the current one reads as "now" */
    .vi-root .uk-plate.prev {
        background: #EBC700;
        opacity: 0.85;
    }

.vi-root .plate-arrow {
    color: var(--vi-text-secondary);
    font-size: 0.9rem;
}

.vi-root .plate-meta {
    font-size: 0.78rem;
    color: var(--vi-text-secondary);
}

.vi-root .plate-type {
    opacity: 0.7;
}

/* ---- ribbon classification picker ---- */
.vi-root .ribbon-class {
    font-family: var(--vi-font-body);
    font-size: 0.9rem;
    padding: 8px 10px;
    border: 1px solid var(--vi-gold-muted);
    border-radius: var(--vi-radius-sm);
    background: var(--vi-surface);
    color: var(--vi-text);
    max-width: 200px;
}

    .vi-root .ribbon-class:focus {
        outline: none;
        border-color: var(--vi-primary);
        box-shadow: 0 0 0 3px rgba(30,58,138,0.15);
    }
    /* highlight when a new vehicle still needs a classification */
    .vi-root .ribbon-class.needs-class {
        border-color: var(--vi-error);
        box-shadow: 0 0 0 2px rgba(220,53,69,0.15);
    }

/* ============================================================
   DIALOG — reusable modal shell + UKVD diff
   ============================================================ */
.vi-root .vi-dialog-backdrop,
.vi-dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15,23,42,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.vi-dialog {
    background: var(--vi-surface);
    border-radius: var(--vi-radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    width: 100%;
    overflow: hidden;
    font-family: var(--vi-font-body);
    color: var(--vi-text);
}

.vi-dialog--sm {
    max-width: 420px;
}

.vi-dialog--md {
    max-width: 640px;
}

.vi-dialog--lg {
    max-width: 880px;
}

.vi-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--vi-primary);
    color: #fff;
}

.vi-dialog-title {
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.vi-dialog-x {
    border: none;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
    width: 30px;
    height: 30px;
    border-radius: 6px;
}

    .vi-dialog-x:hover {
        background: rgba(255,255,255,0.15);
    }

.vi-dialog-body {
    padding: 16px 18px;
    overflow: auto;
}

.vi-dialog-foot {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 12px 18px;
    border-top: 1px solid var(--vi-gold-muted);
    background: var(--vi-surface-alt);
}

/* ---- diff specifics ---- */
.vi-diff-empty {
    padding: 20px;
    text-align: center;
    color: var(--vi-text-secondary);
}

.vi-diff-reg-alert {
    background: #FFF4D6;
    border: 1px solid var(--vi-gold);
    border-radius: var(--vi-radius-sm);
    padding: 10px 12px;
    margin-bottom: 14px;
    font-size: 0.88rem;
}

.vi-diff-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.vi-diff-count {
    font-size: 0.8rem;
    color: var(--vi-text-secondary);
    font-weight: 600;
}

.vi-diff-spacer {
    flex: 1;
}

.vi-btn--sm {
    padding: 5px 10px;
    font-size: 0.8rem;
}

.vi-diff-section {
    margin-bottom: 16px;
}

.vi-diff-section-head {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--vi-primary);
    padding: 4px 0;
    border-bottom: 2px solid var(--vi-gold-muted);
    margin-bottom: 6px;
}

.vi-diff-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

    .vi-diff-table thead th {
        text-align: left;
        font-size: 0.68rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--vi-text-secondary);
        font-weight: 700;
        padding: 4px 8px;
    }

    .vi-diff-table td {
        padding: 6px 8px;
        border-top: 1px solid var(--vi-surface-alt);
        vertical-align: top;
    }

.vi-diff-chk {
    width: 34px;
    text-align: center;
}

.vi-diff-label {
    font-weight: 600;
}

.vi-diff-cur {
    color: var(--vi-text-secondary);
}

.vi-diff-new {
    color: var(--vi-primary);
    font-weight: 600;
}

.vi-diff-blanking {
    background: #FFF7F2;
}

.vi-diff-warn {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.66rem;
    font-weight: 700;
    color: var(--vi-error);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ---- Identity plate strip (current + distinct historical plates) ---- */
.vi-root .plate-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}
/* greyed historical plates — still clearly plates, just de-emphasised */
.vi-root .uk-plate.faded {
    background: #E8E8E8;
    border-color: #9aa0a6;
    color: #5f6368;
    opacity: 0.9;
    font-size: 0.92rem;
    padding-top: 4px;
    padding-bottom: 4px;
}

    .vi-root .uk-plate.faded::before {
        background: #9aa0a6; /* grey band instead of GB blue */
        color: #E8E8E8;
    }

/* ============================================================
   EDIT SECTIONS — tabs (desktop) / accordion (mobile)
   ============================================================ */

/* ---- desktop: tab row ---- */
.vi-root .sec-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--vi-gold-muted);
    margin-bottom: 16px;
    /* stick to the top of the edit-scroll container as content scrolls under */
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--vi-ground);
    /* span the container's side padding so the opaque bar fully covers scrolling content */
    margin-left: -20px;
    margin-right: -20px;
    padding: 12px 20px 0;
}

.vi-root .sec-tab {
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: var(--vi-font-body);
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--vi-text-secondary);
    padding: 10px 18px;
    border-radius: var(--vi-radius-sm) var(--vi-radius-sm) 0 0;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

    .vi-root .sec-tab:hover {
        color: var(--vi-text);
        background: var(--vi-surface-alt);
    }

    .vi-root .sec-tab.active {
        color: var(--vi-primary);
        border-bottom-color: var(--vi-primary);
    }

/* ---- desktop: show only the active panel body; hide accordion headers ---- */
.vi-root .sec-acc-head {
    display: none;
}

.vi-root .sec-panel {
    display: none;
}

    .vi-root .sec-panel.tab-active {
        display: block;
    }

.vi-root .sec-stub {
    padding: 30px;
    text-align: center;
    color: var(--vi-text-secondary);
}

/* ============================================================
   MOBILE (<=768px): tabs become an accordion
   ============================================================ */
@media (max-width: 768px) {
    .vi-root .sec-tabs {
        display: none;
    }

    /* every panel is visible as an accordion item */
    .vi-root .sec-panel {
        display: block;
        border: 1px solid var(--vi-gold-muted);
        border-radius: var(--vi-radius-sm);
        margin-bottom: 8px;
        overflow: hidden;
    }

        .vi-root .sec-panel.tab-active {
            display: block;
        }
    /* no special desktop active on mobile */

    .vi-root .sec-acc-head {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        border: none;
        cursor: pointer;
        text-align: left;
        background: var(--vi-surface);
        padding: 12px 14px;
        font-family: var(--vi-font-body);
    }

    .vi-root .sec-acc-title {
        font-weight: 700;
        font-size: 0.9rem;
        color: var(--vi-primary);
        flex-shrink: 0;
    }

    .vi-root .sec-acc-summary {
        flex: 1;
        min-width: 0;
        font-size: 0.76rem;
        color: var(--vi-text-secondary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .vi-root .sec-acc-chevron {
        color: var(--vi-gold);
        flex-shrink: 0;
    }

    /* body hidden unless this panel is mobile-open */
    .vi-root .sec-body {
        display: none;
        padding: 4px 4px 8px;
    }

    .vi-root .sec-panel.mob-open .sec-body {
        display: block;
    }
}

/* ============================================================
   COMMS SECTION — timeline + composer + quick-actions
   ============================================================ */
.vi-root .comms {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.vi-root .comms-empty, .vi-root .comms-loading {
    padding: 24px;
    text-align: center;
    color: var(--vi-text-secondary);
}

/* ---- compose / quick-actions ---- */
.vi-root .comms-compose {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.vi-root .comms-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.vi-root .comms-quick-btn {
    width: auto;
}

.vi-root .comms-note {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.vi-root .comms-note-type {
    flex: 0 0 auto;
    max-width: 170px;
    border: 1px solid var(--vi-gold-muted);
    border-radius: var(--vi-radius-sm);
    padding: 8px 10px;
    background: var(--vi-surface);
    font-family: var(--vi-font-body);
}

.vi-root .comms-note-input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--vi-gold-muted);
    border-radius: var(--vi-radius-sm);
    padding: 8px 12px;
    font-family: var(--vi-font-body);
    font-size: 0.9rem;
}

    .vi-root .comms-note-input:focus, .vi-root .comms-note-type:focus {
        outline: none;
        border-color: var(--vi-primary);
        box-shadow: 0 0 0 3px rgba(30,58,138,0.15);
    }

.vi-root .comms-error {
    background: #FDECEA;
    border: 1px solid #E6A8A3;
    color: #9A342E;
    border-radius: var(--vi-radius-sm);
    padding: 8px 12px;
    font-size: 0.84rem;
    cursor: pointer;
}

/* ---- collection inline panel ---- */
.vi-root .comms-collection {
    border: 1px solid var(--vi-gold);
    border-radius: var(--vi-radius-sm);
    background: #FFFDF5;
    padding: 14px;
}

.vi-root .comms-collection-head {
    font-weight: 700;
    color: var(--vi-primary);
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.vi-root .comms-collection-actions, .vi-root .comms-edit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 10px;
}

/* ---- timeline ---- */
.vi-root .comms-thread {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.vi-root .comms-entry {
    border: 1px solid var(--vi-gold-muted);
    border-left: 4px solid var(--vi-gold-muted);
    border-radius: var(--vi-radius-sm);
    background: var(--vi-surface);
    padding: 10px 12px;
}

    .vi-root .comms-entry.open {
        border-left-color: var(--vi-primary);
    }

    .vi-root .comms-entry.resolved {
        opacity: 0.72;
    }

        .vi-root .comms-entry.resolved.open {
        }
    /* resolved beats open */
    .vi-root .comms-entry.overdue {
        border-left-color: var(--vi-error);
    }

.vi-root .comms-entry-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.vi-root .comms-entry-date {
    font-size: 0.76rem;
    color: var(--vi-text-secondary);
}

.vi-root .comms-entry-spacer {
    flex: 1;
}

.vi-root .comms-entry-subject {
    font-weight: 700;
    font-size: 0.92rem;
}

.vi-root .comms-entry-details {
    font-size: 0.88rem;
    white-space: pre-wrap;
    margin-top: 2px;
}

.vi-root .comms-entry-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    font-size: 0.78rem;
    color: var(--vi-text-secondary);
    margin-top: 6px;
}

.vi-root .comms-by {
    font-style: italic;
}

.vi-root .comms-followup {
    font-weight: 600;
}

    .vi-root .comms-followup.overdue {
        color: var(--vi-error);
    }

/* badges */
.vi-root .comms-badge {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 3px 8px;
    border-radius: 999px;
    color: #fff;
    white-space: nowrap;
}

.vi-root .badge-doc {
    background: #1E3A8A;
}

.vi-root .badge-delivery {
    background: #0F766E;
}

.vi-root .badge-recovery {
    background: #B45309;
}

.vi-root .badge-alert {
    background: #B91C1C;
}

.vi-root .badge-call {
    background: #6D28D9;
}

.vi-root .badge-default {
    background: #64748B;
}

/* resolve pill */
.vi-root .comms-pill {
    border: none;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

    .vi-root .comms-pill.is-open {
        background: #FEF3C7;
        color: #92400E;
    }

    .vi-root .comms-pill.is-resolved {
        background: #D1FAE5;
        color: #065F46;
    }

/* inline links */
.vi-root .comms-link {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--vi-primary);
}

    .vi-root .comms-link.danger {
        color: var(--vi-error);
    }

    .vi-root .comms-link:hover {
        text-decoration: underline;
    }

/* inline edit block */
.vi-root .comms-edit {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--vi-gold-muted);
}

/* ============================================================
   PURCHASE SECTION — two-column: work area + docked documents
   ============================================================ */
.vi-root .pur-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 16px;
    align-items: start;
}

.vi-root .pur-main {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-content: start;
    min-width: 0;
}
    /* full-row items: error banner, save bar (and Financials, which carries the wide cost box) */
    .vi-root .pur-main > .pur-error,
    .vi-root .pur-main > .pur-actions {
        grid-column: 1 / -1;
    }

.vi-root .pur-empty, .vi-root .pur-loading {
    padding: 24px;
    text-align: center;
    color: var(--vi-text-secondary);
}

.vi-root .pur-error {
    background: #FDECEA;
    border: 1px solid #E6A8A3;
    color: #9A342E;
    border-radius: var(--vi-radius-sm);
    padding: 8px 12px;
    font-size: 0.84rem;
    cursor: pointer;
}

/* card subheading (who vs where distinction) */
.vi-root .vi-card-sub {
    font-weight: 400;
    font-size: 0.74rem;
    color: var(--vi-text-secondary);
    text-transform: none;
    letter-spacing: 0;
    margin-left: 8px;
    font-style: italic;
}

/* integration slots */
.vi-root .pur-slot {
    padding: 4px 0;
}

.vi-root .pur-slot-note {
    font-size: 0.88rem;
    color: var(--vi-text);
}

.vi-root .pur-slot-hint {
    color: var(--vi-text-secondary);
    font-style: italic;
    font-size: 0.8rem;
    margin-left: 6px;
}

/* geocode status */
.vi-root .pur-geo-status {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

.vi-root .pur-geo {
    font-size: 0.82rem;
}

    .vi-root .pur-geo.busy {
        color: var(--vi-text-secondary);
        font-style: italic;
    }

    .vi-root .pur-geo.ok {
        color: var(--vi-primary);
        font-weight: 600;
    }

    .vi-root .pur-geo.coords {
        font-size: 0.72rem;
        color: var(--vi-text-secondary);
    }

/* financials: fields + invoice box side by side, wrapping on narrow */
.vi-root .pur-fin {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
}

.vi-root .pur-fin-fields {
    flex: 1 1 320px;
    min-width: 0;
}

.vi-root .pur-invoice {
    flex: 0 0 240px;
    background: #FFFDF5;
    border: 1px solid var(--vi-gold);
    border-radius: var(--vi-radius-sm);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.vi-root .pur-invoice-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--vi-text-secondary);
    margin-bottom: 4px;
}

.vi-root .pur-sum-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.86rem;
    gap: 12px;
}

    .vi-root .pur-sum-row.muted {
        color: var(--vi-text-secondary);
    }

    .vi-root .pur-sum-row.hero {
        font-weight: 700;
        color: var(--vi-primary);
        border-top: 1px solid var(--vi-gold-muted);
        padding-top: 6px;
        margin-top: 2px;
    }

    .vi-root .pur-sum-row.total {
        font-weight: 700;
        font-size: 1.02rem;
        border-top: 2px solid var(--vi-gold);
        padding-top: 6px;
        margin-top: 4px;
    }

/* status flags */
.vi-root .pur-flags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
}

.vi-root .pur-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    cursor: pointer;
}

    .vi-root .pur-check.warn {
        color: #B45309;
        font-weight: 600;
    }

.vi-root .field.inline {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

    .vi-root .field.inline span {
        white-space: nowrap;
    }

.vi-root .pur-notes {
    width: 100%;
    border: 1px solid var(--vi-gold-muted);
    border-radius: var(--vi-radius-sm);
    padding: 8px 10px;
    font-family: var(--vi-font-body);
    font-size: 0.9rem;
    resize: vertical;
}

.vi-root .pur-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0 8px;
}

.vi-root .pur-saving {
    color: var(--vi-text-secondary);
    font-size: 0.78rem;
}

.vi-root .pur-dirty {
    color: #B45309;
    font-size: 0.78rem;
    font-weight: 600;
}

.vi-root .pur-saved {
    color: #065F46;
    font-weight: 600;
    font-size: 0.86rem;
}

/* ---- documents dock: sticky, full height, inner scroll ---- */
.vi-root .pur-docs-dock {
    position: sticky;
    top: 46px;
    align-self: start;
    z-index: 10;
    height: calc(100vh - 220px);
    min-height: 360px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--vi-gold-muted);
    border-radius: var(--vi-radius-sm);
    background: var(--vi-surface);
    overflow: hidden;
}

.vi-root .pur-docs-head {
    flex: 0 0 auto;
    padding: 10px 14px;
    font-weight: 700;
    color: var(--vi-primary);
    border-bottom: 2px solid var(--vi-gold-muted);
    background: var(--vi-surface-alt);
    font-size: 0.9rem;
}

.vi-root .pur-docs-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px;
}

/* ---- mobile: collapse to single column, dock drops below ---- */
@media (max-width: 900px) {
    .vi-root .pur-layout {
        grid-template-columns: 1fr;
    }

    .vi-root .pur-docs-dock {
        position: static;
        height: auto;
        min-height: 0;
        order: 2;
    }

    .vi-root .pur-docs-body {
        max-height: 60vh;
    }

    .vi-root .pur-invoice {
        flex-basis: 100%;
    }
}
/* phones: cards stack one-up */
@media (max-width: 560px) {
    .vi-root .pur-main {
        grid-template-columns: 1fr;
    }
}

/* ---- Purchase cards reuse the .card primitive; pad their content like .card-body ---- */
.vi-root .pur-main .card > .pur-slot,
.vi-root .pur-main .card > .grid,
.vi-root .pur-main .card > .pur-fin,
.vi-root .pur-main .card > .pur-flags,
.vi-root .pur-main .card > .pur-notes {
    margin: 14px;
}

.vi-root .pur-main .card > .pur-notes {
    width: calc(100% - 28px);
}
/* subheading now sits on the blue card-head — make it readable (light, not muted-dark) */
.vi-root .card-head .vi-card-sub {
    color: rgba(255,255,255,0.75);
}

/* ============================================================
   LIST: thumbnails, view toggle, card scaffold
   ============================================================ */
/* tabs row holds group tabs (left) + view toggle (right) */
.vi-root .tabs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.vi-root .view-toggle {
    display: inline-flex;
    gap: 2px;
    flex-shrink: 0;
}

.vi-root .vt-btn {
    border: 1px solid var(--vi-gold-muted);
    background: var(--vi-surface);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 6px 10px;
    color: var(--vi-text-secondary);
}

    .vi-root .vt-btn:first-child {
        border-radius: var(--vi-radius-sm) 0 0 var(--vi-radius-sm);
    }

    .vi-root .vt-btn:last-child {
        border-radius: 0 var(--vi-radius-sm) var(--vi-radius-sm) 0;
        margin-left: -1px;
    }

    .vi-root .vt-btn.active {
        background: var(--vi-primary);
        color: #fff;
        border-color: var(--vi-primary);
    }

/* table thumbnail column */
.vi-root table.list th.thumb-col,
.vi-root table.list td.thumb-col {
    width: 56px;
    padding: 4px 6px;
}

.vi-root .row-thumb {
    width: 44px;
    height: 44px;
    border-radius: var(--vi-radius-sm);
    object-fit: cover;
    display: block;
    background: var(--vi-surface-alt);
}

.vi-root .row-thumb--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--vi-gold-muted);
    border: 1px dashed var(--vi-gold-muted);
}

/* NOTE: vehicle card-list styles now live in VehicleCardList.razor.css (scoped). */

/* ============================================================
   VEHICLE CARD LIST (card view) — global, .vi-root-scoped
   (kept here, not a .razor.css, to match the project's single-stylesheet approach)
   ============================================================ */
.vi-root .veh-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
    padding: 4px;
}

.vi-root .veh-card {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    border: 1px solid var(--vi-gold-muted);
    border-radius: var(--vi-radius);
    background: var(--vi-surface);
    box-shadow: var(--vi-shadow);
    overflow: hidden;
    transition: box-shadow 0.12s ease, transform 0.12s ease;
}

    .vi-root .veh-card:hover {
        box-shadow: 0 4px 14px rgba(30,58,138,0.18);
        transform: translateY(-1px);
    }

    .vi-root .veh-card .thumb {
        position: relative;
        width: 100%;
        aspect-ratio: 4 / 3;
        background: var(--vi-surface-alt);
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

        .vi-root .veh-card .thumb img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .vi-root .veh-card .thumb .placeholder {
            font-size: 2.6rem;
            color: var(--vi-gold-muted);
            opacity: 0.7;
        }

    .vi-root .veh-card .config-tag {
        position: absolute;
        left: 8px;
        bottom: 8px;
        background: rgba(30,58,138,0.88);
        color: #fff;
        font-size: 0.68rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        padding: 3px 8px;
        border-radius: 999px;
    }

    .vi-root .veh-card .body {
        padding: 10px 12px 12px;
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .vi-root .veh-card .plate {
        align-self: flex-start;
        background: #FFD300;
        color: #111;
        font-family: var(--vi-font-data);
        font-weight: 700;
        font-size: 1rem;
        letter-spacing: 0.06em;
        padding: 4px 10px;
        border-radius: 5px;
        border: 1px solid #C9A700;
        box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
        text-transform: uppercase;
        line-height: 1.1;
    }

    .vi-root .veh-card .make {
        font-size: 0.88rem;
        font-weight: 600;
        color: var(--vi-text);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .vi-root .veh-card .chips {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin-top: 2px;
    }

    .vi-root .veh-card .chip {
        font-size: 0.7rem;
        font-weight: 700;
        padding: 3px 8px;
        border-radius: 999px;
        white-space: nowrap;
        border: 1px solid transparent;
    }

        .vi-root .veh-card .chip.ok {
            background: #D1FAE5;
            color: #065F46;
            border-color: #A7F3D0;
        }

        .vi-root .veh-card .chip.soon {
            background: #FEF3C7;
            color: #92400E;
            border-color: #FDE68A;
        }

        .vi-root .veh-card .chip.expired {
            background: #FEE2E2;
            color: #991B1B;
            border-color: #FECACA;
        }

        .vi-root .veh-card .chip.sorn {
            background: #E0E7FF;
            color: #3730A3;
            border-color: #C7D2FE;
        }

        .vi-root .veh-card .chip.none {
            background: #F1F1F1;
            color: #6B7280;
            border-color: #E5E7EB;
        }

        .vi-root .veh-card .chip.age-fresh {
            background: #16A34A;
            color: #fff;
            border-color: #15803D;
        }

        .vi-root .veh-card .chip.age-stale {
            background: #FACC15;
            color: #4a3a00;
            border-color: #CA8A04;
        }

        .vi-root .veh-card .chip.age-old {
            background: #C2410C;
            color: #fff;
            border-color: #9A3412;
        }

        .vi-root .veh-card .chip.age-never {
            background: #9CA3AF;
            color: #fff;
            border-color: #6B7280;
        }

    /* card party (supplier/buyer) boxes — name + the money for that side */
    .vi-root .veh-card .party-box {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: baseline;
        gap: 6px;
        padding: 5px 8px;
        border-radius: var(--vi-radius-sm);
        font-size: 0.78rem;
        background: var(--vi-surface-alt);
        border-left: 3px solid var(--vi-gold-muted);
    }

        .vi-root .veh-card .party-box.supplier {
            border-left-color: #B45309;
        }

        .vi-root .veh-card .party-box.buyer {
            border-left-color: #0F766E;
        }

    .vi-root .veh-card .party-label {
        font-weight: 700;
        font-size: 0.64rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--vi-text-secondary);
    }

    .vi-root .veh-card .party-name {
        color: var(--vi-text);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }

    .vi-root .veh-card .party-money {
        font-weight: 700;
        color: var(--vi-primary);
        white-space: nowrap;
    }

    /* card ship-age line — small, under the thumbnail; colour matches the accent severity */
    .vi-root .veh-card .ship-age {
        padding: 4px 12px 0;
        font-size: 0.72rem;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

        .vi-root .veh-card .ship-age.accent-bol-green {
            color: #15803D;
            border: 0;
        }

        .vi-root .veh-card .ship-age.accent-bol-yellow {
            color: #A16207;
            border: 0;
        }

        .vi-root .veh-card .ship-age.accent-bol-orange {
            color: #C2410C;
            border: 0;
        }

        .vi-root .veh-card .ship-age.accent-bol-red {
            color: #DC2626;
            border: 0;
        }
