/* ===== Подключение шрифта Montserrat ===== */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

/* ===== Базовые стили ===== */
:root {
    --primary: #2c6e49;
    --primary-dark: #1e4d32;
    --primary-light: #4c9a6e;
    --accent: #f4a261;
    --accent-dark: #e76f51;
    --bg: #f0f4f0;
    --card-bg: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #555;
    --border: #d0d8d0;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Montserrat', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --danger: #e53e3e;
    --danger-light: #fff0f0;
    --success: #2c6e49;
    --success-light: #eaf6ee;
    --warning: #f4a261;
    --warning-light: #fff3e0;
    --text-muted: #999;
    --text-dark: #333;
    --border-light: #e2e8f0;
    --bg-light: #f5faf5;
    --bg-alt: #fafcfa;
    --table-stripe: var(--bg-alt);
    --table-hover: var(--hover-bg);
    --hover-bg: #f0f8f0;
    --border-lighter: #e0e0e0;
}

/* Ручной размер временно скрыт до утверждения правил падающей длины. */
#sizeSelect option[value="__manual__"] {
    display: none !important;
}

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

/* ===== SVG иконки — вертикальное выравнивание по центру ===== */
svg.icon {
    display: inline;
    vertical-align: middle;
    flex-shrink: 0;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* До проверки сессии не показываем форму расчёта и её данные. */
html:not([data-authenticated="true"]) main {
    display: none;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== Header ===== */
header {
    position: relative;
    text-align: left;
    padding: 30px 20px 20px 126px;
}

header h1 {
    font-size: 2rem;
    color: var(--primary-dark);
    margin-bottom: 8px;
}

.brand-mark-header {
    position: absolute;
    top: 42px;
    left: 20px;
    width: 90px;
    height: 67px;
    object-fit: contain;
    object-position: center;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
}

.auth-control {
    position: absolute;
    top: 34px;
    right: 20px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}
.auth-user {
    max-width: 210px;
    overflow: hidden;
    color: var(--text-dark);
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.auth-control .auth-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto;
    height: 40px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--primary);
    border-radius: 7px;
    background: var(--primary);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1;
}
.auth-control .auth-button:hover {
    border-color: var(--primary-dark);
    background: var(--primary-dark);
    color: #fff;
}
.auth-button[hidden],
.account-trigger[hidden],
.account-menu-item[hidden] { display: none !important; }
.auth-button svg { display: block; flex: 0 0 auto; margin: 0; }
.account-trigger {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
    padding: 4px 8px 4px 5px;
    border: 1px solid #b8d4c0;
    border-radius: 7px;
    background: #f7faf8;
    color: var(--text-dark);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.account-trigger:hover,
.account-trigger[aria-expanded="true"] {
    border-color: var(--primary);
    background: #eaf4ed;
}
.account-trigger:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}
.account-avatar {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1;
}
.account-chevron {
    flex: 0 0 auto;
    color: var(--text-muted);
    transition: transform .15s;
}
.account-trigger[aria-expanded="true"] .account-chevron { transform: rotate(180deg); }
.account-menu {
    position: absolute;
    z-index: 10020;
    top: calc(100% + 7px);
    right: 0;
    width: 268px;
    overflow: hidden;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(18, 54, 34, .16);
}
.account-menu[hidden] { display: none; }
.account-menu-section[hidden] { display: none; }
.account-menu-section + .account-menu-section {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--border-light);
}
.account-menu-section-title {
    display: block;
    padding: 6px 10px 3px;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1.2;
    text-transform: uppercase;
}
.account-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--text-dark);
    font: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.account-menu-item:hover { background: #edf5ef; color: var(--primary-dark); }
.account-menu-item svg { flex: 0 0 18px; }
.account-menu-item:disabled {
    color: var(--text-muted);
    cursor: default;
    opacity: 0.7;
}
.account-menu-item:disabled:hover { background: transparent; color: var(--text-muted); }
.account-menu-item--logout {
    margin-top: 3px;
    border-top: 1px solid var(--border-light);
    border-radius: 0 0 5px 5px;
    color: #91452a;
}

.version-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    vertical-align: super;
    background: var(--primary);
    color: #fff;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
    line-height: 1.4;
}

/* ===== Сворачиваемые секции (details/summary) ===== */
details.collapsible {
    display: block;
    padding: 0;
}

details.collapsible > .collapsible-content {
    padding: 0 28px 24px 28px;
}

details.collapsible[open] > .collapsible-content {
    display: block;
}

summary.collapsible-summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 20px 28px;
    user-select: none;
    -webkit-user-select: none;
}

summary.collapsible-summary::-webkit-details-marker {
    display: none;
}

summary.collapsible-summary::before {
    content: '▶';
    font-size: 0.75rem;
    color: var(--primary);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

details.collapsible[open] > summary.collapsible-summary::before {
    transform: rotate(90deg);
}

summary.collapsible-summary h2 {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 1.15rem;
}

summary.collapsible-summary:hover {
    background: var(--bg-light);
    border-radius: var(--radius);
}

details.collapsible[open] > summary.collapsible-summary:hover {
    border-radius: var(--radius) var(--radius) 0 0;
}

/* ===== Карточки ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 28px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.card-header-row h2 {
    margin-bottom: 0;
    flex-shrink: 0;
}

.kp-number-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.kp-number-wrap label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.kp-number-series-chooser,
.kp-number-assigned {
    display: flex;
    align-items: center;
    gap: 6px;
}

.kp-number-series-chooser {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    box-shadow: 0 8px 24px rgba(30, 77, 50, 0.16);
    white-space: nowrap;
}

.kp-number-series-chooser[hidden] {
    display: none;
}

.kp-number-series-chooser label {
    font-size: 0.76rem;
}

.kp-number-assigned > span {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.kp-number-input {
    width: 110px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.82rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.2s;
}

.kp-number-input[readonly] {
    cursor: default;
}

.kp-number-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(44, 110, 73, 0.15);
}

.kp-number-series {
    max-width: 138px;
    padding: 5px 28px 5px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font: 600 0.76rem var(--font);
    background: var(--card-bg);
    cursor: pointer;
}

.kp-number-reserve-btn {
    padding: 6px 10px;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font: 700 0.76rem var(--font);
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.kp-number-reserve-btn:hover:not(:disabled) {
    background: var(--primary-dark);
}

.kp-number-reserve-btn:disabled {
    cursor: wait;
    opacity: 0.65;
}

.kp-number-confirm-btn {
    padding: 5px 9px;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font: 700 0.72rem var(--font);
    white-space: nowrap;
    cursor: pointer;
}

.kp-number-confirm-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.kp-number-clear-btn {
    width: 25px;
    height: 25px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--card-bg);
    color: var(--text-secondary);
    font: 600 1.05rem/1 var(--font);
    cursor: pointer;
}

.kp-number-clear-btn:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.card h2 {
    font-size: 1.25rem;
    color: var(--primary-dark);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--bg);
}

.section-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 14px;
}

/* ===== Формы ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

/* ===== Параметры материала — эргономичная форма ===== */
@keyframes params-copy-highlight {
    0%, 100% { box-shadow: var(--shadow); }
    45% { box-shadow: 0 0 0 4px rgba(44, 110, 73, 0.22), var(--shadow); }
}
#params-section.params-copy-highlight {
    animation: params-copy-highlight 1.8s ease-out;
}
.params-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.42fr);
    gap: 14px;
    align-items: start;
}
.params-workflow,
.params-summary {
    min-width: 0;
}
.params-workflow {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.params-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 12px;
}
.params-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    width: 100%;
    align-items: stretch;
}
.params-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    padding: 14px;
    background: var(--bg-alt);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}
.params-panel-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--primary-dark);
}
.params-panel-grid {
    display: grid;
    grid-template-columns: minmax(260px, 0.8fr) minmax(480px, 1.5fr);
    gap: 10px;
    width: 100%;
}
.manual-size-fields {
    padding: 10px;
    border: 1px dashed var(--primary-light);
    border-radius: var(--radius-sm);
    background: #f7fbf8;
}
.manual-size-heading {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: baseline;
    margin-bottom: 8px;
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 700;
}
.manual-size-price-source {
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 500;
    text-align: right;
}
.manual-size-price-warning {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 0 0 10px;
    padding: 9px 10px;
    border: 1px solid #e6ae64;
    border-radius: var(--radius-sm);
    background: var(--warning-light);
    color: #7a4a0d;
    font-size: 0.78rem;
    line-height: 1.4;
}
.manual-size-price-warning[hidden] {
    display: none;
}
.manual-size-price-warning strong,
.manual-size-price-warning span:last-child {
    display: block;
}
.manual-size-price-warning strong {
    margin-bottom: 2px;
    color: #6d4108;
    font-size: 0.82rem;
}
.manual-size-price-warning-icon {
    display: grid;
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    place-items: center;
    border-radius: 50%;
    background: #d87918;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 800;
}
.manual-size-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.params-batch-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}
.params-side-grid {
    display: grid;
    grid-template-columns: minmax(135px, 1fr) minmax(84px, 0.68fr) minmax(150px, 1.05fr);
    gap: 10px;
    align-items: end;
    width: 100%;
}
.pg-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}
.pg-field label {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}
.pg-field-label {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.dimension-selects {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.pg-field-dimensions > .pg-field-label {
    display: none;
}
.pg-field select,
.pg-field input {
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    box-sizing: border-box;
}
.pg-field select:focus,
.pg-field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(44, 110, 73, 0.15);
}
.pg-field-qty input {
    text-align: center;
    font-weight: 700;
    font-size: 1.05rem;
    padding-left: 8px;
    padding-right: 8px;
}

/* Сетка полей покраски */
.paint-fields {
    margin-top: 0;
    padding: 14px;
    background: var(--bg-alt);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}
.paint-fields-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.paint-fields .paint-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.7fr) minmax(0, 1fr);
    gap: 12px;
    margin-top: 12px;
    align-items: start;
}
.paint-group {
    min-width: 0;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}
.paint-group-main {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.paint-group-params {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-content: start;
}
.paint-group-title {
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1;
    text-transform: uppercase;
}
.paint-group-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.paint-guide-trigger {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font: 700 0.9rem/1 var(--font);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(30, 77, 50, 0.22);
}
.paint-guide-trigger:hover,
.paint-guide-trigger:focus-visible { background: var(--primary-dark); }
.paint-guide-trigger:focus-visible { outline: 3px solid rgba(44, 110, 73, 0.22); outline-offset: 2px; }
.paint-inline-fields,
.paint-compact-fields {
    display: grid;
    gap: 10px;
}
.paint-inline-fields {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.75fr);
    min-width: 0;
}
.paint-inline-fields .form-group {
    min-width: 0;
}
.paint-availability-hint {
    margin: 0;
    color: #785411;
    font-size: 0.72rem;
    line-height: 1.35;
}
.paint-compact-fields {
    grid-template-columns: minmax(118px, 1fr) minmax(86px, 0.72fr);
}
.paint-backside-options {
    display: grid;
    gap: 6px;
}
.paint-backside-note {
    color: var(--text-secondary);
    font-size: 0.71rem;
    line-height: 1.25;
}
.paint-thickness-hint {
    padding: 8px 9px;
    background: #fff8e6;
    border: 1px solid #f1d799;
    border-radius: var(--radius-sm);
    color: #785411;
    font-size: 0.75rem;
    line-height: 1.35;
}
.paint-backside-option {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 7px 9px;
    background: var(--bg-alt);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.78rem;
    user-select: none;
}
.paint-backside-option:hover {
    border-color: var(--primary-light);
    background: var(--hover-bg);
}
.paint-backside-option input {
    width: 15px;
    height: 15px;
    accent-color: var(--primary);
}
.paint-backside-option:has(input:checked) {
    color: var(--primary-dark);
    border-color: var(--primary-light);
    background: var(--success-light);
}
.paint-backside-text {
    min-width: 0;
}
.paint-backside-price {
    color: var(--primary-dark);
    font-weight: 700;
    white-space: nowrap;
}
.paint-fields .form-group label {
    font-size: 0.76rem;
}
.paint-fields .form-group select,
.paint-fields .form-group input {
    min-height: 42px;
    padding: 9px 11px;
    width: 100%;
    box-sizing: border-box;
}
.paint-price-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-size: 0.76rem;
    font-weight: 600;
}
.paint-price-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 10px;
    min-height: 30px;
    padding: 3px 0;
    color: var(--text-secondary);
    font-size: 0.76rem;
    line-height: 1.35;
}
.paint-price-summary strong {
    color: var(--primary-dark);
    font-size: 1.05rem;
    line-height: 1.15;
    white-space: nowrap;
}
.paint-price-summary span {
    min-width: 0;
}

/* Чекбокс покраски */
.paint-toggle-wrap {
    display: flex;
    align-items: center;
    min-height: 44px;
}
.antiseptic-price-row {
    display: grid;
    grid-template-columns: minmax(180px, 250px) 1fr;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: #f6faf7;
}
.antiseptic-price-field {
    max-width: 240px;
}
.antiseptic-note {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.45;
}
.paint-checkbox-label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 9px;
    width: max-content;
    min-height: 32px;
    cursor: pointer;
    user-select: none;
    padding: 6px 0;
    transition: color 0.2s;
}
.paint-checkbox-label:hover {
    color: var(--primary-dark);
}
.paint-checkbox-label:has(input:focus-visible) {
    outline: 3px solid rgba(44, 110, 73, 0.2);
    outline-offset: 4px;
    border-radius: 4px;
}
.paint-checkbox-label input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
.paint-checkbox-switch {
    position: relative;
    width: 34px;
    height: 20px;
    border-radius: 999px;
    background: var(--border);
    transition: background 0.2s ease;
    flex-shrink: 0;
}
.paint-checkbox-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.2s ease;
}
.paint-checkbox-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1;
}
.paint-checkbox-label:has(input:checked) .paint-checkbox-switch {
    background: var(--primary);
}
.paint-checkbox-label:has(input:checked) .paint-checkbox-switch::after {
    transform: translateX(14px);
}
.paint-checkbox-label:has(input:checked) .paint-checkbox-text {
    color: var(--primary-dark);
}
.paint-checkbox-label:has(input:checked) .paint-checkbox-text {
    font-size: 0;
}
.paint-checkbox-label:has(input:checked) .paint-checkbox-text::after {
    content: 'Да';
    font-size: 0.95rem;
}

/* ===== Toggle Switch (переключатель "Покраска") ===== */
.toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    transition: background 0.25s ease;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::after {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

/* ===== Toggle Switch (переключатель "Покраска") ===== */
.toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.form-group {
    display: flex;
    flex-direction: column;
    position: relative;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-group select,
.form-group input,
.form-group textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* Placeholder'ы бледнее — чтобы визуально отличать пустое поле от заполненного */
.form-group input::placeholder,
.form-group select::placeholder,
.form-group textarea::placeholder,
input::placeholder,
select::placeholder,
textarea::placeholder {
    color: var(--border-lighter) !important;
    opacity: 1;
}
.form-group input::-webkit-input-placeholder,
.form-group select::-webkit-input-placeholder,
input::-webkit-input-placeholder,
select::-webkit-input-placeholder {
    color: var(--border-lighter) !important;
    opacity: 1;
}
.form-group input::-moz-placeholder,
.form-group select::-moz-placeholder,
input::-moz-placeholder,
select::-moz-placeholder {
    color: var(--border-lighter) !important;
    opacity: 1;
}

.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(44, 110, 73, 0.15);
}

.form-group input[readonly] {
    background: #f5f7f5;
    color: var(--text);
    cursor: default;
    border-color: var(--border);
    opacity: 0.85;
}

.form-group input[readonly]:focus {
    box-shadow: none;
    border-color: var(--border);
}

.form-inline {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.form-inline .form-group {
    flex: 1;
    min-width: 180px;
}

/* ===== Кнопки ===== */
.btn {
    padding: 10px 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-family: var(--font);
    white-space: nowrap;
}

.btn:hover {
    background: var(--primary-dark);
}

.btn:active {
    transform: scale(0.97);
}

/* ===== Paint Info Popover ===== */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    transition: color 0.2s;
    margin-left: 4px;
    user-select: none;
    vertical-align: middle;
    line-height: 1;
}
.info-icon:hover {
    color: var(--primary);
}
.paint-info-popover {
    display: none;
    position: fixed;
    z-index: 100;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text);
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}
.paint-info-popover.open {
    display: block;
}
.paint-info-popover p {
    margin: 0 0 10px;
}
.paint-info-popover p:last-child {
    margin-bottom: 0;
}
.paint-info-popover ol {
    margin: 0;
    padding-left: 20px;
}
.paint-info-popover ol li {
    margin-bottom: 6px;
}
.paint-info-popover ol li:last-child {
    margin-bottom: 0;
}
.paint-info-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.15s;
}
.paint-info-close:hover {
    background: var(--bg);
    color: var(--text);
}
/* Popover backdrop for closing on outside click */
.paint-info-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 99;
}
.paint-info-backdrop.open {
    display: block;
}

/* ===== Результаты: таблица + сводка партии ===== */
.params-results {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    background: var(--bg-alt);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}
.params-summary-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
/* Таблица характеристик: label | value */
.pr-table {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--card-bg);
}
.pr-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
}
.pr-row:last-child {
    border-bottom: none;
}
.pr-row:nth-child(even) {
    background: var(--bg-alt);
}
.pr-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.pr-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    text-align: right;
    white-space: nowrap;
}
.pr-value-lg {
    font-size: 1.15rem;
    color: var(--primary);
}
.pr-value-xl {
    font-size: 1.35rem;
    color: var(--primary-dark);
}
.pr-subvalue {
    color: var(--text-secondary);
    font-size: 0.76rem;
    line-height: 1.25;
}
.pr-batch-pricing #materialPriceSource {
    display: block;
    margin-top: 2px;
}
.paint-cost-breakdown {
    max-width: 760px;
    color: var(--text-secondary);
    font-size: 0.76rem;
    line-height: 1.4;
}
/* Сводка партии (выделенный блок) */
.pr-batch {
    background: #f2f8f4;
    border: 1px solid var(--primary-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.pr-batch-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
}
.pr-batch-row-single {
    grid-template-columns: 1fr;
}
.pr-batch-row-stock {
    grid-template-columns: minmax(0, 1fr) minmax(120px, .32fr);
}
.pr-batch-cell {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-right: 1px solid var(--primary-light);
}
.pr-batch-cell:last-child {
    border-right: none;
}
.pr-batch-pricing {
    background: var(--hover-bg);
}
.pr-batch-stock { background: var(--bg-alt); }
.pr-batch .pr-label {
    color: var(--primary-dark);
    font-size: 0.75rem;
}
.pr-batch .pr-value {
    color: var(--primary-dark);
}
.pr-batch .pr-value-lg {
    font-size: 1.2rem;
}

/* Итоговый блок (итого с покраской) */
.pr-batch-total {
    background: #eaf6ee;
    border-color: var(--primary);
    border-width: 2px;
}
.pr-batch-total .pr-batch-cell {
    border-right-color: var(--primary);
}
.pr-batch-total .pr-batch-pricing {
    background: #dceee2;
}
.pr-batch-total .pr-label {
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.pr-batch-total .pr-value-lg {
    color: var(--primary);
}
.pr-batch-total .pr-value-xl {
    color: var(--primary-dark);
    font-size: 1.5rem;
}

/* ===== Плавное появление детальных таблиц ===== */
.pr-details-wrap {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, opacity 0.3s ease, margin 0.3s ease;
    margin: 0;
}
.pr-details-wrap.open {
    max-height: 600px;
    opacity: 1;
    margin-top: 2px;
}
.params-summary .pr-details-wrap:not(.single) {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.params-summary .pr-details-wrap:not(.single) > .pr-table {
    flex: none;
}
@media (min-width: 600px) {
    .pr-details-wrap:not(.single) {
        display: flex;
        gap: 10px;
    }
    .pr-details-wrap:not(.single) > .pr-table {
        flex: 1;
        min-width: 0;
    }
}

/* ===== Кнопка Детали ===== */
.btn-detail-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
}
.btn-detail-toggle:hover {
    color: var(--primary);
    border-color: var(--primary-light);
    background: #f4faf6;
}
.btn-detail-toggle .detail-chevron {
    transition: transform 0.2s;
}
.btn-detail-toggle.open .detail-chevron {
    transform: rotate(90deg);
}

.params-summary > #addToKpBtn {
    width: 100%;
}

/* ===== Результаты — общие стили для элементов внутри секций ===== */
.result-item {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.result-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.result-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
}

.result-value.highlight {
    color: var(--primary);
    font-size: 1.3rem;
}

.result-inline {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.result-inline .result-value {
    font-size: 1.2rem;
}

/* ===== Таблица ===== */
.table-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.table-controls select,
.table-controls input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font);
    background: #fff;
}

.table-controls select {
    min-width: 200px;
}

.table-controls input {
    flex: 1;
    min-width: 160px;
}

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-light) var(--border);
}
.table-wrapper::-webkit-scrollbar {
    height: 6px;
}
.table-wrapper::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: 3px;
}
.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 3px;
}
.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}
/* Индикатор прокрутки для мобильных */
.table-wrapper::after {
    content: '← →';
    display: none;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 4px 0;
    opacity: 0.6;
    letter-spacing: 4px;
}
@media (hover: none) and (pointer: coarse) {
    .table-wrapper::after {
        display: block;
    }
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

/* Таблица каталога — автоподбор ширины колонок по содержимому */
#sizeTable {
    table-layout: auto;
    width: 100%;
}

#sizeTable thead th {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

#sizeTable tbody td {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Размеры, сорт и денежные значения читаются как единое значение. */
#sizeTable tbody td:not(:first-child) {
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
}

/* Ширина колонок таблицы каталога */
#sizeTable .col-category { min-width: 160px; }
#sizeTable .col-size     { width: 130px; max-width: 150px; }
#sizeTable .col-sort     { width: 65px; }
#sizeTable .col-volume   { width: 100px; }
#sizeTable .col-pcs      { width: 90px; }
#sizeTable .col-price    { width: 95px; }

thead th {
    background: var(--primary);
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

/* Групповые заголовки таблицы каталога (НДС / Наличные) */
.th-group-header {
    text-align: center;
    background: var(--primary-dark);
    font-size: 0.82rem;
    letter-spacing: 0.5px;
}

.th-sub {
    text-align: center;
    font-size: 0.78rem;
    font-weight: 500;
    background: var(--primary-light);
    padding: 6px 8px;
}

/* Двухуровневая шапка: фиксируем только верхнюю строку */
#sizeTable thead tr:first-child th {
    top: 0;
    z-index: 2;
}

#sizeTable thead tr:nth-child(2) th {
    top: 38px; /* высота первой строки */
    z-index: 1;
}

thead th:first-child {
    border-radius: var(--radius-sm) 0 0 0;
}

thead th:last-child {
    border-radius: 0 var(--radius-sm) 0 0;
}

tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

/* Перенос длинного наименования в таблице каталога */
#tableBody td:first-child {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
    max-width: 180px;
}

tbody tr:hover {
    background: var(--bg-light);
}

tbody tr:nth-child(even) {
    background: var(--bg-alt);
}

tbody tr:nth-child(even):hover {
    background: #f0f8f0;
}

/* ===== Коммерческое предложение (КП) ===== */
#kpTable {
    border: 1px solid #b9c5bc;
}

#kpTable thead th {
    border: 1px solid #1f5a39;
    border-right-color: rgba(255, 255, 255, 0.28);
}

#kpTable thead th:last-child {
    border-right-color: #1f5a39;
}

.kp-name-sort-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}
.kp-name-sort-button:hover { text-decoration: underline; }
.kp-name-sort-button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.kp-name-sort-button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; opacity: .65; }
#kpTable th[aria-sort="ascending"] .kp-name-sort-button svg { transform: rotate(180deg); opacity: 1; }
#kpTable th[aria-sort="descending"] .kp-name-sort-button svg { opacity: 1; }

#kpTable tbody td {
    border: 1px solid #c8d1ca;
}

#kpTable tbody td[data-col="quantity"] {
    font-weight: 700;
}

#kpTable tfoot td {
    border: 1px solid #c8d1ca;
}

#kp-section {
    border-left: 4px solid var(--primary);
    background: linear-gradient(135deg, #ffffff 0%, var(--bg-light) 100%);
    position: relative;
}

#kp-section::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle at top right, rgba(44, 110, 73, 0.04) 0%, transparent 70%);
    border-radius: 0 var(--radius) 0 0;
    pointer-events: none;
}

.kp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.kp-header h2 {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.kp-heading { min-width: 0; }
.kp-formation-date { margin: 5px 0 0 30px; color: var(--text-secondary); font-size: .78rem; font-weight: 600; }

.kp-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.proposal-inline-actions { gap: 8px; }
.proposal-inline-actions[hidden] { display: none; }
.proposal-controls-row { margin: 12px 0 14px; }
.proposal-controls-row[hidden] { display: none; }
.proposal-action-button {
    min-height: 36px;
    padding: 0 11px !important;
    border: 1px solid var(--border) !important;
    border-radius: 5px;
    color: var(--primary) !important;
    background: #fff !important;
    font: 700 .78rem var(--font) !important;
}
.proposal-action-button:hover { border-color: var(--primary-light) !important; background: var(--bg-alt) !important; }
.proposal-action-label { display: inline; }
.kp-title-number { gap: 3px; }
.kp-title-number > span { font-size: .9rem; }
.kp-title-number .kp-number-input {
    width: 56px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--primary);
    font: 700 1rem var(--font);
}
.kp-header-icon-action {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    display: inline-grid;
    place-items: center;
}
.kp-header-icon-action .icon { margin: 0; }

/* ===== Блок клиента (кому выставлять КП) ===== */
#client-section {
    margin-bottom: 16px;
}
#client-section h2 {
    font-size: 1.1rem;
    margin-bottom: 12px;
}
.client-type-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    width: fit-content;
}
.client-type-option {
    padding: 8px 20px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
    color: var(--text-secondary);
    user-select: none;
    border-right: 1.5px solid var(--border);
}
.client-type-option:last-child {
    border-right: none;
}
.client-type-option.active {
    background: var(--primary);
    color: #fff;
}
.client-type-option:hover:not(.active) {
    background: var(--hover-bg);
}
.client-fields {
    transition: opacity 0.2s;
}
#client-section .form-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* ===== Блок добавления произвольной позиции в КП ===== */
.kp-custom-add {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 10px;
}
.kp-custom-fields {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.kp-custom-fields .form-group {
    margin-bottom: 0;
}
.kp-custom-fields .form-group label {
    font-size: 0.78rem;
    margin-bottom: 3px;
}
.kp-custom-fields input {
    padding: 8px 10px;
    font-size: 0.85rem;
}
.kp-custom-fields .custom-item-actions {
    flex-direction: row;
    align-items: center;
    gap: 6px;
}
.kp-actions-cell { padding: 5px 6px !important; }
.kp-row-actions { display: grid; grid-template-columns: 31px 31px; align-items: center; gap: 5px; width: 67px; }
.kp-row-action {
    display: inline-grid;
    place-items: center;
    width: 31px;
    height: 31px;
    min-width: 31px;
    padding: 0;
    border: 1px solid #b8d4c0;
    border-radius: 6px;
    background: #f5faf6;
    color: var(--primary);
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, transform .15s;
}
.kp-row-action:hover { background: #e7f3ea; border-color: var(--primary); color: var(--primary-dark); transform: translateY(-1px); }
.kp-row-action:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 2px; }
.kp-row-action--edit { grid-column: 1; }
.kp-row-action--delete { border-color: #ecc9bb; background: #fff8f5; color: #a94b20; }
.kp-row-action--delete { grid-column: 2; }
.kp-row-action--delete:hover { border-color: #c85f38; background: #fff0e9; color: #873716; }
.kp-row-action svg { display: block; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kp-position-order { display: inline-flex; align-items: center; gap: 5px; }
.kp-order-buttons { display: grid; gap: 1px; }
.kp-order-button { width: 21px; min-width: 21px; height: 18px; border: 0; background: transparent; }
.kp-order-button svg { width: 14px; height: 14px; }
.kp-order-button--up svg { transform: rotate(180deg); }
.kp-order-button:disabled { color: var(--text-muted); opacity: .4; cursor: default; }
.kp-order-button:disabled:hover { background: transparent; transform: none; }
/* Блок доставки под произвольной позицией */
.kp-delivery-block {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    margin-top: 10px;
    font-size: 0.88rem;
    flex-wrap: wrap;
    background: var(--bg);
    border-radius: var(--radius-sm);
}
.kp-delivery-block .delivery-cost-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.kp-delivery-block .delivery-linked-order-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.kp-delivery-block .delivery-cost-input {
    width: 100px;
    padding: 6px 8px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
}

/* Строка чипсов (тип цены) */
.kp-chips-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0 4px 0;
    margin-bottom: 8px;
    font-size: 0.88rem;
    flex-wrap: wrap;
}

.chip-group-label {
    color: var(--text-secondary);
    font-weight: 500;
    margin-right: 2px;
    white-space: nowrap;
}

.chip-group-sep {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
    flex-shrink: 0;
}

/* Пробные варианты компактного меню прайс-листов */
.price-menu {
    position: relative;
    z-index: 3;
}
.price-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 6px 10px 6px 12px;
    border: 1.5px solid var(--primary);
    border-radius: 20px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font: 600 0.85rem var(--font);
    transition: border-color .18s, box-shadow .18s, background .18s;
}
.price-menu-trigger:hover,
.price-menu.open .price-menu-trigger {
    border-color: var(--primary-dark);
    background: var(--primary-dark);
    box-shadow: 0 2px 9px rgba(44, 110, 73, .25);
}
.price-menu-label {
    color: rgba(255,255,255,.78);
    font-weight: 600;
}
.price-menu-value {
    color: #fff;
    white-space: nowrap;
}
.price-menu-arrow { transition: transform .18s; }
.price-menu.open .price-menu-arrow { transform: rotate(180deg); }
.price-menu-options {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 158px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    box-shadow: 0 10px 24px rgba(24, 56, 38, .16);
}
.price-menu.open .price-menu-options { display: grid; gap: 2px; }
.price-menu .price-chip {
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    box-shadow: none;
}
.price-menu .price-chip:hover { background: var(--bg-light); color: var(--primary-dark); }
.price-menu .price-chip.active { background: var(--success-light); color: var(--primary-dark); }
.price-menu-preview {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-secondary);
    font-size: .74rem;
}
.price-menu-preview select {
    min-height: 30px;
    padding: 4px 24px 4px 7px;
    border: 1px dashed var(--border);
    border-radius: 6px;
    background-color: transparent;
    color: var(--text-secondary);
    font: 600 .74rem var(--font);
}

/* Вариант 1: зелёные овальные чипсы */
.client-type-toggle {
    gap: 8px;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
}
.client-type-option {
    padding: 6px 16px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    background: #fff;
    color: var(--text-secondary);
}
.client-type-option:last-child { border-right: 1.5px solid var(--border); }
.client-type-option.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(44, 110, 73, .25);
}
.client-type-option:hover:not(.active) { border-color: var(--primary-light); background: var(--bg-light); }

/* Вариант 2: строгие прямоугольные переключатели */
body[data-chip-style="strict"] .price-menu-trigger,
body[data-chip-style="strict"] .price-type-chip,
body[data-chip-style="strict"] .delivery-chip,
body[data-chip-style="strict"] .client-type-option {
    border-radius: var(--radius-sm);
    box-shadow: none;
}
body[data-chip-style="strict"] .price-menu-trigger {
    border-color: var(--border);
    background: #fff;
    color: var(--text-primary);
}
body[data-chip-style="strict"] .price-menu-trigger:hover,
body[data-chip-style="strict"] .price-menu.open .price-menu-trigger { border-color: var(--primary-light); background: #fff; }
body[data-chip-style="strict"] .price-menu-label { color: var(--text-secondary); }
body[data-chip-style="strict"] .price-menu-value { color: var(--primary-dark); }
body[data-chip-style="strict"] .price-type-chip.active,
body[data-chip-style="strict"] .delivery-chip.active,
body[data-chip-style="strict"] .client-type-option.active { box-shadow: none; }

/* Вариант 3: мягкие метки */
body[data-chip-style="soft"] .price-menu-trigger,
body[data-chip-style="soft"] .price-type-chip,
body[data-chip-style="soft"] .delivery-chip,
body[data-chip-style="soft"] .client-type-option {
    border-color: transparent;
    background: var(--bg-light);
    color: var(--primary-dark);
    box-shadow: none;
}
body[data-chip-style="soft"] .price-menu-label { color: var(--text-secondary); }
body[data-chip-style="soft"] .price-menu-value { color: var(--primary-dark); }
body[data-chip-style="soft"] .price-menu-trigger:hover,
body[data-chip-style="soft"] .price-menu.open .price-menu-trigger { background: var(--success-light); }
body[data-chip-style="soft"] .price-type-chip.active,
body[data-chip-style="soft"] .delivery-chip.active,
body[data-chip-style="soft"] .client-type-option.active {
    border-color: var(--primary-light);
    background: var(--success-light);
    color: var(--primary-dark);
    box-shadow: inset 0 0 0 1px var(--primary-light);
}

/* Вариант 4: минимальный */
body[data-chip-style="minimal"] .price-menu-trigger {
    min-height: 30px;
    gap: 6px;
    padding: 3px 4px;
    border-color: transparent;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
}
body[data-chip-style="minimal"] .price-menu-trigger:hover,
body[data-chip-style="minimal"] .price-menu.open .price-menu-trigger { border-bottom-color: var(--primary); background: transparent; }
body[data-chip-style="minimal"] .price-menu-label { display: none; }
body[data-chip-style="minimal"] .price-menu-value { color: var(--text-primary); }
body[data-chip-style="minimal"] .price-menu-value::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--primary);
}
body[data-chip-style="minimal"] .price-type-chip,
body[data-chip-style="minimal"] .delivery-chip,
body[data-chip-style="minimal"] .client-type-option {
    padding: 5px 3px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: var(--text-secondary);
}
body[data-chip-style="minimal"] .price-type-chip.active,
body[data-chip-style="minimal"] .delivery-chip.active,
body[data-chip-style="minimal"] .client-type-option.active {
    border-bottom-color: var(--primary);
    background: transparent;
    color: var(--primary-dark);
    box-shadow: none;
}
body[data-chip-style="minimal"] .client-type-option:last-child { border-right: 0; }

.price-chip,
.price-type-chip,
.delivery-chip {
    padding: 6px 16px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: #fff;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
    user-select: none;
}

.price-chip:hover,
.price-type-chip:hover,
.delivery-chip:hover {
    border-color: var(--primary-light);
    color: var(--primary);
    background: var(--bg-light);
}

.price-chip.active,
.price-type-chip.active,
.delivery-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(44, 110, 73, 0.25);
}

.price-chip.active:hover,
.price-type-chip.active:hover,
.delivery-chip.active:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 2px 10px rgba(44, 110, 73, 0.35);
}

/* Анимация переключения чипсов */
.price-chip, .price-type-chip, .delivery-chip {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.price-chip::after, .price-type-chip::after, .delivery-chip::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--primary);
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: 20px;
}

.price-chip:active::after, .price-type-chip:active::after, .delivery-chip:active::after {
    opacity: 0.15;
}

/* Универсальные зелёные овальные меню для переключателей */
.choice-menu {
    position: relative;
    z-index: 3;
    display: inline-block;
}
.choice-menu.client-type-toggle {
    display: inline-block;
    margin-bottom: 16px;
}
.choice-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 6px 10px 6px 12px;
    border: 1.5px solid var(--primary);
    border-radius: 20px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font: 600 .85rem var(--font);
    transition: background .18s, border-color .18s, box-shadow .18s;
}
.pg-field-treatment .choice-menu,
.pg-field-treatment .choice-menu-trigger {
    width: 100%;
}
.pg-field-treatment .choice-menu-trigger {
    min-height: 44px;
    justify-content: space-between;
}
.choice-menu-trigger:hover,
.choice-menu.open .choice-menu-trigger {
    border-color: var(--primary-dark);
    background: var(--primary-dark);
    box-shadow: 0 2px 9px rgba(44, 110, 73, .25);
}
.choice-menu-label { color: rgba(255,255,255,.78); }
.choice-menu-value { color: #fff; white-space: nowrap; }
.choice-menu-arrow { transition: transform .18s; }
.choice-menu.open .choice-menu-arrow { transform: rotate(180deg); }
.choice-menu-options {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: max-content;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    box-shadow: 0 10px 24px rgba(24, 56, 38, .16);
}
.choice-menu.open .choice-menu-options { display: grid; gap: 2px; }
.choice-menu-options .price-type-chip,
.choice-menu-options .delivery-chip,
.choice-menu-options .client-type-option,
.choice-menu-options .treatment-option {
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    box-shadow: none;
    font: 600 .85rem var(--font);
}
.choice-menu-options .price-type-chip:hover,
.choice-menu-options .delivery-chip:hover,
.choice-menu-options .client-type-option:hover,
.choice-menu-options .treatment-option:hover {
    background: var(--bg-light);
    color: var(--primary-dark);
}
.choice-menu-options .price-type-chip.active,
.choice-menu-options .delivery-chip.active,
.choice-menu-options .client-type-option.active,
.choice-menu-options .treatment-option.active {
    border: 0;
    background: var(--success-light);
    color: var(--primary-dark);
    box-shadow: none;
}

/* Приоритет пробных стилей над базовым оформлением чипсов */
body[data-chip-style="strict"] .price-type-chip,
body[data-chip-style="strict"] .delivery-chip,
body[data-chip-style="strict"] .client-type-option {
    border-radius: var(--radius-sm);
    box-shadow: none;
}
body[data-chip-style="soft"] .price-menu-trigger,
body[data-chip-style="soft"] .price-type-chip,
body[data-chip-style="soft"] .delivery-chip,
body[data-chip-style="soft"] .client-type-option {
    border-color: transparent;
    background: var(--bg-light);
    color: var(--primary-dark);
    box-shadow: none;
}
body[data-chip-style="soft"] .price-type-chip.active,
body[data-chip-style="soft"] .delivery-chip.active,
body[data-chip-style="soft"] .client-type-option.active {
    border-color: var(--primary-light);
    background: var(--success-light);
    color: var(--primary-dark);
    box-shadow: inset 0 0 0 1px var(--primary-light);
}
body[data-chip-style="minimal"] .price-type-chip,
body[data-chip-style="minimal"] .delivery-chip,
body[data-chip-style="minimal"] .client-type-option {
    padding: 5px 3px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: var(--text-secondary);
}
body[data-chip-style="minimal"] .price-type-chip.active,
body[data-chip-style="minimal"] .delivery-chip.active,
body[data-chip-style="minimal"] .client-type-option.active {
    border-bottom-color: var(--primary);
    background: transparent;
    color: var(--primary-dark);
    box-shadow: none;
}

.delivery-cost-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
}

.delivery-cost-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
}

.delivery-cost-input {
    width: 100px;
}

.delivery-cost-input {
    padding: 6px 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-family: var(--font);
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
    -moz-appearance: textfield;
    appearance: textfield;
}

.delivery-cost-input::-webkit-outer-spin-button,
.delivery-cost-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.delivery-cost-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(44, 110, 73, 0.1);
}

.delivery-cost-input::placeholder {
    color: #bbb;
}

.delivery-cost-currency {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.88rem;
}

/* Кнопка "Очистить" — менее заметная */
.btn-clear-link {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 8px 14px;
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-clear-link:hover {
    background: #fff0f0;
    border-color: var(--accent-dark);
    color: var(--accent-dark);
}

.btn-accent {
    background: var(--accent);
    color: var(--text);
}

.btn-accent:hover {
    background: #e08f4a;
}

.btn-danger {
    background: var(--accent-dark);
    color: #fff;
}

.btn-danger:hover {
    background: #d45a3e;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: #fff;
}

/* ===== Выпадающее меню кнопки "Скачать" ===== */
.btn-dropdown {
    position: relative;
    display: inline-block;
}

.btn-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.btn-dropdown-toggle .dropdown-arrow {
    transition: transform 0.2s ease;
}

.btn-dropdown.open .btn-dropdown-toggle .dropdown-arrow {
    transform: rotate(180deg);
}

.btn-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 160px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    z-index: 100;
    overflow: hidden;
    margin-top: 4px;
}

.btn-dropdown.open .btn-dropdown-menu {
    display: block;
}

.btn-dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    text-align: left;
    font-family: var(--font);
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s;
}

.btn-dropdown-item:hover {
    background: var(--bg);
    color: var(--primary);
}

.btn-dropdown-item:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.kp-total-row td {
    background: var(--warning-light);
    font-weight: 700;
    font-size: 1rem;
    padding: 12px;
    border-top: 2px solid var(--accent) !important;
}
.kp-total-summary {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px 20px;
}
.kp-total-label { color: var(--text-dark); letter-spacing: .03em; }
.kp-total-volume,
.kp-total-weight,
.kp-total-sum {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding-left: 16px;
    border-left: 1px solid rgba(0,0,0,.14);
}
.kp-total-volume { color: var(--primary-dark); }
.kp-total-weight { color: var(--primary); }
.kp-total-sum { color: var(--accent-dark); }
.kp-total-volume b,
.kp-total-weight b,
.kp-total-sum b { font-size: 1.08rem; }
.availability-cell { color: var(--text-muted); text-align: center; }
.kp-total-row td:last-child {
    color: var(--accent-dark);
    font-size: 1.1rem;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
    background: #e0e0e0;
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
    font-family: var(--font);
}

.btn-sm:hover {
    background: #ccc;
    color: var(--text-dark);
}
/* ===== Анимация добавления/удаления строк КП ===== */
@keyframes kp-row-appear {
    0% {
        opacity: 0;
        transform: translateY(-8px);
        background: rgba(44, 110, 73, 0.15);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
        background: transparent;
    }
}

@keyframes kp-row-disappear {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    100% {
        opacity: 0;
        transform: translateX(20px);
    }
}

#kpBody tr {
    animation: kp-row-appear 0.35s ease-out;
}

#kpBody tr.kp-removing {
    animation: kp-row-disappear 0.25s ease-in forwards;
}

/* Выделяет строку, параметры которой сейчас находятся в форме редактирования. */
#kpBody tr.kp-row-editing {
    background: #e7f3ea !important;
    box-shadow: inset 3px 0 0 var(--primary), inset -3px 0 0 var(--primary);
}

/* ===== Empty state для КП ===== */
.kp-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.kp-empty-state .kp-empty-icon {
    margin-bottom: 12px;
    opacity: 0.4;
    color: var(--primary-light);
}

.kp-empty-state .kp-empty-icon svg {
    width: 56px;
    height: 56px;
}

.kp-empty-state .kp-empty-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.kp-empty-state .kp-empty-hint {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.kp-empty-state .kp-empty-arrow {
    display: inline-block;
    animation: kp-bounce 1.5s ease-in-out infinite;
    color: var(--primary);
    opacity: 0.6;
}

.kp-empty-state .kp-empty-arrow svg {
    width: 32px;
    height: 32px;
}

@keyframes kp-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(6px); }
}

/* ===== Чипсы-фильтры категорий в таблице ===== */
.chip-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.chip-filter {
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
    user-select: none;
}

.chip-filter:hover {
    border-color: var(--primary-light);
    color: var(--primary);
    background: var(--bg-light);
}

.chip-filter.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.chip-filter.active:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* ===== Чекбокс скрытия столбца Сорт в КП ===== */
.sort-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}
.sort-toggle-label:hover {
    background: var(--hover-bg);
}
.sort-toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}
.sort-toggle-text {
    font-weight: 600;
}

/* Скрытие столбца Сорт в таблице КП через colgroup */
#sortCol.hidden {
    visibility: collapse;
}

/* Выбор состава столбцов КП */
.kp-columns-control { position: relative; }
.kp-columns-control > summary,
.kp-sort-button {
    list-style: none;
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 5px 11px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    color: var(--text-secondary);
    font-size: .8rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    user-select: none;
}
.kp-columns-control > summary::-webkit-details-marker { display: none; }
.kp-columns-control > summary::after { content: '⌄'; margin-left: 7px; color: var(--primary); font-size: 1rem; line-height: 1; }
.kp-columns-control[open] > summary { border-color: var(--primary-light); color: var(--primary-dark); }
.kp-sort-button:hover { border-color: var(--primary-light); color: var(--primary-dark); }
.kp-sort-button:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 2px; }
.kp-sort-button:disabled { opacity: .5; cursor: default; }
.kp-columns-menu {
    position: absolute;
    z-index: 10;
    top: calc(100% + 7px);
    right: 0;
    display: grid;
    gap: 3px;
    min-width: 205px;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    box-shadow: 0 10px 26px rgba(24, 56, 38, .16);
}
.kp-columns-title { padding: 2px 4px 6px; color: var(--text-muted); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.kp-columns-menu label { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 4px 5px; border-radius: 5px; color: var(--text-primary); font-size: .8rem; cursor: pointer; }
.kp-columns-menu label:hover { background: var(--bg-light); }
.kp-columns-menu input { width: 15px; height: 15px; accent-color: var(--primary); }
#kpTable[data-hidden-columns~="size"] [data-col="size"],
#kpTable[data-hidden-columns~="sort"] [data-col="sort"],
#kpTable[data-hidden-columns~="quantity"] [data-col="quantity"],
#kpTable[data-hidden-columns~="volumeOne"] [data-col="volumeOne"],
#kpTable[data-hidden-columns~="volumeTotal"] [data-col="volumeTotal"],
#kpTable[data-hidden-columns~="price"] [data-col="price"],
#kpTable[data-hidden-columns~="total"] [data-col="total"] { display: none; }

/* ===== Inline-редактирование количества в КП ===== */
.kp-qty-cell {
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 4px;
    padding: 4px 6px;
    user-select: none;
}

.kp-qty-cell:hover {
    background: #e8f5e9;
    outline: 2px dashed var(--primary-light);
}

.kp-qty-input {
    padding: 4px 6px;
    border: 2px solid var(--primary);
    border-radius: 4px;
    font-size: 0.88rem;
    font-family: var(--font);
    width: 70px;
    text-align: center;
    outline: none;
    box-shadow: 0 0 0 3px rgba(44, 110, 73, 0.15);
}

/* ===== Toast-уведомление для отмены очистки КП ===== */
.kp-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #323232;
    color: #fff;
    padding: 14px 24px;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 9999;
    font-family: var(--font);
    font-size: 0.95rem;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    max-width: 90vw;
}

.kp-toast.kp-toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.kp-toast.kp-toast-hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

.kp-toast-text {
    flex: 1;
}

.kp-toast-undo {
    background: var(--accent);
    color: var(--text);
    border: none;
    border-radius: 6px;
    padding: 8px 18px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font);
    transition: background 0.2s;
    white-space: nowrap;
}

.kp-toast-undo:hover {
    background: #e08f4a;
}

.kp-toast-undo:active {
    transform: scale(0.96);
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.footer-version {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 0.68rem;
    line-height: 1.3;
}

/* ===== Адаптивность ===== */
/* Планшеты и небольшие ноутбуки: освобождаем ширину для рабочих полей. */
@media (max-width: 1050px) {
    .params-layout {
        grid-template-columns: 1fr;
    }

    .params-summary {
        position: static;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    header {
        padding: 18px 12px 16px 88px;
    }

    .brand-mark-header {
        top: 28px;
        left: 12px;
        width: 58px;
        height: 44px;
    }

    .auth-control {
        position: relative;
        justify-content: flex-start;
        margin-top: 12px;
    }

    .auth-user { max-width: 160px; }

    .card {
        padding: 16px;
    }

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

    .kp-number-wrap {
        width: 100%;
        flex-wrap: wrap;
    }

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

    .params-layout {
        grid-template-columns: 1fr;
    }

    .params-summary {
        position: static;
    }

    .params-panel-side {
        width: 100%;
    }

    .params-grid,
    .params-panel-grid,
    .params-side-grid {
        grid-template-columns: 1fr;
    }

    .manual-size-grid {
        grid-template-columns: 1fr;
    }
    .dimension-selects {
        grid-template-columns: 1fr;
    }
    .manual-size-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 3px;
    }
    .manual-size-price-source {
        text-align: left;
    }

    .paint-grid {
        grid-template-columns: 1fr 1fr;
    }
    .antiseptic-price-row {
        grid-template-columns: 1fr;
    }

    .paint-fields .paint-grid,
    .paint-inline-fields,
    .paint-compact-fields {
        grid-template-columns: 1fr;
    }

    .paint-guide-rules,
    .paint-guide-formulas {
        grid-template-columns: 1fr;
    }

    .pr-batch-row {
        grid-template-columns: 1fr 1fr;
    }
    .pr-batch-row-single {
        grid-template-columns: 1fr;
    }


    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .form-inline .form-group {
        min-width: auto;
    }

    .table-controls {
        flex-direction: column;
    }

    .table-controls select,
    .table-controls input {
        width: 100%;
    }
}

/* Горизонтальный планшет: партия остаётся компактной, но без тесных полей. */
@media (min-width: 641px) and (max-width: 768px) {
    .params-panel-grid {
        grid-template-columns: minmax(0, 1.45fr) minmax(210px, 0.85fr);
    }

    .params-side-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ===== Модальное окно предпросмотра печати ===== */
.print-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.print-modal-overlay.active {
    display: flex;
}
.print-modal {
    background: #fff;
    width: 100%;
    max-width: 210mm;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.print-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.print-modal-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
}
.print-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.print-modal-close:hover {
    color: var(--text);
}
.print-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #e8e8e8;
}
.print-modal-body .print-content {
    position: relative;
    background: #fff;
    padding: 32px 38px 18px 38px;
    font-family: 'Montserrat', 'Segoe UI', sans-serif;
    color: var(--text);
    font-size: 0.72rem;
    max-width: 210mm;
    margin: 0 auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    min-height: 297mm;
    box-sizing: border-box;
}
.print-modal-body .print-content .print-brand-logo {
    display: block;
    width: 190px;
    height: auto;
    margin: 0 0 14px;
}
.print-modal-body .print-content .requisites-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 0;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #2c6e49;
}
.print-modal-body .print-content .requisites-col {
    flex: 1;
    font-size: 0.7rem;
    line-height: 1.5;
    color: var(--text-secondary);
}
.print-modal-body .print-content .requisites-client {
    text-align: left;
}
.print-modal-body .print-content .requisites-our {
    text-align: right;
}
.print-modal-body .print-content .requisites-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.print-modal-body .print-content .company-details {
    color: var(--text-secondary);
    font-size: 0.7rem;
    line-height: 1.5;
}
.print-modal-body .print-content .client-info {
    color: var(--text-secondary);
    font-size: 0.7rem;
    line-height: 1.5;
}
.print-modal-body .print-content .doc-title {
    text-align: center;
    font-size: 1rem;
    color: var(--primary-dark);
    margin-bottom: 4px;
}
.print-modal-body .print-content .date {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-size: 0.7rem;
    margin-bottom: 8px;
}
.print-modal-body .print-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.68rem;
    table-layout: auto;
}
.print-modal-body .print-content thead th {
    background: var(--primary);
    color: #fff;
    padding: 5px 4px;
    text-align: left;
    word-break: break-word;
    overflow-wrap: break-word;
    border: 1px solid #1e4d32;
}
.print-modal-body .print-content tbody td {
    padding: 3px 4px;
    border: 1px solid #bfc9c1;
    word-break: break-word;
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}
.print-modal-body .print-content tbody td[data-col="quantity"] {
    font-weight: 700;
}
.print-modal-body .print-content tbody td:nth-child(2) {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}
.print-modal-body .print-content tbody tr:nth-child(even) {
    background: var(--bg-alt);
}
.print-modal-body .print-content .total-row td {
    padding: 8px 6px;
    border-top: 2px solid var(--primary);
    border-right: 1px solid #bfc9c1;
    border-bottom: 1px solid #bfc9c1;
    border-left: 1px solid #bfc9c1;
    background: #fff;
}
.print-total-summary {
    display: flex;
    justify-content: flex-end;
    align-items: stretch;
    gap: 10px;
    width: 100%;
}
.print-total-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 142px;
    padding: 7px 10px;
    border: 1px solid #d0d8d0;
    border-radius: 6px;
    text-align: right;
}
.print-total-item--volume {
    background: #eef7ef;
    border-color: #9bc6a7;
    color: var(--primary-dark);
}
.print-total-item--sum {
    min-width: 178px;
    background: #fff4e5;
    border-color: #f0bd79;
    color: #a94b20;
}
.print-total-label {
    font-size: 0.58rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.print-total-value {
    font-size: 0.9rem;
    line-height: 1.2;
    white-space: nowrap;
}
.print-modal-body .print-content .footer {
    text-align: center;
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 0.65rem;
}
.print-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* ===== Лист отгрузки ===== */
.dispatch-sheet { color: #202020; }
.dispatch-heading { margin-bottom: 14px; }
.dispatch-heading > div { text-align: left; }
.dispatch-heading h2 { margin: 0 0 3px; font-size: 1.15rem; color: #1e4d32; }
.dispatch-heading p { margin: 0; color: #666; font-size: .72rem; }
.dispatch-address { margin: 0 0 12px; font-size: .82rem; line-height: 1.4; }
.dispatch-blank-address { color: #777; }
.dispatch-table { width: 100%; border-collapse: collapse; table-layout: fixed !important; font-size: .78rem !important; }
.dispatch-col-name { width: 70%; }
.dispatch-col-sort { width: 14%; }
.dispatch-col-quantity { width: 16%; }
.dispatch-sheet--without-sort .dispatch-col-name { width: 84%; }
.dispatch-sheet--without-sort .dispatch-col-quantity { width: 16%; }
.dispatch-table th,
.dispatch-table td { border: 1px solid #777 !important; padding: 7px 8px !important; vertical-align: middle; }
.dispatch-table thead th { background: #edf1ed !important; color: #202020 !important; text-align: center !important; font-size: .8rem; }
.dispatch-table .dispatch-name { text-align: left; line-height: 1.35; }
.dispatch-table .dispatch-name span { display: block; margin-top: 2px; font-size: .72rem; }
.dispatch-table .dispatch-sort,
.dispatch-table .dispatch-quantity { text-align: center; font-weight: 700; font-size: .86rem; }
.dispatch-signatures { margin-top: 34px; }
.dispatch-signature-row,
.dispatch-signature-labels { display: grid; grid-template-columns: 82px minmax(180px, 1fr) 120px 100px; gap: 18px; align-items: end; }
.dispatch-signature-row + .dispatch-signature-labels { margin: 3px 0 24px; }
.dispatch-line { display: block; min-height: 20px; border-bottom: 1px solid #222; }
.dispatch-signature-labels small { text-align: center; color: #555; font-size: .64rem; }
/* @media print merged into the block below */

/* ===== Печать: скрываем служебные элементы браузера ===== */
@media print {
    @page {
        margin: 0;
        size: portrait;
    }
    body {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    /* Скрываем всё, кроме содержимого модалки печати */
    body > *:not(.print-modal-overlay) {
        display: none !important;
    }
    .print-modal-overlay {
        position: static !important;
        background: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        padding: 0 !important;
        display: block !important;
        align-items: flex-start !important;
    }
    .print-modal {
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        max-height: none !important;
        height: auto !important;
    }
    .print-modal-header,
    .print-modal-footer {
        display: none !important;
    }
    .print-modal-body {
        overflow: visible !important;
        padding: 0 !important;
        background: #fff !important;
    }
    .print-modal-body .print-content {
        box-shadow: none !important;
        margin: 0 !important;
        min-height: auto !important;
        padding: 32px 38px 18px 38px !important;
        font-size: 0.75rem !important;
    }
    .print-modal-body .dispatch-sheet { padding: 22px 30px 18px !important; }
    .dispatch-heading { margin-bottom: 12px; }
    .dispatch-table { font-size: 9.5pt !important; }
    .dispatch-table th,
    .dispatch-table td { padding: 5px 6px !important; }
    .print-content {
        page-break-after: avoid;
    }
    .print-content table {
        page-break-inside: auto;
    }
    .print-content tr {
        page-break-inside: avoid;
    }
}

/* ===== Кнопки сохранения/загрузки КП ===== */
.kp-save-load {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}
.kp-save-load .kp-action-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 5px;
    font-size: 0.75rem;
    color: #90a090;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
    transition: color 0.15s, background 0.15s;
    line-height: 1;
}
.kp-save-load .kp-action-btn:hover {
    color: var(--text);
    background: #e8eee8;
}
.kp-save-load .kp-action-btn:disabled {
    color: #b7c0b7;
    opacity: .48;
    cursor: not-allowed;
    background: transparent;
}
.kp-save-load .kp-action-btn .kp-icon {
    display: block;
}
.kp-save-load .kp-action-btn:active {
    background: #d8e2d8;
}

/* ===== Секции сохранённых КП ===== */
.saved-kp-section-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 12px 4px 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.saved-kp-section-closed {
    margin-top: 16px;
    color: #999;
}

/* ===== Бейдж статуса КП ===== */
.kp-status-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin: 4px 0;
}
.kp-status-active {
    background: #e8f5e9;
    color: #2c6e49;
}
.kp-status-review {
    background: #fff8e1;
    color: #e08f4a;
}
.kp-status-closed {
    background: #f0f0f0;
    color: #777;
}

/* ===== Кнопки статусов ===== */
.btn-status-review, .btn-status-closed, .btn-status-active {
    border: 1px solid var(--border);
    font-size: 0.8rem;
    padding: 2px 6px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    background: #fff;
    line-height: 1.4;
}
.btn-status-review:hover { border-color: #e08f4a; background: #fff8e1; }
.btn-status-closed:hover { border-color: var(--primary); }
.btn-status-active:hover { border-color: var(--accent); }

/* ===== Модальное окно списка сохранённых КП ===== */
.load-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9000;
    justify-content: center;
    align-items: flex-start;
    padding: 60px 20px;
    overflow-y: auto;
}
.load-modal-overlay.active {
    display: flex;
}
.load-modal {
    background: #fff;
    border-radius: 16px;
    padding: 24px 28px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 12px 48px rgba(0,0,0,0.2);
    animation: alert-appear 0.25s ease;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}
.load-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}
.load-modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}
.load-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.load-modal-close:hover {
    color: var(--text-dark);
}
.load-modal-body {
    overflow-y: auto;
    flex: 1;
}

/* ===== Карточка сохранённого КП ===== */
.saved-kp-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    margin-bottom: 10px;
    transition: background 0.15s;
    gap: 12px;
}
.saved-kp-card:hover {
    background: #f7faf7;
}
.saved-kp-card-info {
    flex: 1;
    min-width: 0;
}
.saved-kp-card-number {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}
.saved-kp-card-meta {
    font-size: 0.78rem;
    color: #888;
    margin-top: 2px;
}
.saved-kp-card-client {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.saved-kp-card-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
    align-items: stretch;
}
.saved-kp-card-actions .btn-sm {
    padding: 4px 10px;
    font-size: 0.72rem;
    white-space: nowrap;
}
.saved-kp-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ===== Поиск в списке КП ===== */
.saved-kp-search {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    outline: none;
    box-sizing: border-box;
    margin-bottom: 10px;
}
.saved-kp-search:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(44,110,73,0.1);
}

/* ===== Реестр сохранённых КП ===== */
.saved-kp-modal {
    max-width: 760px;
}
.saved-kp-modal .load-modal-header {
    align-items: flex-start;
    margin-bottom: 18px;
}
.saved-kp-modal-subtitle {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: .8rem;
    line-height: 1.35;
}
.saved-kp-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 172px;
    gap: 10px;
    margin-bottom: 14px;
}
.saved-kp-toolbar .saved-kp-search {
    margin: 0;
}
.saved-kp-status-filter {
    min-height: 36px;
    padding: 7px 28px 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-dark);
    font: inherit;
    font-size: .84rem;
    outline: none;
}
.saved-kp-status-filter:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(44,110,73,.1);
}
.database-proposal-list {
    border-top: 1px solid var(--border-light);
}
.database-proposal-card {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr) 122px 112px auto;
    align-items: center;
    gap: 14px;
    min-height: 70px;
    margin: 0;
    padding: 12px 4px;
    border: 0;
    border-bottom: 1px solid var(--border-light);
    border-radius: 0;
}
.database-proposal-card:hover {
    background: #f7faf7;
}
.database-proposal-number {
    color: var(--primary-dark);
    font-size: .94rem;
    font-weight: 800;
    white-space: nowrap;
}
.database-proposal-client {
    min-width: 0;
}
.database-proposal-client-name {
    overflow: hidden;
    color: var(--text);
    font-size: .92rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.database-proposal-date {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: .76rem;
}
.database-proposal-manager,
.cloud-client-manager {
    display: block;
    margin-top: 3px;
    color: var(--primary-dark);
    font-size: .72rem;
    font-weight: 700;
}
.database-proposal-total {
    color: var(--text-dark);
    font-size: .86rem;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}
.database-proposal-status {
    display: inline-flex;
    justify-content: center;
    padding: 5px 7px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: .72rem;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
}
.database-proposal-status--draft { background: #fff4d9; border-color: #efce86; color: #815d12; }
.database-proposal-status--sent { background: #e8f1fa; border-color: #b9d2ea; color: #255b8b; }
.database-proposal-status--completed { background: #e6f4ea; border-color: #acd8b8; color: #27633a; }
.database-proposal-status--rejected { background: #fbeaea; border-color: #edc2c2; color: #9b3a3a; }
.database-proposal-card .saved-kp-card-actions {
    align-items: flex-end;
}
.database-proposal-card .saved-kp-card-actions .btn-sm {
    min-width: 92px;
    min-height: 34px;
    padding: 7px 10px;
    font-size: .76rem;
}
.saved-kp-empty {
    border: 1px dashed var(--border);
    border-radius: 6px;
    background: #fbfcfb;
}
@media (max-width: 640px) {
    .saved-kp-modal { padding: 20px; }
    .saved-kp-toolbar { grid-template-columns: 1fr; }
    .database-proposal-card {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px 12px;
        padding: 13px 2px;
    }
    .database-proposal-number { grid-column: 1; }
    .database-proposal-status { grid-column: 2; grid-row: 1; }
    .database-proposal-client { grid-column: 1 / -1; }
    .database-proposal-total { grid-column: 1; text-align: left; }
    .database-proposal-card .saved-kp-card-actions { grid-column: 2; grid-row: 3; }
}

/* ===== Калькулятор покраски ===== */
.paint-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.paint-results {
    margin-top: 16px;
}

/* ===== Модальное окно-предупреждение (alert) ===== */
.paint-guide-overlay {
    position: fixed;
    z-index: 1200;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(18, 36, 27, 0.55);
}
.paint-guide-overlay.active { display: flex; }
.paint-guide-modal {
    display: flex;
    flex-direction: column;
    width: min(820px, 100%);
    max-height: min(760px, calc(100vh - 40px));
    overflow: hidden;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 18px 55px rgba(0, 0, 0, 0.3);
}
.paint-guide-header,
.paint-guide-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 17px 20px;
    background: var(--bg-alt);
}
.paint-guide-header { border-bottom: 1px solid var(--border-light); }
.paint-guide-footer { justify-content: flex-end; border-top: 1px solid var(--border-light); }
.paint-guide-eyebrow {
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.paint-guide-header h3 { margin: 3px 0 0; color: var(--text); font-size: 1.15rem; }
.paint-guide-close {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.7rem;
    line-height: 1;
}
.paint-guide-close:hover { background: #e7eee9; color: var(--primary-dark); }
.paint-guide-body { overflow-y: auto; padding: 20px; color: var(--text-secondary); font-size: 0.88rem; line-height: 1.52; }
.paint-guide-body p { margin: 0; }
.paint-guide-intro { color: var(--text); font-size: 0.94rem; }
.paint-guide-section { margin-top: 20px; }
.paint-guide-section h4 { margin: 0 0 8px; color: var(--primary-dark); font-size: 0.92rem; }
.paint-guide-section ol,
.paint-guide-section ul { margin: 8px 0 0; padding-left: 20px; }
.paint-guide-rules { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.paint-guide-rule { padding: 12px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); background: var(--bg-alt); }
.paint-guide-rule strong { color: var(--text); }
.paint-guide-rule p { margin-top: 6px; }
.paint-guide-note { color: #785411; font-size: 0.8rem; }
.paint-guide-formulas { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.paint-guide-formulas div { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); background: #f5f8f5; }
.paint-guide-formulas span { font-size: 0.78rem; }
.paint-guide-body code { color: var(--primary-dark); font: 700 0.8rem/1.2 var(--font); white-space: nowrap; }
.paint-guide-total { margin-top: 10px !important; padding: 10px; border-left: 3px solid var(--primary); background: var(--success-light); color: var(--text); }

.alert-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.auth-modal-overlay {
    display: none;
    position: fixed;
    z-index: 10002;
    inset: 0;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(18, 36, 27, .52);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.auth-modal-overlay.active { display: flex; }
.auth-modal {
    width: min(100%, 410px);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .24);
}
.auth-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px 14px;
    border-bottom: 1px solid var(--border-light);
}
.auth-modal-header h3 {
    margin: 2px 0 0;
    color: var(--primary-dark);
    font-size: 1.15rem;
}
.auth-modal-eyebrow {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
}
.auth-modal-close {
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}
.auth-form {
    display: grid;
    gap: 14px;
    padding: 20px 22px 22px;
}
.auth-form .form-group { margin: 0; }
.password-requirements {
    margin: -3px 0 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.45;
}
.delivery-calculation-result {
    display: grid;
    gap: 4px;
    padding: 11px 13px;
    border-left: 3px solid var(--primary);
    background: var(--success-light);
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.35;
}
.delivery-calculation-result strong {
    color: var(--primary-dark);
    font-size: 1.55rem;
    line-height: 1.1;
}
.delivery-calculation-result-math {
    color: var(--text-secondary);
    font-size: 0.76rem;
    line-height: 1.5;
    white-space: pre-line;
}
.delivery-calculation-result.is-message {
    border-left-color: var(--border);
    background: var(--card-bg);
    color: var(--text-muted);
}
.delivery-calculation-result.is-message strong { display: none; }
.delivery-calculation-result.is-message .delivery-calculation-result-math { display: none; }
.password-visibility {
    display: flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
}
.password-visibility input { accent-color: var(--primary); }
.auth-secondary-action {
    justify-self: center;
    padding: 2px 4px;
    border: 0;
    background: transparent;
    color: var(--primary);
    font: inherit;
    font-size: 0.8rem;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.auth-secondary-action:hover { color: var(--primary-dark); }
.auth-secondary-action:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 2px; }
.proposal-status-field { display: grid; gap: 6px; margin-top: 14px; color: var(--text-secondary); font-size: .82rem; font-weight: 700; }
.proposal-status-field[hidden] { display: none; }
.proposal-status-field select { min-height: 36px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 5px; background: #fff; color: var(--text-dark); font: inherit; }
.cloud-kp-card .proposal-status { color: var(--text-muted); font-size: .78rem; font-weight: 600; }
.auth-error {
    padding: 8px 10px;
    border-left: 3px solid var(--accent-dark);
    background: var(--warning-light);
    color: var(--accent-dark);
    font-size: 0.82rem;
}
.auth-submit { justify-content: center; width: 100%; }
.alert-modal-overlay.active {
    display: flex;
}
.alert-modal {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    padding: 32px 28px 24px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}
.alert-modal-icon {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    margin: 0 auto 10px;
    border-radius: 50%;
    color: var(--primary);
    background: var(--success-light);
}
.alert-modal-icon svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.alert-modal-eyebrow {
    margin-bottom: 6px;
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.alert-modal-overlay--error .alert-modal-icon {
    color: var(--accent-dark);
    background: var(--warning-light);
}
.alert-modal-overlay--error .alert-modal-eyebrow {
    color: #9a5b1c;
}
.alert-modal-message {
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 20px;
    line-height: 1.5;
}
.alert-modal .btn {
    min-width: 100px;
}
.alert-modal-overlay:not(.alert-modal-overlay--error) .alert-modal .btn {
    background: var(--primary);
}
.alert-modal-overlay:not(.alert-modal-overlay--error) .alert-modal .btn:hover {
    background: var(--primary-dark);
}

.toast-container {
    position: fixed;
    z-index: 10020;
    right: 20px;
    bottom: 20px;
    display: grid;
    gap: 8px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}
.toast-notification {
    display: grid;
    grid-template-columns: 20px 1fr 20px;
    align-items: start;
    gap: 10px;
    padding: 12px 12px 12px 14px;
    border: 1px solid #b9d5c2;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(18, 54, 34, .16);
    color: var(--text);
    font: 600 .84rem/1.35 var(--font);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: auto;
}
.toast-notification.is-visible { opacity: 1; transform: translateY(0); }
.toast-notification-icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: var(--primary);
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.toast-notification-message { padding-top: 1px; }
.toast-notification-close {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: var(--text-secondary);
    font: 1.25rem/1 var(--font);
    cursor: pointer;
}
.toast-notification-close:hover { background: var(--bg-alt); color: var(--text); }
@media (max-width: 640px) {
    .toast-container { right: 16px; bottom: 16px; width: calc(100vw - 32px); }
}

.kp-save-confirm-overlay {
    display: none;
    position: fixed;
    z-index: 10001;
    inset: 0;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(18, 36, 27, .52);
    backdrop-filter: blur(4px);
}
.kp-save-confirm-overlay.active { display: flex; }
.kp-save-confirm-modal {
    width: min(500px, 100%);
    overflow: hidden;
    border-radius: var(--radius);
    background: #fff;
    box-shadow: 0 18px 55px rgba(0,0,0,.28);
}
#kpDuplicateConfirmOverlay .kp-save-confirm-modal { width: min(560px, 100%); }
.kp-save-confirm-header,
.kp-save-confirm-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 20px;
    background: var(--bg-alt);
}
.kp-save-confirm-header { border-bottom: 1px solid var(--border-light); }
.kp-save-confirm-footer { justify-content: flex-end; border-top: 1px solid var(--border-light); }
#kpDuplicateConfirmOverlay .kp-save-confirm-footer .btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 12px;
    white-space: normal;
    line-height: 1.3;
}
@media (max-width: 480px) {
    #kpDuplicateConfirmOverlay .kp-save-confirm-footer { flex-direction: column; align-items: stretch; }
}
.kp-save-confirm-eyebrow { color: var(--primary); font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.kp-save-confirm-header h3 { margin: 3px 0 0; color: var(--text); font-size: 1.05rem; }
.kp-save-confirm-close { border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary); font-size: 1.6rem; line-height: 1; cursor: pointer; }
.kp-save-confirm-close:hover { background: #e7eee9; color: var(--primary-dark); }
.kp-save-confirm-body { padding: 18px 20px; color: var(--text-secondary); font-size: .88rem; line-height: 1.45; }
.kp-save-confirm-body p { margin: 0; color: var(--text); font-weight: 600; }
.kp-save-confirm-changes { display: grid; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.kp-save-confirm-changes li { padding: 8px 10px; border-radius: 6px; background: var(--bg-light); }

/* ===== Индикатор загрузки ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    gap: 16px;
}
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loading-text {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loading-fadeout {
    opacity: 0;
    transition: opacity 0.3s ease;
}

@media (max-width: 480px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .params-panel {
        padding: 12px;
    }

    .params-results {
        padding: 12px;
    }

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

    .paint-fields .paint-grid,
    .paint-inline-fields,
    .paint-compact-fields {
        grid-template-columns: 1fr;
    }

    .pr-batch-row {
        grid-template-columns: 1fr;
    }
    .pr-batch-cell {
        border-right: none;
    }
    .pr-batch-pricing {
        background: transparent;
    }
    .pr-batch-total .pr-batch-cell {
        border-right: none;
    }
}

/* ===== Облачная база клиентов ===== */
.cloud-auth-panel {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 6px 8px 6px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255,255,255,.72);
    color: var(--text-secondary);
    font-size: .72rem;
}
.cloud-auth-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(76,154,110,.14);
}
.cloud-auth-button {
    border: 0;
    border-radius: 999px;
    padding: 5px 10px;
    background: var(--primary);
    color: #fff;
    font: 600 .72rem var(--font);
    cursor: pointer;
}
.cloud-auth-button:hover { background: var(--primary-dark); }
.client-controls-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 12px;
}
.client-controls-row .client-type-toggle { margin-bottom: 0; }
.client-inline-actions { gap: 2px; }
.client-inline-actions[hidden] { display: none; }
.client-action-label { display: none; }
#client-section[data-client-mode="idle"] .client-inline-actions { gap: 8px; }
#client-section[data-client-mode="idle"] .client-action-button {
    min-height: 36px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--primary);
    background: #fff;
    font: 700 .78rem var(--font);
}
#client-section[data-client-mode="idle"] .client-action-button .client-action-label { display: inline; }
#client-section[data-client-mode="idle"] .client-action-button:hover { border-color: var(--primary-light); background: var(--bg-alt); }
.choice-menu.client-type-toggle[hidden] { display: none; }
.client-form-actions { display: flex; justify-content: flex-end; margin: 16px 0 0; }
.client-save-btn { min-height: 38px; }
#clientFormArea { padding-top: 2px; }
.client-notes-field { margin-top: 12px; }
.client-notes-field textarea {
    width: 100%;
    min-height: 58px;
    resize: vertical;
    box-sizing: border-box;
}
.client-load-modal { max-width: 720px; }
.cloud-client-list { display: grid; }
.cloud-client-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 2px;
    border-bottom: 1px solid var(--border-light);
}
.cloud-client-card-info {
    min-width: 0;
    display: grid;
    gap: 3px;
}
.cloud-client-card-info strong,
.cloud-client-card-info span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cloud-client-card-info span { color: var(--text-muted); font-size: .82rem; }
@media (max-width: 560px) {
    .cloud-client-card { align-items: stretch; flex-direction: column; }
    .cloud-client-card .btn { width: 100%; }
}
.cloud-client-status {
    margin-left: auto;
    color: var(--text-muted);
    font-size: .72rem;
    text-align: right;
}
#client-section .card-header-row { margin-bottom: 8px; }
#client-section .card-header-row h2 { margin-bottom: 0; }
.cloud-clients-modal { max-width: 640px; }
.cloud-clients-hint { display: block; margin-top: 2px; color: var(--text-muted); font-size: .68rem; }
.cloud-clients-list { display: grid; gap: 8px; }
.cloud-client-card,
.cloud-kp-card {
    width: 100%;
    display: grid;
    gap: 3px;
    padding: 12px 14px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font-family: var(--font);
    text-align: left;
    cursor: pointer;
    transition: border-color .15s, background .15s, transform .15s;
}
.cloud-client-card:hover,
.cloud-kp-card:hover {
    border-color: var(--primary-light);
    background: var(--bg-light);
    transform: translateY(-1px);
}
.cloud-client-name { color: var(--primary-dark); font-size: .9rem; font-weight: 700; }
.cloud-client-contact { color: var(--text-secondary); font-size: .76rem; }
.cloud-kp-title { color: var(--primary); }
.cloud-kp-card { grid-template-columns: auto 1fr auto; align-items: center; margin-bottom: 7px; }
.cloud-kp-card strong { color: var(--primary-dark); }
.cloud-kp-card span { color: var(--text-secondary); font-size: .78rem; }
.cloud-kp-card small { color: var(--text-muted); font-size: .64rem; }

@media (max-width: 640px) {
    .cloud-client-status { flex-basis: 100%; margin-left: 0; text-align: left; }
    .cloud-kp-card { grid-template-columns: 1fr; }
}

/* Новый список клиентов: перекрывает стили отключённого облачного модуля. */
#cloudClientList .cloud-client-card {
    width: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 2px;
    border: 0;
    border-bottom: 1px solid var(--border-light);
    border-radius: 0;
    background: transparent;
    cursor: default;
    transform: none;
}
#cloudClientList .cloud-client-card:hover {
    border-color: var(--border-light);
    background: transparent;
    transform: none;
}
#cloudClientList .cloud-client-card .btn {
    width: auto;
    flex: 0 0 auto;
    padding: 7px 12px;
}
@media (max-width: 560px) {
    #cloudClientList .cloud-client-card { align-items: stretch; flex-direction: column; gap: 8px; }
    #cloudClientList .cloud-client-card .btn { width: 100%; }
}
