:root {
  --marfil: #FFF6EC; --verde: #1E4D45; --coral: #FF7A59; --mostaza: #F2B544;
  --blanco: #FFFFFF; --linea: #EADCCB; --suave: #5E7A74; --rojo: #C8402E; --ok: #2E8B57;
  --radio: 18px; --nav: 72px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--marfil); color: var(--verde); }
body { font: 400 17px/1.4 'Poppins', system-ui, sans-serif; min-height: 100dvh; }
h1, h2, h3 { font-family: 'Poppins', sans-serif; font-weight: 700; margin: 0; }
h1 { font-size: 26px; } h2 { font-size: 20px; } h3 { font-size: 17px; }
.label, label > span, .tag, .nav a span, th { font-family: 'Barlow Condensed', sans-serif; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.label { font-size: 14px; color: var(--suave); }

main { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(var(--nav) + 32px + env(safe-area-inset-bottom)); }
header.top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; min-height: 48px; }
header.top .back { font-size: 26px; width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--blanco); color: var(--verde); }
.brand img { height: 44px; display: block; }
.brand .txt { font: 700 30px 'Poppins'; color: var(--verde); }
.brand .txt b { color: var(--coral); }
.lema { font-family: 'Barlow Condensed'; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; font-size: 14px; margin-top: 2px; }

.card { background: var(--blanco); border-radius: var(--radio); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 0 var(--linea); }
.card.acento { border-left: 6px solid var(--mostaza); }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.muted { color: var(--suave); font-size: 15px; }
/* Las cajas de una cuadrícula pueden encogerse; si no, un nombre largo en una lista empuja la pantalla de lado. */
.grid2 > *, .grid3 > *, .line > *, .row > * { min-width: 0; }
select { text-overflow: ellipsis; }
.grid2 > button, .grid2 > .btn { white-space: normal; line-height: 1.2; padding: 6px 10px; }
.big { font: 700 30px 'Poppins'; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }

button, .btn { font: 600 17px 'Poppins'; border: 0; border-radius: 14px; min-height: 52px; padding: 0 18px; cursor: pointer;
  background: var(--verde); color: var(--blanco); display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn-main { background: var(--coral); color: var(--blanco); width: 100%; min-height: 60px; font-size: 19px; }
.btn-soft { background: var(--blanco); color: var(--verde); border: 2px solid var(--verde); }
.btn-ghost { background: transparent; color: var(--verde); min-height: 44px; padding: 0 8px; text-decoration: underline; }
.btn-danger { background: transparent; color: var(--rojo); border: 2px solid var(--rojo); }
.btn-block { width: 100%; }
.btn-icon { min-height: 44px; width: 44px; padding: 0; background: transparent; color: var(--suave); font-size: 22px; }
button:disabled { opacity: .45; }
.soon { position: relative; }
.soon::after { content: 'Próximamente'; position: absolute; top: -8px; right: 8px; background: var(--mostaza); color: var(--verde);
  font: 600 12px 'Barlow Condensed'; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; }

label { display: block; }
label > span { display: block; font-size: 14px; color: var(--suave); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: 400 18px 'Poppins'; color: var(--verde); background: var(--blanco); border: 2px solid var(--linea);
  border-radius: 12px; min-height: 52px; padding: 10px 12px; }
textarea { min-height: 110px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--coral); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 99px; background: var(--blanco); color: var(--verde); border: 2px solid var(--linea); font-size: 16px; }
.chip.on { background: var(--verde); color: var(--blanco); border-color: var(--verde); }

.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 12px; background: var(--blanco); border-radius: 14px; padding: 14px; margin-bottom: 10px;
  color: var(--verde); text-decoration: none; min-height: 64px; }
.item .grow { flex: 1; min-width: 0; }
.item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-block; font-size: 13px; padding: 2px 8px; border-radius: 99px; background: var(--marfil); }
.tag.up { background: #FFE3DB; color: var(--rojo); } .tag.down { background: #DDF1E4; color: var(--ok); }
.tag.best { background: var(--mostaza); color: var(--verde); }
.tag.pack { background: #E6EFEC; }

.line { display: grid; grid-template-columns: 1fr 84px 92px 40px; gap: 6px; align-items: center; margin-bottom: 8px; }
.line input, .line select { min-height: 48px; padding: 8px; font-size: 16px; }
.line.wide { grid-template-columns: 1fr 1fr 40px; }
.line.wide > :first-child { grid-column: 1 / -1; }
.line .fracs { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: -2px; }
.line .fracs .chip { min-height: 40px; min-width: 52px; padding: 0 8px; font-size: 15px; font-variant-numeric: tabular-nums; }
.line .eq-ask { grid-column: 1 / -1; background: #FFF0D6; border: 2px solid var(--mostaza); border-radius: 12px; padding: 8px 10px; }
.line .eq-ask input { min-height: 44px; }
.line .cost { grid-column: 1 / -1; font-size: 14px; color: var(--suave); margin-top: -4px; }
.line .cost.warn { color: var(--rojo); }

.result { background: var(--verde); color: var(--blanco); }
.result .label { color: #CFE3DD; }
.result table { width: 100%; border-collapse: collapse; }
.result td { padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.15); }
.result td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.result tr.total td { font-weight: 700; font-size: 19px; border-bottom: 0; padding-top: 10px; }
.result .sug { background: var(--coral); border-radius: 14px; padding: 12px 14px; margin-top: 12px; display: flex; justify-content: space-between; align-items: center; }
.result .sug b { font-size: 26px; }

.semaforo { display: flex; gap: 12px; align-items: center; border-radius: 14px; padding: 12px; margin-top: 10px; background: var(--marfil); color: var(--verde); }
.semaforo .dot { width: 28px; height: 28px; border-radius: 50%; flex: none; }
.dot.verde { background: var(--ok); } .dot.amarillo { background: var(--mostaza); } .dot.rojo { background: var(--rojo); }
.mini-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; display: inline-block; }

.faltan { background: #FFF0D6; border: 2px solid var(--mostaza); }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.quick button, .quick a.btn { flex-direction: column; text-align: center; min-height: 96px; font-size: 14px; padding: 8px; line-height: 1.2; background: var(--blanco); color: var(--verde); border: 2px solid var(--linea); }
.quick .ico { font-size: 28px; }

nav.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--blanco); border-top: 1px solid var(--linea);
  display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
nav.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--nav);
  color: var(--suave); text-decoration: none; }
nav.nav a span { font-size: 13px; }
nav.nav a.on { color: var(--coral); }
nav.nav svg { width: 26px; height: 26px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav) + 16px + env(safe-area-inset-bottom)); max-width: 528px; margin: 0 auto;
  background: var(--verde); color: var(--blanco); padding: 14px 16px; border-radius: 14px; z-index: 30; font-weight: 600; text-align: center; }
.modal-bg { position: fixed; inset: 0; background: rgba(30,77,69,.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--marfil); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.modal .stack { margin-top: 14px; }

/* Índice alfabético: letra separadora y barra lateral para saltar */
.letter { font: 700 15px 'Barlow Condensed'; letter-spacing: .1em; color: var(--coral); margin: 14px 4px 6px; padding-bottom: 2px; border-bottom: 2px solid var(--linea); }
.with-az { padding-right: 30px; }
[data-live=list] .item .name { white-space: normal; overflow-wrap: anywhere; }
.az { position: fixed; right: max(4px, calc((100vw - 560px) / 2 - 28px)); top: 50%; transform: translateY(-50%); z-index: 5;
  display: flex; flex-direction: column; gap: 2px; background: var(--blanco); border-radius: 99px; padding: 6px 2px; box-shadow: 0 1px 6px rgba(30,77,69,.18); max-height: calc(100dvh - var(--nav) - 140px); overflow-y: auto; }
.az button { min-height: 30px; height: 30px; width: 28px; padding: 0; background: transparent; color: var(--verde); font: 700 13px 'Barlow Condensed'; border-radius: 99px; }
.az button:active { background: var(--coral); color: var(--blanco); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.tile { display: flex; flex-direction: column; gap: 2px; background: var(--blanco); border-radius: var(--radio); padding: 14px; min-height: 104px;
  color: var(--verde); text-decoration: none; box-shadow: 0 1px 0 var(--linea); }
.tile .ico { font-size: 28px; }
.tile b { font-family: 'Poppins'; font-size: 17px; }
.tile .muted { font-size: 14px; }
details summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; }
.spinner { width: 48px; height: 48px; margin: 16px auto; border-radius: 50%; border: 5px solid var(--linea); border-top-color: var(--coral); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.steps { display: flex; gap: 6px; margin: 8px 0 20px; }
.steps i { flex: 1; height: 6px; border-radius: 9px; background: var(--linea); }
.steps i.on { background: var(--coral); }
.welcome { min-height: 100dvh; padding-bottom: 32px; }
.cost .eqv { color: var(--suave); font-weight: 400; }
a.eqv { color: var(--coral); }
/* Lista de compras: casilla grande para palomear con el pulgar */
.item.shop { gap: 10px; padding: 10px 12px; }
.item.shop .check { width: 40px; min-height: 40px; height: 40px; padding: 0; border-radius: 10px; background: var(--blanco); border: 2px solid var(--verde); color: var(--blanco); font-size: 22px; flex: none; }
.item.shop.done .check { background: var(--ok); border-color: var(--ok); }
.item.shop.done .name { text-decoration: line-through; color: var(--suave); }
details.card > summary { list-style: none; }
.tile.wide { grid-column: 1 / -1; min-height: 0; flex-direction: row; align-items: center; gap: 12px; }
