/* Заказы СРК: список поступивших заявок и карточка заказа.
   Панель повторяет ширину и типографику панели источника этапа. */

.nav-tab-primary .nav-text { font-weight: 600; }

.intake-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.intake-view-header { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.intake-view-header h2 { margin: 0; }
.intake-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.intake-filters label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.intake-filters .prefix-select { min-width: 190px; }
.intake-archived-toggle { font-weight: 600; }

.intake-table td { vertical-align: middle; }
.intake-table .intake-company { font-weight: 600; color: #0f172a; }
.intake-table .intake-task { white-space: nowrap; }
.intake-table .intake-state { color: #334155; font-weight: 600; }
.intake-row.archived { background: #f8fafc; color: #64748b; }
.intake-row-actions { white-space: nowrap; }
.intake-empty { padding: 18px 8px; color: #64748b; }

/* Панель заказа. Колонки растягиваются, чтобы действия держались у нижнего края. */
.intake-positions { display: flex; flex-direction: column; }
.intake-summary {
  position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px;
  padding: 10px 12px; border: 1px solid #cbd5e1; border-left: 4px solid #f59e0b; background: #fff;
}
.intake-summary-counts { font-size: 14px; font-weight: 600; color: #0f172a; }
.intake-summary-state { font-size: 13px; color: #475569; }

.intake-position { margin-top: 14px; padding: 12px; border: 1px solid #cbd5e1; border-radius: 5px; background: #fff; }
.intake-position-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 14px; }
.intake-position-select { display: flex; align-items: baseline; gap: 8px; min-width: 0; cursor: pointer; }
.intake-position-title { font-size: 15px; font-weight: 600; line-height: 1.4; color: #0f172a; overflow-wrap: anywhere; }
.intake-decision { flex-shrink: 0; padding: 2px 8px; border-radius: 3px; background: #e2e8f0; color: #334155; font-size: 13px; font-weight: 600; }

.intake-field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 12px; margin-top: 12px; }
.intake-field { display: grid; gap: 4px; min-width: 0; }
.intake-field-label { color: #64748b; font-size: 13px; font-weight: 600; line-height: 1.3; }
.intake-field-input { width: 100%; min-height: 38px; padding: 5px 8px; border: 1px solid #94a3b8; border-radius: 4px; background: #fff; color: #0f172a; font-size: 14px; }
.intake-field-input.intake-field-stale { border-color: #f59e0b; background: #fffbeb; }
.intake-field-conflict { color: #92400e; font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }

.intake-issues { margin: 10px 0 0 18px; padding: 0; color: #9a3412; font-size: 13px; line-height: 1.45; }
.intake-issues li.blocking { color: #991b1b; font-weight: 600; }
.intake-blocking-tag { font-weight: 600; }
.intake-save-position { margin-top: 10px; }

/* Срок клиента: подтверждение никогда не выводится из набранного текста */
.intake-delivery { margin: 12px 0 0; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 5px; background: #f8fafc; }
.intake-delivery legend { padding: 0 6px; color: #1e293b; font-size: 13px; font-weight: 600; }
.intake-delivery .intake-field[hidden] { display: none; }
.intake-delivery-mode, .intake-delivery-basis { min-height: 38px; padding: 5px 8px; border: 1px solid #94a3b8; border-radius: 4px; background: #fff; font-size: 13px; }
.intake-delivery-preview { margin: 8px 0 0; color: #475569; font-size: 13px; line-height: 1.4; }
.intake-delivery-preview.error { color: #991b1b; font-weight: 600; }

.intake-readiness { margin-top: 12px; }
.intake-profile { min-height: 38px; padding: 5px 8px; border: 1px solid #94a3b8; border-radius: 4px; background: #fff; font-size: 13px; }
.intake-spec { flex-direction: row; align-items: center; gap: 8px; display: flex; }

/* Сравнение с источником: было принято → пришло из источника */
.intake-source-diff { margin: 12px 0; padding: 10px 12px; border-left: 4px solid #f59e0b; background: #fffbeb; }
.intake-source-diff h4 { margin: 0 0 8px; font-size: 14px; color: #92400e; }
.intake-diff-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.intake-diff-table th, .intake-diff-table td { padding: 5px 7px; border-bottom: 1px solid #fde68a; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.intake-diff-before { color: #64748b; }
.intake-diff-after { color: #0f172a; font-weight: 600; }
.intake-source-choice { min-height: 38px; padding: 5px 8px; border: 1px solid #b45309; border-radius: 4px; background: #fff; font-size: 13px; }

.intake-duplicate { margin: 12px 0; padding: 10px 12px; border-left: 4px solid #0369a1; background: #eff6ff; }
.intake-duplicate.conflicting { border-left-color: #dc2626; background: #fef2f2; }
.intake-duplicate h4 { margin: 0 0 6px; font-size: 14px; color: #1e3a8a; }
.intake-duplicate.conflicting h4 { color: #991b1b; }

/* Этапы прежнего разбора: связь не подтверждена, новую поверх не создаём */
.intake-unlinked { margin-top: 12px; padding: 10px 12px; border: 1px solid #fca5a5; border-radius: 5px; background: #fff7ed; }
.intake-unlinked h3 { margin: 0 0 8px; font-size: 15px; color: #9a3412; }
.intake-stage-match { min-height: 38px; padding: 5px 8px; border: 1px solid #94a3b8; border-radius: 4px; background: #fff; font-size: 13px; }

.intake-new-position { margin-top: 14px; padding: 10px 12px; border: 1px dashed #94a3b8; border-radius: 5px; background: #fff; }
.intake-new-position summary { color: #1e293b; font-size: 14px; font-weight: 600; cursor: pointer; }
.intake-add-position { margin-top: 10px; }
.intake-refresh { margin-left: auto; }

/* Этапы позиции: факт отдельно от плана */
.intake-stage-list { margin-top: 14px; padding-top: 10px; border-top: 1px solid #e2e8f0; }
.intake-stage-list h4 { margin: 0 0 8px; font-size: 14px; line-height: 1.35; color: #1e293b; }
.intake-stage { margin-top: 8px; padding: 10px; border: 1px solid #e2e8f0; border-left: 4px solid #94a3b8; background: #f8fafc; }
.intake-stage-preview { border-left-style: dashed; }
.intake-stage-title { font-size: 14px; font-weight: 600; color: #0f172a; overflow-wrap: anywhere; }
.intake-stage-status { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; font-size: 13px; }
.intake-stage-status .intake-fact { font-weight: 600; color: #15803d; }
.intake-stage-status.unconfirmed { border-left: 0; }
.intake-stage-status.unconfirmed .intake-fact { color: #b45309; }
.intake-stage-status .intake-plan { color: #64748b; }
.intake-stage-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.intake-stage-status-controls { display: grid; gap: 8px; margin-top: 10px; }
.intake-stage-status-select { min-height: 38px; padding: 5px 8px; border: 1px solid #94a3b8; border-radius: 4px; background: #fff; font-size: 13px; }
.intake-stage-note { box-sizing: border-box; width: 100%; padding: 8px; border: 1px solid #94a3b8; border-radius: 4px; font: inherit; font-size: 13px; resize: vertical; }
.intake-stage-note[hidden] { display: none; }
.intake-stage-apply { justify-self: start; }
.intake-stage-issue { margin: 0; color: #991b1b; font-size: 13px; line-height: 1.4; }
.intake-stage-issue:empty { display: none; }

.intake-technical { margin-top: 10px; }
.intake-technical summary { color: #64748b; font-size: 13px; cursor: pointer; }

/* Действия видны всегда, но панель низкая: на 1280×720 она не должна закрывать поля.
   Комментарий и редкие действия убраны в раскрываемые блоки. */
.intake-actions {
  position: sticky; bottom: 0; z-index: 4; margin-top: auto; padding: 8px 0 6px;
  max-height: 42vh; overflow-y: auto;
  background: #f8fafc; border-top: 1px solid #cbd5e1; box-shadow: 0 -6px 12px rgba(15, 23, 42, .06);
}
.intake-note-block, .intake-extra-block { margin: 0 0 6px; }
.intake-note-block > summary, .intake-extra-block > summary {
  padding: 3px 0; color: #475569; font-size: 13px; font-weight: 600; cursor: pointer; list-style: revert;
}
.intake-note-block.filled > summary { color: #0369a1; }
.intake-note-mark { font-weight: 400; }
.intake-note { box-sizing: border-box; width: 100%; margin-top: 6px; padding: 8px; border: 1px solid #94a3b8; border-radius: 4px; font: inherit; font-size: 14px; resize: vertical; }
.intake-extra-block { margin: 6px 0 0; }
.intake-action-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.intake-actions > .intake-action-buttons { margin-top: 0; }
.intake-action-buttons button { flex: 1 1 auto; min-height: 36px; padding: 7px 12px; font-size: 14px; font-weight: 600; border-width: 2px; border-radius: 7px; }
.intake-action-buttons button:focus-visible { outline: 3px solid #0f172a; outline-offset: 3px; }
.intake-decision-accept { background: #15803d; border-color: #15803d; color: #fff; }
.intake-decision-accept:hover { background: #166534; border-color: #166534; }
.intake-decision-needs-info { background: #b45309; border-color: #b45309; color: #fff; }
.intake-decision-needs-info:hover { background: #92400e; border-color: #92400e; }
.intake-decision-reject { background: #fff; border-color: #b91c1c; color: #b91c1c; }
.intake-decision-reject:hover { background: #fef2f2; }
.intake-actions button:disabled { opacity: .6; cursor: wait; }

.intake-status { margin: 6px 0 0; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; color: #475569; }
.intake-status:empty { display: none; }
.intake-status.error { padding: 7px 9px; border-left: 4px solid #dc2626; background: #fef2f2; color: #991b1b; }
.intake-status.success { padding: 7px 9px; border-left: 4px solid #059669; background: #ecfdf5; color: #065f46; }

/* Распределение количества по частям этапа */
.intake-allocation { margin-top: 10px; padding: 8px 10px; border: 1px solid #fde68a; border-radius: 4px; background: #fffdf5; }
.intake-allocation[hidden] { display: none; }
.intake-allocation h5 { margin: 0 0 6px; font-size: 13px; color: #92400e; }
.intake-allocation-summary { margin: 8px 0 0; color: #475569; font-size: 13px; line-height: 1.4; }
.intake-allocation-summary.error { color: #991b1b; font-weight: 600; }

/* История решений, фактов и доставки */
.intake-history { margin-top: 22px; padding-top: 14px; border-top: 1px solid #cbd5e1; }
.intake-history-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.intake-history-header h3 { margin: 0; font-size: 1rem; color: #1e293b; }
.intake-history-list { margin: 10px 0 0; padding: 0 0 0 18px; display: grid; gap: 8px; }
.intake-history-item { display: grid; gap: 2px; padding: 7px 9px; border-left: 3px solid #cbd5e1; background: #fff; font-size: 13px; }
.intake-history-item.fact { border-left-color: #15803d; }
.intake-history-item.delivery { border-left-color: #0369a1; }
.intake-history-title { font-weight: 600; color: #0f172a; overflow-wrap: anywhere; }
.intake-history-detail { color: #475569; overflow-wrap: anywhere; }
.intake-prepare-feedback { justify-self: start; margin-top: 6px; }

.intake-feedback { margin-top: 14px; padding: 10px 12px; border: 1px solid #94a3b8; border-radius: 5px; background: #fff; }
.intake-feedback h4 { margin: 0 0 6px; font-size: 14px; color: #1e293b; }
.intake-feedback-text { box-sizing: border-box; width: 100%; margin-top: 8px; padding: 9px; border: 1px solid #94a3b8; border-radius: 4px; font: inherit; font-size: 13px; resize: vertical; }
.intake-feedback-text[readonly] { background: #f1f5f9; color: #334155; }
.intake-feedback-status { margin: 8px 0 0; padding: 7px 9px; border-left: 4px solid #64748b; background: #f1f5f9; font-size: 13px; overflow-wrap: anywhere; }
.intake-feedback-status.sent { border-left-color: #059669; background: #ecfdf5; color: #065f46; }
.intake-feedback-status.unknown { border-left-color: #f59e0b; background: #fffbeb; color: #92400e; }
.intake-feedback-status.failed, .intake-feedback-status.disabled { border-left-color: #dc2626; background: #fef2f2; color: #991b1b; }
.intake-feedback-send { margin-top: 10px; }
.intake-confirm-match { margin-top: 8px; }

.order-card.intake-stage-focus { outline: 3px solid #f59e0b; outline-offset: 2px; }

@media (max-width: 820px) {
  .intake-actions { position: static; max-height: none; }
}

/* Низкие экраны (1280×720): панель не должна съедать больше трети высоты */
@media (max-height: 800px) {
  .intake-actions { max-height: 33vh; padding: 6px 0 4px; }
  .intake-action-buttons button { min-height: 38px; padding: 6px 10px; font-size: 13px; }
  .intake-note, .intake-feedback-text { max-height: 22vh; }
}

@media (max-width: 600px) {
  .intake-filters { flex-direction: column; align-items: stretch; }
  .intake-field-grid { grid-template-columns: 1fr; }
  .intake-action-buttons button { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .order-card.intake-stage-focus { outline-style: solid; }
}

/* Actions occupy their own row; only position content scrolls beneath the summary. */
#intakeDrawerBody { min-height: 0; overflow: hidden; grid-template-columns: minmax(240px, .85fr) minmax(340px, 1.15fr); }
.intake-source { min-height: 0; overflow-y: auto; padding-right: 8px; }
.intake-positions { min-height: 0; overflow: hidden; }
.intake-position-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 2px 16px; }
.intake-positions > .intake-summary { position: static; flex: 0 0 auto; }
.intake-positions > .intake-actions { position: static; flex: 0 0 auto; margin-top: 8px; box-shadow: none; }
@media (max-width: 820px) {
  #intakeDrawerBody { display: block; overflow-y: auto; }
  .intake-source, .intake-positions, .intake-position-scroll { overflow: visible; }
}

/* Workbench: a quiet queue, readable source, one aligned editing grid. */
#intakeView { color: #1f2937; font-size: 14px; line-height: 1.5; }
.intake-card { padding: 24px; gap: 20px; }
.intake-view-header h2 { font-size: 22px; line-height: 30px; font-weight: 600; }
.intake-view-header #intakeListStatus { margin-left: auto; }
#intakeView .help-text, .intake-drawer .help-text { font-size: 13px; line-height: 19px; color: #5b6472; }
.intake-filters { justify-content: space-between; align-items: flex-end; }
.intake-filters .intake-search { display: grid; gap: 6px; font-size: 13px; font-weight: 400; width: min(440px, 100%); }
.intake-search input { min-height: 40px; padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 5px; font-size: 14px; background: #fff; }
.intake-queue-tabs { display: flex; gap: 24px; border-bottom: 1px solid #dce1e7; overflow-x: auto; }
.intake-queue-tab { display: flex; align-items: center; gap: 8px; padding: 10px 0 12px; border: 0; border-bottom: 2px solid transparent; background: none; white-space: nowrap; font-size: 14px; color: #576171; cursor: pointer; }
.intake-queue-tab[aria-pressed="true"] { color: #1d4ed8; border-bottom-color: #1d4ed8; font-weight: 600; }
.intake-tab-count { font-variant-numeric: tabular-nums; font-size: 13px; color: #5b6472; }
.intake-table { table-layout: fixed; width: 100%; min-width: 780px; }
.intake-table th { padding: 12px 14px; text-align: left; font-size: 13px; font-weight: 400; color: #5b6472; background: #f8fafc; }
.intake-table td { padding: 16px 14px; text-align: left; font-size: 14px; line-height: 21px; border-bottom: 1px solid #e4e8ed; overflow-wrap: break-word; }
.intake-table th:nth-child(1) { width: 31%; }
.intake-table th:nth-child(2) { width: 9%; }
.intake-table th:nth-child(3) { width: 16%; }
.intake-table th:nth-child(4) { width: 30%; }
.intake-table th:nth-child(5) { width: 14%; }
.intake-table .intake-company { font-weight: 600; }
.intake-order-subtitle { font-size: 13px; line-height: 19px; color: #5b6472; margin-top: 3px; }
.intake-table .intake-state { font-weight: 400; }
.intake-recognition-label { margin-bottom: 3px; }
.intake-state-work .intake-recognition-label { color: #925c13; }
.intake-state-accepted .intake-recognition-label { color: #237047; }
.intake-row-actions .btn-info { width: 100%; padding: 8px 10px; font-size: 14px; font-weight: 500; background: #fff; color: #1d4ed8; border: 1px solid #cbd5e1; border-radius: 5px; }
.intake-received, .intake-task { font-variant-numeric: tabular-nums; }
.intake-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.intake-drawer { width: min(1240px, 98vw); border-left: 1px solid #cbd5e1; background: #fff; }
.intake-drawer .source-drawer-header h2 { font-size: 20px; line-height: 28px; font-weight: 600; }
.intake-drawer .source-drawer-body { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 28px; padding: 20px 24px; overflow: hidden; min-height: 0; flex: 1; }
.intake-source { overflow-y: auto; padding-right: 10px; }
.intake-positions { min-height: 0; }
.intake-position-scroll { min-height: 0; overflow-y: auto; padding: 0 8px 16px 0; }
.intake-summary { position: static; border: 0; border-bottom: 1px solid #dce1e7; padding: 0 0 14px; margin-bottom: 4px; }
.intake-actions { position: static; flex-shrink: 0; max-height: 30vh; margin-top: 0; background: #fff; box-shadow: none; padding-top: 10px; }
.intake-actions .intake-decision-needs-info { background: #fff; color: #925c13; border: 1px solid #cbd5e1; }
.intake-actions .intake-decision-reject { border: 1px solid #cbd5e1; color: #5b6472; }
.intake-drawer .source-text { max-height: none; padding: 14px; font-size: 14px; line-height: 22px; }
.intake-source-line { min-height: 22px; white-space: pre-wrap; }
.intake-source-line.selected { background: #fef3c7; }
.intake-position { padding: 0; border: 1px solid #dce1e7; border-radius: 6px; }
.intake-position-compact { padding: 14px; cursor: pointer; font-size: 14px; line-height: 22px; font-weight: 500; overflow-wrap: break-word; }
.intake-position-compact .intake-decision { display: inline-block; margin-left: 8px; font-size: 13px; font-weight: 400; }
.intake-position[open] > .intake-position-compact { border-bottom: 1px solid #e4e8ed; }
.intake-position-editor { padding: 14px; }
.intake-position-header .intake-position-title { font-size: 13px; font-weight: 400; }
.intake-position-header > .intake-decision { display: none; }
.intake-field-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 12px; }
.intake-field-label { font-size: 13px; font-weight: 400; line-height: 18px; color: #515c6b; }
.intake-field-input { min-height: 38px; font-size: 14px; line-height: 20px; border-color: #c4ccd6; font-variant-numeric: tabular-nums; }
.intake-field-input.intake-field-missing { border-color: #d6b56b; background: #fffcf2; }
.intake-field-input::placeholder { color: #687385; opacity: 1; }
.intake-spec-picker { display: grid; gap: 8px; margin-top: 14px; }
.intake-spec-choice { max-width: 100%; min-width: 0; padding: 8px; font-size: 14px; }
.intake-raw-field { margin-top: 14px; }
.intake-raw-input, .intake-table-paste { width: 100%; padding: 10px; border: 1px solid #c4ccd6; border-radius: 5px; font-size: 14px; line-height: 21px; resize: vertical; }
.intake-duplicate-position { margin-left: 8px; }
.intake-original-line { margin-top: 10px; color: #515c6b; font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }
.intake-table-entry { padding: 14px 0; margin-top: 12px; border-top: 1px solid #dce1e7; }
.intake-table-entry > summary { cursor: pointer; font-size: 14px; font-weight: 500; }
.intake-table-entry .help-text { margin: 10px 0; }
.intake-table-preview { overflow-x: auto; margin-top: 12px; }
.intake-paste-preview { border-collapse: collapse; font-size: 13px; width: 100%; margin: 12px 0; }
.intake-paste-preview td, .intake-paste-preview th { border: 1px solid #dce1e7; padding: 8px; text-align: left; }
.intake-paste-preview select { width: 140px; padding: 6px; font-size: 13px; }
.intake-skip-header { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.intake-source-add { margin-bottom: 12px; }
.intake-drawer button:focus-visible, .intake-queue-tab:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 3px; }
@media (max-width: 820px) {
  .intake-card { padding: 16px; }
  .intake-drawer .source-drawer-body { display: block; overflow-y: auto; padding: 16px; }
  .intake-source, .intake-position-scroll { overflow: visible; }
  .intake-positions { margin-top: 24px; }
  .intake-actions { max-height: none; }
}
@media (max-width: 480px) {
  .intake-field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .intake-queue-tabs { gap: 18px; }
  .intake-view-header #intakeListStatus { margin-left: 0; }
}

.intake-field-input.intake-field-missing::placeholder { color: #8c681e; }
.intake-compact-geometry { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.intake-compact-description { display: block; margin: 4px 0 6px 16px; color: #5b6472; font-size: 13px; line-height: 19px; font-weight: 400; }
.intake-position-compact .intake-decision { margin-left: 16px; }
.intake-drawer .intake-original-line, .intake-drawer .source-item { font-size: 14px; line-height: 21px; }

.intake-drawer .source-item { white-space: pre-wrap; overflow-wrap: anywhere; }

.intake-table .intake-row { cursor: pointer; }
.intake-table .intake-row:hover > td { background: #f1f5f9; }
.intake-table .intake-row:focus-visible { outline: 2px solid #1d4ed8; outline-offset: -2px; }

.intake-entry-form { margin-top: 12px; }
.intake-entry-form[hidden] { display: none; }
.intake-actions .intake-note { min-height: 38px; margin: 0; }
.intake-extra-block { border: 0; padding: 0; }
.intake-status:empty { display: none; }
.intake-field { min-width: 0; }
.intake-field input, .intake-field select { min-width: 0; width: 100%; max-width: 100%; box-sizing: border-box; }
.intake-readiness { grid-template-columns: minmax(0, 1fr); }
.intake-readiness .intake-spec { display: flex; align-items: center; gap: 8px; }
.intake-readiness .intake-spec input { width: auto; flex: none; }
.intake-new-position, .intake-table-entry { border: 0; padding: 6px 0; margin-top: 6px; }
.intake-extra-block .intake-action-buttons { justify-content: flex-end; }
.intake-extra-block .intake-action-buttons button { flex: none; background: transparent; border-color: transparent; }
