/* ==========================================================================
   HIDROGEO 3D — Base, layout y componentes globales
   ========================================================================== */
[hidden] { display: none !important; }
:root {
  --bg0: #060b10;
  --bg1: #0a1118;
  --bg2: #0d1720;
  --panel: #0b141c;
  --panel2: #101d27;
  --panel3: #14242f;
  --line: #1c2c38;
  --line2: #2a4150;
  --text: #dbe8f1;
  --muted: #7e96a6;
  --dim: #546b7b;
  --accent: #2fc3a8;
  --accent2: #48a9ff;
  --amber: #f2a93b;
  --red: #ef6464;
  --green: #45c98a;
  --shadow: 0 18px 48px rgba(0, 0, 0, .45);
  --mono: "Cascadia Mono", "Consolas", "SFMono-Regular", monospace;
  --sans: "Segoe UI", "Inter", Roboto, system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg0); color: var(--text);
  font-family: var(--sans); font-size: 13.5px; line-height: 1.45;
  display: grid; grid-template-rows: 60px minmax(0, 1fr) 28px;
  overflow: hidden; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
b, strong { font-weight: 600; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.eyebrow { font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); font-weight: 700; }

/* -------------------------------- topbar -------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 22px; padding: 0 18px;
  background: linear-gradient(180deg, #0d1821 0%, #0a1219 100%);
  border-bottom: 1px solid var(--line); position: relative; z-index: 40;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(47, 195, 168, .55), transparent);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 318px; }
.brand-mark { width: 42px; height: 42px; flex: none; filter: drop-shadow(0 0 10px rgba(84, 209, 96, .3)); }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-text h1 { font-size: 16.5px; letter-spacing: .13em; font-weight: 700; line-height: 1.1; }
.brand-text h1 span { color: var(--accent); font-weight: 800; }
.brand-text p { font-size: 10px; color: var(--muted); letter-spacing: .02em; margin-top: 2px; white-space: nowrap; }
.brand-sub b { color: #8bdc63; font-size: 9px; letter-spacing: .13em; font-weight: 800; }
.scenario-chip { display: flex; flex-direction: column; gap: 3px; width: 250px; }
.scenario-chip input {
  background: transparent; border: 1px solid transparent; border-bottom-color: var(--line2);
  padding: 2px 4px; font-size: 13px; font-weight: 600; color: var(--text); outline: none; width: 100%;
}
.scenario-chip input:focus { border-color: var(--accent); background: var(--panel2); border-radius: 3px; }
.topbar-actions { margin-left: auto; display: flex; gap: 7px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px;
  border-radius: 6px; border: 1px solid var(--line2); background: var(--panel2);
  color: var(--text); font-size: 12px; font-weight: 600; transition: .16s ease;
}
.btn:hover { border-color: #3b5a6d; background: var(--panel3); }
.btn.primary { background: linear-gradient(180deg, #35cbb0, #23a08a); border-color: #45d1b8; color: #04120f; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn .ic { width: 15px; height: 15px; }
.badge {
  min-width: 17px; height: 17px; border-radius: 9px; padding: 0 5px; background: var(--panel3);
  border: 1px solid var(--line2); color: var(--muted); font-size: 10px; display: inline-grid; place-items: center;
  font-family: var(--mono);
}
.btn.primary .badge { background: rgba(0,0,0,.14); border-color: rgba(0,0,0,.15); color: #06302a; }

/* ------------------------------- workspace ------------------------------- */
.workspace { display: grid; grid-template-columns: 76px minmax(0, 1fr) 412px; min-height: 0; }
.rail {
  display: flex; flex-direction: column; gap: 3px; padding: 10px 7px;
  background: linear-gradient(180deg, #0c161e, #081016); border-right: 1px solid var(--line);
  overflow-y: auto; z-index: 20;
}
.rail-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  height: 58px; border: 1px solid transparent; border-radius: 7px; background: transparent;
  color: var(--muted); font-size: 9.5px; font-weight: 600; letter-spacing: .02em; transition: .15s;
}
.rail-btn .ic { width: 20px; height: 20px; }
.rail-btn:hover { background: var(--panel2); color: var(--text); }
.rail-btn.active { background: rgba(47, 195, 168, .09); border-color: rgba(47, 195, 168, .28); color: var(--accent); }
.rail-btn.active::before {
  content: ""; position: absolute; left: -8px; top: 14px; bottom: 14px; width: 2px;
  background: var(--accent); border-radius: 2px; box-shadow: 0 0 10px var(--accent);
}

/* ------------------------------- viewport -------------------------------- */
.viewport { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: radial-gradient(120% 90% at 50% 10%, #0e1b26 0%, #070d13 65%, #05090d 100%); }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#gl.dragging { cursor: grabbing; }

/* ---------------------------------- HUD ---------------------------------- */
.hud { position: absolute; z-index: 10; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-tl { top: 14px; left: 14px; }
.hud-tr { top: 14px; right: 14px; }
.hud-legend { right: 14px; bottom: 92px; width: 238px; }
.hud-card {
  background: rgba(9, 17, 24, .82); border: 1px solid rgba(48, 74, 90, .6);
  border-radius: 8px; backdrop-filter: blur(12px); box-shadow: var(--shadow);
}
.scenario-card { width: 292px; padding: 11px 13px 10px; }
.hud-row { display: flex; align-items: center; gap: 7px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); box-shadow: 0 0 0 3px rgba(84,107,123,.12); }
.live-dot.on { background: var(--green); box-shadow: 0 0 8px var(--green), 0 0 0 3px rgba(69,201,138,.13); animation: pulse 1.8s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.hud-label { font-size: 11.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-time { display: flex; align-items: baseline; gap: 8px; margin: 6px 0 9px; }
.hud-time > span:first-child { font-family: var(--mono); font-size: 24px; font-weight: 600; color: #e8f5fb; letter-spacing: -.02em; }
.hud-sub { font-size: 10.5px; color: var(--muted); font-family: var(--mono); }
.hud-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; border-top: 1px solid var(--line); padding-top: 8px; }
.hud-metrics + .hud-metrics { margin-top: 6px; }
.hud-metrics > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.hud-metrics span { font-size: 9px; color: var(--dim); text-transform: uppercase; letter-spacing: .07em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-metrics b { font-family: var(--mono); font-size: 13.5px; font-weight: 600; color: var(--text); white-space: nowrap; }
.hud-metrics small { font-size: 8.5px; color: var(--dim); }
.compliance { margin-top: 8px; font-size: 10px; padding: 4px 7px; border-radius: 4px; background: rgba(84,107,123,.12); color: var(--muted); border: 1px solid transparent; }
.compliance.ok { color: var(--green); background: rgba(69,201,138,.08); border-color: rgba(69,201,138,.25); }
.compliance.bad { color: var(--red); background: rgba(239,100,100,.08); border-color: rgba(239,100,100,.25); }

.view-tools { display: flex; flex-direction: column; gap: 4px; padding: 5px; background: rgba(9,17,24,.82); border: 1px solid rgba(48,74,90,.6); border-radius: 8px; backdrop-filter: blur(12px); }
.tool-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted); transition: .14s; }
.tool-btn:hover { background: var(--panel3); color: var(--text); }
.tool-btn.active { color: var(--accent); background: rgba(47,195,168,.10); border-color: rgba(47,195,168,.22); }
.tool-sep { height: 1px; background: var(--line); margin: 2px 4px; }

.hud-legend { padding: 10px 11px 9px; background: rgba(9,17,24,.84); border: 1px solid rgba(48,74,90,.6); border-radius: 8px; backdrop-filter: blur(12px); box-shadow: var(--shadow); }
.legend-head { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 6px; }
.legend-head span:last-child { font-family: var(--mono); color: var(--dim); }
.legend-bar { height: 9px; border-radius: 3px; border: 1px solid rgba(255,255,255,.09); position: relative; }
.legend-limit { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #fff; box-shadow: 0 0 4px rgba(255,255,255,.85); border-radius: 1px; transform: translateX(-1px); }
.slice-legend { margin-top: 6px; padding-top: 5px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; font-size: 8px; color: var(--muted); }
.slice-legend .slice-head { font-size: 7.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); margin-bottom: 1px; }
.slice-legend b { color: #b9d6e4; font-family: var(--mono); font-weight: 500; }
.slice-swatch { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.slice-swatch.h { background: rgba(147,73,196,.75); }
.slice-swatch.x { background: rgba(73,160,204,.75); }
.slice-swatch.y { background: rgba(204,120,73,.75); }
.legend-scale { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 9px; color: var(--dim); margin-top: 3px; }
.legend-note { font-size: 9px; color: var(--dim); margin-top: 5px; line-height: 1.3; }

/* Leyenda de estratos (sustituye etiquetas 3D que tapaban la pluma) */
.hud-strata {
  left: 14px; bottom: 92px; width: 208px; padding: 8px 10px 7px;
  background: rgba(9, 17, 24, .82); border: 1px solid rgba(48, 74, 90, .55);
  border-radius: 8px; backdrop-filter: blur(12px); box-shadow: var(--shadow);
}
.strata-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 8.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
.strata-head b { font-family: var(--mono); font-size: 8px; letter-spacing: 0; color: var(--muted); font-weight: 500; }
.strata-row { display: flex; align-items: center; gap: 6px; padding: 1.5px 0; }
.strata-row i { width: 8px; height: 8px; border-radius: 2px; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.strata-name { flex: 1; min-width: 0; font-size: 9.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strata-k { font-family: var(--mono); font-size: 8px; color: var(--muted); white-space: nowrap; }
.strata-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); font-size: 8.5px; color: var(--muted); }
.strata-foot span { display: flex; align-items: center; gap: 5px; }
.strata-foot i { width: 9px; height: 2px; border-radius: 1px; background: #63c8f0; box-shadow: 0 0 4px rgba(99,200,240,.6); }
.strata-foot b { font-family: var(--mono); font-weight: 500; color: #9fd7ec; }
@media (max-width: 1080px) { .hud-strata { width: 180px; bottom: 88px; } }

/* Etiquetas de ejes proyectadas: nítidas, sin tapar el bloque */
.scene-labels { position: absolute; inset: 0; z-index: 8; overflow: hidden; pointer-events: none; }
.scene-labels .ann { position: absolute; transform: translate(-50%, -50%); font-family: var(--mono); font-size: 9px; letter-spacing: .02em; color: rgba(198,224,238,.94); text-shadow: 0 1px 3px rgba(0,0,0,.95), 0 0 8px rgba(0,0,0,.75); white-space: nowrap; }
.scene-labels .ann.rot { transform: translate(-50%, -50%) rotate(-90deg); }
.viewref { position: absolute; top: 14px; right: 62px; z-index: 10; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.compass { width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(120,170,195,.32); background: rgba(9,17,24,.55); position: relative; box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.compass .needle { position: absolute; inset: 2px; transform-origin: 50% 50%; }
.compass .needle span { position: absolute; left: 0; right: 0; top: 0; text-align: center; font: 600 6.5px/1.2 var(--mono); color: #9fdcf0; }
.compass .needle i { position: absolute; left: 50%; top: 9px; width: 1.5px; height: 12px; margin-left: -.75px; background: linear-gradient(180deg, #8fdcef, rgba(143,220,239,.15)); border-radius: 1px; box-shadow: 0 0 5px rgba(127,214,239,.55); }
.compass .needle i::before { content: ''; position: absolute; left: 50%; top: -4px; margin-left: -2.5px; border: 2.5px solid transparent; border-bottom: 5px solid #8fdcef; border-top: 0; }
.scale { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.scale .track { display: block; width: 72px; height: 5px; border: 1px solid rgba(160,205,225,.55); border-radius: 1px; overflow: hidden; background: rgba(9,17,24,.5); }
.scale .track i { display: block; height: 100%; background: repeating-linear-gradient(90deg, #8fdcef 0 25%, rgba(143,220,239,.18) 25% 50%); }
.scale b { font-family: var(--mono); font-size: 8px; font-weight: 500; color: rgba(190,220,235,.85); }

/* -------------------------------- timeline ------------------------------- */
.timeline-wrap { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 12; width: min(590px, calc(100% - 40px)); }
.timeline {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 9px;
  background: rgba(9, 17, 24, .9); border: 1px solid rgba(48,74,90,.65); border-radius: 10px;
  backdrop-filter: blur(14px); box-shadow: var(--shadow);
}
.play-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid #45d1b8;
  background: linear-gradient(180deg, #35cbb0, #229b86); color: #03130f; display: grid; place-items: center;
  box-shadow: 0 0 18px rgba(47,195,168,.28); transition: .15s;
}
.play-btn:hover { filter: brightness(1.08); }
.play-btn .ic { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.icon-btn { width: 30px; height: 30px; border-radius: 6px; border: 1px solid transparent; background: transparent; color: var(--muted); display: grid; place-items: center; transition: .15s; }
.icon-btn:hover { color: var(--text); background: var(--panel3); border-color: var(--line2); }
.tl-time { display: flex; flex-direction: column; min-width: 82px; margin-left: 2px; }
.tl-time span:first-child { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.tl-time span:last-child { font-size: 9.5px; color: var(--dim); }
.tl-progress { flex: 1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.tl-progress span { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #2a8f7e, var(--accent)); transition: width .25s linear; }
.speed { display: flex; flex-direction: column; gap: 1px; font-size: 8.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.speed select { background: var(--panel2); border: 1px solid var(--line2); color: var(--text); border-radius: 4px; font-size: 10.5px; padding: 2px 3px; outline: none; }

/* --------------------------------- panel --------------------------------- */
.panel { background: linear-gradient(180deg, #0b141c, #091117); border-left: 1px solid var(--line); min-height: 0; display: flex; flex-direction: column; z-index: 15; }
.panel-head { display: flex; justify-content: space-between; gap: 10px; padding: 14px 16px 11px; border-bottom: 1px solid var(--line); flex: none; }
.panel-title h2 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; margin-top: 2px; }
.panel-title p { font-size: 10.5px; color: var(--muted); margin-top: 3px; max-width: 330px; }
.panel-head .icon-btn { margin-top: 2px; }
.panel-body { overflow-y: auto; overflow-x: hidden; padding: 13px 15px 28px; min-height: 0; }

/* -------------------------------- statusbar ------------------------------ */
.statusbar { display: flex; align-items: center; gap: 18px; padding: 0 14px; background: #070e14; border-top: 1px solid var(--line); font-size: 9.5px; color: var(--muted); letter-spacing: .02em; }
.status-item { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.status-item b { color: #9cb4c3; font-family: var(--mono); font-weight: 500; }
.status-dim { color: var(--dim); }
.status-spacer { flex: 1; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); display: inline-block; }
.dot.ok { background: var(--green); box-shadow: 0 0 7px rgba(69,201,138,.7); }
.dot.warn { background: var(--amber); }
.dot.bad { background: var(--red); }

/* --------------------------------- forms --------------------------------- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.field-top > span:first-child { font-size: 10.5px; color: var(--muted); font-weight: 500; }
.input-wrap { display: flex; align-items: stretch; border: 1px solid var(--line2); border-radius: 5px; background: var(--bg2); overflow: hidden; transition: .14s; }
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47,195,168,.10); }
.input-wrap input, .input-wrap select {
  width: 100%; min-width: 0; border: 0; background: transparent; padding: 6px 6px 6px 8px;
  font-family: var(--mono); font-size: 12px; color: var(--text); outline: none;
}
.input-wrap input::-webkit-outer-spin-button, .input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-wrap input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.input-wrap .unit { display: grid; place-items: center; padding: 0 7px; background: rgba(255,255,255,.035); border-left: 1px solid var(--line); color: var(--dim); font-size: 9.5px; font-family: var(--mono); white-space: nowrap; }
.field.invalid .input-wrap { border-color: var(--red); }
.field .hint { font-size: 8.5px; color: var(--dim); line-height: 1.3; }
select { background: var(--bg2); }
select option { background: #0e1a23; color: var(--text); }
.help { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line2); background: transparent; color: var(--dim); font-size: 9px; display: grid; place-items: center; padding: 0; }
.help:hover { color: var(--accent); border-color: var(--accent); }

/* --------------------------------- utils --------------------------------- */
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.row { display: flex; gap: 8px; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sep { height: 1px; background: var(--line); margin: 14px 0; }
.hidden { display: none !important; }

:root {
  --scrollbar-thumb: #64748b;
  --scrollbar-track: transparent;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

@supports not (scrollbar-color: auto) {
  :root { scrollbar-width: auto; }
  ::-webkit-scrollbar { width: 9px; height: 9px; }
  ::-webkit-scrollbar-track { background: var(--scrollbar-track); }
  ::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 5px; border: 2px solid var(--panel); }
  ::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
}

/* -------------------------------- toasts --------------------------------- */
.toast-wrap { position: fixed; right: 428px; bottom: 46px; display: flex; flex-direction: column; gap: 7px; z-index: 90; pointer-events: none; }
.toast {
  min-width: 250px; max-width: 360px; padding: 9px 12px; border-radius: 7px; font-size: 11.5px;
  background: rgba(13, 24, 32, .96); border: 1px solid var(--line2); box-shadow: var(--shadow);
  color: var(--text); animation: toastIn .22s ease-out; border-left: 2px solid var(--accent);
}
.toast.warn { border-left-color: var(--amber); }
.toast.err { border-left-color: var(--red); }
.toast b { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 2px; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

/* -------------------------------- spinner -------------------------------- */
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(47,195,168,.18); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.solve-overlay { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(5,10,14,.55); backdrop-filter: blur(3px); }
.solve-card { display: flex; align-items: center; gap: 13px; padding: 14px 20px; border-radius: 9px; background: rgba(10,19,26,.96); border: 1px solid var(--line2); box-shadow: var(--shadow); }
.solve-card b { display: block; font-size: 12.5px; }
.solve-card span { display: block; font-size: 10px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }
