/* Targeted usability and light-mode improvements */
:root {
    color-scheme: dark;
    --focus: #7dd3fc;
    --danger-surface: #451a23;
    --success-surface: #073b2e;
    --info-surface: #102c46;
    --warning-surface: #422b08
}

body.light-mode {
    color-scheme: light;
    --bg: #f1f5f9;
    --panel: #fff;
    --panel2: #e8eef5;
    --card: #fff;
    --text: #172033;
    --muted: #526173;
    --line: #c8d3df;
    --input: #fff;
    --paper: #fff;
    --focus: #0369a1;
    --danger-surface: #fff1f2;
    --success-surface: #ecfdf5;
    --info-surface: #eff6ff;
    --warning-surface: #fffbeb
}

html {
    min-width: 320px
}

body {
    line-height: 1.5
}

.main {
    max-width: 1600px;
    padding-top: 64px
}

.public-main {
    margin-left: 0;
    max-width: none;
    padding: 0;
    min-height: 100vh
}

.floating-theme {
    position: fixed;
    z-index: 1001;
    right: 16px;
    top: 12px;
    width: auto;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: 0 8px 24px rgba(0,0,0,.16);
    color: var(--text);
    padding: 9px 12px
}

    .floating-theme svg, .nav-toggle svg {
        width: 20px;
        height: 20px;
        flex: none
    }

.light-mode .sidebar {
    background: #f8fafc;
    border-color: #cbd5e1
}

    .light-mode .sidebar a, .light-mode .nav-logout {
        color: #425169
    }

        .light-mode .sidebar a:hover, .light-mode .sidebar a:focus-visible, .light-mode .nav-logout:hover {
            background: #e7eef6;
            color: #0f172a
        }

.light-mode .card, .light-mode .dashboard-card {
    box-shadow: 0 8px 24px rgba(15,23,42,.08)
}

.light-mode .table th {
    background: #e8eef5;
    color: #1f2937
}

.light-mode .table td {
    border-color: #d5dee8
}

.light-mode .btn.secondary, .light-mode .btn-secondary {
    background: #475569;
    color: #fff
}

.light-mode .badge {
    color: #fff
}

.light-mode .stat-card.warning span, .light-mode .stat-card.success span, .light-mode .stat-card.danger span {
    color: #fff;
    opacity: .95
}

.light-mode .stat-card.warning strong, .light-mode .stat-card.success strong, .light-mode .stat-card.danger strong {
    color: #fff
}

.light-mode .status-pill {
    color: #fff
}

button, input, select, textarea {
    font: inherit
}

input, select, textarea, .form-control {
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--input);
    color: var(--text)
}

textarea {
    min-height: 96px;
    resize: vertical
}

    input::placeholder, textarea::placeholder {
        color: var(--muted);
        opacity: .9
    }

label {
    display: block;
    font-weight: 700;
    margin: 0 0 6px
}

.check {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 44px;
    font-weight: 600
}

    .check input[type=checkbox] {
        min-height: 20px;
        width: 20px;
        height: 20px;
        margin: 0
    }

.btn, button.btn {
    min-height: 44px;
    padding: 10px 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px
}

    .btn.small, .btn-sm {
        min-height: 44px;
        padding: 8px 11px
    }

    .btn:disabled {
        opacity: .55;
        cursor: not-allowed
    }

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px
}

.d-flex {
    display: flex
}

.gap-2 {
    gap: 10px
}

.justify-content-between {
    justify-content: space-between
}

.align-items-start {
    align-items: flex-start
}

.align-items-center {
    align-items: center
}

.d-inline {
    display: inline
}

.nav-form {
    margin: 0
}

.nav-logout {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    margin: 6px 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: inherit
}

.alert {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    margin: 14px 0
}

    .alert.danger, .alert-danger {
        background: var(--danger-surface);
        border-color: var(--red)
    }

    .alert.success, .alert-success {
        background: var(--success-surface);
        border-color: var(--green)
    }

    .alert.info, .alert-info {
        background: var(--info-surface);
        border-color: var(--blue)
    }

    .alert.warning, .alert-warning {
        background: var(--warning-surface);
        border-color: var(--orange)
    }

.validation-summary:empty {
    display: none
}

.validation-summary:not(:empty) {
    background: var(--danger-surface);
    border: 1px solid var(--red);
    border-radius: 12px;
    padding: 10px 14px;
    color: var(--text)
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 72px 20px 32px;
    background: radial-gradient(circle at 50% 20%,rgba(56,189,248,.11),transparent 38%)
}

.login-card {
    width: min(100%,430px);
    padding: 32px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(0,0,0,.25)
}

.login-brand {
    font-size: 25px;
    font-weight: 900;
    color: var(--blue);
    margin-bottom: 24px
}

.login-card h1 {
    margin: 0 0 5px;
    font-size: 30px
}

.login-form {
    display: grid;
    gap: 18px;
    margin-top: 24px
}

.login-submit {
    width: 100%;
    margin-top: 2px
}

.remember-me {
    font-size: 14px
}

.first-run {
    color: var(--muted);
    font-size: 14px;
    margin: 20px 0 0
}

    .first-run a {
        color: var(--blue);
        font-weight: 700
    }

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 900px
}

    .search-box .form-control, .search-input {
        min-height: 52px;
        padding: 13px 16px;
        font-size: 16px
    }

    .search-box .btn {
        min-height: 52px;
        margin: 0
    }

.page-header {
    margin-bottom: 22px
}

    .page-header h1 {
        margin-bottom: 5px
    }

.card, .dashboard-card {
    overflow-x: auto
}

.table {
    width: 100%;
    border-collapse: collapse
}

    .table th, .table td {
        padding: 12px;
        vertical-align: middle
    }

    .table th {
        white-space: nowrap
    }

    .table input, .table select {
        min-width: 110px
    }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 16px
}

    .form-grid.three {
        grid-template-columns: repeat(3,minmax(0,1fr))
    }

.stack {
    display: grid;
    gap: 14px
}

.action-row {
    align-items: center
}

.scanner-panel {
    display: grid;
    gap: 10px;
    margin-top: 12px
}

.scanner-video {
    width: 100%;
    max-width: 520px;
    aspect-ratio: 4/3;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #000
}

    .scanner-video[hidden] {
        display: none
    }

.scanner-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap
}

.public-page {
    width: min(100% - 32px,900px);
    margin: 0 auto;
    padding: 82px 0 40px
}

    .public-page.narrow-page {
        max-width: 620px
    }

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--panel2);
    border: 1px solid var(--line);
    font-weight: 800
}

.public-summary {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 14px
}

    .public-summary div {
        padding: 12px;
        background: var(--panel2);
        border-radius: 12px
    }

    .public-summary dt {
        color: var(--muted);
        font-size: 13px;
        font-weight: 700
    }

    .public-summary dd {
        margin: 3px 0 0;
        font-weight: 700
    }

.timeline-list {
    list-style: none;
    padding: 0;
    margin: 0
}

    .timeline-list li {
        padding: 14px 0;
        border-bottom: 1px solid var(--line)
    }

        .timeline-list li:last-child {
            border: 0
        }

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill,minmax(180px,1fr));
    gap: 14px
}

.photo-card {
    background: var(--panel2);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px
}

    .photo-card img {
        display: block;
        width: 100%;
        aspect-ratio: 4/3;
        object-fit: cover;
        border-radius: 9px
    }

    .photo-card p {
        margin: 8px 0 0
    }

.tracking-link-box {
    display: grid;
    gap: 10px;
    padding: 14px;
    background: var(--info-surface);
    border: 1px solid var(--blue);
    border-radius: 12px
}

    .tracking-link-box input {
        width: 100%
    }

.privacy-note {
    font-size: 13px;
    color: var(--muted)
}

.nav-toggle {
    display: none
}

.nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2,6,23,.58);
    z-index: 899
}

    .nav-backdrop[hidden] {
        display: none
    }

@media(max-width:900px) {
    body.app-shell {
        padding-top: 62px
    }

    .main {
        margin-left: 0;
        padding: 22px 16px 38px;
        min-height: calc(100vh - 62px)
    }

    .public-main {
        padding: 0;
        min-height: 100vh
    }

    .nav-toggle {
        position: fixed;
        left: 12px;
        top: 10px;
        z-index: 1001;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        min-height: 44px;
        padding: 9px 12px;
        border-radius: 11px;
        border: 1px solid var(--line);
        background: var(--panel);
        color: var(--text);
        font-weight: 800
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100vh;
        overflow-y: auto;
        z-index: 1000;
        transform: translateX(-105%);
        transition: transform .18s ease;
        width: min(84vw,300px);
        padding-top: 70px;
        box-shadow: 16px 0 40px rgba(0,0,0,.3)
    }

    body.nav-open .sidebar {
        transform: translateX(0)
    }

    body.nav-open {
        overflow: hidden
    }

    .page-title, .dashboard-header {
        display: block
    }

        .page-title .btn, .dashboard-header .btn {
            margin-top: 12px
        }

    .form-grid, .form-grid.three {
        grid-template-columns: 1fr
    }

    .d-flex {
        flex-wrap: wrap
    }

    .search-box {
        align-items: stretch
    }

        .search-box .form-control {
            flex: 1 1 100%
        }

        .search-box .btn {
            flex: 1 1 100%
        }

    .table {
        min-width: 680px
    }

    .public-summary {
        grid-template-columns: 1fr
    }

    .row {
        gap: 12px
    }

    .card, .dashboard-card {
        padding: 17px;
        border-radius: 15px
    }

    .p-3 {
        padding: 17px
    }

    .login-card {
        padding: 25px 20px
    }

    .photo-grid {
        grid-template-columns: repeat(2,minmax(0,1fr))
    }
}

@media(max-width:430px) {
    .floating-theme span, .nav-toggle span {
        display: none
    }

    .floating-theme, .nav-toggle {
        width: 44px;
        padding: 10px
    }

    .page-title h1, .dashboard-header h1 {
        font-size: 27px
    }

    .photo-grid {
        grid-template-columns: 1fr
    }

    .public-page {
        width: min(100% - 24px,900px)
    }

    .btn {
        width: 100%;
        margin: 3px 0
    }

    .scanner-actions .btn {
        width: auto;
        flex: 1
    }

    .action-row .btn {
        flex: 1 1 100%
    }
}

@media(prefers-reduced-motion:reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition: none !important;
        animation: none !important
    }
}

.nav-install {
    display: block;
    width: 100%;
    min-height: 44px;
    text-align: left;
    padding: 12px 14px;
    margin: 6px 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    color: var(--text);
    font: inherit;
    cursor: pointer
}

.connection-status {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    margin: 0 0 16px;
    background: var(--panel);
    border: 1px solid var(--orange);
    border-radius: 12px;
    color: var(--text)
}

    .connection-status[hidden], .install-status[hidden] {
        display: none
    }

.install-status {
    position: fixed;
    z-index: 1200;
    left: 12px;
    right: 12px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    max-width: 600px;
    margin: auto;
    padding: 14px 16px;
    border: 1px solid var(--blue);
    border-radius: 14px;
    background: var(--panel);
    color: var(--text);
    box-shadow: 0 12px 35px rgba(0,0,0,.3)
}

.mobile-bottom-nav {
    display: none
}

.signature-pad {
    display: block;
    width: 100%;
    height: 220px;
    max-width: 600px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none
}

.photo-preview {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 8px 0
}

    .photo-preview img {
        width: 76px;
        height: 76px;
        object-fit: cover;
        border-radius: 8px;
        border: 1px solid var(--line)
    }

.photo-selection-status {
    min-height: 24px;
    color: var(--muted)
}

@media(max-width:900px) {
    body.app-shell {
        padding-bottom: calc(72px + env(safe-area-inset-bottom))
    }

    .main {
        padding-bottom: 24px
    }

    .mobile-bottom-nav {
        position: fixed;
        z-index: 850;
        left: 0;
        right: 0;
        bottom: 0;
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: 1fr;
        min-height: 64px;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
        background: var(--panel);
        border-top: 1px solid var(--line);
        box-shadow: 0 -8px 24px rgba(0,0,0,.18)
    }

        .mobile-bottom-nav a {
            min-width: 0;
            min-height: 48px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 2px;
            border-radius: 10px;
            color: var(--muted);
            font-weight: 700
        }

            .mobile-bottom-nav a span {
                font-size: 21px;
                line-height: 1
            }

            .mobile-bottom-nav a small {
                font-size: 11px
            }

            .mobile-bottom-nav a.active {
                background: var(--panel2);
                color: var(--blue)
            }

    body.nav-open .mobile-bottom-nav {
        visibility: hidden
    }
}

@media(max-width:430px) {
    .connection-status {
        align-items: stretch;
        flex-direction: column
    }

        .connection-status .btn {
            width: auto
        }

    .install-status {
        bottom: calc(72px + env(safe-area-inset-bottom))
    }
}

.sidebar a.active {
    background: var(--panel);
    color: var(--blue);
    box-shadow: inset 3px 0 0 var(--blue)
}

.nav-user {
    display: grid;
    gap: 2px;
    margin: 14px 0 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--line);
    color: var(--text)
}

    .nav-user small {
        color: var(--muted)
    }

.empty-state {
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 14px;
    background: var(--panel2)
}

    .empty-state h3, .empty-state p {
        margin-top: 0
    }

        .empty-state p:last-child {
            margin-bottom: 0
        }

.empty-hint {
    color: var(--muted);
    padding: 10px 0
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: 16px
}

    .table-wrap > .table {
        min-width: 650px
    }

.badge.status-ready {
    background: #065f46
}

.badge.status-waiting-approval, .badge.status-quote-pending, .badge.status-quote-sent {
    background: #92400e
}

.badge.status-cancelled, .badge.status-transferred-to-insurance {
    background: #991b1b
}

.badge.status-archived, .badge.status-collected {
    background: #475569
}

.badge.status-quality-check {
    background: #6d28d9
}

.badge.status-approved, .badge.status-parts-received {
    background: #047857
}

.login-card {
    position: relative;
    overflow: hidden
}

.login-vehicle {
    height: 112px;
    margin: -10px -6px 4px;
    opacity: .62;
    filter: drop-shadow(0 0 10px rgba(56,189,248,.25))
}

    .login-vehicle svg {
        width: 100%;
        height: 100%;
        fill: none;
        stroke: #38bdf8;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round
    }

    .login-vehicle circle {
        fill: #111827
    }

@media(max-width:600px) {
    .table-wrap > .table {
        min-width: 620px
    }

    .login-vehicle {
        height: 88px
    }

    .nav-user {
        margin-top: 8px
    }
}

/* ---------- Extended layout blocks ---------- */
.register-wrap {
    max-width: 420px;
    margin: 0 auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 110px;
    padding: 16px 18px;
    text-decoration: none;
    box-sizing: border-box;
}

    .stat-card span {
        font-size: 0.9rem;
        line-height: 1.3;
    }

    .stat-card strong {
        font-size: 1.8rem;
        line-height: 1.1;
        margin-top: 12px;
    }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
}

.dashboard-card {
    min-width: 0;
    box-sizing: border-box;
}

@media (max-width: 800px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.report-group {
    margin-bottom: 32px;
}

    .report-group h2 {
        font-size: 1.15rem;
        margin: 0 0 12px;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--line);
    }

    .report-group .stats-grid {
        margin-bottom: 16px;
    }

    .report-group > .stats-grid:last-child {
        margin-bottom: 0;
    }

/* ---------- Hero (large header block) ---------- */
.hero-lg {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2rem;
    padding: 1.75rem 2rem;
    margin-bottom: 1.5rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
}

    .hero-lg .hero-text {
        min-width: 0;
    }

    .hero-lg .hero-eyebrow {}


    /* ---------- Client & Vehicle Cards ---------- */

.client-card-grid,
.vehicle-card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 20px;
margin-top: 20px;
}

/* Shared card styling */
.client-card,
.vehicle-card {
background: var(--panel);
border: 1px solid var(--line);
border-radius: 16px;
padding: 22px;
color: var(--text);
box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.client-card:hover,
.vehicle-card:hover {
transform: translateY(-3px);
box-shadow: 0 12px 30px rgba(0, 0, 0, .18);
}

/* ---------- Client Cards ---------- */

.client-card-header {
display: flex;
align-items: center;
gap: 14px;
margin-bottom: 20px;
}

.client-avatar {
width: 50px;
height: 50px;
min-width: 50px;
border-radius: 50%;
background: var(--panel2);
color: var(--text);
border: 1px solid var(--line);
display: flex;
align-items: center;
justify-content: center;
font-size: 19px;
font-weight: 800;
}

.client-card-title {
min-width: 0;
}

.client-card-title h3 {
margin: 0;
color: var(--text);
font-size: 19px;
font-weight: 700;
overflow-wrap: anywhere;
}

.client-type {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 13px;
}

.client-card-details {
border-top: 1px solid var(--line);
padding-top: 15px;
}

.client-detail {
display: flex;
flex-direction: column;
gap: 3px;
margin-bottom: 14px;
}

.client-detail-label {
font-size: 12px;
color: var(--muted);
font-weight: 700;
text-transform: uppercase;
letter-spacing: .04em;
}

.client-detail-value {
font-size: 14px;
color: var(--text);
overflow-wrap: anywhere;
}

.client-vehicle-count {
display: flex;
align-items: center;
gap: 12px;
margin-top: 18px;
padding: 12px;
background: var(--panel2);
border: 1px solid var(--line);
border-radius: 10px;
}

.vehicle-count-number {
width: 38px;
height: 38px;
display: flex;
align-items: center;
justify-content: center;
background: var(--panel);
border: 1px solid var(--line);
border-radius: 8px;
color: var(--text);
font-size: 17px;
font-weight: 800;
}

.vehicle-count-title {
display: block;
color: var(--text);
font-size: 14px;
font-weight: 700;
}

.client-vehicle-count small {
display: block;
margin-top: 2px;
color: var(--muted);
}

.client-card-footer,
.vehicle-card-footer {
margin-top: 20px;
}

.client-open-btn,
.vehicle-open-btn {
display: block;
width: 100%;
text-align: center;
}

/* ---------- Vehicle Cards ---------- */

.vehicle-card-header {
display: flex;
align-items: center;
gap: 14px;
margin-bottom: 20px;
}

.vehicle-icon {
width: 50px;
height: 50px;
min-width: 50px;
border-radius: 12px;
background: var(--panel2);
border: 1px solid var(--line);
display: flex;
align-items: center;
justify-content: center;
font-size: 24px;
}

.vehicle-card-title {
min-width: 0;
}

.vehicle-label {
display: block;
color: var(--muted);
font-size: 12px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: .04em;
}

.vehicle-card-title h3 {
margin: 3px 0 0;
color: var(--text);
font-size: 20px;
font-weight: 800;
letter-spacing: .03em;
overflow-wrap: anywhere;
}

.vehicle-card-details {
border-top: 1px solid var(--line);
padding-top: 15px;
}

.vehicle-detail {
display: flex;
flex-direction: column;
gap: 3px;
margin-bottom: 14px;
}

.vehicle-detail-label {
font-size: 12px;
color: var(--muted);
font-weight: 700;
text-transform: uppercase;
letter-spacing: .04em;
}

.vehicle-detail-value {
font-size: 14px;
color: var(--text);
overflow-wrap: anywhere;
}

.vehicle-vin {
font-family: monospace;
font-size: 13px;
}

/* ---------- Card responsiveness ---------- */

@media (max-width: 600px) {
.client-card-grid,
.vehicle-card-grid {
grid-template-columns: 1fr;
gap: 16px;
}

.client-card,
.vehicle-card {
 padding: 18px;
}

}

body.light-mode .sidebar {
    background: #e2e8f0;
    border-right-color: #cbd5e1;
}

body.light-mode .brand {
    color: #0369a1;
}

.table td:last-child > a:not(.btn),
.clean-table td:last-child > a:not(.btn),
.clean-list li > a:last-child:not(.btn) {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 10px;
    background: var(--blue);
    color: #00111a;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
    transition: filter .15s, transform .15s;
}

.table td:last-child > a:not(.btn):hover,
.clean-table td:last-child > a:not(.btn):hover,
.clean-list li > a:last-child:not(.btn):hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.table td:last-child > a:not(.btn):focus-visible,
.clean-table td:last-child > a:not(.btn):focus-visible,
.clean-list li > a:last-child:not(.btn):focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 2px;
}