﻿:root {
    --background: #0f1118;
    --sidebar-background: #11141d;
    --surface: #181c27;
    --surface-raised: #202532;
    --surface-hover: #282e3d;
    --border: #353b4a;
    --border-light: #444b5d;
    --text: #f1f3f8;
    --text-muted: #a9b0c1;
    --text-faint: #737b8f;
    --accent: #646cff;
    --accent-hover: #777eff;
    --accent-soft: rgba(100, 108, 255, 0.15);
    --success: #49c97b;
    --success-soft: rgba(73, 201, 123, 0.14);
    --warning: #f2bd4b;
    --warning-soft: rgba(242, 189, 75, 0.14);
    --danger: #ef6262;
    --danger-hover: #ff7474;
    --danger-soft: rgba(239, 98, 98, 0.14);
    --sidebar-width: 255px;
    --sidebar-collapsed-width: 72px;
    --radius-small: 7px;
    --radius-medium: 12px;
    --radius-large: 18px;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.24);
    --transition: 180ms ease;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color-scheme: dark;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--background);
    color: var(--text);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    color: inherit;
}

a {
    color: inherit;
}

img,
svg {
    display: block;
    max-width: 100%;
}

/* --------------------------------------------------
   Sidebar
-------------------------------------------------- */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    width: var(--sidebar-width);
    min-height: 100vh;
    padding: 14px 12px;
    background: var(--sidebar-background);
    border-right: 1px solid var(--border);
    overflow-x: hidden;
    overflow-y: auto;
    transition: width var(--transition), transform var(--transition);
}

    .sidebar.collapsed {
        width: var(--sidebar-collapsed-width);
    }

.sidebar-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    align-items: center;
    gap: 8px;
    min-height: 55px;
    margin-bottom: 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    flex: 1;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient( 135deg, var(--accent), #8d5cff );
    color: white;
    font-size: 1.15rem;
    font-weight: 800;
    box-shadow: 0 8px 22px rgba(100, 108, 255, 0.28);
}

.brand-name {
    overflow: hidden;
    font-size: 1.25rem;
    font-weight: 750;
    letter-spacing: 0.01em;
    white-space: nowrap;
    transition: opacity var(--transition), width var(--transition);
}

.sidebar-toggle {
    display: grid;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

    .sidebar-toggle:hover {
        background: var(--surface-hover);
        border-color: var(--border);
        color: var(--text);
    }

.nav-list,
.nav-submenu {
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nav-link {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) 22px;
    align-items: center;
    column-gap: 12px;
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

    .nav-link:hover {
        background: var(--surface-hover);
        color: var(--text);
    }

    .nav-link.active {
        background: var(--accent-soft);
        border-color: rgba(100, 108, 255, 0.34);
        color: #dfe1ff;
    }

.nav-icon {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    justify-self: center;
    font-size: 1.15rem;
}

.nav-text {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    font-weight: 550;
    white-space: nowrap;
}

.nav-chevron {
    justify-self: center;
    font-size: 1rem;
    transition: transform var(--transition);
}

.nav-dropdown-button[aria-expanded="true"] .nav-chevron {
    transform: rotate(180deg);
}

.nav-submenu {
    display: none;
    margin: 2px 0 6px 43px;
    padding-left: 11px;
    border-left: 1px solid var(--border);
}

    .nav-submenu.open {
        display: block;
    }

    .nav-submenu li + li {
        margin-top: 3px;
    }

    .nav-submenu a {
        display: block;
        padding: 8px 10px;
        border-radius: 8px;
        color: var(--text-muted);
        font-size: 0.9rem;
        text-decoration: none;
        transition: background var(--transition), color var(--transition);
    }

        .nav-submenu a:hover {
            background: var(--surface-hover);
            color: var(--text);
        }

        .nav-submenu a.active {
            background: var(--accent-soft);
            color: #dfe1ff;
        }

.sidebar.collapsed .brand-name,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-chevron {
    display: none;
}

.sidebar.collapsed .nav-link {
    grid-template-columns: 30px;
    justify-content: center;
    justify-items: center;
    min-height: 46px;
    padding: 8px;
}

.sidebar.collapsed .nav-icon {
    justify-self: center;
}

.sidebar.collapsed .nav-submenu {
    display: none;
}

.sidebar.collapsed .nav-link {
    grid-template-columns: 1fr;
    justify-items: center;
    padding-inline: 8px;
}

.sidebar.collapsed .nav-icon {
    justify-self: center;
}

.sidebar.collapsed .nav-submenu {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    grid-template-columns: 1fr;
}

.sidebar.collapsed .brand {
    display: none;
}

.sidebar.collapsed .sidebar-toggle {
    justify-self: center;
    margin: 0;
}

/* --------------------------------------------------
   Main page structure
-------------------------------------------------- */

.page-shell {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    padding: 34px;
    transition: margin-left var(--transition);
}

body.sidebar-is-collapsed .page-shell {
    margin-left: var(--sidebar-collapsed-width);
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 28px;
    margin-bottom: 26px;
}

    .page-header h1 {
        margin: 0;
        font-size: clamp(1.8rem, 3vw, 2.45rem);
        line-height: 1.15;
        letter-spacing: -0.035em;
    }

.page-eyebrow {
    margin: 0 0 7px;
    color: var(--accent-hover);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.page-description {
    max-width: 680px;
    margin: 9px 0 0;
    color: var(--text-muted);
    font-size: 0.98rem;
    line-height: 1.65;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

/* --------------------------------------------------
   Buttons
-------------------------------------------------- */

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 650;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
}

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

    .button:active:not(:disabled) {
        transform: translateY(0);
    }

    .button:focus-visible,
    .sidebar-toggle:focus-visible,
    .nav-link:focus-visible,
    .dialog-close:focus-visible {
        outline: 3px solid rgba(100, 108, 255, 0.35);
        outline-offset: 2px;
    }

    .button:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

.button-primary {
    background: linear-gradient( 135deg, var(--accent), #7b5cff );
    color: white;
    box-shadow: 0 8px 20px rgba(100, 108, 255, 0.2);
}

    .button-primary:hover:not(:disabled) {
        background: linear-gradient( 135deg, var(--accent-hover), #8c70ff );
        box-shadow: 0 10px 26px rgba(100, 108, 255, 0.3);
    }

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

    .button-secondary:hover:not(:disabled) {
        background: var(--surface-hover);
        border-color: var(--border-light);
    }

.button-save {
    background: var(--success);
    color: #07180d;
}

    .button-save:hover:not(:disabled) {
        background: #5cda8d;
        box-shadow: 0 8px 22px rgba(73, 201, 123, 0.2);
    }

.button-danger {
    background: var(--danger);
    color: white;
}

    .button-danger:hover:not(:disabled) {
        background: var(--danger-hover);
        box-shadow: 0 8px 22px rgba(239, 98, 98, 0.2);
    }

/* --------------------------------------------------
   Forms
-------------------------------------------------- */

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    background: #11151e;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input,
select {
    min-height: 42px;
    padding: 9px 11px;
}

textarea {
    min-height: 95px;
    padding: 11px;
    line-height: 1.5;
    resize: vertical;
}

    input::placeholder,
    textarea::placeholder {
        color: var(--text-faint);
    }

    input:hover,
    select:hover,
    textarea:hover {
        border-color: var(--border-light);
    }

    input:focus,
    select:focus,
    textarea:focus {
        outline: none;
        border-color: var(--accent);
        background: #141925;
        box-shadow: 0 0 0 3px rgba(100, 108, 255, 0.14);
    }

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

.form-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

    .form-field > span {
        color: var(--text-muted);
        font-size: 0.84rem;
        font-weight: 650;
    }

    .form-field.required > span::after {
        margin-left: 4px;
        color: var(--danger);
        content: "*";
    }

.form-field-full {
    grid-column: 1 / -1;
}

/* --------------------------------------------------
   Dialogs
-------------------------------------------------- */

dialog {
    color: var(--text);
}

    dialog::backdrop {
        background: rgba(3, 5, 10, 0.76);
        backdrop-filter: blur(4px);
    }

.vehicle-dialog,
.confirm-dialog {
    width: min(760px, calc(100vw - 32px));
    max-height: calc(100vh - 40px);
    margin: auto;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-large);
    background: var(--surface);
    box-shadow: var(--shadow);
}

    .vehicle-dialog[open],
    .confirm-dialog[open] {
        animation: dialog-enter 170ms ease-out;
    }

.vehicle-form {
    padding: 26px;
}

.dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

    .dialog-header h2,
    .confirm-dialog h2 {
        margin: 0;
        font-size: 1.45rem;
    }

.dialog-close {
    display: grid;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

    .dialog-close:hover {
        background: var(--surface-hover);
        border-color: var(--border);
        color: var(--text);
    }

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.confirm-dialog {
    width: min(480px, calc(100vw - 32px));
}

.confirm-dialog-content {
    padding: 28px;
}

    .confirm-dialog-content p {
        margin: 12px 0 0;
        color: var(--text-muted);
        line-height: 1.6;
    }

/* --------------------------------------------------
   Messages
-------------------------------------------------- */

.message {
    display: none;
    margin: 12px 0;
    padding: 11px 13px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: 0.9rem;
    line-height: 1.45;
}

    .message:not(:empty) {
        display: block;
    }

    .message.success {
        background: var(--success-soft);
        border-color: rgba(73, 201, 123, 0.32);
        color: #9aefb9;
    }

    .message.error {
        background: var(--danger-soft);
        border-color: rgba(239, 98, 98, 0.34);
        color: #ffb3b3;
    }

    .message.warning {
        background: var(--warning-soft);
        border-color: rgba(242, 189, 75, 0.34);
        color: #ffdb8a;
    }

/* --------------------------------------------------
   Utilities
-------------------------------------------------- */

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

.no-scroll {
    overflow: hidden;
}

@keyframes dialog-enter {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.985);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --------------------------------------------------
   Responsive layout
-------------------------------------------------- */

@media (max-width: 1000px) {
    .page-shell {
        padding: 26px 22px;
    }

    .page-header {
        flex-direction: column;
    }

    .page-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 760px) {
    :root {
        --sidebar-width: 100%;
    }

    .sidebar {
        position: sticky;
        inset: 0;
        width: 100%;
        min-height: auto;
        height: auto;
        padding: 9px 12px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

        .sidebar.collapsed {
            width: 100%;
        }

    .sidebar-header {
        min-height: 45px;
        margin-bottom: 0;
    }

    .brand-mark {
        flex-basis: 38px;
        width: 38px;
        height: 38px;
    }

    .nav-list {
        display: none;
        padding-top: 10px;
    }

    .sidebar.mobile-open .nav-list {
        display: flex;
    }

    .sidebar.collapsed .brand-name {
        width: auto;
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar.collapsed .nav-text,
    .sidebar.collapsed .nav-chevron {
        width: auto;
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar.collapsed .nav-link {
        justify-content: flex-start;
        padding-inline: 12px;
    }

    .sidebar.collapsed .nav-submenu.open {
        display: block;
    }

    .page-shell,
    body.sidebar-is-collapsed .page-shell {
        margin-left: 0;
        padding: 22px 14px 40px;
    }

    .page-header {
        gap: 18px;
        margin-bottom: 20px;
    }

    .page-actions {
        width: 100%;
    }

        .page-actions .button {
            flex: 1;
        }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-field-full {
        grid-column: auto;
    }

    .vehicle-form,
    .confirm-dialog-content {
        padding: 21px;
    }

    .dialog-footer {
        flex-direction: column-reverse;
    }

        .dialog-footer .button {
            width: 100%;
        }
}
