:root {
  --bg: #f6f8fa;
  --panel: #ffffff;
  --border: #e3e8ee;
  --text: #1a1f36;
  --muted: #697386;
  --accent: #635bff;
  --accent-soft: #f0efff;
  --interior: #0a7d3e;   /* evaporador (unidad interior) */
  --exterior: #c0392b;   /* condensador (unidad exterior) */
  --line: #635bff;
  --amber: #b7791f;
  --amber-soft: #fdf3e0;
  --shadow: 0 1px 3px rgba(26,31,54,.08), 0 1px 2px rgba(26,31,54,.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

header h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
  white-space: nowrap;
}

/* Barra de progreso "línea de cotas" — 7 pasos navegables libremente */
.pasos-nav {
  display: inline-flex;
  align-items: center;
  gap: 0;
}
.paso-nodo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: none;
  background: transparent;
  padding: 2px 6px;
  cursor: pointer;
  color: var(--muted);
}
.paso-nodo .paso-num {
  width: 22px;
  height: 22px;
  line-height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.paso-nodo .paso-label {
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.paso-nodo:hover .paso-num { border-color: var(--accent); }
.paso-nodo.actual .paso-num {
  border: 2px solid var(--accent);
  color: var(--accent);
}
.paso-nodo.actual .paso-label { color: var(--accent); }
.paso-nodo.completo .paso-num {
  background: var(--interior);
  border-color: var(--interior);
  color: #fff;
}
.paso-nodo.atencion .paso-num {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
}
.paso-tramo {
  width: 14px;
  height: 0;
  border-bottom: 2px dashed var(--border);
  margin: 0 1px 14px;
}
.paso-tramo.completo { border-bottom-style: solid; border-bottom-color: var(--interior); }

/* Overlay de carga del plano (siempre visible, no pantalla en blanco muda) */
.plano-loading {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(246, 248, 250, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.plano-loading[hidden] { display: none !important; }
.plano-loading-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 28px;
  box-shadow: 0 12px 40px rgba(26, 31, 54, 0.14);
  text-align: center;
  min-width: 220px;
  max-width: 90vw;
}
.plano-loading-spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 12px;
  border: 3px solid #e3e8ee;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: plano-spin .7s linear infinite;
}
.plano-loading-card p {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.plano-loading-sub {
  margin-top: 6px !important;
  font-size: 12px !important;
  font-weight: 400 !important;
  color: var(--muted) !important;
}
@keyframes plano-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .plano-loading-spinner { animation: none; border-top-color: var(--accent); opacity: .7; }
}

body.modo-calcular .tool-dock { display: none; }
body.modo-calcular .terminar-float { display: none; }

header .obra-datos {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.layout {
  display: flex;
  height: calc(100vh - 53px);
}

.sidebar {
  width: 300px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 14px;
  overflow-y: auto;
  flex-shrink: 0;
}

/* Botón "Herramientas" para abrir el panel en pantallas chicas (celular en obra) */
.sidebar-toggle { display: none; }

@media (max-width: 760px) {
  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 16px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 84vw);
    z-index: 40;
    box-shadow: var(--shadow);
    transform: translateX(-100%);
    transition: transform .2s ease-out;
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(26, 31, 54, .45);
    z-index: 30;
  }
  .sidebar-backdrop[hidden] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* Área del plano: marco fijo; solo .stage-scroll se mueve */
.stage {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background-color: #eef1f4;
  background-image:
    linear-gradient(rgba(99, 91, 255, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 91, 255, .06) 1px, transparent 1px);
  background-size: 24px 24px;
  display: flex;
  flex-direction: column;
}
.stage-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  /* Gesto táctil del plano, no zoom de página */
  touch-action: none;
}
.stage-placeholder {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 320px;
  padding: 24px 12px;
}
.stage-placeholder svg { margin-bottom: 10px; }
.stage-placeholder p { font-size: 14px; margin: 0; line-height: 1.4; }

.canvas-wrap {
  position: relative;
  box-shadow: var(--shadow);
  background: #fff;
  touch-action: none;
  margin: auto;
}

#pdf-canvas { display: block; }

#overlay {
  position: absolute;
  top: 0;
  left: 0;
  cursor: crosshair;
  touch-action: none;
}
#overlay.tool-mano,
#overlay.panning {
  cursor: grab;
}
#overlay.panning:active {
  cursor: grabbing;
}
.work-region-preview {
  fill: rgba(14, 165, 233, 0.12);
  stroke: #0284c7;
  stroke-width: 2;
  stroke-dasharray: 6 4;
}

/* HUD fijo sobre el área del plano (NO scrollea con el papel) */
.stage-hud {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}
.stage-hud > * { pointer-events: auto; }

/* Dock flotante: solo en celular (en escritorio ya está el menú lateral) */
.tool-dock {
  display: none;
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(26, 31, 54, .12);
}
.tool-dock button {
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  font-size: 18px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  line-height: 1;
}
.tool-dock button:hover { background: var(--accent-soft); border-color: #c7c4ff; }
.tool-dock button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(99, 91, 255, .25);
}
.tool-dock button.dock-sec {
  font-size: 15px;
  opacity: 0.92;
}

/* Zoom fijo esquina (siempre a mano) */
.zoom-bar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 4px 16px rgba(26, 31, 54, .12);
}
.zoom-bar button {
  min-width: 40px;
  min-height: 40px;
  padding: 6px 10px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 8px;
}
.zoom-bar #zoom-reset {
  min-width: 56px;
  font-size: 12px;
  font-weight: 600;
}
.zoom-bar .zoom-fit-btn {
  font-size: 15px;
  font-weight: 600;
}

/* Terminar dibujo flotante (cañería / ambiente) */
.terminar-float {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 6;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 24px;
  border: none;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 20px rgba(99, 91, 255, .35);
  cursor: pointer;
}
.terminar-float:hover { filter: brightness(1.05); }

.stage.panning { cursor: grab; }
.stage.panning .stage-scroll,
.stage.panning .stage-scroll * { cursor: grabbing !important; }

@media (max-width: 760px) {
  /* En el celu el dock reemplaza al grid del menú (más fácil con el pulgar) */
  .tool-dock {
    display: flex;
    left: 50%;
    top: auto;
    bottom: 12px;
    transform: translateX(-50%);
    flex-direction: row;
    flex-wrap: nowrap;
    max-width: calc(100% - 24px);
    overflow-x: auto;
    padding: 8px 10px;
    gap: 5px;
  }
  .tools-group .toolbar { display: none; }
  .tool-dock button {
    width: 42px;
    height: 42px;
    min-width: 42px;
    flex-shrink: 0;
  }
  .zoom-bar {
    top: auto;
    bottom: 68px;
    right: 10px;
  }
  .terminar-float {
    bottom: 72px;
  }
  .stage-scroll { padding: 10px; }
}

/* Controles */
.group { margin-bottom: 14px; }
.group h2 {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin: 0 0 8px;
}

/* Toolbar compacta */
.toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.toolbar button {
  padding: 8px 6px;
  font-size: 12px;
  white-space: nowrap;
}
.row-btns { display: flex; flex-direction: row; gap: 6px; }
.row-btns button { flex: 1; padding: 7px 4px; font-size: 12px; }

/* Acordeones del panel */
.acc {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fff;
}
.acc > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .4px;
  user-select: none;
}
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  color: var(--muted);
  transition: transform .15s;
}
.acc[open] > summary::before { transform: rotate(90deg); }
.acc-body { padding: 0 10px 10px; }
.sub-sum {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.mini-h {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  margin: 12px 0 0;
  font-weight: 600;
}
.form-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0 8px;
}
.form-section {
  font-size: 13px;
  margin: 0 0 4px;
  color: var(--text);
}
.modal-box-wide { max-width: 560px; max-height: 90vh; overflow-y: auto; }

/* Asistente de importación: preview a pantalla casi entera */
.modal.modal-import-fs {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
  background: #0f172a;
}
.modal-box-import {
  max-width: none;
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  background: #fff;
}
.import-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  min-height: 40px;
}
.import-topbar-title {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex-shrink: 1;
}
.import-topbar-title h2 {
  font-size: 15px;
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  white-space: nowrap;
}
.import-aviso-mini {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
.import-topbar-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  justify-content: center;
}
.import-topbar-tools > button {
  min-width: 34px;
  padding: 6px 10px;
  font-size: 13px;
}
.import-topbar-tools > button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.import-tool-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 2px;
}
.import-btn-quiet {
  font-size: 12px !important;
  color: var(--muted);
  background: transparent !important;
  border-color: transparent !important;
  min-width: auto !important;
  padding: 6px 8px !important;
}
.import-btn-quiet:hover {
  color: var(--text);
  background: var(--accent-soft) !important;
}
.import-regiones {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-left: 4px;
  padding-left: 8px;
  border-left: 1px solid #bae6fd;
}
.import-regiones .import-regiones-tit {
  font-size: 11px;
  color: #0369a1;
  font-weight: 600;
  margin-right: 2px;
}
.import-regiones button {
  font-size: 12px;
  padding: 5px 11px;
  background: #f0f9ff;
  border: 1px solid #7dd3fc;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 600;
}
.import-regiones button:hover,
.import-regiones button.active {
  background: #0284c7;
  color: #fff;
  border-color: #0284c7;
}
.import-preview-stage {
  position: relative;
  overflow: auto;
  flex: 1;
  min-height: 0;
  touch-action: none;
  cursor: grab;
  background:
    linear-gradient(rgba(99,91,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,91,255,.05) 1px, transparent 1px),
    #eef1f4;
  background-size: 16px 16px, 16px 16px, auto;
}
.import-preview-stage.mode-crop { cursor: crosshair; }
.import-preview-stage.panning { cursor: grabbing; }
.import-preview-hint {
  position: fixed;
  left: 50%;
  bottom: 58px;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 12px;
  background: rgba(15, 23, 42, 0.82);
  color: #fff;
  font-size: 12px;
  border-radius: 20px;
  pointer-events: none;
  z-index: 60;
  max-width: min(92vw, 420px);
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.import-region-outline {
  fill: rgba(2, 132, 199, 0.05);
  stroke: #0284c7;
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}
#import-preview-canvas { display: block; }
#import-preview-svg {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
}
.import-crop-rect {
  fill: rgba(14, 165, 233, 0.15);
  stroke: #0284c7;
  stroke-width: 2;
  stroke-dasharray: 6 4;
}
.import-bottombar {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: #fff;
  padding: 6px 10px;
  box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.05);
}
.import-bottom-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}
.import-nombre-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 220px;
  min-width: 180px;
  max-width: 400px;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.import-nombre-wrap input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
}
.import-nombre-wrap input.import-nombre-pulse {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.22);
  background: #f8f7ff;
}
.import-capas-wrap {
  margin-top: 8px;
  max-height: 160px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fafc;
}
.import-capas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 4px 10px;
}
.import-capas label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin: 0;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.import-capas input { width: auto; margin: 0; flex-shrink: 0; }
.import-crop-pill {
  margin: 0;
  padding: 6px 10px;
  border-radius: 16px;
  font-size: 12px;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.import-crop-pill.ok {
  background: #f0f9ff;
  color: #0369a1;
  border-color: #bae6fd;
}
.import-check-inline {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  margin: 0 !important;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
}
.import-check-inline input {
  width: auto;
  margin: 0;
}
.import-bottom-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.import-bottom-actions button { min-width: 100px; }
.import-mas {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.import-mas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px 14px;
  margin-top: 8px;
}
.import-mas-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.import-mas-grid input[type="text"],
.import-mas-grid input[type="number"],
.import-mas-grid select {
  width: 100%;
  margin: 0;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
}
.import-range-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.import-range-row input[type="range"] { flex: 1; }
.import-meta {
  white-space: pre-wrap;
  max-height: 72px;
  overflow: auto;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  margin: 0;
  color: var(--muted);
}
@media (max-width: 720px) {
  .import-topbar { flex-wrap: wrap; }
  .import-aviso-mini { display: none; }
  .import-topbar-tools { justify-content: flex-start; order: 3; width: 100%; }
  .import-bottom-actions { width: 100%; margin-left: 0; }
  .import-bottom-actions button { flex: 1; }
  .import-crop-pill { white-space: normal; max-width: none; }
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
.form-actions button { min-width: 100px; }
#form-campos .field-hint {
  font-size: 11px;
  color: var(--muted);
  margin: 2px 0 0;
  line-height: 1.3;
}

/* Brújula de orientación del plano */
.norte-wrap {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 8px 0 4px;
  flex-wrap: wrap;
}
.norte-compass {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: radial-gradient(circle at 50% 45%, #fff 0%, #f0efff 70%, #e8e6ff 100%);
  position: relative;
  cursor: grab;
  touch-action: none;
  user-select: none;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.norte-compass:active { cursor: grabbing; }
.norte-dial {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  transition: transform .05s linear;
}
.norte-needle {
  position: absolute;
  left: 50%;
  top: 8px;
  width: 0;
  height: 0;
  margin-left: -8px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 36px solid #c0392b;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.15));
}
.norte-needle::after {
  content: "";
  position: absolute;
  left: -6px;
  top: 36px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 28px solid #1a1f36;
}
.norte-label-n {
  position: absolute;
  left: 50%;
  top: 2px;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 800;
  color: #c0392b;
}
.norte-up {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  text-align: center;
  font-size: 9px;
  color: var(--muted);
  pointer-events: none;
}
.norte-controls { flex: 1; min-width: 120px; }
.norte-grados {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}
.amb-field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
  align-items: center;
}
.amb-field-row label { margin: 0; font-size: 11px; display: flex; align-items: center; gap: 4px; }
.amb-field-row input[type="number"], .amb-field-row select {
  width: auto;
  min-width: 0;
  padding: 4px 6px;
  font-size: 12px;
}
.pared-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}
.pared-chip.ext { border-color: #e8a24a; background: #fff6eb; color: #9a5b00; }
.pared-chip.int { border-color: var(--border); color: var(--muted); }
.pared-line-ext { stroke: #e07a1f; stroke-width: 3; stroke-linecap: round; }
.pared-line-int { stroke: #a0a8b8; stroke-width: 2; stroke-dasharray: 3 3; stroke-linecap: round; }
.pared-hit { cursor: pointer; stroke: transparent; stroke-width: 14; fill: none; }

label { display: block; font-size: 12px; color: var(--muted); margin: 6px 0 3px; }

input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

button {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
}
button:hover { background: #f6f8fa; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: #524dd4; }
button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
button.full { width: 100%; }
button:disabled { opacity: .5; cursor: not-allowed; }

.tool-btns { display: flex; flex-direction: column; gap: 6px; }

.hint {
  font-size: 12px;
  color: var(--muted);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 8px 10px;
  margin-top: 8px;
  line-height: 1.4;
}

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 600;
}
.badge.ok { background: #e3f6ec; color: var(--interior); }
.badge.no { background: #fbeaea; color: var(--exterior); }

ul.unit-list { list-style: none; margin: 0; padding: 0; }
ul.unit-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 12px;
}
.dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.dot.interior { background: var(--interior); }
.dot.exterior { background: var(--exterior); }
.unit-list .del { margin-left: auto; color: var(--muted); cursor: pointer; border: none; background: none; padding: 2px 6px; }

.total-box {
  background: var(--accent-soft);
  border: 1px solid #d9d7ff;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.total-box .big { font-size: 26px; font-weight: 700; color: var(--accent); }
.total-box .sub { font-size: 12px; color: var(--muted); }

/* Marcas en el overlay (SVG) */
.unit-marker { cursor: pointer; }
.route-line { fill: none; stroke: var(--line); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.route-temp { fill: none; stroke: var(--line); stroke-width: 2; stroke-dasharray: 5 4; }
.calib-line { stroke: #f5a623; stroke-width: 3; stroke-linecap: round; }
.route-node { cursor: grab; }
.ambiente-poly { fill: rgba(99,91,255,.10); stroke: #635bff; stroke-width: 1.5; stroke-dasharray: 4 3; }

/* Nombre de la obra actual en el encabezado */
.obra-actual { font-size: 13px; color: var(--muted); font-weight: 600; }

/* Chip de usuario logueado, en el encabezado */
.user-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 6px 4px 10px;
  font-size: 12px;
  color: var(--muted);
}
.user-chip #btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  transition: background .15s, color .15s;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.user-chip #btn-logout:hover { background: #fbeaea; color: var(--exterior); }
button.linkish { font: inherit; }

/* Estados de foco visibles (teclado) */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Menú Proyecto (desplegable, estilo app de escritorio: arriba a la izquierda) */
.menu { position: relative; }
#btn-menu { white-space: nowrap; }
.menu-items {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 4px;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  z-index: 20;
}
.menu-items[hidden] { display: none; }
.menu-items button {
  text-align: left;
  border: none;
  background: none;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.menu-items button:hover { background: var(--accent-soft); }

/* Ventana "Mis proyectos" */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(26, 31, 54, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(26,31,54,.25);
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 18px 20px;
}
/* Import: gana al .modal-box de arriba (misma especificidad fallaba → preview de 520px) */
.modal.modal-import-fs {
  padding: 0 !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  background: #0f172a;
}
.modal.modal-import-fs .modal-box.modal-box-import {
  max-width: none !important;
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 17px; margin: 0; text-transform: none; letter-spacing: 0; color: var(--text); }
.modal-x { border: none; background: none; font-size: 16px; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.proj-list { list-style: none; margin: 12px 0 0; padding: 0; overflow-y: auto; }
.proj-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}
.proj-list .proj-info { flex: 1; min-width: 0; }
.proj-list .proj-nombre { font-weight: 600; font-size: 14px; }
.proj-list .proj-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.proj-list .proj-del { border: none; background: none; color: var(--exterior); cursor: pointer; padding: 4px 8px; }

/* Formulario "Datos de la obra" */
.obra-form { display: flex; flex-direction: column; margin-top: 8px; }
.obra-form label { margin: 10px 0 3px; }
.obra-form label.check { color: var(--text); font-size: 13px; }

/* Reporte imprimible: oculto en pantalla, visible al imprimir */
#reporte { display: none; }

@media print {
  header, .layout { display: none !important; }
  #reporte {
    display: block;
    padding: 24px;
    color: #000;
    font-size: 13px;
  }
  #reporte h1 { font-size: 20px; margin: 0 0 12px; }
  #reporte h2 { font-size: 15px; margin: 18px 0 6px; }
  #reporte .rep-meta p { margin: 2px 0; }
  #reporte table { width: 100%; border-collapse: collapse; margin-top: 4px; }
  #reporte th, #reporte td { border: 1px solid #999; padding: 5px 8px; text-align: left; }
  #reporte th { background: #eee; }
  #reporte .rep-total { margin-top: 8px; font-size: 14px; }
  #reporte .rep-nota { margin-top: 20px; font-size: 11px; color: #555; }
}
