/* =====================================================================
   FLETEIMPORT · Estilos
   Fondo gris frío, chrome azul tinta, cifras tabulares.
   ===================================================================== */

:root {
  --tinta:    #14212E;
  --tinta-2:  #1E3244;
  --fondo:    #EEF1F4;
  --papel:    #FFFFFF;
  --linea:    #D3DAE1;
  --texto:    #22303C;
  --apagado:  #64748B;
  --pos:      #1B7A5A;
  --neg:      #A63D26;
  --deuda:    #9A6510;
  --foco:     #3B82C4;

  --r: 3px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font-family: "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--foco); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--foco);
  outline-offset: 2px;
}

/* --- Barra superior ------------------------------------------------ */

.barra {
  background: var(--tinta);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  flex-wrap: wrap;
}

.marca {
  color: #fff;
  font-weight: 600;
  letter-spacing: .2px;
  padding: 14px 0;
  white-space: nowrap;
}
.marca:hover { text-decoration: none; }
.marca span {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #8FA3B5;
  letter-spacing: .6px;
}

.nav {
  display: flex;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }

.nav a {
  color: #C3D0DB;
  padding: 16px 13px;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.nav a:hover { color: #fff; text-decoration: none; background: var(--tinta-2); }
.nav a.activo { color: #fff; border-bottom-color: var(--foco); }

.sesion {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #8FA3B5;
  white-space: nowrap;
}
.sesion a { color: #C3D0DB; }

/* --- Contenido ----------------------------------------------------- */

.contenido {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 20px 60px;
}

.titulo {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 20px;
}

h2 { font-size: 16px; font-weight: 600; margin: 28px 0 10px; }

.pie {
  text-align: center;
  color: var(--apagado);
  font-size: 12px;
  padding: 0 0 26px;
}

/* --- Avisos -------------------------------------------------------- */

.aviso {
  padding: 10px 14px;
  border-radius: var(--r);
  border-left: 3px solid var(--pos);
  background: var(--papel);
  margin: 0 0 18px;
}
.aviso.error { border-left-color: var(--neg); }
.aviso.info  { border-left-color: var(--foco); }

/* --- Cifras -------------------------------------------------------- */

.cifra {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  white-space: nowrap;
}
.cifra.pos  { color: var(--pos); }
.cifra.neg  { color: var(--neg); }
.cifra.cero { color: var(--apagado); }

/* --- Tarjetas y tablas --------------------------------------------- */

.panel {
  background: var(--papel);
  border: 1px solid var(--linea);
  border-radius: var(--r);
  padding: 18px 20px;
}

table.datos {
  width: 100%;
  border-collapse: collapse;
  background: var(--papel);
  border: 1px solid var(--linea);
  border-radius: var(--r);
}
table.datos th,
table.datos td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--linea);
}
table.datos th {
  font-size: 12px;
  font-weight: 600;
  color: var(--apagado);
  background: #F7F9FB;
}
table.datos td.num,
table.datos th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
table.datos tr:last-child td { border-bottom: none; }
table.datos tbody tr:hover { background: #F7F9FB; }

.vacio {
  color: var(--apagado);
  padding: 22px;
  text-align: center;
  background: var(--papel);
  border: 1px dashed var(--linea);
  border-radius: var(--r);
}

/* --- Posición financiera del inicio -------------------------------- */

.posicion {
  background: var(--papel);
  border: 1px solid var(--linea);
  border-radius: var(--r);
  padding: 26px 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 34px;
  align-items: flex-start;
}

.posicion .neta { min-width: 240px; }

.posicion .neta .rotulo {
  color: var(--apagado);
  font-size: 13px;
  margin-bottom: 2px;
}
.posicion .neta .valor {
  font-size: 42px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.desglose {
  flex: 1;
  min-width: 280px;
  border-collapse: collapse;
}
.desglose td {
  padding: 6px 0;
  border-bottom: 1px solid var(--linea);
}
.desglose td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.desglose tr:last-child td { border-bottom: none; }
.desglose .deuda td:last-child { color: var(--deuda); }

/* --- Formularios --------------------------------------------------- */

label { display: block; font-size: 13px; color: var(--apagado); margin-bottom: 4px; }

input[type=text], input[type=email], input[type=password],
input[type=date], input[type=number], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--linea);
  border-radius: var(--r);
  background: var(--papel);
  color: var(--texto);
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--foco);
  outline: none;
  box-shadow: 0 0 0 3px rgba(59,130,196,.15);
}

.campo { margin-bottom: 16px; }

.boton {
  display: inline-block;
  background: var(--tinta);
  color: #fff;
  border: none;
  border-radius: var(--r);
  padding: 10px 18px;
  font: inherit;
  cursor: pointer;
}
.boton:hover { background: var(--tinta-2); text-decoration: none; }

/* --- Login --------------------------------------------------------- */

.entrada {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--tinta);
}
.entrada .caja {
  background: var(--papel);
  border-radius: var(--r);
  padding: 32px;
  width: 100%;
  max-width: 360px;
}
.entrada h1 {
  font-size: 20px;
  margin: 0 0 4px;
}
.entrada .sub {
  color: var(--apagado);
  font-size: 13px;
  margin: 0 0 22px;
}
.entrada .boton { width: 100%; }

@media (max-width: 640px) {
  .barra { gap: 10px; padding: 0 12px; }
  .contenido { padding: 18px 12px 40px; }
  .posicion { padding: 20px; gap: 20px; }
  .posicion .neta .valor { font-size: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* --- Listados y formularios de mantenimiento ----------------------- */

.tenue { color: var(--apagado); }

.migas { font-size: 13px; color: var(--apagado); margin: -8px 0 18px; }

.filtros {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filtros-form {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 260px;
  max-width: 560px;
}
.filtros-form input[type=text] { flex: 1; }
.filtros-form select { width: auto; }

.boton.secundario {
  background: var(--papel);
  color: var(--texto);
  border: 1px solid var(--linea);
}
.boton.secundario:hover { background: #F7F9FB; }

/* Botón que se ve como enlace: para acciones que necesitan POST */
button.enlace {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--foco);
  cursor: pointer;
}
button.enlace:hover { text-decoration: underline; }

.en-linea { display: inline; }

td.acciones, th.acciones { white-space: nowrap; text-align: right; }
td.acciones a, td.acciones form { margin-left: 12px; }

tr.apagada td:not(.acciones) { opacity: .55; }

.marca-estado { font-size: 12px; }
.marca-estado.activo   { color: var(--pos); }
.marca-estado.inactivo { color: var(--apagado); }

.paginacion {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 13px;
}
.paginacion a { margin: 0 10px; }

/* Formulario */
.formulario { max-width: 780px; }

.rejilla {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0 18px;
}

.campo.ancho { max-width: 100%; }

.error-campo {
  color: var(--neg);
  font-size: 13px;
  margin: 4px 0 0;
}

.acciones-form {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--linea);
}

/* --- Productos y tarifas ------------------------------------------- */

.nota {
  color: var(--apagado);
  font-size: 13px;
  margin: 10px 0 0;
  max-width: 62ch;
}

.sin-tarifa { color: var(--deuda); font-size: 13px; }

.marca-estado.futura { color: var(--foco); }

/* --- Ficha de operación -------------------------------------------- */

.cabecera-ficha {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.pastilla {
  display: inline-block;
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 10px;
  background: #E4E9EE;
  color: var(--texto);
  margin-right: 8px;
}
.pastilla.planificada        { background: #E4E9EE; }
.pastilla.en_preparacion     { background: #DDE7F2; color: #274B6D; }
.pastilla.en_transito        { background: #D9E8F5; color: #1F5680; }
.pastilla.llegada            { background: #DCEBE2; color: #17624A; }
.pastilla.entrega_en_proceso { background: #DCEBE2; color: #17624A; }
.pastilla.cerrada            { background: #14212E; color: #fff; }
.pastilla.cancelada          { background: #F0DEDA; color: var(--neg); }

.resumen {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--linea);
  border: 1px solid var(--linea);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 8px;
}
.resumen > div {
  background: var(--papel);
  padding: 14px 16px;
}
.resumen .rot {
  display: block;
  font-size: 12px;
  color: var(--apagado);
  margin-bottom: 2px;
}
.resumen .val {
  font-size: 19px;
  font-variant-numeric: tabular-nums;
}

table.datos tfoot td {
  background: #F7F9FB;
  font-weight: 600;
  border-top: 2px solid var(--linea);
}

select.mini {
  padding: 4px 6px;
  font-size: 13px;
  width: auto;
}

.marca-variacion {
  color: var(--deuda);
  cursor: help;
  font-weight: 600;
}

.rejilla-alta {
  display: grid;
  grid-template-columns: 1.4fr 1.4fr .7fr .7fr 1.4fr;
  gap: 0 14px;
}
.rejilla-alta .campo { margin-bottom: 12px; }

@media (max-width: 820px) {
  .rejilla-alta { grid-template-columns: 1fr 1fr; }
}

.oculto { display: none; }

.cambio-estado {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.cambio-estado input[type=text] { flex: 1; min-width: 200px; }
.cambio-estado:last-child { margin-bottom: 0; }

.boton.peligro { background: var(--neg); }
.boton.peligro:hover { background: #8E3220; }

/* --- Cobranzas ------------------------------------------------------ */

input.aplicar {
  width: 110px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding: 5px 8px;
}

#totalCobro { font-variant-numeric: tabular-nums; }

/* --- Gastos --------------------------------------------------------- */

.formulario.ancho-total { max-width: 100%; }

.aviso.deuda { border-left-color: var(--deuda); }

.etiqueta-mixto {
  font-size: 11px;
  background: #F0E6D2;
  color: var(--deuda);
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
}

table.tabla-items input,
table.tabla-items select { padding: 5px 8px; font-size: 14px; }
table.tabla-items td { padding: 6px 8px; vertical-align: middle; }
table.tabla-items .importe { width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
table.tabla-items tfoot td { background: #F7F9FB; }
#sumaItems { font-variant-numeric: tabular-nums; font-weight: 600; }

.dif { font-size: 12px; font-weight: 400; margin-top: 2px; }
.dif.falta { color: var(--deuda); }
.dif.sobra { color: var(--neg); }

.reparto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  background: var(--linea);
  border: 1px solid var(--linea);
  border-radius: var(--r);
  overflow: hidden;
  margin: 4px 0 18px;
}
.reparto > div { background: #F7F9FB; padding: 12px 14px; }
.reparto .rot { display: block; font-size: 12px; color: var(--apagado); }
.reparto .val { font-size: 18px; font-variant-numeric: tabular-nums; }

/* --- Finanzas ------------------------------------------------------- */

.filtros-linea {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.filtros-linea .campo { margin-bottom: 0; min-width: 150px; }
.filtros-linea .boton { white-space: nowrap; }

input.solo-lectura {
  background: #F7F9FB;
  color: var(--apagado);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* --- Reportes ------------------------------------------------------- */

td.celda-barra { padding: 8px 12px; }

.barra {
  display: block;
  height: 9px;
  background: var(--foco);
  border-radius: 2px;
  min-width: 2px;
  margin-bottom: 2px;
}
.barra:last-child { margin-bottom: 0; }
.barra.mala  { background: var(--neg); }
.barra.entra { background: var(--pos); }
.barra.sale  { background: var(--neg); }
.barra.deuda { background: var(--deuda); }

.leyenda {
  font-size: 12px;
  color: var(--apagado);
  margin: 8px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.muestra {
  display: inline-block;
  width: 20px;
  height: 8px;
  border-radius: 2px;
  margin-left: 12px;
}
.leyenda .muestra:first-child { margin-left: 0; }
.muestra.entra { background: var(--pos); }
.muestra.sale  { background: var(--neg); }
.muestra.deuda { background: var(--deuda); }

table.tabla-compacta { margin-bottom: 14px; }
table.tabla-compacta th { font-size: 13px; color: var(--texto); }
table.tabla-compacta td { padding: 6px 12px; }
