:root {
  --b24-blue: #2fc6f6;
  --b24-blue-dark: #1aa8d8;
  --text: #172b4d;
  --muted: #6b7a90;
  --line: #dbe4ef;
  --panel: #ffffff;
  --bg: #eef3f8;
  --ok: #16a34a;
  --bad: #d92d20;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Helvetica Neue", sans-serif;
  font-size: 14px;
}

.layout {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 22px;
  margin-bottom: 16px;
}

.topbarActions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbarActions button.primary {
  min-width: 190px;
}

h1,
h2 {
  margin: 0;
  font-weight: 600;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 17px;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

.entityMetaLink {
  margin-left: 12px;
  color: #0b79b7;
  text-decoration: none;
}

.entityMetaLink:hover {
  text-decoration: underline;
}

.status {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 10px;
  min-width: 190px;
  text-align: center;
  background: #f8fbfe;
}

.panel {
  padding: 20px;
  margin-bottom: 16px;
}

.settingsBlock {
  padding: 0;
}

.blockHead {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.settingsBlock .grid {
  padding: 18px 20px 0;
}

.settingsBlock .grid:last-child {
  padding-bottom: 20px;
}

.numberingGrid {
  align-items: start;
}

.fieldStack {
  display: grid;
  gap: 16px;
}

.blockActions {
  display: flex;
  justify-content: flex-start;
  padding: 0 20px 20px;
}

.generatorPanel {
  padding: 0;
}

.generatorHead {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.generatorPanel .grid {
  padding: 18px 20px 0;
}

.serviceBlock h2 {
  margin-bottom: 14px;
}

.fieldHint {
  margin: -4px 20px 20px;
  color: var(--muted);
}

.offerLayoutSection {
  margin: 18px 20px 0;
}

.offerLayoutSection h3,
.signatureSettings h3 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 14px;
}

.signatureSettings {
  margin: 18px 20px 0;
}

.signatureSettings .grid {
  padding: 0;
}

.signatureAssetRow {
  display: grid;
  grid-template-columns: minmax(180px, 280px) auto;
  gap: 10px;
  align-items: start;
}

.signatureUploadRow {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.signatureUploadRow .button,
.signatureUploadRow button {
  width: 120px;
  text-align: center;
}

.signaturePreviewBox {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8fbfe;
  color: var(--muted);
}

.signaturePreviewBox img {
  display: block;
  max-width: 100%;
  max-height: 105px;
  object-fit: contain;
}

.layoutTableWrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.layoutTable {
  width: 100%;
  min-width: 1290px;
  table-layout: fixed;
  border-collapse: collapse;
}

.layoutTable th,
.layoutTable td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  text-align: left;
}

.layoutTable tr:last-child td {
  border-bottom: 0;
}

.layoutTable th {
  background: #f5f8fb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.layoutTable .layoutLabel {
  width: 205px;
  color: var(--text);
}

.layoutTable input,
.layoutTable select {
  min-width: 0;
  width: 100%;
}

.layoutTable th:nth-child(2),
.layoutTable td:nth-child(2),
.layoutTable th:nth-child(9),
.layoutTable td:nth-child(9) {
  width: 72px;
}

.layoutTable th:nth-child(3),
.layoutTable th:nth-child(4),
.layoutTable th:nth-child(5),
.layoutTable th:nth-child(6),
.layoutTable td:nth-child(3),
.layoutTable td:nth-child(4),
.layoutTable td:nth-child(5),
.layoutTable td:nth-child(6) {
  width: 90px;
}

.layoutTable th:nth-child(7),
.layoutTable th:nth-child(8),
.layoutTable td:nth-child(7),
.layoutTable td:nth-child(8) {
  width: 96px;
}

.layoutTable th:nth-child(10),
.layoutTable th:nth-child(12),
.layoutTable td:nth-child(10),
.layoutTable td:nth-child(12) {
  width: 64px;
}

.layoutTable th:nth-child(11),
.layoutTable th:nth-child(13),
.layoutTable td:nth-child(11),
.layoutTable td:nth-child(13) {
  width: 96px;
}

.layoutTable input[type="color"] {
  min-width: 46px;
  height: 34px;
  padding: 2px;
}

.subhead {
  grid-column: 1 / -1;
  margin-bottom: -6px;
  color: var(--text);
  font-weight: 600;
}

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

.contractGrid,
.historyGrid {
  padding: 18px 20px 0;
}

.historyGrid {
  padding-bottom: 20px;
}

.historyList {
  margin: 0;
  padding: 10px 12px;
  min-height: 84px;
  border: 1px solid var(--line);
  background: #f8fbfe;
  color: var(--text);
}

.historyList li + li {
  margin-top: 7px;
}

.one {
  grid-template-columns: 1fr;
}

.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label span,
.fieldLike > span {
  display: block;
  color: var(--muted);
  margin-bottom: 7px;
}

label,
.fieldLike,
.fieldStack,
.multiSelect {
  min-width: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c8d4e2;
  border-radius: 3px;
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 9px 10px;
  min-height: 38px;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

select[multiple] {
  padding: 6px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #f8fbfe;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.check input {
  width: 18px;
  min-height: 18px;
}

.check span {
  margin: 0;
  color: var(--text);
}

.switchLine {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  color: var(--text);
  white-space: nowrap;
}

.switchLine input {
  width: 18px;
  min-height: 18px;
}

.switchLine span {
  margin: 0;
  color: var(--text);
}

.multiSelect {
  position: relative;
}

.filePickerActions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filePickerActions button {
  flex: 1 1 170px;
}

.selectedFiles {
  min-height: 38px;
  margin-top: 8px;
  padding: 9px 10px;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: #f8fbfe;
}

#specificationSelection {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.diskFileDialog {
  width: min(900px, calc(100vw - 56px));
}

.multiSelectButton {
  width: 100%;
  justify-content: flex-start;
  align-items: flex-start;
  min-height: 38px;
  height: auto;
  max-width: 100%;
  padding-top: 9px;
  padding-bottom: 9px;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.multiSelectButton::after {
  flex: 0 0 auto;
  content: "";
  width: 8px;
  height: 8px;
  margin-left: auto;
  margin-top: 4px;
  border-right: 1px solid #52627a;
  border-bottom: 1px solid #52627a;
  transform: rotate(45deg) translateY(-2px);
}

.multiSelectMenu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  background: #fff;
  border: 1px solid #b8c6d8;
  border-radius: 3px;
  box-shadow: 0 10px 26px rgba(23, 43, 77, 0.16);
}

.multiOption {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 8px;
  border-radius: 3px;
}

.multiOption:hover {
  background: #eef7fc;
}

.multiOption input {
  width: 16px;
  min-height: 16px;
}

.multiOption span {
  margin: 0;
  color: var(--text);
}

.multiOption small {
  color: var(--muted);
}

.picker {
  display: flex;
  gap: 8px;
}

.picker input {
  flex: 1;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid #b8c6d8;
  border-radius: 3px;
  padding: 0 14px;
  color: #24364f;
  background: #fff;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

button.primary {
  background: var(--b24-blue);
  border-color: var(--b24-blue-dark);
  color: #fff;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.secondary {
  margin-top: 12px;
}

.file input {
  display: none;
}

.notice {
  border-radius: 4px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.error {
  background: #fff1f0;
  border: 1px solid #ffccc7;
  color: #a8071a;
}

.ok {
  color: var(--ok);
}

.bad {
  color: var(--bad);
}

.hidden {
  display: none !important;
}

.panelHead {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.checkRow {
  display: grid;
  grid-template-columns: 220px 80px 1fr;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.folderModal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(9, 30, 66, 0.32);
}

.folderDialog {
  width: min(980px, calc(100vw - 56px));
  max-height: min(720px, calc(100vh - 56px));
  overflow: hidden;
  background: #fff;
  border: 1px solid #c6d2e2;
  border-radius: 6px;
  box-shadow: 0 18px 48px rgba(9, 30, 66, 0.28);
  padding: 18px;
}

.folderExplorer {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  min-height: 420px;
}

.folderExplorer aside,
.folderExplorer section {
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.folderSideTitle {
  padding: 10px 12px;
  background: #f5f8fb;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.storageList {
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 4px;
}

.storageItem {
  justify-content: flex-start;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 8px 10px;
}

.storageItem:hover {
  background: #eef7fc;
}

.folderToolbar {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  padding: 10px;
  background: #f5f8fb;
  border-bottom: 1px solid var(--line);
}

.folderList {
  max-height: 360px;
  overflow: auto;
}

.folderRow {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
}

.folderRow:hover {
  background: #f8fbfe;
}

.folderRow small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.folderIcon {
  color: #f0a400;
}

.folderEmpty {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.status.ok,
.status.successStatus {
  color: #208a39;
  background: #effaf1;
  border-color: #b9e4c2;
}

.status.statusLink {
  cursor: pointer;
  text-decoration: underline;
}

.primaryMini {
  background: var(--b24-blue);
  border-color: var(--b24-blue-dark);
  color: #fff;
}

.dangerMini {
  color: #c51f1f;
  border-color: #e7aaaa;
  background: #fff;
}

.drawingChips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.drawingChipsEmpty {
  color: var(--muted);
  font-size: 12px;
}

.drawingChip {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 28px 28px 28px;
  gap: 5px;
  align-items: center;
  min-height: 38px;
  padding: 4px 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #f8fbfe;
  cursor: grab;
}

.specificationChip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 5px;
  align-items: center;
  min-height: 38px;
  width: 100%;
  padding: 4px 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #f8fbfe;
}

.specificationChip .chipDelete {
  justify-self: end;
}

.drawingChip.dragging {
  opacity: 0.45;
}

.drawingIndex {
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  font-weight: 400;
  text-align: center;
}

.drawingName {
  min-width: 0;
  color: var(--text);
  overflow-wrap: anywhere;
  white-space: normal;
  line-height: normal;
  font-size: 14px;
  font-family: inherit;
  font-weight: 400;
}

.chipMove,
.chipDelete {
  min-width: 28px;
  width: 28px;
  height: 26px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.chipDelete {
  color: #c51f1f;
  border-color: #e7aaaa;
}

#openDiskFolderNative {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--b24-blue-dark);
  background: #fff;
  text-decoration: none;
  white-space: nowrap;
}

.wideField {
  grid-column: 1 / -1;
}

.generatorLayout {
  width: min(1120px, calc(100vw - 24px));
  padding-top: 14px;
}

.compactTopbar {
  padding: 14px 18px;
}

.priceEditor {
  display: grid;
  gap: 8px;
  padding: 18px 20px 12px;
}

.priceRow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px 72px;
  gap: 8px;
  align-items: center;
}

.priceName,
.priceValue {
  min-width: 0;
}

.removePriceRow {
  width: 72px;
}

.totalLine,
.vatRateLine {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px 72px;
  gap: 8px;
  align-items: center;
  padding: 0 20px 8px;
  color: var(--muted);
}

.totalLabel {
  width: 150px;
  justify-self: end;
  text-align: left;
}

.vatRateLine input {
  width: 100%;
  min-width: 0;
}

.totalSpacer {
  width: 72px;
  min-width: 72px;
}

.totalWithVatLine {
  padding-top: 0;
  padding-bottom: 18px;
  color: #d88916;
}

.totalLine strong {
  min-width: 0;
  text-align: left;
  color: var(--text);
  font-size: 18px;
}

.historyTable {
  padding: 0 20px 18px;
}

.historyHeader,
.historyRow {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 120px 100px;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
}

.historyHeader {
  color: var(--muted);
  font-weight: 600;
}

.historyRow a {
  color: #0b79b7;
  text-decoration: none;
}

@media (max-width: 820px) {
  .topbar,
  .panelHead,
  .blockHead {
    align-items: stretch;
    flex-direction: column;
  }

  .topbarActions {
    align-items: stretch;
    flex-direction: column;
  }

  .two,
  .one,
  .three {
    grid-template-columns: 1fr;
  }

  .switchLine {
    white-space: normal;
  }

  .folderRow,
  .priceRow,
  .historyHeader,
  .historyRow,
  .checkRow {
    grid-template-columns: 1fr;
  }

  .totalLine,
  .vatRateLine {
    grid-template-columns: minmax(0, 1fr) 170px;
  }

  .totalSpacer {
    display: none;
  }

  .folderExplorer,
  .folderToolbar {
    grid-template-columns: 1fr;
  }
}
