/* Neutral theme (default): the Wavechrome desktop apps' look - Chromoscope,
 * filmqr, ChromatiQ - for the portal. Light grey canvas, white cards with
 * hairline borders, one blue accent, colour only where it carries meaning
 * (status), large plain titles, grouped lists. Loaded after main.css and
 * mobile.css; ?theme=classic switches a browser back to the previous look.
 */

:root {
    --wc-bg: #f5f5f7;
    --wc-card: #ffffff;
    --wc-text: #1d1d1f;
    --wc-muted: #6e6e73;
    --wc-faint: #aeaeb2;
    --wc-hairline: #e3e3e8;
    --wc-fill: rgba(120, 120, 128, 0.12);      /* neutral control fill */
    --wc-fill-hover: rgba(120, 120, 128, 0.2);
    --wc-accent: #0071e3;
    --wc-accent-hover: #0077ed;
    --wc-accent-soft: #e8f1fd;
    --wc-ok: #1d7a3e;
    --wc-ok-soft: #e6f4ea;
    --wc-warn: #9a5b00;
    --wc-warn-soft: #fdf1dc;
    --wc-err: #c0392b;
    --wc-err-soft: #fdecea;
    --wc-radius: 12px;
    --wc-shadow: 0 1px 3px rgba(0, 0, 0, .04), 0 6px 20px rgba(0, 0, 0, .05);

    /* main.css tokens, pointed at the neutral palette */
    --primary-navy-900: #0058b0;
    --primary-navy-800: #0063c7;
    --primary-navy-700: var(--wc-accent);
    --primary-navy-600: var(--wc-accent-hover);
    --link-primary: var(--wc-accent);
    --link-hover: #0058b0;
    --bg-body: var(--wc-bg);
    --border-color: var(--wc-hairline);
    --text-primary: var(--wc-text);
    --text-secondary: var(--wc-muted);
    --chrome-ink: var(--wc-bg);
    --chrome-ink-well: var(--wc-bg);
    --wave-gold: var(--wc-accent);
    --wave-gold-soft: var(--wc-accent-soft);
    --accent-golden-light: var(--wc-fill);
    --accent-golden-dark: var(--wc-text);
    --accent-coral-light: var(--wc-fill);
    --accent-coral-dark: var(--wc-text);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-md: var(--wc-shadow);
    --bs-body-color: var(--wc-text);
    --bs-border-color: var(--wc-hairline);
    --bs-link-color: var(--wc-accent);
    --bs-link-color-rgb: 0, 113, 227;
    --bs-primary: var(--wc-accent);
    --bs-primary-rgb: 0, 113, 227;
}

body { background: var(--wc-bg) !important; color: var(--wc-text); -webkit-font-smoothing: antialiased; }
a { color: var(--wc-accent); }
.text-muted, .text-secondary { color: var(--wc-muted) !important; }
.text-primary { color: var(--wc-accent) !important; }
hr { border-color: var(--wc-hairline); opacity: 1; }

/* ---- Titles: large and plain, no leading icon ------------------------- */
#main-content h1, #main-content h2 { font-weight: 700; letter-spacing: -0.02em; }
#main-content h2 { font-size: 2rem; }
#main-content h3 { font-weight: 700; letter-spacing: -0.015em; }
#main-content :is(h1, h2, h3) > .bi:first-child { display: none; }
#main-content :is(h4, h5, h6) > .bi:first-child { color: var(--wc-muted); }

/* ---- Navigation: light sidebar, accent only on the current page ------- */
.app-sidebar {
    background: rgba(245, 245, 247, 0.92) !important;
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-right: 1px solid var(--wc-hairline) !important;
    box-shadow: none !important;
}
.app-sidebar,
.app-sidebar .sidebar-link,
.app-sidebar .sidebar-sublink,
.app-sidebar .sidebar-license-label,
.app-sidebar .sidebar-storage,
.app-sidebar .sidebar-storage *,
.app-sidebar .sidebar-user-menu a,
.app-sidebar [class*="sidebar-user"] { color: var(--wc-text) !important; }
.app-sidebar .sidebar-link i:first-child,
.app-sidebar .sidebar-sublink i { color: var(--wc-accent) !important; }
.app-sidebar .sidebar-chevron,
.app-sidebar .sidebar-license-label,
.app-sidebar .storage-header { color: var(--wc-muted) !important; }
.app-sidebar .sidebar-link:not(.is-active):hover,
.app-sidebar .sidebar-sublink:hover { background: var(--wc-fill) !important; }
.app-sidebar .sidebar-link.is-active,
.app-sidebar .sidebar-sublink.is-active {
    background: var(--wc-fill-hover) !important;
    color: var(--wc-text) !important;
    font-weight: 600;
    box-shadow: none !important;
}
.app-sidebar .sidebar-link,
.app-sidebar .sidebar-sublink { border-radius: 8px; margin: 1px 10px; border-left: 0 !important; }
.app-sidebar .sidebar-submenu,
.app-sidebar [class*="sidebar-footer"],
.app-sidebar [class*="sidebar-user"] { background: transparent !important; border-color: var(--wc-hairline) !important; }
.app-sidebar .sidebar-header,
.app-sidebar .sidebar-status { border-color: var(--wc-hairline) !important; }
.app-sidebar .sidebar-close { color: var(--wc-muted) !important; }
.app-sidebar .progress { background: var(--wc-fill); }
.app-sidebar .sidebar-storage:hover { background: var(--wc-fill) !important; }
.sidebar-overlay { background: rgba(0, 0, 0, 0.25); }

.mobile-header {
    background: rgba(245, 245, 247, 0.85) !important;
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--wc-hairline);
    box-shadow: none !important;
}
.mobile-header .mobile-header-btn { color: var(--wc-accent) !important; }

/* ---- Surfaces --------------------------------------------------------- */
.card {
    background: var(--wc-card);
    border: 1px solid var(--wc-hairline) !important;
    border-radius: var(--wc-radius) !important;
    box-shadow: none !important;
}
.card.shadow-sm, .card.shadow { box-shadow: var(--wc-shadow) !important; border-color: transparent !important; }
.card-header, .card-footer {
    background: transparent !important;
    border-color: var(--wc-hairline) !important;
    color: var(--wc-text) !important;
}
.card-header { border-bottom-width: 1px !important; }
.card-header :is(h4, h5, h6) { font-weight: 600; }
.hover-lift:hover { transform: none !important; background: #fafafa; }

/* Solid-colour cards (hierarchy counters and similar) become plain cards. */
.card:is(.bg-primary, .bg-success, .bg-info, .bg-warning, .bg-danger, .bg-secondary, .bg-dark),
.card :is(.card-body, .card-header):is(.bg-primary, .bg-success, .bg-info, .bg-warning, .bg-danger) {
    background: var(--wc-card) !important;
    color: var(--wc-text) !important;
}
.card:is(.bg-primary, .bg-success, .bg-info, .bg-warning, .bg-danger, .bg-secondary, .bg-dark) :is(.text-white, h1, h2, h3, h4, h5, h6, p, small, i) {
    color: inherit !important;
}
.card:is(.bg-primary, .bg-success, .bg-info, .bg-warning, .bg-danger) :is(h1, h2, h3, .display-4, .display-5, .display-6, .fs-1, .fs-2) {
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Dashboard tiles: one neutral treatment instead of gold and coral. */
.dashboard-action-icon {
    background: var(--wc-accent-soft) !important;
    color: var(--wc-accent) !important;
}
#main-content .p-2.rounded[style*="background"] {
    background: var(--wc-accent-soft) !important;
    color: var(--wc-accent) !important;
}
#main-content .p-2.rounded[style*="background"] * { color: inherit !important; }

/* ---- Buttons: pill shape, one filled accent, neutral fills otherwise -- */
.btn {
    border-radius: 980px !important;
    font-weight: 500;
    box-shadow: none !important;
    transform: none !important;
    transition: background .12s, color .12s;
}
.btn-lg { font-size: 1rem; padding: 0.55rem 1.25rem; }
.btn-primary,
.btn-primary:focus { background: var(--wc-accent) !important; border-color: var(--wc-accent) !important; color: #fff !important; }
.btn-primary:hover { background: var(--wc-accent-hover) !important; border-color: var(--wc-accent-hover) !important; }

.btn:is(.btn-secondary, .btn-light, .btn-outline-primary, .btn-outline-secondary, .btn-outline-info,
        .btn-outline-success, .btn-outline-dark, .btn-outline-warning, .btn-info, .btn-warning) {
    background: var(--wc-fill) !important;
    border-color: transparent !important;
    color: var(--wc-text) !important;
}
.btn:is(.btn-outline-primary, .btn-outline-info) { color: var(--wc-accent) !important; }
.btn:is(.btn-secondary, .btn-light, .btn-outline-primary, .btn-outline-secondary, .btn-outline-info,
        .btn-outline-success, .btn-outline-dark, .btn-outline-warning, .btn-info, .btn-warning):hover {
    background: var(--wc-fill-hover) !important;
}
/* Red stays for destructive actions only, and as text on a soft fill. */
.btn:is(.btn-danger, .btn-outline-danger) {
    background: var(--wc-err-soft) !important;
    border-color: transparent !important;
    color: var(--wc-err) !important;
}
.btn:is(.btn-danger, .btn-outline-danger):hover { background: #f9d9d5 !important; }
.btn-success { background: var(--wc-ok) !important; border-color: var(--wc-ok) !important; color: #fff !important; }
.btn-link { color: var(--wc-accent) !important; }

/* ---- Badges: soft tints, colour = meaning ----------------------------- */
.badge {
    font-weight: 600;
    border-radius: 6px;
    letter-spacing: 0;
}
.badge.bg-primary, .badge.bg-info, .badge.text-bg-primary, .badge.text-bg-info { background: var(--wc-accent-soft) !important; color: var(--wc-accent) !important; }
.badge.bg-success, .badge.text-bg-success { background: var(--wc-ok-soft) !important; color: var(--wc-ok) !important; }
.badge.bg-warning, .badge.text-bg-warning { background: var(--wc-warn-soft) !important; color: var(--wc-warn) !important; }
.badge.bg-danger, .badge.text-bg-danger { background: var(--wc-err-soft) !important; color: var(--wc-err) !important; }
.badge:is(.bg-secondary, .bg-dark, .bg-light, .text-bg-secondary, .text-bg-light) { background: var(--wc-fill) !important; color: #48484a !important; }
.badge[style*="background"] { background: var(--wc-fill) !important; color: #48484a !important; }

/* ---- Forms ------------------------------------------------------------ */
.form-control, .form-select {
    background-color: var(--wc-card);
    border: 1px solid var(--wc-hairline);
    border-radius: 10px;
    color: var(--wc-text);
}
.form-control:focus, .form-select:focus {
    border-color: var(--wc-accent);
    box-shadow: 0 0 0 3px var(--wc-accent-soft);
}
.form-label { font-weight: 600; font-size: 0.85rem; color: var(--wc-text); }
.form-text { color: var(--wc-muted); }
.input-group-text { background: var(--wc-bg); border-color: var(--wc-hairline); color: var(--wc-muted); }
.form-check-input:checked { background-color: var(--wc-accent); border-color: var(--wc-accent); }

/* ---- Tables and lists: hairlines, quiet headings ---------------------- */
.table { --bs-table-bg: transparent; --bs-table-striped-bg: transparent; --bs-table-hover-bg: #fafafa; color: var(--wc-text); }
.table > thead > tr > th,
.table thead th {
    background: transparent !important;
    color: var(--wc-muted) !important;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--wc-hairline) !important;
}
.table > :not(caption) > * > * { border-color: var(--wc-hairline); }
.table-light, .table-dark, thead.table-light, thead.table-dark { --bs-table-bg: transparent; --bs-table-color: var(--wc-muted); }

.list-group-item { border-color: var(--wc-hairline); }
.list-group-item-action:hover { background: #fafafa; }

/* ---- Alerts: soft, no side stripes ------------------------------------ */
.alert { border-radius: var(--wc-radius); border: 1px solid transparent; }
.alert-info, .alert-primary { background: var(--wc-accent-soft); color: #0b4a8f; border-color: #d4e6fb; }
.alert-success { background: var(--wc-ok-soft); color: #14532d; border-color: #cfe9d7; }
.alert-warning { background: var(--wc-warn-soft); color: #6b4300; border-color: #f3e0bd; }
.alert-danger { background: var(--wc-err-soft); color: #7a1c17; border-color: #f4d3cf; }

.progress { background: var(--wc-fill); border-radius: 980px; }
.progress-bar { background: var(--wc-accent); }

footer { background: transparent !important; border-top: 1px solid var(--wc-hairline); }
.nav-tabs .nav-link.active { color: var(--wc-text); border-color: var(--wc-hairline) var(--wc-hairline) var(--wc-card); }
.nav-pills .nav-link.active { background: var(--wc-fill-hover); color: var(--wc-text); }
.pagination .page-link { color: var(--wc-accent); border-color: var(--wc-hairline); }
.pagination .active > .page-link { background: var(--wc-accent); border-color: var(--wc-accent); color: #fff; }
.modal-content { border: 0; border-radius: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, .18); }

/* ---- Inventory tree: white rows, no green tint ------------------------- */
.hierarchy-tree .tree-item,
.hierarchy-tree .tree-item-has-batches {
    background: var(--wc-card) !important;
    border: 1px solid var(--wc-hairline) !important;
    border-radius: 10px;
}
.hierarchy-tree .tree-item:hover { background: #fafafa !important; }
.hierarchy-tree .tree-item-expanded { background: #fafafa !important; border-color: #d2d2d7 !important; }
.hierarchy-tree .text-success, .hierarchy-tree .text-primary, .hierarchy-tree .text-info { color: var(--wc-muted) !important; }

/* ---- Segmented controls (radio button groups), as in macOS/iOS -------- */
.btn-group:has(> .btn-check) {
    background: var(--wc-fill);
    border-radius: 9px;
    padding: 2px;
    gap: 2px;
}
.btn-group:has(> .btn-check) > .btn {
    border-radius: 7px !important;
    background: transparent !important;
    border: 0 !important;
    color: var(--wc-text) !important;
    margin: 0 !important;
}
.btn-group:has(> .btn-check) > .btn-check:checked + .btn {
    background: var(--wc-card) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 0.5px rgba(0, 0, 0, .04) !important;
    font-weight: 600;
}

/* ---- Phone: lists read like inset grouped lists ----------------------- */
@media (max-width: 767.98px) {
    #main-content h2 { font-size: 2rem; }
    table.table-stack > tbody > tr {
        border: 0;
        box-shadow: none;
        border-radius: var(--wc-radius);
    }
    table.table-stack > tbody > tr > td.stack-actions { border-top-color: var(--wc-hairline); }
}

/* Phone dashboard: the four "New ..." shortcuts as one grouped list with
   chevrons, like the Library list in Apple Music. */
@media (max-width: 767.98px) {
    #main-content .row:has(> .col-6 .dashboard-action-icon) {
        --bs-gutter-y: 0;
        margin: 0 0 1rem;
        background: var(--wc-card);
        border-radius: var(--wc-radius);
        box-shadow: var(--wc-shadow);
        overflow: hidden;
    }
    #main-content .row > .col-6:has(.dashboard-action-icon) {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
        padding: 0;
        margin: 0;
    }
    #main-content .col-6:has(.dashboard-action-icon) .card {
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: transparent;
    }
    #main-content .col-6:has(.dashboard-action-icon) .card-body {
        padding: 0.7rem 1rem !important;
        position: relative;
    }
    #main-content .col-6:has(.dashboard-action-icon):not(:last-child) .card-body::before {
        content: "";
        position: absolute;
        left: 4rem;
        right: 0;
        bottom: 0;
        border-bottom: 1px solid var(--wc-hairline);
    }
    #main-content .col-6:has(.dashboard-action-icon) .card-body::after {
        content: "\F285";                 /* bi-chevron-right */
        font-family: "bootstrap-icons";
        margin-left: auto;
        color: var(--wc-faint);
        font-size: 0.95rem;
    }
    #main-content .col-6:has(.dashboard-action-icon) .fw-semibold { font-weight: 500 !important; font-size: 1.05rem; color: var(--wc-text); }
    .dashboard-action-icon { background: transparent !important; width: 2rem !important; height: 2rem !important; font-size: 1.35rem; }
}

/* =======================================================================
   Phone layout (neutral theme): denser, larger text, iOS-style patterns.
   ======================================================================= */
@media (max-width: 991.98px) {
    /* Bottom tab bar, as in Apple's apps. */
    .tabbar {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 1030;
        display: flex;
        justify-content: space-around;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        background: rgba(249, 249, 251, 0.92);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        backdrop-filter: saturate(180%) blur(20px);
        border-top: 1px solid var(--wc-hairline);
    }
    .tabbar a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        color: #8e8e93;
        text-decoration: none;
        font-size: 0.68rem;
        font-weight: 500;
    }
    .tabbar a i { font-size: 1.45rem; line-height: 1.1; }
    .tabbar a.is-active { color: var(--wc-accent); }
    body:has(.tabbar) { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
    body:has(.tabbar) footer { padding-bottom: 1rem; }
}

@media (max-width: 767.98px) {
    body { font-size: 17px; line-height: 1.35; }
    #main-content { padding-left: 16px; padding-right: 16px; margin-top: 0.75rem !important; }
    #main-content h2, #main-content h1 { font-size: 2.1rem; margin-bottom: 0.25rem; }
    #main-content h3 { font-size: 1.65rem; }
    #main-content :is(h4, h5) { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
    #main-content hr { margin: 1rem 0 !important; }
    .badge { font-size: 0.8rem; padding: 0.3em 0.55em; }
    .mobile-header { height: 50px; }
    .mobile-header-logo img { height: 26px; }
    .has-sidebar .app-content { padding-top: 50px; }

    /* Section headings: title left, small "See All"-style link right. */
    .card-header > .d-flex.justify-content-between,
    .card-header.d-flex.justify-content-between { flex-wrap: nowrap !important; }
    .card-header > .d-flex.justify-content-between > :first-child { flex: 1 1 auto !important; }
    .card-header .btn-sm:is(.btn-outline-primary, .btn-outline-secondary) {
        background: none !important;
        padding: 0 !important;
        min-height: 0;
        color: var(--wc-accent) !important;
        font-size: 1rem;
    }
    .card-header .fw-semibold.small { font-size: 1.2rem !important; font-weight: 700 !important; }
    .card-header .fw-semibold.small > .bi { display: none; }

    /* Dashboard recent items: one tappable row with a chevron. */
    .list-group-item:has(a[title="View"]) { position: relative; padding: 0.7rem 0 !important; }
    .list-group-item a.btn[title="View"] {
        position: static;
        background: none !important;
        color: var(--wc-faint) !important;
        min-width: 0; min-height: 0; padding: 0 0 0 0.25rem;
        order: 2;
    }
    .list-group-item a.btn[title="View"] > .bi::before { content: "\F285"; }
    .list-group-item a.btn[title="View"]::after { content: ""; position: absolute; inset: 0; }
    .list-group-item .btn-group:has(a[title="View"]) { align-items: center; gap: 0.25rem; }
    .list-group-item .btn-group:has(a[title="View"]) > :not(a[title="View"]) {
        position: relative; z-index: 1; order: 1;
        background: none !important; color: var(--wc-muted) !important;
        min-height: 0; min-width: 0; padding: 0.25rem 0.5rem;
    }
    .list-group-item .fw-semibold.small { font-size: 1.05rem !important; }
    .list-group-item .text-truncate { overflow: visible; white-space: normal; overflow-wrap: anywhere; }
    .list-group-item .d-flex.align-items-center.gap-2:has(> .text-truncate) { flex-wrap: wrap; row-gap: 0.15rem; }
    .list-group-item .text-muted[style*="font-size"] { font-size: 0.9rem !important; }
    .list-group-item:has(> .d-flex .text-truncate + .badge, > a) .badge { font-size: 0.75rem !important; }

    .list-group-item > .d-flex.justify-content-between:has(a[title="View"]) { flex-wrap: nowrap !important; }
    .list-group-item > .d-flex.justify-content-between:has(a[title="View"]) > :first-child { flex: 1 1 auto !important; }
    table.table-stack > tbody > tr > td[style*="max-width"] { max-width: none !important; white-space: normal !important; }

    /* Detail pages: label/value pairs as one inset grouped list. */
    #main-content .row:has(> [class*="col"] > .text-muted.small:first-child) {
        --bs-gutter-x: 0; --bs-gutter-y: 0;
        margin: 0 0 1.25rem;
        background: var(--wc-card);
        border-radius: var(--wc-radius);
        box-shadow: var(--wc-shadow);
        overflow: hidden;
    }
    #main-content .row:has(> [class*="col"] > .text-muted.small:first-child) > [class*="col"] {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 1rem;
        width: 100%;
        padding: 0.75rem 1rem;
        margin: 0;
        border-bottom: 1px solid var(--wc-hairline);
    }
    #main-content .row:has(> [class*="col"] > .text-muted.small:first-child) > [class*="col"]:last-child { border-bottom: 0; }
    #main-content .row:has(> [class*="col"] > .text-muted.small:first-child) > [class*="col"] > .text-muted.small:first-child {
        font-size: 1rem !important;
        color: var(--wc-text) !important;
        flex: 0 0 auto;
    }
    #main-content .row:has(> [class*="col"] > .text-muted.small:first-child) > [class*="col"] > :not(:first-child) {
        text-align: right;
        color: var(--wc-muted);
        min-width: 0;
        overflow-wrap: anywhere;
    }
    #main-content .row:has(> [class*="col"] > .text-muted.small:first-child) > [class*="col"] > :not(:first-child) a { color: var(--wc-accent); }
    #main-content .row:has(> [class*="col"] > .text-muted.small:first-child) .progress { width: 6rem; margin-left: auto; }
    #main-content .row:has(> [class*="col"] > .text-muted.small:first-child) + hr { display: none; }

    /* Bootstrap definition lists (metadata, scan details) the same way. */
    #main-content dl.row {
        --bs-gutter-x: 0;
        margin: 0 0 1.25rem;
        background: var(--wc-card);
        border-radius: var(--wc-radius);
        box-shadow: var(--wc-shadow);
        padding: 0 1rem;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
    }
    #main-content dl.row > dt,
    #main-content dl.row > dd {
        width: auto; margin: 0; padding: 0.7rem 0;
        border-bottom: 1px solid var(--wc-hairline);
    }
    #main-content dl.row > dt { font-weight: 400; padding-right: 1rem; }
    #main-content dl.row > dd { text-align: right; color: var(--wc-muted); overflow-wrap: anywhere; }
    #main-content dl.row > :nth-last-child(-n+2) { border-bottom: 0; }

    /* Page header actions: icon buttons with a small caption, no Back button
       (the tab bar and the browser's back cover it). */
    #main-content .d-flex.justify-content-between.mb-4:has(> div > :is(h1, h2, h3)) { margin-bottom: 1rem !important; }
    #main-content .d-flex.justify-content-between.mb-4:has(> div > :is(h1, h2, h3)) > div:last-child { gap: 0.75rem !important; margin-top: 0.5rem; }
    #main-content .d-flex.justify-content-between.mb-4:has(> div > :is(h1, h2, h3)) .btn[title="Back"] { display: none !important; }
    #main-content .d-flex.justify-content-between.mb-4:has(> div > :is(h1, h2, h3)) .btn-sm[title]:has(> i:only-child) {
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        background: none !important;
        padding: 0 !important;
        min-width: 3.5rem;
        min-height: 0;
        font-size: 0.72rem;
        color: var(--wc-accent) !important;
    }
    #main-content .d-flex.justify-content-between.mb-4:has(> div > :is(h1, h2, h3)) .btn-sm[title]:has(> i:only-child) > i {
        display: flex; align-items: center; justify-content: center;
        width: 2.75rem; height: 2.75rem;
        border-radius: 50%;
        background: var(--wc-card);
        box-shadow: var(--wc-shadow);
        font-size: 1.15rem;
    }
    #main-content .d-flex.justify-content-between.mb-4:has(> div > :is(h1, h2, h3)) .btn-sm[title]:has(> i:only-child)::after { content: attr(title); }
    #main-content .d-flex.justify-content-between.mb-4:has(> div > :is(h1, h2, h3)) .btn-sm[title]:is(.btn-danger, .btn-outline-danger):has(> i:only-child) { color: var(--wc-err) !important; }

    /* Filters folded behind one button (static/js/mobile-filters.js). */
    form.has-filter-toggle { --bs-gutter-y: 0.6rem; }
    form.has-filter-toggle > .filter-search-col { flex: 1 1 0; width: auto; }
    form.has-filter-toggle > .filter-toggle-col { flex: 0 0 auto; width: auto; padding-left: 0.5rem; padding-right: calc(var(--bs-gutter-x) * .5); margin-top: var(--bs-gutter-y); display: flex; align-items: flex-end; }
    form.has-filter-toggle > .filter-search-col .form-label { display: none; }
    form.has-filter-toggle .filter-toggle { background: var(--wc-fill) !important; color: var(--wc-text) !important; white-space: nowrap; }
    form.has-filter-toggle.has-active-filters .filter-toggle { background: var(--wc-accent-soft) !important; color: var(--wc-accent) !important; }
    form.has-filter-toggle:not(.is-open) > [class*="col"]:not(.filter-search-col):not(.filter-toggle-col) { display: none !important; }
    .card:has(> .card-body > form.has-filter-toggle) { background: transparent; border: 0 !important; box-shadow: none !important; margin-bottom: 0.75rem !important; }
    .card:has(> .card-body > form.has-filter-toggle) > .card-body { padding: 0; }
    form.has-filter-toggle .form-control { background: var(--wc-fill); border-color: transparent; }

    /* List cards: thumbnail beside the ID, tighter rows, readable values. */
    table.table-stack > tbody > tr { padding: 0.75rem 1rem; box-shadow: var(--wc-shadow); margin-bottom: 0.6rem; }
    table.table-stack > tbody > tr > td {
        grid-template-columns: 6.5rem minmax(0, 1fr);
        padding: 0.18rem 0;
        font-size: 0.95rem;
    }
    table.table-stack > tbody > tr > td::before { grid-column: 1; grid-row: 1 / span 4; font-size: 0.85rem; font-weight: 400; color: var(--wc-muted); }
    table.table-stack > tbody > tr > td > * { grid-column: 2; }
    table.table-stack > tbody > tr > td.stack-title { display: block; font-size: 1.1rem; padding-bottom: 0.35rem; }
    table.table-stack > tbody > tr > td.stack-title::before { content: none; }
    table.table-stack > tbody > tr > td.stack-title strong, table.table-stack > tbody > tr > td.stack-title a { font-weight: 700; }
    table.table-stack > tbody > tr.has-media { min-height: 4.5rem; }
    table.table-stack > tbody > tr > td.stack-media {
        display: block;
        float: left;
        width: 3.25rem;
        padding: 0;
        margin: 0 0.75rem 0.25rem 0;
    }
    table.table-stack > tbody > tr > td.stack-media::before { content: none; }
    table.table-stack > tbody > tr > td.stack-media img { width: 3.25rem !important; height: 3.25rem !important; border-radius: 8px !important; }
    table.table-stack > tbody > tr.has-media > td.stack-title { min-height: 3.5rem; }
    table.table-stack > tbody > tr.has-media > td:not(.stack-media):not(.stack-title):not(.stack-select) { clear: left; }
    table.table-stack > tbody > tr > td.stack-actions { margin-top: 0.5rem; padding-top: 0.6rem; gap: 0.4rem; }
    table.table-stack > tbody > tr > td.stack-actions .btn {
        min-height: 2.25rem; min-width: 2.25rem; padding: 0.3rem 0.65rem;
        font-size: 0.9rem;
    }
}

/* Card headers lose their colour fill, so their white text turns dark. */
.card-header.text-white,
.card-header .text-white,
.card-header.text-white :is(h1, h2, h3, h4, h5, h6) { color: var(--wc-text) !important; }
.card-header.bg-danger,
.card-header.bg-danger :is(h1, h2, h3, h4, h5, h6) { color: var(--wc-err) !important; }

/* Public (signed-out) top bar: light, like the signed-in chrome. */
.navbar.bg-primary,
.navbar.navbar-dark {
    background: rgba(245, 245, 247, 0.92) !important;
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--wc-hairline);
    box-shadow: none;
}
.navbar.navbar-dark :is(.navbar-brand, .nav-link, a) { color: var(--wc-accent) !important; }

/* The phone-only "Filters" button (mobile-filters.js) never shows on wider screens. */
@media (min-width: 768px) {
    .filter-toggle-col { display: none !important; }
}
