.slot-warning {
  margin-top: 10px;
  padding: 10px 12px;
  color: #7a1f1f;
  background: #ffe5e5;
  border: 1px solid #d93636;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.compact-check {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  line-height: 1.25;
}

.compact-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.field-grid.frame-fields {
  margin-top: 15px;
}

.params-form label.is-readonly {
  opacity: 0.68;
}

.params-form label.is-readonly input {
  background: #eef2f7;
  color: #64748b;
  cursor: default;
}

.view-tab {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.view-tab:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(2, 6, 23, 0.08);
}

.view-tabs {
  position: absolute;
  z-index: 6;
  top: 95px;
  left: 18px;
  display: flex;
  gap: 8px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.view-tab.active {
  color: #fff;
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  border-color: var(--accent);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.22);
}

.view-tab.view-action {
  background: var(--surface-2);
}

.view-tab.view-action.primary {
  color: #fff;
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  border-color: var(--accent);
}

.front-color-bar {
  position: absolute;
  z-index: 6;
  top: 170px;
  left: 27px;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(520px, calc(100% - 36px));
  padding: 7px 8px 7px 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.front-color-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.front-color-button {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 174px;
  max-width: 330px;
  min-height: 38px;
  padding: 5px 9px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.front-color-button strong,
.front-color-button small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.front-color-button strong {
  font-size: 13px;
  line-height: 1.15;
}

.front-color-button small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.front-color-swatch {
  width: 30px;
  height: 24px;
  border: 1px solid rgba(15, 23, 42, 0.28);
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.36);
}

.front-color-modal {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.44);
}

.front-color-dialog {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  width: min(920px, 100%);
  height: min(720px, calc(100vh - 48px));
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 28px 70px rgba(2, 6, 23, 0.32);
  overflow: hidden;
}

.front-color-dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.front-color-dialog-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.front-color-dialog-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.front-color-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.front-color-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.front-color-systems {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.front-color-system {
  min-height: 34px;
  padding: 7px 11px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
}

.front-color-system.active {
  color: #fff;
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.front-color-system span {
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.78;
}

.front-color-search {
  min-width: 0;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
}

.front-color-warning {
  margin: 12px 20px 0;
  padding: 10px 12px;
  color: #7a4a00;
  background: #fff7df;
  border: 1px solid #f1c76b;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.front-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px;
  padding: 18px 20px 22px;
  overflow: auto;
}

.front-color-tile {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.front-color-tile:hover,
.front-color-tile.active {
  border-color: #1d4ed8;
  box-shadow: 0 10px 24px rgba(29, 78, 216, 0.14);
}

.front-color-tile-swatch {
  width: 38px;
  height: 34px;
  border: 1px solid rgba(15, 23, 42, 0.28);
  border-radius: 6px;
}

.front-color-tile-text strong,
.front-color-tile-text small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.front-color-tile-text strong {
  font-size: 12px;
}

.front-color-tile-text small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.front-color-empty {
  grid-column: 1 / -1;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.canvas-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  min-height: 0;
}

.viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #f8fafc;
  border: 1px solid var(--border);
  overflow: hidden;
}

#wireframeSvg,
#threeViewport,
#drawingSvg {
  width: 100%;
  height: 100%;
  display: block;
}

#threeViewport {
  position: relative;
}

#threeViewport canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.view-cube {
  position: absolute;
  z-index: 4;
  top: 12px;
  right: 12px;
  width: 112px;
  height: 112px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}

#threeViewport .view-cube canvas {
  display: block;
  width: 112px !important;
  height: 112px !important;
  cursor: pointer;
  touch-action: none;
}

.info-strip {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 14px;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.info-strip div {
  padding: 12px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.04);
}

.info-strip span,
.info-strip strong {
  display: block;
}

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

.info-strip strong {
  margin-top: 4px;
  font-size: 15px;
}

.drawing-layout {
  min-height: 0;
  padding: 74px 18px 18px;
  overflow: auto;
}

.drawing-page {
  position: relative;
  display: block;
  width: 100%;
  height: min(72vh, 740px);
  margin-bottom: 12px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.drawing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.print-header {
  display: none;
}

.part-outline {
  fill: #fff;
  stroke: #111827;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.recess-fill {
  fill: #dbeafe;
  stroke: #1d4ed8;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.recess-hatch {
  stroke: #1d4ed8;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.slot-fill {
  fill: rgba(14, 165, 233, 0.2);
  stroke: #0284c7;
  stroke-width: 1.1;
  vector-effect: non-scaling-stroke;
}

.slot-hatch {
  stroke: #0284c7;
  stroke-width: 1.1;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.slot-outline,
.slot-section {
  fill: none;
  stroke: #0284c7;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.slot-section {
  fill: rgba(14, 165, 233, 0.16);
}

.recess-invalid {
  fill: rgba(166, 59, 59, 0.18);
  stroke: var(--danger);
}

.edge-roundover-line {
  fill: none;
  stroke: #7c3aed;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.edge-radius-leader {
  stroke: #7c3aed;
  stroke-width: 1;
  fill: none;
  vector-effect: non-scaling-stroke;
}

.edge-radius-text {
  fill: #5b21b6;
  font: 800 12px Inter, Arial, sans-serif;
}

.section-line {
  stroke: #111827;
  stroke-width: 1.4;
  fill: none;
  vector-effect: non-scaling-stroke;
}

.frame-stage-1-line,
.frame-stage-2-line {
  fill: none;
  stroke: #111827;
  stroke-width: 1.1;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.frame-stage-1-line {
  stroke-dasharray: 6 4;
}

.frame-stage-2-line {
  stroke-dasharray: 2 4;
}

.section-line.thin {
  stroke-width: 0.8;
}

.section-fill {
  fill: #fff;
  stroke: none;
}

.dimension-line,
.extension-line {
  stroke: #111;
  stroke-width: 1.2;
  fill: none;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.extension-line {
  stroke-width: 0.8;
}

.dimension-arrow {
  fill: #111;
  stroke: none;
  pointer-events: none;
}

.dimension-text {
  fill: #111827;
  font: 700 13px Inter, Arial, sans-serif;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

#wireframeSvg,
#drawingSvg {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#wireframeSvg text,
#drawingSvg text {
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

@media (max-width: 920px) {
  .view-tabs {
    position: static;
    margin: 10px;
    overflow-x: auto;
  }

  .front-color-bar {
    position: static;
    margin: 0 10px 10px;
    flex-wrap: wrap;
    max-width: none;
  }

  .front-color-tools {
    grid-template-columns: 1fr;
  }

  .front-color-dialog {
    height: calc(100vh - 34px);
  }

  .canvas-layout {
    grid-template-columns: 1fr;
  }

  .info-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-left: 0;
    border-top: 1px solid var(--border);
    margin-bottom: 28px;
  }
}

@media print {
  @page {
    margin: 8mm;
  }

  html,
  body {
    width: 100%;
    height: auto;
    margin: 0;
    padding: 0 !important;
    overflow: visible !important;
  }

  body > *:not(.app-shell),
  .sidebar,
  .topbar,
  .view-tabs,
  .front-color-bar,
  .front-color-modal,
  .drawing-actions,
  .info-strip,
  #modelView,
  #toast,
  #footerBar,
  #toTopBtn {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .drawing-layout,
  #drawingView {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  .drawing-page {
    display: grid;
    grid-template-rows: 18mm 1fr;
    width: 100% !important;
    height: calc(100vh - 16mm) !important;
    margin: 0 !important;
    border: 0;
    box-shadow: none;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .print-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12mm;
    padding: 0 0 4mm;
    border-bottom: 1px solid #d1d5db;
  }

  .print-header img {
    display: block;
    width: 52mm;
    height: 14mm;
    object-fit: contain;
  }

  .print-header div {
    display: grid;
    gap: 1mm;
    text-align: right;
    color: #111827;
    font-family: 'Inter', Arial, sans-serif;
  }

  .print-header strong {
    font-size: 14pt;
    line-height: 1.1;
  }

  .print-header span {
    font-size: 9pt;
    color: #4b5563;
  }
}
