/* Paleta tomada de la app v1 (static/workspace.css). Misma familia visual. */
@import url("https://fonts.googleapis.com/css2?family=Archivo:wght@600;700&family=Source+Sans+3:wght@400;600&family=JetBrains+Mono:wght@400;600&display=swap");

:root {
  --bg: #1e1e1e; --sidebar: #252526; --panel: #2d2d2d; --border: #3c3c3c;
  --text: #cccccc; --muted: #858585; --accent: #007acc; --selection: #094771;
  --rail: #333333; --contour: #f14c4c; --line: #569cd6; --bezier: #c586c0;
  --work: #4ec9b0; --turn: #e3b341; --warn: #d97706; --crit: #f14c4c;
  --f-display: "Archivo", system-ui, sans-serif;
  --f-body: "Source Sans 3", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--f-body); font-size: 14px; line-height: 1.5; overflow: hidden; }

/* barra superior */
.topbar { height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 12px;
  background: var(--sidebar); border-bottom: 1px solid var(--border); }
.brand { font-family: var(--f-display); font-weight: 700; }
.brand span { color: var(--accent); }
.topbar .spacer { flex: 1; }
.mission-name { color: var(--muted); font-size: 12.5px; }
.btn { font-size: 12.5px; color: var(--text); background: var(--panel);
  border: 1px solid var(--border); border-radius: 4px; padding: 5px 10px; cursor: pointer; }
.btn:hover { background: var(--rail); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn--primary:hover { filter: brightness(1.1); }

/* maqueta A: línea de tiempo abajo, a todo el ancho */
.shell { --w-tree: 260px; --w-props: 330px; --h-time: 330px;
  height: calc(100vh - 44px); display: grid; position: relative;
  grid-template-columns: var(--w-tree) 1fr var(--w-props);
  grid-template-rows: 1fr var(--h-time);
  grid-template-areas: "tree map props" "timeline timeline timeline"; }

/* separadores arrastrables entre paneles */
.gutter { position: absolute; z-index: 12; background: transparent; }
.gutter:hover, .gutter.drag { background: var(--accent); }
.gutter-v { top: 0; bottom: var(--h-time); width: 5px; cursor: col-resize; }
.gutter-h { left: 0; right: 0; height: 5px; cursor: row-resize; }
#gutTree { left: calc(var(--w-tree) - 2px); }
#gutProps { right: calc(var(--w-props) - 2px); }
#gutTime { bottom: calc(var(--h-time) - 2px); }
body.resizing { cursor: inherit; user-select: none; }
body.resizing iframe, body.resizing #gmap { pointer-events: none; }
.pane { background: var(--sidebar); min-width: 0; min-height: 0; display: flex; flex-direction: column; }
#tree { grid-area: tree; border-right: 1px solid var(--border); }
#map { grid-area: map; position: relative; background: #1b1b1b; }
#props { grid-area: props; border-left: 1px solid var(--border); }
#timeline { grid-area: timeline; border-top: 1px solid var(--border); }
.pane-head { height: 30px; display: flex; align-items: center; gap: 8px; padding: 0 11px; flex: none;
  border-bottom: 1px solid var(--border); background: var(--panel);
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .11em;
  text-transform: uppercase; color: var(--muted); }
.pane-head .count { margin-left: auto; color: var(--accent); }
.pane-body { overflow: auto; flex: 1; }

/* mapa */
#gmap { position: absolute; inset: 0; }
.map-tools { position: absolute; left: 10px; top: 10px; z-index: 5; display: flex; gap: 4px;
  background: rgba(37,37,38,.94); border: 1px solid var(--border); border-radius: 5px; padding: 4px; }
.tool { min-width: 32px; height: 28px; display: grid; place-items: center; cursor: pointer;
  border-radius: 4px; font-size: 13px; color: var(--muted); padding: 0 7px; }
.tool:hover { background: var(--rail); color: var(--text); }
.tool.on { background: var(--accent); color: #fff; }
/* El cartel es solo texto: si recibe clics, se come el vértice que el usuario quiso
   poner cerca de la esquina inferior izquierda. */
.map-note { pointer-events: none; position: absolute; left: 10px; bottom: 10px; z-index: 5; font-family: var(--f-mono);
  font-size: 10px; color: var(--muted); background: rgba(37,37,38,.92);
  border: 1px solid var(--border); padding: 4px 8px; border-radius: 4px; }
.map-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 30px; color: var(--muted); font-size: 13px; }

/* árbol */
.tree-group { font-family: var(--f-mono); font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); padding: 9px 11px 3px; }
.tree-item { display: flex; align-items: center; gap: 8px; padding: 5px 11px; cursor: pointer;
  border-left: 2px solid transparent; font-size: 13px; }
.tree-item:hover { background: var(--panel); }
.tree-item.sel { background: var(--selection); border-left-color: var(--accent); }
.tree-item .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tree-item .sub { margin-left: auto; font-family: var(--f-mono); font-size: 10px; color: var(--muted); }
.tree-item.child { padding-left: 26px; }

/* propiedades */
.props { padding: 11px; display: flex; flex-direction: column; gap: 11px; }
.prop-title { font-family: var(--f-display); font-weight: 600; font-size: 14.5px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 11px; color: var(--muted); }
.field input, .field select { background: var(--panel); border: 1px solid var(--border);
  color: var(--text); border-radius: 4px; padding: 5px 7px; font-family: var(--f-body); font-size: 13px;
  /* sin esto el ancho intrínseco del input manda y el panel se va de ancho */
  width: 100%; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.grid2 > * { min-width: 0; }
.props { min-width: 0; }
#props .pane-body { overflow-x: hidden; }
.hint { font-size: 11.5px; color: var(--muted); margin: 0; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.metric { background: var(--panel); border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; }
.metric b { display: block; font-family: var(--f-mono); font-size: 15px; color: var(--text); }
.metric span { font-size: 10.5px; color: var(--muted); }

/* avisos */
.issue { display: flex; gap: 7px; padding: 6px 11px; font-size: 12px;
  border-left: 3px solid var(--crit); background: #3a1d1d; }
.issue.warning { border-left-color: var(--warn); background: #3a2a10; }
.issue code { font-family: var(--f-mono); font-size: 10px; color: var(--muted); display: block; }
.state-chip { font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .08em;
  text-transform: uppercase; padding: 2px 6px; border-radius: 3px; font-weight: 600; }
.state-valid { color: var(--work); background: #14332c; border: 1px solid var(--work); }
.state-blocked { color: var(--crit); background: #3a1d1d; border: 1px solid var(--crit); }
.state-draft { color: var(--muted); background: var(--panel); border: 1px solid var(--border); }
.stale-bar { display: flex; align-items: center; gap: 9px; padding: 6px 11px; flex: none;
  background: #3a2a10; border-bottom: 1px solid var(--warn); font-size: 12.5px; }
.stale-bar .btn { margin-left: auto; padding: 3px 8px; font-size: 11.5px; }

/* línea de tiempo secuencial: un solo eje, bloques uno tras otro */
#tlBody { overflow: hidden; }
.tl-wrap { padding: 6px 11px 0; display: flex; flex-direction: column; gap: 5px; height: 100%; }
.tl-axis { position: relative; height: 15px; border-bottom: 1px solid var(--border);
  font-family: var(--f-mono); font-size: 9px; color: var(--muted); }
.tl-tick { position: absolute; top: 0; transform: translateX(-50%); }
.tl-tick i { position: absolute; left: 50%; top: 12px; height: 4px; border-left: 1px solid var(--border); }
.tl-track { position: relative; height: 34px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.tl-blk { position: absolute; top: 0; bottom: 0; border-right: 1px solid rgba(0,0,0,.45);
  cursor: pointer; display: flex; align-items: center; padding-left: 5px; overflow: hidden; }
.tl-blk:hover { filter: brightness(1.18); }
.tl-blk.sel { outline: 2px solid #fff; outline-offset: -2px; }
.tl-blk.bad { outline: 2px solid var(--crit); outline-offset: -2px; }
.tl-blk span { font-family: var(--f-mono); font-size: 9px; color: #10232b; font-weight: 600; white-space: nowrap; }
.k-work { background: var(--work); } .k-transit { background: var(--line); }
.k-turn { background: var(--turn); } .k-dwell { background: var(--bezier); }
.tl-cursor { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; z-index: 3; pointer-events: none; }
.tl-legend { display: flex; gap: 13px; font-size: 11px; color: var(--muted); align-items: center; flex-wrap: wrap; }
.tl-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 2px;
  margin-right: 5px; vertical-align: -1px; }
.tl-legend .tot { margin-left: auto; font-family: var(--f-mono); color: var(--text); }
.tl-list { display: flex; flex-direction: column; flex: 1; min-height: 0;
  overflow-y: auto; margin: 0 -11px; padding-bottom: 6px; }
.tl-row { display: flex; align-items: center; gap: 9px; padding: 2px 11px; font-size: 12px; cursor: pointer; }
.tl-row:hover { background: var(--panel); }
.tl-row.sel { background: var(--selection); }
.tl-row .sw { width: 7px; height: 13px; border-radius: 2px; flex: none; }
.tl-row .nm { width: 128px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-row .t0 { font-family: var(--f-mono); font-size: 10.5px; color: var(--muted); width: 62px; }
.tl-row .du { font-family: var(--f-mono); font-size: 10.5px; color: var(--muted); width: 58px; }
.tl-row .di { font-family: var(--f-mono); font-size: 10.5px; color: var(--muted); }

/* play */
.player { display: flex; align-items: center; gap: 9px; padding: 5px 11px; flex: none;
  border-bottom: 1px solid var(--border); background: var(--panel); }
.player input[type=range] { flex: 1; accent-color: var(--accent); }
.player .clock { font-family: var(--f-mono); font-size: 11.5px; color: var(--text); min-width: 108px; }
.player .telem { font-family: var(--f-mono); font-size: 10.5px; color: var(--muted); min-width: 190px; }

.toast { position: fixed; right: 14px; bottom: 14px; z-index: 40; background: var(--panel);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 9px 13px; border-radius: 4px; font-size: 12.5px; max-width: 380px; }
.toast.err { border-left-color: var(--crit); }

/* ------------------------------------------------------------------ fase 5 */

/* barra superior: nombre editable y estado de guardado */
.topbar .sep { width: 1px; height: 20px; background: var(--border); }
input.mission-name { background: transparent; border: 1px solid transparent; color: var(--text);
  font-family: var(--f-body); font-size: 13px; padding: 3px 6px; border-radius: 4px; width: 210px; }
input.mission-name:hover { border-color: var(--border); }
input.mission-name:focus { border-color: var(--accent); background: var(--panel); outline: none; }
.store-badge { font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--work); border: 1px solid var(--work);
  border-radius: 3px; padding: 2px 5px; }
.store-badge.unsaved { color: var(--muted); border-color: var(--border); }

/* herramientas e «ir a» sobre el mapa */
.map-tools { flex-wrap: wrap; max-width: calc(100% - 20px); }
.map-go { position: absolute; right: 10px; top: 10px; z-index: 5; display: flex; gap: 4px;
  background: rgba(37,37,38,.94); border: 1px solid var(--border); border-radius: 5px; padding: 4px; }
.map-go form { display: flex; gap: 4px; }
.map-go input { background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 4px; padding: 4px 8px; font-family: var(--f-body); font-size: 12.5px; width: 210px; }
.map-go input:focus { border-color: var(--accent); outline: none; }

/* propuesta de acceso todavía sin aceptar (D12) */
.proposal-bar { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 10px; font-size: 12.5px;
  background: rgba(37,37,38,.97); border: 1px solid var(--accent); border-radius: 5px; padding: 7px 11px; }

/* formularios del panel */
.props-head { padding: 7px 11px; display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border); }
.row { display: flex; gap: 6px; align-items: center; }
.row input { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.check input { accent-color: var(--accent); }
.btn.mini { padding: 2px 6px; font-size: 11px; line-height: 1.3; }
.btn--danger { color: var(--crit); border-color: #5a2a2a; }
.btn--danger:hover { background: #3a1d1d; }
.issue { cursor: pointer; }
.issue:hover { filter: brightness(1.2); }
.field input[type=range] { accent-color: var(--accent); padding: 0; }

/* orden de los lotes */
.order { display: flex; flex-direction: column; gap: 3px; }
.order-row { display: flex; align-items: center; gap: 6px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 4px; padding: 4px 7px; font-size: 12.5px; }
.order-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-row input[type=checkbox] { accent-color: var(--accent); }

/* rangos de t */
.spans { display: flex; flex-direction: column; gap: 4px; }
.span-row { display: flex; align-items: center; gap: 6px; }
.span-row .t { font-family: var(--f-mono); font-size: 10.5px; color: var(--muted); width: 78px; }
.span-row select { flex: 1; background: var(--panel); border: 1px solid var(--border);
  color: var(--text); border-radius: 4px; padding: 3px 6px; font-size: 12px; }

/* diálogos */
.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55);
  display: grid; place-items: center; }
.modal { width: min(560px, 92vw); max-height: 82vh; overflow: auto; background: var(--sidebar);
  border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 18px 48px rgba(0,0,0,.5); }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--panel);
  font-family: var(--f-display); font-weight: 600; }
.modal-body { padding: 12px; display: flex; flex-direction: column; gap: 9px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 7px; padding-top: 4px; }
.mission-row { display: flex; align-items: center; gap: 9px; padding: 7px 9px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 4px; }
.mission-row .mr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mission-row .mr-main b { font-size: 13px; }
.hint.mono { font-family: var(--f-mono); font-size: 10px; }

/* brillo del mapa y pintada */
.map-go .dim { display: flex; align-items: center; gap: 5px; padding: 0 7px;
  color: var(--muted); font-size: 13px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 4px; }
.map-go .dim input[type=range] { width: 84px; accent-color: var(--accent); }
.player .check { flex: none; white-space: nowrap; }

/* árbol: el grupo derivado se pliega */
.tree-toggle { cursor: pointer; display: flex; align-items: center; gap: 5px; }
.tree-toggle:hover { color: var(--text); }
.tree-toggle .caret { font-size: 9px; width: 8px; }

/* las cuatro partidas posibles del lote */
.esquinas { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.esquina { display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  text-align: left; padding: 6px 8px; font-size: 10.5px; line-height: 1.25; color: var(--muted); }
.esquina b { font-family: var(--f-mono); font-size: 13px; color: var(--text); }
.esquina.on { border-color: var(--work); background: #14332c; color: var(--text); }
.esquina.on b { color: var(--work); }

/* volver de la selección a la misión */
.btn.volver { align-self: flex-start; color: var(--accent); border-color: transparent;
  padding: 3px 6px; margin: -4px 0 -2px -4px; }
.btn.volver:hover { background: var(--panel); }

/* los dos cuadros que se llenan mientras corre la reproducción */
.metric.vivo { border-color: var(--accent); }
.metric.vivo b { color: var(--accent); }
.metric.vivo span { white-space: normal; line-height: 1.35; }

/* navegador: ajustes arriba, documento abajo */
.nav-item { display: flex; align-items: center; gap: 8px; padding: 5px 11px; cursor: pointer;
  border-left: 2px solid transparent; font-size: 13px; }
.nav-item:hover { background: var(--panel); }
.nav-item.sel { background: var(--selection); border-left-color: var(--accent); }
.nav-item .sub { margin-left: auto; font-family: var(--f-mono); font-size: 10px; color: var(--muted); }
.dot.d-set { background: var(--muted); border-radius: 2px; }
.nav-item.sel .dot.d-set { background: var(--accent); }
.props .hint a { color: var(--accent); }

.tree-sub { font-family: var(--f-mono); font-size: 9px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); padding: 7px 11px 2px; }
.tree-sub b { color: var(--accent); font-weight: 400; }

/* Reproduciendo se mira y se navega, pero no se edita: bloquear el navegador dejaba sin
   forma de llegar al panel donde se ve el avance de la etapa. */
body.playing #props input, body.playing #props select, body.playing #props textarea,
body.playing #props button, body.playing #props .esquina, body.playing #props .issue,
body.playing .map-tools, body.playing .topbar .btn,
body.playing input.mission-name { opacity: .45; pointer-events: none; }
.lock { display: none; font-family: var(--f-mono); font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; color: #10232b; background: var(--turn);
  padding: 2px 7px; border-radius: 3px; flex: none; }
body.playing .lock { display: inline-block; }
