* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px; color: #1f2937;
  background: #f3f4f6;
  min-height: 100vh;
}
body { display: flex; flex-direction: column; min-height: 100vh; }

/* ============ topbar ============ */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: #1f2937; color: #fff;
  border-bottom: 3px solid #f59e0b;
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: 1.5px; }
.topbar-spacer { flex: 1; }
.btn-ghost {
  background: transparent; color: #d1d5db; border: 1px solid #4b5563;
  padding: 5px 12px; border-radius: 4px; cursor: pointer; font-size: 12px;
}
.btn-ghost:hover { background: #374151; color: #fff; }
.btn-header-bom {
  background: #f59e0b; color: #fff; border: none;
  padding: 7px 16px; border-radius: 6px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  margin-right: 8px;
  font-family: inherit;
  box-shadow: 0 2px 4px rgba(245, 158, 11, .25);
  transition: background .15s;
}
.btn-header-bom:hover { background: #d97706; }

/* ============ buttons ============ */
.btn-primary {
  background: #f59e0b; color: #fff; border: none;
  padding: 11px 22px; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 2px 6px rgba(245, 158, 11, .35);
  transition: background .15s, transform .1s;
}
.btn-primary:hover { background: #d97706; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { background: #d1d5db; cursor: not-allowed; box-shadow: none; }
.btn-block { width: 100%; }

/* dashboard "btn-ghost" lighter variant for the white background */
.dash .btn-ghost, .modal .btn-ghost, .bom-section .btn-ghost {
  color: #4b5563; border-color: #d1d5db; background: #fff;
}
.dash .btn-ghost:hover, .modal .btn-ghost:hover, .bom-section .btn-ghost:hover {
  background: #f3f4f6; color: #1f2937;
}

.muted { color: #9ca3af; }

/* ============ dashboard ============ */
.dash {
  flex: 1;
  max-width: 1280px; width: 100%;
  margin: 0 auto;
  padding: 24px 20px 40px;
}
.dash-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  margin-bottom: 22px;
}

.config-panel {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  display: flex; flex-direction: column;
}
.config-panel h2 { margin: 0 0 4px; font-size: 18px; color: #1f2937; }
.config-hint { font-size: 12px; color: #9ca3af; margin: 0 0 14px; }

.config-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.config-row {
  display: flex; align-items: center; justify-content: space-between;
  background: #f9fafb;
  border: 1px solid #f3f4f6;
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .15s, transform .1s, background .15s;
}
.config-row:hover {
  border-color: #fbbf24;
  background: #fffbeb;
  transform: translateX(2px);
}
.config-row .config-label {
  font-size: 11px; color: #6b7280;
  text-transform: uppercase; letter-spacing: .5px;
  display: block; margin-bottom: 3px;
}
.config-row .config-value {
  font-size: 14px; font-weight: 600; color: #1f2937;
  display: block;
}
.config-row .config-content { flex: 1; min-width: 0; }
.config-row .config-edit {
  font-size: 12px; color: #f59e0b; font-weight: 600;
  flex-shrink: 0; margin-left: 8px;
}
.config-row.recommended .config-value::after {
  content: "★"; color: #f59e0b; margin-left: 6px; font-size: 12px;
}

/* строка-результат для фундамента — отдельный стиль "вычисляется автоматически" */
.config-row.result-row {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 2px dashed #f59e0b;
  background: linear-gradient(135deg, #fffbeb 0%, #fff 100%);
  border-color: #fde68a;
}
.config-row.result-row .config-label {
  color: #92400e;
}
.config-row.result-row .config-edit {
  color: #6b7280;
  font-size: 11px;
}

/* при наведении на одну строку остальные слегка блюрятся (фокус) */
.config-list:hover .config-row {
  filter: blur(0.4px);
  opacity: 0.65;
  transition: filter .15s, opacity .15s;
}
.config-list:hover .config-row:hover {
  filter: none;
  opacity: 1;
}

.cost-card {
  background: linear-gradient(135deg, #fef3c7 0%, #fff 100%);
  border: 1px solid #fbbf24;
  border-radius: 12px;
  padding: 16px;
  margin-top: auto;
}
.cost-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 0;
  font-size: 13px;
}
.cost-row span { color: #4b5563; }
.cost-row b { color: #1f2937; font-size: 14px; }
.cost-row.total {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid #fde68a;
}
.cost-row.total span { font-weight: 600; }
.cost-row.total b {
  font-size: 22px; color: #92400e;
  font-variant-numeric: tabular-nums;
}
.cost-card .btn-primary { margin-top: 12px; }

/* ============ house view ============ */
.house-view {
  background: #fff;
  border-radius: 14px;
  padding: 20px 24px 22px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  display: flex; flex-direction: column;
}
.house-view-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 12px;
}
.house-view-head h2 { margin: 0; font-size: 18px; color: #1f2937; }
.house-mini-plan-wrap {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: #9ca3af;
}
.rotate-controls {
  display: flex; align-items: center; gap: 6px;
  margin-right: auto;
  padding-left: 16px;
}
.rotate-btn {
  width: 32px; height: 32px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 14px; color: #4b5563;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .1s;
  font-family: inherit;
}
.rotate-btn:hover { background: #fef3c7; border-color: #fbbf24; color: #92400e; }
.rotate-btn:active { transform: scale(0.92); }
.rotate-label {
  display: inline-block; min-width: 36px; text-align: center;
  font-weight: 700; font-size: 12px; color: #f59e0b;
  background: #fffbeb; border-radius: 6px; padding: 4px 8px;
}
.house-mini-plan {
  width: 50px; height: 50px;
  background: #fafaf7;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 4px;
  display: flex; align-items: center; justify-content: center;
}
.house-mini-plan svg { width: 100%; height: 100%; }

.house-svg-wrap {
  flex: 1;
  position: relative;
  min-height: 460px;
  background: linear-gradient(180deg, #dbeafe 0%, #f0f9ff 70%);
  border-radius: 10px;
  overflow: hidden;
  cursor: grab;
}
.house-svg-wrap:active { cursor: grabbing; }
.house-scene { width: 100%; height: 100%; min-height: 460px; }
.house-scene canvas { display: block; outline: none; }
.scene-help {
  position: absolute; left: 12px; bottom: 10px;
  background: rgba(15, 23, 42, 0.65);
  color: #fff; font-size: 11px;
  padding: 5px 10px; border-radius: 6px;
  pointer-events: none;
  letter-spacing: 0.2px;
}
.scene-help b { color: #fbbf24; }
.scene-tools {
  position: absolute; right: 12px; top: 12px;
  display: flex; gap: 6px;
  z-index: 5;
}
.scene-tool {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #e5e7eb;
  color: #1f2937;
  font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  transition: background .12s, border-color .12s;
  font-family: inherit;
}
.scene-tool:hover { background: #fef3c7; border-color: #fbbf24; }
.scene-tool.active {
  background: #f59e0b; color: #fff; border-color: #f59e0b;
  box-shadow: 0 2px 6px rgba(245,158,11,.4);
}
body.place-mode .house-svg-wrap { cursor: crosshair !important; }
body.place-mode .scene-help { background: rgba(245, 158, 11, 0.9); }

.scene-sizes { display: flex; gap: 4px; margin-right: 6px; }
.size-btn {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #e5e7eb;
  color: #4b5563;
  font-size: 11px; font-weight: 600;
  padding: 5px 10px; border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s;
}
.size-btn:hover { background: #fef3c7; }
.size-btn.active { background: #f59e0b; color: #fff; border-color: #f59e0b; }

/* color pickers в модалках */
.color-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #f3f4f6;
}
.color-label {
  font-size: 12px; color: #6b7280; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.color-row {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.color-sw {
  position: relative;
  width: 92px; height: 56px;
  border-radius: 8px;
  border: 3px solid #e5e7eb;
  cursor: pointer;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 4px;
  transition: transform .12s, border-color .12s, box-shadow .12s;
  box-shadow: inset 0 -2px 6px rgba(0,0,0,.18);
}
.color-sw:hover {
  border-color: #fbbf24;
  transform: translateY(-2px);
  box-shadow: inset 0 -2px 6px rgba(0,0,0,.18), 0 4px 8px rgba(0,0,0,.1);
}
.color-sw.selected {
  border-color: #f59e0b;
  box-shadow: inset 0 -2px 6px rgba(0,0,0,.18), 0 0 0 2px rgba(245,158,11,.3);
}
.color-sw span {
  font-size: 11px; font-weight: 600;
  color: #fff;
  background: rgba(15, 23, 42, 0.62);
  padding: 2px 8px; border-radius: 4px;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
  letter-spacing: 0.2px;
}
.color-sw.selected::before {
  content: "✓";
  position: absolute; top: 4px; right: 6px;
  color: #fff;
  font-size: 14px; font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}

/* блок источника материала из магазина */
.source-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #f3f4f6;
}
.source-hint {
  font-size: 12px; color: #6b7280;
  margin: 4px 0 10px;
  line-height: 1.4;
}
.source-row {
  display: flex; gap: 8px;
  margin-bottom: 10px;
}
.source-row input[type=url] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font: inherit;
  background: #fff;
}
.source-row input[type=url]:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .12);
}
.source-row .btn-primary { padding: 8px 16px; font-size: 13px; }
.source-loading { color: #6b7280; font-size: 12px; padding: 8px 0; }
.source-error {
  color: #b91c1c; font-size: 13px;
  background: #fee2e2;
  padding: 12px 14px; border-radius: 6px;
  border-left: 3px solid #ef4444;
}
.source-fix-hint {
  font-size: 11px; color: #7f1d1d;
  margin-top: 8px;
  font-style: italic;
}
.source-card {
  display: flex; gap: 14px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px;
}
.source-img {
  width: 110px; height: 110px;
  object-fit: cover;
  border-radius: 6px;
  background: #fff;
  flex-shrink: 0;
}
.source-img-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #9ca3af;
  background: #f3f4f6;
}
.source-info { flex: 1; min-width: 0; }
.source-name {
  font-size: 13px; font-weight: 600; color: #1f2937;
  line-height: 1.3; margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.source-meta {
  font-size: 12px; color: #6b7280;
  margin-bottom: 10px;
}
.source-price b { color: #f59e0b; font-size: 14px; }
.source-actions { display: flex; gap: 6px; }
.source-actions .btn-primary, .source-actions .btn-ghost {
  padding: 6px 12px; font-size: 12px;
}
.source-tabs {
  display: flex; gap: 4px;
  margin-bottom: 10px;
  border-bottom: 1px solid #e5e7eb;
}
.src-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  font-size: 12px; font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  font-family: inherit;
  transition: color .12s, border-color .12s;
}
.src-tab:hover { color: #1f2937; }
.src-tab.active {
  color: #f59e0b;
  border-bottom-color: #f59e0b;
}
.src-pane {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}
.src-pane input[type=text],
.src-pane input[type=number],
.src-pane input[type=url] {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font: inherit;
  background: #fff;
  width: 100%;
}
.src-pane textarea {
  width: 100%;
  min-height: 120px;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font: 11px ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  background: #fff;
  resize: vertical;
}
.src-pane textarea:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .12);
}
.src-pane .source-row { margin-bottom: 0; }

/* Каталог материалов */
.catalog-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
}
.catalog-item {
  position: relative;
  display: flex; gap: 10px; align-items: center;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s, transform .1s, background .12s;
}
.catalog-item:hover {
  border-color: #fbbf24;
  box-shadow: 0 4px 10px rgba(245, 158, 11, .15);
  transform: translateY(-1px);
}
.catalog-item.selected {
  border: 2px solid #16a34a;
  background: #f0fdf4;
  box-shadow: 0 4px 12px rgba(22,163,74,.18);
}
.catalog-item.selected:hover { border-color: #16a34a; }
.catalog-badge {
  position: absolute; top: 6px; right: 8px;
  background: #16a34a; color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.catalog-meta { font-size: 11px; margin: 2px 0; }

/* === 5 типов стен в одну строку === */
.wall-grid-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.wall-grid-row > .wall-card {
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  transition: border-color .12s, box-shadow .12s, transform .1s;
}
.wall-grid-row > .wall-card:hover {
  border-color: #fbbf24;
  box-shadow: 0 4px 10px rgba(245, 158, 11, .15);
  transform: translateY(-1px);
}
.wall-grid-row > .wall-card.selected {
  border-color: #16a34a; background: #f0fdf4;
  box-shadow: 0 4px 12px rgba(22,163,74,.18);
}
.wall-grid-row > .wall-card h3 { font-size: 13px; margin: 6px 0 3px; }
.wall-grid-row > .wall-card p  { font-size: 11px; line-height: 1.3; color: #6b7280;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.wall-grid-row > .wall-card .wall-stats { gap: 4px; flex-wrap: wrap; }
.wall-grid-row > .wall-card .pill { font-size: 10px; padding: 2px 5px; }

/* === Слой-карточки (облиц + строит) — равные по ширине и высоте === */
.layers-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  margin-top: 8px;
}
.layer-card {
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  min-height: 180px;
  display: flex; flex-direction: column;
  transition: border-color .12s, box-shadow .12s;
}
.layer-card:hover { border-color: #fbbf24; box-shadow: 0 6px 16px rgba(245,158,11,.15); }
.layer-title { font-weight: 600; font-size: 13px; color: #1f2937; margin-bottom: 10px; }
.layer-display {
  flex: 1;
  display: flex; gap: 12px; align-items: center;
}
.layer-thumb {
  width: 96px; height: 96px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,.08);
  flex-shrink: 0;
}
.layer-swatch {
  width: 96px; height: 96px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: inset 0 -3px 6px rgba(0,0,0,.18);
  flex-shrink: 0;
}
.layer-info { flex: 1; min-width: 0; }
.layer-name { font-size: 15px; font-weight: 700; color: #14532d; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.layer-meta { font-size: 12px; margin: 4px 0; }
.layer-price { font-size: 16px; color: #166534; }
.layer-price b { font-size: 18px; }
.layer-empty { color: #9ca3af; font-style: italic; padding: 8px; }
.layer-hint { font-size: 11px; color: #6b7280; text-align: center; margin-top: 8px; }
.layer-card:hover .layer-hint { color: #f59e0b; }

/* === Picker view === */
.picker-view { padding: 4px; }
.picker-head {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid #e5e7eb;
}
.picker-head h3 { margin: 0; font-size: 16px; flex: 1; }
.picker-count { font-size: 12px; }
.picker-back { padding: 6px 12px; }
.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px;
}
.picker-item {
  position: relative;
  display: flex; gap: 10px; align-items: center;
  padding: 10px 12px;
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s, transform .1s;
}
.picker-item:hover {
  border-color: #fbbf24;
  box-shadow: 0 4px 10px rgba(245,158,11,.15);
  transform: translateY(-1px);
}
.picker-item.selected {
  border-color: #16a34a; background: #f0fdf4;
  box-shadow: 0 4px 12px rgba(22,163,74,.18);
}
.picker-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.08); }
.picker-swatch { width: 56px; height: 56px; border-radius: 6px; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.08); box-shadow: inset 0 -2px 4px rgba(0,0,0,.18); }
.picker-info { flex: 1; min-width: 0; }
.picker-name { font-size: 13px; font-weight: 600; color: #1f2937; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.picker-meta { font-size: 11px; margin: 2px 0; }
.picker-price { font-size: 13px; }
.picker-badge {
  position: absolute; top: 6px; right: 8px;
  background: #16a34a; color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 10px;
}

/* admin link in topbar */
.admin-link { font-size: 11px; color: #6b7280; text-decoration: none; }
.admin-link:hover { color: #f59e0b; }

/* === Hover-превью карточки в picker === */
.picker-hover-preview {
  position: fixed;
  width: 320px;
  background: #fff;
  border: 2px solid #16a34a;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.22);
  padding: 14px;
  z-index: 10000;
  pointer-events: none;
  font-family: inherit;
}
.picker-hover-preview .hp-img,
.picker-hover-preview .hp-swatch {
  width: 100%; height: 220px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 10px;
  display: block;
  box-shadow: inset 0 -3px 6px rgba(0,0,0,.12);
}
.picker-hover-preview .hp-name {
  font-size: 15px; font-weight: 700; color: #14532d;
  margin-bottom: 10px; line-height: 1.3;
}
.picker-hover-preview .hp-seed {
  display: inline-block;
  background: #6b7280; color: #fff;
  font-size: 9px; font-weight: 700;
  padding: 2px 6px; border-radius: 6px;
  margin-left: 6px; vertical-align: middle;
}
.picker-hover-preview .hp-rows { display: flex; flex-direction: column; }
.picker-hover-preview .hp-row {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 12px;
  border-bottom: 1px dashed #e5e7eb;
  padding: 4px 0;
}
.picker-hover-preview .hp-row:last-child { border-bottom: 0; }
.picker-hover-preview .hp-key { color: #6b7280; flex-shrink: 0; }
.picker-hover-preview .hp-val { color: #1f2937; font-weight: 500; text-align: right;
  word-break: break-word; }

.brick-section {
  margin-top: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.brick-section:hover { border-color: #fbbf24; }
.brick-section[open] { border-color: #16a34a; box-shadow: 0 4px 14px rgba(22,163,74,.10); }

.brick-summary {
  cursor: pointer;
  padding: 12px 14px 10px;
  list-style: none;
  display: block;
}
.brick-summary::-webkit-details-marker { display: none; }
.brick-summary > .color-label { margin-bottom: 8px; font-weight: 600; color: #1f2937; }
.brick-summary > .selected-display-wrap { margin: 0; }
.brick-summary-hint {
  font-size: 11px; color: #6b7280;
  margin-top: 8px; text-align: center;
}
.brick-summary-hint:before { content: '▸ нажмите, чтобы заменить из каталога'; }
.brick-section[open] .brick-summary-hint { color: #16a34a; }
.brick-section[open] .brick-summary-hint:before { content: '▾ свернуть'; }

.brick-section-body { padding: 8px 14px 14px; border-top: 1px solid #e5e7eb; background: #fafafa; }

/* Крупный блок «Выбрано» над спойлером */
.selected-display-wrap { margin: 6px 0 8px; }
.selected-display {
  position: relative;
  display: flex; gap: 14px; align-items: center;
  padding: 14px 18px;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfccb 100%);
  border: 2px solid #16a34a;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(22,163,74,.12);
}
.selected-badge {
  position: absolute; top: 10px; right: 12px;
  background: #16a34a; color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.selected-thumb {
  width: 88px; height: 88px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.08);
}
.selected-swatch {
  width: 88px; height: 88px;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: inset 0 -3px 6px rgba(0,0,0,.18);
}
.selected-info { flex: 1; min-width: 0; padding-right: 88px; }
.selected-name { font-size: 16px; font-weight: 700; color: #14532d; line-height: 1.25;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.selected-meta { font-size: 12px; color: #4d7c0f; margin: 4px 0; }
.selected-meta-item { margin-right: 6px; }
.selected-price { font-size: 17px; color: #166534; margin-top: 4px; }
.selected-price b { font-size: 19px; }
.selected-source { font-size: 11px; }
.selected-empty {
  padding: 12px 16px; text-align: center;
  background: #fef3c7; color: #92400e;
  border: 1px dashed #f59e0b; border-radius: 8px;
}

/* Спойлер для админ-блока «Свой материал из магазина» */
.source-spoiler { margin-top: 8px; }
.source-spoiler > summary {
  cursor: pointer;
  padding: 8px 12px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  color: #374151;
  user-select: none;
  list-style: none;
}
.source-spoiler > summary::-webkit-details-marker { display: none; }
.source-spoiler > summary:before { content: '▸ '; color: #6b7280; font-size: 11px; }
.source-spoiler[open] > summary:before { content: '▾ '; }
.source-spoiler > summary:hover { background: #e5e7eb; }
.source-spoiler[open] > summary { border-radius: 8px 8px 0 0; border-bottom: 0; }
.source-spoiler .source-block { border-radius: 0 0 8px 8px; border-top: 0; padding-top: 4px; }
.catalog-swatch {
  width: 40px; height: 40px;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.1);
  box-shadow: inset 0 -2px 4px rgba(0,0,0,.18);
}
.catalog-info { flex: 1; min-width: 0; }
.catalog-name {
  font-size: 12px; font-weight: 600; color: #1f2937;
  line-height: 1.3; margin-bottom: 4px;
}
.catalog-price { font-size: 12px; color: #6b7280; }
.catalog-price b { color: #f59e0b; font-size: 13px; }
.catalog-empty {
  text-align: center; color: #9ca3af; font-size: 12px; padding: 20px;
}

/* Заголовок секции внутри каталога (распарсенное / готовое) */
.catalog-section-header {
  grid-column: 1 / -1;
  font-size: 11px; color: #6b7280;
  text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 700;
  padding: 10px 4px 6px;
  border-bottom: 1px solid #f3f4f6;
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
}
.catalog-section-header b { color: #f59e0b; font-weight: 700; }
.catalog-section-header .catalog-clear {
  margin-left: auto;
  font-size: 11px; font-weight: 500;
  color: #9ca3af; text-decoration: none;
  text-transform: none; letter-spacing: 0;
}
.catalog-section-header .catalog-clear:hover { color: #ef4444; text-decoration: underline; }

/* Фото-миниатюра в каталоге (распарсенное) */
.catalog-thumb {
  width: 50px; height: 50px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.1);
}

/* Подтверждение успешного парсинга */
.parse-ok {
  background: #d1fae5;
  color: #065f46;
  border-left: 3px solid #10b981;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-top: 6px;
}
.parse-ok b { color: #047857; }

/* Подсказка как добавить парсенный каталог (когда список пуст) */
.catalog-add-hint {
  grid-column: 1 / -1;
  font-size: 12px; color: #4b5563;
  background: #fef3c7;
  padding: 10px 14px;
  border-radius: 8px;
  border-left: 3px solid #f59e0b;
  line-height: 1.5;
  margin-bottom: 8px;
}
.catalog-add-hint a { color: #b45309; font-weight: 600; }
.catalog-add-hint code {
  background: rgba(245, 158, 11, 0.2);
  padding: 1px 6px; border-radius: 3px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 11px;
}

/* Сетка товаров из спарсенной категории */
.items-header {
  font-size: 12px; color: #4b5563;
  margin: 12px 0 10px;
}
.items-header b { color: #1f2937; }
.items-header a { color: #f59e0b; text-decoration: none; }
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  max-height: 460px;
  overflow-y: auto;
  padding-right: 4px;
}
.item-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .12s, transform .1s, box-shadow .12s;
  display: flex; flex-direction: column;
}
.item-card:hover {
  border-color: #fbbf24;
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(245, 158, 11, .15);
}
.item-img {
  width: 100%; height: 110px;
  background: #f9fafb;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.item-img img { width: 100%; height: 100%; object-fit: cover; }
.item-img-empty { color: #9ca3af; font-size: 11px; }
.item-name {
  font-size: 11px; font-weight: 600; color: #1f2937;
  padding: 8px 10px 4px;
  line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}
.item-price {
  font-size: 13px; font-weight: 700; color: #f59e0b;
  padding: 0 10px 10px;
}
.item-price .muted { color: #9ca3af; font-weight: 500; font-size: 11px; }

.house-tags {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 12px;
}
.house-tag {
  background: #f3f4f6;
  color: #4b5563;
  font-size: 12px; font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
}
.house-tag.warn { background: #fee2e2; color: #991b1b; }
.house-tag.accent { background: #fef3c7; color: #92400e; }

/* ============ bom section ============ */
.bom-section {
  background: #fff;
  border-radius: 14px;
  padding: 20px 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  margin-bottom: 22px;
}
.bom-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.bom-head h2 { margin: 0; font-size: 18px; color: #1f2937; }
.bom-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.bom-row {
  display: grid;
  grid-template-columns: 1fr 130px 130px;
  align-items: baseline;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  gap: 8px;
}
.bom-row:nth-child(odd) { background: #f9fafb; }
.bom-row .name { color: #374151; line-height: 1.35; }
.bom-row .qty  { color: #1f2937; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.bom-row .price { color: #f59e0b; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.bom-row .cat-icon {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 8px; vertical-align: middle;
}
.bom-row .cat-concrete { background: #94a3b8; }
.bom-row .cat-rebar    { background: #dc2626; }
.bom-row .cat-fill     { background: #c2a878; }
.bom-row .cat-ins      { background: #fb923c; }
.bom-row .cat-wp       { background: #94d2bd; }
.bom-row .cat-form     { background: #a16207; }
.bom-row .cat-piles    { background: #475569; }
.bom-row .cat-pipes    { background: #ef4444; }
.bom-row .cat-wood     { background: #b45309; }

.bom-section-foot {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid #f3f4f6;
  padding-top: 14px;
}
.bom-grand {
  font-size: 14px; color: #4b5563;
}
.bom-grand b {
  color: #92400e; font-size: 22px;
  font-variant-numeric: tabular-nums; margin-left: 8px;
}
.actions-right { display: flex; gap: 10px; }

/* ============ modal ============ */
.modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
/* атрибут hidden должен победить .modal display:flex */
.modal[hidden], [hidden] { display: none !important; }

/* hotspot — невидимая клик-зона на доме, при наведении подсвечивает */
#houseImage .hotspot {
  fill: #1f2937;
  fill-opacity: 0;
  transition: fill-opacity .15s;
}
#houseImage .hotspot:hover {
  fill-opacity: 0.12;
}

/* подпись разреза в модалке */
.cross-info {
  margin-top: 14px;
  padding: 12px 16px;
  background: #f9fafb;
  border-radius: 8px;
  font-size: 13px;
  color: #374151;
  line-height: 1.5;
}
.cross-info b { color: #1f2937; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(2px);
}
.modal-window {
  position: relative;
  background: #fff;
  border-radius: 14px;
  width: 100%; max-width: 880px;
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
  animation: modalIn .15s ease-out;
}
@keyframes modalIn {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
}
.modal-head h3 { margin: 0; font-size: 18px; color: #1f2937; }
.modal-close {
  background: none; border: none;
  font-size: 28px; line-height: 1; color: #9ca3af;
  cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: #1f2937; }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #f3f4f6;
}

/* ============ shared card grids (used in modals) ============ */
.shape-grid, .floor-grid, .wall-grid, .roof-grid, .rs-grid, .fs-grid, .soil-grid, .fd-types {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.shape-card, .floor-card, .wall-card, .roof-card, .soil-card, .fd-type {
  position: relative;
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px 12px;
  cursor: pointer;
  transition: transform .15s, border-color .15s, box-shadow .15s;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  text-align: center;
}
.shape-card:hover, .floor-card:hover, .wall-card:hover, .roof-card:hover, .soil-card:hover, .fd-type:hover {
  border-color: #fbbf24;
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(245, 158, 11, .15);
}
.shape-card.selected, .floor-card.selected, .wall-card.selected, .roof-card.selected, .soil-card.selected, .fd-type.selected {
  border-color: #f59e0b;
  background: #fffbeb;
  box-shadow: 0 4px 10px rgba(245, 158, 11, .2);
}
.roof-card .roof-tex { width: 100px; height: 60px; border-radius: 4px; overflow: hidden; }
.roof-card h3 { margin: 0; font-size: 14px; color: #1f2937; font-weight: 600; }
.roof-card p { margin: 0; font-size: 11px; color: #6b7280; line-height: 1.4; min-height: 32px; }
.shape-card .preview, .floor-card .silhouette {
  width: 100px; height: 70px;
  display: flex; align-items: end; justify-content: center;
}
.wall-card .wall-tex, .soil-card .soil-tex {
  width: 100px; height: 60px; border-radius: 4px; overflow: hidden;
}
.fd-type .icon { width: 100%; height: 60px; display: flex; align-items: center; justify-content: center; }
.shape-card h3, .floor-card h3, .wall-card h3, .soil-card h3 {
  margin: 0; font-size: 14px; color: #1f2937; font-weight: 600;
}
.fd-type h4 { margin: 0; font-size: 13px; color: #1f2937; font-weight: 600; }
.shape-card p, .floor-card p, .wall-card p, .soil-card p, .fd-type p {
  margin: 0; font-size: 11px; color: #6b7280; line-height: 1.4; min-height: 32px;
}
.shape-card .badge {
  display: inline-block;
  font-size: 11px; color: #92400e; background: #fef3c7;
  padding: 2px 8px; border-radius: 999px; font-weight: 600;
}

.wall-card .wall-stats, .soil-card .pills {
  display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; font-size: 11px;
}
.wall-card .pill, .soil-card .pill {
  background: #fef3c7; color: #92400e;
  padding: 2px 7px; border-radius: 999px; font-weight: 600;
}
.wall-card .pill.muted, .soil-card .pill.muted { background: #f3f4f6; color: #6b7280; }
.soil-card .pill.warn { background: #fee2e2; color: #991b1b; }
.soil-card .pill.ok   { background: #d1fae5; color: #065f46; }

.fd-type .star {
  position: absolute; top: -8px; right: 10px;
  background: #f59e0b; color: #fff;
  font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  box-shadow: 0 2px 4px rgba(245, 158, 11, .4);
}
.fd-type .star.bad {
  background: #ef4444;
  box-shadow: 0 2px 4px rgba(239, 68, 68, .35);
}
.fd-type.disabled {
  filter: blur(0.6px) grayscale(75%);
  opacity: 0.45;
  cursor: not-allowed !important;
  pointer-events: auto; /* чтобы tooltip работал */
}
.fd-type.disabled:hover {
  border-color: #e5e7eb;
  transform: none;
  box-shadow: none;
}
.fd-type.disabled p {
  color: #b91c1c;
  font-style: italic;
}

.floor-card .stat-bar, .wall-card .stat-bar {
  font-size: 11px; color: #92400e; background: #fef3c7;
  padding: 3px 8px; border-radius: 999px; font-weight: 600;
}

.silhouette .ground { stroke: #92400e; stroke-width: 1.5; stroke-dasharray: 3 2; }
.silhouette .body   { fill: #fef3c7; stroke: #f59e0b; stroke-width: 1.5; }
.silhouette .roof   { fill: #fcd34d; stroke: #d97706; stroke-width: 1.5; stroke-linejoin: round; }
.silhouette .basement { fill: #e5e7eb; stroke: #6b7280; stroke-width: 1.5; }
.silhouette .window { fill: #94d2bd; }

/* ============ size controls (in shape modal) ============ */
.size-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}
.size-preview {
  background: #fafaf7;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px;
  display: flex; flex-direction: column;
  min-height: 280px;
}
.size-preview svg { width: 100%; flex: 1; min-height: 220px; }
.size-stats {
  display: flex; gap: 10px;
  border-top: 1px dashed #e5e7eb;
  padding-top: 10px; margin-top: 8px;
}
.stat {
  flex: 1;
  display: flex; flex-direction: column; gap: 2px;
  padding: 6px 12px;
  background: #fff;
  border-radius: 8px;
}
.stat .muted { font-size: 11px; }
.stat b { font-size: 16px; color: #f59e0b; }

.size-controls { display: flex; flex-direction: column; gap: 12px; }
.ctrl {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
}
.ctrl-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.ctrl-head label { font-size: 12px; color: #374151; font-weight: 600; }
.ctrl-head .val {
  font-size: 15px; font-weight: 700; color: #f59e0b;
  font-variant-numeric: tabular-nums;
}
.ctrl-head .val .unit { font-size: 11px; color: #9ca3af; font-weight: 500; margin-left: 3px; }
.ctrl-row { display: flex; gap: 8px; align-items: center; }
.ctrl-row input[type=range] { flex: 1; margin: 0; }
.ctrl-row input[type=number] {
  width: 65px; padding: 4px 8px; border: 1px solid #d1d5db; border-radius: 4px;
  font: inherit; text-align: center;
}
.ctrl-hint { font-size: 11px; color: #9ca3af; margin-top: 5px; }

#sizePreview .plan { fill: #fef3c7; stroke: #f59e0b; stroke-width: 2; stroke-linejoin: round; }
#sizePreview .dim-text { fill: #4b5563; font-size: 12px; font-weight: 600; }

/* ============ GW row (in soil modal) ============ */
.gw-block {
  background: #f9fafb;
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 16px;
}
.gw-title { font-size: 14px; font-weight: 600; color: #1f2937; margin-bottom: 10px; }
.gw-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.gw-opt {
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
  text-align: center;
}
.gw-opt:hover { border-color: #fbbf24; }
.gw-opt.selected { border-color: #f59e0b; background: #fffbeb; }
.gw-opt .gw-icon { font-size: 20px; }
.gw-opt .gw-label { font-size: 13px; font-weight: 600; color: #1f2937; }
.gw-opt .gw-hint  { font-size: 10px; color: #6b7280; }

@media (max-width: 700px) { .gw-row { grid-template-columns: 1fr; } }

/* ============ dev panel ============ */
.dev-panel {
  background: #f9fafb;
  border: 1px dashed #d1d5db;
  border-radius: 10px;
  padding: 10px 14px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  margin-bottom: 10px;
}
.dev-panel-title { font-size: 11px; color: #6b7280; margin-bottom: 6px; }
.dev-panel-body { font-size: 12px; color: #1f2937; line-height: 1.5; }
.dev-panel-body b { color: #f59e0b; }

/* ============ footer ============ */
.footer {
  display: flex; justify-content: space-between;
  padding: 6px 14px; background: #1f2937; color: #9ca3af;
  font-size: 11px;
}
.api-status::before { content: "● "; color: #6b7280; }
.api-status.ok::before  { color: #10b981; }
.api-status.err::before { color: #ef4444; }

/* ============ view toggle ============ */
body.view-pro #dashView { display: none !important; }
body.view-pro #proView { display: grid !important; }
body.view-dash #proView { display: none !important; }

/* ============ pro view ============ */
.pro-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  gap: 12px;
  padding: 12px;
  min-height: 0;
}
.panel {
  background: #fff; border-radius: 6px; padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  overflow-y: auto;
}
.panel h2 { margin: 0 0 12px; font-size: 14px; text-transform: uppercase; color: #6b7280; letter-spacing: .5px; }
fieldset { border: 1px solid #e5e7eb; border-radius: 4px; padding: 10px 12px; margin: 0 0 12px; }
legend { font-weight: 600; font-size: 12px; color: #374151; padding: 0 4px; }
label { display: block; margin: 8px 0; font-size: 12px; color: #374151; }
label.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
label.check input { margin: 0; }
input[type=number], input[type=text], select {
  width: 100%; margin-top: 3px;
  padding: 5px 8px; border: 1px solid #d1d5db; border-radius: 4px;
  font: inherit; background: #fff;
}
input[type=range] { width: calc(100% - 50px); margin-right: 6px; vertical-align: middle; }
output { display: inline-block; min-width: 38px; font-weight: 600; color: #1f2937; }
.viewport { display: flex; flex-direction: column; background: #fff; border-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,.06); min-width: 0; min-height: 0; }
.viewport-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid #e5e7eb; }
.viewport-header h2 { margin: 0; font-size: 14px; text-transform: uppercase; color: #6b7280; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; }
.legend .item { display: flex; align-items: center; gap: 5px; cursor: pointer; padding: 2px 6px; border-radius: 3px; }
.legend .item:hover { background: #f3f4f6; }
.legend .swatch { width: 14px; height: 14px; border: 1px solid #6b7280; border-radius: 2px; }
.svg-wrap { flex: 1; padding: 8px; min-height: 400px; display: flex; }
#diagram { width: 100%; height: 100%; min-height: 380px; }
.results { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.result-row { display: flex; justify-content: space-between; padding: 6px 8px; border-radius: 4px; font-size: 12px; transition: background .15s; }
.result-row:nth-child(odd) { background: #f9fafb; }
.result-row.highlight { background: #fef3c7 !important; }
.result-row .name { color: #374151; }
.result-row .value { font-weight: 600; color: #1f2937; }
.totals { padding-top: 10px; border-top: 1px solid #e5e7eb; }
.total-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.total-row b { color: #f59e0b; }
#diagram .layer { transition: opacity .15s; cursor: pointer; }
#diagram .layer:hover { stroke-width: 2.5; }
#diagram .layer.dim { opacity: 0.25; }
#diagram text { font-size: 11px; fill: #1f2937; font-family: inherit; }
#diagram .dim-line { stroke: #6b7280; stroke-width: 1; }
#diagram .dim-text { fill: #4b5563; font-size: 10px; }

/* ============ responsive ============ */
@media (max-width: 1000px) {
  .dash-grid { grid-template-columns: 1fr; }
  .config-panel { order: 2; }
  .house-view { order: 1; }
}
@media (max-width: 1100px) {
  .pro-layout { grid-template-columns: 1fr; }
}
