:root {
    --brand-primary: #3F7F5B;
    --brand-secondary: #7FB69A;
    --brand-accent: #F2B705;
    --text-main: #2E2E2E;
    --text-muted: #6F6F6F;
    --bg-main: #F6F7F6;
    --border: #E2E5E2;
    --layout-max-width: 1000px;
    --layout-side-gap: 15px;
}

.header-content,
.search-row,
.filters,
.table-container {
    box-sizing: border-box;
    width: calc(100% - (var(--layout-side-gap) * 2));
    max-width: var(--layout-max-width);
    margin-left: auto;
    margin-right: auto;
}

body {
    font-family: Inter, "Segoe UI", sans-serif;
    margin: 0;
    background: var(--bg-main);
    color: var(--text-main);
}

/* ШАПКА */
header {
    background: white;
    padding: 8px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 220;
    transition: padding 0.22s ease, box-shadow 0.22s ease;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: nowrap;
}

.logo-section {
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: gap 0.22s ease;
}

.logo-block {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    transform: scale(1.35);
    transform-origin: center;
    transition: width 0.22s ease, height 0.22s ease;
}

.logo {
    display: inline-flex;
    align-items: center;
    font-size: 20px;
    font-weight: 900;
    color: var(--brand-primary);
    text-transform: uppercase;
    white-space: nowrap;
    transition: font-size 0.22s ease, line-height 0.22s ease;
}

#stockUpdatedLabel {
    display: inline-block;
    margin-left: 4px;
    white-space: nowrap;
    font-size: 0.7em;
}

.contacts {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    overflow: hidden;
    max-height: 56px;
    opacity: 1;
    transition: max-height 0.22s ease, opacity 0.18s ease;
}

.contacts a {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    font-size: 14px;
    line-height: 1.1;
}

.contacts a.phone {
    color: var(--brand-primary);
    font-weight: 800;
    font-size: 16px;
}

.contacts a.tg {
    color: var(--brand-secondary);
}

.contacts a.email {
    color: var(--text-muted);
    font-size: 13px;
}

.info-text {
    font-size: 11px;
    color: var(--text-muted);
    max-width: 500px;
    line-height: 1.3;
    overflow: hidden;
    max-height: 36px;
    opacity: 1;
    transition: max-height 0.22s ease, opacity 0.18s ease;
}

/* ПОИСК */
.search-row {
    margin: 15px auto 0;
    padding: 0;
    display: flex;
    position: relative;
    z-index: 180;
    align-items: stretch;
    gap: 10px;
    overflow: visible;
    max-height: 90px;
    opacity: 1;
    transform: translateY(0);
    transition: max-height 0.22s ease, opacity 0.18s ease, transform 0.22s ease, margin 0.22s ease;
}

.search-tools,
.search-tools-group {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.header-tools {
    display: none;
    align-items: stretch;
    margin-left: auto;
    overflow: visible;
    max-width: 0;
    opacity: 0;
    pointer-events: none;
    transition: max-width 0.22s ease, opacity 0.18s ease;
}

.search-box {
    flex: 1 1 auto;
    min-width: 0;
}

#searchInput {
    width: 100%;
    height: 42px;
    box-sizing: border-box;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 15px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.client-card {
    width: 210px;
    flex: 0 0 210px;
    position: relative;
}

.client-card-summary {
    list-style: none;
    height: 100%;
    height: 42px;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--brand-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.client-card-summary::-webkit-details-marker {
    display: none;
}

.client-card-brief {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    min-width: 0;
}

.client-card-company-short {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.05;
}

.client-card-access-short {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.05;
    opacity: 0.92;
}

.client-card-arrow {
    width: 8px;
    height: 8px;
    border-right: 2px solid rgba(255, 255, 255, 0.9);
    border-bottom: 2px solid rgba(255, 255, 255, 0.9);
    transform: rotate(45deg);
    transition: transform 0.15s ease;
    flex: 0 0 auto;
    margin-top: -2px;
}

.client-card[open] .client-card-arrow {
    transform: rotate(-135deg);
    margin-top: 2px;
}

.client-card-body {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 300;
    width: 100%;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
    padding: 7px 9px;
    box-sizing: border-box;
}

.client-card-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 10px;
    line-height: 1.3;
}

.client-card-logout-form {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eef2ef;
    display: flex;
    justify-content: flex-end;
}

.client-card-logout-link {
    border: 0;
    background: transparent;
    color: var(--brand-primary);
    font-size: 11px;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    padding: 0;
    line-height: 1.2;
}

.client-card-logout-link:hover {
    color: var(--brand-primary-dark);
}

.client-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 210px;
    flex: 0 0 210px;
}

.client-action-btn {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-main);
    border-radius: 6px;
    height: 42px;
    box-sizing: border-box;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    padding: 6px 6px;
    cursor: pointer;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 5px;
    position: relative;
    overflow: visible;
}

.client-action-btn:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

.client-action-btn.has-items {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(63, 127, 91, 0.15);
}

.client-action-btn.has-items::after {
    content: attr(data-quote-count);
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    background: var(--brand-accent);
    color: #fff;
    font-size: 11px;
    line-height: 20px;
    text-align: center;
    font-weight: 800;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    padding: 0 5px;
    box-sizing: border-box;
}

.client-action-btn.just-updated {
    animation: invoice-btn-pulse 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes invoice-btn-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(63, 127, 91, 0.25);
    }
    50% {
        transform: scale(1.11);
        box-shadow: 0 0 0 10px rgba(63, 127, 91, 0.05);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(63, 127, 91, 0);
    }
}

.client-action-btn.quote-drop-hit {
    animation: quote-drop-hit 0.6s ease;
}

@keyframes quote-drop-hit {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(48, 140, 88, 0.35);
    }
    50% {
        transform: scale(1.08);
        box-shadow: 0 0 0 12px rgba(48, 140, 88, 0.08);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(48, 140, 88, 0);
    }
}

.quote-fly-token {
    position: fixed;
    z-index: 3500;
    pointer-events: none;
    transform: translate(-50%, -50%);
    animation: quote-fly 0.8s cubic-bezier(0.18, 0.7, 0.22, 1) forwards;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #3f7f5b, #2f6a4b);
    border-radius: 999px;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 10px 24px rgba(38, 89, 63, 0.35);
    white-space: nowrap;
}

@keyframes quote-fly {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.95);
    }
    55% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--fly-x)), calc(-50% + var(--fly-y))) scale(0.72);
    }
}

.client-action-icon {
    font-size: 18px;
    line-height: 1;
    display: inline-block;
    flex: 0 0 auto;
}

.client-action-text {
    display: inline;
    white-space: normal;
}

.verification-modal {
    position: fixed;
    inset: 0;
    background: rgba(20, 28, 34, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    box-sizing: border-box;
}

#stockDetailsModal {
    z-index: 2600;
}

#colorChoiceModal {
    z-index: 2800;
}

#stockNoticeModal {
    z-index: 3200;
}

.verification-modal[hidden] {
    display: none;
}

.verification-modal-dialog {
    width: min(640px, 100%);
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
    padding: 20px 22px;
    position: relative;
}

.stock-check-dialog {
    width: min(860px, 100%);
}

.header-stock-form-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: visible;
    margin: 10px 0 12px;
}

.header-stock-form-table th,
.header-stock-form-table td {
    border: 1px solid var(--border);
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text-main);
    background: #fff;
    text-align: left;
    position: relative;
    overflow: visible;
    box-shadow: none;
}

.header-stock-form-table th {
    width: 170px;
    background: #f6f7f6;
    font-weight: 700;
}

.header-stock-input {
    width: 100%;
    max-width: 320px;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text-main);
    background: #fff;
}

.header-stock-input-wrap {
    position: relative;
    width: 100%;
    max-width: 320px;
}

.header-stock-suggestions {
    position: absolute;
    left: 0;
    top: calc(100% + 2px);
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
    z-index: 3200;
}

.header-stock-suggestions[hidden] {
    display: none;
}

.header-stock-suggestion-option {
    width: 100%;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
    color: var(--text-main);
    font-size: 13px;
    text-align: left;
    padding: 7px 10px;
    cursor: pointer;
}

.header-stock-suggestion-option:hover {
    background: #f3faf6;
}

.header-stock-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(63, 127, 91, 0.15);
}

.header-stock-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.header-stock-find-btn {
    margin-top: 8px;
}

.header-stock-status {
    margin-top: 10px;
    min-height: 20px;
}

.header-stock-switch-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.header-stock-title-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
}

.header-stock-title-row .verification-modal-title {
    margin: 0;
}

.header-stock-found-label {
    margin: 0;
    font-weight: 700;
}

.header-stock-result-table td {
    font-weight: 700;
    text-transform: lowercase;
}

.header-stock-result-ok {
    background: #e8f5e9;
    color: #1b5e20;
}

.header-stock-result-low {
    background: #ffebee;
    color: #b71c1c;
}

.verification-modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.verification-modal-title {
    margin: 0 30px 12px 0;
    font-size: 22px;
    line-height: 1.25;
    color: var(--text-main);
}

.verification-modal-text {
    margin: 0 0 8px;
    color: var(--text-main);
    line-height: 1.45;
}

.verification-modal-list {
    margin: 0 0 14px 18px;
    padding: 0;
    color: var(--text-main);
    line-height: 1.45;
}

.verification-modal-list li + li {
    margin-top: 4px;
}

.verification-modal-list-numbered {
    margin-left: 22px;
}

.verification-modal-link {
    color: var(--brand-primary);
    font-weight: 600;
    text-decoration: none;
}

.verification-modal-link:hover {
    text-decoration: underline;
}

.color-choice-grid {
    display: grid;
    gap: 10px;
}

.color-choice-row {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 10px;
    align-items: center;
}

.color-choice-label {
    font-size: 13px;
    color: var(--text-main);
    font-weight: 600;
}

.color-choice-select {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text-main);
    background: #fff;
}

.color-choice-select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(63, 127, 91, 0.15);
}

.color-choice-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
}

body.verification-modal-open {
    overflow: hidden;
}

body.header-compact header {
    padding: 6px 0;
}

body.header-compact .header-content {
    gap: 10px;
}

body.header-compact .info-text,
body.header-compact .contacts {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

body.header-compact .header-tools {
    display: flex;
    max-width: 760px;
    opacity: 1;
    pointer-events: auto;
}

body.header-compact .info-text {
    max-height: 0;
    opacity: 0;
}

body.header-compact .search-row {
    max-height: 0;
    opacity: 0;
    transform: translateY(-8px);
    margin: 0 auto;
    overflow: hidden;
    pointer-events: none;
}

body.header-compact .logo-img {
    width: 28px;
    height: 28px;
}

body.header-compact .logo {
    font-size: 15px;
    line-height: 1.1;
}

body.header-compact .search-tools-group {
    gap: 8px;
}

body.header-compact .client-actions {
    width: 246px;
    flex: 0 0 246px;
    gap: 5px;
}

body.header-compact .client-action-btn {
    height: 34px;
    font-size: 9px;
    padding: 4px 3px;
    gap: 4px;
}

body.header-compact .client-action-icon {
    font-size: 14px;
}

body.header-compact .client-card {
    width: 190px;
    flex: 0 0 190px;
}

body.header-compact .client-card-summary {
    height: 34px;
}

.client-card-row + .client-card-row {
    margin-top: 6px;
}

.client-card-key {
    color: var(--text-muted);
    flex: 0 0 auto;
}

.client-card-value {
    color: var(--text-main);
    font-weight: 600;
    text-align: right;
}

.price-header {
    text-align: right;
}

.price-header.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.price-header.sortable::before {
    content: '⇅  ';
    opacity: 0.3;
    font-size: 12px;
}

.price-header.sortable:hover {
    opacity: 0.8;
}

.price-header.sortable.sort-asc::before {
    content: '↑  ';
    opacity: 1;
    color: #0066cc;
}

.price-header.sortable.sort-desc::before {
    content: '↓  ';
    opacity: 1;
    color: #0066cc;
}

/* ФИЛЬТРЫ */
.filters {
    margin: 10px auto 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr)) auto;
    align-items: end;
    gap: 8px;
    overflow: visible;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.filter-item.filter-item-reset {
    align-self: end;
    min-width: 140px;
}

.filter-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.15;
}

.multi-select {
    position: relative;
}

.multi-select-summary {
    list-style: none;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text-main);
    font-size: 12px;
    padding: 0 34px 0 10px;
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.multi-select-summary::-webkit-details-marker {
    display: none;
}

.multi-select-summary::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid #666;
    border-bottom: 2px solid #666;
    transform: translateY(-65%) rotate(45deg);
    pointer-events: none;
    transition: transform 0.15s ease;
}

.multi-select[open] .multi-select-summary {
    border-color: var(--brand-primary);
}

.multi-select[open] .multi-select-summary::after {
    transform: translateY(-30%) rotate(-135deg);
}

.multi-select-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 120;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    max-height: 220px;
    overflow-y: auto;
    padding: 6px 0;
}

.multi-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--text-main);
    cursor: pointer;
}

.multi-option:hover {
    background: #f7f8f7;
}

.btn-reset {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    height: 40px;
    width: 100%;
}

.btn-reset:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

/* ТАБЛИЦА */
.table-container {
    margin: 15px auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    /* ВАЖНО: не ставим overflow на контейнер таблицы,
       иначе sticky-заголовки таблицы работают нестабильно в браузерах */
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th {
    background: var(--brand-primary);
    color: white;
    text-align: left;
    padding: 9px 8px;
    font-size: 13px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Динамически устанавливается через JS */
thead th {
    top: var(--header-offset, 80px);
}


td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 14px;
}

tr:hover {
    background-color: #f9f9f9;
}

/* ЭЛЕМЕНТЫ */
.thumb {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: 4px;
    cursor: zoom-in;
    transition: transform 0.2s;
    background: #fff;
    border: none;
}

.col-photo {
    width: 60px;
    padding: 0;
}

.thumb:hover {
    transform: scale(3);
    position: relative;
    z-index: 200;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    border: none;
}

@media (hover: none) {
    .thumb {
        cursor: default;
    }

    .thumb:hover {
        transform: none;
        position: static;
        z-index: auto;
        box-shadow: none;
        border: none;
    }
}

.col-name {
    font-weight: 600;
    color: var(--brand-primary);
}

.badge {
    background: var(--brand-accent);
    color: white;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 3px;
    margin-left: 5px;
    vertical-align: middle;
}

.col-specs {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.col-features,
.col-packaging {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.col-packaging {
    white-space: nowrap;
}

.col-art {
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
}

.certificate-link {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--brand-secondary);
    text-decoration: none;
    margin-top: 4px;
    transition: color 0.2s;
}

.certificate-link:hover {
    color: var(--brand-primary);
    text-decoration: underline;
}

.certificate-link-under-name {
    margin-top: 6px;
    font-size: 12px;
}

.stock-line {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.stock-details-row {
    margin-top: 8px;
}

.stock-details-btn {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--brand-primary);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.1;
    padding: 3px 7px;
    cursor: pointer;
}

.stock-details-btn-large {
    font-size: 13px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 8px;
}

.stock-details-btn:hover {
    border-color: var(--brand-primary);
    background: #f3faf6;
}

.stock-details-value {
    font-weight: 600;
}

.stock-details-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.stock-details-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 480px;
}

.stock-details-table th,
.stock-details-table td {
    border: 1px solid var(--border);
    padding: 6px 8px;
    text-align: center;
    font-size: 12px;
    white-space: nowrap;
    color: var(--text-main);
}

.stock-details-table thead th {
    background: #f6f7f6;
    font-weight: 700;
}

.stock-details-table tbody th {
    background: #fafbfa;
    font-weight: 700;
}

.stock-check-col-header,
.stock-check-col-cell {
    background: #f4f7f4;
    font-weight: 700;
    min-width: 92px;
}

.stock-check-col-header {
    white-space: normal;
    line-height: 1.15;
    position: sticky;
    right: 0;
    z-index: 2;
    box-shadow: -1px 0 0 var(--border);
}

.stock-check-col-cell {
    position: sticky;
    right: 0;
    z-index: 1;
    box-shadow: -1px 0 0 var(--border);
}

.stock-request-input {
    width: 72px;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text-main);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    padding: 5px 6px;
    text-align: center;
}

.stock-request-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(63, 127, 91, 0.15);
}

.stock-details-cell.stock-details-available {
    background: #e8f5e9;
}

.stock-actions-spacer {
    border: none;
    background: transparent;
}

.stock-actions-cell {
    vertical-align: top;
    background: #f9fbf9;
}

.stock-actions-panel {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
}

.stock-actions-panel-standalone {
    margin-top: 10px;
    width: 100%;
    justify-content: flex-end;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 1px 0 3px;
}

.stock-action-btn {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-main);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    padding: 6px 8px;
    cursor: pointer;
}

.stock-action-btn:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    background: #f3faf6;
}

.stock-action-btn.stock-action-btn-primary {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

.stock-action-btn.stock-action-btn-primary:hover {
    background: #356a4b;
    color: #fff;
    border-color: #356a4b;
}

.logistics-result-wrap {
    margin-top: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    padding: 10px;
}

.logistics-result-title {
    margin: 0 0 8px;
    font-size: 15px;
    color: var(--text-main);
}

.logistics-result-package {
    margin-bottom: 8px;
    font-weight: 600;
}

.logistics-result-totals {
    margin-top: 8px;
    font-weight: 700;
}

.logistics-result-warning {
    margin-top: 6px;
    color: #8a6d1d;
}

.logistics-result-warning-emphasis {
    margin: 0 0 8px;
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    background: #fff4d6;
    border: 1px solid #f0deb0;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.logistics-result-error {
    color: #b71c1c;
}

.quote-draft-table-wrap {
    margin-top: 10px;
    overflow: visible;
    position: relative;
    z-index: 3000;
}

.quote-draft-dialog {
    border-radius: 4px;
    padding: 14px 16px;
}

.quote-draft-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.quote-draft-table th,
.quote-draft-table td {
    border-radius: 0;
    padding: 5px 6px;
    vertical-align: middle;
}

.quote-draft-table thead th {
    background: #f4f6f4;
}

.quote-draft-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: 0;
    background: #fff;
    color: var(--text-main);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    padding: 5px 6px;
}

.quote-draft-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(63, 127, 91, 0.15);
}

.quote-draft-input-qty {
    width: 100%;
    min-width: 0;
    max-width: none;
    padding-left: 2px;
    padding-right: 2px;
    text-align: center;
    -moz-appearance: textfield;
    appearance: textfield;
}

.quote-draft-input-qty::-webkit-outer-spin-button,
.quote-draft-input-qty::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.quote-draft-readonly-cell {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quote-draft-name-cell {
    white-space: normal !important;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.25;
    max-width: none;
    max-height: none;
    overflow: hidden;
    text-overflow: initial;
}

.quote-draft-table td:nth-child(2) {
    white-space: normal !important;
    overflow-wrap: break-word;
    word-break: break-word;
}

.quote-draft-remove-btn {
    white-space: nowrap;
}

.quote-sku-control {
    display: flex;
    gap: 6px;
    align-items: center;
    min-width: 0;
}

.quote-size-control {
    display: flex;
    gap: 6px;
    align-items: center;
    min-width: 0;
}

.quote-size-control .quote-draft-input {
    min-width: 0;
}

.quote-draft-color-select {
    min-width: 0;
}

.quote-sku-input-wrap {
    position: relative;
    z-index: 40;
    width: 92px;
    max-width: 100%;
}

.quote-sku-input-wrap:focus-within {
    z-index: 80;
}

.quote-draft-input-sku {
    width: 100%;
    max-width: none;
}

.quote-draft-table th:nth-child(1),
.quote-draft-table td:nth-child(1) {
    width: 2%;
}

.quote-draft-table th:nth-child(2),
.quote-draft-table td:nth-child(2) {
    width: 21.87%;
}

.quote-draft-table th:nth-child(3),
.quote-draft-table td:nth-child(3) {
    width: 10.1%;
}

.quote-draft-table th:nth-child(4),
.quote-draft-table td:nth-child(4) {
    width: 12.15%;
}

.quote-draft-table th:nth-child(5),
.quote-draft-table td:nth-child(5) {
    width: 10.53%;
}

.quote-draft-table th:nth-child(6),
.quote-draft-table td:nth-child(6) {
    width: 7.29%;
}

.quote-draft-table th:nth-child(7),
.quote-draft-table td:nth-child(7),
.quote-draft-table th:nth-child(8),
.quote-draft-table td:nth-child(8) {
    width: 10%;
}

.quote-draft-table th:nth-child(9),
.quote-draft-table td:nth-child(9) {
    width: 5%;
}

.quote-sku-suggestions {
    position: absolute;
    left: 0;
    top: calc(100% + 2px);
    z-index: 2200;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    max-height: 180px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}

.quote-sku-suggestions[hidden] {
    display: none;
}

.quote-sku-option {
    width: 100%;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
    color: var(--text-main);
    font-size: 12px;
    text-align: left;
    padding: 6px 8px;
    cursor: pointer;
    white-space: nowrap;
}

.quote-sku-option:hover {
    background: #f3faf6;
}

.quote-draft-details-btn {
    width: 32px;
    min-width: 32px;
    padding: 5px 0;
    text-align: center;
    font-size: 13px;
}

.quote-draft-add-row-cell {
    text-align: left;
    background: #fafbfa;
}

.quote-draft-add-btn {
    border-style: dashed;
}

.quote-empty-add-wrap {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.quote-draft-remove-btn {
    color: #b71c1c;
    border-color: #e8b3b3;
    font-size: 18px;
    line-height: 1;
    width: 36px;
    min-width: 36px;
    padding: 4px 0;
    font-weight: 800;
}

.quote-draft-remove-btn:hover {
    color: #fff;
    background: #c62828;
    border-color: #c62828;
}

.quote-draft-table tr.quote-row-available td {
    background: #e8f5e9;
}

.quote-draft-table tr.quote-row-unavailable td {
    background: #ffebee;
}

.quote-draft-index-cell {
    width: 34px;
    min-width: 34px;
    text-align: center;
    font-weight: 700;
}

.quote-status-line {
    min-height: 18px;
    font-weight: 600;
}

.quote-availability-inline {
    font-size: 13px;
    font-weight: 700;
    margin-right: 4px;
    min-width: 130px;
    text-align: right;
}

.quote-availability-ok {
    color: #1b5e20;
}

.quote-availability-bad {
    color: #b71c1c;
}

/* Изоляция от глобальных sticky-стилей основной таблицы прайса */
.stock-details-table th,
.stock-details-table thead th,
.stock-details-table tbody th {
    position: static;
    top: auto;
    z-index: auto;
    box-shadow: none;
}

.stock-label {
    font-weight: 400;
    color: var(--text-muted);
}

.col-price {
    text-align: right;
    white-space: nowrap;
    /* важно: оставляем TD table-cell, не flex */
    vertical-align: middle;
}

.price-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
}

.price-final {
    display: block;
    font-size: 16px;
    font-weight: 800;
    color: var(--brand-primary);
}

.cz-label {
    font-size: 10px;
    color: var(--brand-secondary);
    display: block;
}

/* Остатки: бейджи статусов */
.stock-badge {
    font-size: 9px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border: 1px solid transparent;
    white-space: nowrap;
}

.stock-high {
    background-color: #e6f4ea;
    color: #137333;
    border-color: #137333;
}

.stock-medium {
    background-color: #e8f0fe;
    color: #1967d2;
    border-color: #1967d2;
}

.stock-low {
    background-color: #fef7e0;
    color: #ea8600;
    border-color: #ea8600;
}

.stock-out {
    background-color: #f1f3f4;
    color: #5f6368;
    border-color: #dadce0;
    opacity: 0.8;
}

.stock-unknown {
    background-color: #fff;
    color: var(--text-muted);
    border-color: var(--border);
    opacity: 0.9;
}

.category-row {
    background: #fff4cc;
    font-weight: bold;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-main);
    padding-top: 6px;
    padding-bottom: 6px;
}

.category-row-content {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
}

.category-name {
    flex: 1;
}

.rotate-hint {
    position: fixed;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%) translateY(8px);
    z-index: 300;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: min(92vw, 360px);
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text-main);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.rotate-hint.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.rotate-hint-phone {
    font-size: 20px;
    line-height: 1;
    animation: rotate-hint-phone 1.2s ease-in-out infinite;
}

.rotate-hint-text {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
}

@keyframes rotate-hint-phone {
    0% {
        transform: rotate(0deg);
    }
    35% {
        transform: rotate(-90deg);
    }
    70% {
        transform: rotate(-90deg);
    }
    100% {
        transform: rotate(0deg);
    }
}

@media (max-width: 980px) {
    .filters {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .filter-item.filter-item-reset {
        grid-column: 1 / -1;
    }
}

@media (max-width: 815px) {
    body.header-compact .logo {
        font-size: 13px;
    }

    body.header-compact #stockUpdatedLabel {
        font-size: 0.62em;
    }

    body.header-compact .header-content {
        gap: 8px;
    }

    body.header-compact .search-tools-group {
        gap: 6px;
    }

    body.header-compact .client-actions {
        width: 210px;
        flex: 0 0 210px;
        gap: 4px;
    }

    body.header-compact .client-action-btn {
        height: 32px;
        font-size: 8px;
        padding: 3px 2px;
    }

    body.header-compact .client-card {
        width: 165px;
        flex: 0 0 165px;
    }

    body.header-compact .client-card-summary {
        height: 32px;
        padding: 0 9px;
        font-size: 10px;
    }

    body.header-compact .client-card-company-short {
        font-size: 10px;
    }

    body.header-compact .client-card-access-short {
        font-size: 9px;
    }
}

@media (max-width: 720px) {
    body.header-compact .header-content {
        flex-wrap: wrap;
        align-items: stretch;
    }

    body.header-compact .header-tools {
        width: 100%;
        margin-left: 0;
    }

    body.header-compact .search-tools-group {
        width: 100%;
        gap: 8px;
    }

    body.header-compact .client-actions {
        width: 100%;
        flex: 1 1 auto;
    }

    body.header-compact .client-card {
        width: 190px;
        flex: 0 0 190px;
    }
}

@media (max-width: 760px) {
    .filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    th,
    thead th {
        position: static;
        top: auto;
        box-shadow: none;
    }

    .search-row {
        flex-direction: column;
        gap: 8px;
    }

    .search-tools,
    .search-tools-group {
        width: 100%;
    }

    .search-box {
        flex: 1 1 auto;
    }

    .client-card {
        width: 100%;
        flex: 0 0 auto;
    }

    .client-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
        flex: 0 0 auto;
    }

    .client-card-body {
        position: static;
        margin-top: 6px;
        box-shadow: none;
    }

    .rotate-hint {
        bottom: 10px;
    }

    .header-stock-form-table th,
    .header-stock-form-table td {
        font-size: 12px;
        padding: 7px 8px;
    }

    .header-stock-form-table th {
        width: 120px;
    }

    .header-stock-input {
        max-width: 100%;
        font-size: 12px;
        padding: 7px 8px;
    }

    .header-stock-controls {
        justify-content: flex-start;
    }

    .header-stock-switch-row {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .stock-actions-panel-standalone {
        margin-top: 8px;
        gap: 4px;
        justify-content: flex-end;
    }

    .stock-action-btn {
        font-size: 10px;
        padding: 5px 7px;
        border-radius: 5px;
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .quote-draft-table {
        min-width: 640px;
    }

    .color-choice-row {
        grid-template-columns: 1fr;
    }

    .color-choice-actions {
        justify-content: stretch;
    }

    .color-choice-actions .stock-action-btn {
        flex: 1 1 0;
    }
}

@media (max-width: 600px) {
    :root {
        --layout-side-gap: 12px;
    }

    header {
        padding: 6px 0;
    }

    .header-content { 
        flex-direction: column; 
        align-items: flex-start; 
        gap: 8px;
    }

    .logo-section {
        width: 100%;
    }

    .logo {
        font-size: 16px;
        line-height: 1.2;
    }

    .contacts {
        align-items: flex-start;
        gap: 2px;
    }

    .contacts a.phone {
        font-size: 15px;
    }

    .info-text { 
        font-size: 10px;
        max-width: 100%;
    }

    .search-row {
        margin: 10px auto 0;
        padding: 0;
    }

    #searchInput {
        height: 42px;
        padding: 0 11px;
    }

    .client-card-summary {
        min-height: 42px;
        font-size: 13px;
    }

    .client-action-btn {
        min-height: 42px;
        font-size: 11px;
    }

    .col-specs,
    .col-specs-header {
        display: none;
    }

    .filters {
        grid-template-columns: 1fr;
        gap: 8px;
        margin: 8px auto 0;
        padding: 0;
    }

    .multi-select-summary,
    .btn-reset {
        height: 42px;
        font-size: 13px;
    }

    .multi-select-menu {
        max-height: min(42vh, 220px);
    }

    .multi-option {
        padding: 8px 10px;
        font-size: 13px;
    }

    .filter-item.filter-item-reset {
        grid-column: auto;
    }

    .btn-reset {
        width: 100%;
    }

    .table-container {
        margin: 10px auto 12px;
        border-radius: 6px;
    }

    table {
        min-width: 520px;
    }

    th {
        padding: 10px 8px;
        font-size: 12px;
    }

    td {
        padding: 8px;
        font-size: 12px;
    }

    .col-features,
    .col-packaging,
    .stock-line {
        font-size: 11px;
    }

    .price-final {
        font-size: 15px;
    }

    .category-row {
        font-size: 10px;
        letter-spacing: 0.4px;
        padding-top: 5px;
        padding-bottom: 5px;
    }

    .stock-check-dialog {
        width: min(100%, 100%);
    }

    .header-stock-form-table th,
    .header-stock-form-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    .header-stock-form-table th {
        border-bottom: none;
    }

    .header-stock-form-table td {
        border-top: none;
    }

    .stock-actions-panel-standalone {
        gap: 3px;
    }

    .stock-action-btn {
        font-size: 9px;
        padding: 4px 6px;
    }
}
