:root {
  --bg: #f4f4f4;
  --panel: #ffffff;
  --panel-2: #f7f7f7;
  --line: #e6e6e6;
  --line-strong: #d2d2d2;
  --text: #272727;
  --muted: #6f6f6f;
  --accent: #d7202a;
  --accent-soft: #fdecec;
  --accent-line: #f0b6b9;
  --blue: #272727;
  --blue-soft: #f2f2f2;
  --green: #1f8a70;
  --danger: #d7202a;
  --shadow: 0 1px 2px rgba(39, 39, 39, .05);
  --radius: 8px;
  font-family: "Geologica", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 14px;
  font-size: 13px;
  line-height: 1.35;
}

h1, h2, h3 { margin: 0; font-weight: 600; }

h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: 10px 14px 6px;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text);
  white-space: nowrap;
}
.brand-mark {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--accent);
  color: #fff !important;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}
.brand em {
  font-style: normal;
  color: var(--accent);
}

.project-fields {
  display: flex;
  gap: 8px;
  flex: 1 1 320px;
  min-width: 240px;
}
.project-fields input {
  flex: 1;
  min-width: 120px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  font: inherit;
  color: inherit;
}
.project-fields input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
  font-weight: 500;
}
.btn.ghost:hover { border-color: var(--line-strong); background: #fff; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 4px 9px; font-size: 12px; }

.sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }

.icon-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  font: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
}
.icon-btn:hover { border-color: var(--line-strong); background: #fff; }

/* ---------- dropdown ---------- */

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 230px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(16, 32, 51, .16);
}
.dropdown-menu button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.dropdown-menu button:hover { background: var(--accent-soft); }
.dropdown-menu small { display: block; color: var(--muted); }

.hidden { display: none !important; }

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 250px minmax(420px, 1fr) 330px;
  gap: 10px;
  align-items: stretch;
  min-height: 420px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 10px;
}
.panel-head h2 { padding-right: 0; }

.panel-note {
  margin: auto 14px 12px;
  color: var(--muted);
  font-size: 11.5px;
}

.side-left .list { padding: 0 10px 10px; overflow: auto; }

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 10px 8px;
  flex-wrap: wrap;
}
.tabs button,
.tab {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.tabs button:hover,
.tab:hover { border-color: var(--line-strong); color: var(--text); }
.tabs button.active,
.tab.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- material list ---------- */

.mat-item {
  padding: 9px 10px;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  cursor: pointer;
}
.mat-item:hover { border-color: var(--line-strong); background: #fff; }
.mat-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
.mat-item .mat-name { font-weight: 600; margin-bottom: 2px; }
.mat-item .mat-meta { color: var(--muted); font-size: 11.5px; }
.mat-item .mat-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.mat-item .mat-actions button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 2px 7px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  color: var(--muted);
}
.mat-item .mat-actions button:hover { color: var(--danger); border-color: #e8b4ae; }

/* ---------- workspace ---------- */

.workspace {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.canvas-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.hint { color: var(--muted); font-size: 11.5px; }
.zoom { display: flex; align-items: center; gap: 8px; color: var(--muted); }
#zoomLabel { min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; }

.canvas-wrap {
  flex: 1;
  overflow: auto;
  padding: 18px;
  background-color: #ffffff;
  background-image:
    linear-gradient(rgba(39, 39, 39, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(39, 39, 39, .045) 1px, transparent 1px);
  background-size: 24px 24px;
  min-height: 320px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}
.canvas-wrap svg { display: block; touch-action: none; flex: 0 0 auto; max-width: none; }

.canvas-legend {
  display: flex;
  gap: 16px;
  padding: 6px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  background: var(--panel-2);
}
.canvas-legend span { display: inline-flex; align-items: center; gap: 5px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.sheet { background: #fbe3e4; border: 1px solid #e9a7aa; }
.swatch.seam { background: #e9a7aa; }
.swatch.overlap { background: rgba(215, 32, 42, 0.12); border: 1px dashed #c96a70; }
.swatch.eave { background: #fbe3e4; border: 1px dashed #e08a8f; }
.swatch.sel { background: var(--accent); }

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--muted);
  padding: 30px;
}
.empty-state strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 6px; }

/* ---------- properties ---------- */

.side-right { overflow: auto; padding-bottom: 8px; }

.props { padding: 0 14px 4px; }
.prop-row {
  display: grid;
  grid-template-columns: 1fr 110px;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}
.prop-row label { color: var(--muted); }
.prop-row input,
.prop-row select {
  width: 100%;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font: inherit;
  color: inherit;
}
.prop-row input:focus,
.prop-row select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.prop-value {
  color: var(--muted);
  font-size: 11.5px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prop-actions { display: flex; gap: 6px; margin: 10px 0 4px; }
.prop-empty { padding: 4px 14px 12px; color: var(--muted); }

.prop-section-title {
  margin: 12px 0 6px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.edge-type-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.edge-type-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  align-items: center;
  gap: 6px;
}
.edge-type-name {
  min-width: 0;
  font-size: 11.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.edge-type-row select {
  width: 100%;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-size: 11.5px;
}

/* ---------- tables ---------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.data-table th,
.data-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}
.data-table th:first-child,
.data-table td:first-child { text-align: left; white-space: normal; }
.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
  background: var(--panel-2);
}
.data-table tbody tr:hover { background: #fafcff; }
.data-table .total-row td { font-weight: 700; background: var(--panel-2); }
.data-table.wide { font-size: 12.5px; }
.data-table input {
  width: 82px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  text-align: right;
}
.data-table .name-cell { text-align: left; white-space: normal; }

.spec-title { margin: 2px 0 6px; font-size: 12.5px; }
.spec-table { margin-bottom: 12px; }
.spec-kv { margin-bottom: 12px; table-layout: fixed; }
.spec-kv th {
  width: 24%;
  padding: 4px 6px;
  border: 1px solid var(--line);
  background: #fafafa;
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  white-space: normal;
}
.spec-kv td {
  width: 26%;
  padding: 4px 6px;
  border: 1px solid var(--line);
  text-align: left;
  white-space: normal;
}
.spec-lengths { width: auto; min-width: 260px; margin-bottom: 12px; }
.spec-calc-row td { color: var(--muted); font-style: italic; }
.spec-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 6px;
  margin: 6px 0 8px;
}
.spec-summary > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  font-size: 12px;
}
.spec-summary > div span { color: var(--muted); }
.spec-summary > div.accent { border-color: var(--accent-line); background: var(--accent-soft); }
.spec-summary > div.accent b { color: var(--accent); }
.data-table .num { color: var(--muted); font-size: 11px; }
.data-table .warn { color: var(--danger); font-weight: 600; }

#slopeStats, #lengthList { margin: 0 14px 10px; width: calc(100% - 28px); }
#slopeStats td, #lengthList td, #slopeStats th, #lengthList th { padding: 4px 6px; }

/* ---------- bottom ---------- */

.bottom {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.bottom-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.tab-panel { padding: 10px 12px 14px; }

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.inline-form select,
.inline-form input {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: inherit;
}
.inline-form select { min-width: 260px; }
.inline-form input { width: 90px; }

.totals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}
.total-card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}
.total-card .label { color: var(--muted); font-size: 11.5px; margin-bottom: 4px; }
.total-card .value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.total-card.accent { background: #272727; border-color: #272727; }
.total-card.accent .label { color: #bdbdbd; }
.total-card.accent .value { color: #ffffff; }

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(39, 39, 39, .35);
  backdrop-filter: blur(2px);
}
.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 24px 64px rgba(39, 39, 39, .28);
}
.modal.modal-wide { width: min(880px, 100%); }
.modal.dwg-busy { width: min(460px, 100%); }
.dwg-busy-body { text-align: center; padding: 22px 20px 20px; }
.dwg-busy-body p { margin: 10px 0 0; font-size: 12.5px; }
.dwg-spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: dwg-spin .85s linear infinite;
}
@keyframes dwg-spin { to { transform: rotate(360deg); } }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 14px 16px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-section-title {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
}
.form-grid .form-section-title:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.field label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11.5px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: inherit;
}
.field textarea {
  resize: vertical;
  min-height: 86px;
  line-height: 1.35;
}
.field input:focus,
.field select:focus,
.field textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.range-table-wrap {
  max-height: 190px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.range-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.range-table th,
.range-table td {
  padding: 3px 6px;
  border-bottom: 1px solid #eee;
  text-align: left;
}
.range-table th {
  position: sticky;
  top: 0;
  background: #fafafa;
  color: var(--muted);
  font-weight: 500;
}
.range-table td:first-child,
.range-table td:nth-child(2) { width: 45%; }
.range-table input {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font: inherit;
  background: #fff;
  color: inherit;
}
.range-table .icon-btn { width: 24px; height: 24px; font-size: 14px; }

/* ---------- вставка фигуры ---------- */

.modal-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.modal-tabs button {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.modal-tabs button.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  font-weight: 600;
}
.shape-hint {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11.5px;
}
.shape-pane textarea {
  width: 100%;
  min-height: 190px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
}
.shape-pane textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.shape-preview {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
}
.cutout-existing { margin-top: 14px; }
.cutout-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cutout-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 12px;
}
.shape-library-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 14px 0 6px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.shape-library-head .panel-note { font-weight: 400; }
.shape-library {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}
.shape-lib-tile {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
  padding: 3px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.shape-lib-tile:hover { border-color: var(--accent-line); }
.shape-lib-tile.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.shape-lib-tile svg {
  display: block;
  width: 100%;
  height: 42px;
}
.shape-lib-tile span {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shape-lib-tile.active span { color: var(--accent); font-weight: 600; }

.coords-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.coords-col { min-width: 0; }
.coords-col .form-grid { margin-bottom: 8px; }
.coords-col-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.coords-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.coords-svg {
  display: block;
  width: 100%;
  height: 250px;
}
.coords-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 250px;
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.coords-table input { width: 88px; }
.coords-col-preview .shape-preview { margin-top: 0; }
.check-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.check-row input { width: auto; }
@media (max-width: 720px) {
  .coords-layout { grid-template-columns: 1fr; }
  .coords-svg, .coords-empty { height: 200px; }
}

.segments-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 12px;
}
.segments-table th,
.segments-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}
.segments-table th {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
}
.segments-table th:first-child,
.segments-table td:first-child { text-align: left; width: 28px; }
.segments-table td:last-child { width: 32px; }
.segments-table input {
  width: 82px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  font: inherit;
  text-align: right;
}
.segments-table input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.segments-table .icon-btn { width: 24px; height: 24px; font-size: 14px; }
.segments-actions { display: flex; gap: 6px; margin: 4px 0 8px; }

/* ---------- print ---------- */

.print-report { display: none; }

@media print {
  body { display: block; height: auto; padding: 0; background: #fff; overflow: visible; }
  .menubar, .cad-toolbar, .workbench, .bottom-drawer, .statusbar,
  .topbar, .layout, .bottom, .modal-backdrop { display: none !important; }
  .print-report { display: block; }
  .print-report h1 { font-size: 20px; margin: 0 0 4px; }
  .print-report h2 {
    padding: 12px 0 4px;
    color: #000;
    font-size: 13px;
    border-bottom: 1px solid #999;
  }
  .print-report table { width: 100%; border-collapse: collapse; font-size: 11px; }
  .print-report th, .print-report td { border: 1px solid #bbb; padding: 3px 5px; text-align: right; }
  .print-report th:first-child, .print-report td:first-child { text-align: left; }
  .print-report .pr-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 10px; }
  .print-report .pr-meta { color: #444; font-size: 12px; }
  .print-report .pr-canvas { margin: 8px 0 12px; }
  .print-report .pr-canvas svg { max-width: 100%; height: auto; }
  .print-report .pr-slope { page-break-inside: avoid; margin-bottom: 12px; }
  .print-report .pr-sheet {
    break-before: page;
    page-break-before: always;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .print-report .pr-sheet h2 { break-after: avoid; page-break-after: avoid; }
  .print-report .pr-sheet-meta { margin: 0 0 4mm; color: #444; font-size: 11px; }
  .print-report .pr-sheet-top {
    display: flex;
    align-items: flex-start;
    gap: 6mm;
    margin: 0 0 3mm;
  }
  .print-report .pr-lengths { flex: 0 0 46%; }
  .print-report .pr-lengths h4 {
    margin: 0 0 1.5mm;
    font-size: 10px;
    font-weight: 600;
  }
  .print-report .pr-lengths-grid { display: flex; gap: 3mm; }
  .print-report .pr-lengths-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9px;
  }
  .print-report .pr-lengths-table th,
  .print-report .pr-lengths-table td {
    padding: 1px 3px;
    border: 1px solid #bbb;
    text-align: right;
  }
  .print-report .pr-lengths-table th:first-child,
  .print-report .pr-lengths-table td:first-child { text-align: left; width: 22px; }
  .print-report .pr-params {
    flex: 1 1 auto;
    border-collapse: collapse;
    font-size: 9px;
  }
  .print-report .pr-params th {
    width: 48%;
    padding: 1.4px 4px;
    border-bottom: 1px solid #ddd;
    color: #555;
    font-weight: 500;
    text-align: left;
    white-space: normal;
  }
  .print-report .pr-params td {
    padding: 1.4px 4px;
    border-bottom: 1px solid #ddd;
    text-align: left;
    white-space: normal;
  }
  .print-report .pr-empty { margin: 0; font-size: 9px; color: #777; }
  .print-report .pr-canvas-sheet { margin: 0; text-align: center; }
  .print-report .pr-canvas-sheet svg { display: block; margin: 0 auto; max-width: 100%; }
  .print-report .pr-foot { margin-top: 16px; font-size: 11px; color: #555; }
  @page { size: A4 portrait; margin: 10mm; }
}

@media (max-width: 1180px) {
  .layout { grid-template-columns: 220px minmax(360px, 1fr) 300px; }
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .panel { max-height: none; }
  .side-left { order: 2; }
  .workspace { order: 1; }
  .side-right { order: 3; }
  .canvas-wrap { min-height: 300px; }
}

/* ============================================================
   Рабочий стол (app shell)
   ============================================================ */

body.app-shell {
  height: 100vh;
  overflow: hidden;
  padding: 0;
  gap: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  font-size: 12.5px;
}

.menubar {
  position: relative;
  z-index: 80;
  flex: 0 0 auto;
  height: 35px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  background: #f7f7f7;
  border-bottom: 1px solid #d4d4d4;
}
.menubar .brand { font-size: 14px; gap: 7px; }
.menubar .brand-mark { width: 24px; height: 24px; font-size: 14px; border-radius: 4px; }

.menubar-menus {
  display: flex;
  align-items: stretch;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: visible;
}
.menu { position: relative; }
.menu > button {
  height: 27px;
  padding: 0 7px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}
.menu > button:hover,
.menu.open > button {
  background: #e8e8e8;
  box-shadow: inset 0 -2px 0 var(--accent);
}
.menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  z-index: 200;
  min-width: 215px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 10px 26px rgba(39, 39, 39, .14);
}
.menu.open .menu-dropdown { display: block; }
.menu-dropdown button {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.menu-dropdown button:hover { background: var(--accent-soft); color: var(--accent); }
.menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }

.project-fields.compact {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
  min-width: 0;
}
.project-fields.compact input {
  width: 150px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f7f7f7;
  font: inherit;
  font-size: 12px;
}

.cad-toolbar {
  position: relative;
  z-index: 60;
  flex: 0 0 auto;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.cad-tools {
  display: flex;
  gap: 2px;
  padding-right: 8px;
  border-right: 1px solid var(--line);
}
.tool-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #444;
  cursor: pointer;
}
.tool-btn:hover { background: #f2f2f2; }
.tool-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}

.cad-fields {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 380px;
  min-width: 0;
  overflow-x: auto;
  padding: 2px 0;
}
.cad-fields label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
}
.cad-fields input {
  width: 68px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cad-fields input:read-only { background: #f7f7f7; color: #555; }
.cad-fields input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.zoom-buttons { display: flex; gap: 4px; flex: 0 0 auto; }
.zoom-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.zoom-btn:hover { border-color: var(--accent-line); color: var(--accent); }
.zoom-btn:active { background: var(--accent-soft); }

.cad-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.cad-actions .btn.small { padding: 4px 9px; font-size: 11.5px; }

.workbench {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  background: #fff;
}

.toolrail {
  flex: 0 0 auto;
  width: 38px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 4px;
  border-right: 1px solid var(--line);
  background: #fafafa;
}

.canvas-area {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.draw-hint {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  max-width: calc(100% - 24px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 5px 12px;
  border: 1px solid var(--accent-line);
  border-radius: 6px;
  background: #fff;
  color: #a3161d;
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(39, 39, 39, .08);
}
.draw-hint-text { overflow: hidden; text-overflow: ellipsis; }
.draw-hint .polar { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.draw-hint label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #8a6a6c;
  font-size: 11px;
  white-space: nowrap;
}
.draw-hint input {
  width: 66px;
  padding: 3px 6px;
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 11.5px;
  text-align: right;
}
.draw-hint input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.draw-hint .btn { padding: 3px 9px; font-size: 11px; }
.canvas-area .canvas-wrap {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px;
}
.legend-hint { margin-left: auto; color: #9a9a9a; }

.rightbar {
  flex: 0 0 330px;
  width: 330px;
  border-left: 1px solid var(--line);
  background: #fff;
  overflow: auto;
}
.rightbar details { border-bottom: 1px solid var(--line); }
.rightbar summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: #fafafa;
  color: #4a4a4a;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.rightbar summary::-webkit-details-marker { display: none; }
.rightbar summary::after { content: "▾"; font-size: 10px; color: #8a8a8a; }
.rightbar details:not([open]) summary::after { content: "▸"; }
.rightbar details > *:not(summary) { padding: 8px 12px; }
.rightbar #slopeStats,
.rightbar #lengthList { margin: 0 12px 10px; width: calc(100% - 24px); }
.rightbar .props { padding: 8px 12px 4px; }

.el-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin-bottom: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.el-item:hover { border-color: var(--line-strong); }
.el-item.active { border-color: var(--accent); background: var(--accent-soft); }
.el-num {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: #eee;
  color: #555;
  font-size: 10px;
  font-weight: 600;
}
.el-item.active .el-num { background: var(--accent); color: #fff; }
.el-name { font-size: 12px; font-weight: 500; }
.el-meta { color: var(--muted); font-size: 10.5px; }
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ececec;
  color: #666;
  font-size: 10px;
  font-weight: 600;
}
.object-list {
  max-height: 240px;
  overflow: auto;
}
.object-actions {
  padding: 8px 12px 4px;
}
.object-actions .btn { width: 100%; justify-content: center; }
.layout-orient {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.layout-orient-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.layout-orient-svg { display: block; width: 100%; height: 280px; }
.layout-orient-fields .field { margin-bottom: 8px; }
@media (max-width: 720px) {
  .layout-orient { grid-template-columns: 1fr; }
  .layout-orient-svg { height: 220px; }
}

.bottom-drawer {
  flex: 0 0 auto;
  height: 215px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--line);
  background: #fff;
}
.bottom-drawer.hidden { display: none; }
.bottom-drawer.layouts-active { height: 70vh; }
.drawer-resizer {
  flex: 0 0 7px;
  position: relative;
  cursor: ns-resize;
  background: #f5f5f5;
  border-bottom: 1px solid var(--line);
  touch-action: none;
}
.drawer-resizer::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 50%;
  width: 38px;
  height: 3px;
  border-radius: 2px;
  background: #c9c9c9;
  transform: translateX(-50%);
}
.drawer-resizer:hover::before { background: var(--accent); }
.bottom-drawer .bottom-tabs {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  background: #fafafa;
}
.bottom-drawer .tab-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 8px 10px;
}
.bottom-drawer .pin-btn {
  margin-left: auto;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: #777;
  cursor: pointer;
}
.bottom-drawer .pin-btn:hover { color: var(--accent); border-color: var(--accent-line); }
.bottom-drawer .pin-btn.active {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.drawer-close {
  margin-left: 4px;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: #777;
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.drawer-close:hover { color: var(--danger); border-color: var(--accent-line); }

.layout-pages-actions {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 8px;
  margin-bottom: 6px;
  background: #fff;
}
.layout-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-bottom: 20px;
}
.layout-pages .pr-sheet {
  width: 210mm;
  max-width: 100%;
  box-sizing: border-box;
  padding: 8mm;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.layout-pages .pr-sheet h2 { margin: 0 0 4px; font-size: 15px; }
.layout-pages .pr-sheet-top {
  display: flex;
  align-items: flex-start;
  gap: 6mm;
  margin: 0 0 3mm;
}
.layout-pages .pr-lengths { flex: 0 0 46%; }
.layout-pages .pr-lengths h4 { margin: 0 0 4px; font-size: 11px; }
.layout-pages .pr-lengths-grid { display: flex; gap: 3mm; }
.layout-pages .pr-lengths-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}
.layout-pages .pr-lengths-table th,
.layout-pages .pr-lengths-table td {
  padding: 2px 4px;
  border: 1px solid #ccc;
  text-align: right;
}
.layout-pages .pr-lengths-table th:first-child,
.layout-pages .pr-lengths-table td:first-child { text-align: left; }
.layout-pages .pr-params {
  flex: 1 1 auto;
  border-collapse: collapse;
  font-size: 10px;
}
.layout-pages .pr-params th,
.layout-pages .pr-params td {
  padding: 2px 4px;
  border-bottom: 1px solid #e2e2e2;
  text-align: left;
  white-space: normal;
}
.layout-pages .pr-params th { width: 48%; color: var(--muted); font-weight: 500; }
.layout-pages .pr-canvas-sheet { text-align: center; }
.layout-pages .pr-canvas-sheet svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.statusbar {
  flex: 0 0 auto;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border-top: 1px solid var(--line);
  background: #f7f7f7;
  font-size: 11px;
  color: #666;
}
.sheet-tabs { display: flex; align-items: stretch; height: 100%; gap: 1px; }
.sheet-tab {
  padding: 0 11px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: #555;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.sheet-tab:hover { background: #eee; }
.sheet-tab.active {
  background: #fff;
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 0 2px 0 var(--accent);
}
.sheet-add {
  padding: 0 9px;
  border: 0;
  background: transparent;
  color: #555;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
.sheet-add:hover { color: var(--accent); }
.status-actions { display: flex; gap: 4px; }
.status-toggles {
  display: flex;
  align-items: center;
  gap: 3px;
  padding-left: 6px;
  border-left: 1px solid var(--line);
}
.status-toggles .status-btn {
  padding: 2px 6px;
  font-size: 10px;
  letter-spacing: .02em;
}
.status-select {
  height: 21px;
  padding: 0 2px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: #555;
  font: inherit;
  font-size: 10px;
}
.status-btn {
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: #555;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.status-btn:hover { border-color: var(--line-strong); }
.status-btn.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.status-info { margin-left: auto; white-space: nowrap; color: #777; }

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 300;
  width: 330px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid var(--line);
  box-shadow: 10px 0 30px rgba(39, 39, 39, .16);
}
.drawer.hidden { display: none; }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
}
.drawer .panel-head { padding-right: 10px; }
.drawer .tabs { padding: 0 10px 8px; }
.drawer .list { overflow: auto; padding: 0 10px 10px; }
.drawer .panel-note { margin-top: 0; }

@media (max-width: 1200px) {
  .project-fields.compact input { width: 115px; }
  .rightbar { flex-basis: 300px; width: 300px; }
  .cad-fields input { width: 62px; }
}

@media (max-width: 1000px) {
  .project-fields.compact { display: none; }
  .rightbar { flex-basis: 280px; width: 280px; }
  .cad-fields { flex-basis: 100%; order: 3; }
  .cad-actions { margin-left: auto; }
}

@media (max-width: 760px) {
  .menubar .brand b { display: none; }
  .rightbar { display: none; }
  .cad-actions .btn.small { padding: 4px 7px; }
  .legend-hint { display: none; }
}
