:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --line: #d6ded9;
  --text: #17201c;
  --muted: #64736c;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --accent: #b45309;
  --danger: #b42318;
  --warn: #92400e;
  --ok: #166534;
  --shadow: 0 14px 35px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

a {
  color: var(--brand-dark);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.1), rgba(180, 83, 9, 0.08)),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-panel h1,
.page-title h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.login-panel p,
.page-title p {
  margin: 8px 0 0;
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  font-weight: 800;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--brand);
  border-radius: 6px;
  font-weight: 900;
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 1px;
}

.nav button,
.ghost-button,
.primary-button,
.small-button,
.danger-button {
  min-height: 38px;
  border-radius: 7px;
  padding: 0 13px;
  white-space: nowrap;
}

.nav button {
  background: transparent;
  color: var(--muted);
}

.nav button.active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.primary-button {
  background: var(--brand);
  color: #ffffff;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--brand-dark);
}

.ghost-button,
.small-button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.danger-button {
  background: #fff5f5;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px 18px 48px;
}

.page-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

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

.panel,
.metric,
.table-panel,
.form-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 22px rgba(15, 23, 42, 0.04);
}

.panel,
.form-section {
  padding: 16px;
}

.metric {
  padding: 15px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.table-panel {
  overflow: hidden;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: #f8faf9;
  color: #374151;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover td {
  background: #f5faf8;
}

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

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8f5f2;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
}

.warning,
.error,
.success,
.notice {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.45;
}

.warning {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: var(--warn);
}

.error {
  background: #fff5f5;
  border: 1px solid #fecaca;
  color: var(--danger);
}

.success {
  background: #ecfdf3;
  border: 1px solid #bbf7d0;
  color: var(--ok);
}

.notice {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: #34423b;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.inline-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5d1;
  border-radius: 7px;
  padding: 9px 10px;
  background: #ffffff;
  color: var(--text);
}

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

.field input:focus,
.field select:focus,
.field textarea:focus,
.inline-input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.2);
  border-color: var(--brand);
}

.form-section h2,
.panel h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 14px;
  align-items: start;
}

.key-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}

.kv {
  display: grid;
  gap: 3px;
  min-width: 0;
}

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

.kv strong {
  overflow-wrap: anywhere;
}

.cad-viewer{background:#fff}.cad-toolbar{display:flex;align-items:center;gap:8px;padding:8px;border-bottom:1px solid var(--line);overflow-x:auto}.cad-toolbar strong{margin-right:auto;white-space:nowrap}.cad-toolbar button{min-height:40px;white-space:nowrap}.drawing-pan{height:min(72vh,850px);overscroll-behavior:contain}.drawing-pan iframe{display:block;min-width:700px;height:100%;border:0;transform-origin:top left;touch-action:pan-x pan-y pinch-zoom}.cad-member-info{padding:8px 12px;border-top:1px solid var(--line);font-size:14px}.cad-sheet-list{display:flex;gap:6px;overflow-x:auto;margin:10px 0 16px}.cad-sheet-list button[aria-current="page"]{background:var(--brand);color:#fff}.cad-sheet-list button{min-width:48px;min-height:44px}@media(max-width:620px){.cad-toolbar strong{max-width:130px;overflow:hidden;text-overflow:ellipsis}.drawing-pan{height:62vh}}

.drawings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.drawing-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.drawing-box svg {
  display: block;
  width: 100%;
  height: auto;
}

.model3d-box {
  background: #ffffff;
  overflow: auto;
}

.model3d-box svg {
  min-width: 760px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 10px;
}

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

.price-input {
  width: 110px;
}

.wide-input {
  min-width: 190px;
}

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

.loodsbon {
  white-space: pre-wrap;
}

.mobile-only {
  display: none;
}

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

  .brand,
  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .grid.two,
  .grid.three,
  .grid.four,
  .split,
  .drawings {
    grid-template-columns: 1fr;
  }

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

  .page-title {
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .main {
    padding: 18px 12px 40px;
  }

  .form-grid,
  .key-values {
    grid-template-columns: 1fr;
  }

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

  .form-actions button,
  .page-title button {
    width: 100%;
  }

  th,
  td {
    padding: 9px 8px;
  }

  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: initial;
  }
}

.tabbar {
  display: flex;
  gap: 6px;
  margin: 18px 0 14px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.tabbar button {
  min-height: 40px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.tabbar button.active {
  color: var(--brand-dark);
  border-bottom-color: var(--brand);
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.danger-inline {
  margin-left: 6px;
  color: var(--danger);
}

.table-heading {
  border: 0;
  box-shadow: none;
  padding-bottom: 0;
}

.nesting-drawing {
  margin-top: 12px;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid #cbd5d1;
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  font-weight: 600;
}

.checkbox-line input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.segmented button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.segmented button.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.code-area {
  min-height: 230px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.cad-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.38fr);
  gap: 14px;
  align-items: start;
}

.cad-canvas svg {
  min-width: 760px;
}

.cad-part {
  cursor: pointer;
  transition: stroke-width 0.15s ease, stroke 0.15s ease;
}

.cad-part:hover,
.cad-part.selected {
  stroke: var(--brand) !important;
  stroke-width: 8px !important;
}

.selected-row td {
  background: #ecfdf3;
}

@media (max-width: 980px) {
  .cad-layout {
    grid-template-columns: 1fr;
  }
}

.interactive-cad-root {
  margin-top: 14px;
}

.cad-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.cad-tools {
  max-width: 100%;
  overflow-x: auto;
}

.cad-interactive-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.42fr);
  gap: 14px;
  align-items: start;
}

.cad-canvas.interactive {
  min-height: 520px;
  overflow: auto;
  background: #ffffff;
}

.cad-canvas.interactive svg {
  min-width: 900px;
}

.cad-entity {
  cursor: move;
}

.cad-entity.selected line,
.cad-entity.selected rect,
.cad-entity.selected polygon {
  filter: drop-shadow(0 2px 4px rgba(15, 118, 110, 0.24));
}

.cad-part-label text,
.cad-title-block text,
.cad-legend text {
  letter-spacing: 0;
}

.cad-layer-summary {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.cad-layer-summary h2 {
  margin: 0;
}

.cad-handle {
  cursor: ew-resize;
}

.cad-props {
  display: grid;
  gap: 10px;
}

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

.form-grid.compact input {
  min-height: 34px;
}

@media (max-width: 980px) {
  .cad-interactive-layout {
    grid-template-columns: 1fr;
  }
}


.cad-frame-controls {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.cad-frame-controls label,
.compact-label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.cad-frame-controls input,
.cad-scale-select {
  min-height: 34px;
}

.cad-dimension text {
  pointer-events: none;
}


.cad-material-palette {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.cad-material-list {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.cad-material-add {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 7px 8px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.cad-material-add:hover {
  border-color: var(--brand);
  background: #f0fdfa;
}

.cad-material-add span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--brand);
  color: #ffffff;
  font-weight: 800;
}

.cad-material-add strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.cad-material-add em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}


.assembly-view .assembly-scene {
  transform: rotate(var(--assembly-rotation, 0deg));
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 160ms ease, opacity 160ms ease;
}

.assembly-view[data-assembly-mode="exploded"] .assembly-assembled,
.assembly-view[data-assembly-mode="assembled"] .assembly-exploded {
  display: none;
}

.assembly-view .assembly-module {
  cursor: pointer;
  transition: opacity 140ms ease, filter 140ms ease;
}

.assembly-view .assembly-module:hover {
  filter: url(#assembly-selected-glow);
}

.assembly-view[data-selected-module="leftWall"] [data-assembly-module="leftWall"],
.assembly-view[data-selected-module="rightWall"] [data-assembly-module="rightWall"],
.assembly-view[data-selected-module="roof"] [data-assembly-module="roof"],
.assembly-view[data-selected-module="frontFrame"] [data-assembly-module="frontFrame"] {
  filter: url(#assembly-selected-glow);
}

.model3d-selection {
  margin: 10px 0;
}

.public-page{min-height:100vh;display:grid;place-items:center;padding:24px;background:linear-gradient(135deg,rgba(15,118,110,.12),rgba(180,83,9,.08)),var(--bg)}.public-panel{width:min(560px,100%);text-align:center;background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:32px;box-shadow:var(--shadow)}.brand-mark.large{width:64px;height:64px;margin:0 auto 18px;font-size:30px}.primary-link{display:inline-flex;align-items:center;justify-content:center;min-height:46px;margin-top:18px;padding:0 18px;border-radius:8px;background:var(--brand);color:#fff;text-decoration:none;font-weight:700}.workshop-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;margin-bottom:16px}.workshop-drawing h2{padding:12px;margin:0;font-size:14px}.drawing-pan{max-width:100%;overflow:auto;touch-action:pan-x pan-y pinch-zoom;background:#fff}.drawing-pan img{display:block;width:100%;min-width:620px;height:auto}@media(max-width:620px){button,.primary-button,.ghost-button,.danger-button,.nav button{min-height:44px}.topbar{padding:10px 12px}.nav{margin:0 -12px;padding:0 12px 4px}.workshop-grid{grid-template-columns:1fr}.drawing-pan img{min-width:700px}.login-panel{padding:20px}.main{overflow-x:hidden}body{font-size:16px}}
