/* J&J Cartera — hoja de estilos única, mobile first. */
:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --ink: #0e1a26;
  --muted: #5d6b79;
  --line: #dbe2ea;
  --brand: #10344f;
  --brand-2: #1c4f78;
  --brand-soft: #e6eef7;
  --warn: #9a5600;
  --warn-soft: #fdf0dc;
  --bad: #a3261b;
  --bad-soft: #fbe9e6;
  --ok: #0d6b45;
  --ok-soft: #e6f2eb;
  --radio: 18px;
  --sombra: 0 1px 2px rgba(16, 52, 79, .05), 0 10px 26px rgba(16, 52, 79, .06);
  --nav: 64px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom) + 20px);
}

h1, h2, h3, p { margin: 0; }
a { color: var(--brand); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.num, .kpi-v, .hero-v, .dato strong, .prev-fila strong { font-variant-numeric: tabular-nums; }

.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* --------------------------------------------------------------- cabecera */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: rgba(243, 241, 234, .86);
  backdrop-filter: saturate(1.2) blur(14px);
  border-bottom: 1px solid rgba(226, 223, 212, .8);
}
.top-in { display: flex; align-items: center; justify-content: space-between; min-height: 62px; gap: 12px; }
.marca { display: flex; align-items: center; gap: 10px; }
.logo-mini {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--brand); color: #fff;
  font-size: 12px; font-weight: 800; letter-spacing: -.02em;
}
.eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
}
#marca { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.derecha { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.punto { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
body.sin-red .punto { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }

/* ----------------------------------------------------------------- inicio */
.hero {
  margin-top: 16px;
  padding: 22px 20px 18px;
  border-radius: 24px;
  color: #fff;
  background: linear-gradient(150deg, #17476b 0%, #0f3350 62%, #0b2840 100%);
  box-shadow: 0 18px 40px -22px rgba(12, 63, 42, .8);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -80px;
  width: 210px; height: 210px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .14), transparent 68%);
}
.hero .eyebrow { color: rgba(255, 255, 255, .62); }
.hero-v { font-size: 36px; font-weight: 750; letter-spacing: -.03em; line-height: 1.1; margin-top: 4px; }
.hero-v.chico { font-size: 30px; color: var(--ink); }
.hero-p { font-size: 13px; color: rgba(255, 255, 255, .68); margin-top: 6px; }
.cabeza .hero-p { color: var(--muted); }
.hero-fila {
  display: flex; gap: 24px; margin-top: 18px; padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .14);
}
.hero-fila div { display: flex; flex-direction: column; gap: 2px; }
.hero-fila span { font-size: 11px; color: rgba(255, 255, 255, .6); }
.hero-fila strong { font-size: 17px; font-weight: 650; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.grid2.apretado { gap: 10px; margin-top: 10px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 13px 14px; display: flex; flex-direction: column; gap: 2px;
}
.kpi-t { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.kpi-v { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.kpi-p { font-size: 11.5px; color: var(--muted); }
.kpi.warn .kpi-v { color: var(--warn); }
.kpi.bad .kpi-v { color: var(--bad); }

.seccion { margin-top: 22px; }
.seccion-t { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.seccion-t h2 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.seccion-t a { font-size: 13px; font-weight: 600; text-decoration: none; }
.seccion-t .sec { font-size: 13px; color: var(--muted); }

.fila {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: 15px; padding: 12px 14px; margin-bottom: 9px;
  text-decoration: none; color: inherit; box-shadow: var(--sombra);
  transition: transform .12s ease;
}
.fila:active { transform: scale(.99); }
.fila.estatica { box-shadow: none; }

/* Prendas con foto: la fila pasa a ser miniatura + texto. */
.fila:has(.miniatura) { display: flex; align-items: center; gap: 12px; }
.fila-cuerpo { flex: 1; min-width: 0; }
.miniatura {
  width: 52px; height: 52px; flex: 0 0 52px; border-radius: 11px;
  object-fit: cover; background: var(--brand-soft); border: 1px solid var(--line);
}
.miniatura.vacia {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 20px;
}
.foto-card { width: 100%; max-height: 220px; object-fit: cover; border-radius: 13px; margin: 10px 0; display: block; }
.foto-grande { width: 100%; max-height: 58vh; object-fit: contain; border-radius: 13px; background: var(--brand-soft); display: block; }
.foto-grande.sin-foto {
  min-height: 190px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 6px; color: var(--muted); font-size: 34px;
}
.foto-grande.sin-foto p { font-size: 13px; margin: 0; }
.btn.block { display: flex; align-items: center; justify-content: center; width: 100%; margin-top: 10px; cursor: pointer; }
.aviso-mora-inline { color: var(--warn); font-size: 12.5px; margin: 8px 0 0; }
.fila-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.nombre { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.num { font-size: 15.5px; font-weight: 700; }
.fila-sub { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.sec { color: var(--muted); }
.mal { color: var(--bad) !important; }

.pill {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 999px;
  background: #e6eaf0; color: var(--muted); white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.muted { background: #e6eaf0; color: var(--muted); }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 14px; padding: 12px 14px; border-radius: 15px;
  background: var(--warn-soft); border: 1px solid #f0d5a8;
  color: #7a4400; text-decoration: none;
}
.banner strong { font-size: 13.5px; }
.banner span { font-size: 12.5px; font-weight: 600; white-space: nowrap; }

.barras { display: flex; align-items: flex-end; gap: 10px; margin-top: 8px; }
.barra { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.barra-pista { height: 92px; display: flex; align-items: flex-end; background: #e6eaf0; border-radius: 8px; overflow: hidden; }
.barra-c { width: 100%; border-radius: 8px; background: linear-gradient(180deg, var(--brand-2), var(--brand)); }
.barra span { font-size: 10.5px; color: var(--muted); text-align: center; }

/* ---------------------------------------------------------------- listas */
.buscador {
  display: flex; align-items: center; gap: 8px; margin-top: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0 12px;
}
.buscador span { color: var(--muted); font-size: 19px; }
.buscador input { flex: 1; border: 0; background: transparent; padding: 12px 0; font-size: 16px; color: var(--ink); outline: none; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 8px 14px; font-size: 13.5px; font-weight: 500;
  color: var(--ink); cursor: pointer; font-family: inherit;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

.contador { font-size: 12.5px; color: var(--muted); margin: 8px 0; }
.vacio, .vacio-suave { color: var(--muted); font-size: 14px; text-align: center; padding: 26px 10px; }
.vacio-suave { padding: 16px 4px; text-align: left; }

.fab {
  position: fixed; z-index: 25; right: 18px;
  bottom: calc(var(--nav) + env(safe-area-inset-bottom) + 18px);
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--brand); color: #fff; text-decoration: none;
  display: grid; place-items: center; font-size: 30px; font-weight: 300;
  box-shadow: 0 14px 30px -12px rgba(15, 81, 50, .75);
}

/* ---------------------------------------------------------------- detalle */
.volver { display: inline-block; margin: 16px 0 10px; font-size: 14px; font-weight: 600; text-decoration: none; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radio); padding: 16px; margin-bottom: 12px; box-shadow: var(--sombra); }
.card.cabeza { padding: 18px 16px; }
.titulo { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.titulo-chico { font-size: 16px; font-weight: 650; margin: 4px 0; }
.titulo-pagina { font-size: 26px; font-weight: 750; letter-spacing: -.03em; margin: 8px 0 12px; }
.progreso { height: 8px; border-radius: 999px; background: #e6eaf0; overflow: hidden; margin: 14px 0 6px; }
.progreso div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand-2), var(--brand)); }
.acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.dato { background: #f7f9fb; border-radius: 12px; padding: 9px 11px; display: flex; flex-direction: column; gap: 1px; }
.dato span { font-size: 11px; color: var(--muted); }
.dato strong { font-size: 15px; font-weight: 650; }
.nota { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.pie-nota { font-size: 11.5px; color: var(--muted); text-align: center; margin: 20px 0 8px; }
.aviso-mora { border-color: #f0d5a8; background: #fffaf0; }

.ficha { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0 0; }
.ficha div { min-width: 0; }
.ficha dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.ficha dd { margin: 2px 0 0; font-size: 14px; overflow-wrap: anywhere; }

/* --------------------------------------------------------------- botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: #fff; border: 0; border-radius: 14px;
  padding: 13px 18px; font-size: 15.5px; font-weight: 600; font-family: inherit;
  text-decoration: none; cursor: pointer; min-height: 48px; flex: 1 1 auto;
}
.btn:active { background: #0b2740; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.peligro { background: var(--bad); }
.btn.sm { padding: 9px 14px; min-height: 40px; font-size: 14px; }
.btn.archivo { position: relative; overflow: hidden; }
.btn:disabled { opacity: .55; }

/* --------------------------------------------------------------- formularios */
form label { display: block; margin-top: 14px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
form label:first-child { margin-top: 0; }
input, select, textarea {
  width: 100%; margin-top: 5px; padding: 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: #f8fafc; color: var(--ink);
  font-size: 16px; font-family: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(26, 107, 72, .12); }
label.check { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-size: 14px; color: var(--ink); font-weight: 500; }
label.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); }
.preview { background: var(--brand-soft); border-radius: 12px; padding: 11px 13px; margin-top: 14px; font-size: 13.5px; }
.preview > span { color: var(--muted); }
.prev-fila { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.prev-fila.total { border-top: 1px dashed rgba(15, 81, 50, .25); margin-top: 5px; padding-top: 6px; font-weight: 650; }

/* ------------------------------------------------------------------- menú */
.resumen-mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.resumen-mini div { display: flex; flex-direction: column; gap: 1px; }
.resumen-mini span { font-size: 10.5px; color: var(--muted); }
.resumen-mini strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.menu { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radio); overflow: hidden; box-shadow: var(--sombra); }
.menu a {
  display: flex; align-items: center; gap: 12px; padding: 13px 15px;
  color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 500;
  border-bottom: 1px solid var(--line);
}
.menu a:last-child { border-bottom: 0; }
.menu .ico { width: 30px; height: 30px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 15px; }
.menu em { margin-left: auto; font-style: normal; color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------------ bienvenida */
.bienvenida { text-align: center; padding: 42px 6px 12px; }
.logo {
  width: 84px; height: 84px; border-radius: 24px; margin: 0 auto 20px;
  background: var(--brand); color: #fff; display: grid; place-items: center;
  font-size: 25px; font-weight: 800; letter-spacing: -.03em;
  box-shadow: 0 20px 40px -20px rgba(15, 81, 50, .7);
}
.bienvenida h1 { font-size: 33px; line-height: 1.12; letter-spacing: -.035em; font-weight: 780; }
.bienvenida p { color: var(--muted); font-size: 14.5px; margin: 14px 0 22px; }
.bienvenida .btn { margin-bottom: 9px; width: 100%; }

/* ------------------------------------------------------------------ navegación */
.tabbar {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 760px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .93);
  backdrop-filter: saturate(1.2) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 10px; text-decoration: none; color: var(--muted);
  font-size: 10.5px; font-weight: 600;
}
.tabbar a.activo { color: var(--brand); }
.tabbar a.activo svg { stroke-width: 2.1; }

/* ------------------------------------------------------------------ hoja modal */
dialog {
  padding: 0; border: 0; width: 100%; max-width: 560px;
  margin: auto auto 0; border-radius: 24px 24px 0 0;
  background: var(--surface); color: var(--ink);
  max-height: 92vh;
}
dialog::backdrop { background: rgba(8, 20, 14, .48); backdrop-filter: blur(2px); }
.hoja-in { padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
.hoja-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.hoja-head h2 { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.x {
  background: #e6eaf0; border: 0; border-radius: 50%; width: 34px; height: 34px;
  font-size: 21px; line-height: 1; color: var(--muted); cursor: pointer; flex: 0 0 auto;
}
.hoja-in > .btn { width: 100%; margin-top: 16px; }
.hoja-in .chips { padding-bottom: 0; }

/* ---------------------------------------------------------------------- toast */
#toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(var(--nav) + env(safe-area-inset-bottom) + 22px);
  transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
  background: #0d2338; color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; max-width: calc(100% - 40px);
  box-shadow: 0 16px 30px -14px rgba(0, 0, 0, .6);
  transition: opacity .18s ease, transform .18s ease;
}
#toast.ver { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 720px) {
  .hero-v { font-size: 42px; }
  .bienvenida h1 { font-size: 40px; }
  .tabbar { border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(16, 32, 24, .06); }
  .fab { right: calc(50% - 380px + 18px); }
}

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

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

/* ------------------------------------------------------------------- recibo */
.recibo { border: 1px dashed var(--line); }
.recibo-cab {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 12px;
}
.recibo-cab .titulo { margin: 0; }
.recibo-num { text-align: right; font-size: 11px; color: var(--muted); }
.recibo-num strong { display: block; font-size: 15px; color: var(--ink); }
.recibo-monto { font-size: 32px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 2px; }
.recibo-pie { margin-top: 16px; }
.recibo-firma {
  margin-top: 26px; width: 58%; border-top: 1px solid var(--ink);
  padding-top: 5px; font-size: 11px; color: var(--muted);
}

@media print {
  .top, .tabbar, .volver, .acciones, #toast, .banner-respaldo, .fab { display: none !important; }
  body { background: #fff; }
  main.wrap { max-width: none; padding: 0; }
  .card { box-shadow: none !important; border: none !important; }
  .recibo { border: none; }
}
.texto-copiar {
  width: 100%; font: inherit; font-size: 13px; line-height: 1.45;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px;
  background: var(--surface); color: var(--ink); resize: vertical;
}