/* ===== App de organización y gastos · estilos (móvil primero) ===== */
:root {
  --fondo: #f6f2ec;
  --papel: #fffdf9;
  --tinta: #24211d;
  --suave: #6f675d;
  --linea: #e6dfd4;
  --marca: #2f5d62;        /* navegación y botones: ni verde ni rojo */
  --marca-2: #e8f0ef;

  /* Presupuesto (11.03–11.05) */
  --disponible: #2e7d32;   /* verde: lo que queda */
  --gasto: #d2561b;        /* naranja oscuro: lo gastado */
  --exceso: #6e1423;       /* granate: lo que se pasa del tope */

  /* Comparador de precios (11.01–11.02) — tonos y etiquetas distintos */
  --barato: #157f3b;
  --barato-fondo: #dff3e5;
  --caro: #c42b2b;
  --caro-fondo: #fbe1e1;

  --aviso: #fff4d6;
  --aviso-borde: #e8c766;
  --radio: 16px;
  --sombra: 0 1px 2px rgba(40, 30, 20, .06), 0 4px 14px rgba(40, 30, 20, .06);
  --seguro-abajo: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fondo); color: var(--tinta); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(84px + var(--seguro-abajo));
  -webkit-font-smoothing: antialiased;
}
main { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 24px; }
h1 { font-size: 28px; line-height: 1.15; margin: 4px 0 14px; letter-spacing: -.02em; }
h2 { font-size: 19px; margin: 24px 0 10px; letter-spacing: -.01em; }
h3 { font-size: 16px; margin: 0 0 6px; }
a { color: var(--marca); }
small, .suave { color: var(--suave); }
.num { font-variant-numeric: tabular-nums; }
.oculto { display: none !important; }

/* ---------- tarjetas ---------- */
.tarjeta { background: var(--papel); border-radius: var(--radio); box-shadow: var(--sombra); padding: 16px; margin-bottom: 12px; }
.tarjeta.plana { box-shadow: none; border: 1px solid var(--linea); }
.fila { display: flex; align-items: center; gap: 12px; }
.fila > .crece { flex: 1; min-width: 0; }
.entre { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cortar { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- cabecera de mes ---------- */
.mesbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.mesbar h1 { margin: 0; text-transform: capitalize; }
.mesbar button { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--papel); box-shadow: var(--sombra); font-size: 22px; color: var(--tinta); }

/* ---------- presupuesto ---------- */
.gran-total { font-size: 38px; font-weight: 750; letter-spacing: -.03em; }
.barra { height: 14px; border-radius: 99px; background: #eee6da; overflow: hidden; display: flex; margin: 10px 0 8px; }
.barra > i { display: block; height: 100%; }
.barra .b-gasto { background: var(--gasto); }
.barra .b-resto { background: var(--disponible); opacity: .85; }
.barra .b-exceso { background: var(--exceso); }
.cifras { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; }
.t-disponible { color: var(--disponible); font-weight: 650; }
.t-gasto { color: var(--gasto); font-weight: 650; }
.t-exceso { color: var(--exceso); font-weight: 750; }
.chip-exceso { background: var(--exceso); color: #fff; border-radius: 8px; padding: 2px 8px; font-size: 13px; font-weight: 700; }
.leyenda { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--suave); margin: 6px 0 0; }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- avisos / banners ---------- */
.banner { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--tinta);
  background: var(--aviso); border: 1px solid var(--aviso-borde); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; font-weight: 600; }
.banner span:first-child { font-size: 22px; }
.avisos { background: var(--aviso); border: 1px solid var(--aviso-borde); border-radius: 12px; padding: 10px 14px; margin: 10px 0; font-size: 14.5px; }
.avisos ul { margin: 4px 0 0; padding-left: 18px; }
.error { background: #fde7e7; border: 1px solid #f1b0b0; color: #7a1c1c; border-radius: 12px; padding: 10px 14px; margin: 10px 0; }

/* ---------- accesos rápidos ---------- */
.rejilla { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 4px; }
.acceso { background: var(--papel); border-radius: 16px; box-shadow: var(--sombra); padding: 14px 6px 12px; text-align: center;
  text-decoration: none; color: var(--tinta); font-size: 13.5px; font-weight: 600; border: 0; font-family: inherit; }
.acceso span { display: block; font-size: 28px; margin-bottom: 4px; }

/* ---------- listas ---------- */
.lista { background: var(--papel); border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; margin-bottom: 12px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--linea);
  text-decoration: none; color: inherit; background: none; width: 100%; border-left: 0; border-right: 0; border-top: 0; font: inherit; text-align: left; }
.item:last-child { border-bottom: 0; }
.item .crece { flex: 1; min-width: 0; }
.item .titulo { font-weight: 600; }
.item .sub { font-size: 13.5px; color: var(--suave); }
.item .importe { font-weight: 700; white-space: nowrap; }
.item.archivado { opacity: .55; }
.dia { font-size: 13px; font-weight: 700; color: var(--suave); text-transform: uppercase; letter-spacing: .04em; margin: 16px 4px 6px; display: flex; justify-content: space-between; }

.icono { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px; background: var(--marca-2);
  display: grid; place-items: center; font-size: 22px; overflow: hidden; }
.icono img { width: 100%; height: 100%; object-fit: cover; }
.icono.peq { width: 32px; height: 32px; flex-basis: 32px; font-size: 17px; border-radius: 9px; }

/* ---------- formularios ---------- */
label.campo { display: block; margin: 12px 0; }
label.campo > span { display: block; font-size: 13.5px; font-weight: 650; color: var(--suave); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 17px; color: var(--tinta); background: #fff; border: 1.5px solid var(--linea);
  border-radius: 12px; padding: 11px 12px; -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--suave) 50%), linear-gradient(135deg, var(--suave) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--marca); }
input[type=checkbox] { width: 22px; height: 22px; -webkit-appearance: checkbox; appearance: auto; accent-color: var(--marca); }
.importe-grande { font-size: 30px !important; font-weight: 750; text-align: right; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tres { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.check { display: flex; gap: 10px; align-items: center; margin: 12px 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--linea); background: #fff; border-radius: 99px; padding: 8px 13px; font: inherit; font-size: 15px; color: var(--tinta); }
.chip[aria-pressed=true] { background: var(--marca); border-color: var(--marca); color: #fff; font-weight: 600; }
.chips.desplazable { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips.desplazable::-webkit-scrollbar { display: none; }
.chips.desplazable .chip { white-space: nowrap; }

/* ---------- botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; font: inherit;
  font-weight: 650; padding: 13px 18px; background: var(--marca-2); color: var(--marca); text-decoration: none; }
.btn.primario { background: var(--marca); color: #fff; }
.btn.ok { background: var(--marca); color: #fff; font-size: 19px; font-weight: 800; letter-spacing: .02em; padding: 16px; }
.btn.peligro { background: #fbe4e4; color: #9b1c1c; }
.btn.bloque { display: flex; width: 100%; margin: 10px 0; }
.btn.mini { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.acciones { display: grid; gap: 10px; margin: 18px 0; }
.boton-icono { border: 0; background: none; font-size: 20px; padding: 6px 8px; color: var(--suave); }

/* ---------- pantalla añadir ---------- */
.grande-op { display: flex; align-items: center; gap: 14px; width: 100%; background: var(--papel); border: 0; border-radius: 18px;
  box-shadow: var(--sombra); padding: 18px; margin-bottom: 12px; text-align: left; font: inherit; color: var(--tinta); text-decoration: none; position: relative; }
.grande-op span:first-child { font-size: 34px; }
.grande-op b { display: block; font-size: 17px; }
.grande-op small { display: block; }
.grande-op input[type=file] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }

/* ---------- revisión de ticket ---------- */
.miniatura { width: 100%; max-height: 220px; object-fit: contain; background: #eee7dc; border-radius: 12px; display: block; }
.linea-ticket { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 11px 14px; border-bottom: 1px solid var(--linea); }
.linea-ticket:last-child { border-bottom: 0; }
.linea-ticket .nom { font-weight: 600; }
.linea-ticket .det { font-size: 13px; color: var(--suave); grid-column: 1 / -1; }
.etq { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--marca-2); color: var(--marca); }
.etq.nuevo { background: #efe6ff; color: #5a3a9a; }
.etq.dto { background: #fff1d6; color: #8a5a00; }
.cuadre { font-size: 14px; padding: 8px 14px; }
.barra-ok { position: sticky; bottom: calc(76px + var(--seguro-abajo)); background: linear-gradient(transparent, var(--fondo) 30%); padding-top: 18px; }

/* ---------- comparador ---------- */
.precio-barato { background: var(--barato-fondo); }
.precio-barato .importe { color: var(--barato); }
.precio-caro { background: var(--caro-fondo); }
.precio-caro .importe { color: var(--caro); }
.etq.barato { background: var(--barato); color: #fff; }
.etq.caro { background: var(--caro); color: #fff; }

/* ---------- barras de informe ---------- */
.mini-barra { height: 6px; border-radius: 9px; background: var(--marca); opacity: .75; margin-top: 5px; }

/* ---------- navegación inferior ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around; align-items: center;
  background: rgba(255, 253, 249, .94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--linea); padding: 6px 4px calc(6px + var(--seguro-abajo)); }
.tabs a { flex: 1; text-align: center; text-decoration: none; color: var(--suave); font-size: 11px; font-weight: 600; padding: 4px 0; }
.tabs a span { display: block; font-size: 22px; line-height: 1.15; }
.tabs a.activo { color: var(--marca); }
.tabs a.tab-mas span { width: 54px; height: 54px; margin: -22px auto 0; border-radius: 50%; background: var(--marca); color: #fff;
  font-size: 32px; line-height: 52px; box-shadow: 0 6px 16px rgba(47, 93, 98, .35); }

/* ---------- hojas (modales desde abajo) ---------- */
#capa .fondo { position: fixed; inset: 0; background: rgba(30, 25, 20, .38); z-index: 40; animation: aparece .15s; }
#capa .hoja { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 90vh; overflow-y: auto; background: var(--fondo);
  border-radius: 22px 22px 0 0; padding: 10px 16px calc(20px + var(--seguro-abajo)); animation: sube .2s ease-out; max-width: 640px; margin: 0 auto; }
#capa .hoja::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 9px; background: #d8cfc2; margin: 0 auto 10px; }
#capa .hoja h2 { margin-top: 4px; }
@keyframes sube { from { transform: translateY(40px); opacity: 0; } }
@keyframes aparece { from { opacity: 0; } }

.emojis { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emojis button { font-size: 26px; background: none; border: 0; padding: 6px 0; border-radius: 10px; }
.emojis button:active { background: var(--marca-2); }

.foto-grande { position: fixed; inset: 0; z-index: 60; background: #000; display: grid; place-items: center; }
.foto-grande img { max-width: 100%; max-height: 100%; }
.foto-grande button { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 12px); right: 12px; background: #fff; border: 0; border-radius: 99px; padding: 8px 14px; font-weight: 700; }

/* ---------- toast y carga ---------- */
#toast { position: fixed; left: 50%; bottom: calc(96px + var(--seguro-abajo)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--tinta); color: #fff; padding: 11px 16px; border-radius: 12px; font-weight: 600; z-index: 70; transition: .2s; pointer-events: none; max-width: 90vw; text-align: center; }
#toast.ver { opacity: 1; transform: translateX(-50%) translateY(0); }
.cargando { text-align: center; padding: 50px 10px; color: var(--suave); }
.girando { width: 38px; height: 38px; border: 4px solid var(--linea); border-top-color: var(--marca); border-radius: 50%; margin: 0 auto 14px; animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.vacio { text-align: center; color: var(--suave); padding: 30px 10px; }
.vacio span { display: block; font-size: 40px; margin-bottom: 6px; }

/* ---------- login ---------- */
.login { min-height: 80vh; display: grid; place-items: center; text-align: center; }
.login .logo { font-size: 56px; }
.login input { text-align: center; font-size: 30px; letter-spacing: .4em; max-width: 220px; margin: 18px auto; display: block; }
