:root {
  --bg: #f4f5f7;
  --panel: #fff;
  --line: #d4d7dc;
  --text: #1b1d21;
  --muted: #6b7078;
  --accent: #1d5fd1;
  --changed: #fff3c4;
  --error: #b3261e;
  font: 13px system-ui, sans-serif;
  color: var(--text);
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  background: var(--bg);
  display: grid;
  grid-template-rows: auto 1fr minmax(120px, 30vh) auto;
  overflow: hidden;
}
header {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  padding: 6px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
header .grow {
  flex: 1;
}
header .sep {
  width: 1px;
  height: 20px;
  background: var(--line);
}
button,
select {
  font: inherit;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}
button:hover:not(:disabled) {
  border-color: var(--accent);
}
button:disabled {
  color: var(--muted);
}
#servers {
  max-width: 220px;
}
.muted {
  color: var(--muted);
}
main {
  display: grid;
  grid-template-columns: 1fr 300px;
  min-height: 0;
}
#center {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  min-width: 0;
}
#tabs {
  display: flex;
  flex-wrap: wrap;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
#tabs button {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 6px 12px;
  background: none;
}
#tabs button.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}
#views {
  position: relative;
  min-height: 0;
}
.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.view[hidden] {
  display: none;
}
.surface {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: block;
}
.view.split .pane {
  flex: 1;
  display: flex;
  min-height: 0;
  border-bottom: 1px solid var(--line);
}
.viewbar {
  padding: 4px 8px;
}
.overlay {
  position: absolute;
  top: 6px;
  left: 8px;
  color: var(--muted);
  pointer-events: none;
}
.tableview {
  padding: 6px;
}
.caption {
  padding: 4px 2px 8px;
}
.scroll {
  overflow: auto;
  min-height: 0;
  flex: 1;
}
#system {
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow: auto;
  padding: 0 10px;
}
.system table {
  width: 100%;
  table-layout: fixed;
}
.system table td {
  padding: 2px 4px;
  vertical-align: top;
  overflow-wrap: anywhere;
}
.system table td:first-child {
  width: 55%;
}
#lens {
  display: flex;
  background: var(--panel);
  border-top: 1px solid var(--line);
  min-height: 0;
}
table.grid {
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
table.grid th,
table.grid td {
  border: 1px solid var(--line);
  padding: 2px 6px;
  white-space: nowrap;
}
table.grid th {
  background: #eef0f3;
  position: sticky;
  top: 0;
}
td.num {
  text-align: right;
}
tr.stop td {
  font-weight: bold;
}
tr.cb td {
  color: var(--muted);
}
td.edit {
  padding: 0;
}
.lensopt {
  display: block;
  padding: 2px 6px;
  font-size: 12px;
  color: var(--muted);
}
.lensopt input {
  vertical-align: middle;
}
/* Промежутки между поверхностями (толщина, материал): в режиме сдвига содержимое опущено на полстроки,
   строчные границы этих столбцов — у сдвинутых ячеек. */
table.grid.staggered td.gap {
  padding: 0;
  border-top-color: transparent;
  border-bottom-color: transparent;
}
table.grid.staggered td.gap > .gapv {
  padding: 2px 6px;
  transform: translateY(calc(var(--rowh, 22px) / 2));
  border-bottom: 1px solid var(--line);
}
table.grid.staggered td.edit.gap > .gapv {
  padding: 0;
}
table.grid.staggered tbody tr:first-child td.gap > .gapv {
  border-top: 1px solid var(--line);
  margin-top: -1px;
}
table.grid.staggered tbody tr:last-child td.gap > .gapv {
  visibility: hidden;
}
td.edit input {
  width: 100%;
  min-width: 90px;
  border: none;
  padding: 2px 6px;
  text-align: right;
  font: inherit;
  background: transparent;
}
td.edit input:focus {
  outline: 2px solid var(--accent);
}
td.changed {
  background: var(--changed);
}
footer {
  padding: 4px 10px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
footer.error {
  color: var(--error);
}
body.with-assistant main {
  grid-template-columns: 1fr 260px 380px;
}
#assist.active {
  border-color: var(--accent);
  color: var(--accent);
}
#assistant {
  background: var(--panel);
  border-left: 1px solid var(--line);
  min-height: 0;
  min-width: 0;
}
#assistant[hidden],
#optimize[hidden],
#feedback[hidden] {
  display: none;
}
#feedback {
  background: var(--panel);
  border-left: 1px solid var(--line);
  min-height: 0;
  min-width: 0;
  overflow: auto;
}
.feedback {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
}
.feedback h2 {
  margin: 0;
  font-size: 15px;
}
.feedback .fb-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.feedback .fb-text {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  font: inherit;
}
.feedback .fb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.feedback .fb-shots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.feedback .fb-shots img {
  width: 96px;
  height: 64px;
  object-fit: cover;
  border: 1px solid var(--line);
  cursor: pointer;
}
.feedback .fb-status {
  font-size: 12px;
  color: var(--muted);
  min-height: 1em;
}
.feedback .fb-status.bad {
  color: var(--err, #c0392b);
}
#optimize {
  background: var(--panel);
  border-left: 1px solid var(--line);
  min-height: 0;
  min-width: 0;
  overflow: auto;
}
.optimize .oform {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
}
.optimize .oform label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.optimize .obuttons input {
  width: 4em;
}
.optimize .obuttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.optimize .oset label,
.optimize .ostockhead {
  flex-wrap: wrap;
}
.optimize > .muted {
  padding: 0 8px;
}
.otable,
.tol table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}
.otable th,
.tol table th {
  text-align: left;
  font-weight: normal;
  color: var(--muted, #888);
}
.otable td,
.tol table td {
  padding: 1px 2px;
}
.otable input,
.tol table input {
  width: 3.4em;
  min-width: 0;
  padding: 1px 2px;
}
.otable td:first-child select {
  max-width: 7.5em;
}
.oscroll {
  overflow-x: auto;
}
.otable select {
  max-width: 9em;
}
.otable input.oparam {
  width: 7em;
}
.otable .ovalue {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ovars input[type='checkbox'] {
  width: auto;
  height: auto;
  margin: 0;
}
.ovars label {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.ovars {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5em, 1fr));
  gap: 2px 8px;
  max-height: 14em;
  overflow: auto;
  font-size: 12px;
}
.oset {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  max-height: 10em;
  overflow: auto;
}
.oset label {
  display: flex;
  align-items: center;
  gap: 4px;
}
.oset input[type='checkbox'] {
  width: auto;
  margin: 0;
}
.oset input[type='number'] {
  width: 3.5em;
}
.ostockhead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 12px;
}
.ostockhead select {
  max-width: 14em;
}
.ostockhead .otol {
  width: 3.5em;
}
.ostock {
  margin: 4px 8px;
  padding-left: 2.2em;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  max-height: 12em;
  overflow: auto;
}
.ostock button {
  padding: 0 6px;
  font-size: 11px;
}
.olog {
  margin: 6px 8px;
  padding-left: 2.2em;
  font-variant-numeric: tabular-nums;
}
.assistant {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.ahead {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.ahead .grow {
  flex: 1;
}
.alog {
  flex: 1;
  overflow: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.auser {
  align-self: flex-end;
  background: #e6eefc;
  border-radius: 8px;
  padding: 5px 9px;
  max-width: 85%;
  white-space: pre-wrap;
}
.abot .atext {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.atools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 3px;
}
.chip {
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 7px;
  color: var(--muted);
}
.chip.ok {
  border-color: #6aa46a;
}
.chip.bad {
  border-color: var(--error);
  color: var(--error);
}
.aerr {
  color: var(--error);
}
.ainput {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid var(--line);
}
.ainput textarea {
  flex: 1;
  font: inherit;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 6px;
}
.mic.rec {
  background: #fde2e1;
  border-color: var(--error);
}
@media (max-width: 900px) {
  body.with-assistant main {
    grid-template-columns: 1fr;
  }
  body.with-assistant #center {
    display: none;
  }
  main {
    grid-template-columns: 1fr;
  }
  #system {
    display: none;
  }
}
.layoutbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: center;
}
.layoutbar input[type='number'] {
  width: 4.5em;
  margin-left: 4px;
}
.layoutbar select {
  margin-left: 4px;
}
.layouthost {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}
/* Допуски (web/src/tolerance.ts) */
.optimize .tol {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line, #ccc);
}
.tol .obuttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.tol .obuttons input[type='number'] {
  width: 4.5em;
}
.tol .oscroll {
  max-height: 14em;
  overflow-y: auto;
}
.tol table {
  table-layout: fixed;
}
.tol table select {
  max-width: 100%;
}
.tol table input {
  width: 100%;
  box-sizing: border-box;
}
.tol .ttable th:last-child,
.tol .ttable td:last-child {
  width: 2em;
}
.tol .tworst td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tol .tworst td {
  font-variant-numeric: tabular-nums;
}
.tol .tmc {
  font-size: 12px;
}
.tol input.narrowed {
  outline: 1px solid var(--accent);
  color: var(--accent);
}
.tol .tlimit {
  width: 6em;
}
.optimize .ostarts {
  width: 4.5em;
}
.optimize .osubst {
  width: 5em;
}
.oglobal li button {
  margin-left: 6px;
}
