:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --muted: #667085;
  --text: #182230;
  --accent: #176b87;
  --ok: #20724f;
  --warn: #9a5b00;
  --warn-bg: #fff5df;
  --ok-bg: #e8f5ee;
  --bad-bg: #fdecec;
  --bad: #9b1c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
  font-size: 14px;
}

.shell {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 20px;
}

.topbar,
.toolbar,
.metrics,
.workspace {
  margin-bottom: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.connectivity-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.connectivity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.connectivity-status.online {
  border-color: #b7dfca;
  background: var(--ok-bg);
  color: var(--ok);
}

.connectivity-status.online .connectivity-dot {
  background: var(--ok);
}

.connectivity-status.offline {
  border-color: #f1c7c7;
  background: var(--bad-bg);
  color: var(--bad);
}

.connectivity-status.offline .connectivity-dot {
  background: var(--bad);
}

.connectivity-status.checking .connectivity-dot {
  animation: pulse 1s infinite ease-in-out;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
  }

  50% {
    opacity: 1;
  }
}

.page-tabs {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef2f6;
}

.tab-button {
  width: auto;
  min-width: 88px;
  height: 30px;
  border: 0;
  background: transparent;
  color: #344054;
  font-weight: 700;
}

.tab-button.active {
  background: var(--panel);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.option-group.mixed legend::after {
  content: " разные";
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

.topbar p,
.metric span,
label span,
.details p {
  color: var(--muted);
}

button,
input,
select {
  font: inherit;
}

button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
}

#downloadEconomicsButton {
  width: auto;
  height: auto;
  min-height: 36px;
  max-width: 100%;
  padding: 8px 16px;
  line-height: 1.25;
  white-space: normal;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: wait;
  opacity: 0.6;
}

.primary-button {
  width: auto;
  min-width: 92px;
  padding: 0 16px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

label {
  display: grid;
  gap: 4px;
}

fieldset {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.search {
  min-width: 260px;
  flex: 1;
}

input,
select,
textarea {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 70px;
  padding: 8px 10px;
  resize: vertical;
}

.upload-form {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 12px;
  width: 100%;
}

.analysis-grid {
  display: grid;
  grid-template-columns: minmax(280px, 520px) minmax(320px, 1fr);
  align-items: start;
  gap: 12px;
}

.analysis-inputs,
.analysis-options {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.analysis-service-options { display: grid; gap: 12px; min-width: 0; }
.service-selection { display: flex; flex-wrap: wrap; gap: 12px 20px; }
.service-selection .checkbox-row { font-size: 14px; }
.analysis-options-details { border: 1px solid var(--line); border-radius: 6px; }
.analysis-options-details > summary { padding: 12px; cursor: pointer; font-size: 14px; }
.analysis-options-details > .analysis-options { padding: 0 12px 12px; }

.upload-source {
  display: grid;
  gap: 10px;
}

.source-picker {
  position: relative;
  display: grid;
  gap: 8px;
}

.source-picker > button {
  width: 100%;
  min-height: 36px;
}

.source-picker > span {
  color: var(--muted);
  font-size: 12px;
}

.source-menu {
  position: absolute;
  z-index: 10;
  top: 40px;
  left: 0;
  display: grid;
  width: min(260px, 100%);
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 12px 26px rgba(16, 24, 40, 0.16);
}

.source-menu button {
  width: 100%;
  border: 0;
  text-align: left;
}

.source-menu button:hover,
.source-menu button:focus {
  background: #eef7fa;
}

.hidden-file-input {
  display: none;
}

.upload-form label {
  width: 100%;
}

.upload-form input[type="text"],
.upload-form input[type="file"] {
  width: 100%;
}

.upload-form input[type="file"] {
  padding: 6px 10px;
}

.analysis-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#clearFoldersButton {
  width: auto;
  min-width: 72px;
  padding: 0 12px;
  font-weight: 700;
}

.upload-help {
  overflow: hidden;
  border: 1px solid #b9d8e2;
  border-radius: 8px;
  background: #f6fbfc;
}

.upload-help summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.upload-help summary::-webkit-details-marker {
  display: none;
}

.upload-help summary::after {
  margin-left: auto;
  color: var(--accent);
  content: "Раскрыть  ▾";
  font-size: 12px;
  font-weight: 700;
}

.upload-help[open] summary::after {
  content: "Свернуть  ▴";
}

.upload-help summary > span:not(.upload-help-icon) {
  display: grid;
  gap: 2px;
}

.upload-help summary small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.upload-help-icon {
  display: inline-grid;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.upload-help-content {
  display: grid;
  gap: 12px;
  padding: 0 13px 13px;
  border-top: 1px solid #d7e9ee;
}

.upload-help-lead {
  margin: 12px 0 0;
}

.upload-help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.upload-help-grid section {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.upload-help-grid h3,
.upload-help-grid p {
  margin: 0;
}

.upload-help-grid h3 {
  margin-bottom: 7px;
  font-size: 14px;
}

.upload-help-grid p + p {
  margin-top: 7px;
}

.upload-help code {
  padding: 1px 4px;
  border-radius: 3px;
  background: #eaf3f6;
  font-family: Consolas, monospace;
  font-size: 12px;
}

.help-note,
.upload-help-example span {
  color: var(--muted);
  font-size: 12px;
}

.upload-help-example {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.upload-help-warning {
  margin: 0;
  color: #7a4b00;
}

.upload-status {
  min-height: 20px;
  display: flex;
  align-items: center;
  color: var(--muted);
}

.source-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  color: var(--text);
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.option-group {
  display: grid;
  gap: 6px;
}

.option-frame {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.option-frame > span:first-child {
  color: var(--muted);
  font-size: 13px;
}

.manual-pcb-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
  padding-top: 6px;
}

.manual-pcb-fields.hidden { display: none; }
.manual-pcb-fields label:not(.checkbox-row) { display: grid; gap: 4px; }

.active-source {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(23, 107, 135, 0.16);
}

.upload-status.error {
  color: var(--bad);
  font-weight: 700;
}

.progress-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 24px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e9f0;
}

.progress-bar {
  width: 34%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  animation: progress-slide 1.1s ease-in-out infinite;
}

.progress-panel span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

@keyframes progress-slide {
  0% {
    transform: translateX(-110%);
  }

  100% {
    transform: translateX(310%);
  }
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(112px, 1fr)) minmax(300px, auto);
  gap: 10px;
}

.metric {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.selection-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.selection-actions span {
  color: var(--muted);
  white-space: nowrap;
}

.selection-actions button {
  width: auto;
  min-width: 96px;
  padding: 0 12px;
  white-space: nowrap;
}

.selection-actions .primary-button {
  min-width: 112px;
}

.complex-order-dialog {
  width: min(640px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 18px 50px rgba(20, 35, 45, 0.24);
}

.complex-order-dialog::backdrop {
  background: rgba(20, 35, 45, 0.36);
}

.complex-order-dialog form {
  padding: 16px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 18px;
}

.dialog-head button {
  width: 32px;
  height: 32px;
  padding: 0;
}

.complex-order-lines {
  display: grid;
  gap: 8px;
}

.complex-order-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.complex-order-line strong {
  overflow-wrap: anywhere;
}

.complex-order-line span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.complex-order-line input {
  width: 100%;
}

#historyList .complex-order-line button {
  width: auto;
  min-width: 76px;
  height: 34px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}

.dialog-actions button {
  flex: 0 1 auto;
  width: auto;
  max-width: 100%;
  height: auto;
  min-height: 36px;
  padding: 8px 14px;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
}

.dialog-note,
.dialog-warning {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.dialog-warning {
  color: #9f3a2f;
}

.cleanup-options {
  display: grid;
  gap: 8px;
}

.cleanup-option {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.cleanup-option input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  padding: 0;
}

.cleanup-option span {
  display: grid;
  gap: 2px;
}

.cleanup-option small {
  color: var(--muted);
  font-size: 12px;
}

.danger-button {
  width: auto;
  min-width: 110px;
  padding: 0 14px;
  border-color: #b42318;
  background: #b42318;
  color: #fff;
  font-weight: 700;
}

.select-column {
  width: 42px;
  text-align: center;
}

.project-select-checkbox {
  width: 16px;
  height: 16px;
  padding: 0;
}

.actions-column {
  width: 166px;
  text-align: right;
}

.project-action-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.delete-project-button,
.close-project-button {
  width: auto;
  height: 28px;
  min-width: 78px;
  padding: 0 10px;
  border-color: #f1c7c7;
  background: #fff;
  color: var(--bad);
  font-size: 12px;
  font-weight: 700;
}

.close-project-button {
  border-color: var(--line);
  color: var(--ink);
}

.close-project-button:hover {
  border-color: var(--accent);
  background: #eef7fa;
}

.delete-project-button:hover {
  border-color: var(--bad);
  background: var(--bad-bg);
}

.combined-project {
  background: #eef7fa;
}

.complex-badge {
  display: inline-flex;
  margin-left: 8px;
  padding: 2px 6px;
  border: 1px solid #b8d8e3;
  border-radius: 999px;
  color: var(--accent);
  background: #f4fbfd;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}

.exclude-complex-button {
  width: auto;
  height: 24px;
  margin-left: 8px;
  padding: 0 8px;
  border-color: #b8d8e3;
  color: var(--accent);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
}

.exclude-complex-button:hover {
  background: #eef7fa;
}

.complex-group-header td {
  padding: 10px 12px;
  border-top: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  border-left: 2px solid var(--accent);
  background: #e7f3f7;
}

.complex-group-header .complex-group-summary {
  border-right: 0;
}

.complex-group-header .complex-group-download {
  border-right: 0;
  border-left: 0;
}

.complex-group-header .complex-group-actions {
  border-left: 0;
}

.complex-group-header strong {
  margin-right: 10px;
  color: var(--accent);
}

.complex-group-header span {
  color: var(--text);
}

.complex-group-header em {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.complex-group-row td:first-child {
  border-left: 2px solid var(--accent);
}

.complex-group-row td:last-child {
  border-right: 2px solid var(--accent);
}

.complex-group-last td {
  border-bottom: 2px solid var(--accent);
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.table-wrap {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  overflow-x: auto;
  overflow-y: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.projects-table {
  table-layout: fixed;
}

.projects-col-select {
  width: 4%;
}

.projects-col-name {
  width: 18%;
}

.projects-col-status {
  width: 10%;
}

.projects-col-issues {
  width: 9%;
}

.projects-col-totals {
  width: 27%;
}

.projects-col-files {
  width: 17%;
}

.projects-col-actions {
  width: 15%;
}

.projects-table td {
  min-width: 0;
  overflow-wrap: anywhere;
}

.projects-table th {
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.projects-table .document-download-select {
  width: 100%;
  min-width: 0;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #eef2f6;
  font-size: 12px;
  color: #344054;
}

td.number,
th.number {
  text-align: right;
  white-space: nowrap;
}

tr {
  cursor: pointer;
}

tr:hover td {
  background: #f8fafc;
}

.project-row.expanded td {
  background: #eef7fa;
  border-bottom-color: #b8d8e3;
}

.project-details-row {
  cursor: default;
}

.project-details-row > td {
  padding: 0;
  background: #fff;
}

.project-details-row:hover td {
  background: #fff;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.review {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.ready {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge.bad {
  background: var(--bad-bg);
  color: var(--bad);
}

.file-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.document-download-select {
  max-width: 100%;
  min-width: 190px;
}

.totals-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.total-pill {
  display: inline-grid;
  align-items: center;
  gap: 2px;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.total-pill span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.total-pill.customer-supplied {
  background: #e8f5ee;
}

a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

a:hover {
  text-decoration: underline;
}

.details {
  padding: 16px;
  border-top: 1px solid #b8d8e3;
  background: #fff;
}

.details-empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.hidden {
  display: none;
}

.details-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
  margin-bottom: 14px;
}

.details h2 {
  font-size: 20px;
}

.details h3 {
  margin: 16px 0 8px;
  font-size: 13px;
  color: #344054;
}

.details ul {
  margin: 0;
  padding-left: 18px;
}

.procurement-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.procurement-head span,
.subtle {
  color: var(--muted);
  font-size: 12px;
}

.review-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
}

.text-button,
.text-link {
  min-width: 0;
  width: auto;
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.text-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
}

.muted-link {
  color: #344054;
}

#reviewStatus {
  color: var(--muted);
  font-size: 12px;
}

.procurement-tools {
  display: grid;
  grid-template-columns: 170px 170px minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.procurement-readiness {
  margin: 4px 0 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

.procurement-readiness.blocked { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
.procurement-readiness.ready { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }

.procurement-list { display: grid; gap: 8px; max-height: 620px; overflow: auto; }
.procurement-empty { padding: 20px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); text-align: center; }
.procurement-item { border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.procurement-item.resolved { background: #f8fafc; }
.procurement-item.modified { border-color: #f59e0b; box-shadow: inset 3px 0 #f59e0b; }
.procurement-item.error { border-color: #dc2626; }
.procurement-item summary { display: grid; grid-template-columns: minmax(150px, 1.3fr) minmax(150px, 1fr) minmax(190px, 1.5fr) minmax(150px, auto); gap: 12px; align-items: center; padding: 12px; cursor: pointer; }
.procurement-item summary:focus-visible { outline: 3px solid rgba(37, 99, 235, .3); outline-offset: 2px; }
.component-id { display: grid; gap: 3px; }
.component-id span, .component-meta { color: var(--muted); font-size: 12px; }
.issue-reason { font-size: 13px; }
.row-state { justify-self: end; font-size: 12px; font-weight: 700; }
.procurement-detail { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 0 14px 14px; border-top: 1px solid var(--line); }
.procurement-detail section { padding-top: 12px; }
.procurement-detail h4 { margin: 0 0 7px; font-size: 12px; color: #475467; text-transform: uppercase; letter-spacing: .03em; }
.procurement-detail p { margin: 4px 0; font-size: 13px; }
.recommendation { padding: 10px !important; border-radius: 6px; background: #eff6ff; }
.recommendation.resolved { background: #f0fdf4; }
.offer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 0 0 8px; }
.offer-grid div { min-width: 0; }
.offer-grid dt { color: var(--muted); font-size: 11px; }
.offer-grid dd { margin: 2px 0 0; overflow-wrap: anywhere; font-size: 12px; }
.procurement-detail .procurement-decision-form { grid-column: 1 / -1; }
.decision-error { grid-column: 1 / -1; color: #b42318; font-size: 12px; }
.decision-field[hidden] { display: none; }
.decision-field input[aria-invalid="true"] { border-color: #dc2626; }

.issue-table-wrap {
  max-height: 460px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.issue-table {
  min-width: 1280px;
}

.issue-table tr {
  cursor: default;
}

.issue-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.issue-table td {
  font-size: 13px;
}

.issue-table .subtle {
  display: block;
  margin-top: 3px;
}

.issue-decision-row td {
  padding-top: 0;
  background: #fbfcfe;
  border-top: 0;
}

.issue-main-row + .issue-decision-row td {
  border-bottom: 1px solid var(--line);
}

.decision-row-title {
  margin-bottom: 6px;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.procurement-decision-form {
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) repeat(5, minmax(120px, 1fr)) 1.4fr;
  gap: 6px;
  align-items: end;
}

.procurement-decision-form input,
.procurement-decision-form select,
.procurement-decision-form button {
  width: 100%;
  height: 28px;
  min-width: 0;
  padding: 0 7px;
  font-size: 12px;
}

.decision-check {
  display: inline-flex;
  align-items: center;
  height: 28px;
  gap: 6px;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.decision-check input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.procurement-decision-form input:disabled {
  color: #98a2b3;
  cursor: not-allowed;
  background: #f2f4f7;
  border-color: #e4e7ec;
}

.decision-field {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.decision-field span {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.decision-field.disabled span {
  color: #98a2b3;
}

.decision-hint {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.settings-page {
  margin-top: 14px;
}

.settings-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.settings-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.settings-panel.wide,
.settings-actions {
  grid-column: 1 / -1;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h2 {
  font-size: 18px;
}

.section-head p,
#settingsStatus,
#executorStatus {
  color: var(--muted);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(170px, 1fr));
  gap: 10px;
}

.settings-grid label {
  min-width: 0;
}

.settings-grid input,
.settings-grid textarea,
.settings-grid select {
  width: 100%;
}

.economics-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.economics-result {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

.economics-result span,
.economics-result small {
  color: var(--muted);
}

.economics-result strong {
  font-size: 18px;
}

.formula-panel {
  overflow: hidden;
  background: #fbfcfe;
}

.formula-details {
  padding: 0;
}

.formula-details summary {
  margin: 0;
  padding: 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.formula-details summary::-webkit-details-marker {
  display: none;
}

.formula-details summary::after {
  margin-left: auto;
  color: var(--accent);
  content: "Раскрыть  ▾";
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.formula-details[open] summary::after {
  content: "Свернуть  ▴";
}

.formula-details summary > span {
  display: grid;
  gap: 2px;
}

.formula-details summary h2,
.formula-details summary p {
  margin: 0;
}

.formula-content {
  display: grid;
  gap: 14px;
  padding: 0 14px 14px;
}

.formula-main {
  display: grid;
  gap: 8px;
}

.formula-main code {
  display: block;
  padding: 10px 12px;
  border: 1px solid #d7e3ea;
  border-radius: 6px;
  background: #eef6f9;
  color: #233642;
  font-size: 14px;
  white-space: normal;
}

.formula-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.formula-grid section {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.formula-grid h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #344054;
}

.formula-grid dl {
  display: grid;
  gap: 7px;
  margin: 0;
}

.formula-grid dt {
  font-weight: 700;
  color: var(--text);
}

.formula-grid dd {
  margin: -5px 0 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.supplier-options {
  min-width: 220px;
}

.supplier-checkboxes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
}

.supplier-checkbox {
  min-height: 24px;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.rezonit-tables {
  display: grid;
  gap: 14px;
}

.rezonit-rate-input {
  width: 100%;
  min-width: 90px;
  max-width: 150px;
  font-size: 14px;
  text-align: right;
}

.formula-details .rezonit-tables {
  padding: 0 14px 14px;
}

.rezonit-table-block h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.compact-table {
  overflow-x: auto;
}

.compact-table table {
  min-width: 720px;
}

.gerber-viewer {
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}

.gerber-viewer-head {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.gerber-view-presets {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.gerber-view-presets button {
  width: auto;
  min-width: 58px;
  height: 34px;
  min-height: 30px;
  padding: 4px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.gerber-view-presets button.active {
  background: #e5f2f7;
  color: var(--accent);
}

.gerber-viewer-head h3,
.gerber-viewer-head p {
  margin: 0 0 6px;
}

.gerber-viewer-head p {
  color: var(--muted);
  font-size: 13px;
}

.gerber-marker-switches {
  flex-basis: 100%;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.gerber-viewer-body {
  display: grid;
  grid-template-columns: minmax(210px, 280px) minmax(360px, 1fr);
  gap: 14px;
  margin-top: 10px;
}

.gerber-layer-controls {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 520px;
  overflow: auto;
}

.gerber-layer-toggle {
  display: grid;
  grid-template-columns: 18px 12px 1fr;
  gap: 7px;
  align-items: start;
  padding: 5px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.gerber-layer-swatch {
  width: 10px;
  height: 10px;
  margin-top: 3px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 50%;
}

.gerber-layer-type {
  grid-column: 2 / -1;
  width: 100%;
  min-width: 0;
  font-size: 12px;
}

.gerber-layer-opacity {
  grid-column: 2 / -1;
  width: 100%;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.gerber-viewport {
  min-height: 340px;
  max-height: 620px;
  overflow: auto;
  border: 1px solid #29354a;
  border-radius: 8px;
  background-color: #101722;
  background-image: linear-gradient(45deg, #151f2d 25%, transparent 25%), linear-gradient(-45deg, #151f2d 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #151f2d 75%), linear-gradient(-45deg, transparent 75%, #151f2d 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.gerber-board-stage {
  position: relative;
  width: 100%;
  min-width: 360px;
}

.gerber-layer-image,
.gerber-marker-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.gerber-layer-image {
  object-fit: contain;
}

.gerber-marker-layer {
  pointer-events: none;
}

.gerber-marker {
  position: absolute;
  box-sizing: border-box;
  min-width: 7px;
  min-height: 7px;
  border: 2px solid;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 4px #000;
}

.gerber-marker-layer.smd .gerber-marker {
  border-color: #00e5ff;
  background: rgba(0, 229, 255, 0.12);
}

.gerber-marker-layer.tht .gerber-marker {
  border-color: #ffb020;
  border-style: dashed;
  background: rgba(255, 176, 32, 0.08);
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .project-details-row .details-content {
    width: calc(100vw - 72px);
    max-width: calc(100vw - 72px);
  }

  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .gerber-viewer-body {
    grid-template-columns: 1fr;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .settings-layout {
    grid-template-columns: 1fr;
  }

  .formula-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 12px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .actions {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    overflow-x: auto;
  }

  table {
    min-width: 760px;
  }

  .project-details-row .details-content {
    width: calc(100vw - 40px);
    max-width: calc(100vw - 40px);
  }

  .procurement-tools {
    grid-template-columns: 1fr;
  }

  .procurement-decision-form {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .procurement-item summary { grid-template-columns: 1fr 1fr; }
  .row-state { justify-self: start; }
  .procurement-detail { grid-template-columns: 1fr; }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .upload-help-grid {
    grid-template-columns: 1fr;
  }

  .upload-help summary::after {
    content: "▾";
  }

  .upload-help[open] summary::after {
    content: "▴";
  }
}
.procurement-detail .supplier-offers { margin-top: 12px; grid-column: 1 / -1; min-width: 0; }
.procurement-item .supplier-offers > summary { display: block; padding: 8px 0; }
.supplier-offer { padding: 10px; margin: 8px 0; border: 1px solid #d6dce5; border-radius: 8px; overflow-wrap: anywhere; }
.supplier-offer p { margin: 4px 0; }
.supplier-offer button { display: inline-block; width: auto; min-width: 160px; height: auto; min-height: 32px; margin: 8px; padding: 6px 12px; white-space: nowrap; }
.supplier-offer.unavailable { background: #fff1f0; }
.supplier-offer.weak { border-left: 4px solid #bd8500; }
.supplier-offer.exact { border-left: 4px solid #287b50; }
#purchase-list-summary { margin: 16px 0; padding: 14px; border: 1px solid #d6dce5; border-radius: 8px; background: #f5f8fb; }
#purchase-list-summary select { display: inline-block; width: auto; min-width: 130px; margin-left: 8px; }
#purchase-list-summary p { margin: 8px 0; }

.negotiation-panel { margin: 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
.negotiation-panel summary { cursor: pointer; font-weight: 600; }
.negotiation-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 12px 0; }
.negotiation-fields label { display: grid; gap: 6px; }
.negotiation-fields input { width: 100%; min-width: 0; box-sizing: border-box; }
.negotiation-prices { overflow-x: auto; margin-top: 12px; }
.negotiation-prices table { width: 100%; }
.negotiation-prices th, .negotiation-prices td { padding: 8px; }

.gerber-marker-layer.fine_pitch {
  z-index: 2;
}
.gerber-marker-layer.fine_pitch .gerber-marker {
  border-color: #ff4ee4;
  border-radius: 2px;
  background: rgba(255, 78, 228, 0.28);
  pointer-events: auto;
}
.gerber-fine-pitch-toggle {
  color: #b3239e;
}
.gerber-marker-switches small {
  flex-basis: 100%;
  max-width: 48rem;
  color: var(--muted);
}

.gerber-marker[title] {
  pointer-events: auto;
}

.gerber-viewer-head > div:first-child {
  flex: 1 1 200px;
  min-width: 0;
}
.gerber-marker-switches label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}
.gerber-marker-switches input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  margin: 0;
}
.gerber-marker-switches .gerber-fine-pitch-toggle {
  color: #b3239e;
}

#customerFields { min-width: 0; }
#customerFields label { display: grid; gap: 4px; margin-bottom: 8px; }
#customerFields input, #customerFields select { box-sizing: border-box; width: 100%; min-width: 0; }
#customerFields small { display: block; }

.gerber-viewer-options{display:flex;flex-wrap:wrap;gap:16px;width:100%}#gerberPreviewButton{width:auto;height:auto;min-height:36px;padding:8px 14px;white-space:normal}

.gerber-viewer-options.hidden,.gerber-viewer-body.hidden{display:none}
