/* =========================================================================
   Tudor Sport · componentes.css  [diseno]
   Piezas reutilizables. HTML de ejemplo de cada una: disenio/GUIA-COMPONENTES.md
   Regla: todo lo que se toca mide 44 px o más.
   ========================================================================= */

/* ------------------------------------------------------------------ */
/* 1. Armazón                                                         */
/* ------------------------------------------------------------------ */
.app {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: var(--ancho-max);
  margin: 0 auto;
  background: var(--fondo);
}

.barra-superior {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: var(--alto-barra-superior);
  padding: 4px 6px 4px 16px;
  background: var(--blanco);
  border-bottom: 1px solid var(--borde);
}
.barra-superior > .btn-icono:first-child { margin-left: -10px; }
.barra-superior h1 {
  flex: 1;
  min-width: 0;
  font-size: 19px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.barra-superior .marca-mini { width: 30px; height: 30px; object-fit: contain; }
.barra-superior .subtitulo { display: block; font-size: 12.5px; font-weight: 500; color: var(--sub); }

/* Grupo pegado arriba: barra superior + barra de guardado */
.cabecera-fija { position: sticky; top: 0; z-index: 20; }
.cabecera-fija .barra-superior { position: static; }
.cabecera-fija > *, .cabecera-fija .barra-superior > * { min-width: 0; }  /* BUG-042: un título largo no ensancha la pantalla */

.contenido {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 16px calc(var(--alto-barra-inferior) + 28px + var(--seguro-abajo));
}
/* BUG-073: red de seguridad. Un texto largo sin espacios (zona, marca, nombre del Forms…) se parte
   en vez de ensanchar la pantalla. `anywhere` (no `break-word`) para que también baje el ancho mínimo
   de las cajas flex/grid. Los textos de una sola línea con "…" (white-space:nowrap) no cambian. */
.contenido, .hoja-inferior, .dialogo { min-width: 0; overflow-wrap: anywhere; }
.contenido > *, .hoja-inferior > *, .formulario > *, .caja > * { min-width: 0; }

.barra-inferior {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: var(--ancho-max);
  height: calc(var(--alto-barra-inferior) + var(--seguro-abajo));
  margin: 0 auto;
  padding-bottom: var(--seguro-abajo);
  background: var(--blanco);
  border-top: 1px solid var(--borde);
}
.nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--alto-toque);
  padding: 0;
  border: 0;
  background: none;
  color: var(--sub);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
}
.nav-item.activo { color: var(--marca); font-weight: 700; }
.nav-item.activo::before {
  content: "";
  position: absolute;
  top: 0;
  left: 26%;
  right: 26%;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--marca);
}
.nav-item .contador {
  position: absolute;
  top: 7px;
  left: calc(50% + 6px);
}

/* Barra pegada abajo con el botón principal del formulario (sobre la barra inferior) */
.barra-accion {
  position: sticky;
  bottom: calc(var(--alto-barra-inferior) + var(--seguro-abajo));
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: auto -16px -28px;   /* se pega a la barra inferior; el auto la empuja al fondo si hay poco contenido */
  padding: 12px 16px 14px;
  background: var(--fondo);
  border-top: 1px solid var(--borde);
}
.barra-accion .fila-botones { display: flex; gap: 10px; }
.barra-accion .fila-botones .btn { flex: 1; }

/* ------------------------------------------------------------------ */
/* 2. Botones                                                         */
/* ------------------------------------------------------------------ */
.btn {
  position: relative;
  display: inline-flex;
  max-width: 100%;   /* BUG-073: un botón con texto largo no se sale */
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--alto-boton);
  padding: 0 18px;
  border: 1.5px solid transparent;
  border-radius: var(--radio);
  background: var(--blanco);
  color: var(--texto);
  font: 700 16px/1.2 var(--fuente);
  text-align: center;
  text-decoration: none;
  user-select: none;
  transition: transform .08s ease, filter .15s ease, background-color .15s ease;
}
.btn:active { transform: scale(.98); filter: brightness(.95); }
.btn .ico { width: 22px; height: 22px; }

.btn-primario { background: var(--marca); border-color: var(--marca); color: var(--marca-texto); }
.btn-secundario { background: var(--blanco); border-color: var(--borde-fuerte); color: var(--texto); }
.btn-peligro { background: var(--rojo-claro); border-color: var(--rojo-claro); color: var(--rojo); }
.btn-whatsapp { background: var(--whatsapp); border-color: var(--whatsapp); color: var(--whatsapp-texto); }
.btn-texto {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--alto-toque);
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--marca);
  font: 700 15px/1.2 var(--fuente);
  text-decoration: none;
  white-space: nowrap;
}
.btn-texto:active { background: var(--marca-claro); }

.btn-grande {
  width: 100%;
  min-height: var(--alto-boton-grande);
  border-radius: var(--radio-grande);
  font-size: 18px;
}
.btn-bloque { width: 100%; }
.btn-chico { min-height: var(--alto-toque); padding: 0 14px; font-size: 15px; border-radius: 12px; }

.btn-icono {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--alto-toque);
  height: var(--alto-toque);
  min-height: var(--alto-toque);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--texto);
}
.btn-icono:active { background: var(--fondo); transform: none; }
.btn-icono.con-fondo { background: var(--gris-suave); }
.btn-icono.whatsapp { background: var(--whatsapp); color: var(--whatsapp-texto); }

.btn[disabled], .btn[aria-disabled="true"] {
  opacity: .45;
  pointer-events: none;
  filter: grayscale(.3);
}

/* Guardando: el texto se oculta y aparece una ruedita (bloquea el doble toque) */
.btn.cargando { color: transparent !important; pointer-events: none; }
.btn.cargando > * { visibility: hidden; }
.btn.cargando::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, .15);
  border-top-color: var(--texto);
  animation: girar .7s linear infinite;
}
.btn-primario.cargando::after { border-color: rgba(255, 255, 255, .35); border-top-color: var(--marca-texto); }
.btn-whatsapp.cargando::after { border-color: rgba(255, 255, 255, .35); border-top-color: var(--whatsapp-texto); }

/* Botón redondo con texto debajo (acciones de la ficha del cliente) */
.acciones-redondas { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.accion-redonda {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 72px;
  padding: 6px 2px;
  border: 0;
  background: none;
  color: var(--texto);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.accion-redonda .circulo {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--marca-claro);
  color: var(--marca);
}
.accion-redonda.whatsapp .circulo { background: var(--whatsapp); color: var(--whatsapp-texto); }
.accion-redonda.principal .circulo { background: var(--marca); color: var(--marca-texto); }

/* ------------------------------------------------------------------ */
/* 3. Formularios                                                     */
/* ------------------------------------------------------------------ */
.formulario { display: flex; flex-direction: column; gap: 16px; }

.campo { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.campo > label,
.campo-etiqueta { font-size: 15px; font-weight: 600; color: var(--texto); }
.campo .opcional { font-weight: 400; color: var(--sub); }

.campo input,
.campo select,
.campo textarea {
  width: 100%;
  min-height: var(--alto-boton);
  padding: 11px 14px;
  border: 1.5px solid var(--borde-fuerte);
  border-radius: 12px;
  background: var(--blanco);
  color: var(--texto);
  font: 400 16px/1.3 var(--fuente);   /* 16 px: el celular no hace zoom */
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.campo textarea { min-height: 88px; resize: vertical; }
.campo select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6b70' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
}
.campo input:focus,
.campo select:focus,
.campo textarea:focus {
  border-color: var(--marca);
  box-shadow: 0 0 0 3px var(--marca-claro);
}
.campo input::placeholder, .campo textarea::placeholder { color: #a1a1a8; }

.campo-ayuda { font-size: 13.5px; color: var(--sub); }
.campo-error { display: none; font-size: 14px; font-weight: 600; color: var(--rojo); }
.campo.con-error .campo-error { display: block; }
.campo.con-error input,
.campo.con-error select,
.campo.con-error textarea,
.campo.con-error .input-monto { border-color: var(--rojo); }
.campo.con-error input:focus,
.campo.con-error .input-monto:focus-within { box-shadow: 0 0 0 3px var(--rojo-claro); }

/* Monto grande con "S/" delante. Siempre inputmode="decimal" (teclado de números) */
.input-monto {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 0 16px;
  border: 1.5px solid var(--borde-fuerte);
  border-radius: var(--radio);
  background: var(--blanco);
}
.input-monto > span { font-size: 22px; font-weight: 700; color: var(--sub); }
.input-monto input,
.campo .input-monto input {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 60px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font: 700 30px/1 var(--fuente);
  font-variant-numeric: tabular-nums;
  outline: none;
}
.input-monto:focus-within { border-color: var(--marca); box-shadow: 0 0 0 3px var(--marca-claro); }
.input-monto.chico { min-height: 52px; padding: 0 12px; }
.input-monto.chico > span { font-size: 17px; }
.input-monto.chico input,
.campo .input-monto.chico input { min-height: 48px; font-size: 21px; }

/* Campo corto en una sola línea: etiqueta a la izquierda, número a la derecha */
.campo.en-linea { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.campo.en-linea > label { flex: 1; font-weight: 500; font-size: 15px; }
.campo.en-linea input { width: 84px; flex: none; text-align: center; font-weight: 700; }

/* Dos campos lado a lado */
.fila-campos { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.fila-campos > * { min-width: 0; }  /* BUG-073 */

/* Buscador (redondeado, con lupa y botón para borrar) */
.buscador { position: relative; }
.buscador > .ico {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 20px;
  height: 20px;
  color: var(--sub);
  transform: translateY(-50%);
  pointer-events: none;
}
.buscador input {
  width: 100%;
  min-height: 52px;
  padding: 0 48px 0 44px;
  border: 1.5px solid var(--borde-fuerte);
  border-radius: var(--radio-ficha);
  background: var(--blanco);
  font: 400 16px var(--fuente);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.buscador input:focus { border-color: var(--marca); box-shadow: 0 0 0 3px var(--marca-claro); }
.buscador input::-webkit-search-cancel-button { display: none; }
.buscador .btn-icono { position: absolute; right: 4px; top: 4px; color: var(--sub); }

/* Interruptor sí/no (activar o desactivar un valor de una lista) */
.interruptor { position: relative; display: inline-flex; flex: none; width: 52px; height: 44px; align-items: center; }
.interruptor input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.interruptor span {
  position: relative;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: var(--borde-fuerte);
  transition: background-color .15s;
}
.interruptor span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--blanco);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .15s;
}
.interruptor input:checked + span { background: var(--verde); }
.interruptor input:checked + span::after { transform: translateX(22px); }
.interruptor input:focus-visible + span { outline: 3px solid var(--marca); outline-offset: 2px; }

/* ------------------------------------------------------------------ */
/* 4. Selección: fichas, segmentado, color                            */
/* ------------------------------------------------------------------ */
.fichas { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; min-width: 0; max-width: 100%; }  /* una ficha alta no estira a las demás */
.fichas.desliza {
  flex-wrap: nowrap;
  overflow-x: auto;
  margin: 0 -16px;
  padding: 2px 16px;
  scrollbar-width: none;
}
.fichas.desliza::-webkit-scrollbar { display: none; }

.ficha {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: none;
  max-width: 100%;   /* BUG-073: una zona o marca larga se parte en varias líneas dentro de la ficha */
  min-width: 0;
  min-height: var(--alto-toque);
  padding: 6px 16px;
  border: 1.5px solid var(--borde-fuerte);
  border-radius: var(--radio-ficha);
  background: var(--blanco);
  color: var(--texto);
  font: 600 15px/1.1 var(--fuente);
  text-align: center;
  white-space: nowrap;
}
/* Solo se parte si no entra en la fila: las fichas cortas siguen en una línea */
.ficha { white-space: normal; overflow-wrap: anywhere; }
.fichas.desliza { max-width: none; }  /* sale hasta el borde con margen negativo */
.fichas.desliza > .ficha { max-width: min(240px, 70vw); }  /* en la fila que se desliza, una ficha larga se parte a 240 px */
.ficha > * { min-width: 0; }
.ficha.activa,
.ficha[aria-pressed="true"] {
  border-color: var(--marca);
  background: var(--marca);
  color: var(--marca-texto);
}
.ficha .ico { width: 18px; height: 18px; }
.ficha-agregar { border-style: dashed; color: var(--marca); background: transparent; }
.ficha .cuenta { font-weight: 500; opacity: .75; }
/* fichas que llenan la fila en partes iguales (medio de pago, montos rápidos) */
.fichas.parejas { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); align-items: stretch; }
.fichas.parejas .ficha { padding: 6px 4px; }
/* En las parejas el ancho lo pone la cuadrícula: las palabras no se cortan (como antes) y un texto
   larguísimo del Sheets se recorta desde el final en vez de salirse (se lee completo en Ajustes). */
.fichas.parejas > * { min-width: 0; }
.fichas.parejas .ficha { white-space: nowrap; overflow-wrap: normal; overflow: clip; overflow-clip-margin: 3px; }

/* Selector de 2 opciones */
.segmentado {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radio);
  background: #e6e6ea;
}
.segmentado button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--alto-toque);
  padding: 0 8px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--sub);
  font: 600 15px var(--fuente);
}
.segmentado button.activa,
.segmentado button[aria-pressed="true"] {
  background: var(--blanco);
  color: var(--texto);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .14);
}

/* Selector de color de marca (como el prototipo): fichas + arcoíris para color libre.
   El color de cada ficha lo pone JS: boton.style.setProperty('--c', '#7c3aed') */
.selector-color { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.selector-color button,
.selector-color label {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 3px solid var(--blanco);
  border-radius: 50%;
  background: var(--c, #ccc);
  box-shadow: 0 0 0 1px var(--borde-fuerte);
  cursor: pointer;
}
.selector-color label.arcoiris {
  background: conic-gradient(#ff0000, #ff9900, #ffee00, #33dd00, #00ccff, #3355ff, #cc00ff, #ff0000);
}
.selector-color label input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.selector-color .activa { box-shadow: 0 0 0 3px var(--texto); }
.selector-color-nombre { font-size: 14px; color: var(--sub); }
.selector-color-nombre b { color: var(--texto); }

/* Selector de calificación del pagador: 4 colores + "Sin color" */
.selector-cal { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.selector-cal button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 76px;
  padding: 8px 2px;
  border: 1.5px solid var(--borde);
  border-radius: var(--radio);
  background: var(--blanco);
  color: var(--texto);
  font: 600 13px/1.1 var(--fuente);
}
.selector-cal button::before {
  content: "";
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--cal-color, var(--cal-vacio));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1);
}
.selector-cal button.activa,
.selector-cal button[aria-pressed="true"] {
  border-color: var(--texto);
  box-shadow: inset 0 0 0 1px var(--texto);
  background: var(--gris-suave);
}
.selector-cal button.activa::before { box-shadow: 0 0 0 3px var(--blanco), 0 0 0 5px var(--texto); }
.selector-cal-ayuda { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: var(--alto-toque); font-size: 14px; color: var(--sub); }
.selector-cal-ayuda b { color: var(--texto); }

/* ------------------------------------------------------------------ */
/* 5. Datos: cajas, secciones, KPI, resumen, tabla, avance            */
/* ------------------------------------------------------------------ */
.caja {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--borde);
  border-radius: var(--radio-grande);
  background: var(--blanco);
}
.caja.sin-relleno { padding: 0; overflow: hidden; }
.caja > * + * { margin-top: 12px; }
.caja.sin-relleno > * + * { margin-top: 0; }

.seccion { display: flex; flex-direction: column; gap: 10px; }
.seccion-titulo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 32px;
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}
.seccion-titulo .btn-texto { margin-right: -10px; font-size: 15px; }
.seccion-titulo > span:first-child { display: inline-flex; align-items: center; gap: 8px; }

.contador {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--marca);
  color: var(--marca-texto);
  font-size: 12.5px;
  font-weight: 700;
}
.contador.rojo { background: var(--rojo); color: #fff; }
.contador.gris { background: #e3e3e8; color: var(--texto); }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  background: var(--blanco);
  color: inherit;
  text-align: left;
  text-decoration: none;
  font: inherit;
}
button.kpi, a.kpi { cursor: pointer; }
.kpi-etiqueta { font-size: 13.5px; font-weight: 500; color: var(--sub); }
.kpi-valor { font-size: 23px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-detalle { font-size: 13px; color: var(--sub); }
.kpi[data-estado="atrasado"] .kpi-valor { color: var(--rojo); }
.kpi[data-estado="por_vencer"] .kpi-valor { color: var(--ambar); }
.kpi[data-estado="al_dia"] .kpi-valor { color: var(--verde); }
.kpi.ancho { grid-column: 1 / -1; }
.kpi-principal {
  grid-column: 1 / -1;
  border-color: var(--marca);
  background: var(--marca);
  color: var(--marca-texto);
}
.kpi-principal .kpi-etiqueta,
.kpi-principal .kpi-detalle { color: var(--marca-suave); }
.kpi-principal .kpi-valor { font-size: 32px; }

/* Resumen que cambia mientras se escribe (antes → después) */
.resumen-vivo {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 12px 14px;
  border-radius: var(--radio);
  background: var(--gris-suave);
  border: 1px solid var(--borde);
}
.resumen-vivo .fila { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 15px; }
.resumen-vivo, .resumen-vivo .fila > * { min-width: 0; word-break: break-word; overflow-wrap: anywhere; }  /* BUG-042 */
.resumen-vivo .fila > :first-child { color: var(--sub); }
.resumen-vivo .fila > :last-child { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.resumen-vivo .total { margin-top: 2px; padding-top: 9px; border-top: 1px dashed #cdcdd3; font-size: 18px; }
.resumen-vivo .total > :first-child { color: var(--texto); font-weight: 600; }
.resumen-vivo .total > :last-child { font-weight: 700; }
.resumen-vivo .tachado { color: var(--sub); text-decoration: line-through; font-weight: 500; margin-right: 6px; }

/* Mensaje corto debajo del resumen: "Queda al día", "Queda pendiente S/ 20…" */
.mensaje-estado {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 600;
  background: var(--verde-bg);
  color: var(--verde);
}
.mensaje-estado .ico { width: 20px; height: 20px; }
.mensaje-estado[data-tipo="parcial"] { background: var(--ambar-bg); color: var(--ambar); }
.mensaje-estado[data-tipo="adelanta"] { background: var(--verde-bg); color: var(--verde); }
.mensaje-estado[data-tipo="cierra"] { background: var(--marca-claro); color: var(--marca); }
.mensaje-estado[data-tipo="error"] { background: var(--rojo-claro); color: var(--rojo); }

.tabla { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tabla th { padding: 8px 6px; border-bottom: 1px solid var(--borde); color: var(--sub); font-size: 12.5px; font-weight: 500; text-align: left; }
.tabla td { padding: 10px 6px; border-bottom: 1px solid var(--borde); vertical-align: top; }
.tabla th:first-child, .tabla td:first-child { padding-left: 0; }
.tabla th:last-child, .tabla td:last-child { padding-right: 0; }
.tabla .der { text-align: right; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla td:not(.der) { word-break: break-word; overflow-wrap: anywhere; }  /* BUG-042: detalle largo del Sheets */
.tabla th:first-child, .tabla td:first-child { white-space: nowrap; word-break: normal; overflow-wrap: normal; }
.tabla td.acciones-mov { white-space: nowrap; }
.tabla td.acciones-mov .btn-icono + .btn-icono { margin-left: 2px; }
.tabla .der { white-space: nowrap; }
/* Movimiento por revisar (§11.7): no cuenta en el saldo. Fila apagada + .badge-revisar en el detalle */
.tabla tr.por-revisar td { background: var(--ambar-bg); color: var(--sub); }
.tabla tr.por-revisar td.der { text-decoration: line-through; }
.tabla tr.por-revisar .badge-revisar { margin-top: 4px; }

.avance { display: flex; flex-direction: column; gap: 6px; }
.avance-barra { height: 10px; border-radius: 10px; background: var(--borde); overflow: hidden; }
.avance-barra > i { display: block; height: 100%; border-radius: 10px; background: var(--marca); }
.avance-texto { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--sub); }
.avance-texto b { color: var(--texto); }

/* Filas etiqueta – valor (datos del cliente, acuerdo de pago) */
.datos { display: flex; flex-direction: column; min-width: 0; }
/* BUG-042: un texto sin espacios (enlace de mapa, zona larga) se parte en varias líneas */
.datos > *, .dato > *, .datos dd { min-width: 0; }
.datos dd, .dato-valor, .dato-etiqueta { word-break: break-word; overflow-wrap: anywhere; }
.dato {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 0;
  border-bottom: 1px solid var(--borde);
}
.dato:last-child { border-bottom: 0; }
.dato > .ico { color: var(--sub); }
.dato-texto { flex: 1; min-width: 0; }
.dato-etiqueta { font-size: 13px; color: var(--sub); }
.dato-valor { font-size: 15.5px; font-weight: 600; }

/* ------------------------------------------------------------------ */
/* 6. Clientes: lista, fila, avatar, punto de calificación            */
/* ------------------------------------------------------------------ */
.lista {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--borde);
  border-radius: var(--radio-grande);
  background: var(--blanco);
  overflow: hidden;
  min-width: 0;
}
.lista > li { display: block; min-width: 0; }
.lista > li:last-child > .fila-cliente,
.lista > .fila-cliente:last-child { border-bottom: 0; }

.fila-cliente {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 72px;
  padding: 10px 10px 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--borde);
  background: var(--blanco);
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
}
a.fila-cliente, button.fila-cliente { cursor: pointer; }
.fila-cliente > * { min-width: 0; }  /* BUG-042: ningún hijo empuja la fila más allá de la pantalla */
.fila-cliente:active { background: var(--gris-suave); }
.fila-cliente.elegida { background: var(--marca-claro); }
.fila-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; color: inherit; text-decoration: none; }
a.fila-info { align-self: stretch; justify-content: center; }
/* El nombre puede ocupar 2 líneas: es lo más importante de la fila */
.fila-nombre { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 16px; font-weight: 700; line-height: 1.25; word-break: break-word; overflow-wrap: anywhere; }
/* En las listas: una sola línea con "…". En la ficha (cabecera y Datos) se parte en varias líneas. */
.fila-sub { min-width: 0; max-width: 100%; font-size: 13.5px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; word-break: break-word; overflow-wrap: anywhere; }
.fila-sub .badge-estado, .fila-sub .badge-revisar { margin-right: 4px; vertical-align: 1px; }
.fila-lado { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: none; }
.fila-monto { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fila-acciones { display: flex; gap: 2px; flex: none; }

/* Avatar de iniciales. El anillo de color = calificación (data-cal) */
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  margin: 4px;
  border-radius: 50%;
  background: var(--marca-claro);
  color: var(--marca);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .02em;
  box-shadow: 0 0 0 2.5px var(--blanco), 0 0 0 5.5px var(--cal-color, var(--cal-vacio));
}
.avatar[data-cal=""], .avatar:not([data-cal]) { box-shadow: 0 0 0 2.5px var(--blanco), 0 0 0 4px var(--cal-vacio); }
.avatar.grande { width: 68px; height: 68px; font-size: 24px; margin: 6px; box-shadow: 0 0 0 3px var(--blanco), 0 0 0 7px var(--cal-color, var(--cal-vacio)); }

.punto-cal {
  display: inline-block;
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cal-color, var(--cal-vacio));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
  vertical-align: middle;
}

/* ------------------------------------------------------------------ */
/* 7. Estados                                                         */
/* ------------------------------------------------------------------ */
.badge-estado {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--gris-suave);
  color: var(--sub);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}
.badge-estado::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-estado[data-estado="al_dia"]     { background: var(--verde-bg); color: var(--verde); }
.badge-estado[data-estado="por_vencer"] { background: var(--ambar-bg); color: var(--ambar); }
.badge-estado[data-estado="atrasado"]   { background: var(--rojo-claro); color: var(--rojo); }
.badge-estado[data-estado="pagado"]     { background: #e9e9ee; color: var(--texto); }
.badge-estado[data-estado="sin_cronograma"] { background: var(--gris-suave); color: var(--sub); box-shadow: inset 0 0 0 1px var(--borde-fuerte); }

.badge-revisar {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--ambar-bg);
  color: var(--ambar);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(161, 98, 7, .35);
}
.badge-revisar::before { content: "!"; display: grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; background: currentColor; color: var(--ambar-bg); font-size: 10.5px; font-weight: 800; }

/* ------------------------------------------------------------------ */
/* 8. Avisos                                                          */
/* ------------------------------------------------------------------ */
/* Barra de guardado en el Sheets (debajo de la barra superior) */
.barra-sync {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 6px 16px;
  border: 0;
  border-bottom: 1px solid var(--borde);
  background: var(--verde-bg);
  color: var(--verde);
  font: 600 13.5px/1.25 var(--fuente);
  text-align: left;
}
.barra-sync .ico { width: 18px; height: 18px; }
.barra-sync .accion {
  margin-left: auto;
  padding-left: 8px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}
button.barra-sync { cursor: pointer; min-height: var(--alto-toque); }
.barra-sync[data-estado="ok"]            { background: var(--verde-bg); color: var(--verde); }
.barra-sync[data-estado="pendiente"]     { background: var(--ambar-bg); color: var(--ambar); }
.barra-sync[data-estado="sincronizando"] { background: var(--gris-suave); color: var(--sub); }
.barra-sync[data-estado="sincronizando"] .ico { animation: latir 1.2s ease-in-out infinite; }
.barra-sync[data-estado="error"]         { background: var(--rojo-claro); color: var(--rojo); }
.barra-sync[data-estado="cambios"]       { background: var(--marca-claro); color: var(--marca); }
.barra-sync[data-estado="solo_celular"]  { background: var(--gris-suave); color: var(--sub); }
.barra-sync[data-estado="solo_celular"] .accion { color: var(--marca); }

/* Aviso grande "Hay cambios en tu Sheets · Actualizar" */
.aviso-cambios {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 14px;
  border: 1.5px solid var(--marca);
  border-radius: var(--radio);
  background: var(--marca-claro);
  color: var(--texto);
  animation: aparecer .25s ease-out;
}
.aviso-cambios > .ico { width: 24px; height: 24px; color: var(--marca); }
.aviso-cambios .aviso-texto { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; line-height: 1.25; }
.aviso-cambios .aviso-texto small { display: block; font-size: 13px; font-weight: 500; color: var(--sub); }
.aviso-cambios .btn {
  min-height: var(--alto-toque);
  padding: 0 14px;
  border-color: var(--marca);
  background: var(--marca);
  color: var(--marca-texto);
  font-size: 15px;
}

/* Aviso dentro del contenido (info, alerta, peligro, ok) */
.aviso {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radio);
  background: var(--gris-suave);
  border: 1px solid var(--borde);
  color: var(--texto);
  font-size: 14.5px;
}
a.aviso { text-decoration: none; }
.aviso > .ico { width: 22px; height: 22px; margin-top: 1px; }
.aviso .aviso-cuerpo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.aviso .aviso-cuerpo b { font-weight: 700; }
.aviso .fila-botones { display: flex; gap: 8px; flex-wrap: wrap; }
.aviso .fila-botones .btn { flex: 1; }
.aviso[data-tipo="alerta"]  { background: var(--ambar-bg); border-color: #f6e2a8; }
.aviso[data-tipo="alerta"] > .ico { color: var(--ambar); }
.aviso[data-tipo="peligro"] { background: var(--rojo-claro); border-color: #f8caca; }
.aviso[data-tipo="peligro"] > .ico { color: var(--rojo); }
.aviso[data-tipo="ok"]      { background: var(--verde-bg); border-color: #c7ebd5; }
.aviso[data-tipo="ok"] > .ico { color: var(--verde); }
.aviso[data-tipo="marca"]   { background: var(--marca-claro); border-color: transparent; }
.aviso[data-tipo="marca"] > .ico { color: var(--marca); }

/* Mensaje corto que aparece y se va ("Guardado en el celular") */
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--alto-barra-inferior) + 14px + var(--seguro-abajo));
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(var(--ancho-max) - 32px);
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: var(--radio);
  background: var(--oscuro);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
  animation: subir .22s ease-out;
}
.toast .ico { width: 22px; height: 22px; }
.toast[data-tipo="ok"] .ico { color: var(--cal-verde); }
.toast[data-tipo="error"] { background: var(--rojo); }
.toast[data-tipo="info"] .ico { color: #93c5fd; }
.toast .btn-texto { margin-left: auto; color: #fff; text-decoration: underline; }

/* Fondo oscuro + ventana de confirmación */
.fondo-oscuro {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(17, 17, 20, .5);
  animation: aparecer .18s ease-out;
}
.fondo-oscuro:has(> .hoja-inferior) { align-items: flex-end; padding: 0; }
.fondo-oscuro.abajo { align-items: flex-end; padding: 0; }

.dialogo {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 400px;
  padding: 22px 20px 18px;
  border-radius: var(--radio-grande);
  background: var(--blanco);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .25);
}
.dialogo h2 { font-size: 19px; }
.dialogo p { color: var(--sub); font-size: 15.5px; }
.dialogo-acciones { display: flex; gap: 10px; margin-top: 6px; }
.dialogo-acciones .btn { flex: 1; }

/* Hoja que sube desde abajo (registrar abono, filtros, elegir) */
.hoja-inferior {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: var(--ancho-max);
  max-height: 94dvh;
  overflow-y: auto;
  padding: 8px 16px calc(16px + var(--seguro-abajo));
  border-radius: 22px 22px 0 0;
  background: var(--blanco);
  box-shadow: var(--sombra-alta);
  animation: subir .24s ease-out;
}
.hoja-inferior::before {
  content: "";
  flex: none;
  align-self: center;
  width: 42px;
  height: 5px;
  border-radius: 3px;
  background: #d4d4d8;
}
.hoja-cabecera { display: flex; align-items: center; gap: 10px; }
.hoja-cabecera h2 { flex: 1; min-width: 0; }
.hoja-cabecera > .btn-icono { margin-right: -8px; }

/* Lista vacía */
.vacio {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 20px;
  text-align: center;
  color: var(--sub);
}
.vacio .circulo { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: var(--marca-claro); color: var(--marca); margin-bottom: 4px; }
.vacio .circulo .ico { width: 28px; height: 28px; }
.vacio h3 { color: var(--texto); font-size: 17px; }
.vacio .btn { margin-top: 8px; }

/* Cargando… (bloque) */
.cargando:not(.btn) {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 16px;
  color: var(--sub);
  font-size: 15px;
}
.cargando:not(.btn)::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--borde);
  border-top-color: var(--marca);
  animation: girar .7s linear infinite;
}

/* ------------------------------------------------------------------ */
/* 9. Pasos 1-2-3 (Nueva venta)                                       */
/* ------------------------------------------------------------------ */
.pasos {
  display: flex;
  align-items: flex-start;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: paso;
}
.pasos li {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--sub);
  font-size: 13.5px;
  font-weight: 500;
  counter-increment: paso;
}
.pasos li::before {
  content: counter(paso);
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--borde-fuerte);
  border-radius: 50%;
  background: var(--blanco);
  color: var(--sub);
  font-size: 15px;
  font-weight: 700;
}
.pasos li::after {
  content: "";
  position: absolute;
  top: 16px;
  left: calc(50% + 22px);
  right: calc(-50% + 22px);
  height: 2px;
  border-radius: 2px;
  background: var(--borde-fuerte);
}
.pasos li:last-child::after { display: none; }
.pasos li.hecho { color: var(--texto); }
.pasos li.hecho::before { content: "✓"; border-color: var(--marca); background: var(--marca); color: var(--marca-texto); }
.pasos li.hecho::after { background: var(--marca); }
.pasos li.actual { color: var(--texto); font-weight: 700; }
.pasos li.actual::before { border-color: var(--marca); color: var(--marca); box-shadow: 0 0 0 4px var(--marca-claro); }

/* ------------------------------------------------------------------ */
/* 10. Filas de opciones (Ajustes) y listas editables                 */
/* ------------------------------------------------------------------ */
.opciones { margin: 0; padding: 0; list-style: none; border: 1px solid var(--borde); border-radius: var(--radio-grande); background: var(--blanco); overflow: hidden; }
.opcion {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 10px 12px 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--borde);
  background: var(--blanco);
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
}
.opciones > li:last-child > .opcion, .opciones > .opcion:last-child { border-bottom: 0; }
.opciones, .opciones > li { min-width: 0; }  /* BUG-073 (.opcion-texto ya tiene min-width:0) */
a.opcion, button.opcion { cursor: pointer; }
.opcion:active { background: var(--gris-suave); }
.opcion > .ico:first-child,
.opcion .opcion-icono { color: var(--marca); }
.opcion .opcion-icono { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--marca-claro); flex: none; }
.opcion-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.opcion-titulo { font-size: 16px; font-weight: 600; }
.opcion-sub { font-size: 13.5px; color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opcion > .ico:last-child { color: #b0b0b7; width: 20px; height: 20px; }
.opcion.inactiva .opcion-titulo { color: var(--sub); text-decoration: line-through; }

/* ------------------------------------------------------------------ */
/* Animaciones                                                        */
/* ------------------------------------------------------------------ */
@keyframes girar { to { transform: rotate(360deg); } }
@keyframes latir { 50% { opacity: .35; } }
@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }
@keyframes subir { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
