:root {
    color-scheme: light;

    --bg: #F4F6F9;
    --surface: #FFFFFF;
    --surface-2: #EEF2F6;
    --border: #DDE3EA;

    --text: #202631;
    --text-muted: #687386;

    --accent: #0B7DDA;
    --accent-hover: #096DBC;
    --accent-text: #FFFFFF;
    --accent-soft: #E6F2FC;

    --badge-bg: #E9EEF4;
    --badge-text: #465365;

    --success-bg: #E8F7EE;
    --success-border: #B8E5C8;
    --success-text: #216E3A;

    --error-bg: #FCEBEC;
    --error-border: #F1C2C6;
    --error-text: #A52A34;

    --shadow: 0 4px 18px rgba(27, 39, 51, 0.06);
    --shadow-hover: 0 10px 28px rgba(27, 39, 51, 0.10);
    --shadow-menu: 0 12px 32px rgba(27, 39, 51, 0.14);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-round: 999px;

    --transition: 180ms ease;
}

[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0F1420;
    --surface: #1A2130;
    --surface-2: #222B3C;
    --border: #2A3344;

    --text: #E8ECF4;
    --text-muted: #9AA5B8;

    --accent: #4DA3FF;
    --accent-hover: #70B5FF;
    --accent-text: #08121E;
    --accent-soft: #172B44;

    --badge-bg: #252E3E;
    --badge-text: #C5CDDA;

    --success-bg: #14291D;
    --success-border: #285E3A;
    --success-text: #82D6A0;

    --error-bg: #31191D;
    --error-border: #673039;
    --error-text: #F29AA2;

    --shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
    --shadow-hover: 0 8px 20px rgba(0, 0, 0, 0.18);
    --shadow-menu: 0 12px 32px rgba(0, 0, 0, 0.28);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    transition:
        background var(--transition),
        color var(--transition);
}

button,
input {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    color: inherit;
}

[hidden] {
    display: none !important;
}

/* TOPBAR */

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    width: min(1180px, calc(100% - 40px));
    height: 68px;
    margin: auto;

    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 750;
}

.brand-icon {
    color: var(--accent);
}

.topbar-actions {
    position: relative;
    display: flex;
    gap: 8px;
}

.icon-button {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    cursor: pointer;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    transition:
        transform var(--transition),
        border-color var(--transition),
        color var(--transition);
}

.icon-button:hover {
    transform: translateY(-1px);
    border-color: var(--accent);
    color: var(--accent);
}

/* USER MENU */

.user-menu {
    position: relative;
}

.dropdown {
    position: absolute;
    top: 50px;
    right: 0;

    width: 190px;
    padding: 7px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-menu);
}

.dropdown-link,
.dropdown-button {
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;

    display: flex;
    align-items: center;
    gap: 9px;

    background: transparent;
    color: var(--text);

    border: 0;
    border-radius: var(--radius-sm);

    cursor: pointer;
    text-align: left;
}

.dropdown-link:hover,
.dropdown-button:hover {
    background: var(--surface-2);
}

.dropdown form {
    margin: 0;
}

/* LAYOUT */

.page-container {
    width: min(1180px, calc(100% - 40px));
    margin: auto;
    padding: 44px 0 72px;
}

.page-header {
    margin-bottom: 26px;

    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 7px;
    font-size: clamp(30px, 4vw, 42px);
    letter-spacing: -0.035em;
}

h2 {
    margin-bottom: 8px;
}

.eyebrow {
    margin-bottom: 6px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.page-description,
.muted {
    color: var(--text-muted);
}

.page-description {
    margin: 0;
}

/* BUTTONS */

.button {
    min-height: 42px;
    padding: 9px 16px;

    border: 1px solid transparent;
    border-radius: var(--radius-sm);

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;

    font-weight: 650;
    cursor: pointer;

    transition:
        transform var(--transition),
        background var(--transition),
        border-color var(--transition);
}

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

.button-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

.button-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.button-secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

/* FLASH */

.flash-container {
    margin-bottom: 22px;
    display: grid;
    gap: 10px;
}

.flash-message {
    padding: 13px 16px;
    border: 1px solid;
    border-radius: var(--radius-md);
}

.flash-success {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-text);
}

.flash-error {
    background: var(--error-bg);
    border-color: var(--error-border);
    color: var(--error-text);
}

/* LOGIN */

.login-shell {
    min-height: calc(100vh - 180px);

    display: flex;
    justify-content: center;
    align-items: center;
}

.login-card {
    width: min(430px, 100%);
    padding: 34px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.login-card h1 {
    font-size: 30px;
}

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

/* FORM */

.form-group {
    margin-bottom: 17px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;

    font-size: 14px;
    font-weight: 650;
}

.form-control {
    width: 100%;
    min-height: 44px;
    padding: 9px 12px;

    background: var(--surface);
    color: var(--text);

    border: 1px solid var(--border);
    border-radius: var(--radius-sm);

    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
}

.form-panel {
    margin-bottom: 26px;
    padding: 24px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

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

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

/* HOME CATEGORY CARDS */

.category-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

.category-card {
    min-height: 220px;
    padding: 28px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);

    display: flex;
    flex-direction: column;
    justify-content: space-between;

    transition:
        transform var(--transition),
        box-shadow var(--transition),
        border-color var(--transition);
}

.category-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: var(--accent);
}

.category-icon {
    font-size: 42px;
}

.category-card h2 {
    font-size: 25px;
}

.category-count {
    color: var(--text-muted);
}

/* VEHICLES */

.vehicle-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.vehicle-card {
    padding: 23px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);

    transition:
        transform var(--transition),
        box-shadow var(--transition);
}

.vehicle-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.vehicle-brand {
    margin-bottom: 3px;

    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.vehicle-card h2 {
    margin-bottom: 4px;
}

.vehicle-description {
    min-height: 24px;
    margin-bottom: 19px;
    color: var(--text-muted);
}

.vehicle-actions {
    margin-top: 20px;
    padding-top: 18px;

    border-top: 1px solid var(--border);

    display: flex;
    justify-content: flex-end;
}

.button-small {
    min-height: 36px;
    padding: 7px 12px;

    font-size: 13px;
}

.badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.badge {
    padding: 5px 10px;

    background: var(--badge-bg);
    color: var(--badge-text);

    border: 1px solid var(--border);
    border-radius: var(--radius-round);

    font-size: 13px;
    font-weight: 700;
}

/* EMPTY STATE */

.empty-state {
    padding: 55px 25px;
    text-align: center;

    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
}

.empty-icon {
    margin-bottom: 12px;
    font-size: 38px;
}

/* STATS */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.stat-card {
    padding: 25px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.stat-label {
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 14px;
}

.stat-value {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.stat-unit {
    margin-left: 3px;
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 650;
}

.preview-card {
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

/* MOBILE */

@media (max-width: 850px) {
    .vehicle-grid,
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 650px) {
    .topbar-inner,
    .page-container {
        width: calc(100% - 24px);
    }

    .topbar-inner {
        height: 62px;
    }

    .brand {
        font-size: 16px;
    }

    .brand-icon {
        display: none;
    }

    .page-container {
        padding-top: 30px;
    }

    .page-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .category-grid,
    .vehicle-grid,
    .stats-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .category-card {
        min-height: 180px;
    }

    .login-card {
        padding: 24px;
    }
}
