/* Sistema visual de Cabal — v1.
   Marca: "orden hecho visible". Naranja contenido sobre neutros cálidos.
   Fuente única de estilos para la UI web y el HTML standalone del CLI. */

:root {
  /* Marca */
  --naranja:        #E85D2A;  /* acento: fills, botones, titulares grandes (NO texto de cuerpo) */
  --naranja-deep:   #B8431A;  /* hover y texto en naranja (WCAG AA) */
  --naranja-claro:  #FBE9DF;  /* lavado / fondo tenue */
  --tinta:          #1C1A17;  /* texto principal */
  --papel:          #FAF7F2;  /* fondo */
  --gris-calido:    #6E6A63;  /* texto secundario */

  /* Superficies derivadas */
  --superficie:     #FFFFFF;
  --linea:          #ECE6DD;  /* bordes cálidos tenues */
  --linea-fuerte:   #DDD5C8;

  /* Semánticos (sobre neutros cálidos) */
  --ok-bg:   #E4F0E4;  --ok-fg:   #2E6B39;  --ok-line:   #57A05F;
  --warn-bg: #FBEFD3;  --warn-fg: #8A6310;  --warn-line: #D6A21E;
  --err-bg:  #FBE0DC;  --err-fg:  #B3261E;  --err-line:  #D24C3A;
  --info-bg: #E5ECF6;  --info-fg: #2C4B7C;

  --radio:   10px;
  --radio-sm: 6px;
  --sombra:  0 1px 3px rgba(28, 26, 23, 0.06), 0 1px 2px rgba(28, 26, 23, 0.04);
  --ancho:   1080px;

  --fuente-titulo: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --fuente-texto:  "Inter", -apple-system, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  font-family: var(--fuente-texto);
  color: var(--tinta);
  background: var(--papel);
  margin: 0;
  padding: 0;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Estructura ---------- */
.contenedor {
  max-width: var(--ancho);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
.contenedor.angosto { max-width: 640px; }

/* ---------- Encabezado de marca ---------- */
.cabal-header {
  border-bottom: 1px solid var(--linea);
  background: var(--papel);
}
.cabal-header .interior {
  max-width: var(--ancho);
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.marca {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--fuente-titulo);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  color: var(--tinta);
  text-decoration: none;
}
.marca .punto {
  width: 0.6em;
  height: 0.6em;
  border-radius: 2px;
  background: var(--naranja);
  display: inline-block;
}
.marca .producto {
  font-family: var(--fuente-texto);
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--gris-calido);
  padding-left: 0.9rem;
  margin-left: 0.2rem;
  border-left: 1px solid var(--linea-fuerte);
}

/* ---------- Tipografía ---------- */
h1 {
  font-family: var(--fuente-titulo);
  font-weight: 600;
  font-size: 1.7rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.4rem;
}
.lead { color: var(--gris-calido); margin-top: 0; font-size: 1.02rem; }

/* ---------- Tarjeta / formulario ---------- */
.card {
  background: var(--superficie);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 1.6rem;
}
.card.subida { margin-top: 1.75rem; }

label { display: block; font-weight: 600; margin-bottom: 0.55rem; font-size: 0.95rem; }

input[type="file"] {
  display: block;
  width: 100%;
  padding: 1.25rem;
  border: 1.5px dashed var(--linea-fuerte);
  border-radius: var(--radio-sm);
  background: var(--papel);
  margin-bottom: 1.1rem;
  font-family: var(--fuente-texto);
  color: var(--gris-calido);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
input[type="file"]:hover { border-color: var(--naranja); background: var(--naranja-claro); }

button, .boton {
  font-family: var(--fuente-texto);
  background: var(--naranja);
  color: #fff;
  border: 0;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radio-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s ease;
}
button:hover, .boton:hover { background: var(--naranja-deep); }

.hint { font-size: 0.85rem; color: var(--gris-calido); margin-top: 0.6rem; }

.error {
  background: var(--err-bg);
  color: var(--err-fg);
  padding: 0.7rem 0.9rem;
  border-radius: var(--radio-sm);
  margin-bottom: 1rem;
  border-left: 3px solid var(--err-line);
  font-size: 0.92rem;
}

/* ---------- Resumen de resultados ---------- */
.resumen {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0.3rem 0 1.5rem;
  color: var(--gris-calido);
}
.resumen .total-num { font-family: var(--fuente-titulo); font-weight: 600; color: var(--tinta); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.valido,  .badge.vigente   { background: var(--ok-bg);   color: var(--ok-fg); }
.badge.observaciones              { background: var(--warn-bg); color: var(--warn-fg); }
.badge.invalido,
.badge.cancelado, .badge.no-encontrado { background: var(--err-bg);  color: var(--err-fg); }

/* ---------- Acciones ---------- */
.acciones { margin-bottom: 1.5rem; }
.volver {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--naranja-deep);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}
.volver:hover { text-decoration: underline; }

/* ---------- Tabla ---------- */
.tabla-wrap {
  background: var(--superficie);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  overflow: hidden;
}
table { border-collapse: collapse; width: 100%; }
th, td {
  text-align: left;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--linea);
  vertical-align: top;
}
th {
  background: var(--papel);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gris-calido);
  font-weight: 700;
  position: sticky;
  top: 0;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr.valido td:first-child        { box-shadow: inset 3px 0 0 var(--ok-line); }
tbody tr.observaciones td:first-child { box-shadow: inset 3px 0 0 var(--warn-line); }
tbody tr.invalido td:first-child      { box-shadow: inset 3px 0 0 var(--err-line); }
tbody tr:hover { background: #FBF8F3; }

.mono {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.82rem;
  color: var(--gris-calido);
}
.total { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.obs {
  font-size: 0.8rem;
  margin-top: 0.4rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radio-sm);
  background: var(--warn-bg);
  color: var(--warn-fg);
}
.obs.invalido { background: var(--err-bg); color: var(--err-fg); }

/* ---------- Clasificación ---------- */
.clasif {
  margin-top: 0.5rem;
  padding: 0.5rem 0.7rem;
  background: var(--papel);
  border: 1px solid var(--linea);
  border-radius: var(--radio-sm);
  font-size: 0.8rem;
}
.clasif-row { padding: 0.3rem 0; border-top: 1px solid var(--linea); }
.clasif-row:first-child { border-top: 0; }
.clasif .desc { font-weight: 600; color: var(--tinta); }
.clasif .cuenta {
  color: var(--naranja-deep);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}
.clasif .razon { color: var(--gris-calido); font-style: italic; margin-top: 0.2rem; }
.clasif .alerta { color: var(--warn-fg); margin-top: 0.2rem; }

.iva, .conf {
  display: inline-block;
  border-radius: 4px;
  font-size: 0.72rem;
  margin-left: 0.3rem;
  font-weight: 600;
}
.corte-69b {
  font-size: 0.8rem;
  color: #5A554D;
  margin: 0.4rem 0 0.8rem;
}

.iva { padding: 0.1rem 0.4rem; }
.iva.si          { background: var(--ok-bg);   color: var(--ok-fg); }
.iva.no          { background: var(--err-bg);  color: var(--err-fg); }
.iva.no_aplica,
.iva.tasa_cero,
.iva.exento,
.iva.no_objeto   { background: #ECE8E1;        color: #5A554D; }
.iva.revisar,
.iva.parcial,
.iva.pendiente_rep { background: var(--warn-bg); color: var(--warn-fg); }
.iva.pendiente_llm { background: var(--info-bg); color: var(--info-fg); }

.conf {
  padding: 0.05rem 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.68rem;
}
.conf.alta  { background: var(--info-bg); color: var(--info-fg); }
.conf.media { background: var(--warn-bg); color: var(--warn-fg); }
.conf.baja  { background: var(--err-bg);  color: var(--err-fg); }

/* ---------- Pie ---------- */
.pie {
  margin-top: 2rem;
  color: var(--gris-calido);
  font-size: 0.8rem;
  text-align: center;
}
.pie .marca-min { color: var(--naranja-deep); font-weight: 600; }

/* ---------- Firma de marca: el "poner en orden" (entrada que alinea) ---------- */
@keyframes alinear {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.alinear { animation: alinear 0.45s ease both; }
tbody tr.alinear:nth-child(1) { animation-delay: 0.02s; }
tbody tr.alinear:nth-child(2) { animation-delay: 0.05s; }
tbody tr.alinear:nth-child(3) { animation-delay: 0.08s; }
tbody tr.alinear:nth-child(4) { animation-delay: 0.11s; }
tbody tr.alinear:nth-child(n+5) { animation-delay: 0.14s; }

@media (prefers-reduced-motion: reduce) {
  .alinear { animation: none; }
}

@media (max-width: 640px) {
  .contenedor { padding: 1.25rem 1rem 3rem; }
  .marca .producto { display: none; }
  th, td { padding: 0.5rem 0.6rem; }
}

/* ---------- Campo de RFC del contribuyente ---------- */
.campo-rfc {
  display: block;
  width: 100%;
  max-width: 22rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--linea-fuerte);
  border-radius: var(--radio-sm);
  background: var(--superficie);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tinta);
  transition: border-color 0.15s ease;
}
.campo-rfc:focus { outline: none; border-color: var(--naranja); }
.campo-rfc::placeholder { color: var(--gris-calido); opacity: 0.6; text-transform: none; }
.opcional { font-weight: 400; color: var(--gris-calido); font-size: 0.85rem; }
.hint-rfc { margin-bottom: 1.4rem; max-width: 40rem; }

/* Cerrar sesión: es una acción, así que va en un form, pero visualmente es un
   enlace discreto — no compite con "Procesar lote", que es lo que se viene a hacer. */
.salir { margin-top: 1.6rem; text-align: right; }
.salir .enlace {
  background: none;
  border: none;
  padding: 0;
  width: auto;
  font-size: 0.85rem;
  color: var(--gris-calido);
  text-decoration: underline;
  cursor: pointer;
}
.salir .enlace:hover { color: var(--tinta); }

/* Barra de progreso del lote. Sin JavaScript: la página se recarga sola con un
   meta refresh, así que el ancho lo pinta el servidor en cada pasada. */
.barra {
  height: 0.7rem;
  background: var(--linea);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.barra-relleno {
  height: 100%;
  background: var(--naranja);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.progreso-cifras { margin: 0 0 0.4rem; font-size: 1.05rem; }
