:root {
  --fondo: #eceff1; --papel: #ffffff; --tinta: #1c262c; --suave: #5a6972; --borde: #ccd5da;
  --acento: #0b6e86; --acento-sua: #dcedf2; --on: #0a8a3a; --on-sua: #dff3e5;
  --err: #b3261e; --err-sua: #fbe6e4; --avi: #8a5a00; --avi-sua: #fdf1d8; --inf: #245f9e; --inf-sua: #e2eefa;
  --cabecera: #18262e; --mono: Consolas, "Cascadia Mono", monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--fondo); color: var(--tinta); font: 14px/1.45 "Segoe UI", system-ui, sans-serif; display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--papel); border: 1px solid var(--borde); border-radius: 4px; padding: 5px 10px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--acento); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--acento); outline-offset: 1px; }
input, select, textarea { background: var(--papel); border: 1px solid var(--borde); border-radius: 4px; padding: 4px 6px; }
.primario { background: var(--acento); border-color: var(--acento); color: #fff; }

.barra-sup { background: var(--cabecera); color: #fff; display: flex; align-items: center; gap: 22px; padding: 8px 16px; }
.marca { flex: none; }
.marca img { display: block; height: 44px; background: #fff; border-radius: 6px; padding: 2px 6px; }
[hidden] { display: none !important; }
.barra-sup nav { display: flex; gap: 4px; flex: 1; }
.barra-sup nav button { background: transparent; border-color: transparent; color: #c6d3da; }
.barra-sup nav button.activo { background: #2d414d; color: #fff; }
.plc { display: flex; align-items: center; gap: 8px; }
.estado { font: 700 12px var(--mono); padding: 4px 10px; border-radius: 3px; background: #6f2b26; }
.estado.en-run { background: var(--on); }
.run, .stop { font-weight: 700; color: var(--tinta); }

.vista { display: none; flex: 1; min-height: 0; }
.vista.activa { display: flex; flex-direction: column; }
.documento { overflow: auto; padding: 22px; }
.documento.activa { display: block; }
.documento article, .contenedor { max-width: 980px; margin: 0 auto; }
.documento h2 { margin: 26px 0 8px; font-size: 18px; }
.documento h2:first-child { margin-top: 0; }
.documento table { border-collapse: collapse; width: 100%; background: var(--papel); }
.documento th, .documento td { border: 1px solid var(--borde); padding: 6px 9px; text-align: left; vertical-align: top; }
.documento th { background: var(--acento-sua); }
code { font-family: var(--mono); }

.paleta { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 7px 12px; background: var(--papel); border-bottom: 1px solid var(--borde); }
.paleta .sep { width: 1px; height: 24px; background: var(--borde); margin: 0 6px; }
.paleta button { font-family: var(--mono); font-size: 13px; }
.paleta .txt { font-family: inherit; }
.propiedades { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; min-height: 42px; padding: 6px 12px; background: var(--acento-sua); border-bottom: 1px solid var(--borde); }
.propiedades label { display: flex; align-items: center; gap: 5px; font-size: 13px; }
.propiedades input[type=text] { width: 130px; font-family: var(--mono); }
.propiedades input[type=number] { width: 86px; }
.propiedades .ayuda { color: var(--suave); }

.trabajo { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 350px; }
.programa { overflow: auto; padding: 12px; }
.lateral { display: flex; flex-direction: column; min-height: 0; background: var(--papel); border-left: 1px solid var(--borde); }
.pestanas { display: flex; border-bottom: 1px solid var(--borde); }
.pestanas button { flex: 1; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 9px 2px; font-size: 13px; }
.pestanas button.activo { border-bottom-color: var(--acento); font-weight: 600; }
.panel { flex: 1; overflow: auto; padding: 12px; }
.panel h3 { margin: 12px 0 6px; font-size: 13px; color: var(--suave); text-transform: uppercase; letter-spacing: .4px; }
.panel h3:first-child { margin-top: 0; }

.segmento { background: var(--papel); border: 1px solid var(--borde); border-radius: 5px; margin-bottom: 10px; }
.segmento.activo { border-color: var(--acento); }
.seg-cab { display: flex; align-items: center; gap: 8px; padding: 5px 9px; border-bottom: 1px solid var(--borde); }
.seg-cab b { white-space: nowrap; font-size: 13px; }
.seg-cab input { flex: 1; min-width: 80px; border-color: transparent; background: transparent; }
.seg-cab input:hover, .seg-cab input:focus { border-color: var(--borde); background: #fff; }
.seg-cab button { padding: 2px 7px; font-size: 12px; }
.seg-cuerpo { overflow-x: auto; padding: 4px 6px; }
.seg-expl { padding: 7px 11px; border-top: 1px dashed var(--borde); background: #f7fafb; font-size: 13px; }
.agregar { width: 100%; padding: 8px; border-style: dashed; color: var(--suave); }

svg.red { display: block; }
svg .w { stroke: #71818b; stroke-width: 1.6; stroke-linecap: square; }
svg .w.off { stroke: #2a6fb4; stroke-dasharray: 4 3; }
svg .w.on { stroke: var(--on); stroke-width: 2.8; }
svg .barra { stroke: #33434d; stroke-width: 3; }
svg .barra.on { stroke: var(--on); }
svg .c { stroke: var(--tinta); stroke-width: 2; fill: none; }
svg .caja { stroke: var(--tinta); stroke-width: 1.5; fill: #fff; }
svg .cuerpo.on .c, svg .cuerpo.on .caja { stroke: var(--on); stroke-width: 2.6; }
svg .cuerpo.on .caja { fill: var(--on-sua); }
svg .lamina { transition: transform .15s ease-out; }
body.en-run svg .cuerpo:not(.on) .lamina { transform: rotate(-28deg); }
svg .puente { display: none; }
svg .cuerpo.on .puente { display: inline; stroke: var(--on); stroke-width: 4; }
.foco circle { fill: #fff; stroke: var(--tinta); stroke-width: 2; }
.foco line { stroke: var(--tinta); stroke-width: 2; }
.foco.on { filter: drop-shadow(0 0 7px #ffc400); }
.foco.on circle { fill: #ffd23f; stroke: #a87a00; }
.foco.on line { stroke: #a87a00; }
.focos { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; padding: 6px 0 10px; }
.foco-tarjeta { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; }
body.en-run svg.red g { cursor: default !important; }
body.en-run svg.red g.accionable { cursor: pointer !important; touch-action: none; }
body.en-run svg g:not(.accionable):hover > .zona { fill: transparent; }
svg .cajat { font: 700 13px var(--mono); text-anchor: middle; fill: var(--tinta); }
svg .dir { font: 12px var(--mono); text-anchor: middle; fill: var(--tinta); }
svg .dir.falta { fill: var(--err); font-weight: 700; }
svg .simb { font: 600 11px "Segoe UI", sans-serif; text-anchor: middle; fill: var(--acento); }
svg .pin { font: 11.5px var(--mono); fill: var(--tinta); }
svg .pin.fin { text-anchor: end; }
svg .zona { fill: transparent; stroke: transparent; }
svg g:hover > .zona { fill: var(--acento-sua); }
svg .zona.sel { fill: #bfe2ec; stroke: var(--acento); stroke-width: 1.5; }
svg .hueco { fill: #fff; stroke: #93a3ad; stroke-dasharray: 4 3; }
svg .huecot { font: 11px "Segoe UI", sans-serif; text-anchor: middle; fill: var(--suave); }

.fila-es { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.led { width: 13px; height: 13px; border-radius: 50%; background: #c1ccd2; border: 1px solid #8798a2; flex: none; }
.led.on { background: #1fbf5b; border-color: var(--on); box-shadow: 0 0 5px #1fbf5b; }
.fila-es .nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-es .ad { font-family: var(--mono); font-size: 12.5px; color: var(--suave); width: 42px; flex: none; }
.pulsador { width: 90px; flex: none; padding: 4px; font-size: 12px; touch-action: none; user-select: none; }
.pulsador.pres { background: var(--acento); border-color: var(--acento); color: #fff; }
.vacio { color: var(--suave); }
.tabla-s { width: 100%; border-collapse: collapse; }
.tabla-s th { font-size: 12px; text-align: left; color: var(--suave); padding: 2px; }
.tabla-s td { padding: 2px; }
.tabla-s input, .tabla-s select { width: 100%; font-size: 13px; padding: 3px 4px; }
.tabla-s .ad { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.tabla-s button { padding: 1px 6px; }
.alta-s { display: flex; gap: 6px; margin-top: 8px; }
.alta-s input { width: 90px; font-family: var(--mono); }
.diag { display: block; width: 100%; text-align: left; border: 0; border-left: 4px solid; border-radius: 3px; padding: 7px 9px; margin-bottom: 6px; }
.diag small { display: block; font-weight: 600; margin-bottom: 2px; }
.diag.error { background: var(--err-sua); border-color: var(--err); }
.diag.aviso { background: var(--avi-sua); border-color: var(--avi); }
.diag.info { background: var(--inf-sua); border-color: var(--inf); }
.bien { color: var(--on); font-weight: 600; }

.cinta { padding: 10px 14px; background: #fff8e6; border-bottom: 1px solid #e6d6a8; }
.cinta h2 { font-size: 15px; margin: 0 0 3px; }
.cinta p { margin: 0 0 7px; max-width: 900px; }
.cinta .acc { display: flex; flex-wrap: wrap; gap: 6px; }
.resultado { margin-top: 8px; padding: 8px 11px; border-radius: 4px; background: var(--err-sua); max-width: 900px; }
.resultado.ok { background: var(--on-sua); }
.resultado ol { margin: 4px 0 0; padding-left: 20px; }
.tarjetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); gap: 10px; }
.tarjeta { background: var(--papel); border: 1px solid var(--borde); border-radius: 5px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.tarjeta h3 { margin: 0; font-size: 15px; }
.tarjeta p { margin: 0; color: var(--suave); flex: 1; font-size: 13px; }
.tarjeta .meta { font-size: 12px; color: var(--acento); font-weight: 600; }
.tarjeta .hecho { color: var(--on); }
.tarjeta .acc { display: flex; gap: 6px; margin-top: 4px; }
.vacio-caja { padding: 18px; border: 1px dashed var(--borde); border-radius: 5px; background: var(--papel); }
.proyecto-acc { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

.aviso { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--cabecera); color: #fff; padding: 9px 16px; border-radius: 5px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
.aviso.ver { opacity: 1; }
body.en-run .paleta button, body.en-run .seg-cab button, body.en-run .agregar { opacity: .45; }
body.en-run .accionable, .pulsador { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
@media (max-width: 860px) {
  body { height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }
  .barra-sup { display: grid; grid-template-columns: auto 1fr; gap: 6px 8px; padding: calc(6px + env(safe-area-inset-top)) 10px 6px; }
  .marca img { height: 38px; }
  .plc { grid-column: 2; grid-row: 1; justify-self: end; gap: 5px; }
  .plc button { min-height: 38px; padding: 5px 8px; }
  .barra-sup nav { grid-column: 1 / -1; grid-row: 2; }
  .barra-sup nav button { flex: 1; min-height: 40px; }
  #v-prog.activa { display: block; overflow-y: auto; }
  .paleta { flex-wrap: nowrap; overflow-x: auto; }
  .paleta button { flex: none; min-height: 40px; }
  .trabajo { display: block; }
  .programa { overflow: visible; padding: 8px; }
  .lateral { border-left: 0; border-top: 1px solid var(--borde); }
  .panel { overflow: visible; }
  .pestanas button { min-height: 44px; }
  svg.red { width: max(100%, calc(var(--ancho) * .72px)); height: auto; }
  input, select, textarea { font-size: 16px; }
  .pulsador { width: 104px; min-height: 44px; }
  .seg-cab button { min-height: 34px; }
  .documento { padding: 14px; }
}
