/* ============================================================
   X7Market — стили мини-приложения
   Порядок: токены → база → компоненты → адаптив → анимации
   ============================================================ */

/* --- Reset --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* --- Дизайн-токены --- */
:root {
    --accent: #0088cc;
    --accent-strong: #006a9e;
    --accent-on-soft: #006a9e;
    --accent-soft: #e6f3fa;

    --success: #25a35a;
    --success-strong: #1d8a4b;
    --success-soft: #e7f6ee;

    --danger: #c0392b;
    --danger-soft: #fbeceb;
    --warning: #a66c15;

    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-muted: #eef1f4;
    --surface-inverse: #22303a;
    --nav-bg: rgba(255, 255, 255, .78);

    --text: #1f2b33;
    --text-muted: #5a6a74;
    --text-subtle: #7b878f;
    --text-on-accent: #ffffff;

    --border: #e3e8ec;
    --border-strong: #d2dbe1;

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

    --shadow-sm: 0 1px 2px rgba(20, 32, 40, .06);
    --shadow-md: 0 8px 24px rgba(28, 42, 52, .14);
    --shadow-lg: 0 18px 60px rgba(0, 0, 0, .25);

    --transition: background-color .15s ease, border-color .15s ease,
        color .15s ease, box-shadow .15s ease, opacity .15s ease;
}

body.dark-mode {
    --accent-on-soft: #9ad4f0;
    --accent-soft: #12303f;

    --success-soft: #14301f;
    --danger-soft: #3a2422;

    --bg: #12161a;
    --surface: #1c2329;
    --surface-muted: #262e35;
    --surface-inverse: #e9eef1;
    --nav-bg: rgba(28, 35, 41, .85);

    --text: #eef2f4;
    --text-muted: #a9b5bd;
    --text-subtle: #8b979f;

    --border: #2c353c;
    --border-strong: #3a444c;

    --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
}

/* --- База --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 20px 92px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* --- Иконки --- */
.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.icon {
    width: 1.25em;
    height: 1.25em;
    flex: 0 0 auto;
    display: inline-block;
    vertical-align: middle;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-lg { width: 1.4em; height: 1.4em; }
.icon-nav { width: 24px; height: 24px; }

/* --- Система экранов --- */
.screen {
    display: none;
    flex: 1;
    width: 100%;
}

.screen.active {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.header {
    text-align: center;
    padding-bottom: 30px;
    margin-bottom: 20px;
}

.header h1 {
    font-size: 28px;
    color: var(--accent);
    margin-bottom: 8px;
    font-weight: 600;
}

.header p {
    font-size: 14px;
    color: var(--text-muted);
}

/* --- Кнопки --- */
.btn {
    padding: 18px 24px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    color: var(--text-on-accent);
    text-decoration: none;
}

.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary { background: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }

.btn-secondary { background: var(--accent-soft); color: var(--accent-on-soft); box-shadow: none; }
.btn-secondary:hover:not(:disabled) { background: #d7ecf7; }
body.dark-mode .btn-secondary:hover:not(:disabled) { background: #16394b; }

.btn-support { background: var(--surface-muted); color: var(--text); box-shadow: none; }
.btn-support:hover:not(:disabled) { background: var(--border); }

.btn-back { background: var(--surface-muted); color: var(--text-muted); box-shadow: none; margin-top: 16px; }
.btn-back:hover:not(:disabled) { background: var(--border); color: var(--text); }

.btn-success { width: 100%; margin-top: 20px; background: var(--success); }
.btn-success:hover:not(:disabled) { background: var(--success-strong); }

.btn-clear-cart { width: 100%; margin-top: 10px; background: var(--surface-muted); color: var(--text-muted); box-shadow: none; }
.btn-clear-cart:hover:not(:disabled) { background: var(--border); }

/* Светлая тема: более яркие вторичные кнопки. Тёмная тема не меняется. */
body:not(.dark-mode) .btn-secondary {
    background: #bfe4f7;
    color: #004f73;
    border-color: #96d2ee;
}

body:not(.dark-mode) .btn-secondary:hover:not(:disabled) {
    background: #aadcf5;
}

body:not(.dark-mode) .btn-support {
    background: #dcf0fb;
    color: #005f88;
    border-color: #b3dcf1;
}

body:not(.dark-mode) .btn-support:hover:not(:disabled) {
    background: #cae8f8;
}

body:not(.dark-mode) .btn-clear-cart {
    background: #fde3e0;
    color: #a93226;
    border-color: #f3bcb5;
}

body:not(.dark-mode) .btn-clear-cart:hover:not(:disabled) {
    background: #fbd2cd;
}

.btn-text { font-size: 16px; font-weight: 500; text-align: center; }

.make-model-search-button { margin-top: 24px; }

.buttons-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    justify-content: center;
    margin-bottom: 30px;
}

/* --- Главный экран: выбор города и темы --- */
.top-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
}

.top-controls .city-selector { margin-bottom: 0; }
.top-controls .theme-toggle { margin-top: 0; }

.city-selector {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    font-size: 14px;
}

.city-selector__control {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.city-selector__value {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    padding: 6px 12px 6px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    background: var(--surface-muted);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.city-selector__value:hover {
    background: var(--accent-soft);
    color: var(--accent-on-soft);
}

.city-selector__value:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.city-selector__icon {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.city-selector__chevron {
    width: 7px;
    height: 7px;
    margin-top: -4px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform .15s ease;
}

.city-selector__value[aria-expanded="true"] .city-selector__chevron {
    margin-top: 2px;
    transform: rotate(225deg);
}

.city-options {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 1002;
    min-width: 170px;
    max-height: 220px;
    overflow-y: auto;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.city-options[hidden] { display: none; }

.city-option {
    display: block;
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    text-align: left;
    font: inherit;
    cursor: pointer;
    transition: background-color .15s ease;
}

.city-option:hover,
.city-option:focus-visible { background: var(--accent-soft); outline: none; }

.city-option[aria-selected="true"] { background: var(--accent-soft); font-weight: 600; }

/* --- Переключатель темы (ползунок) --- */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
    padding: 6px;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    cursor: pointer;
}

.theme-toggle[hidden] { display: none; }

.theme-toggle__track {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 56px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--surface-muted);
    transition: var(--transition);
}

.theme-toggle__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: transform .2s ease;
}

.theme-toggle__icon {
    position: relative;
    z-index: 1;
    width: 14px;
    height: 14px;
    color: var(--text-subtle);
    transition: color .2s ease;
}

.theme-toggle__icon--sun { color: var(--warning); }
body.dark-mode .theme-toggle__icon--sun { color: var(--text-subtle); }
body.dark-mode .theme-toggle__icon--moon { color: var(--accent); }

body.dark-mode .theme-toggle__thumb {
    background: var(--border-strong);
    transform: translateX(24px);
}

.theme-toggle:hover .theme-toggle__track { border-color: var(--accent); }

.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Нижнее меню --- */
.bottom-nav {
    position: fixed;
    z-index: 10;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: min(calc(100% - 32px), 440px);
    display: flex;
    justify-content: space-around;
    padding: 9px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--nav-bg);
    box-shadow: var(--shadow-md);
    transition: opacity .2s ease, transform .2s ease;
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .bottom-nav {
        -webkit-backdrop-filter: blur(14px);
        backdrop-filter: blur(14px);
    }
}

.bottom-nav-button {
    position: relative;
    flex: 1;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 0;
    background: transparent;
    color: var(--text-subtle);
    font-size: 12px;
    cursor: pointer;
    transition: color .15s ease;
}

.bottom-nav-button .icon { width: 24px; height: 24px; }
.bottom-nav-button.active { color: var(--accent); }
.bottom-nav-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

.cart-badge {
    position: absolute;
    top: -4px;
    right: 2px;
    min-width: 17px;
    padding: 1px 4px;
    border-radius: 10px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
}

.input-focused .bottom-nav { opacity: 0; pointer-events: none; transform: translate(-50%, 20px); }

/* --- Уведомление о cookie --- */
.cookie-notice {
    position: fixed;
    z-index: 11;
    right: 16px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    left: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: min(calc(100% - 32px), 600px);
    margin: 0 auto;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
}

.cookie-notice[hidden] { display: none; }
.cookie-notice p { margin: 0; }
.cookie-notice a { color: var(--accent); font-weight: 600; }
.cookie-notice button {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 9px 14px;
    border: 0;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.cookie-notice button:hover { background: var(--accent-strong); }

/* --- Тосты --- */
.toast-container {
    position: fixed;
    z-index: 60;
    left: 16px;
    right: 16px;
    bottom: calc(84px + env(safe-area-inset-bottom));
    display: grid;
    gap: 8px;
    justify-items: center;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    width: 100%;
    max-width: 520px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--surface-inverse);
    color: var(--bg);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .2s ease, transform .2s ease;
}

.toast--visible { opacity: 1; transform: translateY(0); }
.toast--success { background: var(--success); color: #fff; }
.toast--error { background: var(--danger); color: #fff; }

/* --- Формы и поля --- */
.form-label { display: block; margin: 14px 0 6px; font-weight: 600; }

.filter-input,
.parts-input {
    width: 100%;
    padding: 13px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.parts-input { padding: 16px; }

.filter-input:focus,
.parts-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 136, 204, .12);
}

.filter-input::placeholder,
.parts-input::placeholder { color: var(--text-subtle); }

.filter-input:disabled {
    background-color: var(--surface-muted);
    color: var(--text-subtle);
    cursor: not-allowed;
}

.email-checkout-field[hidden] { display: none; }

.checkout-consent {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 16px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
}

.checkout-consent input { width: 18px; height: 18px; accent-color: var(--accent); margin-top: 2px; }
.checkout-consent a { color: var(--accent); font-weight: 600; text-decoration: none; }
.checkout-consent a:hover { text-decoration: underline; }
.legal-notice { margin-top: 8px; color: var(--text-muted); font-size: 13px; }
.legal-notice a { color: var(--accent); }

/* --- Экран поиска --- */
.search-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    padding: 20px 0;
}

.search-label {
    display: block;
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
    text-align: center;
    margin-bottom: 12px;
}

/* --- Фильтры: марка / модель / поколение --- */
.filter-group {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.filter-group label { font-size: 14px; font-weight: 500; color: var(--text); }

.options-list {
    display: none;
    position: absolute;
    top: 66px;
    left: 0;
    z-index: 1000;
    width: 100%;
    max-height: 270px;
    overflow-y: auto;
    margin-top: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--surface);
    box-shadow: var(--shadow-md);
}

.options-list.show { display: block; }

.option-item {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 12px 16px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    text-align: left;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    transition: background-color .15s ease;
}

.option-item:hover,
.option-item:focus-visible { background-color: var(--accent-soft); outline: none; }
.option-item[aria-selected="true"] { background-color: var(--accent-soft); font-weight: 600; }
.option-item:last-child { border-bottom: none; }

.option-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    color: var(--text-muted);
    font-size: 14px;
}

.option-loading .icon { animation: spin .8s linear infinite; }

/* --- Выпадающие списки (ТО / стратегия) --- */
.maintenance-select { position: relative; }

.maintenance-select-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    cursor: pointer;
}

.maintenance-select-button:disabled { cursor: not-allowed; }

.maintenance-select-arrow {
    width: 9px;
    height: 9px;
    margin: -5px 3px 0 12px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    flex-shrink: 0;
}

.maintenance-options {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 1001;
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.maintenance-options[hidden] { display: none; }

.maintenance-options button {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.maintenance-options button:hover,
.maintenance-options button:focus-visible,
.maintenance-options button[aria-selected="true"] { background: var(--accent-soft); outline: none; }
.maintenance-options button:last-child { border-bottom: 0; }

/* --- Результаты поиска (карточки) --- */
.search-results {
    width: 100%;
    margin-top: 8px;
}

.result-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 2px 8px;
    color: var(--text-muted);
    font-size: 13px;
}

.result-list {
    display: grid;
    gap: 8px;
    padding: 0;
    list-style: none;
}

.result-card {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    text-align: left;
    font: inherit;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.result-card:hover { border-color: var(--accent); }
.result-card:active { background: var(--accent-soft); }
.result-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.result-card-title { grid-column: 1; font-weight: 600; overflow-wrap: anywhere; }
.result-card-meta { grid-column: 1; color: var(--text-muted); font-size: 12.5px; overflow-wrap: anywhere; }
.result-card-price {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    white-space: nowrap;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.sort-price-button {
    padding: 4px 2px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.sort-price-button:hover { color: var(--accent); }

.results-message {
    padding: 24px 12px;
    color: var(--text-muted);
    text-align: center;
}

/* --- Результаты для ТО (по категориям) --- */
.vehicle-result-category + .vehicle-result-category {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.vehicle-result-category h3 { margin: 0 0 8px; font-size: 14px; font-weight: 600; }

.vehicle-part-list {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.vehicle-part-list--scrollable { max-height: 260px; overflow-y: auto; overscroll-behavior: contain; }

.vehicle-part-list-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 70px;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 600;
}

.vehicle-part-list-header > :last-child { text-align: center; }
.vehicle-part-list-header .vehicle-sort-price { white-space: nowrap; }

.vehicle-part-entry { display: flex; align-items: stretch; border-bottom: 1px solid var(--border); }
.vehicle-part-entry:last-child { border-bottom: 0; }

.vehicle-part-item {
    display: grid;
    flex: 1;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 10px;
    min-width: 0;
    padding: 10px;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.vehicle-part-item:hover { background: var(--accent-soft); }
.vehicle-part-item-description { overflow-wrap: anywhere; font-weight: 600; }
.vehicle-part-item-manufacturer,
.vehicle-part-item-article { color: var(--text-muted); font-size: 12px; overflow-wrap: anywhere; }
.vehicle-part-item-price {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: center;
    white-space: nowrap;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.vehicle-part-selected { display: grid; width: 70px; flex: 0 0 70px; place-items: center; cursor: pointer; }
.vehicle-part-checkbox { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

.vehicle-part-entry .recommended-choice-toggle { align-self: center; margin: 0 8px; flex-shrink: 0; }

.recommended-part-row { cursor: pointer; }

.recommended-choice-toggle {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.recommended-choice-toggle span {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-top: -4px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
}

.vehicle-part-options {
    max-height: 220px;
    overflow-y: auto;
    margin-top: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.vehicle-part-options[hidden] { display: none; }

.vehicle-part-option {
    display: grid;
    grid-template-columns: minmax(70px, 25%) minmax(0, 1fr) 82px;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 0 9px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    text-align: left;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.vehicle-part-option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vehicle-part-option span:last-child { text-align: right; }
.vehicle-part-option:hover,
.vehicle-part-option[aria-selected="true"] { background: var(--accent-soft); }
.vehicle-part-option:last-child { border-bottom: 0; }

.vehicle-total {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 10px 2px;
    font-size: 15px;
}

.vehicle-total strong { font-variant-numeric: tabular-nums; }
.vehicle-add-to-cart { margin-top: 16px; }

/* --- Модальные окна --- */
.detail-modal[hidden] { display: none; }

.detail-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 20px;
}

.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 24, 30, .56); }

.detail-dialog {
    position: relative;
    width: min(100%, 520px);
    max-height: calc(100vh - 40px);
    overflow: auto;
    padding: 28px 20px 20px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}

.modal-close {
    position: absolute;
    top: 6px;
    right: 10px;
    width: 44px;
    height: 44px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: var(--radius-sm); }

.detail-dialog h2 { padding-right: 40px; font-size: 19px; }

.detail-description { margin: 18px 0 8px; font-size: 15px; font-weight: 400; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-applicability { margin: -8px 0 18px; color: var(--text-muted); font-size: 12px; font-weight: 400; line-height: 1.45; }
.detail-purchase-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.detail-purchase-row strong { min-width: 0; font-size: 18px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.detail-availability { min-height: 1.5em; margin: 10px 0 14px; color: var(--text-muted); font-size: 14px; font-weight: 600; }
.detail-availability[data-kind="ready"] { color: var(--success-strong); }
.detail-availability[data-kind="delivery"] { color: var(--warning); }
.detail-availability[data-kind="unavailable"],
.detail-availability[data-kind="error"] { color: var(--danger); }

.add-to-cart-button { margin-top: 22px; }
.modal-open { overflow: hidden; }

.email-verification-error { min-height: 1.4em; margin: 8px 0 0; color: var(--danger); font-size: 14px; }
.email-verification-error.is-success { color: var(--success-strong); }
.email-verification-error:empty { display: none; }
.detail-dialog #resendEmailCodeButton { width: 100%; margin-top: 10px; }

/* --- Количество --- */
.quantity-control {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}

.quantity-control button {
    width: 36px;
    height: 36px;
    border: 0;
    background: var(--surface-muted);
    color: var(--accent);
    font-size: 20px;
    cursor: pointer;
}

.quantity-control button:hover { background: var(--border); }

.quantity-control .quantity-value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 36px;
    flex-shrink: 0;
    color: var(--text);
    text-align: center;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* --- Корзина --- */
.cart-content { flex: 1; overflow: auto; padding: 4px 0 24px; }
.cart-items { display: grid; gap: 10px; }

.cart-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.cart-item-info { min-width: 0; display: grid; gap: 3px; }
.cart-item-info span,
.cart-item-info small { color: var(--text-muted); overflow-wrap: anywhere; }
.cart-item-actions { display: grid; justify-items: end; align-content: space-between; gap: 10px; flex-shrink: 0; }

.remove-item { min-height: 32px; border: 0; background: transparent; color: var(--danger); cursor: pointer; font-size: 12px; }
.remove-item:hover { text-decoration: underline; }

.cart-total-row {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
    padding-top: 14px;
    border-top: 1px solid var(--border-strong);
    font-size: 18px;
}

.cart-total-row strong { font-variant-numeric: tabular-nums; }

.empty-cart { padding: 40px 12px; color: var(--text-muted); text-align: center; }

/* --- Заказы --- */
.orders-content { flex: 1; overflow: auto; display: grid; align-content: start; gap: 12px; padding: 4px 0 24px; }
.order-card { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.order-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.order-card-header time { color: var(--text-muted); font-size: 12px; text-align: right; }
.order-status { color: var(--accent); font-weight: 600; }
.order-item-list { display: grid; gap: 8px; list-style: none; }
.order-item { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.order-item-info { min-width: 0; display: grid; gap: 3px; }
.order-item-info span { overflow-wrap: anywhere; }
.order-item-info small { color: var(--text-muted); overflow-wrap: anywhere; }
.order-item strong { flex-shrink: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.order-total { display: flex; justify-content: space-between; padding-top: 10px; border-top: 1px solid var(--border); font-size: 16px; }
.order-total strong { font-variant-numeric: tabular-nums; }

.order-cancel-button {
    width: 100%;
    min-height: 44px;
    padding: 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: var(--danger);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.cancel-confirmation-message { margin: 12px 0 20px; color: var(--text-muted); }
.cancel-confirmation-actions { display: flex; gap: 12px; }
.cancel-confirmation-actions .btn,
.cancel-confirmation-actions .order-cancel-button { flex: 1; width: auto; margin-top: 0; padding: 12px 8px; }

/* --- Контакты поддержки --- */
.support-contacts {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.support-contacts[hidden] { display: none; }

.support-contact-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 48px;
    padding: 12px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
}

.support-contact-link:hover { background: var(--accent-strong); }
.support-contact-email-link { overflow-wrap: anywhere; }

/* --- Футер --- */
.footer {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: var(--text-subtle);
    font-size: 12px;
}

/* --- Юридические страницы --- */
.legal-page { min-height: 100vh; padding: 28px 20px 100px; background: var(--bg); color: var(--text); }
.legal-page__container { max-width: 760px; margin: 0 auto; }
.legal-page__card {
    padding: 28px 20px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}
.legal-page__eyebrow { margin-bottom: 10px; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.legal-page__title { margin-bottom: 8px; font-size: clamp(24px, 5vw, 32px); color: var(--accent); }
.legal-page__subtitle { margin-bottom: 18px; color: var(--text-muted); font-size: 14px; }
.policy-subtitle { margin: 8px 0 0; color: var(--text-muted); font-size: 14px; line-height: 1.5; }
.policy-subtitle a { color: var(--accent); }
.policy-dates { margin: 12px 0 20px; color: var(--text-muted); font-size: 13px; }
.legal-page__text { display: grid; gap: 12px; color: var(--text); font-size: 15px; line-height: 1.7; }
.legal-page__text p { margin: 0; }
.legal-page__button-wrap { margin-top: 24px; display: flex; justify-content: center; }
.legal-page__button { width: min(100%, 230px); text-decoration: none; }

/* --- Анимации --- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Адаптив --- */
@media (max-width: 480px) {
    .container { padding: 16px 16px 92px; }
    .header { padding-bottom: 20px; }
    .header h1 { font-size: 24px; }

    .btn { padding: 16px 20px; font-size: 15px; }
    .btn-text { font-size: 15px; }

    .filter-input,
    .parts-input { font-size: 16px; }

    .cart-item { align-items: center; gap: 8px; padding: 12px 10px; }
    .cart-item-info { flex: 1; }
    .cart-item-actions { min-width: 104px; }
    .detail-purchase-row { flex-wrap: wrap; }

    .option-item { padding: 10px 12px; font-size: 13px; }

    .cookie-notice { align-items: flex-start; gap: 10px; padding: 12px; font-size: 12px; }
    .cookie-notice button { padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }

    .btn:active { transform: none; }
}

.question-button { width: 100%; margin-top: 12px; }
#questionText { resize: vertical; min-height: 120px; font: inherit; }
#questionModal .form-label { display: block; margin-top: 16px; }
#questionModal .filter-input { width: 100%; box-sizing: border-box; }

/* Delivery in search results */
.delivery-badge {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    gap: 5px;
    grid-column: 1;
    padding: 3px 8px;
    margin-top: 5px;
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
    color: var(--accent-on-soft);
    font-size: 12px;
    line-height: 1.5;
    font-weight: 600;
    white-space: nowrap;
}
.delivery-badge svg { width: 14px; height: 14px; flex: 0 0 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.delivery-badge--ready { color: var(--success-strong); background: var(--success-soft); }
body.dark-mode .delivery-badge--ready { color: #86d9a7; }
.delivery-badge--unknown { color: var(--text-muted); background: var(--surface-muted); }
.result-sort-controls { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.result-sort-controls .sort-price-button { padding: 5px 9px; border-radius: var(--radius-pill); white-space: nowrap; font-size: 12px; }
.result-sort-controls .sort-price-button[aria-pressed="true"] { color: var(--accent-on-soft); background: var(--accent-soft); }
.result-sort-controls .sort-price-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.result-toolbar { flex-wrap: wrap; }
.vehicle-part-list-header { grid-template-columns: minmax(0, 1fr) auto auto; gap: 5px; }
.vehicle-part-list-header > :last-child { text-align: initial; }
.vehicle-part-option .delivery-badge { grid-column: 1 / -1; margin: 0 0 7px; }
@media (max-width: 380px) {
    .vehicle-part-list-header { grid-template-columns: 1fr auto; }
    .vehicle-part-list-header > .result-sort-controls { grid-column: 1; grid-row: 2; }
    .vehicle-part-list-header > span:last-child:not(:first-child) { grid-column: 2; grid-row: 1 / span 2; }
}

/* Quiet applicability marker for maintenance results. */
.compatibility-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-inline-end: 6px;
    border-radius: 50%;
    background: #0088cc;
    flex: 0 0 7px;
    vertical-align: middle;
}
body.dark-mode .compatibility-dot { background: #86d9a7; }
.compatibility-legend, .detail-compatibility {
    display: flex;
    align-items: baseline;
    gap: 6px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}
.compatibility-legend { margin: 0 0 14px; }
.compatibility-legend .compatibility-dot, .detail-compatibility .compatibility-dot { margin-inline-end: 0; align-self: baseline; transform: translateY(-1px); }
.detail-compatibility { margin: 8px 0 12px; color: var(--accent-on-soft); }
body.dark-mode .detail-compatibility { color: #86d9a7; }
.detail-compatibility[hidden] { display: none; }
