:root {
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-main: #0f172a;
  --text-sec: #475569;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --sidebar-w: 372px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Remove setas nativas de input[type=number] */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, select {
  font-family: inherit;
}

/* ================= LAYOUT FIXO ================= */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.param-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.sidebar-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  position: relative;
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.menu-trigger {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 140ms ease;
}

.menu-trigger:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 14px;
  width: 260px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  display: none;
  z-index: 60;
}

.nav-popover.open {
  display: block;
  animation: fadeSlide 120ms ease;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.nav-popover-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 10px 4px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-sec);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  transition: background 120ms ease, color 120ms ease;
}

.ico {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.metric-val,
.stepper-input,
.zoom-val,
.artboard-meta,
.cad-statusbar,
.file-dims {
  font-variant-numeric: tabular-nums;
}

.file-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.file-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.file-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  flex-shrink: 0;
  overflow: hidden;
  color: var(--text-muted);
}

.file-thumb svg {
  width: 100%;
  height: 100%;
  display: block;
}

.file-dims {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.server-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #bbf7d0;
  background: var(--success-soft);
  color: #15803d;
  flex-shrink: 0;
}

.server-pill.offline {
  border-color: #fecaca;
  background: var(--danger-soft);
  color: var(--danger);
}

.server-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-body::-webkit-scrollbar {
  width: 6px;
}
.sidebar-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 99px;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-pane {
  display: none;
  flex-direction: column;
  gap: 14px;
}
.sidebar-pane.active {
  display: flex;
}

/* ================= SEÇÕES & INPUTS ================= */
.sec-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--bg-subtle);
}
.sec-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sec-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-sec);
}

.sec-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: 999px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-sec);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.text-input, .select-input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 12.5px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.text-input:focus, .select-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

/* Dropzone flex limpa */
.dropzone {
  width: 100%;
  min-height: 68px;
  padding: 10px 12px;
  border: 1.5px dashed #93c5fd;
  border-radius: var(--radius-md);
  background: #f8fbff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  cursor: pointer;
  transition: all 150ms ease;
}

.dropzone:hover, .dropzone.dragover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.dropzone-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
}

.dropzone-sub {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 280px;
}

/* Stepper customizado sem setinhas nativas */
.stepper {
  display: flex;
  align-items: center;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  overflow: hidden;
}

.stepper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.stepper-btn {
  width: 28px;
  height: 100%;
  border: 0;
  background: var(--bg-app);
  color: var(--text-sec);
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 120ms ease, color 120ms ease;
}

.stepper-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.stepper-input {
  width: 100%;
  min-width: 0;
  height: 100%;
  border: 0;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  outline: none;
}

/* Lista de arquivos DXF */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.file-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.file-meta {
  min-width: 0;
}

.file-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 11px;
  color: var(--text-muted);
}

.icon-btn-remove {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #fecaca;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-btn-remove:hover {
  background: #fee2e2;
}

.file-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.file-controls .stepper {
  width: 98px;
  height: 30px;
  flex-shrink: 0;
}

.seg-group {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  gap: 2px;
}

.seg-group.full {
  display: flex;
  width: 100%;
}

.seg-group.full .seg-btn {
  flex: 1;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--text-sec);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 120ms ease;
  white-space: nowrap;
}

.seg-btn:hover {
  color: var(--text-main);
}

.seg-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.preset-chip {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-app);
  color: var(--text-sec);
  font-size: 11px;
  font-weight: 600;
  transition: all 120ms ease;
}

.preset-chip:hover {
  border-color: var(--border-strong);
  color: var(--text-main);
}

.preset-chip.active {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

/* Switch / Toggle */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-app);
}

.toggle-text {
  min-width: 0;
}

.toggle-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.toggle-sub {
  font-size: 10.5px;
  color: var(--text-muted);
}

.switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  display: inline-block;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 150ms ease;
  cursor: pointer;
}
.slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: transform 150ms ease;
}
.switch input:checked + .slider {
  background: var(--primary);
}
.switch input:checked + .slider::before {
  transform: translateX(16px);
}

/* Chips de cor ACI para furos */
.color-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 2px 2px;
}

.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sec);
  transition: all 120ms ease;
}

.color-chip.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.color-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.2);
  flex-shrink: 0;
}

/* Retalhos */
.retalho-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-app);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.retalho-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-size: 12px;
  font-weight: 600;
}

.btn-primary {
  width: 100%;
  height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 140ms ease, transform 80ms ease;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-outline {
  width: 100%;
  height: 32px;
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-outline:hover {
  background: #dbeafe;
}

.alert-inline {
  font-size: 11.5px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #fecaca;
  background: var(--danger-soft);
  color: var(--danger);
  display: none;
}
.alert-inline.show {
  display: block;
}

/* ================= ÁREA PRINCIPAL FIXA À DIREITA ================= */
.workspace {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-app);
}

.view-panel {
  display: none;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.view-panel.active {
  display: flex;
}

/* Topbar da direita */
.ws-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.ws-title-group {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ws-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.ws-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-sec);
  border: 1px solid var(--border);
}

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

.dl-btn {
  height: 32px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 120ms ease;
}

.dl-btn:hover {
  background: var(--bg-subtle);
  border-color: #94a3b8;
}

.dl-btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.dl-btn.primary:hover {
  background: var(--primary-hover);
}

.dl-btn.disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* Acordeões progressivos da Sidebar */
.acc-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  overflow: hidden;
}

.acc-summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-app);
  user-select: none;
  transition: background 120ms ease;
}
.acc-summary::-webkit-details-marker {
  display: none;
}
.acc-summary:hover {
  background: var(--bg-subtle);
}

.acc-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.acc-chev {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  transition: transform 150ms ease;
  display: inline-block;
}
.acc-card[open] > .acc-summary .acc-chev {
  transform: rotate(90deg);
  color: var(--primary);
}

.acc-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-sec);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acc-body {
  padding: 10px 11px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-surface);
}

/* Faixa única compacta de métricas */
.metrics-strip {
  flex-shrink: 0;
  margin: 10px 18px 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  overflow: hidden;
}

.metric-cell {
  padding: 6px 10px;
  border-right: 1px solid var(--bg-subtle);
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.metric-cell:last-child {
  border-right: 0;
}

.metric-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.metric-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
}

.metric-val {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.metric-sub {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.metric-bar {
  width: 100%;
  height: 3px;
  border-radius: 99px;
  background: var(--bg-subtle);
  margin-top: 4px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 260ms ease;
}

/* Popover reutilizável da Toolbar & Topbar */
.pop-wrap {
  position: relative;
  display: inline-flex;
}

.pop-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  min-width: 220px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 85;
}

.pop-panel.open {
  display: flex;
}

.pop-row-btn {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-sec);
  font-size: 11.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  text-decoration: none;
}
.pop-row-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}
.pop-row-btn.active {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

/* Faixa de KPIs */
.kpi-strip {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 18px 0;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.kpi-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-val {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-sub {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.kpi-bar {
  width: 100%;
  height: 4px;
  border-radius: 99px;
  background: var(--bg-subtle);
  margin-top: 5px;
  overflow: hidden;
}

.kpi-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 260ms ease;
}

/* Recomendações selecionáveis colapsáveis */
.rec-strip {
  flex-shrink: 0;
  margin: 8px 18px 0;
  background: var(--warning-soft);
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  display: none;
  flex-direction: column;
  gap: 7px;
}

.rec-strip.show {
  display: flex;
}

.rec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rec-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #92400e;
}

.rec-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rec-list.collapsed {
  display: none;
}

.rec-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #fcd34d;
  background: #ffffff;
  font-size: 11.5px;
  color: var(--text-main);
}

.rec-apply {
  border: 0;
  border-radius: 6px;
  background: #d97706;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
}

.rec-apply:hover {
  background: #b45309;
}

/* Prancheta CAD Fixa */
.cad-card {
  flex: 1;
  min-height: 0;
  margin: 10px 18px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cad-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-wrap: wrap;
}

.sheet-tabs {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.sheet-tab {
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-app);
  color: var(--text-sec);
  font-size: 11.5px;
  font-weight: 600;
}

.sheet-tab.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.cad-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.layer-chip {
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.layer-chip.active {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

.zoom-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  height: 26px;
  background: var(--bg-app);
}

.zoom-pill button {
  border: 0;
  background: transparent;
  color: var(--text-sec);
  font-size: 11.5px;
  font-weight: 700;
  padding: 0 8px;
  height: 100%;
}
.zoom-pill button:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}
.zoom-val {
  font-size: 11px;
  font-weight: 700;
  padding: 0 6px;
  color: var(--text-main);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.cad-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  grid-template-rows: 22px minmax(0, 1fr) 24px;
  background: #f8fafc;
  user-select: none;
}

.cad-ruler-corner {
  grid-column: 1;
  grid-row: 1;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cad-ruler-top {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.cad-ruler-left {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.cad-ruler-top canvas,
.cad-ruler-left canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.ruler-cursor-x {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--primary);
  opacity: 0;
  pointer-events: none;
}

.ruler-cursor-y {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--primary);
  opacity: 0;
  pointer-events: none;
}

.cad-viewport {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 1px 1px, #cbd5e1 1px, transparent 0) 0 0 / 24px 24px,
    #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cad-statusbar {
  grid-column: 1 / 3;
  grid-row: 3;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 10.5px;
  color: var(--text-muted);
}

.cad-status-left,
.cad-status-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.cad-scale-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cad-scale-bar {
  height: 5px;
  width: 60px;
  border-left: 1.5px solid var(--text-sec);
  border-right: 1.5px solid var(--text-sec);
  border-bottom: 1.5px solid var(--text-sec);
}

.empty-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
  text-align: left;
}

.empty-step {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-app);
  padding: 8px 9px;
}

.empty-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  margin-bottom: 4px;
}

.empty-step strong {
  display: block;
  font-size: 11px;
  color: var(--text-main);
}

.empty-step span {
  font-size: 10.5px;
  color: var(--text-muted);
}

.cad-empty {
  max-width: 490px;
  text-align: center;
  padding: 24px 22px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.cad-empty h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}

.cad-empty p {
  font-size: 12px;
  color: var(--text-muted);
}

.cad-svg-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  padding: 12px;
  overflow: hidden;
}

.cad-svg-wrap.grabbing {
  cursor: grabbing;
}

.cad-board-world {
  display: inline-block;
  transform-origin: center center;
  transition: transform 60ms linear;
  padding: 18px;
}

.artboard-grid {
  display: grid;
  gap: 24px;
  align-items: start;
  justify-items: center;
}

.artboard-card {
  background: #ffffff;
  border: 1.5px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.artboard-card:hover {
  border-color: #93c5fd;
}

.artboard-card.selected {
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14), 0 8px 24px rgba(15, 23, 42, 0.1);
}

.artboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.artboard-title {
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.artboard-meta {
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.artboard-exp-btn {
  height: 22px;
  padding: 0 8px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 10.5px;
  font-weight: 700;
  flex-shrink: 0;
}

.artboard-exp-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.artboard-svg-box {
  padding: 4px;
  background: #ffffff;
}

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

.cad-board-world.hide-ids .cad-piece-label {
  display: none;
}

.cad-board-world.hide-holes .cad-piece-hole {
  display: none;
}

.cad-board-world.hide-dashed .cad-piece-dashed {
  display: none;
}

.cad-board-world .cad-piece.selected .cad-piece-fill {
  stroke-width: 2.6;
  fill-opacity: 0.4;
}

.cad-board-world.hl-mirrored .cad-piece:not(.is-mirrored) {
  opacity: 0.25;
}

.cad-board-world.hl-nested .cad-piece:not(.is-hole) {
  opacity: 0.25;
}

/* Painel Unificado de Exportação */
.export-panel {
  width: 344px;
  padding: 10px;
  gap: 9px;
}

.exp-sheet-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.exp-fmt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  max-height: 230px;
  overflow-y: auto;
}

.exp-fmt-link {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-app);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.exp-fmt-link:hover {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

.exp-extra-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}

.exp-extra-chk {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-app);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sec);
  cursor: pointer;
}

.piece-hud {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  font-size: 11.5px;
  color: var(--text-main);
  box-shadow: var(--shadow-md);
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 5;
}

.piece-hud.show {
  display: inline-flex;
}

/* Drawer inferior colapsável (Resumo do Lote) */
.bottom-drawer {
  flex-shrink: 0;
  margin: 0 18px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.drawer-toggle {
  width: 100%;
  padding: 7px 12px;
  border: 0;
  background: var(--bg-surface);
  color: var(--text-sec);
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-toggle:hover {
  background: var(--bg-app);
}

.drawer-content {
  display: none;
  max-height: 210px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  padding: 10px 12px;
}

.drawer-content.open {
  display: block;
}

.clean-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.clean-table th, .clean-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--bg-subtle);
  text-align: left;
}

.clean-table th {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Views secundárias (Pré-Flight & Fila) */
.scroll-workspace {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.card-box h3 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.status-badge.ok { background: var(--success-soft); color: #15803d; border: 1px solid #bbf7d0; }
.status-badge.warn { background: var(--warning-soft); color: #b45309; border: 1px solid #fde68a; }
.status-badge.err { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }

.fila-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.fila-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-app);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 980px) {
  .param-sidebar {
    position: static;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .workspace {
    margin-left: 0;
    width: 100%;
    height: auto;
    overflow: visible;
  }
  .kpi-strip, .metrics-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .cad-card {
    min-height: 460px;
  }
  .editor-body {
    grid-template-columns: 1fr !important;
  }
}

/* ================= EDITOR CAD PROFISSIONAL DE OBJETOS ================= */
.file-edit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-top: 2px;
  border-top: 1px dashed var(--border);
}

.btn-edit-objs {
  flex: 1;
  height: 28px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg-app);
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 120ms ease;
}

.btn-edit-objs:hover {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

.edit-count-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  white-space: nowrap;
}

.editor-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 12px;
}

.editor-backdrop.open {
  display: flex;
}

.editor-modal {
  width: 96vw;
  height: 92vh;
  max-width: 1680px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.editor-title-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-title-meta h2 {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
}

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

.ed-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ed-btn:hover:not(:disabled) {
  background: var(--bg-subtle);
}

.ed-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ed-btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.ed-btn.primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.editor-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr) 276px;
  background: var(--bg-app);
}

.editor-outliner,
.editor-inspector {
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.editor-outliner {
  border-right: 1px solid var(--border);
}

.editor-inspector {
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
  gap: 12px;
}

.ed-panel-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.ed-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ed-outliner-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.outliner-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 11.5px;
  text-align: left;
  width: 100%;
}

.outliner-item:hover {
  background: var(--bg-app);
  border-color: var(--border);
}

.outliner-item.selected {
  background: var(--primary-soft);
  border-color: var(--primary-border);
}

.outliner-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.outliner-label {
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.outliner-op {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-subtle);
  color: var(--text-sec);
  flex-shrink: 0;
}

.editor-canvas-wrap {
  position: relative;
  overflow: hidden;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.editor-canvas-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ed-ent-path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  transition: opacity 100ms ease;
}

.ed-ent-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 12px;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
}

.ed-ent-sel {
  fill: none;
  stroke: #2563eb;
  stroke-opacity: 0.38;
  stroke-width: 7px;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.ed-marquee {
  position: absolute;
  border: 1.5px dashed var(--primary);
  background: rgba(37, 99, 235, 0.1);
  pointer-events: none;
  display: none;
  z-index: 10;
}

.editor-canvas-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  z-index: 8;
  flex-wrap: wrap;
}

.editor-canvas-bar > * {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-sec);
}

.ed-swatch-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.ed-swatch-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-main);
}

.ed-swatch-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.ed-op-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.ed-op-btn {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-app);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.ed-op-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.ed-op-btn.danger:hover {
  border-color: #fecaca;
  background: var(--danger-soft);
  color: var(--danger);
}

.ed-legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  padding: 3px 0;
  border-bottom: 1px solid var(--bg-subtle);
}

.export-wrap {
  position: relative;
  display: inline-flex;
}

.export-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  width: 224px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 5px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 80;
}

.export-menu.open {
  display: flex;
}

.export-menu a {
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.export-menu a:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.export-ext-tag {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 1px 6px;
  border-radius: 4px;
}

.rep-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  height: 100%;
  padding: 12px;
  min-height: 0;
}

.rep-compare-pane {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.rep-compare-head {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-app);
}

.rep-svg-box {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  overflow: hidden;
  background: #f8fafc;
}

.rep-svg-box svg {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

.rec-cat-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  text-transform: uppercase;
}

/* ================= TOASTS DE FEEDBACK ================= */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  max-width: 340px;
}

.toast-item {
  pointer-events: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3.5px solid var(--primary);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  padding: 9px 12px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  animation: fadeSlide 160ms ease;
}

.toast-item.ok { border-left-color: var(--success); }
.toast-item.warn { border-left-color: var(--warning); }
.toast-item.err { border-left-color: var(--danger); }

.toast-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

.toast-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ================= FASE 2: FÁBRICA, CUSTOS & ESTOQUE ================= */
.link-mini {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  padding: 0;
}
.link-mini:hover {
  text-decoration: underline;
}

.cost-box {
  border: 1px solid var(--primary-border);
  background: var(--primary-soft);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}

.cost-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fab-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fab-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-app);
  padding: 9px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.fab-item-meta {
  min-width: 180px;
  flex: 1;
}

.fab-item-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
}

.fab-item-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.fab-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ================= GERADOR PARAMÉTRICO 2D / 3D ================= */
.param-fields-grid {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.param-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
  background-color: #f8fafc;
  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 18px 18px;
}

.param-viewport:active {
  cursor: grabbing;
}

.param-svg-world {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  transform-origin: center center;
  will-change: transform;
}

.param-svg-world svg {
  max-width: 92%;
  max-height: 92%;
  width: auto;
  height: auto;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  box-shadow: var(--shadow-md);
}

/* ================= AUTENTICAÇÃO & BARRA DE USUÁRIO ================= */
.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-app);
  margin-bottom: 6px;
}

.user-pill-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 700;
  min-width: 0;
  flex: 1;
  text-align: left;
  cursor: pointer;
}

.user-pill-btn:hover {
  color: var(--primary);
}

.user-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.user-pill-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(241, 245, 249, 0.92);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 410px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 24px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.auth-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.auth-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.auth-alert {
  font-size: 12px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.auth-alert.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.auth-dev-box {
  font-size: 11.5px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  border: 1px dashed var(--primary-border);
  background: var(--primary-soft);
  color: var(--text-main);
}

.auth-dev-box a {
  color: var(--primary);
  font-weight: 700;
}

.nest-progress-box {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 10px;
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  margin-bottom: 6px;
}

.nest-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--text-main);
}

.nest-progress-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.nest-progress-pct {
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.nest-progress-track {
  height: 6px;
  border-radius: 99px;
  background: #dbeafe;
  overflow: hidden;
}

.nest-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: var(--primary);
  transition: width 220ms ease;
}

