:root {
  --fondo: #101418;
  --panel: #1A2026;
  --panel2: #232A31;
  --linea: #2E363E;
  --texto: #F2F4F5;
  --tenue: #9AA4AD;
  --verde: #2FB57C;
  --rojo: #E5604D;
  --ambar: #F0A030;
  --azul: #5B8DEF;
  --radio: 14px;
  --abajo: env(safe-area-inset-bottom, 0px);
  --arriba: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fondo); color: var(--texto); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 22px 0 10px; }
a { color: var(--azul); }
.tenue { color: var(--tenue); }
.chico { font-size: .82rem; }
.num { font-variant-numeric: tabular-nums; }
.verde { color: var(--verde); }
.rojo { color: var(--rojo); }
.ambar { color: var(--ambar); }

/* ---------- Acceso ---------- */
.acceso { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.acceso .tarjeta { width: 100%; max-width: 360px; }
.acceso h1 { font-size: 1.6rem; margin-top: 14px; }
.logo { width: 56px; height: 56px; border-radius: 16px; background: var(--verde); color: #08130D; display: grid; place-items: center; font-size: 32px; font-weight: 800; }

/* ---------- Estructura ---------- */
.barra {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--arriba)) 18px 12px; background: rgba(16, 20, 24, .92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--linea);
}
.barra h1 { font-size: 1.3rem; }
.vista { padding: 14px 16px calc(110px + var(--abajo)); max-width: 720px; margin: 0 auto; }
.cargando { color: var(--tenue); text-align: center; margin-top: 40px; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: space-around;
  background: rgba(22, 27, 32, .96); backdrop-filter: blur(12px); border-top: 1px solid var(--linea);
  padding: 6px 4px calc(6px + var(--abajo));
}
.nav a { flex: 1; text-align: center; color: var(--tenue); text-decoration: none; font-size: .68rem; padding: 4px 0; }
.nav a span { display: block; font-size: 1.15rem; line-height: 1.3; }
.nav a.activo { color: var(--texto); }
.fab {
  position: fixed; right: 18px; bottom: calc(76px + var(--abajo)); z-index: 7; width: 58px; height: 58px; border-radius: 50%;
  border: 0; background: var(--verde); color: #08130D; font-size: 34px; line-height: 1; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45); cursor: pointer;
}
.icono { background: none; border: 0; color: var(--tenue); font-size: 1.35rem; cursor: pointer; padding: 4px 8px; }

/* ---------- Tarjetas ---------- */
.tarjeta-p { background: var(--panel); border: 1px solid var(--linea); border-radius: var(--radio); padding: 14px 16px; margin-bottom: 12px; }
.grande { font-size: 2rem; font-weight: 750; letter-spacing: -.02em; }
.fila { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fila > :first-child { min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini { background: var(--panel); border: 1px solid var(--linea); border-radius: var(--radio); padding: 12px 14px; cursor: pointer; }
.mini .t { font-size: .78rem; color: var(--tenue); display: flex; align-items: center; gap: 6px; }
.mini .v { font-size: 1.25rem; font-weight: 700; margin-top: 2px; }
.punto { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.etapa { display: inline-block; font-size: .75rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--panel2); color: var(--ambar); }

.barra-p { height: 8px; border-radius: 99px; background: var(--panel2); overflow: hidden; margin-top: 8px; }
.barra-p i { display: block; height: 100%; border-radius: 99px; background: var(--verde); }
.meta { margin-bottom: 14px; }
.meta:last-child { margin-bottom: 0; }
.meta .fila span:last-child { font-size: .85rem; color: var(--tenue); }

.lista { background: var(--panel); border: 1px solid var(--linea); border-radius: var(--radio); overflow: hidden; margin-bottom: 12px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--linea); }
.item:last-child { border-bottom: 0; }
.item .cuerpo { flex: 1; min-width: 0; }
.item .nombre { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: .8rem; color: var(--tenue); }
.item .monto { font-weight: 650; white-space: nowrap; text-align: right; }
.item.click { cursor: pointer; }
.vacio { padding: 18px 14px; color: var(--tenue); text-align: center; font-size: .9rem; }
.chip { font-size: .7rem; font-weight: 650; padding: 2px 7px; border-radius: 99px; background: var(--panel2); color: var(--tenue); white-space: nowrap; }
.chip.atrasado { background: rgba(229, 96, 77, .18); color: var(--rojo); }
.chip.listo { background: rgba(47, 181, 124, .16); color: var(--verde); }
.chip.pendiente { background: rgba(240, 160, 48, .16); color: var(--ambar); }
.chip.pagado { background: rgba(91, 141, 239, .16); color: var(--azul); }

.barras .b { margin-bottom: 9px; }
.barras .b .fila { font-size: .85rem; }
.barras .barra-p { height: 6px; margin-top: 4px; }
.barras .barra-p i { background: var(--azul); }

.captura { display: flex; gap: 8px; margin-bottom: 14px; }
.captura input { flex: 1; }

.selector-mes { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.selector-mes strong { text-transform: capitalize; }

/* ---------- Formularios ---------- */
label { display: block; font-size: .82rem; color: var(--tenue); margin-bottom: 12px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 12px 13px; font: inherit; font-size: 16px; color: var(--texto);
  background: var(--panel2); border: 1px solid var(--linea); border-radius: 11px; outline: none; -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--tenue) 50%), linear-gradient(135deg, var(--tenue) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input:focus, select:focus, textarea:focus { border-color: var(--verde); }
textarea { min-height: 110px; resize: vertical; }
.monto-input { font-size: 1.8rem; font-weight: 700; text-align: center; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 16px; border-radius: 11px;
  border: 1px solid var(--linea); background: var(--panel2); color: var(--texto); font: inherit; font-weight: 600; cursor: pointer;
}
.btn.primario { background: var(--verde); border-color: var(--verde); color: #08130D; }
.btn.peligro { color: var(--rojo); }
.btn.chico-b { padding: 7px 11px; font-size: .85rem; }
.btn.ancho { width: 100%; }
.btn:disabled { opacity: .5; }
.botones { display: flex; gap: 10px; margin-top: 6px; }
.botones .btn { flex: 1; }
.aviso { padding: 10px 12px; border-radius: 11px; background: var(--panel2); font-size: .88rem; margin: 10px 0; }
.aviso.error { background: rgba(229, 96, 77, .15); color: #FFB4A8; }
.aviso.bien { background: rgba(47, 181, 124, .14); color: #A9EBCB; }
.aviso.alerta { background: rgba(240, 160, 48, .14); color: #FFD9A0; }
.tabs { display: flex; gap: 6px; background: var(--panel2); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.tabs button { flex: 1; border: 0; background: none; color: var(--tenue); font: inherit; font-weight: 600; padding: 9px 4px; border-radius: 9px; cursor: pointer; font-size: .9rem; }
.tabs button.activo { background: var(--panel); color: var(--texto); }

/* ---------- Reparto ---------- */
.reparto .linea { display: grid; grid-template-columns: 1fr 120px; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--linea); }
.reparto .linea:last-child { border-bottom: 0; }
.reparto .linea input { margin: 0; padding: 8px 10px; text-align: right; font-weight: 650; }
.reparto .grupo { padding: 8px 14px; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--tenue); background: var(--panel2); }
.reparto .total { display: flex; justify-content: space-between; padding: 12px 14px; font-weight: 700; }

/* ---------- Hoja modal ---------- */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.hoja {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--panel); border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(22px + var(--abajo)); animation: sube .18s ease-out;
}
.hoja h3 { font-size: 1.15rem; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
@keyframes sube { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) { .modal { align-items: center; } .hoja { border-radius: 20px; } }
.opciones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opcion { background: var(--panel2); border: 1px solid var(--linea); border-radius: 14px; padding: 16px 12px; text-align: center; cursor: pointer; color: var(--texto); font: inherit; }
.opcion b { display: block; font-size: 1.5rem; margin-bottom: 4px; }

.toast {
  position: fixed; left: 50%; bottom: calc(150px + var(--abajo)); transform: translateX(-50%); z-index: 30; max-width: 90vw;
  background: #F2F4F5; color: #101418; padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: .9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4); white-space: pre-line;
}
.toast.error { background: var(--rojo); color: #fff; }
code, .codigo { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; word-break: break-all; background: var(--panel2); padding: 2px 6px; border-radius: 6px; }
.pasos li { margin-bottom: 8px; font-size: .92rem; }
.nota-t { white-space: pre-wrap; font-size: .95rem; }
.tachado .nombre { text-decoration: line-through; color: var(--tenue); }
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--linea); background: none; flex: none; cursor: pointer; color: var(--verde); font-weight: 800; padding: 0; }
.check.si { border-color: var(--verde); background: rgba(47, 181, 124, .2); }
