/* TDS Drill · hoja de estilos
 *
 * Dos decisiones que mandan sobre lo demás:
 *  1. Se lee al sol. Fondo claro, texto casi negro, nada de gris sobre gris.
 *  2. Se toca con guantes sucios. Ningún control de menos de 48 px de alto.
 */

:root {
  /* Colores muestreados del logo de la empresa. */
  --naranja: #FBA832;
  --naranja-oscuro: #E19116;      /* solo para el estado :active */
  --naranja-texto: #9E6400;       /* naranja legible COMO TEXTO sobre fondo claro */
  --naranja-suave: #FEF3E0;
  --carbon: #363435;
  --carbon-2: #4C4849;
  --gris: #5C6470;
  --gris-claro: #E4E7EB;
  --fondo: #F4F5F7;
  --panel: #FFFFFF;
  --verde: #1B8A4B;
  --verde-suave: #E7F5ED;
  --rojo: #C62828;
  --rojo-suave: #FDEAEA;
  --ambar: #B26A00;
  --ambar-suave: #FFF5E0;
  --azul: #1F5FA8;

  --r: 12px;
  --sombra: 0 1px 2px rgba(22,24,28,.08), 0 4px 12px rgba(22,24,28,.06);
  --toque: 52px;
  --tope: env(safe-area-inset-top, 0px);
  --pie: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--fondo);
  color: var(--carbon);
  font: 400 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior-y: none;
}
body { padding-bottom: calc(76px + var(--pie)); }
body.admin { padding-bottom: 24px; }

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
a { color: var(--azul); }

/* ---------- cabecera ---------- */
.barra {
  position: sticky; top: 0; z-index: 40;
  background: var(--carbon); color: #fff;
  padding: calc(10px + var(--tope)) 14px 10px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.barra .marca { display: flex; align-items: baseline; gap: 1px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.barra .marca em { font-style: normal; color: var(--naranja); }
.barra h1 { font-size: 17px; font-weight: 600; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra .atras {
  background: rgba(255,255,255,.12); border: 0; color: #fff;
  width: 40px; height: 40px; border-radius: 10px; font-size: 22px; line-height: 1;
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.barra .atras:active { background: rgba(255,255,255,.24); }

/* ---------- estado de sincronización ---------- */
.sync {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; font-size: 13.5px; font-weight: 600;
  background: var(--verde-suave); color: var(--verde);
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.sync.offline { background: var(--ambar-suave); color: var(--ambar); }
.sync.error   { background: var(--rojo-suave);  color: var(--rojo); }
.sync .punto { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.sync.offline .punto { animation: latir 1.6s infinite; }
@keyframes latir { 50% { opacity: .25; } }
.sync button {
  margin-left: auto; background: rgba(0,0,0,.07); border: 0; color: inherit;
  font-family: inherit; font-size: 13px; padding: 6px 12px; border-radius: 8px; cursor: pointer;
}

/* ---------- contenedores ---------- */
.envoltura { max-width: 900px; margin: 0 auto; padding: 14px; }
.admin .envoltura { max-width: 1240px; }

.tarjeta {
  background: var(--panel); border-radius: var(--r);
  box-shadow: var(--sombra); padding: 16px; margin-bottom: 12px;
}
.tarjeta.plana { box-shadow: none; border: 1px solid var(--gris-claro); }

.titulo-seccion {
  font-size: 12.5px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
  color: var(--gris); margin: 22px 2px 10px;
}
.titulo-seccion:first-child { margin-top: 6px; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--toque); padding: 0 20px;
  background: var(--naranja); color: var(--carbon); border: 0; border-radius: var(--r);
  font-family: inherit; font-size: 16.5px; font-weight: 600; line-height: 1;
  cursor: pointer; text-decoration: none;
  transition: background .12s, transform .06s;
}
.btn:active { background: var(--naranja-oscuro); transform: scale(.985); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.ancho { width: 100%; }
.btn.oscuro { background: var(--carbon); }
.btn.oscuro:active { background: var(--carbon-2); }
.btn.fantasma { background: transparent; color: var(--carbon); border: 1.5px solid var(--gris-claro); }
.btn.fantasma:active { background: var(--gris-claro); }
.btn.peligro { background: var(--rojo); }
.btn.chico { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 9px; }

/* ---------- formularios ---------- */
label.campo { display: block; margin-bottom: 14px; }
label.campo > span {
  display: block; font-size: 14.5px; font-weight: 600; margin-bottom: 6px; color: var(--carbon);
}
.ayuda { display: block; font-weight: 400; font-size: 13px; color: var(--gris); margin-top: 2px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%; min-height: var(--toque); padding: 12px 14px;
  border: 1.5px solid var(--gris-claro); border-radius: 10px;
  background: #fff; color: var(--carbon);
  font-family: inherit; font-size: 16.5px; font-weight: 400; line-height: 1.3;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 0; border-color: var(--naranja); box-shadow: 0 0 0 3px var(--naranja-suave);
}
.fila { display: flex; gap: 10px; }
.fila > * { flex: 1; min-width: 0; }
.requerido { color: var(--rojo); }

/* ---------- chulito grande ---------- */
.chulo {
  display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: 60px; padding: 10px 14px; margin-bottom: 8px;
  background: #fff; border: 1.5px solid var(--gris-claro); border-radius: var(--r);
  font-family: inherit; font-size: 16px; font-weight: 500; line-height: 1.3;
  text-align: left; color: var(--carbon); cursor: pointer;
}
.chulo .caja {
  width: 30px; height: 30px; flex: none; border-radius: 8px;
  border: 2px solid var(--gris-claro); display: grid; place-items: center;
  font-size: 19px; color: transparent; font-weight: 800;
}
.chulo.si { border-color: var(--verde); background: var(--verde-suave); }
.chulo.si .caja { background: var(--verde); border-color: var(--verde); color: #fff; }

/* ---------- condición: N/A · Cumple · Mejora ---------- */
.item-cond { padding: 12px 0; border-bottom: 1px solid var(--gris-claro); }
.item-cond:last-child { border-bottom: 0; }
.item-cond > .texto { font-weight: 600; font-size: 15.5px; margin-bottom: 8px; }
.cond { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cond button {
  min-height: 46px; border: 1.5px solid var(--gris-claro); background: #fff;
  border-radius: 10px; font-family: inherit; font-size: 14px; font-weight: 700;
  line-height: 1.15; color: var(--gris); cursor: pointer;
  display: grid; place-items: center; padding: 4px;
}
.cond button.sel[data-v="0"] { background: var(--gris-claro); border-color: var(--gris); color: var(--carbon); }
.cond button.sel[data-v="1"] { background: var(--verde-suave); border-color: var(--verde); color: var(--verde); }
.cond button.sel[data-v="2"] { background: var(--ambar-suave); border-color: var(--ambar); color: var(--ambar); }
.item-cond .nota-item {
  margin-top: 8px; min-height: 44px; font-size: 15px; padding: 10px 12px;
}

/* ---------- listas ---------- */
.lista { display: grid; gap: 10px; }
.fila-lista {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--panel); border: 0; border-radius: var(--r); box-shadow: var(--sombra);
  padding: 14px 16px; min-height: 66px; cursor: pointer; font-family: inherit;
  font-size: 16px; color: inherit;
}
.fila-lista:active { background: #FAFAFB; }
.fila-lista .cuerpo { flex: 1; min-width: 0; }
.fila-lista .cuerpo b { display: block; font-size: 16px; }
.fila-lista .cuerpo small { display: block; color: var(--gris); font-size: 13.5px; margin-top: 2px; }
.fila-lista .flecha { color: var(--gris-claro); font-size: 22px; flex: none; }

.marca-etapa {
  width: 38px; height: 38px; flex: none; border-radius: 10px;
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
  background: var(--gris-claro); color: var(--gris);
}
.marca-etapa.hecha { background: var(--verde); color: #fff; }
.marca-etapa.curso { background: var(--naranja); color: var(--carbon); }

/* ---------- etiquetas de estado ---------- */
.tag {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  background: var(--gris-claro); color: var(--gris);
}
.tag.verde { background: var(--verde-suave); color: var(--verde); }
.tag.naranja { background: var(--naranja-suave); color: var(--naranja-texto); }
.tag.rojo { background: var(--rojo-suave); color: var(--rojo); }
.tag.ambar { background: var(--ambar-suave); color: var(--ambar); }
.tag.pend { background: var(--carbon); color: #fff; }

/* ---------- barra de progreso ---------- */
.progreso { height: 8px; border-radius: 999px; background: var(--gris-claro); overflow: hidden; }
.progreso i { display: block; height: 100%; background: var(--naranja); border-radius: 999px; }

/* ---------- métricas ---------- */
.metricas { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 10px; }
.metrica { background: var(--panel); border-radius: var(--r); box-shadow: var(--sombra); padding: 14px 16px; }
.metrica b { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.metrica small { display: block; color: var(--gris); font-size: 12.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; margin-top: 3px; }
.metrica.alerta b { color: var(--rojo); }

/* ---------- tablas ---------- */
.tabla-envoltura { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
table.datos { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.datos th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--gris); font-weight: 800; padding: 8px 10px; border-bottom: 2px solid var(--gris-claro);
  white-space: nowrap;
}
table.datos td { padding: 10px; border-bottom: 1px solid var(--gris-claro); vertical-align: top; }
table.datos tr:last-child td { border-bottom: 0; }
table.datos td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- fotos ---------- */
.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.fotos img, .miniatura {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px;
  background: var(--gris-claro); display: block; border: 0; padding: 0; cursor: pointer;
}
.subir-foto {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 92px; border: 2px dashed var(--gris-claro); border-radius: var(--r);
  background: #fff; color: var(--gris); font-family: inherit; font-size: 15px;
  font-weight: 600; line-height: 1; cursor: pointer;
}
.subir-foto:active { border-color: var(--naranja); color: var(--naranja-texto); }

/* ---------- barra inferior del operador ---------- */
.pestanas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255,255,255,.97); backdrop-filter: blur(8px);
  border-top: 1px solid var(--gris-claro);
  padding-bottom: var(--pie);
}
.pestanas button {
  background: 0; border: 0; padding: 9px 4px 8px; cursor: pointer;
  display: grid; gap: 3px; justify-items: center;
  font-family: inherit; font-size: 11px; font-weight: 600; line-height: 1.1; color: var(--gris);
}
.pestanas button svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 1.9; }
.pestanas button.sel { color: var(--naranja-texto); }

/* ---------- hoja emergente ---------- */
.telon {
  position: fixed; inset: 0; z-index: 90; background: rgba(22,24,28,.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.hoja {
  background: var(--panel); width: 100%; max-width: 640px;
  border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + var(--pie));
  max-height: 92vh; overflow-y: auto; animation: subir .2s ease-out;
}
@keyframes subir { from { transform: translateY(22px); opacity: .4; } }
.hoja h2 { font-size: 19px; margin-bottom: 14px; }
.hoja .agarre { width: 40px; height: 4px; border-radius: 999px; background: var(--gris-claro); margin: -6px auto 14px; }

/* ---------- avisos ---------- */
.aviso { padding: 12px 14px; border-radius: 10px; font-size: 14.5px; margin-bottom: 12px; font-weight: 500; }
.aviso.info  { background: var(--naranja-suave); color: var(--naranja-texto); }
.aviso.malo  { background: var(--rojo-suave); color: var(--rojo); }
.aviso.bueno { background: var(--verde-suave); color: var(--verde); }

.vacio { text-align: center; padding: 44px 20px; color: var(--gris); }
.vacio p { margin: 6px 0 18px; font-size: 15px; }

.brindis {
  position: fixed; left: 50%; bottom: calc(96px + var(--pie)); transform: translateX(-50%);
  background: var(--carbon); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 14.5px; font-weight: 600; z-index: 120; box-shadow: 0 6px 20px rgba(0,0,0,.28);
  animation: subir .18s ease-out; max-width: 90vw; text-align: center;
}

/* ---------- escritorio ---------- */
@media (min-width: 860px) {
  .rejilla-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
  .pestanas { grid-template-columns: repeat(4, minmax(0, 120px)); justify-content: center; }
}
.menu-admin {
  display: flex; gap: 4px; overflow-x: auto; padding: 8px 14px;
  background: var(--carbon-2); position: sticky; top: 0; z-index: 30;
}
.menu-admin button {
  background: transparent; border: 0; color: rgba(255,255,255,.72); cursor: pointer;
  font-family: inherit; font-size: 14.5px; font-weight: 600; line-height: 1;
  padding: 10px 14px; border-radius: 9px; white-space: nowrap;
}
.menu-admin button.sel { background: var(--naranja); color: var(--carbon); }

/* Gestor de formularios: una pregunta por fila.
   En pantalla angosta los botones se van abajo en vez de estrujar el texto. */
.fila-pregunta {
  display: grid; grid-template-columns: auto 1fr auto auto;
  align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--gris-claro);
}
.fila-pregunta:last-of-type { border-bottom: 0; }
.fila-pregunta .mover { display: grid; gap: 2px; }
.fila-pregunta .texto { min-width: 0; }

@media (max-width: 620px) {
  .fila-pregunta {
    grid-template-columns: auto 1fr;
    grid-template-areas: 'mover texto' '. acciones';
    row-gap: 8px;
  }
  .fila-pregunta .mover { grid-area: mover; }
  .fila-pregunta .texto { grid-area: texto; }
  .fila-pregunta > .btn:nth-last-child(2) { grid-area: acciones; justify-self: start; }
  .fila-pregunta > .btn:last-child { grid-area: acciones; justify-self: start; margin-left: 92px; }
}

/* --- detalle del pozo en el panel --- */
.encabezado-pozo { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.encabezado-pozo > div:first-child { flex: 1; min-width: 220px; }
.acciones-pozo { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 16px; }

/* La columna litológica necesita aire a la derecha para las descripciones. */
.columna-lito { overflow-x: auto; }
.columna-lito svg { display: block; max-width: 100%; height: auto; }

.foto-caja { margin: 0; }
.foto-caja img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  border-radius: 10px; background: var(--gris-claro); cursor: pointer; display: block;
}
.foto-caja figcaption {
  font-size: 11.5px; color: var(--gris); margin-top: 5px; line-height: 1.25;
}
.fotos { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

/* --- lo que hay que mirar hoy --- */
.punto-atencion {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: 0; border-bottom: 1px solid var(--gris-claro);
  padding: 13px 0; cursor: pointer; font-family: inherit; font-size: 15px;
  color: var(--carbon); text-align: left;
}
.punto-atencion:last-child { border-bottom: 0; }
.punto-atencion:active { background: #FAFAFB; }
.bolita { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.bolita.rojo { background: var(--rojo); }
.bolita.ambar { background: var(--ambar); }

/* --- rejilla semanal del preoperacional (como el formato en papel) --- */
table.rejilla td, table.rejilla th { padding: 7px 8px; font-size: 13px; }
table.rejilla td:first-child { min-width: 190px; }
.celda-cond { text-align: center; font-weight: 800; font-size: 12px; }
.celda-cond.cumple { background: var(--verde-suave); color: var(--verde); }
.celda-cond.mejora { background: var(--ambar-suave); color: var(--ambar); }
.celda-cond.na     { background: var(--gris-claro); color: var(--gris); }
table.rejilla .fila-pie td { background: #FAFAFB; font-weight: 600; }
table.rejilla .fila-pie:first-of-type td { border-top: 2px solid var(--gris-claro); }

/* --- ver la clave --- */
.ver-clave {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--gris); cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  padding: 10px 10px; min-height: 40px;
}
.ver-clave:active { color: var(--carbon); }

/* --- firma con el dedo --- */
.firma-caja {
  position: relative; border: 2px dashed var(--gris-claro); border-radius: var(--r);
  background: #fff; overflow: hidden; touch-action: none;
}
.firma-lienzo { display: block; width: 100%; touch-action: none; cursor: crosshair; }
.firma-pista {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--gris); font-size: 15px; pointer-events: none;
}
.firma-hecha {
  border: 1.5px solid var(--gris-claro); border-radius: 10px; background: #fff;
  padding: 6px 10px; display: flex; align-items: center; gap: 10px;
}
.firma-hecha img { height: 46px; max-width: 160px; object-fit: contain; }

/* --- cronograma: nombre | barra | acción --- */
.crono { display: grid; grid-template-columns: minmax(170px, 1.4fr) 3fr auto; gap: 10px 14px; align-items: center; }
.crono-nombre b { display: block; font-size: 14.5px; }
.crono-nombre small { display: block; color: var(--gris); font-size: 12.5px; margin-top: 1px; }
.crono-nombre .tag { margin-top: 4px; }
.crono-pista {
  position: relative; height: 22px; border-radius: 6px;
  background: repeating-linear-gradient(90deg, var(--gris-claro) 0 1px, transparent 1px 100%) , #FAFAFB;
  background-size: 10% 100%;
}
.crono-barra {
  position: absolute; top: 4px; height: 14px; border-radius: 999px;
  background: var(--naranja); min-width: 6px;
}
.crono-barra.hecha    { background: var(--verde); }
.crono-barra.atrasada { background: var(--rojo); }
.crono-barra.curso    { background: var(--naranja); }
/* La línea de hoy es la que hace legible el atraso de un vistazo. */
.crono-hoy { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--carbon); opacity: .55; }

@media (max-width: 720px) {
  .crono { grid-template-columns: 1fr auto; }
  .crono-pista { grid-column: 1 / -1; }
}
