/* Casa PO — estilos */
:root {
  --bg: #10161f;
  --panel: #1a2332;
  --panel2: #223047;
  --border: #33415c;
  --text: #e8edf5;
  --muted: #8fa1bd;
  --accent: #4da3ff;
  --ok: #3ddc84;      /* medida verificada */
  --warn: #ffc857;    /* medida aproximada */
  --danger: #ff6b6b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}

/* ===== Topbar ===== */
#topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding-top: max(8px, env(safe-area-inset-top));
  z-index: 30;
}
.brand { font-size: 15px; white-space: nowrap; }
.spacer { flex: 1; }
#modeTabs { display: flex; gap: 4px; background: var(--bg); border-radius: 10px; padding: 3px; }
.tab {
  border: none; background: transparent; color: var(--muted);
  padding: 6px 14px; border-radius: 8px; font-size: 14px; cursor: pointer;
}
.tab.active { background: var(--accent); color: #06121f; font-weight: 600; }
.iconbtn {
  border: 1px solid var(--border); background: var(--panel2); color: var(--text);
  padding: 6px 10px; border-radius: 8px; font-size: 14px; cursor: pointer;
}
.badge {
  background: var(--warn); color: #332200; border-radius: 9px;
  font-size: 11px; font-weight: 700; padding: 1px 6px;
}
.badge.zero { background: var(--ok); color: #063; }
.sync-dot { color: var(--muted); font-size: 12px; }
.sync-dot.on { color: var(--ok); }

/* ===== Popover menú ===== */
.popover {
  position: absolute; top: 52px; right: 10px; z-index: 40;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px; display: flex; flex-direction: column; gap: 4px; min-width: 230px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.popover button {
  background: transparent; border: none; color: var(--text); text-align: left;
  padding: 8px 10px; border-radius: 6px; font-size: 14px; cursor: pointer;
}
.popover button:hover { background: var(--panel); }
.popover hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.menu-version { color: var(--muted); font-size: 11px; text-align: center; padding: 4px; }

/* ===== Workspace ===== */
#workspace { flex: 1; position: relative; overflow: hidden; }
#view2d, #view3d { position: absolute; inset: 0; }
#canvas2d { width: 100%; height: 100%; display: block; background: #0d131c; cursor: crosshair; }
#canvas3dWrap { position: absolute; inset: 0; }
#canvas3dWrap canvas { display: block; }

/* ===== Toolbars flotantes ===== */
#toolbar2d, #toolbar3d {
  position: absolute; top: 10px; left: 10px; z-index: 20;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.tool {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 8px 12px; border-radius: 10px; font-size: 13px; cursor: pointer;
}
.tool.active { background: var(--accent); color: #06121f; border-color: var(--accent); font-weight: 600; }

/* ===== Barra de pistas ===== */
.hintbar {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(26,35,50,.92); border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 10px; font-size: 12px; color: var(--muted);
  max-width: 92%; text-align: center; z-index: 20; pointer-events: none;
}

/* ===== Panel propiedades ===== */
#propsPanel {
  position: absolute; top: 10px; right: 10px; z-index: 25;
  width: 260px; max-height: calc(100% - 80px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px;
}
#propsPanel h3 { font-size: 14px; margin-bottom: 10px; display: flex; justify-content: space-between; }
.prop-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.prop-row label { font-size: 13px; color: var(--muted); flex: 1; }
.prop-row input[type="number"] {
  width: 84px; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 6px 8px; border-radius: 7px; font-size: 14px; text-align: right;
}
.prop-row input:focus { outline: none; border-color: var(--accent); }
.prop-row .unit { font-size: 12px; color: var(--muted); width: 24px; }
.verify-toggle {
  display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer;
  padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg);
}
.verify-toggle.ok { border-color: var(--ok); color: var(--ok); }
.verify-toggle.aprox { border-color: var(--warn); color: var(--warn); }
.btn-danger {
  width: 100%; margin-top: 8px; background: transparent; border: 1px solid var(--danger);
  color: var(--danger); padding: 8px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.btn-row { display: flex; gap: 6px; margin-top: 4px; }
.btn-sm {
  flex: 1; background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 7px; border-radius: 8px; cursor: pointer; font-size: 12px;
}
.closebtn { background: none; border: none; color: var(--muted); font-size: 14px; cursor: pointer; }

/* ===== Checklist ===== */
#checklistPanel {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 28;
  width: 320px; max-width: 90vw;
  background: var(--panel); border-left: 1px solid var(--border);
  padding: 16px; overflow-y: auto;
}
#checklistPanel h3 { font-size: 15px; margin-bottom: 6px; display: flex; justify-content: space-between; }
#checklistPanel .muted { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.chk-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border: 1px solid var(--border); border-radius: 9px;
  margin-bottom: 6px; font-size: 13px; cursor: pointer;
}
.chk-item:hover { border-color: var(--warn); }
.chk-item .dot { color: var(--warn); }
.chk-empty { color: var(--ok); font-size: 13px; text-align: center; padding: 20px 0; }

/* ===== Panel de capas ===== */
#layersPanel {
  position: absolute; top: 10px; right: 10px; z-index: 26;
  width: 300px; max-width: 92vw; max-height: calc(100% - 80px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px;
}
#layersPanel h3 { font-size: 14px; margin-bottom: 10px; display: flex; justify-content: space-between; }
#layersPanel .tiny { font-size: 11px; color: var(--muted); margin-top: 10px; }
.layer-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 8px; margin-bottom: 3px; font-size: 13px;
}
.layer-row:hover { background: var(--panel2); }
.layer-row.off { opacity: 0.45; }
.layer-row .eye { background: none; border: none; cursor: pointer; font-size: 15px; width: 26px; }
.layer-row .dot { font-size: 13px; }
.layer-row .lname { flex: 1; }
.layer-row .llen { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.layer-row .draw {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 7px; padding: 4px 8px; cursor: pointer; font-size: 13px;
}
.layer-row .draw.active { background: var(--accent); border-color: var(--accent); }
.layer-row .draw:disabled { opacity: 0.35; cursor: default; }
.layer-sub {
  font-size: 11px; color: var(--muted); padding: 0 8px 6px 42px;
  font-variant-numeric: tabular-nums;
}
.prop-note {
  font-size: 11px; color: var(--muted); margin: -2px 0 8px;
  line-height: 1.5;
}

/* ===== Lectura de medición 3D ===== */
#measureReadout {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 22;
  background: var(--panel); border: 2px solid var(--accent); border-radius: 12px;
  padding: 10px 22px; font-size: 22px; font-weight: 700; color: var(--accent);
}

/* ===== Toast ===== */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--panel2); border: 1px solid var(--accent); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
}

.hidden { display: none !important; }

/* ===== Móvil ===== */
@media (max-width: 640px) {
  .brand b { display: none; }
  #propsPanel { left: 10px; right: 10px; width: auto; top: auto; bottom: 44px; max-height: 45%; }
  .tab { padding: 6px 10px; font-size: 13px; }
  .hintbar { display: none; }
}
