/* ============ Nuestro Plan — estilos ============ */
:root {
  --marca: #0f5e6b;
  --marca-2: #13798a;
  --marca-suave: #e3f1f3;
  --fondo: #f4f6f8;
  --superficie: #ffffff;
  --superficie-2: #f8fafb;
  --borde: #e2e7ec;
  --texto: #18222b;
  --texto-2: #5b6874;
  --bien: #1c7c4a;
  --bien-suave: #e4f4ea;
  --alerta: #b26a00;
  --alerta-suave: #fff3dc;
  --mal: #b4232f;
  --mal-suave: #fde7e9;
  --sombra: 0 1px 2px rgba(16, 24, 32, .06), 0 4px 16px rgba(16, 24, 32, .06);
  --radio: 14px;
  --radio-chico: 10px;
  --nav-alto: 68px;
  color-scheme: light;
}
[data-tema="oscuro"] {
  --marca: #4fb3c2;
  --marca-2: #6cc6d3;
  --marca-suave: #17343a;
  --fondo: #0f1418;
  --superficie: #182027;
  --superficie-2: #1d262e;
  --borde: #2a3640;
  --texto: #e8eef2;
  --texto-2: #9aa9b5;
  --bien: #4cc483;
  --bien-suave: #163326;
  --alerta: #f0ad3c;
  --alerta-suave: #3a2d14;
  --mal: #f2727d;
  --mal-suave: #3b1c20;
  --sombra: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: var(--fondo);
  color: var(--texto);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.suave { color: var(--texto-2); }
.chico { font-size: .875rem; }
.oculto { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Layout ---------- */
.shell { min-height: 100vh; }
.contenido {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--nav-alto) + 96px);
}
.encabezado {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 8px 0 16px;
}
.encabezado .titulo-hogar { font-size: .875rem; color: var(--texto-2); }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--nav-alto) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--superficie);
  border-top: 1px solid var(--borde);
  display: grid; grid-template-columns: repeat(5, 1fr);
}
.nav button {
  border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .75rem; color: var(--texto-2); min-height: 48px;
}
.nav button svg { width: 24px; height: 24px; }
.nav button[aria-current="page"] { color: var(--marca); font-weight: 600; }
.nav .marca-nav { display: none; }

.fab {
  position: fixed; right: 18px; z-index: 25;
  bottom: calc(var(--nav-alto) + 18px + env(safe-area-inset-bottom));
  width: 64px; height: 64px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: var(--marca); color: #fff;
  box-shadow: 0 6px 20px rgba(15, 94, 107, .35);
  display: grid; place-items: center;
}
[data-tema="oscuro"] .fab { color: #0f1418; }
.fab svg { width: 30px; height: 30px; }

@media (min-width: 900px) {
  .nav {
    top: 0; right: auto; width: 232px; height: 100vh;
    border-top: 0; border-right: 1px solid var(--borde);
    grid-template-columns: 1fr; grid-auto-rows: min-content;
    padding: 20px 12px; gap: 4px;
  }
  .nav .marca-nav { display: flex; align-items: center; gap: 10px; padding: 4px 12px 20px; font-weight: 700; font-size: 1.05rem; }
  .nav .marca-nav img { width: 32px; height: 32px; border-radius: 8px; }
  .nav button {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 10px 12px; border-radius: 10px; font-size: .95rem;
  }
  .nav button[aria-current="page"] { background: var(--marca-suave); }
  .contenido { padding: 28px 32px 48px; margin-left: 232px; margin-right: auto; max-width: 860px; }
  .shell .contenido { margin-left: max(232px, calc(232px + (100vw - 232px - 860px) / 2)); }
  .fab { bottom: 32px; right: 32px; }
}

/* ---------- Tarjetas ---------- */
.tarjeta {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 18px;
  box-shadow: var(--sombra);
  margin-bottom: 14px;
}
.tarjeta-titulo { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.heroe {
  background: linear-gradient(135deg, var(--marca), var(--marca-2));
  color: #fff; border: 0;
}
[data-tema="oscuro"] .heroe { background: linear-gradient(135deg, #12515c, #176a78); }
.heroe .etiqueta { opacity: .85; font-size: .95rem; }
.heroe .cifra { font-size: 2.4rem; font-weight: 700; letter-spacing: -.5px; margin: 4px 0 6px; }
.heroe .sub { opacity: .9; font-size: .9rem; }
.heroe .barra { background: rgba(255,255,255,.25); }
.heroe .barra > span { background: #fff; }

/* ---------- Barras de progreso ---------- */
.barra { height: 8px; border-radius: 99px; background: var(--borde); overflow: hidden; }
.barra > span { display: block; height: 100%; border-radius: 99px; background: var(--bien); transition: width .3s; }
.barra.ambar > span { background: var(--alerta); }
.barra.rojo > span { background: var(--mal); }
.barra.marca > span { background: var(--marca); }
.barra.gruesa { height: 12px; }

/* ---------- Filas / listas ---------- */
.fila {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--borde);
}
.fila:last-child { border-bottom: 0; }
.fila.clic { cursor: pointer; }
.fila .cuerpo { flex: 1; min-width: 0; }
.fila .nombre { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila .detalle { font-size: .85rem; color: var(--texto-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila .monto { font-weight: 600; text-align: right; white-space: nowrap; }
.fila .monto.ingreso { color: var(--bien); }
.icono-cat {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.2rem;
  background: var(--superficie-2); border: 1px solid var(--borde);
}
.iniciales {
  width: 24px; height: 24px; border-radius: 50%;
  display: inline-grid; place-items: center; font-size: .68rem; font-weight: 700;
  background: var(--marca-suave); color: var(--marca); flex: 0 0 24px;
}
.iniciales.b { background: var(--alerta-suave); color: var(--alerta); }
.dia-grupo { font-size: .8rem; font-weight: 700; color: var(--texto-2); text-transform: uppercase; letter-spacing: .4px; margin: 18px 0 2px; }

.cat-fila { padding: 12px 0; border-bottom: 1px solid var(--borde); }
.cat-fila:last-child { border-bottom: 0; }
.cat-fila .arriba { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cat-fila .arriba .nombre { flex: 1; font-weight: 600; }
.cat-fila .abajo { display: flex; justify-content: space-between; font-size: .82rem; color: var(--texto-2); margin-top: 6px; }

/* ---------- Estados ---------- */
.estado { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; }
.estado.bien { background: var(--bien-suave); color: var(--bien); }
.estado.ambar { background: var(--alerta-suave); color: var(--alerta); }
.estado.rojo { background: var(--mal-suave); color: var(--mal); }
.estado.marca { background: var(--marca-suave); color: var(--marca); }
.texto-bien { color: var(--bien); }
.texto-ambar { color: var(--alerta); }
.texto-rojo { color: var(--mal); }

.aviso {
  border-radius: var(--radio-chico); padding: 12px 14px; font-size: .92rem;
  background: var(--marca-suave); color: var(--texto); margin-bottom: 14px;
  display: flex; gap: 10px; align-items: flex-start;
}
.aviso.ambar { background: var(--alerta-suave); }
.aviso.rojo { background: var(--mal-suave); }
.aviso.bien { background: var(--bien-suave); }

.vacio { text-align: center; padding: 28px 12px; color: var(--texto-2); }
.vacio .grande { font-size: 2rem; margin-bottom: 8px; }

.banda-offline {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: var(--alerta-suave); color: var(--alerta);
  text-align: center; font-size: .85rem; padding: 6px 12px; font-weight: 600;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 12px;
  border: 1px solid transparent; cursor: pointer; font-weight: 600;
  background: var(--marca); color: #fff; text-decoration: none;
}
[data-tema="oscuro"] .btn { color: #0f1418; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sec { background: var(--superficie); color: var(--texto); border-color: var(--borde); }
.btn.fantasma { background: none; color: var(--marca); border-color: transparent; padding: 0 10px; }
.btn.peligro { background: var(--mal); color: #fff; }
.btn.ancho { width: 100%; }
.btn.chico { min-height: 38px; padding: 0 14px; font-size: .9rem; border-radius: 10px; }
.btn-icono {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--borde);
  background: var(--superficie); cursor: pointer; display: grid; place-items: center;
}
.btn-icono svg { width: 20px; height: 20px; }
.acciones { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.acciones .btn { flex: 1; }

/* ---------- Formularios ---------- */
label.campo { display: block; margin-bottom: 14px; }
label.campo > span { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 6px; }
label.campo small { display: block; color: var(--texto-2); font-size: .8rem; margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--borde); border-radius: 12px;
  background: var(--superficie); color: var(--texto);
}
.input:focus { outline: 2px solid var(--marca); outline-offset: 1px; border-color: transparent; }
.input-monto { font-size: 2rem; font-weight: 700; text-align: center; min-height: 64px; }
.fila-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fila-form.tres { grid-template-columns: 2fr 1.3fr 1fr; }
@media (max-width: 480px) { .fila-form.tres { grid-template-columns: 1fr 1fr; } .fila-form.tres > :first-child { grid-column: 1 / -1; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--borde); background: var(--superficie); cursor: pointer;
  border-radius: 99px; padding: 8px 14px; min-height: 42px;
  display: inline-flex; align-items: center; gap: 6px; font-size: .92rem;
}
.chip[aria-pressed="true"] { background: var(--marca); color: #fff; border-color: var(--marca); }
[data-tema="oscuro"] .chip[aria-pressed="true"] { color: #0f1418; }

.pestanas { display: grid; grid-template-columns: 1fr 1fr; background: var(--superficie-2); border: 1px solid var(--borde); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.pestanas button { border: 0; background: none; min-height: 40px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--texto-2); }
.pestanas button[aria-selected="true"] { background: var(--superficie); color: var(--texto); box-shadow: var(--sombra); }

.check-fila { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--borde); }
.check-fila input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--marca); flex: 0 0 22px; }
.check-fila .nombre { flex: 1; }
.check-fila .input { max-width: 150px; min-height: 42px; text-align: right; }

.selector-mes { display: flex; align-items: center; gap: 6px; }
.selector-mes .mes { font-weight: 700; min-width: 118px; text-align: center; text-transform: capitalize; font-size: .95rem; }
.selector-mes .btn-icono { width: 38px; height: 38px; }

/* ---------- Modal ---------- */
.velo {
  position: fixed; inset: 0; z-index: 60; background: rgba(10, 16, 22, .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: aparecer .15s ease-out;
}
.modal {
  width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  background: var(--superficie); border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: subir .2s ease-out;
}
.modal .cabeza { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
@media (min-width: 640px) {
  .velo { align-items: center; }
  .modal { border-radius: 20px; }
}
@keyframes aparecer { from { opacity: 0; } }
@keyframes subir { from { transform: translateY(24px); opacity: .6; } }

/* ---------- Toast ---------- */
#toast-raiz { position: fixed; left: 0; right: 0; z-index: 70; bottom: calc(var(--nav-alto) + 96px); display: flex; justify-content: center; pointer-events: none; padding: 0 16px; }
@media (min-width: 900px) { #toast-raiz { bottom: 32px; } }
.toast {
  pointer-events: auto; max-width: 520px; width: 100%;
  background: #1d2a33; color: #fff; border-radius: 12px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  animation: subir .2s ease-out;
}
.toast .msg { flex: 1; font-size: .92rem; }
.toast button { background: none; border: 0; color: #7fd3df; font-weight: 700; cursor: pointer; min-height: 40px; padding: 0 6px; }

/* ---------- Pantallas de inicio / asistente ---------- */
.pantalla-centro { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.cargador { width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--borde); border-top-color: var(--marca); animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

.bienvenida { max-width: 420px; width: 100%; text-align: center; }
.bienvenida img { width: 84px; height: 84px; border-radius: 22px; margin-bottom: 18px; box-shadow: var(--sombra); }
.bienvenida h1 { font-size: 1.8rem; margin-bottom: 8px; }
.bienvenida p { color: var(--texto-2); margin-bottom: 24px; }
.btn-google { background: var(--superficie); color: var(--texto); border: 1px solid var(--borde); width: 100%; }
.btn-google svg { width: 20px; height: 20px; }

.asistente { max-width: 600px; margin: 0 auto; padding: 20px 16px 120px; }
.progreso-pasos { display: flex; gap: 6px; margin: 8px 0 22px; }
.progreso-pasos span { flex: 1; height: 6px; border-radius: 99px; background: var(--borde); }
.progreso-pasos span.hecho { background: var(--marca); }
.asistente .pregunta { font-size: 1.45rem; font-weight: 700; margin-bottom: 6px; }
.asistente .ayuda { color: var(--texto-2); margin-bottom: 20px; }
.pie-asistente {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--superficie); border-top: 1px solid var(--borde);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.pie-asistente .dentro { max-width: 600px; margin: 0 auto; display: flex; gap: 10px; }
.pie-asistente .btn { flex: 1; }
.lista-items .item { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--borde); }
.cuadre { font-variant-numeric: tabular-nums; }
.cuadre .linea { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--borde); }
.cuadre .linea.total { border-bottom: 0; font-weight: 700; font-size: 1.15rem; padding-top: 12px; }

/* ---------- Deudas ---------- */
.deuda { border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; margin-bottom: 12px; background: var(--superficie); }
.deuda.foco { border: 2px solid var(--marca); box-shadow: var(--sombra); }
.deuda .cabeza { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.deuda .saldo { font-size: 1.35rem; font-weight: 700; }
.deuda .datos { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .85rem; color: var(--texto-2); margin-top: 8px; }
.deuda.terminada { opacity: .75; }
.orden-num { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--superficie-2); border: 1px solid var(--borde); font-size: .8rem; font-weight: 700; }
.foco .orden-num { background: var(--marca); color: #fff; border-color: var(--marca); }

.ayuda-i { border: 0; background: none; color: var(--texto-2); cursor: pointer; padding: 0 4px; font-size: .9rem; }
.codigo-inv { font-size: 2rem; font-weight: 800; letter-spacing: 4px; text-align: center; padding: 12px; background: var(--superficie-2); border-radius: 12px; border: 1px dashed var(--borde); margin: 10px 0; }

:focus-visible { outline: 2px solid var(--marca); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
