:root {
    --navy: #405189;
    --ink: #2a276b;
    --red: #ed1c24;
    --red-dark: #cc3042;
    --text: #252839;
    --muted: #707070;
    --bg: #eef1f6;
    --line: #d9deea;
    --card: #ffffff;
    --ok: #e7f6ee;
    --ok-text: #0f6b3c;
    --err: #fdecee;
    --err-text: #9f1d2a;
}

* { box-sizing: border-box; }

body {
    display: flex;
    flex-direction: column;
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.45;
}

a { color: var(--navy); }

img { max-width: 100%; height: auto; }

.wrap {
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    background: var(--navy);
    color: #fff;
    padding-top: env(safe-area-inset-top);
}

.header-bar {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 78px;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.brand {
    display: flex;
    align-items: center;
}

.brand img {
    height: 34px;
    width: auto;
}

.brand-kicker {
    margin: 0;
    padding-left: 18px;
    border-left: 1px solid rgba(255, 255, 255, 0.35);
    color: #fff;
    font-size: 14px;
    letter-spacing: 0.02em;
}

.header-nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-nav a {
    color: #fff;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 4px;
}

.header-nav a.is-active,
.header-nav a:hover {
    background: rgba(255, 255, 255, 0.12);
}

main.wrap {
    flex: 1;
    padding: 28px 0 48px;
}

.site-footer {
    border-top: 3px solid var(--navy);
    color: var(--muted);
    font-size: 13px;
    padding: 16px 0 calc(28px + env(safe-area-inset-bottom));
}

h1, h2 { margin: 0; color: var(--ink); }
h1 { font-size: 32px; line-height: 1.15; }
h2 { font-size: 18px; }

.lede { margin: 8px 0 0; color: var(--muted); }

.page-head,
.section-head,
.actions,
.car-row,
.service-card header,
.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.actions { flex-wrap: wrap; }
.actions form { display: flex; margin: 0; }

.page-head,
.section-head {
    justify-content: space-between;
    margin-bottom: 18px;
}

.section-head { margin-top: 8px; }
.section-head span { color: var(--muted); font-size: 14px; }

.back {
    display: inline-block;
    margin-bottom: 6px;
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
}

.back:hover { color: var(--red); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--text);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--ink); }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-dark); }
.btn-light { background: #fff; color: var(--navy) !important; }
.btn-light:hover { background: #f7f8fb !important; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--navy); color: var(--navy); }
.btn-ghost.danger:hover { border-color: var(--red); color: var(--red); }

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 18px;
}

.stats article,
.panel,
.car-row,
.service-card,
.empty-state {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.stats article { padding: 14px 16px; }
.stats span { display: block; color: var(--muted); font-size: 13px; }
.stats strong { display: block; margin-top: 4px; font-size: 28px; color: var(--navy); }

.search { display: flex; gap: 8px; }

input,
select,
textarea {
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(64, 81, 137, 0.35);
    border-color: var(--navy);
}

textarea { resize: vertical; }

.search input { width: 280px; margin-top: 0; }

.car-list,
.service-list { display: grid; gap: 10px; }

.car-row { padding: 8px 8px 8px 0; }
.car-main {
    flex: 1;
    display: grid;
    grid-template-columns: 150px 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 10px 16px;
    color: inherit;
    text-decoration: none;
}
.car-main:hover strong { color: var(--red); }
.car-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.car-title strong,
.car-title em,
.service-card p { overflow-wrap: anywhere; }
.car-title em { font-style: normal; color: var(--muted); font-size: 14px; }
.car-meta { text-align: right; color: var(--muted); font-size: 14px; }
.car-meta b { color: var(--navy); font-size: 18px; }
.car-meta small { display: block; margin-top: 2px; }

.plate {
    display: inline-flex;
    align-items: stretch;
    overflow: hidden;
    border: 1px solid #1d2433;
    border-radius: 4px;
    background: #fff;
    color: #1d2433;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.plate span {
    display: flex;
    align-items: center;
    padding: 0 6px;
    background: #1d4f91;
    color: #fff;
    font-size: 10px;
    letter-spacing: 0.08em;
}
.plate { gap: 8px; padding-right: 8px; font-size: 14px; line-height: 28px; }

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 22px;
}

.panel { padding: 18px; }
.panel h2 { margin-bottom: 14px; }

.facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
    margin: 0;
}
.facts dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.facts dd { margin: 2px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.notes {
    margin: 16px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    color: var(--text);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
}
.form-grid.tight { margin-bottom: 12px; }
.span-2 { grid-column: span 2; }
label { font-size: 13px; color: var(--muted); font-weight: 700; }
.stack-form label { display: block; }
.form-actions { justify-content: flex-start; }

.service-card { padding: 16px 18px; }
.service-card header { justify-content: flex-start; margin-bottom: 8px; }
.service-card time { font-weight: 700; color: var(--ink); }
.service-card header strong { color: var(--navy); }
.service-card header span { margin-left: auto; color: var(--muted); }
.service-card p { margin: 0 0 12px; }
.service-card .actions { justify-content: flex-start; }

.empty-state { padding: 36px 20px; text-align: center; }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { margin: 0 0 16px; color: var(--muted); }
.empty-state.compact { padding: 20px; }
.empty-state.compact p { margin: 0; }

.flash {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 6px;
}
.flash-ok { background: var(--ok); color: var(--ok-text); }
.flash-err { background: var(--err); color: var(--err-text); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 800px) {
    .wrap { width: min(1080px, calc(100% - 28px)); }
    main.wrap { padding: 20px 0 36px; }
    h1 { font-size: 26px; }

    .header-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        min-height: 0;
        padding: 14px 0;
    }
    .brand img { height: 28px; }
    .brand-kicker { font-size: 13px; padding-left: 12px; }
    .header-nav {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
        margin-left: 0;
        gap: 8px;
    }
    .header-nav a {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        text-align: center;
    }

    .page-head,
    .section-head {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }
    .page-head .actions { width: 100%; }
    .page-head .actions .btn,
    .page-head .actions form { flex: 1 1 0; }
    .page-head .actions form .btn { width: 100%; }

    .stats {
        gap: 8px;
    }
    .stats article { padding: 12px 10px; }
    .stats span { font-size: 12px; }
    .stats strong { font-size: 22px; }

    .search { flex-direction: column; align-items: stretch; }
    .search input { width: 100%; }
    .search .btn { width: 100%; min-height: 44px; }

    .detail-grid,
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }

    .car-row {
        flex-direction: column;
        align-items: stretch;
        padding: 14px;
        gap: 12px;
    }
    .car-main {
        grid-template-columns: 1fr;
        justify-items: start;
        gap: 8px;
        padding: 0;
    }
    .car-meta { text-align: left; }
    .car-row > form .btn { width: 100%; min-height: 44px; }

    .service-card header { flex-wrap: wrap; align-items: flex-start; }
    .service-card header span { margin-left: 0; }
    .service-card .actions { align-items: stretch; }
    .service-card .actions .btn,
    .service-card .actions form { flex: 1 1 calc(50% - 12px); }
    .service-card .actions form .btn,
    .service-card .actions > .btn { width: 100%; min-height: 44px; }

    input,
    select,
    textarea { font-size: 16px; }
    input,
    select { min-height: 44px; }
    .btn { min-height: 44px; }
}

@media (max-width: 420px) {
    .facts { grid-template-columns: 1fr; }
    .stats span { font-size: 11px; }
    .service-card .actions .btn,
    .service-card .actions form { flex-basis: 100%; }
}
