:root {
  color-scheme: light;
  font-family: Arial, "Segoe UI", sans-serif;
  --win-face: #f0f0f0;
  --win-border: #9c9c9c;
  --win-shadow: #ffffff;
  --win-blue: #d8e9ff;
  --ink: #1d232b;
  --muted: #5c6672;
  --panel: #fbfbfb;
  --content-width: min(1720px, calc(100vw - 28px));
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #d7dce2;
  color: var(--ink);
  font-size: 15px;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

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

.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: inset 1px 1px 0 var(--win-shadow);
}

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

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

.hint-text {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  border: 1px inset var(--win-border);
  background: #98fb98;
  padding: 8px;
  overflow: auto;
  line-height: 1.28;
  white-space: pre-wrap;
}

.hint-preview {
  background: white;
  border: 1px inset var(--win-border);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.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 #777;
  background: #dfeafa;
  box-shadow: 2px 2px 8px rgb(0 0 0 / 30%);
}

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

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

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

.tip-next {
  min-height: 37px;
  background: linear-gradient(#d8ffd8, #8fff8f);
  font-weight: 700;
}

.tip-close {
  min-height: 37px;
  background: linear-gradient(#ffd5d5, #ff8d8d);
  font-weight: 700;
}

.top-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  grid-template-rows: repeat(2, minmax(42px, 1fr));
  gap: 4px;
  padding: 5px;
  min-height: 94px;
}

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

.file-picker {
  display: none;
}

.win-button,
.tab {
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid #7f7f7f;
  background: linear-gradient(#ffffff, #dfdfdf);
  box-shadow: inset 1px 1px 0 #ffffff;
  cursor: pointer;
  line-height: 1.15;
  white-space: normal;
}

.win-button:active,
.win-button.active,
.tab.active {
  background: var(--win-blue);
  box-shadow: inset 1px 1px 1px #8aa9c8;
}

.win-button.pdf-ready {
  background: #c0ffc0;
}

.win-button.pdf-blocked {
  background: #f08080;
}

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

.tab {
  border-radius: 0;
  min-width: 138px;
}

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

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

.tab-stack {
  min-width: 0;
}

.tab-page {
  width: 100%;
  max-width: none;
  min-height: calc(100vh - 146px);
  padding: 8px;
  background: var(--win-face);
  border: 1px solid var(--win-border);
}

.tech-grid {
  display: grid;
  grid-template-columns: minmax(430px, 0.9fr) minmax(470px, 1fr) minmax(360px, 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: 10px 10px 9px;
  min-width: 0;
}

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

.win-group legend {
  padding: 0 5px;
  font-weight: 700;
}

.common-group {
  grid-area: common;
}

.machine-group {
  grid-area: machine;
}

.win-group.battery-group {
  grid-area: battery;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
  gap: 5px 12px;
}

.connector-common {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 5px 12px;
}

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

.charger-group {
  grid-area: charger;
  align-self: start;
}

.win-group.comments-group {
  grid-area: comments;
}

.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;
}

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

.field {
  display: grid;
  grid-template-columns: minmax(128px, 36%) minmax(80px, 1fr);
  gap: 7px;
  align-items: center;
  min-width: 0;
  min-height: 25px;
}

.field-wide {
  grid-column: 1 / -1;
  grid-template-columns: 230px 1fr;
}

.field span,
.check {
  color: #111;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.15;
}

.field input,
.field select,
.field textarea,
.spec-text,
.control-text,
.placement-result,
.grid-box textarea,
.note-description {
  width: 100%;
  border: 1px inset var(--win-border);
  background: #fff;
  color: #111;
  min-width: 0;
  min-height: 25px;
  padding: 2px 5px;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

.check input {
  flex: 0 0 auto;
}

.is-hidden {
  display: none;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #e9e9e9;
  color: #777;
}

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

.calc-panel {
  grid-area: calc;
  padding: 10px;
  display: grid;
  gap: 5px;
  align-self: start;
}

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

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

.list-panel,
.preview-panel {
  padding: 8px;
  min-width: 0;
  overflow: auto;
}

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

.win-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 13px;
}

.win-table th,
.win-table td {
  border: 1px solid #b7b7b7;
  padding: 4px 6px;
  text-align: left;
  vertical-align: top;
}

.win-table th {
  background: #e8eef4;
  font-weight: 700;
}

.win-table tr.selected,
.win-table tbody tr:hover {
  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: 8px;
  background: var(--win-face);
  border: 1px solid var(--win-border);
  box-shadow: inset 1px 1px 0 var(--win-shadow);
}

.standard-section h3,
.grid-box h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.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;
}

.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: 8px;
  background: #c0c0c0;
  border: 1px solid var(--win-border);
  box-shadow: inset 1px 1px 0 var(--win-shadow);
}

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

.spec-top {
  grid-area: top;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 8px;
  align-items: center;
}

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

.spec-text,
.control-text {
  resize: none;
  white-space: pre;
  line-height: 1.35;
  overflow: auto;
  text-overflow: clip;
}

.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 inset var(--win-border);
}

.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 inset var(--win-border);
  overflow: auto;
}

.note-list li {
  padding: 8px;
  border-bottom: 1px solid #ddd;
}

.note-image {
  border: 1px inset var(--win-border);
  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 select {
  height: 24px;
  border: 1px inset var(--win-border);
  background: white;
}

.note-create-button {
  background: linear-gradient(#ffd5d5, #ff8d8d);
}

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

.note-message {
  padding: 6px 8px;
  border: 1px solid #c5a24f;
  background: #fff4c6;
}

.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;
}

.placeholder-row {
  color: #777;
}

.problem-description {
  border: 1px inset var(--win-border);
  background: white;
  resize: none;
  padding: 6px;
}

.problem-picture {
  border: 1px inset var(--win-border);
  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: #e0e0e0;
  border: 1px solid #888;
  box-shadow: 1px 1px 0 #fff inset;
}

.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 inset var(--win-border);
  background: white;
  font: 16px "Segoe UI", Arial, sans-serif;
  padding: 4px 6px;
}

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

.note-draft-images {
  min-height: 150px;
  max-height: 150px;
  overflow: auto;
  border: 1px inset var(--win-border);
  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 #d0d0d0;
  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;
  background: linear-gradient(#d8ffd8, #8fff8f);
}

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

.placement-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.placement-fill-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 8px;
  align-items: start;
}

.placement-fill-controls > .win-button,
.placement-fill-buttons {
  grid-column: 1 / -1;
}

.placement-fill-controls .win-group {
  margin: 0;
}

.placement-fill-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.placement-tables {
  display: grid;
  grid-template-columns: repeat(2, minmax(360px, 1fr));
  gap: 8px;
  max-height: 470px;
  overflow: auto;
}

.grid-box {
  padding: 8px;
}

.placement-table-box {
  min-width: 0;
  min-height: 170px;
  overflow: auto;
}

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

.placement-data-grid input {
  width: 100%;
  min-width: 90px;
  border: 1px inset var(--win-border);
  padding: 2px 4px;
}

.small-button {
  margin-top: 6px;
  min-height: 24px;
}

.icon-button {
  min-width: 24px;
  min-height: 22px;
  padding: 0 5px;
}

.placement-result {
  min-height: 180px;
  white-space: pre;
}

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

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

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

@media (max-width: 1200px) {
  .work-area.with-hints {
    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-fill-controls,
  .placement-tables {
    grid-template-columns: 1fr;
  }

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

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

  .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,
  .connector-common {
    grid-template-columns: 1fr;
  }

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

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