/* Sistema de diseño ARPEA (portado de arpea-resico) — calma, jerarquía y una
   sola cosa importante por pantalla. La marca (verde/dorado) acentúa; el
   lienzo es silencioso. */
:root {
  --gold: #966f31;
  --gold-dark: #775725;
  --gold-soft: #f6efe3;
  --arpea-green: #0a4a3c;
  --arpea-green-deep: #063d32;
  --arpea-green-soft: #e9f2ee;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --paper: #ffffff;
  --field: #ffffff;
  --bg: #f6f6f4;
  --line: #e7e4dd;
  --hairline: rgba(29, 29, 31, .08);
  --danger: #b3382f;
  --danger-bg: #fdf0ee;
  --success: #2e7d4f;
  --success-bg: #edf7f0;
  --warn-ink: #8a6d1f;
  --warn-bg: #f6efdc;
  --shadow: 0 1px 2px rgba(29, 29, 31, .04), 0 10px 30px rgba(29, 29, 31, .05);
  --radius-card: 16px;
  --radius-control: 10px;
  --focus-ring: 0 0 0 4px rgba(10, 74, 60, .14);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0 auto;
  max-width: 64rem;
  min-width: 320px;
  padding: 26px 20px 64px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  letter-spacing: -.006em;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

h1, h2, h3, p { margin-top: 0; }

/* ── Encabezado ─────────────────────────────────────────────────────────── */

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

.marca {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.marca .logo-arpea {
  width: 52px;
  height: 52px;
  flex: none;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--arpea-green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.marca h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.022em;
  line-height: 1.2;
}

.subtitulo {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.controles {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ── Controles y ficha ──────────────────────────────────────────────────── */

label {
  display: grid;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: #55544f;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--field);
  color: var(--ink);
  padding: 9px 12px;
  min-height: 40px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--arpea-green);
  box-shadow: var(--focus-ring);
}

.controles label { min-width: 11rem; }

.ficha {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 12px;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 14px;
}

/* ── Expedientes ────────────────────────────────────────────────────────── */

.expedientes {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  margin-bottom: 14px;
}

.expedientes label { flex: 1 1 16rem; }
.expedientes-acciones { display: flex; gap: 8px; }

.zona-botones {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}
.zona-carga .zona-botones button { margin-top: 0; }

/* ── Zona de carga ──────────────────────────────────────────────────────── */

.zona-carga {
  border: 2px dashed var(--line);
  border-radius: var(--radius-card);
  background: var(--paper);
  padding: 26px 20px;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
}

.zona-carga.arrastrando {
  border-color: var(--arpea-green);
  background: var(--arpea-green-soft);
}

.zona-carga p { margin: 4px 0; }
.zona-carga .nota, .nota { color: var(--muted); font-size: 13px; }
.zona-carga button { margin-top: 12px; }

/* ── Botones genéricos ──────────────────────────────────────────────────── */

.boton-primario,
.boton-secundario {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -.01em;
  white-space: nowrap;
  transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
}

.boton-primario:active,
.boton-secundario:active { transform: scale(.98); }

.boton-primario:focus-visible,
.boton-secundario:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.boton-primario { background: var(--arpea-green); color: #fff; }
.boton-primario:hover { background: var(--arpea-green-deep); }

.boton-secundario { background: rgba(29, 29, 31, .06); color: var(--ink); }
.boton-secundario:hover { background: rgba(29, 29, 31, .1); }

/* ── Aviso de aproximado (regla de producto: siempre visible) ───────────── */

.aviso-aproximado {
  background: var(--gold-soft);
  border: 1px solid #e3d2b1;
  border-left: 4px solid var(--gold);
  border-radius: var(--radius-control);
  color: #5c4a26;
  padding: 12px 16px;
  margin: 14px 0;
  font-size: 13px;
}

.aviso-aproximado strong { color: var(--gold-dark); }

/* ── Tarjetas de cifras ─────────────────────────────────────────────────── */

.tarjetas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.tarjeta {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  min-width: 0;
}

.tarjeta h3 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.tarjeta .cifra {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.022em;
  font-variant-numeric: tabular-nums;
  color: var(--arpea-green);
}

.tarjeta .detalle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12.5px;
}

/* ── Bloques de contenido ───────────────────────────────────────────────── */

.bloque,
section.bloque {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin: 14px 0;
}

.bloque h2,
section.bloque h2 {
  margin: 0 0 4px;
  font-size: 16.5px;
  font-weight: 650;
  letter-spacing: -.014em;
}

.bloque .explica,
section.bloque .explica {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 12px;
}

/* ── Tablas ─────────────────────────────────────────────────────────────── */

.tabla-desplazable { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

th {
  background: var(--paper);
  color: var(--muted);
  text-align: left;
  padding: 9px 10px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}

td {
  border-bottom: 1px solid var(--hairline);
  padding: 9px 10px;
  vertical-align: top;
}

tbody tr:hover { background: rgba(29, 29, 31, .02); }

td.num, th.num { text-align: right; white-space: nowrap; }

tr.total td {
  font-weight: 700;
  color: var(--arpea-green);
  border-top: 2px solid var(--arpea-green);
  border-bottom: 0;
}

/* ── Chips y semáforo ───────────────────────────────────────────────────── */

.chip,
.semaforo-verde,
.semaforo-ambar,
.semaforo-rojo {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.chip { background: var(--arpea-green-soft); color: var(--arpea-green); }
.chip.neutro { background: #ece9e2; color: #5f5a50; }
.chip.dorado { background: var(--gold-soft); color: var(--gold-dark); }

.semaforo-verde { background: var(--success-bg); color: var(--success); }
.semaforo-ambar { background: var(--warn-bg); color: var(--warn-ink); }
.semaforo-rojo { background: var(--danger-bg); color: var(--danger); }

/* ── Barra de progreso ──────────────────────────────────────────────────── */

.barra-progreso {
  height: 8px;
  border-radius: 999px;
  background: rgba(29, 29, 31, .08);
  overflow: hidden;
}

.barra-progreso > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--arpea-green);
  transition: width .25s ease;
}

.barra-progreso.dorada > span { background: var(--gold); }

/* ── Avisos y errores ───────────────────────────────────────────────────── */

.aviso {
  background: var(--gold-soft);
  border: 1px solid #e3d2b1;
  border-left: 4px solid var(--gold);
  border-radius: var(--radius-control);
  color: #5c4a26;
  padding: 10px 14px;
  margin: 8px 0;
  font-size: 13px;
}

.aviso strong { display: block; color: var(--gold-dark); }

.error-archivo {
  background: var(--danger-bg);
  border: 1px solid #f0cdc9;
  border-radius: var(--radius-control);
  color: var(--danger);
  padding: 8px 12px;
  margin: 6px 0;
  font-size: 13px;
}

.pie-carga {
  color: var(--muted);
  font-size: 13px;
  margin-top: 12px;
}

/* ── Impresión: reporte limpio, sin controles ni sombras ────────────────── */

@media print {
  body {
    max-width: none;
    padding: 0;
    background: #fff;
    font-size: 12px;
  }

  .controles,
  .ficha,
  .zona-carga,
  .boton-primario,
  .boton-secundario,
  .no-imprimir,
  button {
    display: none !important;
  }

  .tarjeta,
  .bloque,
  section.bloque,
  .aviso,
  .aviso-aproximado {
    box-shadow: none;
    border-color: #c9c5bc;
    break-inside: avoid;
  }

  .tabla-desplazable { overflow: visible; }
  tbody tr:hover { background: transparent; }
  th { position: static; }
  .error-archivo { display: none !important; }
}

/* ── Piezas de integración (botones de entregables, buscador, comparativo) ─ */

.acciones-entregables {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}

.filtros-buscador {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

@media (max-width: 720px) {
  .filtros-buscador { grid-template-columns: 1fr 1fr; }
}

tr.fila-cfdi { cursor: pointer; }
tr.fila-cfdi:hover { background: var(--arpea-green-soft); }
tr.fila-cfdi.cancelado td { color: var(--muted); text-decoration: line-through; }

.detalle-cfdi {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius-control);
  padding: 14px 16px;
  background: var(--gold-soft);
}

/* Comparativo: la anomalía debe saltar a la vista sin leer los números. */
td.anomalia {
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 700;
}

tr.sin-movimientos td { color: var(--muted); }
