/* =====================================================================
   LukAPP · Estilos (mobile-first, sin frameworks)
   Marca: verde profundo #103E32 · verde lima #C5FA79 · blanco cálido #F5F5F0 · negro #171717
   Regla de accesibilidad: el lima va de RELLENO (botones, chips) o como texto sobre
   verde profundo; nunca como texto sobre fondo claro (no se lee).
   ===================================================================== */
:root {
  --verde: #103E32;
  --lima: #C5FA79;
  --crema: #F5F5F0;
  --negro: #171717;
  --bg: var(--crema);
  --card: #ffffff;
  --text: var(--negro);
  --muted: #59625e;
  --line: #e2e2da;
  --brand: var(--verde);
  --accent: var(--verde);
  --btn-bg: var(--verde);      /* botón principal: verde con texto lima */
  --btn-fg: var(--lima);
  --ok: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(15 23 42 / .06), 0 2px 8px rgb(15 23 42 / .05);
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0c1512; --card: #14211c; --text: #ecece6; --muted: #a3aea8; --line: #24342d; --brand: #0a2a21;
          --accent: var(--lima); --btn-bg: var(--lima); --btn-fg: var(--verde); }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-size: 16px; line-height: 1.45;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 99; background: var(--card); padding: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.cargando { padding: 48px 16px; text-align: center; color: var(--muted); }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px;
  background: var(--brand); color: #fff;
}
.topbar__brand { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; }
.topbar__brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo { width: 30px; height: 30px; flex: none; }
.periodo { display: flex; align-items: center; gap: 2px; }
.periodo__label { background: rgb(255 255 255 / .12); border: 0; color: #fff; border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.icon-btn { background: transparent; border: 0; color: inherit; width: 40px; height: 40px; border-radius: 50%; font-size: 1.3rem; line-height: 1; }
.icon-btn:hover { background: rgb(127 127 127 / .15); }

/* ---------- Contenido ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 12px; outline: none; }
.titulo { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 2px 12px; flex-wrap: wrap; }
.titulo h1 { font-size: 1.3rem; margin: 0; }
h2 { font-size: 1rem; margin: 0 0 10px; }
.grid { display: grid; gap: 12px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.card--flat { box-shadow: none; border: 1px solid var(--line); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; min-width: 0; }
.kpi__label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.kpi__valor { font-size: 1.2rem; font-weight: 750; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.kpi__sub { font-size: .8rem; color: var(--muted); }

.alerta { border-radius: var(--radius); padding: 12px 14px; font-weight: 600; }
.alerta--bad { background: #fee2e2; color: #991b1b; }
.alerta--ok { background: #dcfce7; color: #166534; }
.alerta--warn { background: #fef3c7; color: #92400e; }

/* Barras de progreso */
.barra { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; position: relative; }
.barra > i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; }
.barra > i.ppto { opacity: .3; }
.fila-barra { display: grid; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.fila-barra:last-child { border-bottom: 0; }
.fila-barra__top { display: flex; justify-content: space-between; gap: 8px; font-size: .92rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* Listas */
.lista { list-style: none; margin: 0; padding: 0; }
.item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center;
  padding: 10px 2px; border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: 0; }
.item__titulo { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__meta { font-size: .8rem; color: var(--muted); grid-column: 1; }
.item__monto { text-align: right; font-weight: 650; }
.item__acciones { grid-column: 2; grid-row: 2; display: flex; gap: 6px; justify-content: flex-end; }
.item--click { cursor: pointer; }
.item--click:hover { background: rgb(127 127 127 / .05); }
.dia-titulo { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; margin: 14px 2px 2px; }

.badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--line); color: var(--muted); vertical-align: middle; }
.badge--ok { background: #dcfce7; color: #166534; }
.badge--bad { background: #fee2e2; color: #991b1b; }
.badge--warn { background: #fef3c7; color: #92400e; }

/* Botones */
.btn { border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 650; background: var(--line); color: var(--text); min-height: 42px; }
.btn--primario { background: var(--btn-bg); color: var(--btn-fg); }
.btn--ok { background: var(--ok); color: #fff; }
.btn--peligro { background: transparent; color: var(--bad); }
.btn--sm { padding: 5px 10px; min-height: 32px; font-size: .82rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; }

/* Chips de filtro */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 12px; white-space: nowrap; font-size: .88rem; }
.chip[aria-pressed="true"] { background: var(--verde); color: var(--crema); border-color: var(--verde); }

/* Formularios */
.campo { display: grid; gap: 4px; margin-bottom: 12px; }
.campo label, .campo > span { font-size: .85rem; font-weight: 600; color: var(--muted); }
.campo input, .campo select, .campo textarea, .buscar {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); min-height: 44px;
}
.campo input:focus, .campo select:focus { border-color: var(--accent); }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.segmento { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg); border-radius: 10px; padding: 3px; gap: 3px; }
.segmento input { position: absolute; opacity: 0; }
.segmento label { text-align: center; padding: 8px; border-radius: 8px; font-weight: 650; color: var(--muted); cursor: pointer; }
.segmento input:checked + label { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.segmento input:focus-visible + label { outline: 3px solid var(--accent); }
.check { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.check input { width: 20px; height: 20px; }
.ayuda { font-size: .8rem; color: var(--muted); margin: -6px 0 12px; }

/* Hoja / modal */
.hoja { border: 0; padding: 0; width: 100%; max-width: 560px; max-height: 92dvh; border-radius: 18px 18px 0 0; margin: auto auto 0; background: var(--card); color: var(--text); }
.hoja::backdrop { background: rgb(10 30 24 / .55); }
.hoja form { display: flex; flex-direction: column; max-height: 92dvh; }
.hoja__head { display: flex; justify-content: space-between; align-items: center; padding: 12px 12px 4px 16px; }
.hoja__head h2 { margin: 0; font-size: 1.1rem; }
.hoja__body { padding: 8px 16px; overflow-y: auto; }
.hoja__foot { display: flex; gap: 8px; justify-content: space-between; padding: 12px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); }
.hoja__foot .btn--primario { flex: 1; }

/* FAB y tabbar */
.fab {
  position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); z-index: 20;
  width: 58px; height: 58px; border-radius: 18px; border: 2px solid var(--verde); background: var(--lima); color: var(--verde);
  font-size: 2rem; font-weight: 700; line-height: 1; box-shadow: 0 6px 18px rgb(16 62 50 / .35);
}
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 15; height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .7rem; font-weight: 600; }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--accent); }

/* Gráfica de flujo */
.grafica { width: 100%; height: auto; display: block; }
.grafica text { fill: var(--muted); font-size: 10px; }
.leyenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 90px); transform: translateX(-50%) translateY(20px);
  background: var(--verde); color: var(--crema); padding: 10px 16px; border-radius: 10px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: 90vw; text-align: center;
}
.toast.ver { opacity: 1; transform: translateX(-50%); }
.vacio { text-align: center; padding: 28px 12px; color: var(--muted); }
.totales { display: flex; justify-content: space-between; gap: 8px; padding-top: 10px; margin-top: 4px; border-top: 2px solid var(--line); font-weight: 700; }
table.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla th, .tabla td { text-align: left; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.tabla th:not(:first-child), .tabla td:not(:first-child) { text-align: right; }

/* ---------- Tablet / escritorio ---------- */
@media (min-width: 720px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .grid--2 { grid-template-columns: 1fr 1fr; }
  .hoja { border-radius: 18px; margin: auto; }
}
@media (min-width: 1024px) {
  body { padding-bottom: 24px; padding-left: 96px; }
  .tabbar { z-index: 5; inset: 0 auto 0 0; width: 96px; height: 100%; grid-template-columns: 1fr; grid-auto-rows: 76px; align-content: start; padding-top: 70px; border-top: 0; border-right: 1px solid var(--line); }
  .topbar { margin-left: -96px; padding-left: 20px; }
  .fab { bottom: 24px; right: 24px; }
  .toast { bottom: 100px; }
  .grid--3 { grid-template-columns: 2fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }


/* =====================================================================
   Asistente de inicio (onboarding) · public/js/onboarding.js
   Una pregunta por pantalla, todo a mano del pulgar en el celular.
   ===================================================================== */
body.modo-onboarding { padding: 0; }
body.modo-onboarding .topbar, body.modo-onboarding .tabbar, body.modo-onboarding .fab { display: none; }
body.modo-onboarding main { max-width: none; padding: 0; }
@media (min-width: 1024px) { body.modo-onboarding { padding-left: 0; } }

.ob { min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); }
.ob--oscura { --ob-fondo: var(--verde); background: var(--verde); color: var(--crema); --btn-bg: var(--lima); --btn-fg: var(--verde); --muted: rgb(245 245 240 / .78); --line: rgb(245 245 240 / .18); --accent: var(--lima); }
.ob-cuerpo { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 8px 16px 24px; }
.ob h1 { font-size: 1.55rem; line-height: 1.2; margin: 12px 0 8px; outline: none; }
.ob h2 { font-size: 1.05rem; margin: 22px 0 8px; }
.ob h3 { font-size: 1rem; margin: 0 0 10px; }
.ob-intro { color: var(--muted); margin: 0 0 16px; }
.ob .ayuda { margin: 2px 0 12px; }

/* Barra superior: atrás + progreso */
.ob-top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 8px; background: inherit; }
.ob-atras { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; font-size: 1.8rem; line-height: 1; }
.ob-atras:hover { background: rgb(127 127 127 / .15); }
.ob-progreso { flex: 1; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.ob-progreso i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .3s; }
.ob-paso { font-size: .85rem; font-weight: 700; color: var(--muted); min-width: 2.5em; text-align: right; }

/* Pie fijo con el botón principal (siempre al alcance del pulgar) */
.ob-pie { position: sticky; bottom: 0; background: inherit; padding: 8px 16px calc(12px + var(--safe-b)); width: 100%; max-width: 560px; margin: 0 auto; display: grid; gap: 6px; }
.ob .ob-pie { box-shadow: 0 -10px 16px -12px rgb(0 0 0 / .15); }
.ob-sig { width: 100%; min-height: 52px; border-radius: 14px; font-size: 1.05rem; font-weight: 800; background: var(--btn-bg); color: var(--btn-fg); }
.ob-error { margin: 0; min-height: 0; color: #b42318; font-weight: 600; font-size: .92rem; }
.ob-error:empty { display: none; }
.ob--oscura .ob-error { color: #ffb4a8; }
.ob-link { background: none; border: 0; padding: 8px 0; color: var(--muted); text-decoration: underline; font-weight: 600; justify-self: center; }
.ob-agregar { width: 100%; min-height: 48px; margin: 4px 0 8px; border: 2px dashed var(--line); border-radius: 14px; background: transparent; font-weight: 700; color: var(--text); }
.ob-sub { font-weight: 700; margin: 4px 0 8px; }

/* Bienvenida */
.ob-hero { text-align: center; padding: 8vh 4px 0; display: grid; justify-items: center; gap: 4px; }
.ob-hero h1 { font-size: 1.7rem; margin-top: 28px; }
.ob-hero p { max-width: 34ch; margin: 4px auto; }
.ob-marca { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; margin: 14px 0 0 !important; }
.ob-marca span { color: var(--lima); }
.ob-lema { font-size: 1.05rem; opacity: .9; margin-top: 0 !important; }
.ob-privado { font-size: .85rem; color: var(--muted); margin-top: 18px !important; }

/* Opciones de una sola elección: tarjetas grandes */
.ob-opciones { border: 0; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
.ob-opciones legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.ob-opciones input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ob-opciones label { display: grid; gap: 2px; padding: 14px 16px 14px 46px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); cursor: pointer; position: relative; min-height: 52px; align-content: center; }
.ob-opciones label::before { content: ""; position: absolute; left: 16px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--muted); }
.ob-opciones label span { font-size: .85rem; color: var(--muted); }
.ob-opciones input:checked + label { border-color: var(--verde); background: #eefbdc; }
.ob-opciones input:checked + label::before { border-color: var(--verde); background: var(--verde); box-shadow: inset 0 0 0 3px #eefbdc; }
.ob-opciones input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Chips de selección múltiple */
.ob-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.ob-chip { min-height: 44px; padding: 8px 14px; border-radius: 99px; border: 2px solid var(--line); background: var(--card); font-weight: 600; }
.ob-chip[aria-pressed="true"] { background: var(--lima); border-color: var(--verde); color: var(--negro); }
.ob-chip[aria-pressed="true"]::before { content: "✓ "; }

/* Tarjeta de detalle (monto + día de lo que se marcó) */
.ob-fila { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 14px 2px; margin: 0 0 12px; }
.ob-fila--quitar { padding-bottom: 6px; }
.ob .campo input, .ob .campo select { min-height: 48px; font-size: 1rem; }
.ob-pesos { position: relative; }
.ob-pesos span { position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--muted); font-weight: 700; pointer-events: none; }
.ob-pesos input { padding-left: 28px !important; }
.ob-pesos--pct span { left: auto; right: 14px; }
.ob-pesos--pct input { padding-left: 12px !important; }
.ob-check { padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; font-weight: 600; }
.ob-mas { margin: 0 0 10px; }
.ob-mas summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: 6px 0 10px; }

/* Pantalla final (fondo verde) */
.ob-card { background: rgb(255 255 255 / .06); border: 1px solid rgb(245 245 240 / .16); border-radius: 16px; padding: 16px; margin: 0 0 12px; }
.ob-card h2 { margin-top: 0; }
.ob--oscura .campo input, .ob--oscura .campo select { background: rgb(0 0 0 / .22); border-color: rgb(245 245 240 / .25); color: var(--crema); }
.ob--oscura .campo select option { color: var(--negro); }
.ob-grande { font-size: 2.4rem; font-weight: 800; line-height: 1.1; margin: 2px 0 6px; letter-spacing: -.02em; }
.ob-card--verde .ob-grande { color: var(--lima); }
.ob-card--amarillo .ob-grande { color: #ffd166; }
.ob-card--rojo .ob-grande { color: #ff9b8c; }
.ob-estado { display: flex; gap: 8px; align-items: baseline; margin: 0 0 14px; }
.ob-estado i { flex: none; width: 12px; height: 12px; border-radius: 50%; translate: 0 1px; }
.ob-card--verde .ob-estado i { background: var(--lima); }
.ob-card--amarillo .ob-estado i { background: #ffd166; }
.ob-card--rojo .ob-estado i { background: #ff9b8c; }
.ob-barra { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: rgb(245 245 240 / .16); }
.ob-barra i { display: block; height: 100%; }
.b-comp { background: var(--crema); }
.b-ahorro { background: var(--lima); }
.ob-totales { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 14px 0 0; }
.ob-totales dt { font-size: .82rem; color: var(--muted); }
.ob-totales dd { margin: 0; font-weight: 700; }
.ob-lista { list-style: none; margin: 0; padding: 0; }
.ob-lista li { display: flex; justify-content: space-between; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.ob-lista li:last-child { border-bottom: 0; }
.ob-lista small, .ob-col small { color: var(--muted); margin-left: 6px; font-weight: 400; }

/* Reparto por quincena */
.ob-cols { display: grid; gap: 10px; }
.ob-col { border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.ob-col--mal { border-color: #ff9b8c; }
.ob-col h3 { margin: 0; }
.ob-col > p { margin: 2px 0 8px; }
.ob-col ul { list-style: none; margin: 0; padding: 0; }
.ob-col li button { width: 100%; display: flex; justify-content: space-between; gap: 8px; text-align: left; min-height: 44px; padding: 6px 4px; background: none; border: 0; border-bottom: 1px solid var(--line); color: inherit; font-size: .92rem; }
.ob-col li button:hover { background: rgb(255 255 255 / .06); }
.ob-col li button small { display: block; margin: 0; }
.ob-queda { margin: 8px 0 0; }
.ob-col--mal .ob-queda { color: #ff9b8c; }

@media (prefers-color-scheme: dark) {
  .ob-opciones input:checked + label { background: rgb(197 250 121 / .1); border-color: var(--lima); }
  .ob-opciones input:checked + label::before { border-color: var(--lima); background: var(--lima); box-shadow: inset 0 0 0 3px var(--card); }
  .ob-chip[aria-pressed="true"] { border-color: var(--lima); }
  .ob-error { color: #ffb4a8; }
}
@media (min-width: 600px) {
  .ob-cols { grid-template-columns: 1fr 1fr; }
  .ob h1 { font-size: 1.8rem; }
}
