/* ── Dealer portal (/inventory) ── */

.dealer-inv-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 48px 64px;
}

.dealer-inv-flash-wrap {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dealer-inv-flash {
    padding: 0 0 8px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
}

.dealer-inv-flash--success {
    color: #047857;
}

.dealer-inv-flash--error {
    color: #b91c1c;
}

.dealer-inv-flash--info {
    color: var(--navy);
}

.dealer-inv-section {
    margin-bottom: 40px;
}

.dealer-inv-hint {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin-bottom: 16px;
    max-width: 720px;
    line-height: 1.5;
}

.dealer-inv-vin-form {
    margin-top: 8px;
}

.dealer-inv-vin-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.dealer-inv-label {
    flex: 1 1 100%;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.dealer-inv-vin-input {
    flex: 1 1 280px;
    min-width: 200px;
    padding: 10px 12px;
    border-radius: 4px;
    border: 1px solid var(--border-medium);
    background: var(--bg-card);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
}

/* Vehicles: an index of entries separated by hairlines, not bordered cards. */
.dealer-inv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 0 40px;
}

.dealer-inv-card {
    border-top: 1px solid var(--border-light);
    padding: 20px 0 28px;
}

.dealer-inv-card-img {
    height: 180px;
    background-size: cover;
    background-position: center;
    margin-bottom: 14px;
}

.dealer-inv-card-body {
    padding: 0;
}

.dealer-inv-card-title {
    font-size: 1.05rem;
    margin-bottom: 4px;
}

.dealer-inv-card-vin {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.dealer-inv-edit-form .dealer-inv-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
    margin-bottom: 12px;
}

.dealer-inv-edit-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.dealer-inv-edit-form input,
.dealer-inv-edit-form textarea {
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid var(--border-medium);
    background: var(--bg-card);
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
}

.dealer-inv-notes {
    grid-column: 1 / -1;
}

.dealer-inv-upload-form {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
}

.dealer-inv-upload-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.dealer-inv-file-input {
    display: block;
    margin-bottom: 10px;
    font-size: 0.85rem;
}

.dealer-inv-thumb-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.dealer-inv-thumb {
    width: 56px;
    height: 56px;
    background-size: cover;
    background-position: center;
}

.dealer-inv-thumb-wrap {
    position: relative;
    width: 56px;
    height: 56px;
}

.dealer-inv-thumb-delete-form {
    position: absolute;
    top: -6px;
    right: -6px;
    margin: 0;
}

.dealer-inv-thumb-delete-btn {
    width: 18px;
    height: 18px;
    line-height: 16px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid #fecaca;
    background: var(--bg-card);
    color: #b91c1c;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}

.dealer-inv-thumb-delete-btn:hover {
    background: rgba(200, 60, 60, 0.25);
}

.dealer-inv-delete-form {
    margin-top: 14px;
}

.dealer-inv-delete-btn {
    background: transparent;
    border: 1px solid #fecaca;
    color: #b91c1c;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
}

.dealer-inv-delete-btn:hover {
    background: rgba(200, 60, 60, 0.12);
}

.dealer-inv-empty {
    padding: 18px 0;
    color: var(--text-muted);
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}

/* —— Unified left sidebar (app + admin) —— */
:root {
    --app-sidebar-width: 260px;
}

body:has(.app-sidebar) {
    /* `clip` (not `hidden`) prevents horizontal overflow WITHOUT making body a
       scroll container — otherwise it breaks position:sticky (the filter sidebar). */
    overflow-x: clip;
}

.page:has(.app-sidebar),
.page.page--app-layout {
    display: grid;
    grid-template-columns: var(--app-sidebar-width) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    align-items: start;
    box-sizing: border-box;
}

.page:has(.app-sidebar) > :not(.app-sidebar):not(.app-sidebar-toggle):not(.app-sidebar-backdrop),
.page.page--app-layout > :not(.app-sidebar):not(.app-sidebar-toggle):not(.app-sidebar-backdrop) {
    grid-column: 2;
}

.app-sidebar {
    grid-column: 1;
    grid-row: 1 / -1;
    position: fixed;
    left: 0;
    top: 0;
    width: var(--app-sidebar-width);
    min-height: 100vh;
    max-height: 100vh;
    height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 12px 20px;
    background: var(--navy);
    border-right: 1px solid rgba(255, 252, 248, 0.1);
    box-shadow: none;
    z-index: 40;
}

/* Fixed bottom bars: sit to the right of the pinned sidebar on desktop */
@media (min-width: 901px) {
    body:has(.app-sidebar) .compare-tray,
    body:has(.app-sidebar) .car-mobile-cta {
        left: var(--app-sidebar-width);
    }
}

.app-sidebar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 8px 8px;
}

.app-sidebar__logo {
    font-family: var(--font-display, Georgia, serif);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--bg-page);
    text-decoration: none;
    letter-spacing: 0.02em;
}

.app-sidebar__logo:hover {
    color: #fff;
}

.app-sidebar__close {
    display: none;
    border: none;
    background: transparent;
    color: rgba(255, 252, 248, 0.85);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
}

.app-sidebar__search {
    padding: 10px 8px 12px;
    margin-top: auto;
    border-top: 1px solid rgba(255, 252, 248, 0.1);
}

.sidebar-search {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.sidebar-search--compact {
    gap: 6px;
}

.sidebar-search__heading {
    margin: 0;
    padding: 0 2px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 252, 248, 0.45);
}

.sidebar-search__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 48px 28px;
    gap: 6px;
    align-items: stretch;
}

.sidebar-search__field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.sidebar-search__field--grow {
    grid-column: auto;
}

.sidebar-search__field--zip {
    grid-column: auto;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sidebar-search__input-wrap {
    position: relative;
    display: block;
    width: 100%;
}

.sidebar-search__icon {
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    pointer-events: none;
    color: rgba(252, 250, 246, 0.65);
}

.sidebar-search__input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 4px 8px 24px;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid rgba(255, 252, 248, 0.22);
    background: transparent;
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.25;
    outline: none;
}

.sidebar-search__input--zip {
    padding: 8px 4px;
    text-align: center;
}

.sidebar-search__input::placeholder {
    color: rgba(252, 250, 246, 0.52);
}

.sidebar-search__input:hover {
    border-bottom-color: rgba(255, 252, 248, 0.4);
}

.sidebar-search__input:focus {
    border-bottom-color: rgba(255, 252, 248, 0.85);
}

.sidebar-search__submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 36px;
    padding: 0;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid rgba(255, 252, 248, 0.22);
    background: transparent;
    color: rgba(252, 250, 246, 0.95);
    cursor: pointer;
}

.sidebar-search__submit .sc-icon {
    display: block;
}

.sidebar-search__submit:hover,
.sidebar-search__submit:focus-visible {
    border-bottom-color: rgba(255, 252, 248, 0.85);
    color: #fff;
    outline: none;
}

.app-sidebar .nav-search {
    display: none;
}

.app-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    padding: 4px 0;
}

.app-sidebar__group-label {
    margin: 14px 8px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 252, 248, 0.45);
}

.app-sidebar__group-label:first-child {
    margin-top: 4px;
}

.app-sidebar__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px 9px 8px;
    border-radius: 0;
    border-left: 2px solid transparent;
    color: rgba(255, 252, 248, 0.82);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.25;
}

.app-sidebar__link:hover {
    color: #fff;
}

.app-sidebar__link--active,
.app-sidebar__link[aria-current="page"] {
    border-left-color: #d9c39a;
    color: #fff;
    font-weight: 600;
}

.app-sidebar__link--admin {
    color: rgba(186, 230, 253, 0.95);
}

.app-sidebar__link--premium {
    color: #fde68a;
}

.app-sidebar__icon {
    flex-shrink: 0;
    opacity: 0.9;
}

.app-sidebar__foot {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 252, 248, 0.12);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.app-sidebar__foot .dev-logout-form {
    margin: 4px 0 0;
}

.app-sidebar__foot .dev-logout-button {
    width: 100%;
    text-align: left;
    padding: 9px 10px;
    border-radius: 0;
    background: transparent;
    border: none;
    color: rgba(255, 252, 248, 0.7);
    font-size: 14px;
    cursor: pointer;
}

.app-sidebar__foot .dev-logout-button:hover {
    background: transparent;
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.app-sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 50;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 2px;
    background: var(--navy);
    color: #fff;
    box-shadow: none;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.app-sidebar-toggle__bar {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}

.app-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 35;
}

.app-layout-flash {
    padding: 12px 20px 0;
}

.page:has(.app-sidebar) .admin-flash-wrap,
.page.page--app-layout .admin-flash-wrap,
.app-layout-flash {
    max-width: none;
    margin: 12px 0 0;
    padding: 0 clamp(16px, 3vw, 32px);
    width: 100%;
    min-width: 0;
    grid-column: 2;
}

.page:has(.app-sidebar) .admin-main,
.page.page--app-layout .admin-main,
.app-layout-main {
    max-width: none;
    margin: 0;
    padding: 20px clamp(16px, 3vw, 32px) 48px;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    box-sizing: border-box;
}

.page:has(.app-sidebar) > .admin-main,
.page.page--app-layout > .admin-main {
    grid-column: 2;
}

@media (max-width: 900px) {
    .page:has(.app-sidebar),
    .page.page--app-layout {
        display: block;
    }

    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        z-index: 45;
    }

    body.app-sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .app-sidebar-toggle {
        display: inline-flex;
    }

    /* Open menu: the sidebar's own close control replaces the floating toggle,
       which otherwise sat on top of the logo. */
    body.app-sidebar-open .app-sidebar-toggle {
        display: none;
    }

    .app-sidebar__close:not([hidden]) {
        display: inline-flex;
    }

    body:has(.app-sidebar) .db-shell,
    body:has(.app-sidebar) .hub-shell,
    body:has(.app-sidebar) .find-dealers-section,
    body:has(.app-sidebar) .car-detail,
    /* M1 (visual review 2026-09-28): the fixed 44px toggle covered the first
       line of these sidebar pages ("HTSA recall lookup", "ack to inventory"). */
    body:has(.app-sidebar) .compare-page-section,
    body:has(.app-sidebar) .nhtsa-recalls-section,
    body:has(.app-sidebar) .auth-section,
    body:has(.app-sidebar) .dealer-research,
    body.admin-shell-body .admin-main {
        padding-top: 56px;
    }

    body:has(.app-sidebar) .listings-filter-shell,
    body.app-layout-body .listings-filter-shell {
        padding-top: 56px;
    }
}

body.listings-page .page:has(.app-sidebar),
body.listings-page.page--app-layout .page {
    width: 100%;
}

body.listings-page:has(.app-sidebar) > .guest-banner,
body.listings-page .page:has(.app-sidebar) > .guest-banner {
    grid-column: 2;
}

body.listings-page:has(.app-sidebar) .listings-filter-shell.filter-bar,
body.listings-page .page:has(.app-sidebar) .listings-filter-shell.filter-bar {
    grid-column: 2;
    width: 100%;
    min-width: 0;
}

body.listings-page:has(.app-sidebar) .listings-layout,
body.listings-page .page:has(.app-sidebar) .listings-layout {
    padding-left: clamp(12px, 2vw, 24px);
}

/* —— Store admin (/admin) ——
   Editorial layout on the light page: type, whitespace and 1px hairlines.
   No cards, KPI tiles, pills or tinted panels (owner rule, 2026-09-30). */
.admin-shell-body {
    background: var(--bg-page);
}

.admin-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 48px;
}

.admin-lead,
.admin-muted {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.admin-muted {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.admin-lead a,
.admin-muted a {
    color: var(--navy);
}

.admin-flash-wrap {
    max-width: 1200px;
    margin: 12px auto 0;
    padding: 0 20px;
}

/* Flash messages: colored text above a hairline, no tinted box. */
.admin-flash {
    margin: 0 0 8px;
    padding: 0 0 8px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.admin-flash-error {
    color: #b91c1c;
}

.admin-flash-success {
    color: #047857;
}

/* Figures row: numbers over labels between hairlines, no tiles. */
.admin-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px 32px;
    margin-top: 16px;
    padding: 14px 0;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}

.admin-kpi-card {
    padding: 0;
}

.admin-kpi-label {
    margin: 0 0 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.admin-kpi-value {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.admin-kpi-hint {
    margin: 6px 0 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.admin-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    align-items: flex-end;
    margin: 20px 0;
    font-size: 0.88rem;
}

.admin-filters label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.admin-filters label:has(input[type="checkbox"]) {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding-bottom: 8px;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
}

.admin-filters input[type="search"],
.admin-filters select {
    min-width: 160px;
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid var(--border-medium);
    background: var(--bg-card);
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
    text-transform: none;
    letter-spacing: 0;
}

.admin-table-wrap {
    overflow-x: auto;
    margin-top: 12px;
    border-top: 1px solid var(--border-medium);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
    color: var(--text);
}

.admin-table th,
.admin-table td {
    padding: 9px 12px 9px 0;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    vertical-align: top;
}

.admin-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.admin-table a {
    color: var(--navy);
}

.admin-issues {
    max-width: 220px;
    color: #b45309;
    font-size: 0.8rem;
}

.admin-pagination {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
    color: var(--text-secondary);
}

.admin-inline-kpis {
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 24px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.admin-back {
    margin: 0 0 12px;
}

.admin-back a {
    color: var(--navy);
}

.admin-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px 40px;
    margin-top: 16px;
}

.admin-subh {
    font-size: 1.05rem;
    margin: 28px 0 10px;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
    color: var(--text);
}

.admin-issue-list,
.admin-checklist {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--text);
    line-height: 1.5;
}

.admin-mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
    color: var(--text);
}

.admin-mini-table th,
.admin-mini-table td {
    padding: 6px 8px 6px 0;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
    vertical-align: top;
}

.admin-mini-table th {
    color: var(--text-muted);
    font-weight: 600;
}

.admin-gallery-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.admin-gallery-thumb img {
    width: 120px;
    height: 80px;
    object-fit: cover;
    display: block;
}

.admin-textarea {
    width: 100%;
    max-width: 720px;
    padding: 10px 12px;
    border-radius: 4px;
    border: 1px solid var(--border-medium);
    background: var(--bg-card);
    color: var(--text);
    font-family: inherit;
    margin-bottom: 10px;
}

.admin-notes-form,
.admin-inline-form {
    margin-top: 8px;
}

/* Raw JSON: monospace between hairlines, no dark slab. */
.admin-json {
    max-height: 420px;
    overflow: auto;
    margin: 0;
    padding: 10px 0;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--text);
}

.admin-table-tall th {
    width: 180px;
}

.admin-error-text,
.admin-error-wrap code {
    color: #b91c1c;
    font-size: 0.78rem;
    word-break: break-word;
    background: none;
}

/* Dealer portal overview: a figure and a hairline index of actions. */
.dealer-inv-figure {
    margin: 0 0 6px;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.dealer-inv-figure strong {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-right: 6px;
    font-variant-numeric: tabular-nums;
}

.dealer-inv-actions {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    border-top: 1px solid var(--border-light);
}

.dealer-inv-actions li {
    display: grid;
    grid-template-columns: minmax(180px, 240px) 1fr;
    gap: 4px 24px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.dealer-inv-actions a {
    font-weight: 600;
    color: var(--navy);
}

.dealer-inv-actions span {
    color: var(--text-muted);
}

@media (max-width: 640px) {
    .dealer-inv-actions li {
        grid-template-columns: 1fr;
    }
}

/* Recently updated: plain entries, no card frame (scoped to the dealer portal). */
.dealer-inv-layout .saved-grid.dealer-inv-recent {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px 32px;
}

.dealer-inv-layout .saved-card {
    border: none;
    border-top: 1px solid var(--border-light);
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    padding-top: 12px;
}

.dealer-inv-layout .saved-card:hover {
    box-shadow: none;
    transform: none;
}

.dealer-inv-layout .saved-image {
    border-radius: 0;
}

.dealer-inv-layout .saved-empty {
    border: none;
    border-top: 1px solid var(--border-light);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    padding: 18px 0;
    text-align: left;
}

/* Admin pages stack plain db-sections without the member dashboard's flex gap. */
.admin-main > .db-section + .db-section {
    margin-top: 44px;
}
