/* Paleta United: blanco + rojo corporativo RGB(192,0,0) = #C00000 */
:root { --rojo: #c00000; --rojo-osc: #9e0000; --gris: #4a4a4a; --gris-cl: #6b6b6b; }
* { box-sizing: border-box; margin: 0; }
body { font-family: "Segoe UI", Arial, sans-serif; background: #f6f6f7; color: #1e2a35; }

header { background: #fff; color: var(--gris); padding: 12px 24px; display: flex; flex-wrap: wrap;
  align-items: center; gap: 18px; border-bottom: 3px solid var(--rojo); box-shadow: 0 1px 6px rgba(0,0,0,.08); }
.brand { display: flex; align-items: center; gap: 14px; }
.logo { height: 40px; width: auto; display: block; }
header h1 { font-size: 19px; color: var(--gris); font-weight: 700; }
header h1 span { font-weight: 400; font-size: 13px; color: var(--rojo); margin-left: 8px; }
nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tab { background: #fff; color: var(--rojo); border: 1px solid #e2b3b3; padding: 7px 16px; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600; }
.tab:hover { border-color: var(--rojo); }
.tab.activa { background: var(--rojo); color: #fff; border-color: var(--rojo); }
.btn-export { color: #fff; background: var(--gris); padding: 7px 14px; border-radius: 6px; text-decoration: none; font-size: 13px; border: 0; cursor: pointer; }
.btn-export:hover { background: var(--gris-cl); }

.panel { display: none; padding: 20px 24px; max-width: 1400px; margin: 0 auto; }
.panel.visible { display: block; }

.filtros { margin-bottom: 14px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.filtros select, .filtros input { padding: 6px 10px; border: 1px solid #d3b3b3; border-radius: 6px; font-size: 14px; }
.leyenda { font-size: 12px; color: var(--gris-cl); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 16px; }
.card { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.08); border-left: 4px solid var(--rojo); }
.card .num { font-size: 30px; font-weight: 700; color: var(--rojo); }
.card .lbl { font-size: 13px; color: var(--gris-cl); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 950px) { .grid2 { grid-template-columns: 1fr; } }
.tarjeta { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.08); overflow: auto; }
.tarjeta h3 { font-size: 15px; margin-bottom: 10px; color: var(--rojo); }

table.mini { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.mini th { background: #f7ecec; color: var(--gris); text-align: left; padding: 6px 8px; position: sticky; top: 0; }
table.mini td { padding: 5px 8px; border-bottom: 1px solid #f0e6e6; }
table.mini tr:hover td { background: #fdf5f5; }

/* mapa de vasijas */
#mapa { display: grid; gap: 3px; font-size: 10.5px; }
.vasija { border-radius: 4px; text-align: center; padding: 5px 0; cursor: pointer; background: #eee; color: #8a8a8a; border: 1px solid #ddd; }
.vasija.n1 { background: #ffe082; color: #6d5200; border-color: #f4d564; }
.vasija.n2 { background: #ffb74d; color: #5c3a00; border-color: #f2a53a; }
.vasija.n3 { background: #ef5350; color: #fff; border-color: #d84341; }
.vasija:hover { outline: 2px solid var(--rojo); }
.fila-label { font-weight: 700; color: var(--gris-cl); align-self: center; text-align: center; }

/* zona de carga */
#dropzone { border: 2px dashed #d59a9a; border-radius: 12px; padding: 44px; text-align: center; color: var(--rojo); font-size: 17px; cursor: pointer; background: #fdf6f6; margin-bottom: 16px; }
#dropzone.over { background: #fbeaea; border-color: var(--rojo); }
.ayuda { font-size: 13px; color: var(--gris-cl); margin-bottom: 12px; }

.prev-informe { border: 1px solid #e6d2d2; border-radius: 10px; margin-bottom: 18px; padding: 14px; }
.prev-informe h4 { color: var(--rojo); margin-bottom: 6px; }
.prev-meta { font-size: 12.5px; color: var(--gris-cl); margin-bottom: 8px; display: flex; gap: 14px; flex-wrap: wrap; }
.prev-meta input { border: 1px solid #d6bcbc; border-radius: 4px; padding: 3px 6px; font-size: 12.5px; }
.aviso-dup { background: #fff3e0; color: #8a5300; padding: 6px 10px; border-radius: 6px; font-size: 12.5px; margin-bottom: 8px; }
.error { background: #fdecea; color: #b3261e; padding: 8px 12px; border-radius: 6px; margin-bottom: 10px; }
table.edit { width: 100%; border-collapse: collapse; font-size: 12px; }
table.edit th { background: #f7ecec; padding: 4px 6px; text-align: left; }
table.edit td { padding: 2px 4px; border-bottom: 1px solid #f0e6e6; }
table.edit input, table.edit select { width: 100%; border: 1px solid #dcc4c4; border-radius: 4px; padding: 3px 5px; font-size: 12px; }
.btn { background: var(--rojo); color: #fff; border: 0; border-radius: 6px; padding: 8px 18px; font-size: 14px; cursor: pointer; margin-top: 10px; }
.btn:hover { background: var(--rojo-osc); }
.btn.rojo { background: var(--rojo); padding: 4px 10px; font-size: 12px; margin: 0; }
.btn.gris { background: var(--gris); }
.btn:disabled { opacity: .5; cursor: default; }
.ok-msg { color: #2e7d32; font-weight: 600; margin-left: 12px; }
canvas { max-height: 320px; }

/* mapa EWS según diagrama de planta (semi racks A/B, columnas y tuberías) */
.mapa-ews { overflow-x: auto; padding: 4px 0; }
.ews-headers { display: flex; margin-bottom: 8px; font-weight: 700; color: var(--rojo); font-size: 13px; }
.ews-headers span:first-child { flex: 0 0 auto; width: 258px; text-align: center; }
.ews-headers span:last-child { flex: 0 0 auto; width: 258px; text-align: center; margin-left: 44px; }
.fila-ews { display: flex; align-items: center; margin: 2px 0; width: max-content; }
.fila-ews.salto { margin-top: 12px; }
.fila-ews .grupo { display: flex; align-items: center; }
.vasija-c { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #26a69a;
  background: #f2faf9; color: #33505c; font-size: 8.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex: 0 0 auto; }
.vasija-c:hover { outline: 2px solid var(--rojo); }
.vasija-c.n1 { background: #ffe082; border-color: #e6c34d; color: #6d5200; }
.vasija-c.n2 { background: #ffb74d; border-color: #f2a53a; color: #5c3a00; }
.vasija-c.n3 { background: #ef5350; border-color: #d84341; color: #fff; }
.vasija-hueco { width: 26px; height: 26px; flex: 0 0 auto; visibility: hidden; }
/* unión = piezas independientes: tramos de tubería (azul) + coplas (amarillas) */
.union { display: flex; align-items: center; flex: 0 0 auto; }
.union.invisible { visibility: hidden; }
.tramo { width: 6px; height: 5px; background: #29b6f6; flex: 0 0 auto; }
.tramo.g { width: 7px; height: 6px; }
.copla { width: 5px; height: 12px; background: #f4c542; border: 1px solid #d9a821; border-radius: 2.5px; flex: 0 0 auto; }
.copla.g { height: 13px; }
.poste-ews { width: 12px; align-self: stretch; margin: -2px 3px; background: #b6bdc4;
  border-left: 1px solid #9aa2a9; border-right: 1px solid #9aa2a9; flex: 0 0 auto; }
.pasillo-ews { width: 44px; flex: 0 0 auto; }
.base-ews { height: 12px; background: #b6bdc4; border-radius: 6px; margin-top: 6px; width: 560px; }

/* piezas interactivas con intensidad propia */
.tramo[data-v1], .copla[data-v1] { cursor: pointer; }
.tramo[data-v1]:hover, .copla[data-v1]:hover { outline: 2px solid var(--rojo); outline-offset: 1px; }
.tramo.n1 { background: #ffca28; }
.tramo.n2 { background: #fb8c00; }
.tramo.n3 { background: #e53935; }
.copla.n1 { background: #ffca28; border-color: #c98f00; }
.copla.n2 { background: #fb8c00; border-color: #b34d00; }
.copla.n3 { background: #e53935; border-color: #8e1c1c; }

/* mapa Planta Cero según diagrama (semi rack B izq / A der, celdas rectangulares, tuberías colectoras) */
.mapa-pc { overflow-x: auto; padding: 4px 0; font-size: 9.5px; }
.pc-headers { display: flex; gap: 40px; margin-bottom: 12px; }
.pc-headers span { flex: 0 0 auto; width: 306px; text-align: center; font-weight: 700; color: var(--rojo);
  font-size: 13px; border: 1.5px solid #444; padding: 5px 0; background: #fff; }
.fila-pc { display: flex; align-items: center; width: max-content; margin: 1px 0; }
.fila-pc .grupo { display: flex; align-items: center; }
.celda-pc { width: 30px; height: 22px; border: 1px solid #556; margin-left: -1px; background: #fff;
  color: #1e2a35; font-weight: 700; display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex: 0 0 auto; }
.celda-pc:hover { outline: 2px solid var(--rojo); z-index: 1; }
.celda-pc.hueco { visibility: hidden; cursor: default; }
.celda-pc.n1 { background: #ffe082; }
.celda-pc.n2 { background: #ffb74d; }
.celda-pc.n3 { background: #ef5350; color: #fff; }
.poste-pc { width: 16px; align-self: stretch; margin: -8px 2px; flex: 0 0 auto; z-index: 2;
  background: linear-gradient(90deg, #8d949b, #cdd2d7 45%, #848b92); border-radius: 8px / 3px; }
.pasillo-pc { width: 40px; flex: 0 0 auto; }
.tuberia-fila { margin: 5px 0; }
.tuberia-pc { width: 306px; height: 14px; border-radius: 7px; flex: 0 0 auto;
  background: linear-gradient(180deg, #aab1b8, #dde1e5 45%, #8d949b); }
.sep-pc { height: 16px; }

/* =========================================================
   RESPONSIVE — adaptación a desktop, laptop, tablet y móvil
   ========================================================= */
/* red de seguridad: nada empuja scroll horizontal en la página;
   el contenido ancho (tablas, mapas) scrollea DENTRO de su tarjeta */
html, body { max-width: 100%; overflow-x: hidden; }
.tarjeta { overflow-x: auto; -webkit-overflow-scrolling: touch; }
img { max-width: 100%; height: auto; }

/* --- Tablet (horizontal y vertical) --- */
@media (max-width: 900px) {
  header { padding: 12px 16px; gap: 12px; }
  header h1 { font-size: 18px; flex: 1 1 100%; }
  nav { flex: 1 1 100%; }
  .panel { padding: 16px 14px; }
  .filtros { gap: 12px; }
}

/* --- Móvil (iPhone / Android) --- */
@media (max-width: 640px) {
  header { padding: 10px 12px; gap: 8px; }
  header h1 { font-size: 16px; line-height: 1.25; }
  header h1 span { display: block; margin: 3px 0 0; font-size: 11px; }
  nav { gap: 6px; }
  .tab, .btn-export { flex: 1 1 auto; min-width: 0; text-align: center; min-height: 42px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 10px; font-size: 13px; }

  .panel { padding: 12px 10px; }

  /* filtros en etiqueta+control apilados, controles cómodos para tocar */
  .filtros { gap: 10px; }
  .filtros label { flex: 1 1 46%; display: flex; flex-direction: column; gap: 3px;
    font-size: 12px; color: #445; }
  .filtros select, .filtros input { width: 100%; min-height: 42px;
    font-size: 16px; /* >=16px evita el auto-zoom de iOS al enfocar */ }
  .leyenda { flex: 1 1 100%; }

  /* indicadores 2 por fila */
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
  .card { padding: 12px; }
  .card .num { font-size: 24px; }
  .card .lbl { font-size: 12px; }

  .tarjeta { padding: 12px; }
  .tarjeta h3 { font-size: 14px; }
  canvas { max-height: 260px; }

  /* tablas: legibles con scroll horizontal dentro de su tarjeta */
  table.mini { min-width: 520px; font-size: 12px; }

  /* carga de informes */
  #dropzone { padding: 28px 14px; font-size: 15px; }
  .prev-informe { overflow-x: auto; }
  .prev-meta { gap: 8px; }
  .prev-meta span { flex: 1 1 100%; }
  .prev-meta input { width: 100%; box-sizing: border-box; }
  table.edit { min-width: 720px; }
  .btn { min-height: 42px; }

  /* login sin zoom en iOS */
  #l-email, #l-pass { font-size: 16px !important; min-height: 42px; }
}

/* --- Móvil pequeño --- */
@media (max-width: 380px) {
  header h1 { font-size: 15px; }
  .cards { grid-template-columns: 1fr; }
  .filtros label { flex: 1 1 100%; }
}

/* apartado de filtros cartucho/CIP */
.fl-grupo { margin-bottom: 16px; }
.fl-grupo h4 { font-size: 13px; color: var(--rojo); margin-bottom: 8px; border-bottom: 1px solid #e3eaf1; padding-bottom: 4px; }
.fl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.fl-grid.cip { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.filtro-box { position: relative; aspect-ratio: 1 / 1; border: 2px solid #26a69a; border-radius: 10px;
  background: #f2faf9; color: #33505c; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-weight: 700; font-size: 13px; transition: transform .1s; }
.fl-grid.cip .filtro-box { aspect-ratio: 2.4 / 1; border-radius: 8px; }
.filtro-box:hover { transform: scale(1.06); outline: 2px solid var(--rojo); }
.filtro-box.n1 { background: #ffe082; border-color: #e6c34d; color: #6d5200; }
.filtro-box.n2 { background: #ffb74d; border-color: #f2a53a; color: #5c3a00; }
.filtro-box.n3 { background: #ef5350; border-color: #d84341; color: #fff; }
.fb-n { position: absolute; top: -6px; right: -6px; background: var(--rojo); color: #fff;
  font-size: 10px; min-width: 17px; height: 17px; border-radius: 9px; display: flex;
  align-items: center; justify-content: center; padding: 0 4px; }
@media (max-width: 640px) {
  .fl-grid { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
  .fl-grid.cip { grid-template-columns: 1fr 1fr; }
}
