:root {
    --bg: #eef4fa;
    --bg-accent: #d7e8f7;
    --ink: #1d2a3a;
    --muted: #5d6d80;
    --line: #d4e1ee;
    --brand: #2f86d1;
    --brand-dark: #2164ab;
    --brand-soft: #e3f1fc;
    --surface: #ffffff;
    --surface-2: #f6fbff;
    --danger: #c44747;
    --danger-bg: #fdeeee;
    --success: #2e9a5b;
    --shadow: 0 16px 36px rgba(45, 90, 130, 0.1);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Barlow", "Segoe UI", sans-serif;
    color: var(--ink);
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 50% at 8% -8%, rgba(74, 163, 234, 0.22), transparent 52%),
        radial-gradient(ellipse 55% 40% at 100% 0%, rgba(47, 134, 209, 0.1), transparent 46%),
        linear-gradient(180deg, #f7fbff 0%, var(--bg) 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent 0,
            transparent 47px,
            rgba(47, 134, 209, 0.04) 47px,
            rgba(47, 134, 209, 0.04) 48px
        ),
        repeating-linear-gradient(
            0deg,
            transparent 0,
            transparent 47px,
            rgba(47, 134, 209, 0.04) 47px,
            rgba(47, 134, 209, 0.04) 48px
        );
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 72%);
    z-index: 0;
}

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

a:hover {
    color: var(--brand-dark);
}

.page {
    position: relative;
    z-index: 1;
    max-width: 1120px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 28px 20px 32px;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px 12px 14px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    border-radius: 14px;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
}

.logo:hover {
    color: var(--ink);
}

.logo-mark {
    display: grid;
    place-items: center;
    width: 56px;
    height: 32px;
}

.logo-mark svg {
    width: 56px;
    height: 32px;
}

.logo-text {
    display: flex;
    align-items: center;
    line-height: 1.05;
}

.logo-name {
    font-family: "Oswald", sans-serif;
    font-weight: 700;
    font-size: 1.35rem;
    letter-spacing: 0.06em;
}

.nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.92rem;
    letter-spacing: 0.02em;
}

.nav-link:hover,
.nav-link.is-active {
    color: var(--brand-dark);
    background: var(--brand-soft);
}

.nav-form {
    margin: 0;
}

.nav-link-button {
    border: 0;
    background: transparent;
    font: inherit;
    cursor: pointer;
}

.main {
    flex: 1;
    padding: 44px 8px 24px;
}

.footer {
    color: var(--muted);
    font-size: 0.88rem;
    text-align: center;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--brand);
    font-family: "Oswald", sans-serif;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-size: 0.82rem;
}

h1,
h2 {
    margin: 0 0 12px;
    font-family: "Oswald", sans-serif;
    line-height: 1.15;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

h1 {
    font-size: clamp(2.1rem, 5vw, 3.6rem);
    font-weight: 700;
}

h2 {
    font-size: 1.15rem;
    font-weight: 600;
}

.lead {
    max-width: 640px;
    margin: 0 0 28px;
    color: var(--muted);
    font-size: 1.08rem;
    line-height: 1.7;
}

.hero {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 32px;
    align-items: center;
    padding: 8px 0 40px;
}

.hero-copy {
    min-width: 0;
}

.hero-visual {
    position: relative;
    min-height: 260px;
    display: grid;
    place-items: center;
    padding: 28px 20px 12px;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 18%, rgba(74, 163, 234, 0.14), transparent 48%),
        linear-gradient(180deg, #f4f9fe, var(--surface));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.hero-logo {
    display: block;
    width: min(100%, 260px);
    height: auto;
    filter: drop-shadow(0 12px 20px rgba(47, 134, 209, 0.16));
}

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 13px 22px;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(180deg, #4aa3ea, var(--brand));
    color: #fff;
    font-family: "Oswald", sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(47, 134, 209, 0.22);
}

.button:hover {
    background: linear-gradient(180deg, #5eb0f0, var(--brand-dark));
    color: #fff;
}

.button-ghost {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    box-shadow: none;
}

.button-ghost:hover {
    background: var(--brand-soft);
    color: var(--brand-dark);
    border-color: rgba(47, 134, 209, 0.35);
}

.button-danger {
    background: linear-gradient(180deg, #e06a6a, var(--danger));
    box-shadow: 0 10px 22px rgba(196, 71, 71, 0.22);
}

.button-danger:hover {
    background: linear-gradient(180deg, #ea7c7c, #a83838);
    color: #fff;
}

.button-success {
    background: linear-gradient(180deg, #4cbb75, var(--success));
    box-shadow: 0 10px 22px rgba(46, 154, 91, 0.22);
}

.button-success:hover {
    background: linear-gradient(180deg, #5cc884, #268a50);
    color: #fff;
}

.order-delete {
    display: flex;
    justify-content: flex-end;
    margin-top: 24px;
}

.button-sm {
    padding: 8px 14px;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
}

.button-danger.button-sm {
    box-shadow: 0 6px 14px rgba(196, 71, 71, 0.16);
}

.button-success.button-sm {
    box-shadow: 0 6px 14px rgba(46, 154, 91, 0.16);
}

.modal-confirm {
    width: min(440px, 100%);
    max-height: none;
    border-top-color: var(--danger);
}

.modal-confirm .modal-head {
    padding: 24px 24px 8px;
}

.modal-confirm .modal-head h2 {
    font-size: 1.15rem;
    line-height: 1.4;
}

.modal-confirm-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding: 12px 24px 24px;
}

.button-block {
    width: 100%;
}

.cards,
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.card,
.stat-card,
.auth-card,
.panel,
.content-block {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card,
.content-block,
.stat-card,
.panel {
    padding: 24px;
}

.card {
    position: relative;
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--brand);
}

.card-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    margin-bottom: 14px;
    border-radius: 11px;
    background: var(--brand-soft);
    color: var(--brand);
    font-family: Oswald, sans-serif;
    font-size: 20px;
    font-weight: 600;
    line-height: 1;
}

.card p,
.content-block p {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
}

.auth-wrap {
    display: grid;
    grid-template-columns: minmax(220px, 0.85fr) minmax(280px, 1.15fr);
    gap: 20px;
    align-items: stretch;
}

.auth-aside {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 420px;
    padding: 28px;
    background:
        radial-gradient(circle at 30% 18%, rgba(74, 163, 234, 0.18), transparent 46%),
        linear-gradient(180deg, #eaf4fd, #f7fbff);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-aside-start {
    justify-content: flex-start;
}

.auth-aside h2 {
    margin: 0 0 8px;
    font-size: 1.8rem;
}

.auth-aside p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.auth-card {
    width: 100%;
    padding: 32px;
}

.form {
    display: grid;
    gap: 16px;
}

.field {
    display: grid;
    gap: 8px;
    font-weight: 600;
}

.field > input[type="hidden"] {
    display: none;
}

.field input,
.field select {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
}

.field select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 36px;
}

.field input:focus,
.field select:focus {
    outline: 2px solid var(--brand-soft);
    border-color: var(--brand);
    background-color: #fff;
}

.field select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.alert {
    margin: 0 0 20px;
    padding: 14px 16px;
    border-radius: 10px;
    background: var(--danger-bg);
    color: var(--danger);
    list-style: none;
    border: 1px solid rgba(196, 71, 71, 0.18);
}

.alert-success {
    background: #eef8f2;
    color: var(--success);
    border-color: rgba(46, 154, 91, 0.22);
}

.form-note {
    margin: 20px 0 0;
    color: var(--muted);
    text-align: center;
}

.panel {
    padding: 32px;
    border-top: 4px solid var(--brand);
}

.stat-grid {
    margin: 0 0 28px;
}

.stat-card {
    background: var(--surface-2);
}

.stat-label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.data-table th,
.data-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.data-table th {
    color: var(--brand-dark);
    background: var(--surface-2);
    font-family: "Oswald", sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.data-table tbody tr:not(.order-group-head):hover {
    background: var(--brand-soft);
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr.work-price-row td {
    padding-top: 8px;
    padding-bottom: 8px;
    color: var(--muted);
    background: var(--surface-2);
    font-size: 0.92rem;
}

.data-table tbody tr.work-price-row:hover td {
    background: var(--brand-soft);
}

.data-table tbody.order-group .order-group-head td {
    padding: 10px 14px 10px 18px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    border-bottom: 1px solid var(--line);
    box-shadow: inset 4px 0 0 var(--brand);
    font-family: "Oswald", sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.data-table tbody.order-group + tbody.order-group .order-group-head td {
    border-top: 12px solid var(--surface);
}

.data-table tbody.order-group tr:not(.order-group-head) td:first-child {
    padding-left: 18px;
    box-shadow: inset 4px 0 0 var(--brand);
}

.data-table tbody.order-group:nth-of-type(even) .order-group-head td {
    background: #edf4fb;
    box-shadow: inset 4px 0 0 #6aa9dc;
}

.data-table tbody.order-group:nth-of-type(even) tr:not(.order-group-head) {
    background: var(--surface-2);
}

.data-table tbody.order-group:nth-of-type(even) tr:not(.order-group-head) td:first-child {
    box-shadow: inset 4px 0 0 #6aa9dc;
}

.data-table tbody.order-group .order-group-head:hover td {
    background: var(--brand-soft);
}

.data-table tbody.order-group:nth-of-type(even) .order-group-head:hover td {
    background: #edf4fb;
}

.order-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.order-link:hover {
    color: var(--brand-dark);
}

.order-spec {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px 20px;
    margin: 24px 0;
    padding: 20px 24px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.data-table tfoot td {
    padding: 12px 14px;
    font-weight: 700;
    background: var(--surface-2);
    border-bottom: 0;
}

.data-table td.cell-wrap {
    white-space: normal;
    min-width: 180px;
}

.content-block + .content-block {
    margin-top: 16px;
}

.content-block h2 {
    color: var(--brand);
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}

.panel-head .lead {
    margin-bottom: 0;
}

.car-form {
    max-width: 640px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.order-form {
    max-width: 860px;
}

.order-form .actions {
    justify-content: flex-end;
}

.order-form .field > span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.order-form .field input,
.order-form .field select {
    font-weight: 600;
    color: var(--ink);
}

.order-items-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 8px 0 0;
}

.order-items-head h2 {
    margin: 0;
    text-transform: none;
    letter-spacing: 0;
}

.order-works,
.order-items,
.work-items {
    display: grid;
    gap: 16px;
}

.order-add-work {
    display: flex;
    justify-content: flex-start;
}

.order-work,
.order-item {
    display: grid;
    gap: 16px;
    padding: 24px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.order-work .order-item {
    background: var(--surface);
}

.order-item-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.order-item-head h2 {
    margin: 0;
    text-transform: none;
    letter-spacing: 0;
}

.button:disabled,
.button-ghost:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.form-loading {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(29, 42, 58, 0.46);
}

.form-loading[hidden] {
    display: none !important;
}

.form-loading-box {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 4px solid var(--brand);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--ink);
    font-weight: 600;
}

.form-loading-spinner {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border: 3px solid var(--brand-soft);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: form-loading-spin 0.7s linear infinite;
}

@keyframes form-loading-spin {
    to {
        transform: rotate(360deg);
    }
}

.catalog-picker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px 10px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}

.catalog-picker-value {
    margin: 0;
    min-width: 0;
    font-weight: 600;
    line-height: 1.45;
    white-space: normal;
}

.catalog-picker-value.is-empty {
    color: var(--muted);
    font-weight: 500;
}

.catalog-picker-open {
    flex: 0 0 auto;
    padding: 10px 16px;
}

body.modal-open {
    overflow: hidden;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(29, 42, 58, 0.46);
}

.modal-overlay[hidden] {
    display: none !important;
}

.modal {
    display: flex;
    flex-direction: column;
    width: min(720px, 100%);
    max-height: min(82vh, 760px);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 4px solid var(--brand);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px 8px;
}

.modal-head h2 {
    margin: 0;
    text-transform: none;
    letter-spacing: 0;
    font-size: 1.25rem;
}

.modal-search {
    padding: 8px 20px 12px;
}

.modal-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0 12px 12px 20px;
}

.modal-hint {
    margin: 0;
    padding: 12px 20px 18px;
    color: var(--muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--line);
}

.catalog-tree-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.catalog-tree-list .catalog-tree-list {
    padding-left: 18px;
}

.catalog-tree-item.is-collapsed > .catalog-tree-list {
    display: none;
}

.catalog-tree-item.is-hidden {
    display: none;
}

.catalog-tree-row {
    display: flex;
    align-items: center;
    gap: 2px;
}

.catalog-tree-toggle {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}

.catalog-tree-toggle::before {
    content: "";
    display: block;
    width: 0;
    height: 0;
    margin: 0 auto;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 6px solid var(--muted);
}

.catalog-tree-item.has-children:not(.is-collapsed) > .catalog-tree-row .catalog-tree-toggle::before {
    transform: rotate(90deg);
}

.catalog-tree-toggle:disabled {
    opacity: 0;
    cursor: default;
}

.catalog-tree-node {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.catalog-tree-node:hover,
.catalog-tree-node.is-selected {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.catalog-page {
    display: grid;
    gap: 16px;
    margin-top: 8px;
}

.catalog-page-search {
    max-width: 420px;
}

.catalog-page-tree .catalog-tree-row {
    gap: 8px;
    flex-wrap: wrap;
}

.catalog-tree-label {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
}

.catalog-tree-label.is-focus {
    background: var(--brand-soft);
    border-radius: 8px;
    color: var(--brand-dark);
}

.catalog-tree-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.catalog-form {
    max-width: 640px;
}

.settings-links {
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
}

.settings-links a {
    color: var(--brand-dark);
    font-weight: 600;
    text-decoration: none;
}

.settings-links a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.car-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.car-card {
    padding: 24px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.car-card h2 {
    margin-bottom: 16px;
    text-transform: none;
    letter-spacing: 0;
}

.spec-list {
    display: grid;
    gap: 12px;
    margin: 0 0 20px;
}

.spec-list div {
    display: grid;
    gap: 4px;
}

.car-card .spec-list {
    gap: 0;
}

.car-card .spec-list div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.car-card .spec-list div:first-child {
    padding-top: 0;
}

.car-card .spec-list div:last-child {
    padding-bottom: 12px;
}

.spec-list dt {
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.car-card .spec-list dt {
    flex: 0 1 auto;
    min-width: 0;
}

.spec-list dd {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.car-card .spec-list dd {
    flex: 1 1 auto;
    min-width: 0;
    text-align: right;
}

@media (max-width: 860px) {
    .hero,
    .auth-wrap {
        grid-template-columns: 1fr;
    }

    .auth-aside {
        min-height: 240px;
    }

    .panel-head {
        flex-direction: column;
    }

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

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

    .order-items-head,
    .order-item-head,
    .catalog-picker,
    .modal-head,
    .catalog-tree-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 720px) {
    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .nav {
        justify-content: center;
    }

    .main {
        padding-top: 28px;
    }
}
