/* Taller EbroBot — espacio de trabajo: montaje a la izquierda, aparato en el centro, ficha a la derecha. */
:root {
  --fondo: #f4f3ef;
  --superficie: #ffffff;
  --superficie-2: #f8f7f4;
  --linea: #e6e3dc;
  --linea-fuerte: #d6d2c8;
  --tinta: #1a2232;
  --suave: #6b7280;
  --tenue: #9aa1ad;
  --acento: #c7621f;
  --acento-suave: #fbeee3;
  --ok: #2f7d55;
  --mal: #b4352c;
  --aviso: #a66a12;
  --cuerpo: #24345e;
  --ojos: #f2a65a;
  --sombra: 0 1px 2px rgb(26 34 50 / .05);
  --nevera-1: #f1f2f4; --nevera-2: #d9dde2; --nevera-texto: #6b7280;
  --radio: 10px;
  /* compatibilidad con estilos antiguos */
  --panel: var(--superficie); --borde: var(--linea); --fondo-2: var(--superficie-2);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fondo: #0d1220; --superficie: #141a29; --superficie-2: #10162a; --linea: #222a3c; --linea-fuerte: #2e374c;
    --tinta: #e8ebf2; --suave: #9aa3b5; --tenue: #6c7588; --acento: #f0a35e; --acento-suave: #2a2118;
    --ok: #62c793; --mal: #f07a70; --aviso: #e2b25a; --cuerpo: #3a4d80; --sombra: none;
    --nevera-1: #252c3c; --nevera-2: #1a2030; --nevera-texto: #8b94a7;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fondo: #0d1220; --superficie: #141a29; --superficie-2: #10162a; --linea: #222a3c; --linea-fuerte: #2e374c;
  --tinta: #e8ebf2; --suave: #9aa3b5; --tenue: #6c7588; --acento: #f0a35e; --acento-suave: #2a2118;
  --ok: #62c793; --mal: #f07a70; --aviso: #e2b25a; --cuerpo: #3a4d80; --sombra: none;
    --nevera-1: #252c3c; --nevera-2: #1a2030; --nevera-texto: #8b94a7;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--fondo); color: var(--tinta); font: 13.5px/1.45 "Nunito Sans", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
.oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.titulo-seccion { font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--tenue); margin: 0 0 10px; }
.nota { color: var(--suave); font-size: 12px; }
.nota.fijo { margin: -4px 0 8px; }
.fila-aviso { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; border-radius: 6px; }

/* ---------- barra superior */
.barra { height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; background: var(--superficie); border-bottom: 1px solid var(--linea); position: sticky; top: 0; z-index: 20; }
.marca { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo-bot { width: 24px; height: 24px; color: var(--cuerpo); flex: none; }
.logo { font: 600 16px "Fredoka", sans-serif; white-space: nowrap; }
.separador { width: 1px; height: 18px; background: var(--linea-fuerte); }
.sub { color: var(--suave); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra-der { display: flex; align-items: center; gap: 6px; }
.estado-firmware { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--suave); white-space: nowrap; }
.estado-firmware::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tenue); }
.estado-firmware.ok::before { background: var(--ok); }
.estado-firmware.mal { color: var(--mal); }
.estado-firmware.mal::before { background: var(--mal); }

/* ---------- espacio de trabajo */
.espacio { display: grid; grid-template-columns: 300px minmax(0, 1fr) 280px; min-height: calc(100vh - 48px); }
.lateral { background: var(--superficie); padding: 16px; overflow-y: auto; position: sticky; top: 48px; height: calc(100vh - 48px); }
.lateral.izquierda { border-right: 1px solid var(--linea); }
.lateral.derecha { border-left: 1px solid var(--linea); }
.lateral section + section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--linea); }
.centro { padding: 16px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ---------- montaje: ranuras y opciones */
.ranuras { display: flex; flex-direction: column; gap: 2px; }
.ranuras > button { display: flex; flex-direction: column; text-align: left; padding: 8px 10px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; position: relative; }
.ranuras > button:hover { background: var(--superficie-2); }
.ranuras > button small { font-size: 11px; color: var(--tenue); font-weight: 700; }
.ranuras > button b { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 14px; }
.ranuras > button::after { content: "›"; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--tenue); transition: transform .15s; }
.ranuras > button[aria-selected="true"] { background: var(--superficie-2); }
.ranuras > button[aria-selected="true"]::after { transform: translateY(-50%) rotate(90deg); color: var(--acento); }
.carril { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 8px 8px; padding-left: 8px; border-left: 1px solid var(--linea); }
.grupo-carril { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--tenue); padding: 8px 8px 2px; }
.tarjeta { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 10px; align-items: center; text-align: left; padding: 6px 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; cursor: pointer; }
.tarjeta:hover { background: var(--superficie-2); }
.tarjeta[aria-checked="true"] { border-color: var(--linea-fuerte); background: var(--superficie-2); box-shadow: inset 2px 0 0 var(--acento); }
.tarjeta:disabled { opacity: .35; cursor: not-allowed; }
.tarjeta-img { width: 56px; height: 40px; display: grid; place-items: center; }
.tarjeta-img svg { max-width: 56px; max-height: 40px; width: auto; height: auto; }
.tarjeta b { display: block; font-size: 13px; font-weight: 700; line-height: 1.25; }
.tarjeta .etiquetas { display: block; font-size: 11.5px; color: var(--suave); line-height: 1.35; margin-top: 1px; }
.tarjeta .etiquetas span + span::before { content: " · "; color: var(--tenue); }
.tarjeta .etiquetas span.mal { color: var(--mal); }
.tarjeta .etiquetas span.bien { color: var(--ok); }
.tarjeta .precio { font-size: 12.5px; color: var(--suave); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- controles */
.segmento { display: inline-flex; background: var(--superficie-2); border: 1px solid var(--linea); border-radius: 8px; padding: 2px; gap: 2px; }
.lateral .segmento { display: flex; margin-bottom: 10px; }
.segmento button { flex: 1; font-size: 12.5px; font-weight: 700; padding: 5px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--suave); cursor: pointer; white-space: nowrap; }
.segmento button.activo { background: var(--superficie); color: var(--tinta); box-shadow: 0 1px 2px rgb(0 0 0 / .1); }
.pestanas { display: flex; gap: 2px; }
.pestanas button { font-size: 13px; font-weight: 700; padding: 6px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--suave); cursor: pointer; position: relative; }
.pestanas button:hover { color: var(--tinta); }
.pestanas button[aria-selected="true"] { color: var(--tinta); }
.pestanas button[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -9px; height: 2px; border-radius: 2px; background: var(--acento); }
.boton { font-size: 12.5px; font-weight: 700; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--linea-fuerte); background: var(--superficie); cursor: pointer; white-space: nowrap; }
.boton:hover { border-color: var(--tenue); }
.boton.fantasma { border-color: transparent; background: transparent; color: var(--suave); }
.boton.fantasma:hover { background: var(--superficie-2); color: var(--tinta); }
.icono { width: 30px; height: 30px; display: inline-grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--suave); cursor: pointer; font-size: 14px; flex: none; }
.icono:hover { background: var(--superficie-2); color: var(--tinta); }
.interruptor { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; cursor: pointer; font-size: 13px; }
.interruptor input { appearance: none; width: 28px; height: 16px; border-radius: 99px; background: var(--linea-fuerte); position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
.interruptor input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgb(0 0 0 / .2); }
.interruptor input:checked { background: var(--acento); }
.interruptor input:checked::after { transform: translateX(12px); }
.interruptor.compacto { padding: 0; font-size: 12.5px; color: var(--suave); }
.campo { display: grid; grid-template-columns: 1fr 64px; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
select, input[type="number"], input[type="date"] { padding: 5px 8px; border-radius: 7px; border: 1px solid var(--linea); background: var(--superficie-2); min-width: 0; width: 100%; font-size: 12.5px; }
input[type="range"] { accent-color: var(--acento); width: 100%; margin: 0; }
.deslizador { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--suave); }
.deslizador b { font-weight: 700; color: var(--tinta); font-variant-numeric: tabular-nums; min-width: 38px; }
.deslizador.crece { flex: 1; }
.deslizador.bateria input { width: 90px; }
.deslizador svg { width: 16px; height: 16px; flex: none; color: var(--tenue); }
.divisor { width: 1px; height: 20px; background: var(--linea); flex: none; }

/* ---------- escenario */
.escenario { background: var(--superficie); border: 1px solid var(--linea); border-radius: var(--radio); box-shadow: var(--sombra); display: flex; flex-direction: column; }
.escenario-cabecera { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--linea); }
.lienzo { position: relative; flex: 1; min-height: 460px; background: var(--superficie-2); }
.escena { display: flex; justify-content: center; align-items: center; min-height: 460px; height: 100%; overflow: auto; padding: 24px; }
.escena svg { max-width: 100%; height: auto; max-height: 520px; }
.escena.real svg { max-width: none; max-height: none; }
.escena canvas.pixeles { image-rendering: pixelated; box-shadow: 0 0 0 1px var(--linea); max-width: 100%; }
.escena3d { width: 100%; min-height: 460px; }
.escena3d canvas { display: block; touch-action: none; }
.flotante { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 8px; background: color-mix(in srgb, var(--superficie) 88%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--linea); border-radius: 10px; box-shadow: 0 4px 16px rgb(0 0 0 / .06); }
.flotante .deslizador input { width: 110px; }
.linea-tiempo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border-top: 1px solid var(--linea); }
.linea-tiempo input[type="date"] { width: 138px; }

/* ---------- panel inferior */
.inferior { background: var(--superficie); border: 1px solid var(--linea); border-radius: var(--radio); box-shadow: var(--sombra); }
.inferior-cabecera { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--linea); }
.inferior-cabecera .acciones { display: flex; align-items: center; gap: 6px; }
.inferior [data-panel] { padding: 4px 16px 14px; }

/* ---------- ficha */
.cifras { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--linea); border: 1px solid var(--linea); border-radius: 10px; overflow: hidden; margin-bottom: 14px; }
.cifra { background: var(--superficie); padding: 10px 12px; }
.cifra.principal, .cifra.ancha { grid-column: 1 / -1; }
.cifra span { display: block; font: 600 20px "Fredoka", sans-serif; font-variant-numeric: tabular-nums; line-height: 1.15; }
.cifra.principal span { font-size: 34px; color: var(--acento); }
.cifra small { color: var(--suave); font-size: 11.5px; }
.datos { margin: 0 0 18px; }
.datos div { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--linea); font-size: 12.5px; }
.datos div:last-child { border-bottom: 0; }
.datos dt { color: var(--suave); }
.datos dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.avisos { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.avisos li { font-size: 12.5px; line-height: 1.4; padding: 7px 9px 7px 22px; border-radius: 8px; background: var(--superficie-2); color: var(--suave); position: relative; }
.avisos li::before { content: ""; position: absolute; left: 9px; top: 12px; width: 6px; height: 6px; border-radius: 50%; background: var(--tenue); }
.avisos li.grave { color: var(--tinta); background: color-mix(in srgb, var(--mal) 8%, var(--superficie)); }
.avisos li.grave::before { background: var(--mal); }
details { margin-top: 6px; font-size: 12.5px; border-top: 1px solid var(--linea); padding-top: 8px; }
summary { cursor: pointer; font-weight: 700; color: var(--suave); list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "›"; display: inline-block; width: 12px; transition: transform .15s; }
details[open] summary::before { transform: rotate(90deg); }
.lista-suave { margin: 8px 0 4px; padding-left: 16px; color: var(--suave); }
.lista-suave li { margin-bottom: 4px; }
.codigo { background: var(--superficie-2); border-radius: 8px; padding: 8px; font: 11px/1.4 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-all; max-height: 200px; overflow: auto; margin: 8px 0 0; }
.codigo.error { color: var(--mal); }

/* ---------- componentes */
.grupo-bom { margin-top: 12px; }
.grupo-bom-cab { display: flex; justify-content: space-between; font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--tenue); padding: 4px 0; }
.item-bom { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 7px 0; border-top: 1px solid var(--linea); }
.item-bom.sub { padding-left: 18px; grid-template-columns: 26px minmax(0, 1fr) auto; }
.item-bom .icono-bom { display: grid; place-items: center; height: 34px; }
.item-bom .icono-bom svg { max-width: 34px; max-height: 30px; width: auto; height: auto; }
.item-bom.sub .icono-bom svg { max-width: 24px; }
.item-bom b { font-size: 13px; font-weight: 700; }
.item-bom .ref { color: var(--tenue); font-size: 11.5px; margin-left: 6px; }
.item-bom .fun { font-size: 12px; color: var(--suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-bom .fun a { color: var(--suave); }
.item-bom .imp { text-align: right; font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-bom .imp small { display: block; font-weight: 400; color: var(--tenue); font-size: 11px; }
.item-bom.falta b { color: var(--mal); }
.total-bom { display: flex; justify-content: space-between; align-items: baseline; padding-top: 12px; margin-top: 8px; border-top: 1px solid var(--linea-fuerte); font-weight: 700; }
.total-bom span { font: 600 20px "Fredoka", sans-serif; color: var(--acento); }

/* ---------- comparador */
.tabla-scroll { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tabla th { text-align: left; color: var(--tenue); font-weight: 700; font-size: 11.5px; padding: 8px; border-bottom: 1px solid var(--linea); cursor: pointer; white-space: nowrap; }
.tabla td { padding: 7px 8px; border-bottom: 1px solid var(--linea); }
.tabla tr.fila-dato { cursor: pointer; }
.tabla tr.fila-dato:hover td { background: var(--superficie-2); }
.tabla tr.elegida td { background: var(--acento-suave); }
.tabla .num { text-align: right; }
.vacio { color: var(--suave); padding: 14px 0; }

/* ---------- diagrama de conexiones */
.diagrama-caja { overflow: auto; max-height: 72vh; cursor: grab; background: var(--superficie-2); padding-bottom: 56px; }
.diagrama-caja:fullscreen { max-height: none; }
.diagrama-caja.ampliado .diagrama { max-width: none; }
.pines-plegable { margin: 0; padding: 8px 14px 14px; border-top: 1px solid var(--linea); background: var(--superficie); }
.diagrama { display: block; width: 100%; height: auto; font-family: "Nunito Sans", sans-serif; }
.diagrama .et { font-size: 13px; fill: var(--tinta); }
.diagrama .et.mini { font-size: 11.5px; }
.diagrama .et.grande { font: 600 18px "Fredoka", sans-serif; fill: var(--suave); }
.diagrama .et.fuerte { font-weight: 800; }
.diagrama .et.tenue { fill: var(--tenue); }
.diagrama .et.centro { text-anchor: middle; }
.diagrama .et.derecha { text-anchor: end; }
.diagrama .et.error { fill: var(--mal); font-weight: 800; }
.diagrama .hilo { fill: none; stroke-width: 3.2; stroke-linecap: round; }
.diagrama .hilo-funda { fill: none; stroke: #000; stroke-opacity: .2; stroke-width: 5.5; stroke-linecap: round; }
.diagrama .hilo.rojo { stroke: #c8322b; }
.diagrama .hilo.negro { stroke: #2a2d33; }
.diagrama .hilo.azul { stroke: #2b5aa8; }
.diagrama .hilo.verde { stroke: #2e7d4f; }
.diagrama .hilo.falta { stroke: var(--mal); stroke-dasharray: 6 6; }
.diagrama .senal { fill: none; stroke: #e8a456; stroke-width: 1.6; stroke-dasharray: 4 5; opacity: .75; }
.diagrama .cinta { fill: none; stroke: #c98a2b; stroke-width: 22; stroke-linecap: butt; opacity: .95; }
.diagrama .cinta-trazas { fill: none; stroke: #f0c77a; stroke-width: 16; stroke-dasharray: 1 2.2; opacity: .5; }
.diagrama .ondas path { fill: none; stroke: var(--acento); stroke-width: 2.5; stroke-linecap: round; opacity: 0; }
.diagrama.estado-reposo .pieza-placa { filter: saturate(.8) brightness(.95); }
.diagrama.estado-wifi .ondas path { animation: onda 1.2s ease-out infinite; }
.diagrama.estado-wifi .ondas path:nth-child(2) { animation-delay: .4s; }
.diagrama.estado-refresco .senal { animation: datos .6s linear infinite; stroke: #f5bf5f; opacity: 1; }
.diagrama.estado-refresco .cinta-trazas { animation: datos .6s linear infinite; opacity: .85; }
.diagrama.estado-refresco .tinta-activa { animation: tinta 1.1s steps(2) infinite; }
@keyframes onda { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }
@keyframes datos { to { stroke-dashoffset: -18; } }
@keyframes tinta { 50% { opacity: .15; } }
@media (prefers-reduced-motion: reduce) { .diagrama * { animation: none !important; } }
.pines { margin-top: 8px; width: 100%; border-collapse: collapse; font-size: 12.5px; }
.pines th { text-align: left; color: var(--tenue); font-weight: 700; padding: 4px 8px 4px 0; }
.pines td { padding: 4px 8px 4px 0; border-top: 1px solid var(--linea); }
.pines tr.mal td { color: var(--mal); font-weight: 700; }
.tabla-mini { width: 100%; border-collapse: collapse; }

.aviso-flotante { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(16px); background: var(--tinta); color: var(--superficie); padding: 8px 14px; border-radius: 10px; font-size: 12.5px; font-weight: 700; opacity: 0; pointer-events: none; transition: .2s; z-index: 30; }
.aviso-flotante.ver { opacity: 1; transform: translateX(-50%); }

/* ---------- pantallas más estrechas */
@media (max-width: 1280px) {
  .espacio { grid-template-columns: 260px minmax(0, 1fr); }
  .lateral.derecha { grid-column: 1 / -1; position: static; height: auto; border-left: 0; border-top: 1px solid var(--linea); display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 24px; }
}
@media (max-width: 860px) {
  .espacio { grid-template-columns: 1fr; }
  .lateral { position: static; height: auto; border: 0 !important; border-bottom: 1px solid var(--linea) !important; }
  .centro { padding: 12px 16px; }
  .sub, .separador { display: none; }
  .lienzo, .escena, .escena3d { min-height: 320px; }
  .campo { grid-template-columns: 1fr 1fr; }
}

/* Nombres de las piezas en el 3D */
#escena3d { position: relative; }
.rotulos3d { position: absolute; inset: 0; pointer-events: none; }
.rotulos3d:not(.detalle) .etiqueta3d.de-placa, .rotulos3d.detalle .etiqueta3d:not(.de-placa) { display: none; }
.etiqueta3d { position: relative; width: 0; height: 0; }
.etiqueta3d i { position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--tinta); background: var(--superficie); box-sizing: border-box; }
.etiqueta3d span { position: absolute; font: 600 11px "Nunito Sans", sans-serif; color: var(--tinta); background: var(--superficie); border: 1px solid var(--linea-fuerte);
  border-radius: 6px; padding: 2px 7px; white-space: nowrap; box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.etiqueta3d span::before { content: ""; position: absolute; width: 22px; border-top: 1px solid var(--tinta); opacity: .6; top: 50%; }
.etiqueta3d.der span { left: 26px; } .etiqueta3d.der span::before { right: 100%; }
.etiqueta3d.izq span { right: 26px; } .etiqueta3d.izq span::before { left: 100%; }
.etiqueta3d.arr span { bottom: 6px; } .etiqueta3d.aba span { top: 6px; }
.etiqueta3d.sonido i { border-color: var(--acento); background: var(--acento); }
.etiqueta3d.sonido span { border-color: var(--acento); color: var(--acento); }
