* { 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;
  align-items: start; /* НЕ растягивать ячейки на высоту самой длинной (drill раздел не должен раздуть визуал) */
}

.config-panel {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  display: flex; flex-direction: column;
  /* фикс ширины — иначе длинный текст таба раздвигает grid track */
  min-width: 0;
  max-width: 360px;
  overflow: hidden;
}
.config-panel > div { min-width: 0; }
.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;
  flex-wrap: wrap; gap: 6px;
}
.house-view-head h2 { margin: 0; font-size: 18px; color: #1f2937; }
@media (max-width: 600px) {
  .house-view-head h2 { font-size: 15px; flex-basis: 100% }  /* h2 на отдельной строке — освобождает место остальным */
  .vm-btn { padding: 3px 6px; font-size: 10px }
  .view-mode-toggle { margin-left: 0; padding: 2px }
  .rotate-controls { padding-left: 4px; gap: 2px; margin-right: 0 }  /* убираем auto — flex-row распределяется свободно */
  .rotate-controls button { font-size: 10px; padding: 2px 4px }
  .house-mini-plan-wrap { font-size: 10px }
  .house-mini-plan { transform: scale(0.85); transform-origin: left center }
}
.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%; pointer-events: none; }
.house-mini-plan-btn {
  cursor: pointer;
  font-family: inherit;
  transition: border-color .12s, background .12s, transform .1s;
}
.house-mini-plan-btn:hover { border-color: #f59e0b; background: #fffbeb; }
.house-mini-plan-btn:active { transform: scale(0.95); }

/* Тултип при наведении на части дома (стены/крыша/окна/...) */
.scene-tooltip {
  position: absolute; z-index: 60;
  background: rgba(31,41,55,0.94); color: #fff;
  font-size: 12px; font-weight: 600;
  padding: 4px 9px; border-radius: 6px;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  white-space: nowrap;
  transform: translate(-50%, -125%);
  transition: opacity .08s ease;
}
.scene-tooltip::after {
  content: '';
  position: absolute; left: 50%; bottom: -5px;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid rgba(31,41,55,0.94);
}

/* === Переключатель 3D / План этажа === */
.view-mode-toggle {
  display: inline-flex; gap: 0;
  margin-left: 8px;
  background: #f3f4f6; border-radius: 8px; padding: 3px;
}
.vm-btn {
  background: transparent; border: none; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 600;
  padding: 5px 10px; border-radius: 6px;
  color: #6b7280;
  transition: background .12s, color .12s;
}
.vm-btn:hover { color: #1f2937; }
.vm-btn.vm-active { background: #fff; color: #16a34a; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* Кнопка «на весь экран» — иконка-оверлей в окне дома/плана (НИЗ-право, чтобы не
   перекрывать панель инструментов вверху) */
.house-fs-btn {
  position: absolute; bottom: 10px; right: 10px; z-index: 60;
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.92); color: #4b5563;
  font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  transition: background .12s, color .12s;
}
.house-fs-btn:hover { background: #fff; color: #111827; }
.house-view.fullscreen .house-fs-btn { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }

/* Разворот окна дома на весь экран */
.house-view.fullscreen {
  position: fixed; inset: 0; z-index: 3000;
  width: 100vw; height: 100vh; max-width: 100vw;
  border-radius: 0; margin: 0; padding: 12px 16px 14px;
  box-shadow: none;
}
.house-view.fullscreen .house-svg-wrap,
.house-view.fullscreen .house-scene { min-height: 0; flex: 1 1 auto; height: auto; }
body.house-fullscreen { overflow: hidden; }

/* Блок «Этажность» — НАД формой дома, аккуратной сеткой во всю ширину */
.drill-floors-block { margin: 0 0 14px; padding-bottom: 12px; border-bottom: 1px solid #eef0f2; }
.drill-block-title { font-size: 13px; font-weight: 700; color: #374151; margin-bottom: 7px; }
.drill-floors-row { display: flex; flex-direction: column; gap: 6px; }
.hf-pill-row, .hf-check-row { display: flex; gap: 6px; }
/* Единый стиль всех 4 кнопок в духе левого меню: серая рамка → зелёный активный */
.drill-floors-row .hf-pill,
.drill-floors-row .hf-check {
  flex: 1 1 0; justify-content: center; text-align: center;
  margin-left: 0; padding: 8px 8px;
  border: 1px solid #d1d5db; border-radius: 8px;
  background: #fff; color: #374151; box-shadow: none;
}
.drill-floors-row .hf-pill:hover,
.drill-floors-row .hf-check:hover { background: #f9fafb; border-color: #16a34a; color: #16a34a; }
.drill-floors-row .hf-pill.on,
.drill-floors-row .hf-check[data-on="1"] {
  background: #16a34a; color: #fff; border-color: #16a34a; box-shadow: none;
}
.drill-floors-row .hf-pill.on:hover,
.drill-floors-row .hf-check[data-on="1"]:hover { background: #15803d; color: #fff; }

/* === Поэтажный план — 2D-редактор внутренних стен === */
.plan-editor-wrap {
  position: absolute; inset: 0;
  background: #fafaf7;
  z-index: 30;
  display: flex; flex-direction: column;
  padding: 8px;
  box-sizing: border-box;
}
.plan-editor-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 6px;
  flex-wrap: wrap;   /* mobile: позволяет переносить блоки tabs/actions на отдельные строки */
}
.plan-floor-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.plan-floor-tab {
  background: #fff; border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px; font-weight: 600; color: #6b7280;
  cursor: pointer; font-family: inherit;
}
.plan-floor-tab:hover { background: #fffbeb; border-color: #fbbf24; color: #1f2937; }
.plan-floor-tab.on { background: #f59e0b; border-color: #d97706; color: #fff; }
.plan-actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.plan-toolbar-sep { display: inline-block; width: 1px; height: 22px; background: #e5e7eb; margin: 0 4px; }

/* Панель свойств выделенной стены */
.wall-props-panel {
  position: absolute; z-index: 30;
  top: 8px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: #fff; border: 2px solid #f59e0b; border-radius: 8px;
  padding: 6px 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  font-size: 12px;
}
.wpp-label { font-weight: 700; color: #b45309; }
.wpp-kind-toggle { display: inline-flex; border: 1px solid #d1d5db; border-radius: 6px; overflow: hidden; background: #fff; }
.wpp-kind-btn {
  padding: 5px 10px; font-size: 12px; background: transparent;
  border: 0; border-right: 1px solid #d1d5db; cursor: pointer;
  font-family: inherit; color: #4b5563; white-space: nowrap;
}
.wpp-kind-btn:last-child { border-right: 0; }
.wpp-kind-btn:hover { background: #fef3c7; color: #1f2937; }
.wpp-kind-btn.on { background: #f59e0b; color: #fff; font-weight: 700; }
.wpp-thick-label { display: inline-flex; align-items: center; gap: 4px; color: #4b5563; }
.wpp-thick-label input {
  width: 60px; padding: 4px 6px; border: 1px solid #d1d5db; border-radius: 4px;
  font-family: inherit; font-size: 12px;
}
.wpp-del-btn {
  padding: 5px 10px; font-size: 12px; background: #fff; border: 1px solid #fca5a5;
  color: #b91c1c; border-radius: 6px; cursor: pointer; font-family: inherit;
}
.wpp-del-btn:hover { background: #fee2e2; border-color: #ef4444; }
.plan-editor-body { position: relative; }

/* Вкладки промежутков между этажами для выбора перекрытия */
.fs-gap-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.fs-gap-tab {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 6px 12px; background: #fff; border: 1px solid #d1d5db; border-radius: 6px;
  cursor: pointer; font-family: inherit; font-size: 12px; text-align: left; min-width: 160px;
}
.fs-gap-tab:hover { background: #fffbeb; border-color: #fbbf24; }
.fs-gap-tab.on { background: #f59e0b; color: #fff; border-color: #d97706; font-weight: 600; }
.fs-gap-tab.on .fs-gap-sel { color: #fef3c7; }
.fs-gap-title { font-weight: 700; }
.fs-gap-sel { font-size: 11px; color: #6b7280; }
.fs-gap-empty { font-size: 12px; color: #6b7280; font-style: italic; padding: 8px; }

/* Модалка раскладки плит перекрытия — top-level fixed overlay */
.slab-layout-overlay {
  position: fixed; inset: 0;
  background: rgba(31, 41, 55, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000;
}
.slab-layout-modal {
  background: #fff; border-radius: 8px; width: 95vw; max-width: 1150px;
  max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.slab-layout-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid #e5e7eb;
}
.slab-layout-header h3 { margin: 0; font-size: 16px; color: #1f2937; }
.modal-close {
  background: transparent; border: 1px solid #e5e7eb; border-radius: 6px;
  width: 32px; height: 32px; cursor: pointer; font-size: 14px;
}
.modal-close:hover { background: #fef3c7; }
.slab-layout-warn {
  background: #fef2f2; color: #991b1b; padding: 10px 16px; font-size: 13px;
  border-bottom: 1px solid #fecaca; line-height: 1.5;
}
.slab-layout-body {
  display: grid; grid-template-columns: 1fr 360px; gap: 12px; padding: 12px;
  overflow: auto; min-height: 0; flex: 1;
}
.slab-layout-plan { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.slab-layout-legend {
  display: flex; gap: 14px; font-size: 12px; color: #4b5563; flex-wrap: wrap;
}
.slab-layout-legend .lg-sw {
  display: inline-block; width: 14px; height: 8px; vertical-align: middle; margin-right: 4px;
}
.lg-bearing { background: #b45309; }
.lg-partition { background: #9ca3af; border-top: 1px dashed #6b7280; height: 2px !important; }
.lg-plate { background: #c0c0c0; border: 1px solid #6b7280; }
#slabLayoutSvg {
  width: 100%; max-height: 70vh; background: #fafafa;
  border: 1px solid #e5e7eb; border-radius: 6px;
}
.slab-layout-side h4 { margin: 0 0 8px; font-size: 14px; color: #1f2937; }
.slab-layout-plates {
  display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow: auto;
}
.slab-layout-plates .plate-row {
  display: flex; gap: 8px; align-items: center; padding: 8px 10px;
  background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 12px;
}
.slab-layout-plates .plate-row .plate-name { flex: 1; font-weight: 600; }
.slab-layout-plates .plate-row .plate-meta { color: #6b7280; font-size: 11px; }
.slab-layout-plates .plate-row .plate-price { color: #b45309; font-weight: 700; white-space: nowrap; }
.slab-layout-total {
  background: #fef3c7; border: 1px solid #fbbf24; border-radius: 6px;
  padding: 10px 12px; margin-top: 8px; font-weight: 700; font-size: 13px; color: #1f2937;
}
.plan-btn {
  background: #fff; border: 1px solid #e5e7eb;
  border-radius: 6px; padding: 6px 10px;
  font-size: 12px; cursor: pointer; font-family: inherit;
  color: #6b7280;
  white-space: nowrap;
}
.plan-btn:hover { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
@media (max-width: 600px) {
  .plan-btn { padding: 5px 7px; font-size: 11px; }
  .plan-floor-tab { padding: 5px 9px; font-size: 11px; }
  .plan-editor-toolbar { gap: 4px; }
}
.plan-editor-body {
  flex: 1; position: relative;
  background: #fff;
  border: 1px solid #e5e7eb; border-radius: 8px;
  overflow: hidden;
  min-height: 0;
}
.plan-editor {
  width: 100%; height: 100%; display: block;
  touch-action: none;
  user-select: none;
  cursor: crosshair;
}
.plan-status {
  position: absolute; right: 8px; top: 8px;
  background: rgba(255,255,255,0.92);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px; color: #1f2937;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  pointer-events: none;
  max-width: 60%;
}
.plan-editor-hint {
  margin-top: 6px;
  font-size: 11px; color: #6b7280;
  background: #fffbeb;
  border-left: 3px solid #fbbf24;
  padding: 5px 10px;
  border-radius: 4px;
}

/* плановые SVG-стили */
.plan-house-outline { fill: #f3f4f6; stroke: #1f2937; stroke-width: 3; }
.plan-grid-line { stroke: #e5e7eb; stroke-width: 0.5; }
.plan-grid-line-major { stroke: #d1d5db; stroke-width: 0.8; }
.plan-wall-bearing { stroke: #b45309; stroke-width: 8; stroke-linecap: round; cursor: move; }
.plan-wall-bearing:hover { stroke: #92400e; }
.plan-wall-partition { stroke: #6b7280; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 8 4; cursor: move; }
.plan-wall-partition:hover { stroke: #1f2937; }
.plan-wall-ghost { stroke: #93c5fd; stroke-width: 6; stroke-linecap: round; opacity: 0.5; pointer-events: none; }
.plan-wall-required { stroke: #dc2626; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 6 6; opacity: 0.6; pointer-events: none; }
.plan-wall-warning { stroke: #dc2626; stroke-width: 10; stroke-linecap: round; opacity: 0.3; pointer-events: none; }
.plan-wall-selected-halo { fill: none; stroke: #2563eb; stroke-width: 14; stroke-linecap: round; opacity: 0.35; pointer-events: none; }
/* Проёмы (двери/окна) — рисуются поверх стен */
.opening-erase { stroke: #fff; stroke-linecap: butt; pointer-events: none; }
.opening-erase.opening-bearing { stroke-width: 9; } /* перекрываем bearing wall (stroke-width 8) */
.opening-erase.opening-partition { stroke-width: 5; }
.opening-window-line { stroke: #3b82f6; stroke-width: 1.2; pointer-events: none; }
.opening-door-arc { stroke: #3b82f6; stroke-width: 1; fill: none; stroke-dasharray: 2 2; pointer-events: none; }
.opening-door-leaf { stroke: #3b82f6; stroke-width: 1.5; pointer-events: none; }

.plan-point { fill: #fff; stroke: #1f2937; stroke-width: 2; cursor: move; touch-action: none; }
.plan-point:hover { fill: #fef3c7; }
.plan-point-mid { fill: #fbbf24; stroke: #92400e; } /* промежуточные вершины polyline — отличаем от концов */
.plan-point-pending { fill: #fbbf24; stroke: #b45309; }
/* Pending-точки текущей рисуемой стены — отдельный класс чтобы не пересекаться с plan-point router */
.plan-pending-point { fill: #fbbf24; stroke: #b45309; stroke-width: 2; cursor: move; touch-action: none; }
.plan-pending-point.first { fill: #f59e0b; stroke: #92400e; stroke-width: 2.5; }
.plan-pending-point:hover { fill: #fde68a; }
.plan-wall-pending { stroke: #b45309; stroke-width: 8; stroke-linecap: round; opacity: 0.7; pointer-events: none; }
.plan-ghost-line { stroke: #b45309; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 4 4; opacity: 0.45; pointer-events: none; }
/* Активный инструмент (Окно/Дверь/Комната) — подсветка кнопки */
.plan-btn.tool-active {
  background: #d97706 !important;
  color: #fff !important;
  border-color: #78350f !important;
  box-shadow: inset 0 3px 5px rgba(0,0,0,0.35), 0 0 0 2px #fbbf24 !important;
  transform: translateY(1px);
  font-weight: 700;
}
.plan-btn.tool-active:hover { background: #b45309 !important; }
/* Опеннинг-маркер: маленький кружок поверх проёма для click-to-delete */
.opening-handle { fill: #3b82f6; stroke: #1e40af; stroke-width: 1; cursor: pointer; }
.opening-handle:hover { fill: #f59e0b; stroke: #b45309; }
/* Метка комнаты (тип + название) */
.plan-room-label { font-size: 13px; fill: #1f2937; font-weight: 700; text-anchor: middle; pointer-events: none; }
.plan-room-area { font-size: 10px; fill: #4b5563; text-anchor: middle; pointer-events: none; }
.plan-room-hit { fill: transparent; cursor: pointer; }
.plan-room-hit:hover { fill: rgba(251,191,36,0.18); }

/* === Модалка генератора плана === */
.plan-gen-overlay {
  position: absolute; inset: 0;
  background: rgba(31,41,55,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 40;
}
.plan-gen-modal {
  background: #fff; border-radius: 12px;
  padding: 18px 22px;
  max-width: 480px; width: calc(100% - 24px);
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
  max-height: calc(100% - 24px); overflow: auto;
}
.plan-gen-modal h3 { margin: 0 0 6px; font-size: 17px; color: #1f2937; }
.plan-gen-sub { font-size: 12px; color: #6b7280; margin: 0 0 14px; }
.plan-gen-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.plan-gen-row > label { font-size: 13px; font-weight: 600; color: #374151; min-width: 120px; }
.plan-gen-pills { display: flex; gap: 4px; flex-wrap: wrap; }
.pgp {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 7px;
  padding: 6px 12px; cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 600; color: #6b7280;
}
.pgp:hover { background: #fef3c7; border-color: #fbbf24; color: #1f2937; }
.pgp.on { background: #16a34a; border-color: #15803d; color: #fff; }
.plan-gen-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid #f3f4f6;
}
.plan-btn-primary {
  background: #f59e0b; border-color: #d97706; color: #fff;
}
.plan-btn-primary:hover { background: #d97706; color: #fff; }
.plan-gen-roomslist {
  font-size: 11px; color: #6b7280; margin-top: 10px; padding-top: 8px; border-top: 1px dashed #e5e7eb;
}

/* === Каталог готовых планов === */
.plan-cat-modal { max-width: 760px; }
.plan-cat-filters { padding: 4px 0 10px; border-bottom: 1px dashed #e5e7eb; margin-bottom: 10px; }
.plan-cat-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  max-height: 50vh; overflow-y: auto;
  padding: 4px 2px 4px 0;
}
.plan-cat-card {
  background: #fafaf7; border: 2px solid #e5e7eb; border-radius: 10px;
  padding: 8px; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color .12s, transform .1s;
}
.plan-cat-card:hover { border-color: #fbbf24; background: #fffbeb; }
.plan-cat-card.applied { border-color: #16a34a; background: #f0fdf4; }
.plan-cat-card .plan-cat-preview {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 6px;
  height: 130px; overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.plan-cat-card .plan-cat-preview svg { width: 100%; height: 100%; display: block; }
.plan-cat-card .plan-cat-title { font-size: 12px; font-weight: 700; color: #1f2937; line-height: 1.2; }
.plan-cat-card .plan-cat-meta { font-size: 10px; color: #6b7280; }
.plan-cat-empty {
  grid-column: 1 / -1;
  text-align: center; color: #6b7280; font-size: 13px;
  padding: 30px 10px;
}
.plan-dim-text { fill: #1f2937; font-size: 11px; font-weight: 600; pointer-events: none; }
.plan-dim-line { stroke: #9ca3af; stroke-width: 1; pointer-events: none; }

/* В режиме плана прячем все 3D-оверлеи (vis, floors, scene-tools, scene-help) */
.plan-mode .scene-tools,
.plan-mode .scene-help,
.plan-mode .house-vis-toggles,
.plan-mode .house-floors-pills,
.plan-mode #houseScene,
.plan-mode .framing-vis-panel { display: none !important; }

.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;
  touch-action: none;        /* отдаём жесты Three.js OrbitControls (pinch-zoom, drag-rotate) */
}
.house-svg-wrap:active { cursor: grabbing; }
/* Когда открыт color-editor — дать слоту высоты, чтобы оба плана влезали */
.house-svg-wrap.plan-mode:has(#planColorEditor:not([hidden])) { min-height: 72vh; }
.house-scene { width: 100%; height: 100%; min-height: 460px; touch-action: none; }
.house-scene canvas { display: block; outline: none; touch-action: none; }

/* Этажность — сворачиваемый pill-бар поверх 3D, в правом нижнем углу */
.house-floors-pills {
  position: absolute; bottom: 44px; right: 10px; z-index: 50;
  display: flex; flex-direction: column; gap: 3px;
  background: rgba(255,255,255,0.92); border-radius: 8px;
  padding: 4px; box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  user-select: none;
}
.house-floors-pills .overlay-content {
  display: flex; gap: 3px; flex-wrap: wrap;
}
.hf-pill {
  font-size: 12px; font-weight: 600;
  padding: 5px 10px; border-radius: 6px;
  cursor: pointer; color: #6b7280;
  background: transparent; border: 1px solid transparent;
  white-space: nowrap; line-height: 1;
  font-family: inherit;
}
.hf-pill:hover { background: #f3f4f6; color: #1f2937; }
.hf-pill.on { background: #f59e0b; color: #fff; box-shadow: 0 1px 3px rgba(245,158,11,0.4); }
.hf-check {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; color: #6b7280;
  padding: 5px 8px; border-radius: 6px; cursor: pointer;
  margin-left: 4px;
  white-space: nowrap;
}
.hf-check:hover { background: #f3f4f6; color: #1f2937; }
.hf-check[data-on="1"] { background: #16a34a; color: #fff; }
.hf-check[data-on="1"]:hover { background: #15803d; }
.hf-check.hf-disabled { opacity: 0.4; cursor: not-allowed; }
.hf-check.hf-disabled:hover { background: transparent; color: #6b7280; }
.hf-check input { margin: 0; cursor: inherit; accent-color: #16a34a; }

/* === Сворачиваемые overlay-панели на 3D-визуале === */
.overlay-toggle {
  background: transparent; border: none; cursor: pointer;
  font-family: inherit; font-size: 11px; font-weight: 700; color: #6b7280;
  padding: 2px 4px 4px; margin: 0; line-height: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  border-bottom: 1px dashed #e5e7eb;
}
.overlay-toggle:hover { color: #1f2937; }
.overlay-toggle-arrow { font-size: 9px; transition: transform .15s ease; }
.overlay-collapsible.collapsed .overlay-toggle { border-bottom: none; padding-bottom: 2px; }
.overlay-collapsible.collapsed .overlay-toggle-arrow { transform: rotate(-90deg); }
.overlay-collapsible.collapsed .overlay-content { display: none; }
.overlay-content { padding-top: 4px; }
.house-vis-toggles .overlay-content { display: flex; flex-direction: column; gap: 4px; }

/* === Сворачиваемые полосы материалов стен/кровли под визуалом === */
.quick-bar-wrap {
  margin-top: 10px;
}
.qbw-toggle {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 8px 12px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 700; color: #1f2937;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  transition: background .12s;
}
.qbw-toggle:hover { background: #fef3c7; }
.qbw-title { flex-shrink: 0; }
.qbw-current { flex: 1; text-align: left; color: #6b7280; font-weight: 500; font-size: 12px; }
.qbw-arrow { font-size: 10px; color: #6b7280; transition: transform .15s ease; }
.quick-bar-wrap.collapsed .qbw-arrow { transform: rotate(-90deg); }
.quick-bar-wrap .wall-quick-bar,
.quick-bar-wrap .roof-quick-bar {
  margin-top: 6px; /* отступ от заголовка-кнопки */
}
.quick-bar-wrap.collapsed .wall-quick-bar,
.quick-bar-wrap.collapsed .roof-quick-bar { display: none; }

/* === Когда полосы свёрнуты, визуал растёт на их высоту; разворот возвращает обратно. === */
.house-view.wall-bar-collapsed .house-svg-wrap,
.house-view.wall-bar-collapsed .house-scene,
.house-view.roof-bar-collapsed .house-svg-wrap,
.house-view.roof-bar-collapsed .house-scene { min-height: 550px; }
.house-view.wall-bar-collapsed.roof-bar-collapsed .house-svg-wrap,
.house-view.wall-bar-collapsed.roof-bar-collapsed .house-scene { min-height: 640px; }

/* Видимость частей дома — overlay в левом нижнем углу 3D-визуала (НАД sceneHelp, чтобы не перекрывать scene-tools сверху) */
.house-vis-toggles {
  position: absolute; bottom: 44px; left: 10px; z-index: 50;
  background: rgba(255,255,255,0.92); border-radius: 8px;
  padding: 6px 10px; box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  display: flex; flex-direction: column; gap: 3px;
  font-size: 12px; font-weight: 500; color: #1f2937;
  user-select: none;
}
.house-vis-toggles label {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer;
}
.house-vis-toggles input[type=checkbox] {
  margin: 0; cursor: pointer; accent-color: #16a34a;
}
.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;
}
/* Аккордеон секций в drill-down */
.drill-section {
  margin-bottom: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}
.drill-section-active {
  border-color: #fbbf24;
  background: #fffbeb;
}
.drill-section-header {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  background: transparent;
  border: none;
  color: #1f2937;
  font-size: 13px; font-weight: 600;
  padding: 10px 12px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}
.drill-section-header:hover { background: #fef3c7; }
.drill-section-active .drill-section-header { background: #fef3c7; }
.drill-section-arrow {
  display: inline-block;
  width: 12px;
  font-size: 10px;
  color: #6b7280;
}
.drill-section-title-text { flex-shrink: 0; }
.drill-section-summary {
  margin-left: auto;
  font-weight: 400;
  font-size: 12px;
  color: #6b7280;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drill-section-body {
  padding: 10px 12px 14px;
  border-top: 1px solid #fbbf24;
}

/* Drill-down режим левой панели */
.btn-back-drill {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  color: #1f2937;
  font-size: 13px; font-weight: 600;
  padding: 6px 12px; border-radius: 6px;
  cursor: pointer;
  margin-bottom: 12px;
  font-family: inherit;
}
.btn-back-drill:hover { background: #e5e7eb; }

/* Когда drill-down активен — расширяем левую колонку чтобы поместился план кровли.
   Чуть шире чем сам план (500px viewBox + padding). */
body.drill-active .dash-grid { grid-template-columns: 440px 1fr; }
@media (max-width: 1000px) {
  body.drill-active .dash-grid { grid-template-columns: 1fr; }
}
/* В drill-down плане ставим SVG над apex-списком (не рядом). */
#configPanelDrill .custom-roof-layout { grid-template-columns: 1fr; gap: 12px; }
#configPanelDrill .custom-roof-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
#configPanelDrill .custom-roof-designer { padding: 10px; }
#configPanelDrill .rs-grid,
#configPanelDrill .shape-grid,
#configPanelDrill .floor-grid,
#configPanelDrill .roof-grid,
#configPanelDrill .fs-grid,
#configPanelDrill .soil-grid,
#configPanelDrill .fd-types { grid-template-columns: 1fr 1fr; gap: 8px; }
#configPanelDrill .shape-card,
#configPanelDrill .roof-card,
#configPanelDrill .floor-card { padding: 10px; }
#configPanelDrill .shape-card .preview svg,
#configPanelDrill .floor-card .preview svg { max-width: 100%; height: auto; }

/* Свёрнутая плашка выбора типа крыши — экономит вертикальное место когда тип уже выбран. */
.rs-collapsed-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: #fef3c7; border: 1px solid #fbbf24;
  border-radius: 8px; margin-bottom: 12px;
  font-size: 13px;
}
.rs-cb-label { color: #78350f; }
.rs-cb-name { color: #92400e; font-size: 14px; }
.rs-cb-toggle {
  margin-left: auto;
  background: #fff; border: 1px solid #fbbf24;
  color: #92400e; font-weight: 600;
  padding: 5px 12px; border-radius: 6px;
  cursor: pointer; font-family: inherit; font-size: 12px;
}
.rs-cb-toggle:hover { background: #fef3c7; }

/* Inline-этажность в shape-секции */
.fl-btn {
  flex: 1;
  background: #fff;
  border: 1.5px solid #d1d5db;
  color: #1f2937;
  font-size: 13px; font-weight: 600;
  padding: 8px 12px; border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s, border-color .12s;
}
.fl-btn:hover { background: #fef3c7; border-color: #fbbf24; }
.fl-btn-active {
  background: #f59e0b; color: #fff; border-color: #f59e0b;
}

/* Сворачиваемая секция «Коньковые точки» */
.apex-section {
  margin-top: 14px;
  border-top: 1px solid #e5e7eb;
  padding-top: 10px;
}
.apex-section-toggle {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  background: transparent;
  border: none;
  color: #1f2937;
  font-size: 13px; font-weight: 600;
  padding: 6px 0;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}
.apex-section-toggle:hover { color: #2563eb; }
.apex-section-arrow {
  display: inline-block;
  width: 14px;
  font-size: 11px;
  color: #6b7280;
  transition: transform .15s;
}
.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:disabled,
.scene-tool[disabled] {
  opacity: 0.4; cursor: not-allowed; background: #f3f4f6; color: #9ca3af;
  border-color: #e5e7eb; box-shadow: none;
}
.scene-tool:disabled:hover,
.scene-tool[disabled]:hover { background: #f3f4f6; border-color: #e5e7eb; color: #9ca3af; }
.scene-tool.active {
  background: #f59e0b; color: #fff; border-color: #f59e0b;
  box-shadow: 0 2px 6px rgba(245,158,11,.4);
}
.scene-tool.on {
  background: #16a34a; color: #fff; border-color: #16a34a;
  box-shadow: 0 2px 6px rgba(22,163,74,.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; }

/* === Полоса материалов стен и кровли под 3D-визуалом (быстрый шорткат) === */
.wall-quick-bar, .roof-quick-bar, .roof-shape-quick-bar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 6px; margin-top: 10px; padding: 8px;
  background: #fff; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.wall-quick-card, .roof-quick-card, .roof-shape-quick-card {
  cursor: pointer; padding: 4px 4px 5px; border: 2px solid #e5e7eb; border-radius: 8px;
  background: #fff; text-align: center; transition: border-color .12s, transform .1s;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.wall-quick-card:hover, .roof-quick-card:hover, .roof-shape-quick-card:hover { border-color: #fbbf24; transform: translateY(-1px); }
.wall-quick-card.selected, .roof-quick-card.selected, .roof-shape-quick-card.selected { border-color: #16a34a; background: #f0fdf4; }
.wall-quick-card .wq-tex, .roof-quick-card .wq-tex, .roof-shape-quick-card .wq-tex { width: 50px; height: 26px; border-radius: 3px; overflow: hidden; }
.wall-quick-card .wq-tex svg, .roof-quick-card .wq-tex svg, .roof-shape-quick-card .wq-tex svg { width: 100%; height: 100%; display: block; }
.wall-quick-card .wq-title, .roof-quick-card .wq-title, .roof-shape-quick-card .wq-title { font-size: 11px; font-weight: 600; line-height: 1.1; }
.roof-shape-quick-card.disabled { opacity: 0.4; cursor: not-allowed; }
.roof-shape-quick-card.disabled:hover { transform: none; border-color: #e5e7eb; }

/* === Описания вынесены в title=tooltip — на самих карточках скрыты === */
.shape-card p, .floor-card p, .wall-card p, .roof-card p, .soil-card p, .fd-type p,
.wall-grid-row > .wall-card p, .rs-grid .rs-card p, .fs-grid .fs-card p {
  display: none !important;
}
.wall-quick-card .wq-price, .roof-quick-card .wq-price {
  font-size: 12px; font-weight: 700; color: #dc2626;
  background: #fef3c7; padding: 1px 5px; border-radius: 5px;
  margin-top: 1px;
}
.wall-quick-card .wq-price small, .roof-quick-card .wq-price small { font-size: 9px; color: #92400e; font-weight: 600; }
.wall-quick-card .wq-price-best, .roof-quick-card .wq-price-best { background: #dcfce7; color: #15803d; }
.wall-quick-card .wq-price-best::before, .roof-quick-card .wq-price-best::before { content: '👍 '; }
.wall-quick-card .wq-price-na, .roof-quick-card .wq-price-na { background: #f3f4f6; color: #6b7280; font-weight: 500; font-size: 11px; }

/* === Каталог стен в левой панели — компактный со scroll и live-превью === */
#configPanelWallCatalog .wcat-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.wcat-title { margin: 0; font-size: 18px; color: #1f2937; }
.wcat-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px;
  background: #f3f4f6; padding: 4px; border-radius: 10px;
}
.wcat-tab {
  background: transparent; border: none; padding: 7px 8px; border-radius: 7px;
  font-size: 12px; font-weight: 600; cursor: pointer; color: #6b7280;
  transition: background .12s, color .12s;
}
.wcat-tab:hover { color: #1f2937; }
.wcat-tab.on { background: #fff; color: #16a34a; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.wcat-tab.disabled { opacity: 0.35; cursor: not-allowed; }
.wcat-tab.disabled:hover { color: #6b7280; }
.wcat-options {
  font-size: 11px; color: #6b7280; padding: 4px 8px;
  background: #f9fafb; border-radius: 6px; margin-bottom: 8px;
  min-height: 18px;
}
.wcat-list-wrap {
  position: relative; height: 460px;
  border: 1px solid #f3f4f6; border-radius: 10px; overflow: hidden;
  background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
}
.wcat-list {
  height: 100%; overflow-y: auto; padding: 200px 8px;  /* большой top/bottom — чтобы крайние карточки могли быть «по центру» */
  scroll-snap-type: y mandatory;
}
.wcat-list::-webkit-scrollbar { width: 6px; }
.wcat-list::-webkit-scrollbar-track { background: transparent; }
.wcat-list::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 3px; }
.wcat-item {
  display: flex; gap: 10px; padding: 8px; margin-bottom: 6px;
  background: #fff; border: 2px solid transparent; border-radius: 10px;
  cursor: pointer; scroll-snap-align: center; transition: border-color .15s, transform .12s;
}
.wcat-item:hover { border-color: #fbbf24; }
.wcat-item.centered:not(.active) {
  border-color: #fbbf24; background: #fffbeb;
}
.wcat-item.active {
  border-color: #16a34a; background: #f0fdf4;
  box-shadow: 0 2px 8px rgba(22,163,74,.15);
}
.wcat-item.active.centered { transform: scale(1.02); }
.wcat-item img {
  width: 64px; height: 64px; object-fit: cover; border-radius: 6px;
  background: #f3f4f6; flex-shrink: 0;
}
.wcat-item .wcat-info { flex: 1; min-width: 0; }
.wcat-item .wcat-name { font-size: 12px; font-weight: 600; color: #1f2937; line-height: 1.2; margin-bottom: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wcat-item .wcat-meta { font-size: 10px; color: #6b7280; }
.wcat-item .wcat-price { font-size: 13px; font-weight: 700; color: #dc2626; margin-top: 2px; }
/* Полоска по центру — подсказка «клик чтобы примерить на дом» (НЕ авто-apply) */
.wcat-center-mark {
  position: absolute; left: 8px; right: 8px; top: 50%; transform: translateY(-50%);
  height: 84px; pointer-events: none; border-radius: 8px;
  border-top: 2px dashed rgba(251, 191, 36, .55);
  border-bottom: 2px dashed rgba(251, 191, 36, .55);
}
.wcat-center-mark::after {
  content: 'клик — примерить';
  position: absolute; right: 8px; bottom: 4px;
  font-size: 10px; color: #92400e; background: rgba(255,255,255,.85);
  padding: 1px 6px; border-radius: 4px;
}
.wcat-foot { margin-top: 10px; }
.wcat-foot .btn-block { width: 100%; }
.wall-quick-total {
  margin-top: 8px; padding: 10px 14px; background: #fef3c7; border-radius: 10px;
  display: flex; align-items: center; gap: 12px; font-size: 13px;
  border-left: 4px solid #f59e0b;
}
.wall-quick-total .wq-label { color: #92400e; font-weight: 600; }
.wall-quick-total .wq-amount { font-size: 20px; color: #dc2626; }
.wall-quick-total .wq-meta { color: #92400e; font-size: 11px; margin-left: auto; }

/* === Большой итог "Итого по проекту" в левой панели === */
.project-total {
  margin-top: 12px; padding: 14px 16px; background: #fef3c7; border-radius: 10px;
  border-left: 4px solid #f59e0b;
}
.project-total .pt-label { color: #92400e; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.project-total .pt-amount { display: block; font-size: 24px; color: #dc2626; font-weight: 700; line-height: 1.15; }
.project-total .pt-meta { color: #92400e; font-size: 11px; margin-top: 4px; }

/* === 5 типов стен — auto-fit grid (на широком 5 в ряд, на узком 2-3 — переносит) === */
.wall-grid-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 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;
  height: 32px; display: flex; align-items: center;
  margin-bottom: 10px;
}
/* Табы во "втором" ярусе карточки — занимают ту же высоту что .layer-title,
   обе карточки в .layers-row выравниваются по верху одинаково. */
.layer-tabs {
  display: flex; gap: 0;
  height: 32px;
  margin-bottom: 10px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  overflow: hidden;
}
.layer-tab {
  flex: 1;
  border: 0; background: transparent;
  cursor: pointer;
  font-size: 13px; font-weight: 500;
  color: #4b5563;
  padding: 0 10px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .12s, color .12s;
}
.layer-tab:hover { background: #e5e7eb; color: #111827; }
.layer-tab.on {
  background: #16a34a;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(22,163,74,.35);
}

/* Слайдер толщины штукатурного слоя */
.plaster-thickness {
  margin-bottom: 10px;
  padding: 8px 10px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
.plaster-thickness label { font-size: 12px; color: #4b5563; display: block; margin-bottom: 4px; }
.plaster-thickness label b { color: #166534; font-size: 14px; }
.plaster-thickness input[type=range] { width: 100%; cursor: pointer; }
.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-section-header {
  grid-column: 1 / -1;
  font-size: 13px; font-weight: 700;
  color: #1f2937;
  padding: 14px 8px 4px;
  border-bottom: 2px solid #e5e7eb;
  margin-top: 6px;
  position: sticky; top: 0;
  background: #fff; z-index: 1;
}
.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-noimg { display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: rgba(255,255,255,.6); text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.admin-noimg { display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: rgba(255,255,255,.6); text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.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; }

/* Подсветка строк BOM без цены */
.bom-row-missing { background: #fef3c7; }
.bom-row-missing .name { color: #92400e; }
.price.missing { color: #b45309; font-weight: 700; cursor: help; }
#bomGrandTotal .missing,
#costTotal .missing { color: #b45309; font-size: 12px; font-weight: 600; }

/* === Аккордеон-секции в смете === */
.bom-section-acc {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  margin-bottom: 8px;
  overflow: hidden;
}
.bom-section-acc > summary {
  cursor: pointer;
  padding: 10px 14px;
  font-size: 14px;
  background: #f9fafb;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.bom-section-acc > summary::-webkit-details-marker { display: none; }
.bom-section-acc > summary:before { content: '▸ '; color: #6b7280; font-weight: 700; transition: transform .15s; display: inline-block; }
.bom-section-acc[open] > summary:before { content: '▾ '; }
.bom-section-acc[open] > summary { background: #f3f4f6; border-bottom: 1px solid #e5e7eb; }
.bom-sect-title { font-weight: 700; color: #1f2937; }
.bom-sect-meta { font-size: 12px; }
.bom-sect-sum { margin-left: auto; font-weight: 600; color: #166534; font-size: 13px; }
.bom-sect-sum .missing { font-weight: 600; }
.bom-section-acc .bom-rows { padding: 4px 0; }
.bom-section-acc .bom-row { padding: 6px 14px; }

/* === 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 70px 100px 100px 110px;
  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 .count { color: #0f766e; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.bom-row .unit-price { color: #6b7280; font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; }
.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;
}
@media (max-width: 720px) {
  .modal-window { border-radius: 8px; max-height: calc(100vh - 16px); }
  .modal-head { padding: 10px 14px; }
  .modal-head h3 { font-size: 16px; }
  .modal-body { padding: 12px; }
  .modal-foot { padding: 10px 12px; }
}
@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;
}
.roof-card.disabled {
  filter: blur(0.6px) grayscale(75%);
  opacity: 0.45;
  cursor: not-allowed !important;
}
.roof-card.disabled:hover {
  border-color: #e5e7eb;
  transform: none;
  box-shadow: none;
}
.roof-card.disabled p { color: #b91c1c; font-style: italic; }

.custom-roof-designer { padding: 16px; background: #fafaf9; border-radius: 8px; margin-top: 12px; }
.custom-roof-layout { display: grid; grid-template-columns: 1fr 240px; gap: 16px; align-items: start; }
.custom-roof-layout svg { width: 100%; height: auto; max-height: 380px; min-height: 240px; }
.custom-apex-list { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 720px) {
  .custom-roof-designer { padding: 10px; }
  .custom-roof-layout { grid-template-columns: 1fr; gap: 12px; }
  .custom-roof-layout svg { max-height: 320px; min-height: 200px; }
  .custom-roof-toolbar { flex-wrap: wrap; gap: 6px; }
  .custom-roof-toolbar .cr-tool-btn,
  .custom-roof-toolbar .cr-tool-check { font-size: 12px; padding: 5px 8px; }
  .custom-apex-row { font-size: 13px; }
}
.custom-apex-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; background: #fff; border-radius: 6px;
  font-size: 12px;
}
.custom-apex-num {
  display: inline-block; width: 22px; height: 22px;
  border-radius: 50%; background: #dc2626; color: #fff;
  text-align: center; line-height: 22px; font-weight: 700;
  flex-shrink: 0;
}
.custom-apex-row label { flex: 1; display: flex; align-items: center; gap: 4px; }
.custom-apex-row input[type=range] { flex: 1; }
.custom-apex-del { padding: 2px 8px !important; color: #b91c1c; }
.custom-apex-row > label.apex-lock {
  flex: 0 0 auto;
  display: inline-flex; align-items: center;
  cursor: pointer;
  width: 18px; height: 18px;
  margin-right: 2px;
}
.custom-apex-row > label.apex-lock input {
  margin: 0; flex: 0 0 auto; width: 16px; height: 16px; cursor: pointer;
}
.custom-apex-row > .apex-lock-pad {
  flex: 0 0 auto;
  display: inline-block;
  width: 20px; height: 18px;
}
.custom-section-hdr {
  font-size: 11px; font-weight: 700; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-top: 12px; margin-bottom: 4px; padding: 0 4px;
}
.custom-ray-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; background: #fff; border-radius: 6px;
  font-size: 12px; border: 1px solid #e5e7eb;
}
.custom-ray-row.excluded { opacity: 0.5; background: #f3f4f6; text-decoration: line-through; }
.custom-ray-label {
  display: inline-block; min-width: 28px; height: 22px;
  border-radius: 4px; padding: 0 6px;
  text-align: center; line-height: 20px; font-weight: 700;
  border: 2px solid; font-size: 11px;
  flex-shrink: 0;
}
.custom-ray-info { flex: 1; color: #475569; font-size: 12px; }
.custom-ray-del {
  padding: 2px 8px !important; color: #b91c1c;
  font-size: 11px !important; white-space: nowrap;
}
.custom-roof-toolbar { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.custom-roof-toolbar .btn-ghost { font-size: 12px; padding: 4px 10px; }
.cr-tool-btn {
  font-size: 13px; padding: 6px 12px; border-radius: 6px;
  background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1;
  cursor: pointer; font-weight: 600;
}
.cr-tool-btn:hover:not([disabled]) { background: #e2e8f0; }
.cr-tool-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.cr-tool-btn.active {
  background: #f59e0b; color: #fff; border-color: #d97706;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.3);
}
.cr-tool-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; padding: 6px 10px; border-radius: 6px;
  background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1;
  cursor: pointer; font-weight: 600;
}
.cr-tool-check input { margin: 0; cursor: pointer; }
.cr-tool-check:has(input:checked) {
  background: #fef3c7; border-color: #f59e0b; color: #92400e;
}
.cr-tool-step {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; padding: 6px 10px; border-radius: 6px;
  background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1;
  font-weight: 600; cursor: pointer;
}
.cr-tool-step input[type=range] { width: 90px; cursor: pointer; }
.cr-tool-step b { color: #b45309; min-width: 28px; text-align: right; }
.cr-mode-hint {
  font-size: 12px; padding: 8px 12px;
  background: #fef3c7; border-radius: 6px; color: #78350f;
  margin-bottom: 8px; border-left: 3px solid #f59e0b;
}
.roof-card .star.bad {
  display: inline-block; background: #fee2e2; color: #b91c1c;
  font-size: 10px; padding: 2px 6px; border-radius: 999px; margin-bottom: 4px;
}

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

/* ============ Эркеры (раздел в shape-модалке) ============ */
.erker-section {
  margin-top: 24px;
  padding: 16px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}
.erker-section-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.erker-section-title { margin: 0; font-size: 15px; color: #1f2937; }
.erker-section-hint  { font-size: 12px; color: #6b7280; margin-top: 8px; }
.erker-list { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.erker-empty {
  font-size: 13px; color: #9ca3af; padding: 16px; text-align: center;
  background: #fff; border: 1px dashed #d1d5db; border-radius: 8px;
}
.erker-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 12px 14px;
}
.erker-card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid #f3f4f6;
}
.erker-del-btn {
  background: transparent; border: 1px solid #fca5a5; color: #b91c1c;
  border-radius: 6px; padding: 3px 10px; font-size: 12px; cursor: pointer;
}
.erker-del-btn:hover { background: #fee2e2; }
.erker-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px;
}
.erker-ctrl { display: flex; flex-direction: column; gap: 4px; }
.erker-ctrl > label { font-size: 12px; color: #374151; font-weight: 600; }
.erker-ctrl-head { display: flex; justify-content: space-between; align-items: baseline; }
.erker-ctrl-head b { font-size: 13px; color: #0f766e; }
.erker-ctrl-row { display: flex; gap: 6px; align-items: center; }
.erker-ctrl-row input[type=range] { flex: 1; margin: 0; }
.erker-ctrl-row input[type=number] { width: 70px; padding: 3px 6px; border: 1px solid #d1d5db; border-radius: 5px; font-size: 12px; }
.erker-ctrl select { padding: 5px 8px; border: 1px solid #d1d5db; border-radius: 5px; font-size: 13px; background: #fff; }

/* ============ 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; }
}

/* ===========================================================================
   MOBILE (≤ 720px): полная переработка под телефон
   - визуал занимает 60vh, фиксированный (без min-height скачков от полос)
   - scene-tools: горизонтальный скролл вместо переполнения экрана
   - overlay-панели свёрнуты по умолчанию, занимают мало места
   - материалы (стены/кровля): горизонтальный скролл-список вместо узкого grid
   - dev-панель, footer и pro-view скрыты
   - touch-friendly: кнопки ≥ 38px, увеличенные tap-targets
   =========================================================================== */
@media (max-width: 720px) {
  /* topbar — оставляем только бренд + смета; «Сброс» и «Профи-режим» уезжают за экран */
  .topbar { padding: 6px 8px; gap: 4px; flex-wrap: nowrap; overflow: hidden; }
  .brand { font-size: 14px; letter-spacing: 1px; flex-shrink: 0; }
  .btn-header-bom { padding: 6px 10px; font-size: 12px; }
  .btn-header-bom::before { content: ''; } /* короче подпись на мобилке */
  #btnResetAll, #btnToggleView { display: none; } /* на мобиле прячем, остаются в десктоп-меню */

  /* base layout — паддинги/гэпы плотнее */
  .container { padding: 8px 8px 16px; }
  .dash-grid { gap: 10px; margin-bottom: 10px; }
  /* ВАЖНО: min-width:0 на flex/grid детях, иначе они растут до размера контента
     (например, горизонтальная полоса материалов раздувает родителя до 600+ px) */
  .house-view, .config-panel { min-width: 0; max-width: 100%; padding: 10px 10px 12px; border-radius: 10px; }
  .house-view-head { margin-bottom: 8px; flex-wrap: wrap; gap: 6px; }
  .house-view-head h2 { font-size: 15px; }
  .house-mini-plan { width: 38px; height: 38px; padding: 2px; }
  .rotate-controls { padding-left: 0; margin-right: auto; gap: 4px; }
  .rotate-btn { width: 30px; height: 30px; font-size: 13px; }
  .rotate-label { font-size: 11px; min-width: 30px; padding: 3px 6px; }

  /* визуал — основной экран на мобиле */
  .house-svg-wrap { min-height: 60vh !important; border-radius: 8px; }
  .house-scene { min-height: 60vh !important; }

  /* scene-tools — горизонтальная прокрутка, не вылазит за экран */
  .scene-tools {
    right: 8px; top: 8px; left: 8px; /* растягиваем во всю ширину */
    overflow-x: auto; overflow-y: hidden;
    flex-wrap: nowrap; gap: 4px;
    padding: 2px 0;
    /* прячем скроллбар, но даём скроллить пальцем */
    scrollbar-width: none;
    background: rgba(255,255,255,0.85);
    border-radius: 8px;
    padding: 4px;
  }
  .scene-tools::-webkit-scrollbar { display: none; }
  .scene-tool {
    flex-shrink: 0;
    padding: 6px 10px;
    font-size: 12px;
    min-height: 32px;
  }

  /* overlay vis-toggles — иконки-only, свёрнуты по дефолту */
  .house-vis-toggles {
    top: auto; bottom: 10px; left: 8px; right: auto;
    padding: 4px 6px; font-size: 11px; gap: 2px;
  }
  .house-vis-toggles .overlay-toggle { font-size: 10px; padding: 2px; }
  .house-vis-toggles .overlay-toggle-label { font-size: 10px; }

  /* overlay floors-pills — компактный, справа внизу */
  .house-floors-pills {
    bottom: 10px; right: 8px; left: auto;
    padding: 4px; font-size: 11px;
  }
  .house-floors-pills .overlay-content { gap: 2px; }
  .hf-pill { padding: 5px 8px; font-size: 11px; }
  .hf-check { padding: 4px 6px; font-size: 11px; margin-left: 2px; }

  /* нижние полосы материалов — горизонтальный скролл вместо grid */
  .quick-bar-wrap { margin-top: 8px; }
  .qbw-toggle { padding: 7px 10px; font-size: 12px; }
  .qbw-title { font-size: 12px; }
  .qbw-current { font-size: 11px; }
  .wall-quick-bar, .roof-quick-bar, .roof-shape-quick-bar {
    display: flex !important;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 6px;
    padding: 6px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    /* критично: иначе flex-row контейнер растёт до размера всех children и раздувает родителя */
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
  .quick-bar-wrap { min-width: 0; max-width: 100%; }
  .wall-quick-bar::-webkit-scrollbar,
  .roof-quick-bar::-webkit-scrollbar { height: 4px; }
  .wall-quick-card, .roof-quick-card, .roof-shape-quick-card {
    flex: 0 0 auto;
    width: 100px;
    padding: 6px 4px 7px;
  }
  .wall-quick-card .wq-tex, .roof-quick-card .wq-tex { width: 60px; height: 32px; }
  .wall-quick-card .wq-title, .roof-quick-card .wq-title { font-size: 11px; }
  .wall-quick-card .wq-price, .roof-quick-card .wq-price { font-size: 11px; padding: 1px 4px; }

  /* config-panel — компактнее */
  .config-panel {
    padding: 12px 12px 14px;
    max-width: 100%;
  }
  .config-row { padding: 10px 8px; }
  .config-row .config-icon { font-size: 18px; }
  .config-row .config-title { font-size: 13px; }
  .config-row .config-subtitle { font-size: 11px; }
  .btn-primary, .btn-block { min-height: 40px; font-size: 14px; }

  /* dev-панель — на мобиле не нужна */
  .dev-panel { display: none !important; }

  /* footer тоньше */
  .footer { padding: 4px 8px; font-size: 10px; }

  /* pro view на телефоне неприменим */
  body.view-pro #proView { display: none !important; }
  body.view-pro #dashView { display: block !important; }

  /* admin-overlay/help скрываем когда экран узкий */
  .scene-help { font-size: 10px; padding: 4px 8px; left: 8px; right: 8px; bottom: 6px; }

  /* модалки на мобиле — почти fullscreen */
  .modal-window { border-radius: 8px; max-width: calc(100vw - 12px); max-height: calc(100vh - 12px); margin: 6px; }
  .modal-head { padding: 10px 12px; }
  .modal-body { padding: 10px 12px; }
}

/* перф: пропускаем рендер карточек каталога вне viewport.
   Каждая карточка ~80px; content-visibility:auto экономит layout/paint */
@media (max-width: 720px) {
  .wcat-item, .wall-quick-card, .roof-quick-card {
    content-visibility: auto;
    contain-intrinsic-size: 80px;
  }
  /* SVG плана крыши — отключаем touch-action чтобы pointer events не конфликтовали со scroll */
  #customRoofPlan { touch-action: none; }
}

/* очень узкие экраны (<= 380px) — ещё компактнее */
@media (max-width: 380px) {
  .container { padding: 6px 6px 12px; }
  .house-view { padding: 8px 8px 10px; }
  .wall-quick-card, .roof-quick-card, .roof-shape-quick-card { width: 88px; }
  .house-view-head h2 { font-size: 14px; }
  .qbw-current { display: none; } /* убираем подпись чтобы заголовок влез */
}
