:root {
  --brand: #68747c;
  --brand-dark: #414b52;
  --brand-soft: #e9edef;
  --ink: #20282d;
  --muted: #6f797f;
  --line: #d4dadd;
  --surface: #ffffff;
  --canvas: #e9edef;
  --success: #198754;
  --warning: #d98a00;
  --danger: #c83c4b;
  --sidebar: #242b30;
  --shadow: 0 16px 45px rgba(30, 38, 43, 0.08);
  --radius: 16px;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; font-family: Inter, "Segoe UI", Arial, sans-serif; color: var(--ink); background: var(--canvas); font-size: 14px; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { color: var(--brand); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 29px; line-height: 1.15; margin-bottom: 8px; letter-spacing: -0.02em; }
h2 { font-size: 17px; margin-bottom: 4px; }
button, input, select, textarea { font: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 25px 18px 20px; display: flex; flex-direction: column; background: linear-gradient(165deg, #343c42 0%, var(--sidebar) 55%, #181e22 100%); color: #fff; }
.brand { display: flex; flex-direction: column; gap: 8px; padding: 0 10px 25px; color: #fff; }
.brand:hover { color: #fff; }
.brand img { width: 100%; max-width: 190px; height: auto; opacity: .95; }
.brand span { color: #a9bcc8; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 5px; }
.nav a { display: grid; grid-template-columns: 27px 1fr; align-items: center; min-height: 46px; padding: 9px 12px; border-radius: 11px; color: #b8c8d2; line-height: 1.25; }
.nav a:hover, .nav a.active { color: #fff; background: rgba(200, 210, 216, .12); }
.nav a.active { box-shadow: inset 3px 0 0 var(--brand); }
.nav-icon { color: #b5c0c6; font-size: 18px; text-align: center; }
.nav-divider { height: 1px; margin: 14px 10px; background: rgba(255,255,255,.1); }
.sidebar-footer { margin-top: auto; padding: 15px 11px 0; border-top: 1px solid rgba(255,255,255,.1); }
.environment { display: inline-flex; margin-bottom: 10px; padding: 4px 8px; border-radius: 20px; color: #bfeaff; background: rgba(23,143,189,.2); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.environment-prod { color: #c5f5d7; background: rgba(25,135,84,.22); }
.user-name { margin-bottom: 4px; font-weight: 700; }
.link-button { padding: 0; border: 0; color: #8fa5b3; background: none; cursor: pointer; }
.link-button:hover { color: #fff; }

.main-content { min-width: 0; padding: 36px 42px 70px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.page-header.compact { align-items: center; }
.page-header p:last-child { margin-bottom: 0; }
.eyebrow { margin-bottom: 7px; color: var(--brand-dark); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.muted { color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 12px; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 10px 17px; border: 1px solid transparent; border-radius: 10px; font-weight: 700; cursor: pointer; transition: .15s ease; }
.button-primary { color: #fff; background: var(--brand); box-shadow: 0 8px 20px rgba(23,143,189,.2); }
.button-primary:hover { color: #fff; background: var(--brand-dark); transform: translateY(-1px); }
.button-secondary { color: var(--ink); border-color: var(--line); background: #fff; }
.button-secondary:hover { color: var(--brand-dark); border-color: #a9cad9; background: #fbfdfe; }
.button-danger { color: #fff; background: var(--danger); }
.button-danger:hover { color: #fff; background: #a92f3d; }
.button-ghost { color: var(--muted); background: transparent; }
.button-wide { width: 100%; }
.button-compact { min-height: 34px; padding: 6px 10px; font-size: 11px; white-space: nowrap; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.metric-card, .panel { border: 1px solid #e1e8ed; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.metric-card { min-height: 140px; padding: 21px; display: flex; flex-direction: column; }
.metric-card span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.metric-card strong { margin-top: 16px; font-size: 28px; line-height: 1; }
.metric-card small { margin-top: auto; color: var(--muted); }
.metric-card.accent { color: #fff; border-color: var(--brand); background: linear-gradient(135deg, #3d474e, #7d8990); }
.metric-card.accent span, .metric-card.accent small { color: rgba(255,255,255,.76); }

.panel { margin-bottom: 20px; overflow: hidden; }
.panel-header { min-height: 73px; padding: 19px 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.panel-header p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 18px; color: #6b7c87; background: #f7f9fa; font-size: 11px; font-weight: 800; letter-spacing: .05em; text-align: left; text-transform: uppercase; }
td { padding: 15px 18px; border-top: 1px solid #e8edf0; vertical-align: middle; }
tbody tr:hover td { background: #fbfdfe; }
td small { display: block; margin-top: 4px; color: var(--muted); }
.num { text-align: right; white-space: nowrap; }
.strong-link { font-weight: 800; }
tfoot td { color: var(--ink); background: #f7f9fa; font-size: 16px; font-weight: 800; }
.empty-state { padding: 45px 20px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 7px; color: var(--ink); font-size: 17px; }
.empty-state p { margin: 0; }

.status { display: inline-flex; padding: 6px 9px; border-radius: 30px; color: #52646f; background: #edf1f3; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-ready, .status-approved { color: #147046; background: #e2f4eb; }
.status-published, .status-verified { color: #147046; background: #e2f4eb; }
.status-review { color: #8d630d; background: #fff2d5; }
.status-archived { color: #66727a; background: #e8ecee; }
.status-sent { color: #8d630d; background: #fff2d5; }
.status-rejected { color: #a72b38; background: #fce8ea; }
.forecast-status-row { padding: 0 22px 16px; display: flex; align-items: center; justify-content: flex-start; }
.forecast-status-row .status { margin: 0; }

.alert-card { margin-bottom: 20px; padding: 16px 19px; display: flex; align-items: center; gap: 15px; border: 1px solid #f3d38f; border-radius: 12px; color: #6f4d08; background: #fff8e9; }
.alert-card span { color: #876b32; }
.alert-card a { margin-left: auto; font-weight: 800; }
.alert-card.neutral { align-items: flex-start; flex-direction: column; border-color: #c6e3ef; color: var(--brand-dark); background: var(--brand-soft); }
.alert-card.neutral span { color: #4c6f7d; }
.messages { margin-bottom: 18px; }
.message { padding: 13px 16px; border-radius: 10px; border: 1px solid #b8dec9; color: #176941; background: #eaf7f0; }
.message.error { border-color: #efc3c8; color: #a12c38; background: #fdecf0; }
.message a { color: inherit; font-weight: 800; }

.field-control { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cfd9df; border-radius: 9px; color: var(--ink); background: #fff; outline: none; transition: .15s ease; }
.field-control:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(23,143,189,.12); }
textarea.field-control { resize: vertical; }
select[multiple].field-control { min-height: 210px; }
label { display: block; color: #425460; font-size: 12px; font-weight: 700; }
label .field-control { margin-top: 7px; }
.errorlist { margin: 6px 0 0; padding: 0; color: var(--danger); list-style: none; font-size: 11px; }
.stack-form { display: flex; flex-direction: column; gap: 18px; }
.stack-form label small { display: block; margin-top: 5px; color: var(--muted); font-weight: 400; }
.toolbar { padding: 16px 20px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.toolbar .search { max-width: 420px; }
.narrow-panel { max-width: 720px; padding: 23px; }
.narrow-panel .alert-card { margin: 0 0 24px; }

.editor-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(340px, .9fr); align-items: start; gap: 20px; }
.editor-main, .editor-side { align-self: start; }
.form-grid { padding: 22px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 19px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.reference-picker { padding: 18px 20px 20px; }
.reference-filter-grid { display: grid; grid-template-columns: 1fr; gap: 9px; margin-bottom: 12px; }
.reference-search-label { margin-bottom: 12px; }
.reference-picker-meta { min-height: 31px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.reference-picker-meta strong { color: var(--ink); font-size: 14px; }
.reference-clear { color: var(--brand-dark); font-size: 12px; font-weight: 800; }
.reference-clear:hover { color: var(--brand); }
.reference-choice-list { max-height: 296px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; scrollbar-color: #bfd1da transparent; }
.reference-choice { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: start; gap: 9px; padding: 9px 10px; border: 1px solid transparent; border-radius: 9px; color: #425460; font-size: 12px; font-weight: 600; cursor: pointer; transition: .15s ease; }
.reference-choice[hidden],
.reference-choice.is-filtered-out { display: none !important; }
.reference-choice:hover { border-color: #c8dde6; background: #f5fafc; }
.reference-choice:has(input:checked) { border-color: #8cc9df; color: var(--brand-dark); background: var(--brand-soft); }
.reference-choice input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.reference-choice span { line-height: 1.35; }
.field-hint { margin: 11px 0 0; color: var(--muted); font-size: 12px; }
.positions-panel { margin-top: 0; overflow: visible; }
.panel-header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.line-list { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.line-card { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr) 70px; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fcfdfe; }
.line-card.is-deleted { opacity: .45; }
.line-index { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--brand-dark); background: var(--brand-soft); font-weight: 800; }
.line-fields { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.line-description { grid-column: 1 / -1; }
.line-summary { min-width: 0; grid-column: 2; padding: 12px 14px; border-radius: 9px; color: var(--muted); background: #f1f5f7; line-height: 1.4; }
.line-summary span, .line-summary strong { display: block; }
.line-summary strong { margin-top: 5px; color: var(--ink); }
.delete-line { grid-column: 3; grid-row: 1 / span 2; align-self: center; color: var(--muted); text-align: center; }
.delete-line input { display: block; margin: 0 auto 5px; }
.notes-panel { padding: 21px; }
.editor-actions { position: sticky; bottom: 15px; z-index: 10; margin-top: 20px; padding: 14px 18px; display: flex; align-items: center; justify-content: flex-end; gap: 18px; border: 1px solid #d7e1e6; border-radius: 14px; background: rgba(255,255,255,.94); box-shadow: 0 14px 45px rgba(20, 52, 70, .16); backdrop-filter: blur(12px); }
.editor-actions [data-tkp-submit] { touch-action: manipulation; }
.live-total { margin-left: auto; text-align: right; }
.live-total span, .live-total strong { display: block; }
.live-total span { color: var(--muted); font-size: 11px; }
.live-total strong { margin-top: 3px; font-size: 19px; }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.definition-grid { margin: 0; padding: 21px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.definition-grid dt { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.definition-grid dd { margin: 5px 0 0; font-weight: 700; }
.reference-grid { padding: 18px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.reference-card { padding: 17px; border: 1px solid var(--line); border-radius: 10px; }
.reference-card strong, .reference-card span { display: block; }
.reference-card span { margin-top: 5px; color: var(--brand-dark); font-size: 12px; }
.reference-card p { margin: 10px 0 0; color: var(--muted); }
.reference-card small { display: block; margin-top: 12px; color: var(--ink); font-weight: 700; }
.reference-card-with-photo { padding: 0; overflow: hidden; }
.reference-card-with-photo img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #edf1f3; }
.reference-card-with-photo > div { padding: 17px; }
.calculation-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.checkbox-label { display: flex; align-items: center; gap: 10px; min-height: 42px; padding-top: 20px; }
.checkbox-label input { width: 18px; height: 18px; order: -1; }
.checkbox-card { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafb; cursor: pointer; }
.checkbox-card input { width: 18px; height: 18px; accent-color: var(--brand-dark); }
.reference-toolbar { align-items: flex-end; }
.reference-toolbar label { min-width: 220px; }
.library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.reference-documents { padding: 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.reference-document { padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: #fbfdfe; }
.reference-document strong, .reference-document span { display: block; }
.reference-document span { margin-top: 5px; color: var(--muted); font-size: 12px; }
code { padding: 2px 5px; border-radius: 4px; color: #274d61; background: #eef4f7; font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; }
.audit-table td { vertical-align: top; }
.audit-event { font-weight: 800; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 40px; background: radial-gradient(circle at 20% 20%, #e6f7fd 0, transparent 35%), linear-gradient(135deg, #f3f7f9, #e9f2f6); }
.login-card { width: 100%; max-width: 440px; padding: 42px; border: 1px solid rgba(255,255,255,.9); border-radius: 22px; background: rgba(255,255,255,.93); box-shadow: 0 30px 80px rgba(20, 57, 76, .16); }
.login-logo-frame { width: 100%; margin-bottom: 30px; padding: 22px 18px; display: flex; align-items: center; justify-content: center; background: #050505; }
.login-logo { display: block; width: 100%; height: auto; }
.login-card h1 { font-size: 32px; }
.login-card .stack-form { margin-top: 27px; }

.bitrix-placement-page,
.bitrix-launch-page { min-height: 100vh; display: grid; place-items: center; padding: 22px; background: #eef2f4; }
.bitrix-placement-card,
.bitrix-launch-card { width: 100%; max-width: 560px; padding: 30px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow); text-align: center; }
.bitrix-placement-card img { display: block; width: 190px; max-width: 70%; margin: 0 auto 24px; padding: 15px 18px; border-radius: 12px; background: var(--sidebar); }
.bitrix-placement-card p,
.bitrix-launch-card p { color: var(--muted); line-height: 1.55; }
.bitrix-placement-card .button { margin-top: 8px; }
.narrow-card { max-width: 760px; padding: 26px; }

.profile-main-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(240px, 1.45fr) minmax(130px, .72fr) minmax(160px, .85fr);
  gap: 12px;
}
.line-options-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  align-items: end;
  gap: 12px;
}
.line-pricing-row {
  display: grid;
  grid-template-columns: minmax(155px, .8fr) minmax(130px, .75fr) 105px auto minmax(170px, .9fr);
  align-items: end;
  gap: 12px;
}
.ral-toggle,
.second-side-toggle { display: flex; align-items: center; gap: 7px; min-height: 42px; padding-top: 19px; white-space: nowrap; }
.ral-toggle input, .second-side-toggle input, .manual-price-toggle input { width: 18px; height: 18px; accent-color: var(--brand-dark); }
.manual-price-toggle { display: flex; align-items: center; gap: 7px; min-height: 42px; padding-top: 19px; white-space: nowrap; }
.steel-grade .field-control { max-width: 78px; text-transform: uppercase; }
.field-with-unit { margin-top: 7px; display: flex; align-items: center; gap: 8px; }
.field-with-unit .field-control { margin-top: 0; }
.field-with-unit > span { color: var(--muted); font-size: 12px; }
.profile-price-hidden { display: none; }
.future-position-actions { margin: -4px 0 20px; padding: 16px 18px; display: flex; align-items: center; gap: 12px; border: 1px dashed #c5cdd1; border-radius: 13px; background: rgba(255,255,255,.52); }
.future-position-actions button:disabled { color: #8f989d; border-color: #d8dddf; background: #eef1f2; cursor: not-allowed; box-shadow: none; }
.future-position-actions span { margin-left: auto; color: var(--muted); font-size: 12px; }

/* Version 4.5.2: логически сгруппированная карточка позиции профлиста. */
.line-card[data-line-form] {
  display: block;
  padding: 0;
  overflow: hidden;
  background: #fff;
}
.line-card[data-line-form].is-deleted { opacity: .62; }
.line-card-header {
  min-height: 62px;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: #f7fafb;
}
.line-card-title { display: flex; align-items: center; gap: 11px; min-width: 0; }
.line-card-title > div { min-width: 0; }
.line-card-title strong, .line-card-title small { display: block; }
.line-card-title small { margin-top: 3px; color: var(--muted); font-weight: 500; }
.line-card[data-line-form] .line-index { flex: 0 0 30px; }
.line-delete-button {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 0;
  color: #9b3340;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.line-delete-button:hover { color: #7c1724; text-decoration: underline; }
.line-delete-button.is-undo { color: var(--brand-dark); }
.line-delete-input { display: none; }
.line-card[data-line-form] .line-fields { gap: 0; }
.line-field-group { padding: 16px; border-bottom: 1px solid #e7edf0; }
.line-field-group-title {
  margin-bottom: 12px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.line-field-group-title strong { color: var(--ink); font-size: 13px; }
.line-field-group-title span { color: var(--muted); font-size: 11px; font-weight: 500; }
.line-material-row {
  max-width: 540px;
  display: grid;
  grid-template-columns: minmax(150px, .7fr) minmax(180px, 1fr);
  gap: 12px;
}
.line-coating-row {
  display: grid;
  grid-template-columns: minmax(190px, .8fr) minmax(170px, .8fr) minmax(190px, 1fr);
  align-items: end;
  gap: 12px;
}
.line-card[data-line-form] .line-summary {
  margin: 14px 16px 16px;
  padding: 13px 15px;
  background: #f0f5f7;
}
.line-card-error { margin: 12px 16px 0; }
.line-card[data-line-form] .meterage-calculator { margin: 16px; }
.line-card[data-line-form].is-deleted .line-fields,
.line-card[data-line-form].is-deleted .line-summary { display: none; }
.logistics-body { padding: 18px 22px 22px; }
.logistics-mode ul {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
}
.logistics-mode label {
  align-items: center;
  display: flex;
  min-height: 50px;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafb;
  cursor: pointer;
}
.logistics-mode input[type="radio"] { appearance: none; width: 18px; height: 18px; flex: 0 0 18px; margin: 0; border: 2px solid #9da8ae; border-radius: 3px; background: #fff; }
.logistics-mode input[type="radio"]:checked { border-color: var(--brand-dark); background: var(--brand-dark); box-shadow: inset 0 0 0 3px #fff; }
.logistics-mode label:has(input:checked) { color: var(--brand-dark); border-color: #aab4b9; background: var(--brand-soft); }
.logistics-fields { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(135deg, #f5f7f8, #eceff1); }
.logistics-summary { margin-top: 16px; }
.live-total small { margin-top: 4px; display: block; color: var(--muted); font-size: 12px; }
.competitor-lines { padding: 18px; display: grid; gap: 12px; }
.competitor-line { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #f7f8f8; }
.selected-row td { background: #e8edef; }

.profile-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(330px, .65fr); align-items: start; gap: 20px; }
.profile-form { overflow: visible; }
.signature-upload { padding: 0 22px 22px; }
.signature-upload input[type="file"] { margin-top: 7px; }
.profile-actions { position: static; margin: 0 22px 22px; box-shadow: none; backdrop-filter: none; }
.signature-panel { overflow: hidden; }
.signature-previews { padding: 18px; display: grid; gap: 14px; }
.signature-preview { margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.signature-preview-gray { background: #d9dee1; }
.signature-preview-white { background: #fff; }
.signature-preview img { display: block; width: 100%; height: 110px; object-fit: contain; }
.signature-preview figcaption { margin-top: 9px; color: var(--muted); font-size: 11px; }

.meterage-calculator {
  padding: 14px;
  border: 1px dashed #b9cbd4;
  border-radius: 11px;
  background: #f8fbfc;
}
.meterage-heading,
.meterage-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.meterage-heading small { display: block; margin-top: 3px; color: var(--muted); }
.meterage-rows { margin-top: 10px; display: grid; gap: 8px; }
.meterage-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, .7fr) auto;
  align-items: end;
  gap: 10px;
}
.meterage-total {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.meterage-total strong { color: var(--ink); }
.specification-tools {
  margin: 0 18px 18px;
  padding: 18px;
  border: 1px solid #b9d7e3;
  border-radius: 12px;
  background: #f4fafc;
}
.specification-tools-heading,
.specification-preview-heading,
.specification-import-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.specification-tools-heading h3 { margin: 0 0 4px; font-size: 16px; }
.specification-tools-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.specification-import {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #d7e7ed;
}
.specification-instruction { margin: 0 0 14px; color: #425460; line-height: 1.55; }
.specification-instruction kbd {
  padding: 2px 6px;
  border: 1px solid #b7c6ce;
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--ink);
  background: #fff;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}
.specification-import-actions { justify-content: flex-start; }
.specification-file-button { cursor: pointer; }
.specification-status { margin-top: 12px; min-height: 18px; color: var(--muted); font-size: 12px; }
.specification-status.is-error { color: var(--danger); font-weight: 700; }
.specification-status.is-success { color: #147046; font-weight: 700; }
.specification-preview { margin-top: 14px; padding-top: 14px; border-top: 1px solid #d7e7ed; }
.specification-preview-heading small { display: block; margin-top: 3px; color: var(--muted); }
.specification-preview-table { margin-top: 12px; display: grid; gap: 8px; }
.specification-preview-row {
  display: grid;
  grid-template-columns: 28px minmax(180px, 1.4fr) minmax(120px, .7fr) minmax(120px, .65fr) minmax(110px, .55fr) minmax(160px, 1fr) auto;
  align-items: end;
  gap: 9px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.specification-preview-row.needs-review {
  border-color: #d9a93a;
  box-shadow: inset 3px 0 0 #d9a93a;
}
.specification-preview-row > label:first-child { align-self: center; }
.specification-preview-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--brand); }
.specification-preview-warning { align-self: center; color: #8d630d; font-size: 11px; line-height: 1.35; }
.specification-preview-warning.is-ready { color: #147046; }
.fastener-body { padding: 18px 22px 22px; display: grid; gap: 16px; }
.fastener-mode ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.fastener-mode label { display: flex; align-items: center; gap: 8px; }
.candidate-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.fastener-dimensions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 12px;
}

.text-template-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 410px);
  align-items: start;
  gap: 22px;
}
.text-template-form { min-width: 0; }
.text-template-section { overflow: visible; }
.text-template-section summary {
  min-height: 68px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  cursor: pointer;
  list-style: none;
  font-size: 17px;
  font-weight: 800;
}
.text-template-section summary::-webkit-details-marker { display: none; }
.text-template-section summary::after {
  content: "＋";
  margin-left: auto;
  color: var(--brand);
  font-size: 22px;
}
.text-template-section[open] summary {
  border-bottom: 1px solid var(--line);
}
.text-template-section[open] summary::after { content: "−"; }
.text-template-section summary small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.text-block-grid {
  padding: 20px 22px 23px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 18px;
}
.text-block-field:has(textarea) { grid-column: 1 / -1; }
.text-block-label { display: block; min-height: 18px; }
.text-block-field textarea { min-height: 96px; line-height: 1.5; }
.text-length {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 400;
}
.text-length.is-over { color: #a66a00; }
.text-length strong { font-weight: 800; }
.text-template-save {
  padding: 20px 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 20px;
}
.text-template-side {
  position: sticky;
  top: 22px;
  min-width: 0;
}
.live-text-preview { overflow: hidden; }
.live-preview-paper {
  margin: 18px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid #d8dfe3;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 10px 25px rgba(27, 41, 49, .08);
  overflow-wrap: anywhere;
}
.live-preview-paper [data-text-preview] { white-space: pre-line; }
.live-preview-title {
  display: block;
  color: #26343b;
  font-size: 13px;
  line-height: 1.35;
  text-align: right;
}
.live-preview-paper > p {
  margin: 15px 0;
  padding: 12px;
  border-left: 3px solid #178fbd;
  color: #52616a;
  background: #eff8fb;
  font-size: 11px;
  line-height: 1.45;
}
.live-preview-paper h3 {
  margin: 12px 0 7px;
  padding-bottom: 5px;
  border-bottom: 1px solid #9fd4e8;
  font-size: 12px;
}
.live-preview-rule {
  height: 2px;
  margin: 12px 0;
  background: #178fbd;
}
.live-preview-placeholder {
  height: 48px;
  border: 1px solid #d9dee1;
  background: repeating-linear-gradient(
    to bottom,
    #fff,
    #fff 11px,
    #edf1f3 12px
  );
}
.live-preview-terms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}
.live-preview-terms span {
  min-height: 34px;
  padding: 6px;
  border: 1px solid #d9dee1;
  color: #5f6d75;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}
.live-preview-paper footer {
  margin-top: 16px;
  padding-top: 9px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid #d9dee1;
  color: #65727a;
  font-size: 9px;
}
.revision-list { padding: 8px 18px 18px; }
.revision-list article {
  padding: 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e6ebee;
}
.revision-list article:last-child { border-bottom: 0; }
.revision-list article > div { min-width: 0; }
.revision-list strong,
.revision-list span,
.revision-list small { display: block; }
.revision-list span,
.revision-list small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}
.revision-list form { flex: 0 0 auto; }
.revision-list .button { min-height: 34px; padding: 6px 9px; font-size: 11px; }
.restore-defaults {
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.restore-defaults p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }

@media (max-width: 1350px) {
  .main-content { padding-left: 28px; padding-right: 28px; }
  .text-template-layout { grid-template-columns: minmax(0, 1fr) 340px; }
}

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .sidebar { padding-left: 12px; padding-right: 12px; }
  .brand img { width: 145px; }
  .main-content { padding: 28px 20px 60px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .text-template-layout { grid-template-columns: 1fr; }
  .text-template-side { position: static; }
  .editor-layout, .detail-grid { grid-template-columns: 1fr; }
  .profile-layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3 { grid-column: span 2; }
  .calculation-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .line-options-row, .line-pricing-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 16px; }
  .brand { padding-bottom: 15px; }
  .nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-divider { display: none; }
  .sidebar-footer { margin-top: 15px; }
  .main-content { padding: 24px 14px 55px; }
  .page-header { align-items: stretch; flex-direction: column; gap: 16px; }
  .page-header .button { width: 100%; }
  .metric-grid, .form-grid, .calculation-grid, .definition-grid, .reference-grid, .library-grid, .reference-documents { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: span 1; }
  .line-card { grid-template-columns: 30px minmax(0, 1fr); }
  .line-fields { grid-template-columns: 1fr; }
  .profile-main-row, .line-options-row, .line-pricing-row { grid-template-columns: 1fr; }
  .ral-toggle, .second-side-toggle, .manual-price-toggle { padding-top: 0; }
  .delete-line { grid-column: 2; grid-row: auto; justify-self: end; display: flex; align-items: center; gap: 7px; }
  .delete-line input { display: inline-block; margin: 0; }
  .line-card-header { align-items: flex-start; }
  .line-card-title small { display: none; }
  .line-delete-button { padding-right: 0; }
  .line-field-group-title { align-items: flex-start; flex-direction: column; gap: 3px; }
  .line-material-row, .line-coating-row { max-width: none; grid-template-columns: 1fr; }
  .logistics-mode ul, .logistics-fields, .competitor-line { grid-template-columns: 1fr; }
  .future-position-actions { align-items: stretch; flex-direction: column; }
  .future-position-actions span { margin-left: 0; }
  .editor-actions { position: static; align-items: stretch; flex-direction: column; }
  .live-total { display: none; }
}

/* Version 4.4: отдельный контур перепродажной номенклатуры. */
.resale-positions-panel { border-color: #aebbc2; }
.resale-profile-main-row {
  grid-template-columns: minmax(190px, .95fr) minmax(220px, 1.2fr) minmax(130px, .65fr) minmax(150px, .75fr);
}
.resale-pricing-row {
  grid-template-columns: minmax(155px, .8fr) minmax(150px, .8fr) minmax(220px, 1.1fr);
}
@media (max-width: 980px) {
  .resale-profile-main-row, .resale-pricing-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .resale-profile-main-row, .resale-pricing-row { grid-template-columns: 1fr; }
}

/* Version 4.4.2: common nomenclature and resubmission catalog */
.resale-catalog-panel { border-color: #aebbc2; }
.catalog-thicknesses { min-width: 180px; line-height: 1.5; }
.resubmission-catalog-grid,
.resubmission-metrics-grid,
.resubmission-price-grid {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.resubmission-metrics-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.resubmission-price-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
}
.resubmission-price-grid .line-summary { min-height: 42px; }
.resubmission-source-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(260px, .9fr) minmax(320px, 1.4fr);
  align-items: end;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.resubmission-source-hint {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--muted);
  background: #eef3f5;
  font-size: 12px;
  line-height: 1.45;
}
.resubmission-comparison {
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px solid #b8d7e3;
  border-radius: 11px;
  background: #f4fafc;
}
.resubmission-comparison > strong { display: block; color: var(--brand-dark); }
.resubmission-comparison > small { display: block; margin-top: 5px; color: var(--muted); }
.resubmission-comparison p { margin: 9px 0 0; }
.comparison-warning { color: #84620e; }
.comparison-grid {
  margin-top: 11px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.comparison-grid > div { padding: 10px; border: 1px solid #d4e2e8; border-radius: 8px; background: #fff; }
.comparison-grid span, .comparison-grid strong { display: block; }
.comparison-grid span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.comparison-grid strong { margin-top: 4px; font-size: 12px; }
.resubmission-source { margin-top: 9px !important; }
.resubmission-catalog-grid .span-2,
.resubmission-metrics-grid .span-2 { grid-column: span 2; }
.span-full { grid-column: 1 / -1; }
.resubmission-legacy-catalog {
  grid-column: 1 / -1;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}
.resubmission-legacy-catalog summary {
  cursor: pointer;
  color: var(--muted);
  margin-bottom: 10px;
}
.delete-control { grid-column: 1 / -1; }
.version-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; padding: 16px 22px; }
.version-chip { padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #fff; font-size: 12px; font-weight: 700; }
.version-chip.active { color: #fff; border-color: var(--brand); background: var(--brand); }
.form-span-full { grid-column: 1 / -1; }
.changed-row td { background: #fff8e9; }
.catalog-preview-image { display: block; max-width: 100%; max-height: 320px; object-fit: contain; }
.compact-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1050px) {
  .resubmission-catalog-grid,
  .resubmission-metrics-grid,
  .resubmission-price-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .comparison-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .resubmission-catalog-grid,
  .resubmission-metrics-grid,
  .resubmission-price-grid { grid-template-columns: 1fr; }
  .resubmission-source-grid { grid-template-columns: 1fr; }
  .resubmission-catalog-grid .span-2,
  .resubmission-metrics-grid .span-2 { grid-column: span 1; }
  .meterage-heading, .meterage-total { align-items: stretch; flex-direction: column; }
  .meterage-row, .fastener-dimensions, .fastener-mode ul { grid-template-columns: 1fr; }
  .panel-header-actions,
  .specification-tools-heading,
  .specification-preview-heading,
  .specification-import-actions { align-items: stretch; flex-direction: column; }
  .panel-header-actions .button,
  .specification-tools-heading .button,
  .specification-preview-heading .button,
  .specification-import-actions .button { width: 100%; text-align: center; }
  .specification-preview-row { grid-template-columns: 28px minmax(0, 1fr); }
  .specification-preview-row > label:not(:first-child),
  .specification-preview-warning,
  .specification-preview-row > button { grid-column: 2; }
  .specification-tools { margin: 0 12px 12px; padding: 14px; }
}

.bitrix-sync-body { padding: 20px 22px; }
.bitrix-sync-actions { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 10px; }
.bitrix-sync-note { margin: 14px 0 0; }
.compact-definition-grid { padding: 0; }

/* Version 5.1 — commercial analytics */
.analytics-header { margin-bottom: 18px; }
.analytics-scope-note { margin-bottom: 14px; padding: 11px 15px; border: 1px solid #c8dfd2; border-radius: 10px; color: #176941; background: #edf8f2; font-size: 12px; font-weight: 700; }
.analytics-filter-panel { overflow: visible; position: relative; z-index: 20; }
.analytics-filter-form { padding: 18px 20px; }
.analytics-filter-grid { display: grid; grid-template-columns: repeat(4, minmax(170px, 1fr)); gap: 14px; align-items: end; }
.analytics-date-range { display: grid; grid-template-columns: repeat(2, minmax(125px, 1fr)); gap: 8px; }
.analytics-filter-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.search-select { position: relative; min-width: 0; }
.search-select > label { margin-bottom: 7px; }
.search-select-menu { position: absolute; z-index: 100; top: calc(100% + 5px); left: 0; right: 0; max-height: 290px; padding: 6px; overflow-y: auto; border: 1px solid #cfd9df; border-radius: 10px; background: #fff; box-shadow: 0 16px 40px rgba(32, 40, 45, .15); }
.search-select-menu button { width: 100%; padding: 9px 10px; border: 0; border-radius: 7px; color: #425460; background: transparent; text-align: left; cursor: pointer; }
.search-select-menu button:hover { color: var(--brand-dark); background: #f1f5f7; }
.search-select-heading { padding: 8px 10px 5px; color: #87949c; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.analytics-tabs { margin: 0 0 20px; padding: 6px; display: flex; gap: 4px; overflow-x: auto; border: 1px solid #dbe2e6; border-radius: 12px; background: #f4f7f8; }
.analytics-tabs a { flex: 0 0 auto; padding: 9px 13px; border-radius: 8px; color: #687780; font-size: 12px; font-weight: 800; white-space: nowrap; }
.analytics-tabs a:hover { color: var(--brand-dark); background: #fff; }
.analytics-tabs a.active { color: #fff; background: var(--brand-dark); }
.analytics-metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.analytics-metric-grid .metric-card { min-height: 148px; }
.metric-delta { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: auto; padding-top: 13px; font-weight: 700; }
.metric-delta span { color: inherit; font-size: inherit; font-weight: inherit; letter-spacing: 0; text-transform: none; }
.metric-delta.positive { color: #198754; }
.metric-delta.negative { color: #b83c4a; }
.metric-delta.neutral { color: var(--muted); }
.metric-card.accent .metric-delta { color: rgba(255,255,255,.88); }
.analytics-chart-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.analytics-chart-card { min-width: 0; }
.chart-frame { height: 290px; padding: 8px 14px 16px; }
.chart-frame canvas { display: block; width: 100%; height: 270px; }
.analytics-definition-list { padding: 18px 22px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 0; }
.analytics-definition-list div { padding: 12px 13px; border-radius: 9px; background: #f6f8f9; }
.analytics-definition-list dt { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.analytics-definition-list dd { margin: 5px 0 0; font-size: 18px; font-weight: 800; }
.analytics-signal-list { display: flex; flex-direction: column; }
.analytics-signal-list a { padding: 13px 20px; border-top: 1px solid #e8edf0; }
.analytics-signal-list a:first-child { border-top: 0; }
.analytics-signal-list strong, .analytics-signal-list span, .analytics-signal-list small { display: block; }
.analytics-signal-list span { margin-top: 3px; color: #425460; }
.analytics-signal-list small { margin-top: 4px; color: var(--muted); }
.analytics-footnote { margin: 0; padding: 0 22px 18px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.panel-footnote { padding-top: 14px; border-top: 1px solid #e8edf0; }
.analytics-wide-table { min-width: 1120px; }
.analytics-wide-table td { vertical-align: top; }
.analytics-trade-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.empty-state.compact { padding: 22px 20px; }
@media (max-width: 1280px) {
  .analytics-filter-grid { grid-template-columns: repeat(3, minmax(170px, 1fr)); }
  .analytics-metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .analytics-chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .analytics-filter-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .analytics-metric-grid, .analytics-trade-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-definition-list { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .analytics-filter-grid, .analytics-metric-grid, .analytics-trade-grid { grid-template-columns: 1fr; }
  .analytics-date-range { grid-template-columns: 1fr 1fr; }
  .analytics-filter-actions { align-items: stretch; flex-direction: column; }
  .analytics-filter-actions .button { width: 100%; }
}

.fastener-commercial-table-wrap {
  margin-top: 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.fastener-commercial-editor {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
}
.fastener-commercial-editor th,
.fastener-commercial-editor td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.fastener-commercial-editor th {
  font-size: 11px;
  color: var(--muted);
  text-align: left;
  background: #f7f9fa;
}
.fastener-commercial-editor tr:last-child td { border-bottom: 0; }
.fastener-commercial-editor .field-control { min-width: 110px; }
.fastener-commercial-editor td.num { white-space: nowrap; text-align: right; }

/* Version 5.1.1: editable fastener quantity with explicit automatic reset. */
.fastener-quantity-cell {
    min-width: 150px;
}
.fastener-quantity-cell .field-control {
    min-width: 95px;
}
.fastener-auto-reset {
    display: inline-block;
    margin-top: 6px;
    font-size: 12px;
}

/* Version 5.2 — Bitrix approval data and commercial profile calculator. */

.calculator-mode-panel { padding: 14px 18px; }
.calculator-mode-switch { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.calculator-mode-panel .muted { margin: 8px 0 0; }
[data-calculator-extended][hidden] { display: none !important; }
.registry-actions { justify-content: flex-end; }
.approval-panel { border-color: #cfe0e8; }
.approval-panel .panel-header { background: #f7fbfd; }

.calculator-panel { overflow: visible; }
.calculator-control-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
  padding: 18px 22px;
}
.calculator-control-grid label { min-width: 0; }
.calculator-control-grid label > .field-control { margin-top: 6px; }
.calculator-table-wrap {
  margin: 0 22px 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.calculator-offer-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
}
.calculator-offer-table th,
.calculator-offer-table td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.calculator-offer-table th {
  color: #fff;
  background: var(--brand);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}
.calculator-offer-table td { text-align: center; white-space: nowrap; }
.calculator-offer-table td:first-child { text-align: left; font-weight: 700; }
.calculator-offer-table .delivery-row td { background: #f5f8f9; }
.calculator-offer-table tfoot td {
  background: #eef6f9;
  border-bottom: 0;
  font-size: 14px;
  font-weight: 800;
}
.calculator-offer-table tfoot td:first-child { text-align: right; }
.calculator-offer-table .money-cell { white-space: nowrap; text-align: right; }
.calculator-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 22px 20px;
}
.calculator-badge {
  display: inline-flex;
  align-items: center;
  min-height: 31px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}
.calculator-badge.neutral { color: #5d6e78; background: #f0f3f5; border-color: #dce3e7; }
.calculator-badge.success { color: #176941; background: #e9f7ef; border-color: #bfe2cf; }
.calculator-badge.warning { color: #80610f; background: #fff8df; border-color: #ead89d; }
.calculator-badge.danger { color: #a12e3d; background: #fff0f2; border-color: #edc1c7; }
.calculator-summary-panel { overflow: visible; }
.calculator-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 22px;
}
.calculator-kpis article {
  display: flex;
  min-height: 112px;
  flex-direction: column;
  padding: 14px;
  border: 1px solid #dbe4e8;
  border-radius: 10px;
  background: #f8fafb;
}
.calculator-kpis span { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.calculator-kpis strong { margin-top: 8px; font-size: 20px; line-height: 1.15; }
.calculator-kpis small { margin-top: auto; padding-top: 8px; color: var(--muted); }
.calculator-optimized {
  margin: 0 22px 18px;
  padding: 16px;
  border: 1px solid #bcd9e5;
  border-radius: 11px;
  background: #f3fafc;
}
.calculator-optimized h3 { margin: 0; }
.calculator-optimized-grid {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) minmax(140px, 1fr) minmax(140px, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}
.calculator-transfer-form { display: flex; justify-content: flex-end; padding: 0 22px 22px; }
.calculator-specification {
  margin: 0 22px 18px;
  padding: 14px;
  border: 1px solid #d7e4e9;
  border-radius: 10px;
  background: #f8fbfc;
}
.calculator-specification-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.calculator-specification-status { margin-top: 9px; color: var(--muted); font-size: 12px; }
.calculator-specification-status.is-error { color: #b23343; }
.calculator-specification-status.is-success { color: #197347; }
.calculator-specification-result {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}
.calculator-constraint-note { margin: 0 22px 18px; padding: 10px 12px; border-left: 3px solid #c4d8e1; color: var(--muted); background: #f8fafb; font-size: 11px; }

@media (max-width: 1280px) {
  .calculator-control-grid { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
  .calculator-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 850px) {
  .registry-actions { align-items: stretch; flex-direction: column; width: 100%; }
  .registry-actions .button { width: 100%; text-align: center; }
  .calculator-control-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .calculator-optimized-grid { grid-template-columns: 1fr; }
  .calculator-transfer-form { justify-content: stretch; }
  .calculator-transfer-form .button { width: 100%; }
}
@media (max-width: 560px) {
  .calculator-control-grid, .calculator-kpis, .calculator-specification-result { grid-template-columns: 1fr; }
  .calculator-specification-actions .button { width: 100%; text-align: center; }
}

/* Version 5.4 compact editor additions */
.manager-bonus-card { margin: 12px 0; padding: 12px 14px; border: 1px solid var(--line, #d9dee7); border-radius: 12px; background: #f7f9fc; }
.manager-bonus-card > div { display:flex; justify-content:space-between; gap:16px; align-items:center; }
.manager-bonus-card strong { font-size:1.25rem; }
.compact-checkbox { min-height:auto; padding:8px 10px; }
.compact-form-grid { gap: 10px 12px; }
.roof-lines-table input, .roof-lines-table select { min-width: 90px; }
.warning-text { display:block; margin-top:4px; }
.editor-main .form-grid { gap: 8px 12px; }
.editor-main .panel-header { margin-bottom: 8px; }


/* Version 5.4 RC4 shadow feedback */
.live-total { min-width: 330px; }
.live-total-breakdown { display:flex !important; flex-wrap:wrap; justify-content:flex-end; gap:2px 12px; }
.live-total-breakdown span { display:inline !important; }
.live-total-breakdown b, .live-bonus-breakdown b { color: var(--ink, #26343b); }
.live-bonus-label { margin-top:6px; font-weight:800; color:#40515b !important; }
.live-bonus-value { margin-top:0 !important; font-size:17px !important; color:#176941; }
.live-bonus-breakdown { margin-top:0 !important; }
.roofing-entry-summary { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; padding:0 18px 18px; }
.roofing-entry-summary > div { padding:11px 12px; border:1px solid #dbe4e8; border-radius:10px; background:#f8fafb; }
.roofing-entry-summary span, .roofing-entry-summary strong { display:block; }
.roofing-entry-summary span { color:var(--muted); font-size:11px; }
.roofing-entry-summary strong { margin-top:3px; }
.roofing-entry-empty { grid-column:1/-1; }
.roofing-entry-empty span { margin-top:4px; }
.roof-logistics-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; padding:0 18px 14px; }
.roof-logistics-card { min-width:0; padding:14px; border:1px solid #d9e2e7; border-radius:12px; background:#f8fafb; }
.roof-logistics-kind { display:block; margin-bottom:10px; font-weight:800; font-size:15px; }
.roof-logistics-card dl { margin:0; }
.roof-logistics-card dl > div { display:flex; justify-content:space-between; gap:12px; padding:5px 0; border-bottom:1px solid #e5eaed; }
.roof-logistics-card dt { color:var(--muted); }
.roof-logistics-card dd { margin:0; text-align:right; white-space:nowrap; }
.roof-logistics-card p { margin:10px 0 0; color:var(--muted); font-size:12px; line-height:1.45; }
.roof-logistics-total { display:flex; align-items:center; justify-content:space-between; gap:16px; margin:0 18px 18px; padding:12px 14px; border-top:2px solid #178fbd; background:#eef8fb; }
.roof-logistics-total strong { font-size:22px; }
@media (max-width: 1100px) { .roof-logistics-grid { grid-template-columns:1fr; } .roofing-entry-summary { grid-template-columns:repeat(2,minmax(0,1fr)); } }

/* Version 5.4 RC5 — Фиксация цены и потребности */
.price-need-metrics { margin-bottom: 20px; }
.price-need-table td { vertical-align: middle; }
.price-need-table td small { display: block; margin-top: 4px; color: var(--muted, #6b7780); }
.planning-inline-form { display: grid; grid-template-columns: auto minmax(130px, 170px) auto; gap: 8px; align-items: center; min-width: 290px; }
.planning-inline-toggle { display: inline-flex; gap: 7px; align-items: center; white-space: nowrap; }
.planning-month { min-width: 140px; padding-block: 7px; }
.planning-save-state { min-width: 64px; font-size: 12px; color: #2b7a4b; }
.planning-save-state.is-error { color: #b42318; }
.price-need-editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; align-items: start; }
.price-need-editor-main { min-width: 0; display: grid; gap: 18px; }
.price-need-summary { position: sticky; top: 18px; display: grid; gap: 14px; padding: 20px; }
.price-need-summary-main { display: grid; gap: 5px; padding-bottom: 14px; border-bottom: 1px solid #dfe6ea; }
.price-need-summary-main small, .summary-row span { color: #66737d; }
.price-need-summary-main strong { font-size: 25px; line-height: 1.15; }
.summary-row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.summary-row strong { text-align: right; }
.button-full { width: 100%; justify-content: center; }
.metal-plan-panel [data-metal-plan-month][hidden] { display: none !important; }
@media (max-width: 1100px) {
  .price-need-editor-layout { grid-template-columns: 1fr; }
  .price-need-summary { position: static; order: -1; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .price-need-summary .eyebrow, .price-need-summary-main, .price-need-summary .button-full { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .planning-inline-form { grid-template-columns: 1fr; min-width: 180px; }
  .price-need-summary { grid-template-columns: 1fr; }
}


/* Version 5.4 RC5 FCP3 — compact fasteners + manager bonus in price/need request */
.price-need-fastener-wrap { overflow-x: hidden; }
.price-need-fastener-table { width: 100%; min-width: 0; table-layout: fixed; }
.price-need-fastener-table th,
.price-need-fastener-table td { padding: 9px 7px; min-width: 0; overflow-wrap: anywhere; }
.price-need-fastener-table th { line-height: 1.2; white-space: normal; }
.price-need-fastener-table .field-control { width: 100%; min-width: 0; padding-left: 9px; padding-right: 9px; }
.price-need-fastener-table .fastener-quantity-cell { min-width: 0; }
.price-need-fastener-table .fastener-quantity-cell .field-control { min-width: 0; }
.price-need-fastener-table td.num { white-space: normal; text-align: right; }
.price-need-fastener-table .pn-fastener-col-position { width: 17%; }
.price-need-fastener-table .pn-fastener-col-quantity { width: 13%; }
.price-need-fastener-table .pn-fastener-col-packsize { width: 10%; }
.price-need-fastener-table .pn-fastener-col-packages { width: 7%; }
.price-need-fastener-table .pn-fastener-col-priceunit { width: 11%; }
.price-need-fastener-table .pn-fastener-col-price { width: 10%; }
.price-need-fastener-table .pn-fastener-col-unitprice { width: 10%; }
.price-need-fastener-table .pn-fastener-col-packageprice { width: 10%; }
.price-need-fastener-table .pn-fastener-col-total { width: 12%; }
.price-need-bonus-summary { margin-top: 2px; padding: 12px 0; border-top: 1px solid #dfe6ea; border-bottom: 1px solid #dfe6ea; }
.price-need-bonus-total strong { color: #176941; font-size: 18px; }
.price-need-bonus-summary small { display: block; margin-top: 5px; color: var(--muted); line-height: 1.35; }
.price-need-bonus-summary b { color: var(--ink, #26343b); }
@media (max-width: 1280px) {
  .price-need-fastener-wrap { overflow-x: auto; }
  .price-need-fastener-table { min-width: 900px; }
}

/* Version 5.5 — utility bar, embedded help and contextual tips */
:root { --utility-bar-height: 42px; }
.utility-bar {
  position: fixed; inset: 0 0 auto 0; z-index: 1200; height: var(--utility-bar-height);
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 0 18px; background: #173342; color: #fff; border-bottom: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 1px 6px rgba(16, 40, 52, .16);
}
.utility-current { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 700; letter-spacing: .02em; opacity: .86; }
.utility-actions { display: flex; align-items: center; gap: 4px; }
.utility-link { color: #fff; text-decoration: none; font-size: 12px; font-weight: 700; border-radius: 7px; padding: 7px 10px; border: 0; background: transparent; cursor: pointer; }
.utility-link:hover, .utility-link:focus-visible { background: rgba(255,255,255,.12); color: #fff; }
.utility-button { font: inherit; }
.utility-logout { margin: 0; }
.has-utility-bar { padding-top: var(--utility-bar-height); }
.has-utility-bar .sidebar { top: var(--utility-bar-height); height: calc(100vh - var(--utility-bar-height)); }
.help-drawer-backdrop { position: fixed; inset: var(--utility-bar-height) 0 0 0; z-index: 1290; background: rgba(15, 29, 36, .30); backdrop-filter: blur(1px); }
.help-drawer { position: fixed; z-index: 1300; top: var(--utility-bar-height); right: 0; bottom: 0; width: min(590px, 94vw); background: #fff; box-shadow: -18px 0 42px rgba(24,42,52,.18); transform: translateX(102%); transition: transform .18s ease; overflow: hidden; }
.help-drawer.is-open { transform: translateX(0); }
.help-drawer-inner { height: 100%; display: grid; grid-template-rows: auto 1fr auto; }
.help-drawer-header { display:flex; justify-content:space-between; align-items:flex-start; gap:14px; padding:20px 22px 14px; border-bottom:1px solid #dfe7ea; }
.help-drawer-header h2 { margin: 4px 0 0; font-size: 22px; }
.help-drawer-close { border:0; background:#eef3f5; color:#283a43; width:34px; height:34px; border-radius:9px; font-size:24px; line-height:1; cursor:pointer; }
.help-drawer-body { overflow:auto; padding:18px 22px 30px; }
.help-drawer-footer { display:flex; justify-content:space-between; gap:14px; padding:12px 22px; border-top:1px solid #dfe7ea; background:#f8fafb; font-size:12px; }
.prose-help { color:#25343d; line-height:1.58; }
.prose-help h2 { margin:24px 0 8px; font-size:19px; color:#173342; }
.prose-help h3 { margin:18px 0 6px; font-size:15px; color:#2f596d; }
.prose-help p { margin: 0 0 12px; }
.prose-help ul { margin: 7px 0 14px 20px; padding:0; }
.prose-help li { margin:5px 0; }
.prose-help code { padding:2px 5px; background:#eef3f5; border-radius:4px; font-size:.92em; }
.help-article { max-width: 1050px; padding: 26px 30px; }
.help-topic-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; }
.help-topic-card { display:block; text-decoration:none; color:inherit; padding:20px; min-height:160px; transition:transform .12s ease, box-shadow .12s ease; }
.help-topic-card:hover { transform:translateY(-2px); box-shadow:0 10px 26px rgba(25,54,68,.10); }
.help-topic-card h2 { margin:0 0 10px; font-size:18px; }
.help-topic-card p { color:var(--muted); line-height:1.5; }
.help-topic-card span { font-weight:700; color:#137dab; }
.help-tip-wrap { display:inline-flex; align-items:center; margin-left:5px; position:relative; vertical-align:middle; }
.help-tip-icon { width:18px; height:18px; border:1px solid #9fb3bd; border-radius:50%; display:inline-grid; place-items:center; padding:0; background:#fff; color:#46616e; font-size:11px; font-weight:900; line-height:1; cursor:help; }
.help-tip-bubble { display:none; position:absolute; z-index:1500; right:0; top:calc(100% + 8px); width:270px; padding:10px 12px; border-radius:9px; background:#1c3541; color:#fff; box-shadow:0 10px 28px rgba(16,32,40,.24); font-size:12px; line-height:1.4; font-weight:500; text-align:left; white-space:normal; }
.help-tip-wrap:hover .help-tip-bubble, .help-tip-wrap:focus-within .help-tip-bubble { display:block; }
@media (max-width: 980px) { .help-topic-grid { grid-template-columns:1fr 1fr; } }
@media (max-width: 700px) { .utility-current { display:none; } .utility-bar { justify-content:flex-end; padding-inline:8px; } .help-topic-grid { grid-template-columns:1fr; } }

/* Version 5.5 — price center */
.price-center-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:18px; align-items:start; }
.price-center-card { padding-bottom:18px; }
.price-center-state { display:grid; gap:4px; margin:0 18px 14px; padding:13px 14px; border:1px solid #dce5e9; border-radius:10px; background:#f8fafb; }
.price-center-state strong { font-size:16px; }
.price-center-state span { color:var(--muted); font-size:12px; }
.price-center-actions { display:flex; flex-wrap:wrap; gap:8px; margin:0 18px 16px; }
.price-center-card details { margin:0 18px; }
.price-center-card summary { cursor:pointer; font-weight:800; color:#38515d; }
.compact-history, .price-revision-list { display:grid; gap:8px; margin-top:10px; }
.compact-history > div, .price-revision-row { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:9px 10px; border:1px solid #e1e8eb; border-radius:8px; background:#fff; }
.compact-history span, .price-revision-row span, .price-revision-row small { display:block; margin-top:2px; color:var(--muted); font-size:11px; }
.price-revision-row form { margin:0; }
.error-text { color:#b42318 !important; }
.upload-panel { max-width:760px; }
.stacked-form { display:grid; gap:16px; padding:0 18px 18px; }
.stacked-form label { display:grid; gap:7px; }
@media (max-width: 1200px) { .price-center-grid { grid-template-columns:1fr; } }

/* Version 5.5 RC1.5 — manual QA fixes: stable navigation + readable fasteners. */
.has-utility-bar .sidebar {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  background: linear-gradient(165deg, #343c42 0%, var(--sidebar) 55%, #181e22 100%);
}
.has-utility-bar .sidebar::-webkit-scrollbar { width: 8px; }
.has-utility-bar .sidebar::-webkit-scrollbar-track { background: rgba(255,255,255,.04); }
.has-utility-bar .sidebar::-webkit-scrollbar-thumb { background: rgba(191,207,216,.28); border-radius: 10px; }
.has-utility-bar .sidebar .nav { flex: 0 0 auto; }
.has-utility-bar .sidebar-footer { flex: 0 0 auto; background: transparent; }
.help-drawer-open { overflow: hidden; }

/* Do not squeeze nine commercial fastener columns into a narrow editor column. */
.price-need-fastener-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-gutter: stable;
}
.price-need-fastener-table {
  width: 100%;
  min-width: 1080px;
  table-layout: fixed;
}
.price-need-fastener-table th,
.price-need-fastener-table td {
  padding: 10px 8px;
  overflow-wrap: normal;
  word-break: normal;
  vertical-align: middle;
}
.price-need-fastener-table th {
  font-size: 10px;
  line-height: 1.25;
  white-space: normal;
}
.price-need-fastener-table .field-control {
  width: 100%;
  min-width: 0;
  padding-left: 8px;
  padding-right: 8px;
}
.price-need-fastener-table .pn-fastener-col-position { width: 190px; }
.price-need-fastener-table .pn-fastener-col-quantity { width: 132px; }
.price-need-fastener-table .pn-fastener-col-packsize { width: 95px; }
.price-need-fastener-table .pn-fastener-col-packages { width: 78px; }
.price-need-fastener-table .pn-fastener-col-priceunit { width: 116px; }
.price-need-fastener-table .pn-fastener-col-price { width: 110px; }
.price-need-fastener-table .pn-fastener-col-unitprice { width: 112px; }
.price-need-fastener-table .pn-fastener-col-packageprice { width: 118px; }
.price-need-fastener-table .pn-fastener-col-total { width: 125px; }
.price-need-fastener-table td.num { white-space: nowrap; }
.price-need-fastener-table .fastener-auto-reset { display: inline-block; margin-top: 5px; }

@media (max-width: 760px) {
  .has-utility-bar .sidebar { overflow: visible; }
}

/* Version 5.5.1 RC2 — AutoKLIN */
.autoklin-shell { overflow:visible; }
.autoklin-toolbar-head { align-items:flex-start; }
.autoklin-engine-badge { padding:7px 10px; border:1px solid #b9dbe8; border-radius:999px; background:#eef8fb; color:#176984; font-size:12px; font-weight:800; white-space:nowrap; }
.autoklin-control-grid { display:grid; grid-template-columns:minmax(220px,2fr) minmax(150px,1fr) minmax(240px,1.2fr); gap:14px; padding:0 18px 16px; align-items:end; }
.autoklin-control-grid label { display:grid; gap:6px; font-size:13px; font-weight:700; }
.autoklin-source-note { display:grid; gap:2px; min-height:66px; padding:10px 12px; border:1px solid #dde5e9; border-radius:10px; background:#f8fafb; }
.autoklin-source-note span,.autoklin-source-note small { color:var(--muted); font-size:11px; }
.autoklin-section-tabs { display:flex; flex-wrap:wrap; gap:6px; padding:0 18px 12px; }
.autoklin-section-button { min-width:42px; padding:7px 10px; }
.autoklin-section-button.active { border-color:#178fbd; background:#eef8fb; color:#0f6481; font-weight:800; }
.autoklin-input-card { margin:0 18px 18px; padding:14px; border:1px solid #d9e2e7; border-radius:12px; background:#fbfcfd; }
.autoklin-input-head { display:flex; justify-content:space-between; gap:16px; margin-bottom:12px; }
.autoklin-input-head > div { display:grid; gap:3px; }
.autoklin-input-head span { color:var(--muted); font-size:12px; }
.autoklin-result-kpis { display:flex; flex-wrap:wrap; gap:10px; }
.autoklin-result-kpis span { min-width:120px; padding:8px 10px; border:1px solid #d9e2e7; border-radius:10px; background:#f8fafb; display:grid; gap:2px; }
.autoklin-result-kpis small { color:var(--muted); }
.autoklin-result-kpis strong { font-size:18px; }
.autoklin-details { margin:14px 18px; }
.autoklin-details summary { cursor:pointer; font-weight:800; }
.autoklin-section-result-card { margin-top:10px; padding:12px; border:1px solid #e1e7ea; border-radius:10px; background:#fafcfd; }
.autoklin-section-result-card h3 { margin:0 0 7px; font-size:14px; }
.autoklin-section-result-card ul { margin:0; padding-left:18px; color:var(--muted); }
.autoklin-commercial-note { margin:14px 18px; }
@media (max-width: 900px) { .autoklin-control-grid { grid-template-columns:1fr; } .autoklin-input-head { display:grid; } }
.roof-slope-entry-card { display:flex; align-items:center; justify-content:space-between; gap:16px; margin:0 18px 14px; padding:13px 14px; border:1px solid #d9e2e7; border-radius:12px; background:#f8fafb; }
.roof-slope-entry-card.active { border-color:#9dcedf; background:#eef8fb; }
.roof-slope-entry-card > div { display:grid; gap:3px; min-width:0; }
.roof-slope-entry-card strong { font-size:15px; }
.roof-slope-entry-card small { color:var(--muted); line-height:1.4; }
.roof-slope-entry-kicker { color:#176984; font-size:11px; font-weight:800; text-transform:uppercase; letter-spacing:.04em; }
@media (max-width: 760px) { .roof-slope-entry-card { align-items:stretch; flex-direction:column; } }

/* Version 5.5.4 RC4: staged alternative solution editor. */
.alternative-positions-panel { border-color: #9fbac5; }
.alternative-editor { padding: 18px 22px 20px; display: grid; gap: 14px; background: #fbfdfe; }
.alternative-editor label { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-weight: 700; }
.alternative-source-row,
.alternative-profile-row,
.alternative-pricing-row,
.alternative-paint-row { display: grid; gap: 12px; align-items: end; }
.alternative-source-row { grid-template-columns: minmax(260px, 1.2fr) minmax(260px, 1fr); }
.alternative-profile-row { grid-template-columns: minmax(220px, 1.5fr) minmax(140px, .65fr) minmax(150px, .7fr); }
.alternative-pricing-row { grid-template-columns: minmax(150px, .5fr) minmax(220px, .8fr) 1fr; }
.alternative-paint-row { grid-template-columns: repeat(3, minmax(170px, 1fr)); }
.alternative-paint-row .ral-toggle { flex-direction: row; align-items: center; align-self: center; }
.alternative-editor-errors { margin: 0; }
.alternative-existing-list { padding: 0 22px 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.alternative-existing-chip { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 12px; color: var(--muted); }
.alternative-panel-actions { padding: 0 22px 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
@media (max-width: 900px) {
  .alternative-source-row,
  .alternative-profile-row,
  .alternative-pricing-row,
  .alternative-paint-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .alternative-source-row,
  .alternative-profile-row,
  .alternative-pricing-row,
  .alternative-paint-row { grid-template-columns: 1fr; }
}

/* Version 5.5.4 RC6: independent logistics for an alternative solution. */
.alternative-logistics-block { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.alternative-logistics-heading { display: grid; gap: 3px; }
.alternative-logistics-heading small { color: var(--muted); font-weight: 400; }
.alternative-logistics-row { display: grid; grid-template-columns: minmax(230px, 1.2fr) minmax(150px, .65fr) minmax(190px, .8fr) minmax(170px, .7fr); gap: 12px; align-items: end; }
@media (max-width: 900px) { .alternative-logistics-row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .alternative-logistics-row { grid-template-columns: 1fr; } }

/* STALLIN TKP 6.0 — AI infrastructure, compact summary and Assist drawer */
.editor-actions .live-total { min-width: 0; display:grid; grid-template-columns:minmax(250px,1.35fr) minmax(150px,.65fr); gap:8px 20px; align-items:center; text-align:left; }
.editor-actions .live-total-main, .editor-actions .live-total-bonus { min-width:0; }
.editor-actions .live-total-main { border-right:1px solid #dfe6ea; padding-right:20px; }
.editor-actions .live-total-bonus { padding-left:0; }
.editor-actions .live-total span, .editor-actions .live-total strong { display:block; }
.editor-actions .live-total-breakdown { justify-content:flex-start; }
.editor-actions .live-bonus-label { margin-top:0; }
@media (max-width:1180px){ .editor-actions{gap:10px;padding:10px 12px}.editor-actions .live-total{grid-template-columns:minmax(210px,1.2fr) minmax(130px,.8fr);gap:6px 12px}.editor-actions .live-total-main{padding-right:12px}.live-total-breakdown{font-size:10px}.editor-actions .button{padding-left:12px;padding-right:12px} }
@media (max-width:760px){ .editor-actions{flex-wrap:wrap}.editor-actions .live-total{order:-1;width:100%;grid-template-columns:1fr 1fr}.editor-actions>a{margin-right:auto} }
.ai-assist-fab { position:fixed; right:22px; bottom:92px; z-index:70; border:1px solid rgba(30,70,90,.24); border-radius:999px; padding:11px 16px; background:rgba(255,255,255,.90); box-shadow:0 12px 32px rgba(20,52,70,.20); backdrop-filter:blur(12px); color:var(--brand-dark); font-weight:800; cursor:pointer; }
.ai-assist-fab:hover{background:#fff;transform:translateY(-1px)}
.ai-assist-drawer{position:fixed;top:48px;right:0;bottom:0;width:min(500px,94vw);z-index:80;transform:translateX(105%);transition:transform .2s ease;background:#fff;border-left:1px solid var(--line);box-shadow:-18px 0 48px rgba(22,46,60,.18);display:flex;flex-direction:column}.ai-assist-drawer.is-open{transform:translateX(0)}
.ai-assist-header{padding:18px 20px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between}.ai-assist-header h2{margin:2px 0 0}.ai-assist-close{border:0;background:transparent;font-size:28px;cursor:pointer}.ai-assist-messages{flex:1;overflow:auto;padding:18px;display:flex;flex-direction:column;gap:12px;background:#f6f8fa}.ai-chat-message{max-width:88%;padding:11px 13px;border-radius:14px;white-space:pre-wrap;line-height:1.45}.ai-chat-message.user{align-self:flex-end;background:var(--brand-dark);color:#fff}.ai-chat-message.assistant{align-self:flex-start;background:#fff;border:1px solid var(--line)}.ai-chat-message.error{border-color:#d77878;color:#9c2e2e}.ai-assist-form{display:flex;gap:9px;padding:14px;border-top:1px solid var(--line)}.ai-assist-form textarea{min-height:48px;max-height:150px;resize:vertical}.ai-assist-safety{padding:8px 16px;font-size:11px;color:var(--muted);border-top:1px solid #edf1f3}.ai-provider-grid,.ai-prompt-grid{padding:18px;display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:12px}.ai-provider-card,.ai-prompt-card{border:1px solid var(--line);border-radius:12px;padding:15px;background:#fbfcfd;display:flex;flex-direction:column;gap:7px}.ai-prompt-card{text-decoration:none;color:inherit}.ai-provider-card span,.ai-provider-card small,.ai-prompt-card span{color:var(--muted)}.row-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.ai-settings-panel,.simple-settings-form{padding:18px}.ai-settings-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.panel-footer-actions{margin-top:16px;display:flex;justify-content:flex-end;gap:10px}.knowledge-grid{padding:18px;display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:10px}.knowledge-grid .panel-footer-actions{grid-column:1/-1}.ai-lab-layout{display:grid;grid-template-columns:minmax(320px,.8fr) minmax(0,1.2fr);gap:18px}.ai-lab-result{padding:18px;overflow:auto}.ai-lab-result pre{max-height:520px;overflow:auto;white-space:pre-wrap;background:#111b21;color:#dce7ec;padding:12px;border-radius:10px}.ai-test-answer{white-space:pre-wrap;line-height:1.5;padding:14px;border:1px solid var(--line);border-radius:10px;background:#fafcfd}@media(max-width:900px){.ai-settings-grid,.ai-lab-layout{grid-template-columns:1fr}.ai-assist-fab{right:12px;bottom:84px}}

/* STALLIN TKP 6.0 RC2 rev2 — enterprise AI/OCR control surfaces */
.ai-page-header { align-items:flex-end; gap:24px; }
.ai-status-strip { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; margin-bottom:16px; }
.ai-status-tile { min-height:104px; padding:16px 18px; border:1px solid var(--line); border-radius:14px; background:#fff; box-shadow:0 8px 24px rgba(26,53,68,.06); display:grid; align-content:center; gap:4px; }
.ai-status-tile span { color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.06em; font-weight:700; }
.ai-status-tile strong { font-size:17px; color:var(--ink); }
.ai-status-tile small { color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ai-status-tile.is-ok { border-color:#b8ddca; background:#f7fcf9; }
.ai-status-tile.is-ok strong { color:#24774d; }
.ai-status-tile.is-warn { border-color:#ead49d; background:#fffaf0; }
.ai-status-tile.is-off { background:#f7f8f9; }
.ai-status-tile.is-locked { border-color:#d8c9c9; background:#fff8f8; }
.ai-status-tile.is-locked strong { color:#944646; }
.ai-hard-boundary { margin-bottom:18px; }
.ai-control-form { display:grid; gap:14px; margin-bottom:18px; }
.ai-config-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; }
.ai-config-card { margin:0; overflow:hidden; }
.ai-config-card .panel-header { padding:18px 20px 14px; }
.ai-config-card .panel-header h2 { margin:2px 0 4px; }
.ai-config-body { padding:4px 20px 20px; display:grid; gap:14px; }
.ai-field { display:grid; gap:6px; min-width:0; font-weight:600; color:var(--ink); }
.ai-field > span { font-size:12px; }
.ai-field .field-hint { font-weight:400; }
.ai-inline-fields { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.ai-switch-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.control-switch { position:relative; display:flex; gap:11px; align-items:flex-start; min-height:62px; padding:11px 12px; border:1px solid var(--line); border-radius:12px; background:#fbfcfd; cursor:pointer; }
.control-switch > input[type="checkbox"] { appearance:none; -webkit-appearance:none; width:38px; min-width:38px; height:22px; margin:1px 0 0; border:1px solid #aab8c0; border-radius:999px; background:#dfe5e8; position:relative; transition:.15s ease; }
.control-switch > input[type="checkbox"]::after { content:""; position:absolute; width:16px; height:16px; border-radius:50%; background:white; top:2px; left:2px; box-shadow:0 1px 4px rgba(0,0,0,.22); transition:.15s ease; }
.control-switch > input[type="checkbox"]:checked { background:var(--brand-dark); border-color:var(--brand-dark); }
.control-switch > input[type="checkbox"]:checked::after { left:18px; }
.control-switch > span { display:grid; gap:3px; min-width:0; }
.control-switch strong { font-size:12px; }
.control-switch small { color:var(--muted); font-weight:400; line-height:1.35; }
.control-switch.compact { min-height:54px; }
.ai-inline-notice { border-radius:10px; padding:10px 12px; background:#f2f6f8; color:#536771; font-size:12px; line-height:1.4; }
.ai-inline-notice.success { background:#edf8f2; color:#276a48; }
.ai-inline-notice.warning { background:#fff6df; color:#806321; }
.ai-policy-list { display:grid; gap:9px; }
.ai-policy-list > div { display:grid; gap:2px; padding:10px 12px; border-left:3px solid #d9e4e9; background:#f8fafb; }
.ai-policy-list span { color:var(--muted); font-size:12px; line-height:1.4; }
.ai-save-bar { position:sticky; bottom:0; z-index:15; border:1px solid var(--line); border-radius:13px; background:rgba(255,255,255,.96); backdrop-filter:blur(10px); box-shadow:0 10px 30px rgba(24,52,68,.12); padding:12px 14px; display:flex; align-items:center; justify-content:flex-end; gap:18px; }
.ai-save-bar span { margin-right:auto; color:var(--muted); font-size:12px; }
.ai-section-panel { overflow:hidden; }
.ai-provider-grid { padding:18px 20px 20px; }
.ai-provider-card { background:#fff; box-shadow:0 5px 18px rgba(28,56,70,.05); }
.ai-provider-card-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.ai-provider-card-head > div { display:grid; gap:3px; }
.ai-provider-url { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; padding:7px 9px; border-radius:7px; background:#f2f5f6; color:#334b57; font-size:11px; }
.ai-provider-meta { display:flex; flex-wrap:wrap; gap:6px 12px; color:var(--muted); font-size:11px; }
.ai-provider-message { color:var(--muted); line-height:1.35; }
.ai-health-badge,.ocr-run-status { display:inline-flex; align-items:center; width:max-content; border-radius:999px; padding:4px 8px; font-size:10px; line-height:1; font-weight:800; letter-spacing:.03em; text-transform:uppercase; background:#edf1f3; color:#52646e; }
.ai-health-badge.status-healthy,.ocr-run-status.status-pass { background:#e6f6ed; color:#24734b; }
.ai-health-badge.status-failed,.ocr-run-status.status-fail,.ocr-run-status.status-provider_error { background:#fdeaea; color:#9b3737; }
.ocr-run-status.status-config_error,.ocr-run-status.status-partial,.ai-health-badge.status-unknown { background:#fff2d6; color:#8a641a; }
.ocr-run-status.status-skipped { background:#eff2f4; color:#71828a; }
.ai-health-badge.hard-deny { background:#f8e7e7; color:#893b3b; }
.ai-prompt-card { min-height:104px; justify-content:center; }
.ai-prompt-card > span { text-transform:uppercase; font-size:10px; letter-spacing:.06em; font-weight:700; }
.ai-prompt-card > strong { color:var(--ink); }
.ai-table-actions { padding:0 18px 18px; }
.compact-control { min-width:170px; }
.ai-provider-form { overflow:hidden; }
.ai-provider-form-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; padding:4px 20px 20px; }
.ai-provider-form-grid .span-2 { grid-column:span 2; }
.ai-subsection-header { border-top:1px solid var(--line); }
.provider-switches { padding:4px 20px 8px; grid-template-columns:repeat(3,minmax(0,1fr)); }
.ai-form-actions { padding:0 20px 20px; }
.field-control { width:100%; min-height:40px; border:1px solid #bac7ce; border-radius:9px; background:#fff; padding:8px 10px; color:var(--ink); font:inherit; box-sizing:border-box; }
textarea.field-control { min-height:110px; resize:vertical; }
select.field-control { padding-right:30px; }
.field-control:focus { outline:none; border-color:#5b8295; box-shadow:0 0 0 3px rgba(58,111,136,.12); }
.ai-lab-statusbar { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; margin-bottom:16px; }
.ai-lab-statusbar > div { border:1px solid var(--line); border-radius:11px; background:#fff; padding:11px 13px; display:grid; gap:3px; }
.ai-lab-statusbar span { color:var(--muted); font-size:10px; text-transform:uppercase; letter-spacing:.05em; }
.ai-lab-statusbar strong { font-size:12px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.enterprise-lab-layout { grid-template-columns:minmax(370px,.72fr) minmax(0,1.28fr); align-items:start; }
.ai-lab-input,.ai-lab-result { overflow:hidden; }
.ai-lab-input .panel-header,.ai-lab-result .panel-header { padding:18px 20px 14px; }
.ocr-image-preview { min-height:170px; border:1px dashed #b6c4cb; border-radius:11px; background:#f8fafb; display:grid; place-items:center; overflow:hidden; color:var(--muted); font-size:12px; text-align:center; }
.ocr-image-preview img { width:100%; max-height:360px; object-fit:contain; background:#fff; }
.ai-prompt-draft { border:1px solid var(--line); border-radius:10px; background:#fafcfd; }
.ai-prompt-draft summary { padding:11px 12px; cursor:pointer; font-weight:700; font-size:12px; }
.ai-prompt-draft .details-body { padding:0 12px 12px; }
.ai-result-meta { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; padding:0 20px 15px; }
.ai-result-meta > div { padding:9px 10px; border-radius:9px; background:#f5f8f9; display:grid; gap:3px; }
.ai-result-meta span { color:var(--muted); font-size:10px; text-transform:uppercase; }
.ocr-engine-results { padding:0 20px 20px; display:grid; gap:12px; }
.ocr-engine-card { border:1px solid var(--line); border-radius:12px; padding:13px; background:#fff; }
.ocr-engine-card.status-pass { border-color:#b8ddca; }
.ocr-engine-card.status-fail,.ocr-engine-card.status-provider_error { border-color:#ebbbbb; }
.ocr-engine-head { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; margin-bottom:9px; }
.ocr-engine-head > div { display:grid; gap:2px; }
.ocr-engine-head small { color:var(--muted); }
.ocr-engine-metric { font-size:11px; color:var(--muted); margin-bottom:8px; }
.ocr-engine-card details { margin-top:8px; }
.ocr-engine-card summary,.ai-lab-result > details summary { cursor:pointer; font-weight:700; font-size:11px; color:#435a66; }
.ai-lab-result pre { max-height:430px; font-size:11px; line-height:1.45; }
.ai-lab-empty { margin:8px 20px 20px; min-height:250px; display:grid; place-items:center; }
.fastener-control-strip { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; margin-bottom:14px; }
.fastener-commercial-editor td.is-disabled { background:#f5f7f8; }
.roofing-detail-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.compact-detail-grid,.roofing-kpi-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; padding:18px; }
.compact-detail-grid > div,.roofing-kpi-grid > div { display:grid; gap:3px; padding:10px 12px; border:1px solid var(--line); border-radius:10px; background:#fbfcfd; }
.compact-detail-grid span,.roofing-kpi-grid span { color:var(--muted); font-size:10px; text-transform:uppercase; }
.roofing-tkp-shell-form { overflow:hidden; }
.human-boundary-card { margin-top:16px; }
@media(max-width:1180px){.ai-config-grid{grid-template-columns:1fr 1fr}.ai-config-card:last-child{grid-column:1/-1}.ai-status-strip{grid-template-columns:1fr 1fr}.provider-switches{grid-template-columns:1fr 1fr}}
@media(max-width:900px){.ai-config-grid,.ai-provider-form-grid,.enterprise-lab-layout,.roofing-detail-grid{grid-template-columns:1fr}.ai-config-card:last-child{grid-column:auto}.ai-provider-form-grid .span-2{grid-column:auto}.ai-lab-statusbar{grid-template-columns:1fr 1fr}.fastener-control-strip{grid-template-columns:1fr}.provider-switches{grid-template-columns:1fr 1fr}.ai-result-meta{grid-template-columns:1fr 1fr}}
@media(max-width:600px){.ai-status-strip,.ai-lab-statusbar,.provider-switches,.ai-switch-grid,.ai-inline-fields,.ai-result-meta,.compact-detail-grid,.roofing-kpi-grid{grid-template-columns:1fr}.ai-save-bar{align-items:stretch;flex-direction:column}.ai-save-bar span{margin:0}.ai-save-bar .button{width:100%}}
.ai-prompt-editor-layout{display:grid;grid-template-columns:minmax(0,1.55fr) minmax(300px,.45fr);gap:16px;align-items:start}.ai-prompt-editor,.ai-prompt-history{overflow:hidden}.ai-prompt-history .revision-list{padding:0 18px 18px}.ai-prompt-editor textarea{min-height:480px}.ai-prompt-editor input[type="text"]{width:100%;min-height:40px;border:1px solid #bac7ce;border-radius:9px;padding:8px 10px;box-sizing:border-box}.ai-prompt-editor .control-switch{max-width:420px}@media(max-width:900px){.ai-prompt-editor-layout{grid-template-columns:1fr}}


/* Version 6.0 RC3 — production UX/security polish */
.button-success{background:#198754;border-color:#198754;color:#fff}.button-success:hover{background:#157347;border-color:#146c43;color:#fff}.button.is-loading{cursor:wait;opacity:.85}
.bitrix-transfer-status{margin:0 0 14px;padding:11px 14px;border:1px solid var(--line);border-radius:10px;display:flex;align-items:center;justify-content:space-between;gap:12px;background:#f7f9fa;font-size:12px}.bitrix-transfer-status strong{font-size:13px}.bitrix-transfer-status span{color:var(--muted);text-align:right}.bitrix-transfer-status.is-success{border-color:#add9bf;background:#edf8f2;color:#176941}.bitrix-transfer-status.is-stale{border-color:#ead59e;background:#fff8e8;color:#805d10}.bitrix-transfer-status.is-error{border-color:#e1b0b5;background:#fff1f2;color:#9c2e3b}.bitrix-transfer-status.is-syncing{border-color:#b8d6e8;background:#eef7fc;color:#236079}.bitrix-transfer-status.is-pending{color:#566872}
.editor-actions{padding:8px 12px;gap:12px;min-height:64px}.editor-actions .live-total{flex:1;display:grid;grid-template-columns:minmax(380px,1.55fr) minmax(190px,.65fr);gap:10px 18px;align-items:center}.editor-actions .live-total-main{display:grid;grid-template-columns:auto minmax(0,1fr);gap:4px 18px;align-items:center;border-right:1px solid #dfe6ea;padding-right:18px}.live-total-primary{min-width:170px}.live-total-primary span,.live-total-bonus>span{display:block;color:var(--muted);font-size:11px}.live-total-primary strong,.live-total-bonus>strong{display:block;margin-top:2px;font-size:19px}.live-total-details{min-width:0;display:flex;flex-direction:column;gap:4px}.editor-actions .live-total-breakdown,.editor-actions .live-total-metrics{display:flex;flex-wrap:wrap;align-items:center;gap:4px 14px;margin:0;font-size:11px;color:var(--muted)}.editor-actions .live-total-breakdown span,.editor-actions .live-total-metrics span{display:inline}.editor-actions .live-total-breakdown b{color:var(--text);font-weight:800}.editor-actions .live-total-bonus{padding-left:0;min-width:180px}.editor-actions .live-bonus-breakdown{margin-top:3px;display:block;font-size:11px;color:var(--muted)}
.ai-assist-form{display:flex;align-items:stretch;gap:8px;padding:12px 14px;border-top:1px solid var(--line)}.ai-assist-form textarea{flex:1 1 auto;width:auto;min-width:0;box-sizing:border-box;min-height:48px;max-height:150px;resize:vertical}.ai-assist-form .button{flex:0 0 48px;width:48px;min-width:48px;padding:0;align-self:stretch;display:flex;align-items:center;justify-content:center}.ai-assist-fab{bottom:var(--ai-assist-bottom,92px)}
.ocr-normalized-table-wrap{overflow:auto;margin:10px 0}.ocr-normalized-table{width:100%;min-width:760px;font-size:12px}.ocr-normalized-table th,.ocr-normalized-table td{padding:8px 9px;white-space:nowrap}.ocr-normalized-table tr.needs-review{background:#fff8e8}
@media(max-width:1180px){.editor-actions .live-total{grid-template-columns:minmax(320px,1.4fr) minmax(160px,.6fr)}.editor-actions .live-total-main{gap:4px 10px;padding-right:10px}.live-total-primary{min-width:150px}.editor-actions .live-total-breakdown,.editor-actions .live-total-metrics{gap:3px 9px;font-size:10px}}
@media(max-width:760px){.editor-actions{position:static;min-height:0;flex-direction:column;align-items:stretch}.editor-actions .live-total{width:100%;grid-template-columns:1fr 1fr}.editor-actions .live-total-main{grid-template-columns:1fr;border-right:0;padding-right:0}.ai-assist-fab{right:12px;bottom:18px}.bitrix-transfer-status{align-items:flex-start;flex-direction:column}.bitrix-transfer-status span{text-align:left}.ai-assist-form{padding:10px}.ai-assist-form .button{flex-basis:44px;width:44px;min-width:44px}}

/* Version 6.1 — human-gated AI Action Mode */
.ai-action-card {
  margin: 10px 0 4px;
  padding: 14px;
  border: 1px solid var(--border, #d7dbe2);
  border-radius: 14px;
  background: var(--surface, #fff);
  box-shadow: 0 8px 24px rgba(23, 31, 46, .08);
}
.ai-action-card-head, .ai-action-totals > div, .ai-action-change {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.ai-action-card-head { margin-bottom: 10px; }
.ai-action-badge {
  font-size: 11px;
  padding: 3px 7px;
  border: 1px solid currentColor;
  border-radius: 999px;
  opacity: .8;
  white-space: nowrap;
}
.ai-action-sections { font-size: 13px; margin: 8px 0; }
.ai-action-sections ul { margin: 5px 0 0 18px; padding: 0; }
.ai-action-change { font-size: 12px; padding: 5px 0; border-top: 1px solid rgba(0,0,0,.06); }
.ai-action-change span:last-child { font-weight: 600; text-align: right; }
.ai-action-totals { margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(0,0,0,.08); }
.ai-action-totals > div { padding: 3px 0; font-size: 13px; }
.ai-action-status { min-height: 18px; margin-top: 8px; font-size: 12px; }
.ai-action-status.error { color: #b42318; }
.ai-action-buttons { display: flex; gap: 8px; margin-top: 10px; }
.ai-action-buttons .button { flex: 1; }
.ai-action-card.is-applied { opacity: .72; }
.ai-action-card.is-cancelled { opacity: .62; }
