:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --panel-subtle: #f8fafc;
  --panel-muted: #f1f5f9;
  --border: #e2e8f0;
  --border-med: #cbd5e1;
  --text: #1e293b;
  --text-strong: #0f172a;
  --muted: #475569;
  --muted-light: #64748b;
  --accent: #0284c7;
  --accent-dark: #0369a1;
  --accent-soft: #e0f2fe;
  --orange: #ea580c;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;

  --fs-2xs: 10px;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-md: 13px;
  --fs-lg: 14px;
  --fs-xl: 16px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
body { display: flex; flex-direction: column; }

.m-topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border-med);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}
.m-ribbon-row-top {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 10px;
  gap: 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.m-ribbon-row-top::-webkit-scrollbar { display: none; }
.m-ribbon-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.m-rtab {
  height: 28px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  border-radius: 4px 4px 0 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.m-rtab:hover { color: var(--text-strong); background: var(--panel-muted); }
.m-rtab.active {
  color: var(--accent-dark);
  background: #ffffff;
  border-color: var(--border);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.m-ribbon-cmds {
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: #ffffff;
  overflow-x: auto;
  scrollbar-width: none;
}
.m-ribbon-cmds::-webkit-scrollbar { display: none; }
.m-rpanel {
  display: none;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.m-rpanel.active { display: flex; }
.m-icon-cmd {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s;
}
.m-icon-cmd:hover { background: var(--panel-muted); border-color: var(--border-med); }
.m-icon-cmd.active { background: var(--accent-soft); border-color: var(--accent); }
.m-cmd-sep { width: 1px; height: 18px; background: var(--border); margin: 0 3px; flex-shrink: 0; }
.m-brand {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  flex: 0 0 auto;
  overflow: visible;
}
.m-brand strong {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.m-logo {
  width: 24px; height: 24px; border-radius: var(--r-sm);
  background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; text-decoration: none;
  transition: background 0.12s;
}
.m-logo:hover {
  background: var(--panel-muted);
}
.m-logo img {
  width: 22px; height: 22px; display: block; object-fit: contain;
}
.m-sep { color: var(--border-med); flex-shrink: 0; }
.m-proj-code {
  font-family: var(--font-mono);
  font-weight: 600; font-size: var(--fs-xs);
  padding: 2px 6px; border-radius: var(--r-xs);
  background: var(--accent-soft); color: var(--accent-dark);
  flex-shrink: 0;
}
.m-select {
  height: 28px; padding: 0 6px; font: inherit; font-size: var(--fs-xs); font-weight: 500;
  border: 1px solid var(--border-med); border-radius: var(--r-sm); background: var(--panel);
  color: var(--text-strong); max-width: 118px; text-overflow: ellipsis;
}
.m-tabs {
  display: flex; gap: 2px;
  background: var(--panel-muted);
  padding: 2px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  flex: 0 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.m-tabs::-webkit-scrollbar { display: none; }
.m-tab {
  height: 26px; padding: 0 6px; border: 1px solid transparent; border-radius: var(--r-sm);
  background: transparent; color: var(--muted); font: inherit; font-size: var(--fs-xs); font-weight: 500;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.m-tab:hover { background: rgba(255, 255, 255, 0.6); color: var(--text-strong); }
.m-tab.active {
  background: var(--panel); border-color: var(--border); color: var(--accent);
  font-weight: 600; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.m-actions { display: flex; align-items: center; gap: var(--sp-1); flex-shrink: 0; margin-left: auto; }
.m-btn, .m-btn-sm {
  height: 28px; padding: 0 8px; border: 1px solid var(--border-med); border-radius: var(--r-sm);
  background: var(--panel); color: var(--text-strong); font: inherit; font-size: var(--fs-xs); font-weight: 500;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.m-btn-sm { height: 24px; padding: 0 8px; font-size: var(--fs-xs); }
.m-btn:hover, .m-btn-sm:hover { background: var(--panel-muted); border-color: #94a3b8; }
.m-btn-primary { background: var(--accent); border-color: var(--accent-dark); color: #ffffff; font-weight: 600; }
.m-btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #ffffff; }

.m-workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: hidden;
}
.m-side-left, .m-side-right {
  background: var(--panel);
  display: flex; flex-direction: column; min-height: 0;
  flex: 0 0 auto;
}
.m-side-left { width: 312px; border-right: 1px solid var(--border-med); }
.m-side-right { width: 304px; border-left: 1px solid var(--border-med); }
.m-side-left.hidden, .m-side-right.hidden, .m-resizer.hidden, .hidden { display: none !important; }

.m-resizer {
  width: 5px;
  flex: 0 0 5px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 6;
  transition: background 0.12s;
}
.m-resizer:hover, .m-resizer.active { background: rgba(2, 132, 199, 0.4); }

.m-panel-head {
  height: 36px; padding: 0 var(--sp-3);
  background: var(--panel-subtle);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  font-weight: 600; font-size: var(--fs-md); color: var(--text-strong); flex-shrink: 0;
}
.m-head-title { display: inline-flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; }
.m-head-tools { display: inline-flex; align-items: center; gap: var(--sp-1); flex-shrink: 0; }
.m-icon-btn {
  width: 24px; height: 24px; padding: 0;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: transparent; color: var(--muted); font: inherit; font-size: var(--fs-md); font-weight: 600; line-height: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.m-icon-btn:hover { background: var(--panel-muted); border-color: var(--border); color: var(--text-strong); }
.m-search-bar { padding: var(--sp-2) 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.m-badge {
  background: var(--accent-soft); color: var(--accent-dark); font-family: var(--font-mono); font-size: var(--fs-xs);
  font-weight: 600; padding: 1px 7px; border-radius: 999px; margin-left: 2px;
}
.m-input-sm {
  width: 100%; height: 28px; padding: 0 var(--sp-2); font: inherit; font-size: var(--fs-sm);
  border: 1px solid var(--border-med); border-radius: var(--r-sm); background: var(--panel);
}
.m-tree, .m-props {
  flex: 1 1 auto; overflow-y: auto; padding: var(--sp-2) 10px;
}

.m-grp-hdr {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1);
  padding: 6px var(--sp-2); margin-top: var(--sp-1); border-radius: var(--r-xs);
  background: var(--panel-muted); font-weight: 600; font-size: var(--fs-sm); color: var(--text-strong);
  user-select: none;
}
.m-grp-cost {
  width: 100%; padding-left: 22px; margin-top: 2px;
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500;
  color: var(--accent-dark); display: flex; justify-content: space-between; gap: 6px;
}
.m-tree-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: var(--sp-2) 10px; margin-bottom: var(--sp-2); border-radius: var(--r-sm);
  background: #f0f9ff; border: 1px solid #bae6fd; font-size: var(--fs-xs); color: #0c4a6e;
}
.m-tree-summary strong { font-family: var(--font-mono); font-size: var(--fs-sm); }
.m-piece-cost {
  margin-left: auto; flex-shrink: 0;
  font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted);
}

/* Guía de Cortes Optimizada */
.cut-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--sp-2); margin-bottom: var(--sp-3); }
.cut-kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--sp-2) var(--sp-3); }
.cut-kpi span { display: block; font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; }
.cut-kpi strong { font-family: var(--font-mono); font-size: var(--fs-xl); color: var(--text-strong); }
.cut-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3); margin-bottom: var(--sp-3); }
.cut-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.cut-card-title { font-weight: 700; font-size: var(--fs-md); color: var(--text-strong); }
.cut-meta { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--accent-dark); }
.cut-bar-row { display: grid; grid-template-columns: 62px 1fr 124px; align-items: center; gap: var(--sp-2); margin-bottom: 6px; font-size: var(--fs-xs); }
.cut-bar-track { display: flex; height: 22px; background: var(--border); border: 1px solid #94a3b8; border-radius: var(--r-xs); overflow: hidden; }
.cut-seg { display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: 600; color: #ffffff; background: var(--accent); border-right: 1px solid #ffffff; overflow: hidden; white-space: nowrap; padding: 0 3px; }
.cut-seg.alt { background: var(--accent-dark); }
.cut-seg.ptr { background: #334155; }
.cut-seg.ptr.alt { background: #475569; }
.cut-waste { display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: var(--fs-2xs); color: #991b1b; background: repeating-linear-gradient(45deg, #fee2e2, #fee2e2 4px, #fecaca 4px, #fecaca 8px); overflow: hidden; white-space: nowrap; }
.cut-bar-stat { font-family: var(--font-mono); font-size: var(--fs-xs); text-align: right; color: var(--muted); }
.cut-sheet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 10px;
}
.cut-sheet-card {
  border: 1px solid var(--border-med);
  border-radius: var(--r-sm);
  background: var(--panel);
  padding: var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.cut-sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-xs);
  color: var(--text-strong);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.cut-sheet-svg { width: 100%; height: auto; display: block; background: var(--panel); }
.cut-sheet-foot { font-size: var(--fs-xs); color: var(--muted); text-align: center; }
.m-grp-hdr:hover { background: var(--border); }
.m-grp-toggle {
  width: 18px; height: 18px; padding: 0; border: none; background: transparent;
  color: var(--muted); font-size: var(--fs-xs); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.m-grp-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.m-grp-items { padding-left: var(--sp-2); }
.m-grp-items.collapsed { display: none; }
.m-btn-sm.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); font-weight: 600; }
.m-reopen-btn { background: var(--panel-subtle); font-weight: 600; }

/* Caja de sección en Propiedades */
.m-secbox-grid { display: flex; flex-direction: column; gap: 6px; padding: var(--sp-1) 2px var(--sp-2); }
.m-secbox-axis { display: grid; grid-template-columns: 32px 1fr 1fr; align-items: center; gap: 6px; font-size: var(--fs-xs); }
.m-secbox-axis input[type="range"] { width: 100%; margin: 0; accent-color: var(--accent); }
.m-prop-desc-box {
  font-size: var(--fs-sm); line-height: 1.45; color: var(--text);
  background: var(--panel-subtle); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: var(--sp-2) 10px; margin: var(--sp-1) 0 var(--sp-2); word-break: break-word;
}
.m-prop-param-tag {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  color: var(--muted); background: var(--border); padding: 1px 5px; border-radius: var(--r-xs);
}

/* Catálogo Gráfico Indexado de Elementos de Detalle 2D */
.det-cat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: var(--sp-2); margin-top: var(--sp-2);
}
.det-cat-card {
  border: 1px solid var(--border-med); border-radius: var(--r-sm); background: var(--panel);
  overflow: hidden; display: flex; flex-direction: column;
}
.det-cat-preview {
  background: var(--panel); border-bottom: 1px solid var(--border); padding: var(--sp-1);
}
.det-cat-preview svg { width: 100%; height: 80px; display: block; }
.det-cat-meta { padding: 6px var(--sp-2); display: flex; flex-direction: column; gap: 2px; }
.det-cat-code {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 700; color: var(--text-strong);
}
.det-cat-code span { color: var(--muted); font-weight: 500; }
.det-cat-name { font-size: var(--fs-sm); font-weight: 600; color: var(--text-strong); }
.det-cat-dims { font-family: var(--font-mono); font-size: var(--fs-xs); color: #334155; }
.det-cat-ref { font-size: var(--fs-xs); color: var(--muted-light); }
.m-piece-row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px var(--sp-2); border-radius: var(--r-xs); cursor: pointer; font-size: var(--fs-sm);
  border: 1px solid transparent;
}
.m-piece-row:hover { background: var(--panel-subtle); }
.m-piece-row.active { background: #fff7ed; border-color: #fb923c; color: #9a3412; font-weight: 600; }
.m-tag-chip {
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 600;
  padding: 1px 5px; border-radius: var(--r-xs); background: var(--accent-soft); color: var(--accent-dark);
  flex-shrink: 0;
}
.m-piece-row.active .m-tag-chip { background: var(--orange); color: #ffffff; }
.m-piece-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.m-center { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.m-view { display: none; flex-direction: column; flex: 1 1 auto; min-width: 0; min-height: 0; }
.m-view.active { display: flex; }

.m-3d-toolbar, .m-subbar {
  min-height: 38px; padding: 5px var(--sp-3); background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px 6px; flex-shrink: 0;
}
.m-ctrl { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.m-ctrl input[type="range"] { width: 88px; accent-color: var(--accent); }
.m-chk { cursor: pointer; }
.m-mono { font-family: var(--font-mono); font-size: var(--fs-xs); }
.m-policy-pill {
  margin-left: auto; font-size: var(--fs-xs); color: var(--muted);
  background: var(--panel-muted); padding: 3px var(--sp-2); border-radius: var(--r-xs); white-space: nowrap;
}

.m-canvas-host {
  position: relative; flex: 1 1 auto; min-height: 0;
  background: radial-gradient(circle at 50% 42%, #f8fafc 0%, #e5ecf4 100%);
  overflow: hidden; touch-action: none;
}
.m-canvas-host canvas { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; }
.m-tags-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.m-3d-tag {
  position: absolute; transform: translate(-50%, -50%);
  font-family: var(--font-mono); font-size: 8.5px; font-weight: 700; line-height: 1.2;
  padding: 1px 4px; border-radius: 3px;
  background: rgba(15, 23, 42, 0.86); color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.55);
  pointer-events: auto; cursor: pointer; white-space: nowrap;
}
.m-3d-tag.active { background: var(--orange); border-color: #ffffff; z-index: 5; }

.m-scroll-pane { flex: 1 1 auto; overflow: auto; min-width: 0; padding: var(--sp-4); }
.m-subbtn {
  height: 26px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r-xs);
  background: var(--panel); color: var(--muted); font: inherit; font-size: var(--fs-xs); cursor: pointer; white-space: nowrap;
}
.m-subbtn.active { background: var(--text-strong); border-color: var(--text-strong); color: #ffffff; font-weight: 600; }

.m-prop-sec {
  font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--muted); background: var(--panel-muted); padding: 5px var(--sp-2); border-radius: var(--r-xs); margin: var(--sp-2) 0 var(--sp-1);
}
.m-prop-sec:first-child { margin-top: 0; }
.m-prop-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2);
  padding: 5px 6px; border-bottom: 1px solid var(--panel-muted); font-size: var(--fs-sm);
}
.m-prop-k { color: var(--muted); flex-shrink: 0; }
.m-prop-v { text-align: right; color: var(--text-strong); font-weight: 500; word-break: break-word; }
.m-prop-v a { color: var(--accent-dark); font-weight: 600; text-decoration: underline; }
.m-tag-input {
  width: 112px; height: 26px; padding: 0 6px; text-align: right;
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 600;
  border: 1px solid #94a3b8; border-radius: var(--r-xs);
}

/* Detalles 2D y Planos */
.montaje-detail-svg {
  width: 100%; height: auto; display: block;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--panel);
}
.montaje-sheet-page {
  background: var(--panel); border: 1px solid #94a3b8; border-radius: var(--r-xs);
  padding: var(--sp-3); box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  max-width: 1240px; margin: 0 auto;
}
.montaje-sheet-page[data-layout-mode="60x45"] { max-width: 980px; }
.montaje-sheet-page[data-layout-mode="1x1"] { max-width: 820px; }
.montaje-sheet-frame { border: 1.4px solid var(--text-strong); padding: var(--sp-2); display: flex; flex-direction: column; gap: var(--sp-2); }
.ms-sheet-coordbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px;
  padding: 4px 8px; border-bottom: 1px solid var(--border-med); background: var(--panel-subtle);
  font-size: var(--fs-xs); color: #334155;
}
.ms-mosaic-grid {
  display: grid;
  gap: var(--sp-2);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.ms-mosaic-grid.cols-1 { grid-template-columns: 1fr; }
.montaje-sheet-page[data-layout-mode="1x1"] .ms-mosaic-grid { grid-template-columns: 1fr; }
.ms-mosaic-cell {
  border: 1px dashed #94a3b8;
  border-radius: var(--r-xs);
  padding: 6px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
}
.ms-mosaic-cell.span-full { grid-column: 1 / -1; }
.ms-mosaic-tag {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs); font-weight: 600; color: #334155;
  border-bottom: 1px solid var(--border); padding-bottom: 4px;
}
.ms-mosaic-coord {
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 700;
  background: var(--text-strong); color: #ffffff; padding: 1px 6px; border-radius: 3px;
  flex-shrink: 0;
}
.ms-mosaic-body { min-width: 0; overflow-x: auto; }
.ms-mosaic-body .montaje-detail-svg { border: none; border-radius: 0; }
.m-subbar-sep { width: 1px; height: 18px; background: var(--border); margin: 0 var(--sp-1); flex-shrink: 0; }
.montaje-sheet-titleblock {
  display: grid; grid-template-columns: 1.6fr 1fr 1.6fr 1fr 0.7fr;
  border-top: 1.5px solid var(--text-strong); padding-top: 6px; gap: var(--sp-2); font-size: var(--fs-xs);
}
.montaje-sheet-titleblock.is-hidden { display: none !important; }
.ms-tb-cell { display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--border-med); padding-right: 6px; }
.ms-tb-cell:last-child { border-right: none; text-align: right; }
.ms-tb-cell span { font-size: var(--fs-2xs); color: var(--muted-light); text-transform: uppercase; }
.ms-tb-num strong { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--accent-dark); }
.ms-sec-title { font-size: var(--fs-sm); font-weight: 700; color: var(--text-strong); margin-bottom: 6px; }
.ms-table { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); }
.ms-table th, .ms-table td { border: 1px solid var(--border-med); padding: 4px 6px; text-align: left; }
.ms-table th { background: var(--panel-muted); font-weight: 600; color: #334155; }
.ms-table a { color: var(--accent-dark); font-weight: 600; }
.ms-tags-grid { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.ms-tag-pill {
  font-size: var(--fs-xs); padding: 2px 6px; border-radius: var(--r-xs);
  background: var(--panel-muted); border: 1px solid var(--border-med);
}
.ms-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.ms-empty { padding: var(--sp-3); background: var(--panel-subtle); border: 1px dashed var(--border-med); border-radius: var(--r-sm); color: var(--muted-light); }

.m-statusbar {
  height: 28px; padding: 0 var(--sp-3); background: var(--text-strong); color: #e2e8f0;
  display: flex; align-items: center; justify-content: space-between; font-size: var(--fs-xs); flex-shrink: 0;
}

/* Elementos exclusivos de interfaz móvil (ocultos en escritorio) */
.m-mob-only,
.m-mob-thumb-bar,
.m-mob-backdrop,
.m-mob-visual-sheet,
.m-mob-sel-bar,
.m-mob-nav-dock {
  display: none;
}

.m-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Columna izquierda apilada: Navegador + Propiedades */
.m-left-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.m-nav-pane { flex: 1 1 56%; }
.m-props-pane { flex: 1 1 44%; border-top: 1px solid var(--border-med); }
.m-hsplit {
  height: 5px;
  flex: 0 0 5px;
  cursor: row-resize;
  background: var(--panel-muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.m-hsplit:hover, .m-hsplit.active { background: rgba(2, 132, 199, 0.35); }
.m-nav-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px 6px;
}
.m-nav-sec { margin-bottom: 4px; }
.m-nav-sec-hdr {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 6px;
  border-radius: 4px;
  background: var(--panel-muted);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-strong);
  cursor: pointer;
  user-select: none;
}
.m-nav-sec-hdr:hover { background: var(--border); }
.m-nav-sec-body { padding: 3px 0 3px 8px; display: flex; flex-direction: column; gap: 1px; }
.m-nav-sec:not(.open) .m-nav-sec-body { display: none; }
.m-nav-row {
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 11.5px;
  padding: 4px 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.m-nav-row:hover { background: var(--panel-muted); color: var(--text-strong); }
.m-nav-row.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.m-search-inline { padding: 4px 2px; border-bottom: none; }
.m-nav-sec-body .m-tree { padding: 2px 0; overflow: visible; flex: none; }

/* Barra inferior con Estilo visual, Lentes, Relación de datos a la izquierda; Despiece y Etiquetas a la derecha */
.m-sb-left, .m-sb-right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.m-sb-right { flex-shrink: 0; }
.m-sb-sep { color: #475569; }
.m-sb-select {
  height: 20px;
  padding: 0 5px;
  font: inherit;
  font-size: 10.5px;
  font-weight: 500;
  color: #e2e8f0;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 4px;
  cursor: pointer;
}
.m-sb-select:hover { border-color: #38bdf8; }
.m-sb-explode { color: #e2e8f0; gap: 5px; font-size: 11px; flex-shrink: 0; }
.m-sb-explode input[type="range"] { width: 78px; height: 14px; accent-color: #38bdf8; cursor: pointer; }
.m-sb-explode .m-mono { color: #38bdf8; min-width: 28px; cursor: pointer; }
.m-sb-icon-btn {
  width: 24px;
  height: 22px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-strong);
}
.m-sb-icon-btn:hover { background: var(--panel-muted); border-color: var(--border-med); }
.m-sb-icon-btn.active { background: #fef3c7; border-color: #f59e0b; }

.m-lentes-popover {
  position: fixed;
  left: 10px;
  bottom: 58px;
  z-index: 80;
  min-width: 196px;
  background: #ffffff;
  border: 1px solid var(--border-med);
  border-radius: 7px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.2);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.m-lentes-item {
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 4px;
  background: transparent;
  padding: 6px 9px;
  font: inherit;
  font-size: 11.5px;
  color: var(--text-strong);
  cursor: pointer;
}
.m-lentes-item:hover { background: var(--accent-soft); color: var(--accent-dark); }
.m-lentes-sep { height: 1px; background: var(--border); margin: 3px 4px; }

/* Capa de cotas de medición 3D */
.m-measure-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 12;
}
.m-measure-pill {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  border: 1px solid #38bdf8;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

/* Pantalla dividida Explosión de insumos + Modelo 3D */
.m-center.m-split-3d {
  flex-direction: row;
}
.m-center.m-split-3d #m-view-proveedores {
  display: flex;
  flex: 1 1 54%;
  min-width: 280px;
  border-right: 1px solid var(--border-med);
}
.m-center.m-split-3d #m-view-3d {
  display: flex;
  flex: 1 1 46%;
  min-width: 240px;
}
.m-split-resizer {
  width: 5px;
  flex: 0 0 5px;
  cursor: col-resize;
  background: var(--panel-muted);
  touch-action: none;
  user-select: none;
  position: relative;
  z-index: 15;
  transition: background 0.12s;
}
.m-split-resizer:hover, .m-split-resizer.active { background: rgba(2, 132, 199, 0.45); }

/* Explosión de insumos (RLOPSRM / BIMCOIN) */
.exp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.exp-head-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.exp-head-title h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-strong);
}
.exp-scope-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.exp-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.exp-sec-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 14px 0 6px;
  padding: 5px 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-strong);
}
.exp-sec-hdr.sec-mo { border-left-color: #d97706; }
.exp-sec-hdr.sec-eq { border-left-color: #7c3aed; }
.exp-sec-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-dark);
}
.exp-table th.num, .exp-table td.num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
.exp-table th.ctr, .exp-table td.ctr { text-align: center; white-space: nowrap; }
.exp-row { cursor: pointer; transition: background 0.1s; }
.exp-row:hover { background: #f0f9ff; }
.exp-row.active { background: #fff7ed; }
.exp-row.active td:first-child { box-shadow: inset 3px 0 0 #ea580c; }
.exp-mat-name { font-weight: 600; color: var(--text-strong); display: block; }
.exp-mat-sub { font-size: 10px; color: var(--muted-light); display: block; margin-top: 1px; }
.exp-ficha-card {
  margin: 8px 0 10px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid #38bdf8;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.08);
}
.exp-ficha-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 6px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.exp-ficha-head strong { font-size: 12.5px; color: var(--text-strong); }
.exp-ficha-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 6px 12px;
  font-size: 11px;
}
.exp-ficha-item span { display: block; font-size: 10px; color: var(--muted-light); text-transform: uppercase; }
.exp-ficha-item strong { color: var(--text-strong); font-weight: 600; word-break: break-word; }
.exp-ficha-item a { color: var(--accent-dark); font-weight: 600; }
.exp-ficha-foot {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.exp-total-strip {
  margin-top: 12px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid var(--border-med);
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  font-size: 11px;
}
.exp-total-strip strong { font-family: var(--font-mono); color: var(--text-strong); }

/* Pie de plano oficial del proyecto (idéntico al estándar de planta en plan_templates.js) */
.sheet-pdf-paper {
  background: #ffffff;
  border: 1.5px solid #0f172a;
  padding: 10px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  max-width: 1320px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 232px;
  gap: 10px;
  min-height: 540px;
}
.sheet-pdf-paper.no-sidebar { grid-template-columns: 1fr; }
.sheet-pdf-paper.no-sidebar .sheet-pdf-sidebar { display: none; }
.sheet-pdf-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  border: 1px solid #334155;
  padding: 8px;
  background: #ffffff;
}
.sheet-pdf-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sheet-side-box {
  border: 1px solid #334155;
  padding: 8px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sheet-side-hdr {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-strong);
  border-bottom: 1px solid var(--border-med);
  padding-bottom: 3px;
  margin-bottom: 2px;
}
.sheet-north-box { flex-direction: row; align-items: center; gap: 8px; }
.sheet-north-meta { display: flex; flex-direction: column; gap: 2px; font-size: 10.5px; color: var(--text); }
.sheet-north-meta strong { font-size: 11.5px; color: var(--text-strong); }
.sheet-sym-row { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text); }
.sheet-sym-swatch { width: 20px; height: 10px; flex-shrink: 0; display: inline-block; border: 1px solid var(--text-strong); }
.sheet-sym-swatch.glass { background: #e0f2fe; border-color: #0369a1; }
.sheet-sym-swatch.alum { background: #1e293b; }
.sheet-sym-swatch.cut { border: none; border-bottom: 2px dashed #0f172a; height: 5px; }
.sheet-sym-swatch.det { width: 12px; height: 12px; border-radius: 50%; margin: 0 4px; border: 1.5px solid #0f172a; background: #ffffff; }
.sheet-sym-swatch.npt { width: 11px; height: 11px; border-radius: 50%; margin: 0 4px; background: conic-gradient(#0f172a 0 90deg, #fff 90deg 180deg, #0f172a 180deg 270deg, #fff 270deg); }
.sheet-titleblock-pdf { border: 2px solid var(--text-strong); margin-top: auto; gap: 4px; }
.sheet-tb-brand { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; color: var(--text-strong); border-bottom: 1.5px solid var(--text-strong); padding-bottom: 4px; }
.sheet-tb-row { display: flex; justify-content: space-between; gap: 6px; font-size: 10.5px; color: var(--muted); }
.sheet-tb-row strong { color: var(--text-strong); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 148px; }
.sheet-tb-code { font-family: var(--font-mono); font-size: 15px; font-weight: 700; color: var(--text-strong); text-align: center; padding: 4px 0; border-top: 1px solid var(--border-med); border-bottom: 1px solid var(--border-med); margin: 2px 0; }
.sheet-tb-foot { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }

/* Cinta inferior de actualizaciones y versiones (idéntica a index.html) */
.change-ticker-bar {
  height: 24px;
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  font-size: 11px;
  flex-shrink: 0;
  border-top: 1px solid rgba(51, 65, 85, 0.85);
}
.change-ticker-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(2, 132, 199, 0.28);
  color: #bae6fd;
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 4px;
  height: 18px;
  padding: 0 7px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.mcp-dot { width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; display: inline-block; }
.mcp-dot.online { background: #10b981; box-shadow: 0 0 6px rgba(16, 185, 129, 0.75); }
.change-ticker-viewport { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; cursor: pointer; }
.change-ticker-track { display: inline-flex; align-items: center; gap: 28px; padding-left: 100%; animation: mTickerScroll 42s linear infinite; }
.change-ticker-viewport:hover .change-ticker-track { animation-play-state: paused; }
.change-ticker-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.change-ticker-rev { font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; color: #38bdf8; }
.change-ticker-src { font-size: 10.5px; color: #fbbf24; font-weight: 600; }
.change-ticker-user { font-size: 10.5px; color: #94a3b8; }
.ticker-update-pill {
  background: #059669;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  height: 18px;
  padding: 0 8px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
@keyframes mTickerScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}
.m-version-popover {
  position: fixed;
  left: 10px;
  bottom: 30px;
  z-index: 85;
  width: min(440px, calc(100vw - 20px));
  max-height: 320px;
  background: #ffffff;
  border: 1px solid var(--border-med);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.m-version-pop-head {
  height: 32px;
  padding: 0 10px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-strong);
}
.m-version-pop-body { overflow-y: auto; padding: 6px 8px; display: flex; flex-direction: column; gap: 6px; }
.m-ver-row { border: 1px solid var(--border); border-radius: 5px; padding: 6px 8px; font-size: 11px; }
.m-ver-row.current { background: #eff6ff; border-color: #93c5fd; }
.m-ver-row-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 2px; }
.m-ver-row-top strong { font-family: var(--font-mono); color: var(--accent-dark); }
.m-ver-row-top span { font-size: 10px; color: var(--muted-light); }

/* Modal Relación de datos (captura etiquetada JPEG HD para observaciones) */
.m-rel-modal {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(15, 23, 42, 0.58);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.m-rel-card {
  width: min(1040px, 96vw);
  max-height: 92vh;
  background: #ffffff;
  border: 1px solid var(--border-med);
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.m-rel-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
}
.m-rel-canvas {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border-med);
  background: #ffffff;
}
.m-rel-obs-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ViewCube 3D (idéntico al de escritorio, anclado al lienzo 3D) */
.m-viewcube-hud {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 84px;
  height: 84px;
  z-index: 25;
  user-select: none;
  touch-action: none;
}
.vc-home-btn {
  position: absolute;
  top: -2px;
  left: -2px;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid var(--border-med);
  background: rgba(255, 255, 255, 0.95);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}
.vc-home-btn:hover { color: var(--accent-dark); background: #ffffff; }
.vc-scene {
  width: 100%;
  height: 100%;
  perspective: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.vc-compass {
  position: absolute;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 1.5px solid rgba(100, 116, 139, 0.35);
  background: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}
.vc-dir { position: absolute; font-family: var(--font-mono); font-size: 8.5px; font-weight: 700; color: #334155; }
.vc-n { top: 1px; left: 50%; transform: translateX(-50%); color: #dc2626; }
.vc-s { bottom: 1px; left: 50%; transform: translateX(-50%); }
.vc-e { right: 3px; top: 50%; transform: translateY(-50%); }
.vc-o { left: 3px; top: 50%; transform: translateY(-50%); }
.vc-cube { width: 44px; height: 44px; position: relative; transform-style: preserve-3d; }
.vc-face {
  position: absolute;
  width: 44px;
  height: 44px;
  background: rgba(241, 245, 249, 0.95);
  border: 1px solid #64748b;
  color: #1e293b;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backface-visibility: hidden;
  transition: background 0.12s, color 0.12s;
}
.vc-face:hover { background: var(--accent); color: #ffffff; border-color: var(--accent-dark); }
.vc-corner { position: absolute; width: 10px; height: 10px; z-index: 4; background: transparent; }
.vc-tl { top: -1px; left: -1px; border-bottom-right-radius: 3px; }
.vc-tr { top: -1px; right: -1px; border-bottom-left-radius: 3px; }
.vc-bl { bottom: -1px; left: -1px; border-top-right-radius: 3px; }
.vc-br { bottom: -1px; right: -1px; border-top-left-radius: 3px; }
.vc-corner:hover { background: var(--accent); }
.vc-front  { transform: translateZ(22px); }
.vc-back   { transform: rotateY(180deg) translateZ(22px); }
.vc-right  { transform: rotateY(90deg) translateZ(22px); }
.vc-left   { transform: rotateY(-90deg) translateZ(22px); }
.vc-top    { transform: rotateX(90deg) translateZ(22px); background: rgba(226, 232, 240, 0.96); }
.vc-bottom { transform: rotateX(-90deg) translateZ(22px); background: rgba(203, 213, 225, 0.96); }

@media (max-width: 900px) {
  .m-center.m-split-3d { flex-direction: column; }
  .m-center.m-split-3d #m-view-proveedores {
    border-right: none;
    border-bottom: none;
    flex: 1 1 50%;
    min-width: 0;
    min-height: 0;
  }
  .m-center.m-split-3d #m-view-3d {
    flex: 1 1 50%;
    min-width: 0;
    min-height: 0;
  }
  .m-split-resizer {
    width: 100%;
    height: 16px;
    flex: 0 0 16px;
    cursor: row-resize;
    background: var(--panel-subtle);
    border-top: 1px solid var(--accent);
    border-bottom: 1px solid var(--border-med);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    user-select: none;
    position: relative;
    z-index: 20;
  }
  .m-split-resizer::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: -8px;
    bottom: -8px;
  }
  .m-split-resizer::after {
    content: '';
    width: 44px;
    height: 4px;
    border-radius: 999px;
    background: var(--accent);
    opacity: 0.72;
    transition: opacity 0.12s, transform 0.12s;
  }
  .m-split-resizer:hover {
    background: var(--panel-subtle);
  }
  .m-split-resizer.active {
    background: var(--accent-soft);
  }
  .m-split-resizer.active::after {
    opacity: 1;
    transform: scaleX(1.18);
  }
  .sheet-pdf-paper { grid-template-columns: 1fr; }
}

/* =========================================================================
   INTERFAZ MÓVIL COMPLETA PARA VISUALIZACIÓN SEPARADA (<= 768px)
   0 barras fijadas al borde inferior · Hojas arriba con velo · Táctil 3D
   ========================================================================= */
@media (max-width: 768px) {
  :root {
    --m-mob-safe-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }

  .m-mob-only {
    display: inline-flex;
  }
  .m-mob-hide {
    display: none !important;
  }

  /* 1. Encabezado compacto: Marca + 4 Pestañas completas + Barra rápida + Comandos */
  .m-topbar {
    position: relative;
    z-index: 68;
    padding-top: env(safe-area-inset-top, 0px);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
  }
  .m-ribbon-row-top {
    height: auto;
    flex-wrap: wrap;
    padding: 5px 8px 0;
    gap: 4px 6px;
    overflow: visible;
    border-bottom: none;
  }
  .m-brand {
    order: 1;
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    gap: 6px;
  }
  .m-brand strong {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .m-logo {
    width: 22px;
    height: 22px;
  }
  .m-logo img {
    width: 20px;
    height: 20px;
  }
  .m-proj-code {
    font-size: 10.5px;
    padding: 2px 6px;
  }
  .m-select {
    height: 30px;
    font-size: 12px;
    padding: 0 6px;
    max-width: 124px;
  }
  .m-actions {
    order: 2;
    margin-left: auto;
    flex-shrink: 0;
  }
  .m-actions .m-icon-cmd {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }
  .m-ribbon-tabs {
    order: 3;
    flex: 1 0 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
    border-top: 1px solid var(--border);
    padding: 3px 6px 0;
    margin: 2px -8px 0;
  }
  .m-rtab {
    flex: 1 0 auto;
    height: 30px;
    padding: 0 5px;
    font-size: 11.5px;
    text-align: center;
  }

  /* Barra rápida táctil integrada arriba (jamás choca con botones inferiores del celular) */
  .m-mob-thumb-bar {
    display: flex;
    width: 100%;
    height: 36px;
    padding: 3px 6px;
    gap: 4px;
    background: var(--panel-subtle);
    border-top: 1px solid var(--border);
    align-items: stretch;
    justify-content: space-between;
  }
  .m-mob-thumb-btn {
    flex: 1;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    padding: 0 3px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
  }
  .m-mob-thumb-btn.active {
    background: var(--accent-soft);
    border-color: rgba(2, 132, 199, 0.28);
    color: var(--accent-dark);
  }
  .m-mob-thumb-btn.pan-active {
    background: #fef3c7;
    border-color: rgba(217, 119, 6, 0.35);
    color: #b45309;
  }
  .m-mob-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .m-mob-dot {
    position: absolute;
    top: -2px;
    right: -3px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--orange);
    border: 1px solid #ffffff;
  }

  /* Tira de comandos por pestaña */
  .m-ribbon-cmds {
    height: 38px;
    padding: 0 8px;
    border-top: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
  }
  .m-rpanel {
    gap: 6px;
  }
  .m-ribbon-cmds .m-icon-cmd {
    width: 34px;
    height: 32px;
    border-radius: 8px;
  }

  /* 2. Espacio central a pantalla completa (0 barras inferiores) */
  .m-workspace {
    display: flex;
    flex-direction: column;
    position: relative;
  }
  .m-center {
    flex: 1 1 auto;
    min-height: 0;
  }
  .m-resizer,
  #m-left-hsplit {
    display: none !important;
  }
  .m-statusbar {
    display: none !important;
  }

  /* Aviso discreto de actualización nueva arriba a la izquierda (nunca abajo) */
  .change-ticker-bar {
    position: fixed;
    top: calc(var(--m-top-offset, 144px) + 8px);
    left: 8px;
    right: auto;
    bottom: auto;
    height: 0;
    padding: 0;
    background: transparent;
    border: none;
    pointer-events: none;
    z-index: 35;
  }
  .change-ticker-badge,
  .change-ticker-viewport {
    display: none !important;
  }
  .ticker-update-pill {
    pointer-events: auto;
    height: 28px;
    border-radius: 999px;
    padding: 0 12px;
    font-size: 11px;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
  }

  /* 3. Hojas flotantes superiores con velo de cierre (Navegador, Propiedades, Visualización) */
  .m-mob-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.32);
    z-index: 58;
  }
  #m-side-left,
  .m-mob-visual-sheet {
    position: fixed;
    left: 8px;
    right: 8px;
    top: calc(var(--m-top-offset, 144px) + 6px);
    bottom: auto;
    width: auto !important;
    max-height: calc(var(--m-vvh, 100dvh) - var(--m-top-offset, 144px) - var(--m-mob-safe-bottom, 68px));
    background: var(--panel);
    border: 1px solid var(--border-med);
    border-radius: 14px;
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.24);
    z-index: 62;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  #m-side-right {
    position: static !important;
    width: auto !important;
    max-height: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    flex: 1 1 auto !important;
    min-height: 0;
  }
  #m-side-left[data-mob-pane="nav"] #m-side-right {
    display: none !important;
  }
  #m-side-left[data-mob-pane="nav"] #m-nav-pane {
    display: flex;
    flex: 1 1 auto !important;
  }
  #m-side-left[data-mob-pane="props"] #m-nav-pane {
    display: none !important;
  }
  #m-side-left[data-mob-pane="props"] #m-side-right {
    display: flex;
    flex: 1 1 auto !important;
  }

  .m-panel-head {
    height: 42px;
    padding: 0 12px;
    font-size: 13px;
  }
  .m-icon-btn {
    width: 34px;
    height: 34px;
    font-size: 17px;
    border-radius: 8px;
  }
  .m-nav-scroll,
  .m-props,
  .m-mob-viz-body {
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding-bottom: 14px;
  }
  .m-nav-sec-hdr {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 12.5px;
  }
  .m-nav-row {
    min-height: 38px;
    padding: 6px 10px;
    font-size: 13px;
  }
  .m-input-sm,
  .m-tag-input {
    height: 36px;
    font-size: 16px;
  }
  .m-piece-row,
  .m-grp-hdr {
    min-height: 38px;
    font-size: 13px;
  }
  .m-prop-row {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 13px;
  }
  .m-secbox-axis {
    grid-template-columns: 28px 1fr 1fr;
    gap: 8px;
    min-height: 32px;
  }

  /* Hoja móvil de Visualización, Despiece y Lentes */
  .m-mob-viz-body {
    padding: 10px 12px 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .m-mob-viz-sec {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    margin-top: 2px;
  }
  .m-mob-explode-row {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .m-mob-explode-row input[type="range"] {
    flex: 1 1 auto;
    height: 28px;
    accent-color: var(--accent);
  }
  .m-mob-explode-val {
    min-width: 38px;
    text-align: right;
    font-weight: 700;
    color: var(--accent-dark);
  }
  .m-mob-viz-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .m-mob-viz-chip {
    flex: 1 1 auto;
    min-height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--border-med);
    background: var(--panel);
    color: var(--text);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
  }
  .m-mob-viz-chip.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-dark);
  }
  .m-mob-viz-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .m-mob-viz-actions .m-btn {
    height: 38px;
    justify-content: center;
    font-size: 12.5px;
    border-radius: 8px;
  }
  .m-mob-span-2 {
    grid-column: 1 / -1;
  }

  /* 4. Controles táctiles 3D en lienzo (ViewCube escalado + Dock derecho + Píldora selección) */
  .m-viewcube-hud {
    top: 6px;
    right: 6px;
    transform: scale(0.68);
    transform-origin: top right;
  }
  .m-center.m-split-3d .m-viewcube-hud {
    transform: scale(0.56);
  }
  .m-mob-nav-dock {
    display: inline-flex;
    flex-direction: column;
    position: absolute;
    right: 8px;
    top: 68px;
    z-index: 26;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(203, 213, 225, 0.95);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.14);
    touch-action: none;
    transition: opacity 0.14s ease;
  }
  .m-center.m-split-3d .m-mob-nav-dock {
    top: 56px;
    gap: 3px;
    padding: 3px;
  }
  .m-mob-dock-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .m-center.m-split-3d .m-mob-dock-btn {
    width: 30px;
    height: 30px;
  }
  .m-mob-dock-btn:active {
    background: var(--accent-soft);
    color: var(--accent-dark);
  }

  .m-mob-sel-bar {
    display: flex;
    position: absolute;
    top: 8px;
    left: 8px;
    right: 70px;
    z-index: 28;
    align-items: center;
    gap: 4px;
    padding: 4px 5px 4px 10px;
    border-radius: 11px;
    background: rgba(15, 23, 42, 0.93);
    color: #ffffff;
    backdrop-filter: blur(10px);
    box-shadow: 0 6px 22px rgba(15, 23, 42, 0.26);
    transition: opacity 0.14s ease;
  }
  .m-mob-measure-bar {
    background: rgba(3, 105, 161, 0.95);
  }
  .m-mob-sel-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .m-mob-sel-btn {
    height: 30px;
    padding: 0 8px;
    border-radius: 7px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .m-mob-sel-btn.primary {
    background: var(--accent);
    border-color: #38bdf8;
    color: #ffffff;
  }
  .m-mob-sel-btn.icon {
    width: 28px;
    padding: 0;
    font-size: 16px;
    border-color: transparent;
    background: transparent;
    color: #cbd5e1;
  }
  body.m-mob-sheet-open .m-mob-nav-dock,
  body.m-mob-sheet-open .m-mob-sel-bar,
  .m-center.m-split-3d .m-mob-sel-bar {
    opacity: 0;
    pointer-events: none;
  }

  /* 5. Vistas secundarias: Explosión, Cortes, Plantas, Detalles, Planos y Relación de datos */
  .m-3d-toolbar,
  .m-subbar {
    height: 42px;
    min-height: 42px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 0 8px;
    gap: 6px;
  }
  .m-3d-toolbar::-webkit-scrollbar,
  .m-subbar::-webkit-scrollbar {
    display: none;
  }
  .m-ctrl {
    font-size: 12px;
    flex-shrink: 0;
  }
  .m-policy-pill {
    display: none;
  }
  .m-btn-sm,
  .m-subbtn {
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
    flex-shrink: 0;
    border-radius: 7px;
  }
  .m-scroll-pane {
    padding: 10px 10px calc(24px + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
  }

  .cut-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .cut-kpis > .cut-kpi:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
  .cut-kpi {
    padding: 7px 10px;
  }
  .cut-kpi strong {
    font-size: 14px;
  }
  .cut-card {
    padding: 10px;
  }
  .cut-bar-row {
    grid-template-columns: 1fr auto;
    gap: 4px 8px;
    padding-bottom: 6px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--panel-muted);
  }
  .cut-bar-track {
    grid-column: 1 / -1;
    order: 3;
    height: 28px;
  }
  .cut-bar-stat {
    order: 2;
  }
  .cut-sheet-grid {
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 8px;
  }

  .exp-head {
    gap: 6px;
  }
  .exp-head-title h2 {
    font-size: 13.5px;
  }
  .exp-sec-hdr {
    flex-wrap: wrap;
    font-size: 11px;
  }
  .exp-table {
    min-width: 440px;
  }
  .exp-table td,
  .exp-table th {
    padding: 6px 6px;
  }
  .exp-ficha-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 10px;
  }
  .exp-total-strip {
    flex-direction: column;
    gap: 4px;
  }

  .ms-mosaic-grid,
  .ms-two-col {
    grid-template-columns: 1fr;
  }
  .montaje-sheet-page {
    padding: 6px;
  }
  .sheet-pdf-paper {
    padding: 6px;
    min-height: 0;
  }
  .sheet-tb-row strong {
    max-width: 190px;
  }
  .det-cat-grid {
    grid-template-columns: 1fr;
  }

  /* Modal Relación de datos responsivo */
  .m-rel-modal {
    padding: 8px;
  }
  .m-rel-card {
    width: 100%;
    max-height: calc(var(--m-vvh, 100dvh) - 16px);
  }
  .m-rel-card .m-version-pop-head {
    height: auto;
    min-height: 40px;
    padding: 6px 10px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .m-rel-obs-row {
    flex-direction: column;
    align-items: stretch;
  }

  .m-lentes-popover {
    left: 8px;
    right: 8px;
    top: calc(var(--m-top-offset, 144px) + 6px);
    bottom: auto;
    z-index: 70;
  }
}

/* Orientación horizontal (landscape) en teléfonos */
@media (max-width: 932px) and (max-height: 480px) and (orientation: landscape) {
  :root {
    --m-mob-safe-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }
  .m-ribbon-row-top {
    padding: 3px 8px 0;
  }
  .m-rtab {
    height: 26px;
    font-size: 11px;
  }
  .m-mob-thumb-bar {
    height: 32px;
  }
  .m-ribbon-cmds {
    height: 32px;
  }
  .m-ribbon-cmds .m-icon-cmd {
    width: 30px;
    height: 28px;
  }
  .m-viewcube-hud {
    transform: scale(0.56);
  }
  .m-mob-nav-dock {
    top: 56px;
  }
}

@media print {
  .m-topbar, .m-side-left, .m-side-right, .m-right-dock, .m-mueble-designer, .m-statusbar, .change-ticker-bar, .m-subbar, .m-3d-toolbar,
  .m-mob-thumb-bar, .m-mob-nav-dock, .m-mob-sel-bar, .m-mob-backdrop, .m-mob-visual-sheet { display: none !important; }
  .m-workspace { display: block; }
  .m-scroll-pane { overflow: visible; padding: 0; }
  .montaje-sheet-page, .sheet-pdf-paper { box-shadow: none; border: none; max-width: none; padding: 0; }
}

/* =========================================================================
   PANEL DERECHO SIEMPRE VISIBLE (PROPIEDADES + DISEÑO PARAMÉTRICO) Y DOBLE VERSIÓN
   ========================================================================= */
#m-nav-pane {
  flex: 1 1 100%;
  min-height: 0;
}
.m-right-dock {
  width: 312px;
  min-width: 268px;
  max-width: 440px;
  background: var(--panel);
  border-left: 1px solid var(--border-med);
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-height: 0;
  z-index: 25;
}
.m-right-dock.hidden {
  display: none !important;
}
.m-right-tabs {
  height: 36px;
  padding: 0 8px;
  background: var(--panel-subtle);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.m-right-tab {
  height: 28px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  border-radius: 5px 5px 0 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.m-right-tab:hover {
  color: var(--text-strong);
  background: var(--panel-muted);
}
.m-right-tab.active {
  color: var(--accent-dark);
  background: #ffffff;
  border-color: var(--border);
  border-bottom-color: var(--accent);
}
.m-sel-pill {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.m-right-pane {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  border-left: none;
}
.m-right-pane.hidden {
  display: none !important;
}
.m-mb-subhead {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
}
.m-mb-footer-btns {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.m-mb-footer-btns .m-mb-apply-btn {
  flex: 1 1 auto;
  margin-top: 0;
}

/* Doble versión en barra inferior: Versión Módulo + Versión Modelo */
.m-ver-pill {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.32);
  color: #e0f2fe;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}
.m-ver-pill.m-ver-model {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.35);
  color: #d1fae5;
}

/* Tarjeta estructural de pandeo y enlaces comerciales auditados en Propiedades */
.m-defl-card {
  border-radius: 6px;
  padding: 8px 9px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-size: 11px;
}
.m-defl-card.ok {
  background: #ecfdf5;
  border-color: #a7f3d0;
}
.m-defl-card.warn {
  background: #fffbeb;
  border-color: #fde68a;
}
.m-defl-card.fail {
  background: #fef2f2;
  border-color: #fecaca;
}
.m-defl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-weight: 700;
  color: var(--text-strong);
  margin-bottom: 4px;
}
.m-defl-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 700;
}
.m-defl-card.ok .m-defl-badge { background: #10b981; color: #ffffff; }
.m-defl-card.warn .m-defl-badge { background: #f59e0b; color: #ffffff; }
.m-defl-card.fail .m-defl-badge { background: #dc2626; color: #ffffff; }
.m-defl-metrics {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text);
  margin-bottom: 5px;
}
.m-defl-btns {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.m-defl-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  text-align: left;
  padding: 5px 7px;
  border-radius: 5px;
  border: 1px solid var(--border-med);
  background: #ffffff;
  color: var(--accent-dark);
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
}
.m-defl-btn.is-ok {
  border-color: #6ee7b7;
  background: #f0fdf4;
}
.m-defl-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.m-defl-lbl {
  min-width: 0;
  flex: 1 1 auto;
  line-height: 1.25;
}
.m-defl-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
}
.m-defl-cost {
  color: var(--text-strong);
  font-weight: 700;
}
.m-defl-cost.save {
  color: #059669;
}
.m-defl-res {
  font-size: 9.5px;
  font-weight: 500;
  color: var(--text-muted);
}
.m-defl-res.ok {
  color: #047857;
  font-weight: 700;
}
.m-comm-links {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}
.m-comm-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid #bae6fd;
  background: #f0f9ff;
  color: #0369a1;
  font-size: 10.5px;
  font-weight: 600;
  text-decoration: none;
}
.m-comm-link:hover {
  background: #e0f2fe;
  border-color: #0284c7;
}

/* =========================================================================
   DISEÑADOR PARAMÉTRICO DE MUEBLES DE OBRA (MELAMINA) · MÍNIMO BÁSICO
   ========================================================================= */
.m-mueble-designer {
  width: 100%;
  min-width: 0;
  max-width: none;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.m-mueble-designer.hidden {
  display: none !important;
}
.m-mb-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.m-mb-row-1 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.m-mb-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.m-mb-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.m-mb-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: #475569;
  min-width: 0;
}
.m-mb-field input,
.m-mb-field select {
  width: 100%;
  height: 27px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #ffffff;
  color: #0f172a;
  font-size: 11.5px;
  font-family: inherit;
  min-width: 0;
}
.m-mb-field input:focus,
.m-mb-field select:focus {
  outline: none;
  border-color: #0284c7;
}
.m-mb-checks {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 2px;
  border-top: 1px solid var(--panel-muted);
}
.m-mb-summary {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.m-mb-kpi {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.m-mb-kpi span {
  font-size: 10px;
  color: #64748b;
}
.m-mb-kpi strong {
  font-size: 12.5px;
  color: #0f172a;
  font-family: 'JetBrains Mono', monospace;
}
.mb-sheet-cut-svg {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
}
.mb-cut-rect:hover rect {
  stroke: #0284c7;
  stroke-width: 2;
  filter: brightness(0.95);
}
.m-mf-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  flex-shrink: 0;
}
.m-mb-apply-btn {
  width: 100%;
  height: 30px;
  justify-content: center;
  margin-top: 2px;
  font-weight: 600;
}
.m-eff-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.m-eff-ctrl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
}
.m-eff-ctrl select {
  max-width: 170px;
  height: 26px;
}
.m-eff-pills {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.m-eff-sugg-card {
  border-color: #bae6fd;
  background: #f0f9ff;
}
.m-eff-sugg-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.m-eff-sugg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  background: #ffffff;
  border: 1px solid #e0f2fe;
  border-radius: 6px;
  font-size: 11.5px;
}
.m-waste-bar {
  display: flex;
  height: 22px;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border-med);
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
}
.m-waste-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  padding: 0 4px;
}
.m-waste-seg.useful { background: #0284c7; color: #ffffff; }
.m-waste-seg.reusable { background: #10b981; color: #ffffff; }
.m-waste-seg.scrap { background: #f59e0b; color: #ffffff; }
@media (max-width: 768px) {
  .m-right-dock {
    display: none;
    position: fixed;
    left: 8px;
    right: 8px;
    top: calc(var(--m-top-offset, 144px) + 6px);
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    width: auto;
    min-width: 0;
    max-width: none;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.25);
    z-index: 65;
  }
  .m-right-dock.mob-open {
    display: flex !important;
  }
  #m-resizer-right {
    display: none !important;
  }
}

/* =========================================================================
   ALERTAS DE REPORTES CRÍTICOS (CAMPANITA + POPOVER EN MÓDULO DE MONTAJE)
   ========================================================================= */
.m-crit-bell-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 7px;
  position: relative;
}
.m-crit-bell-btn.has-critical {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #b91c1c;
}
.m-crit-bell-btn.has-critical:hover {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}
.m-crit-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc2626;
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
}
.m-crit-badge.hidden {
  display: none !important;
}
.m-crit-popover {
  position: fixed;
  top: 44px;
  right: 12px;
  width: min(356px, calc(100vw - 24px));
  max-height: 74vh;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 12px 32px -4px rgba(15, 23, 42, 0.2), 0 2px 6px rgba(15, 23, 42, 0.08);
  z-index: 160;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.m-crit-popover.hidden {
  display: none !important;
}
.m-crit-head {
  height: 36px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  color: #0f172a;
  flex-shrink: 0;
}
.m-crit-head > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.m-crit-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.m-crit-body .crit-filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0;
}
.m-crit-body .crit-filter-btn {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  border-radius: 999px;
  padding: 2px 8px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.45;
}
.m-crit-body .crit-filter-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.m-crit-body .crit-filter-btn.active {
  background: #dc2626;
  border-color: #b91c1c;
  color: #ffffff;
  font-weight: 600;
}
.m-crit-body .crit-list-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.m-crit-body .crit-item-card {
  width: 100%;
  text-align: left;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #dc2626;
  border-radius: 6px;
  padding: 7px 9px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
  font-family: var(--font-sans);
  transition: background 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.m-crit-body .crit-item-card:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.08);
}
.m-crit-body .crit-item-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
.m-crit-body .crit-item-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: #0f172a;
}
.m-crit-body .crit-item-cat {
  font-size: 10.5px;
  color: #64748b;
}
.m-crit-body .crit-item-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: #b91c1c;
  background: #fee2e2;
  border-radius: 4px;
  padding: 1px 5px;
}
.m-crit-body .crit-item-title {
  font-size: 12px;
  font-weight: 500;
  color: #0f172a;
  line-height: 1.35;
}
.m-crit-body .crit-item-detail {
  font-size: 11px;
  color: #475569;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-crit-body .crit-empty {
  padding: 18px 12px;
  text-align: center;
  font-size: 12px;
  color: #64748b;
}
.m-crit-row-highlight {
  outline: 2px solid #dc2626;
  outline-offset: -2px;
  background: #fee2e2 !important;
}
@keyframes mCritPulse {
  0%, 100% { stroke-opacity: 0.95; transform: scale(1); }
  50% { stroke-opacity: 0.35; transform: scale(1.16); }
}
.m-planta-crit-ring {
  transform-box: fill-box;
  transform-origin: center;
  animation: mCritPulse 1.5s ease-in-out infinite;
}
.m-planta-err-tip {
  position: absolute;
  z-index: 20;
  max-width: 310px;
  padding: 6px 9px;
  border-radius: 5px;
  background: #ffffff;
  border: 1px solid #fca5a5;
  border-left: 3px solid #dc2626;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14);
  line-height: 1.35;
  pointer-events: none;
}
.m-planta-err-tip.is-warn {
  border-color: #fcd34d;
  border-left-color: #d97706;
}
.m-planta-err-tip.hidden {
  display: none;
}
.m-planta-err-tip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #991b1b;
  margin-bottom: 2px;
}
.m-planta-err-tip.is-warn .m-planta-err-tip-head {
  color: #92400e;
}
.m-planta-err-tip-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: #b91c1c;
}
.m-planta-err-tip.is-warn .m-planta-err-tip-badge {
  color: #b45309;
}
.m-planta-err-tip-desc {
  font-size: 11px;
  color: #334155;
}

/* Visor 2D vectorial con zoom/paneo y detalle acotado del elemento */
.m-zoom2d-grp {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--panel);
  overflow: hidden;
  flex-shrink: 0;
}
.m-zoom2d-btn,
.m-zoom2d-val {
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-strong);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.m-zoom2d-btn {
  width: 24px;
  padding: 0;
  font-size: 13px;
  line-height: 1;
}
.m-zoom2d-val {
  min-width: 44px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.m-zoom2d-btn:hover,
.m-zoom2d-val:hover {
  background: var(--panel-muted);
}
.m-planta-2d-frame {
  position: relative;
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #ffffff;
  overflow: hidden;
  line-height: 0;
}
.m-planta-2d-frame svg {
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
  cursor: grab;
}
.m-planta-2d-frame svg.is-panning {
  cursor: grabbing !important;
}
.m-planta-2d-frame svg.is-place-mode {
  cursor: crosshair !important;
}
.m-planta-split-grid {
  width: 100%;
  max-width: 1560px;
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(340px, 0.92fr);
  gap: 8px;
  align-items: stretch;
}
.m-planta-split-grid.no-detail {
  grid-template-columns: minmax(0, 1fr);
}
.m-planta-split-grid.detail-expanded {
  grid-template-columns: minmax(0, 1fr);
}
.m-planta-split-grid.detail-expanded .m-planta-main-pane {
  display: none;
}
.m-planta-main-pane,
.m-planta-detail-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  overflow: hidden;
}
.m-planta-detail-pane {
  border-color: #fca5a5;
}
.m-planta-detail-pane.is-ok {
  border-color: #93c5fd;
}
.m-planta-pane-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 8px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 11px;
  flex-shrink: 0;
}
.m-planta-pane-title {
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-planta-pane-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.m-planta-svg-host {
  position: relative;
  flex: 1 1 auto;
  min-height: 440px;
  max-height: calc(100vh - 156px);
  background: #ffffff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.m-planta-svg-host > svg {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  cursor: grab;
}
.m-planta-svg-host > svg.is-panning {
  cursor: grabbing !important;
}
.m-planta-svg-host > svg.is-place-mode {
  cursor: crosshair !important;
}
.m-planta-door-pick {
  cursor: pointer;
}
.m-planta-door-pick:hover circle {
  stroke: #0284c7;
  stroke-width: 2;
  fill: rgba(2, 132, 199, 0.12);
}
@media (max-width: 1020px) {
  .m-planta-split-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .m-planta-svg-host {
    min-height: 320px;
    max-height: 62vh;
  }
}
