:root {
    color-scheme: light;
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-soft: #ecf6fb;
    --surface-muted: #f8fafc;
    --ink: #17324d;
    --muted: #66768a;
    --line: #d8e2eb;
    --blue: #2368b8;
    --cyan: #0d8aa4;
    --green: #258b62;
    --amber: #a86416;
    --danger: #b42335;
    --shadow: 0 10px 24px rgba(23, 50, 77, 0.07);
    --shadow-soft: 0 4px 14px rgba(23, 50, 77, 0.05);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: linear-gradient(180deg, #f9fbfd 0, var(--bg) 280px);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px clamp(16px, 4vw, 42px);
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.brand,
.topnav,
.hero-actions,
.card-actions,
.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topnav {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.brand {
    color: var(--ink);
    font-weight: 800;
}

.brand-mark {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 8px;
    background: var(--ink);
    color: #ffffff;
    font-size: 0.78rem;
    letter-spacing: 0;
}

.topnav a:not(.button) {
    color: var(--muted);
    font-weight: 650;
}

.topnav a[aria-current="page"] {
    color: var(--ink);
}

.logout-form {
    display: flex;
    margin: 0;
}

.user-chip {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 750;
}

.page {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
    padding: 22px 0 48px;
}

.page-header,
.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 4px 0 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.page-header h1,
.detail-header h1,
.form-shell h1 {
    margin: 0;
    font-size: clamp(1.9rem, 3vw, 2.6rem);
    line-height: 1.12;
    letter-spacing: 0;
}

.detail-header h1,
.form-shell h1 {
    font-size: clamp(1.8rem, 3vw, 2.6rem);
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--cyan);
    font-size: 0.77rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.detail-subtitle,
.vehicle-subtitle,
.muted,
.cell-note,
.help-text {
    color: var(--muted);
}

.button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    font-weight: 750;
    line-height: 1;
    cursor: pointer;
    transition:
        background 0.16s ease,
        border-color 0.16s ease,
        color 0.16s ease,
        transform 0.16s ease;
}

.button:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.button-primary {
    border-color: var(--blue);
    background: var(--blue);
    color: #ffffff;
}

.button-primary:hover {
    background: #1e5da7;
}

.button-quiet {
    border-color: #bbd8ea;
    background: var(--surface-soft);
    color: #17466f;
}

.button-ghost {
    background: transparent;
}

.button-ghost:hover {
    background: var(--surface-muted);
}

.button-danger {
    border-color: #f1c1c8;
    background: #fff0f2;
    color: var(--danger);
}

.metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.metric,
.panel,
.vehicle-card,
.empty-state,
.form-shell {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.metric {
    padding: 16px 18px;
}

.metric-label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.metric strong,
.summary-panel strong {
    display: block;
    font-size: 1.9rem;
    line-height: 1.1;
}

.dashboard-grid,
.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 18px;
    align-items: start;
}

.detail-grid {
    grid-template-columns: minmax(0, 1fr) 280px;
    margin-bottom: 22px;
}

.side-stack {
    display: grid;
    gap: 18px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.section-heading h2,
.panel h2,
.empty-state h2,
.vehicle-card h3 {
    margin: 0;
    letter-spacing: 0;
}

.vehicle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 14px;
}

.vehicle-card,
.panel,
.empty-state {
    padding: 18px;
}

.vehicle-card {
    display: flex;
    min-height: 270px;
    flex-direction: column;
}

.card-topline {
    display: flex;
    min-height: 28px;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.vehicle-card h3 {
    font-size: 1.15rem;
}

.vehicle-subtitle {
    min-height: 24px;
    margin: 6px 0 0;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #edf7f3;
    color: var(--green);
    font-size: 0.8rem;
    font-weight: 800;
}

.compact-list,
.spec-grid {
    display: grid;
    gap: 9px;
    margin: 16px 0;
}

.compact-list div,
.spec-grid div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid #edf1f5;
    padding-bottom: 8px;
}

dt {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

dd {
    margin: 0;
    text-align: right;
    font-weight: 700;
}

.summary-panel {
    min-height: 150px;
}

.card-actions {
    margin-top: auto;
    padding-top: 2px;
}

.card-actions .button {
    width: 100%;
}

.panel {
    box-shadow: none;
}

.side-stack .panel {
    background: var(--surface-muted);
}

.side-stack .section-heading {
    margin-bottom: 14px;
}

.note-block {
    margin-top: 14px;
    padding: 14px;
    border-radius: 8px;
    background: #fff9eb;
    color: #554113;
}

.timeline-list,
.attachment-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.timeline-list {
    display: grid;
    gap: 13px;
}

.timeline-list li {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
}

.timeline-list a {
    font-weight: 800;
}

.timeline-list div {
    min-width: 0;
}

.timeline-list p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.date-chip {
    display: inline-flex;
    width: 92px;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    border-radius: 8px;
    background: #e7f1ff;
    color: #164d86;
    font-size: 0.84rem;
    font-weight: 850;
}

.history-section {
    margin-top: 22px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.history-table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
}

.history-table th,
.history-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.history-table th {
    background: #f0f6fb;
    color: #405269;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.history-table tbody tr:hover {
    background: #fbfdff;
}

.history-table p {
    margin: 5px 0 0;
    color: #405269;
}

.cell-note,
.due-note,
.mini-link {
    display: block;
    margin-top: 4px;
    font-size: 0.86rem;
}

.due-note {
    color: var(--cyan);
    font-weight: 750;
}

.attachment-list li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.link-danger,
.danger-link {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--danger);
    font: inherit;
    cursor: pointer;
}

.actions-col {
    width: 120px;
}

.actions-col a {
    display: block;
    margin-bottom: 5px;
}

.empty-state {
    padding: 28px;
    text-align: center;
}

.empty-state p {
    max-width: 520px;
    margin: 8px auto 18px;
    color: var(--muted);
}

.form-shell {
    max-width: 900px;
    margin: 0 auto;
    padding: clamp(18px, 4vw, 34px);
    box-shadow: var(--shadow-soft);
}

.form-shell.narrow {
    max-width: 600px;
}

.back-link {
    display: inline-block;
    margin-bottom: 14px;
    color: var(--muted);
    font-weight: 750;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.field {
    display: grid;
    gap: 6px;
}

.field:has(textarea),
.field-full,
.form-actions,
.form-errors {
    grid-column: 1 / -1;
}

label {
    color: #33475f;
    font-weight: 800;
}

.field-control,
.field-select,
.form-grid input[type="text"],
.form-grid input[type="password"],
.form-grid input[type="email"] {
    width: 100%;
    min-height: 42px;
    border: 1px solid #cbd8e4;
    border-radius: 8px;
    padding: 10px 12px;
    background: #ffffff;
    color: var(--ink);
    font: inherit;
}

.field-control:focus,
.field-select:focus,
.button:focus-visible,
a:focus-visible,
.link-danger:focus-visible {
    outline: 3px solid rgba(35, 104, 184, 0.24);
    outline-offset: 2px;
}

.field-textarea {
    min-height: 120px;
    resize: vertical;
}

.help-text {
    font-size: 0.86rem;
}

.field-errors,
.form-errors {
    color: var(--danger);
    font-weight: 750;
}

.messages {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.message {
    padding: 12px 14px;
    border: 1px solid #bfe5cf;
    border-radius: 8px;
    background: #effaf4;
    color: #155b39;
    font-weight: 750;
}

@media (max-width: 850px) {
    .topbar,
    .page-header,
    .detail-header,
    .hero-actions,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .topnav,
    .hero-actions,
    .form-actions {
        width: 100%;
    }

    .topnav .button,
    .hero-actions .button,
    .form-actions .button {
        flex: 1;
    }

    .metrics,
    .dashboard-grid,
    .detail-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .history-table {
        min-width: 760px;
    }
}

@media (max-width: 520px) {
    .page {
        width: min(100% - 18px, 1180px);
        padding-top: 14px;
    }

    .page-header,
    .detail-header,
    .form-shell,
    .empty-state {
        padding: 18px;
    }

    .page-header {
        padding-inline: 0;
    }

    .topnav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .user-chip,
    .logout-form,
    .logout-form .button {
        width: 100%;
    }

    .button {
        min-height: 42px;
        padding-inline: 12px;
    }
}
