:root {
  color-scheme: light;
  font-family: Arial, "Segoe UI", sans-serif;
  --page-bg: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --surface-strong: #edf3f8;
  --win-face: #f7f9fc;
  --win-border: #b7c2cf;
  --win-shadow: #ffffff;
  --win-blue: #dcecff;
  --accent: #2f6fb2;
  --accent-soft: #d8e9ff;
  --accent-border: #93b9e3;
  --danger: #d96d6d;
  --danger-soft: #f4b8b8;
  --success: #45a66a;
  --success-soft: #dff3e5;
  --required: #c9862c;
  --required-soft: #fff8e8;
  --ink: #17202a;
  --muted: #566272;
  --panel: #fbfcfe;
  --border-soft: #d5dde7;
  --border-strong: #9facbb;
  --shadow-soft: 0 1px 2px rgb(21 33 48 / 8%);
  --content-width: min(1640px, calc(100vw - 28px));
  --placement-width: min(1880px, calc(100vw - 28px));
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
}

button,
input,
textarea {
  font: inherit;
}

#app {
  min-height: 100vh;
  padding: 8px 10px 12px;
}

.top-panel {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) 132px;
  gap: 8px;
  align-items: stretch;
  width: var(--content-width);
  max-width: none;
  margin: 0 auto 6px;
}

.hint-box,
.top-actions,
.win-group,
.calc-panel,
.list-panel,
.preview-panel,
.grid-box,
.note-columns,
.spec-top {
  background: var(--win-face);
  border: 1px solid var(--win-border);
  box-shadow: var(--shadow-soft);
}

.hint-box {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: calc(100vh - 116px);
  min-height: 560px;
  max-height: calc(100vh - 116px);
  padding: 10px;
  gap: 8px;
  position: sticky;
  top: 6px;
  align-self: start;
  overflow: hidden;
}

.hint-box > span {
  grid-column: 1 / -1;
  font-weight: 700;
  color: #1f2d3d;
}

.hint-text {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  border: 1px solid #a8d7a2;
  border-radius: 4px;
  background: #effbea;
  padding: 10px;
  overflow: auto;
  line-height: 1.42;
  white-space: pre-wrap;
}

.hint-text::placeholder {
  color: #5c7b58;
}

.hint-preview {
  background: white;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 8px;
}

.hint-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.tip-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 22%);
}

.tip-form {
  width: 535px;
  max-width: calc(100vw - 24px);
  min-height: 212px;
  padding: 14px 14px 4px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-soft);
  box-shadow: 0 12px 30px rgb(21 33 48 / 28%);
}

.tip-form textarea {
  width: 100%;
  height: 146px;
  resize: none;
  overflow: auto;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  background: white;
  color: #000;
  text-align: center;
  padding: 12px;
  line-height: 1.45;
}

.tip-buttons {
  display: grid;
  grid-template-columns: 160px 1fr 160px;
  gap: 8px;
  align-items: center;
  margin-top: 9px;
}

.tip-buttons b {
  color: #b3261e;
  font: 700 22px Arial, sans-serif;
  text-align: center;
}

.tip-next {
  min-height: 37px;
  border-color: #8dc7a0;
  background: linear-gradient(#f4fff7, var(--success-soft));
  font-weight: 700;
}

.tip-close {
  min-height: 37px;
  border-color: #d48d8d;
  background: linear-gradient(#fff7f7, var(--danger-soft));
  font-weight: 700;
}

.top-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  grid-template-rows: repeat(2, minmax(34px, 1fr));
  gap: 6px;
  padding: 7px;
  min-height: 78px;
}

.top-panel > input[type="date"] {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  background: #fff;
  padding: 0 8px;
  font-size: 15px;
  box-shadow: var(--shadow-soft);
}

.file-picker {
  display: none;
}

.win-button,
.tab {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: linear-gradient(#ffffff, #eef2f6);
  box-shadow: 0 1px 1px rgb(21 33 48 / 6%);
  cursor: pointer;
  line-height: 1.22;
  white-space: normal;
  color: var(--ink);
}

.primary-action {
  border-color: #7fb895;
  background: linear-gradient(#f8fff9, #dff3e5);
  font-weight: 700;
}

.win-button:active,
.win-button.active,
.tab.active {
  background: var(--win-blue);
  border-color: var(--accent-border);
  box-shadow: inset 0 1px 2px rgb(57 96 134 / 18%);
}

.win-button.pdf-ready {
  border-color: #8dc7a0;
  background: linear-gradient(#f4fff7, var(--success-soft));
}

.win-button.pdf-blocked {
  border-color: #d48d8d;
  background: linear-gradient(#fff7f7, var(--danger-soft));
}

.top-actions .win-button[data-action="save"],
.top-actions .win-button[data-action="load"] {
  background: linear-gradient(#ffffff, #edf4fb);
}

.capacity-workspace {
  display: grid;
  gap: 10px;
  min-height: calc(100vh - 168px);
  grid-template-rows: auto auto minmax(360px, 1fr);
}

.capacity-actions {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.1fr);
  gap: 18px;
}

.capacity-actions .win-button {
  min-height: 34px;
  font-size: 15px;
}

.capacity-calculate {
  border-color: #8dc7a0;
  background: linear-gradient(#f4fff7, #c9f1d3);
}

.capacity-workbook {
  border-color: #d6c666;
  background: linear-gradient(#fffef2, #fff59a);
}

.capacity-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(210px, 1fr));
  gap: 6px 18px;
  align-items: center;
}

.capacity-fields .field,
.capacity-fields .check {
  min-height: 34px;
}

.capacity-result {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 5px;
  min-height: 0;
  font-weight: 700;
}

.capacity-result textarea {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  border: 1px solid var(--border-strong);
  background: #fff;
  padding: 10px;
  font: 14px/1.45 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color: var(--text);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  width: 100%;
  max-width: none;
  padding-left: 4px;
  align-items: flex-end;
}

.tab {
  border-radius: 5px 5px 0 0;
  min-width: 138px;
  background: #edf2f7;
  border-color: #bdc8d5;
  border-bottom-color: var(--border-strong);
  box-shadow: none;
  color: #344457;
  font-weight: 500;
}

.tab.active {
  background: var(--surface);
  border-top: 2px solid var(--accent);
  border-bottom-color: var(--surface);
  color: #12395f;
  font-weight: 700;
  padding-top: 4px;
}

.work-area {
  display: grid;
  width: var(--content-width);
  max-width: none;
  margin: 0 auto;
  gap: 8px;
  align-items: start;
}

.work-area.placement-mode {
  width: var(--placement-width);
}

.work-area.with-hints {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
}

.tab-stack,
.tab-page,
.tech-grid {
  min-width: 0;
  max-width: 100%;
}

.tab-page {
  width: 100%;
  max-width: none;
  min-height: calc(100vh - 146px);
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-soft);
}

.tech-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1fr) minmax(0, 0.72fr);
  grid-template-areas:
    "common machine charger"
    "battery battery charger"
    "options options calc"
    "comments comments calc";
  gap: 8px;
  align-items: start;
}

.win-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  margin: 0;
  padding: 11px 12px 10px;
  min-width: 0;
  border-radius: 4px;
  border-top-color: var(--section-accent, var(--win-border));
  border-top-width: 2px;
}

.win-group.wide {
  grid-column: auto;
}

.win-group legend {
  padding: 0 7px;
  font-weight: 700;
  color: #24384e;
  background: var(--surface);
}

.win-group legend::before,
.grid-box h3::before,
.standard-section h3::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 12px;
  margin-right: 6px;
  border-radius: 2px;
  background: var(--section-accent, var(--accent-border));
  vertical-align: -1px;
}

.common-group {
  grid-area: common;
  --section-accent: #7aa2d4;
}

.machine-group {
  grid-area: machine;
  --section-accent: #70a5a0;
}

.win-group.battery-group {
  grid-area: battery;
  --section-accent: #7a9f6d;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
}

.battery-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.battery-row > :first-child {
  grid-column: 1;
}

.battery-row > :nth-child(2) {
  grid-column: 2;
}

.battery-connector-block {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.battery-connector-block:has(.field:not(.is-hidden), .check:not(.is-hidden)) {
  margin-top: 2px;
  padding: 6px 8px;
  border-left: 3px solid var(--accent-border);
  border-radius: 0 5px 5px 0;
  background: #f8fbff;
}

.win-group.options-group {
  grid-area: options;
  --section-accent: #b09a54;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 14px;
}

.charger-group {
  grid-area: charger;
  --section-accent: #9a83bd;
  align-self: start;
}

.win-group.comments-group {
  grid-area: comments;
  --section-accent: #a0a8b3;
}

.form-column {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
}

.form-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.machine-power-pair .field {
  grid-template-columns: minmax(135px, 58%) minmax(72px, 1fr);
}

.dependent-stack {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.dependent-stack:has(.field:not(.is-hidden), .check:not(.is-hidden)) {
  margin: 1px 0 3px 18px;
  padding: 6px 8px 6px 10px;
  border-left: 3px solid var(--accent-border);
  border-radius: 0 5px 5px 0;
  background: #f8fbff;
}

.field {
  display: grid;
  grid-template-columns: minmax(150px, 0.42fr) minmax(180px, 1fr);
  gap: 8px 10px;
  align-items: center;
  min-width: 0;
  min-height: 32px;
}

.field-wide {
  grid-column: 1 / -1;
  grid-template-columns: minmax(220px, 0.28fr) minmax(260px, 1fr);
}

.field span,
.check {
  color: #1f2933;
  min-width: 0;
  overflow-wrap: break-word;
  line-height: 1.25;
}

.field input,
.combo-control > input,
.field textarea,
.spec-text,
.control-text,
.placement-result,
.grid-box textarea,
.note-description {
  width: 100%;
  border: 1px solid #aeb8c4;
  border-radius: 4px;
  background: #fff;
  color: #111;
  min-width: 0;
  min-height: 32px;
  padding: 5px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: inset 0 1px 2px rgb(21 33 48 / 5%);
}

.field.is-required.is-empty {
  margin-left: -5px;
  padding-left: 5px;
  border-left: 3px solid var(--required);
  border-radius: 4px;
  background: linear-gradient(90deg, var(--required-soft), rgb(255 255 255 / 0) 72%);
}

.field.is-required.is-empty span::after {
  content: " *";
  color: var(--required);
  font-weight: 700;
}

.field.is-required.is-empty input,
.field.is-required.is-empty textarea {
  border-color: #d4ad75;
  background: #fffdf8;
}

.combo-field:focus-within {
  position: relative;
  z-index: 40;
}

.combo-control {
  position: relative;
  min-width: 0;
}

.combo-control > input {
  padding-right: 36px;
}

.combo-toggle {
  position: absolute;
  z-index: 2;
  top: 1px;
  right: 1px;
  width: 31px;
  height: 30px;
  padding: 0;
  border: 0;
  border-left: 1px solid #c4ccd5;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(#fff, #eef2f6);
  color: #344454;
  font-size: 16px;
  line-height: 28px;
  cursor: pointer;
}

.combo-toggle:hover,
.combo-toggle:active {
  background: var(--accent-soft);
}

.combo-toggle:disabled {
  cursor: default;
  opacity: 0.5;
}

.combo-options {
  position: absolute;
  z-index: 80;
  top: calc(100% + 2px);
  left: 0;
  width: 100%;
  max-height: min(280px, 45vh);
  overflow: auto;
  border: 1px solid #7f8d9d;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 8px 20px rgb(21 33 48 / 24%);
}

.combo-options[hidden],
.combo-option[hidden],
.combo-empty[hidden] {
  display: none;
}

.combo-option {
  display: block;
  width: 100%;
  min-height: 30px;
  padding: 6px 8px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: #111;
  text-align: left;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.combo-option + .combo-option {
  border-top: 1px solid #edf0f3;
}

.combo-option:hover,
.combo-option.is-active {
  background: var(--accent-soft);
}

.combo-option[aria-selected="true"] {
  font-weight: 700;
}

.combo-empty {
  padding: 8px;
  color: var(--muted);
  text-align: center;
}

.field input:focus-visible,
.combo-control > input:focus-visible,
.field textarea:focus-visible,
.spec-text:focus-visible,
.control-text:focus-visible,
.placement-result:focus-visible,
.grid-box textarea:focus-visible,
.note-description:focus-visible,
.problem-description:focus-visible,
.placement-data-grid input:focus-visible,
.note-toolbar input:focus-visible,
.note-editor-field input:not([type="file"]):focus-visible,
.note-editor-field textarea:focus-visible,
.win-button:focus-visible,
.tab:focus-visible {
  outline: 2px solid rgb(47 111 178 / 28%);
  outline-offset: 1px;
  border-color: var(--accent);
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.common-group .field,
.machine-group .field,
.charger-group .field,
.calc-panel .field {
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.check {
  display: flex;
  gap: 6px;
  align-items: center;
  min-height: 32px;
  overflow-wrap: anywhere;
}

.check input {
  flex: 0 0 auto;
}

.is-hidden {
  display: none;
}

input:disabled,
textarea:disabled {
  background: #edf0f3;
  color: #7a8490;
}

input[readonly],
textarea[readonly] {
  background: #eef1f5;
}

.combo-control > input[data-combo-select]:not(:disabled) {
  background: #fff;
  color: #111;
  cursor: default;
}

.calc-panel {
  grid-area: calc;
  padding: 12px;
  display: grid;
  gap: 6px;
  align-self: start;
  background: #f6fbff;
  border-color: #bfd4e9;
  border-radius: 4px;
}

.calc-title {
  font-weight: 700;
}

.split-view {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 8px;
  height: 720px;
}

.list-panel,
.preview-panel {
  padding: 10px;
  min-width: 0;
  overflow: auto;
  border-radius: 4px;
}

.preview-panel iframe {
  width: 100%;
  height: 100%;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  background: #fff;
}

.win-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: white;
  font-size: 13px;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  overflow: hidden;
}

.win-table th,
.win-table td {
  border-right: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
  line-height: 1.32;
}

.win-table th:last-child,
.win-table td:last-child {
  border-right: 0;
}

.win-table tbody tr:last-child td {
  border-bottom: 0;
}

.win-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef4fa;
  font-weight: 700;
  color: #23364a;
}

.win-table tr.selected,
.win-table tbody tr:hover {
  background: var(--win-blue);
}

.win-table tbody tr:nth-child(even):not(.selected) td {
  background: #f8fafc;
}

.win-table tbody tr:hover td,
.win-table tr.selected td {
  background: var(--win-blue);
}

.standards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  height: calc(100vh - 166px);
  min-height: 610px;
}

.standard-section {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 10px;
  background: var(--win-face);
  border: 1px solid var(--win-border);
  border-top: 2px solid var(--section-accent, var(--win-border));
  border-radius: 4px;
  box-shadow: var(--shadow-soft);
}

.standard-section:nth-child(1) {
  --section-accent: #7a9f6d;
}

.standard-section:nth-child(2) {
  --section-accent: #7aa2d4;
}

.standard-section:nth-child(3) {
  --section-accent: #70a5a0;
}

.standard-section h3,
.grid-box h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #24384e;
}

.standard-table tbody tr {
  cursor: pointer;
}

.spec-layout {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) 320px;
  grid-template-rows: auto 1fr minmax(150px, 0.34fr);
  grid-template-areas:
    "spec top"
    "spec master"
    "spec control";
  gap: 8px;
  height: calc(100vh - 166px);
  min-height: 650px;
  min-width: 0;
}

.spec-master-panel {
  grid-area: master;
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.spec-tool-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border-soft);
  border-top: 2px solid var(--section-accent, var(--border-soft));
  border-radius: 4px;
  box-shadow: var(--shadow-soft);
}

.spec-tool-panel:nth-child(1) {
  --section-accent: #7aa2d4;
}

.spec-tool-panel:nth-child(2) {
  --section-accent: #9a83bd;
}

.spec-tool-panel:nth-child(3) {
  --section-accent: #b09a54;
}

.spec-tool-panel .field {
  grid-template-columns: 1fr;
}

.spec-top {
  grid-area: top;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px;
  align-items: center;
  min-width: 0;
  border-radius: 4px;
}

.spec-top .field {
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.spec-layout > .note-message {
  grid-column: 1 / -1;
}

.spec-text,
.control-text {
  resize: none;
  white-space: pre;
  line-height: 1.45;
  overflow: auto;
  text-overflow: clip;
  padding: 10px 12px;
}

.spec-text {
  grid-area: spec;
  font-size: 15px;
}

.control-text {
  grid-area: control;
  min-height: 0;
}

.spec-locked {
  background: #d3d3d3;
}

.notes-view {
  display: grid;
  gap: 8px;
}

.note-toolbar {
  display: flex;
  gap: 8px;
}

.note-toolbar input {
  width: 220px;
  border: 1px solid #aeb8c4;
  border-radius: 4px;
  padding: 4px 7px;
}

.note-columns {
  display: grid;
  grid-template-columns: 300px 1fr 320px;
  min-height: 620px;
  padding: 8px;
  gap: 8px;
}

.note-columns.norms-view {
  grid-template-columns: minmax(420px, 1.4fr) minmax(320px, 1fr) 260px;
}

.note-list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: white;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  overflow: auto;
}

.note-list li {
  padding: 8px;
  border-bottom: 1px solid var(--border-soft);
}

.note-image {
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  background: white;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  color: var(--muted);
}

.note-table tbody tr {
  cursor: pointer;
}

.problem-notes-view {
  display: grid;
  gap: 8px;
}

.problem-note-toolbar {
  display: grid;
  grid-template-columns: 60px 165px 189px 189px 1fr;
  align-items: center;
  gap: 7px;
  min-height: 32px;
}

.problem-note-toolbar .combo-control {
  width: 165px;
}

.problem-note-toolbar .combo-control:focus-within {
  z-index: 40;
}

.placeholder-row,
.table-empty-state,
.hint-text:placeholder-shown,
.spec-text:placeholder-shown,
.placement-result:placeholder-shown {
  color: #6f7b88;
}

.note-create-button {
  border-color: #d48d8d;
  background: linear-gradient(#fff7f7, var(--danger-soft));
}

.note-report-button {
  display: none;
}

.note-message {
  padding: 8px 10px;
  border: 1px solid #d6b75c;
  border-radius: 4px;
  background: #fff7d7;
}

.problem-notes-grid {
  display: grid;
  grid-template-columns: minmax(360px, 428px) minmax(440px, 533px);
  grid-template-rows: 176px 447px;
  gap: 6px;
}

.problem-files-list,
.problem-images-list,
.problem-description,
.problem-picture {
  width: 100%;
  height: 100%;
}

.problem-files-list,
.problem-images-list {
  display: block;
  overflow: auto;
}

.problem-files-list tbody tr,
.problem-images-list tbody tr {
  cursor: pointer;
}

.problem-description {
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  background: white;
  resize: none;
  padding: 10px;
  line-height: 1.45;
}

.problem-picture {
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  background: white;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.problem-picture img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.problem-note-actions,
.note-editor-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.note-editor-panel {
  width: min(580px, 100%);
  min-height: 530px;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  box-shadow: var(--shadow-soft);
}

.note-editor-panel h3 {
  margin: 0 0 10px;
  font: 600 16px "Segoe UI", Arial, sans-serif;
}

.note-editor-field {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

.note-editor-field span {
  font: 14px "Segoe UI", Arial, sans-serif;
}

.note-editor-field input:not([type="file"]),
.note-editor-field textarea {
  width: 100%;
  border: 1px solid #aeb8c4;
  border-radius: 4px;
  background: white;
  font: 16px "Segoe UI", Arial, sans-serif;
  padding: 7px 8px;
}

.note-editor-field textarea {
  resize: vertical;
  min-height: 150px;
}

.note-draft-images {
  min-height: 150px;
  max-height: 150px;
  overflow: auto;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  background: white;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 6px;
}

.note-draft-image {
  display: grid;
  grid-template-rows: 82px auto 24px;
  gap: 4px;
  align-items: center;
  justify-items: center;
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 4px;
}

.note-draft-image img,
.note-draft-image span {
  width: 82px;
  height: 82px;
  object-fit: contain;
  background: #f4f4f4;
}

.note-draft-image b {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
  font-size: 12px;
  text-align: center;
}

.note-editor-ok {
  min-width: 260px;
  min-height: 40px;
  border-color: #8dc7a0;
  background: linear-gradient(#f4fff7, var(--success-soft));
}

.placement-view {
  display: grid;
  gap: 10px;
  width: var(--placement-width);
  max-width: 100%;
  margin: 0 auto;
}

.placement-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  box-shadow: var(--shadow-soft);
}

.placement-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 7px;
}

.placement-workbench {
  display: grid;
  grid-template-columns: minmax(760px, 1fr) minmax(330px, 410px);
  gap: 10px;
  align-items: start;
}

.placement-main {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.placement-result-panel {
  position: sticky;
  top: 62px;
  display: grid;
  grid-template-rows: auto minmax(320px, calc(100vh - 230px));
  gap: 8px;
  min-width: 0;
  padding: 10px;
  background: var(--win-face);
  border: 1px solid var(--win-border);
  border-top: 2px solid #7aa2d4;
  border-radius: 6px;
  box-shadow: var(--shadow-soft);
}

.placement-result-title {
  font-weight: 700;
  color: #24384e;
}

.placement-tables {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
}

.grid-box {
  padding: 10px;
  border-radius: 4px;
  border-top: 2px solid var(--section-accent, var(--win-border));
}

.placement-table-box {
  --section-accent: #8da6c1;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  align-self: start;
  overflow: hidden;
}

.placement-table-header {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.placement-table-header h3 {
  margin: 0;
}

.placement-table-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.placement-local-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: 8px;
  align-items: end;
  min-width: 0;
  padding: 8px;
  border: 1px solid #c9d5e2;
  border-radius: 5px;
  background: #f8fbff;
}

.placement-local-controls .field {
  grid-template-columns: 1fr;
  gap: 4px;
  min-height: 0;
}

.placement-local-controls .field span {
  font-weight: 600;
}

.placement-local-controls .win-button {
  min-height: 42px;
}

.placement-table-box:nth-child(4n + 1) {
  --section-accent: #7aa2d4;
}

.placement-table-box:nth-child(4n + 2) {
  --section-accent: #70a5a0;
}

.placement-table-box:nth-child(4n + 3) {
  --section-accent: #b09a54;
}

.placement-table-box:nth-child(4n + 4) {
  --section-accent: #9a83bd;
}

.placement-table-scroll {
  min-width: 0;
  min-height: 0;
  max-height: min(520px, calc(100vh - 250px));
  overflow: auto;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  background: #fff;
}

.placement-table-body {
  display: grid;
  grid-template-rows: auto auto;
  gap: 6px;
  min-height: 0;
}

.placement-table-scroll .win-table {
  border: 0;
  border-radius: 0;
}

.placement-data-grid th,
.placement-data-grid td {
  padding: 4px 6px;
  vertical-align: middle;
}

.table-empty-state {
  padding: 6px 8px;
  border: 1px dashed #c8d2dd;
  border-radius: 4px;
  background: #fbfcfe;
  font-size: 13px;
  line-height: 1.35;
}

.grid-box textarea {
  min-height: 110px;
  resize: vertical;
}

.placement-data-grid input {
  width: 100%;
  min-width: 132px;
  min-height: 28px;
  border: 1px solid #aeb8c4;
  border-radius: 3px;
  padding: 3px 7px;
}

.placement-data-grid input[data-column="Наименование"],
.placement-data-grid input[data-column="Тип ячеек"],
.placement-data-grid input[data-column="Номер сборки"] {
  min-width: 260px;
}

.placement-data-grid input[data-column="кол."],
.placement-data-grid input[data-column="ед."],
.placement-data-grid input[data-column="сечение, мм²"],
.placement-data-grid input[data-column="длина, мм"],
.placement-data-grid input[data-column="Длина, мм."],
.placement-data-grid input[data-column="Ширина, мм."],
.placement-data-grid input[data-column="Высота, мм."] {
  min-width: 112px;
}

.small-button {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 13px;
}

.icon-button {
  min-width: 30px;
  min-height: 26px;
  padding: 0 7px;
}

.placement-result {
  height: 100%;
  min-height: 320px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
  resize: vertical;
  line-height: 1.45;
  padding: 10px 12px;
}

@media (max-width: 1650px) {
  .work-area.with-hints {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 310px);
  }

  .work-area.with-hints .tech-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.82fr);
    grid-template-areas:
      "common machine"
      "battery battery"
      "options options"
      "charger calc"
      "comments comments";
  }

  .work-area.with-hints .common-group .form-pair,
  .work-area.with-hints .machine-group .form-pair {
    grid-template-columns: 1fr;
  }

  .machine-power-pair {
    grid-template-columns: 1fr;
  }

  .machine-power-pair .field {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1500px) {
  .standards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .placement-workbench {
    grid-template-columns: minmax(0, 1fr);
  }

  .placement-result-panel {
    position: static;
    grid-template-rows: auto minmax(260px, 38vh);
  }
}

@media (max-width: 1200px) {
  .work-area.with-hints {
    grid-template-columns: minmax(0, 1fr);
  }

  .tech-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "common"
      "machine"
      "battery"
      "options"
      "charger"
      "calc"
      "comments";
  }

  .win-group.battery-group,
  .win-group.options-group {
    grid-template-columns: 1fr;
  }

  .hint-box {
    position: static;
    height: min(620px, calc(100vh - 80px));
    min-height: 480px;
    max-height: none;
  }
}

@media (max-width: 900px) {
  .top-panel,
  .work-area.with-hints,
  .tech-grid,
  .split-view,
  .spec-layout,
  .note-columns,
  .problem-note-toolbar,
  .problem-notes-grid,
  .placement-tables,
  .placement-workbench,
  .placement-table-header {
    grid-template-columns: 1fr;
  }

  .placement-toolbar,
  .placement-result-panel {
    position: static;
  }

  .placement-table-actions {
    justify-content: stretch;
  }

  .placement-table-actions .win-button {
    flex: 1 1 138px;
  }

  .win-group.wide,
  .spec-top,
  .calc-panel {
    grid-column: auto;
  }

  .top-actions,
  .spec-top,
  .capacity-actions,
  .capacity-fields {
    grid-template-columns: 1fr;
  }

  .capacity-fields > span:empty {
    display: none;
  }

  .spec-layout {
    grid-template-areas:
      "top"
      "spec"
      "control"
      "master";
    grid-template-rows: auto minmax(420px, 1fr) minmax(150px, auto) auto;
    height: auto;
  }

  .field,
  .field-wide {
    grid-template-columns: 1fr;
  }

  .tech-grid {
    grid-template-areas:
      "common"
      "machine"
      "battery"
      "options"
      "charger"
      "calc"
      "comments";
  }

  .battery-group,
  .options-group,
  .battery-row {
    grid-template-columns: 1fr;
  }

  .battery-row > :first-child,
  .battery-row > :nth-child(2) {
    grid-column: 1;
  }

  .placement-result {
    min-height: 260px;
  }

  .problem-notes-grid {
    grid-template-rows: none;
  }

  .standards-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
}
