:root {
  --bg: #16c4a0;
  --ink: #111;
  --yellow: #ffc933;
  --orange: #ff6a2b;
  --pink: #ff9fc0;
  --blue: #5aa9ff;
  --green: #a6e86b;
  --white: #fff;
  --radius: 18px;
  --shadow: 4px 4px 0 var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
.wrap { max-width: 980px; margin: 0 auto; padding: 20px 16px 80px; }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.brand { font-weight: 800; font-size: 1.5rem; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand span { background: var(--yellow); border: 2px solid var(--ink); border-radius: 12px; padding: 2px 10px; box-shadow: 3px 3px 0 var(--ink); }
.user { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .9rem; }

/* controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  background: var(--yellow); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 999px; padding: 10px 20px;
  box-shadow: 3px 3px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.dark { background: var(--ink); color: #fff; box-shadow: 3px 3px 0 rgba(0,0,0,.35); }
.btn.white { background: #fff; }
.btn.orange { background: var(--orange); }
.btn.small { padding: 6px 14px; font-size: .85rem; }
.btn.block { width: 100%; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 700; font-size: .85rem; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], select {
  width: 100%; font: inherit; padding: 11px 14px; background: #fff; color: var(--ink);
  border: 2px solid var(--ink); border-radius: 14px; outline: none;
}
input:focus, select:focus { box-shadow: 3px 3px 0 var(--ink); }
.error { color: #b00020; font-weight: 600; font-size: .85rem; margin: 4px 0 0; }
.alert { background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 10px 14px; margin-bottom: 14px; font-weight: 600; }

/* cards */
.card { background: #fff; border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.c-yellow { background: var(--yellow); } .c-orange { background: var(--orange); }
.c-pink { background: var(--pink); } .c-blue { background: var(--blue); } .c-green { background: var(--green); }

/* auth */
.auth { max-width: 400px; margin: 4vh auto 0; text-align: center; }
.auth .card { text-align: left; }
.auth h1 { font-size: 2rem; margin: 10px 0 18px; text-align: center; }
.auth .hero { font-size: 4rem; }
.auth .alt { text-align: center; margin-top: 16px; font-weight: 600; }

/* lists grid */
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title h1 { font-size: 2rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.list-card { text-decoration: none; display: flex; flex-direction: column; gap: 6px; min-height: 160px; transition: transform .1s; }
.list-card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.list-card .icon { font-size: 2.6rem; line-height: 1; }
.list-card h3 { font-size: 1.35rem; margin-top: auto; }
.list-card small { font-weight: 600; }
.new-card { border-style: dashed; background: rgba(255,255,255,.35); box-shadow: none; cursor: pointer; align-items: center; justify-content: center; font-weight: 800; font: inherit; font-weight: 800; font-size: 1.1rem; }

/* dialog */
dialog { border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: 6px 6px 0 var(--ink); padding: 22px; width: min(420px, 92vw); background: #fff; }
dialog::backdrop { background: rgba(0,0,0,.45); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches label { cursor: pointer; }
.swatches input { display: none; }
.swatches i { display: block; width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--ink); }
.swatches input:checked + i { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.row > .fixed { flex: 0 0 90px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* list detail */
.list-head { padding: 18px 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.list-head .icon { font-size: 2.6rem; }
.list-head h1 { font-size: 1.9rem; flex: 1; min-width: 140px; }
.back { display: inline-block; font-weight: 700; margin-bottom: 10px; }
.cols { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }
.card h2 { font-size: 1.15rem; margin-bottom: 12px; }
.results { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; max-height: 60vh; overflow: auto; padding: 2px 4px 6px 2px; }
.prod { display: flex; align-items: center; gap: 12px; padding: 10px; background: #fff; border: 2px solid var(--ink); border-radius: 14px; }
.prod .thumb { width: 52px; height: 52px; border-radius: 10px; border: 2px solid var(--ink); background: var(--yellow) center/cover; flex: none; display: grid; place-items: center; font-size: 1.4rem; }
.prod .info { flex: 1; min-width: 0; }
.prod .info b { display: block; font-size: .9rem; line-height: 1.25; }
.prod .info span { font-weight: 800; }
.hint { font-size: .85rem; font-weight: 600; opacity: .8; margin: 8px 0 0; }
.badge { display: inline-block; font-size: .65rem; font-weight: 800; padding: 1px 7px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--yellow); margin-left: 6px; vertical-align: middle; }

.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #fff; border: 2px solid var(--ink); border-radius: 14px; }
.item.done .name { text-decoration: line-through; opacity: .5; }
.item .name { flex: 1; min-width: 0; font-weight: 600; font-size: .92rem; line-height: 1.25; }
.item .name a { text-decoration: none; }
.item .name small { display: block; font-weight: 500; opacity: .7; }
.chk { width: 26px; height: 26px; accent-color: var(--ink); flex: none; cursor: pointer; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink); background: var(--yellow); font-weight: 800; cursor: pointer; line-height: 1; padding: 0; }
.qty span { min-width: 20px; text-align: center; font-weight: 700; }
.line-price { font-weight: 800; min-width: 58px; text-align: right; font-size: .9rem; }
.x { background: none; border: none; cursor: pointer; font-size: 1.1rem; padding: 4px; }
.total { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding: 12px 14px; background: var(--ink); color: #fff; border-radius: 14px; font-weight: 800; font-size: 1.1rem; }
.empty { text-align: center; font-weight: 600; padding: 22px 6px; opacity: .8; }
.toolbar { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.list-card .spend { font-size: 1.05rem; margin-top: 2px; }
.total.grand { margin: 0 0 18px; }

/* admin */
.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stats .card { display: flex; flex-direction: column; gap: 2px; }
.stats small { font-weight: 700; }
.stats b { font-size: 1.9rem; letter-spacing: -.02em; }
.stats em { font-style: normal; font-size: .8rem; font-weight: 600; opacity: .8; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-size: .75rem; text-transform: uppercase; padding: 0 8px 8px; }
.tbl td { padding: 10px 8px; border-top: 2px solid var(--ink); vertical-align: middle; }
.tbl thead + tr td, .card > .tbl tr:first-child td { border-top: none; }
.tbl small { opacity: .7; font-weight: 500; }

/* ---------- iconos (Font Awesome) ---------- */
.icons { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.icons label { cursor: pointer; }
.icons input { display: none; }
.icons i { display: grid; place-items: center; height: 42px; border: 2px solid var(--ink); border-radius: 12px; background: #fff; font-size: 1.05rem; transition: transform .15s, background .15s; }
.icons label:hover i { transform: translateY(-2px); }
.icons input:checked + i { background: var(--yellow); box-shadow: 2px 2px 0 var(--ink); transform: scale(1.08); }
.qty button i { font-size: .6rem; }
.x { color: var(--ink); transition: color .15s, transform .15s; }
.x:hover { color: #c62828; transform: rotate(90deg) scale(1.15); }
.hero i { display: inline-block; }
.new-card .icon { font-size: 1.6rem; }
.new-card { gap: 8px; }
.btn i, .brand i { font-size: .9em; }
.back i { transition: transform .15s; }
.back:hover i { transform: translateX(-4px); }
.thumb i { font-size: 1.2rem; }
.btn.added { background: var(--green); }
.tbl a { text-decoration: none; }
.tbl a:hover { text-decoration: underline; }
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- animaciones ---------- */
@keyframes bounceIn { 0% { opacity: 0; transform: translateY(40px) scale(.85); } 50% { opacity: 1; transform: translateY(-14px) scale(1.04); } 68% { transform: translateY(6px) scale(.98); } 84% { transform: translateY(-3px) scale(1.01); } 100% { opacity: 1; transform: none; } }
@keyframes bounceOut { 0% { opacity: 1; transform: none; } 22% { opacity: 1; transform: translateY(-8px) scale(1.06); } 100% { opacity: 0; transform: translateY(30px) scale(.6); } }
@keyframes bounceFlash { 0%, 100% { background: #fff; } 30% { background: var(--yellow); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-8px) rotate(3deg); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.anim { animation: bounceIn .75s both; animation-delay: calc(var(--i, 0) * 70ms); }
.float { animation: bounceIn .8s both, floaty 3.2s ease-in-out .8s infinite; }
.alert.slide { animation: bounceIn .7s both; }
.alert.slide.out { animation: bounceOut .4s both; }
.item.enter { animation: bounceIn .7s both, bounceFlash 1s; }
.item.leaving { animation: bounceOut .4s both; pointer-events: none; }
.items .item { transition: background .2s, opacity .2s; }
.item.done { background: #f1f1f1; }
.total span.bump, #total.bump { display: inline-block; animation: bump .35s; }
dialog[open] { animation: bounceIn .6s both; }
dialog.closing { animation: bounceOut .35s both; }
dialog[open]::backdrop { animation: fadeIn .3s; }
dialog.closing::backdrop { opacity: 0; transition: opacity .35s; }

.card { transition: transform .15s, box-shadow .15s; }
.list-card .icon { transition: transform .25s cubic-bezier(.3, 1.6, .5, 1); display: inline-block; align-self: flex-start; }
.list-card:hover .icon { transform: scale(1.2) rotate(-8deg); }
.new-card:hover { background: rgba(255, 255, 255, .6); }
.list-card { transition: transform .15s, box-shadow .15s, background .2s; }
.stats .card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.prod { transition: transform .15s, box-shadow .15s; }
.prod:hover { transform: translateX(3px); box-shadow: 3px 3px 0 var(--ink); }
.prod .btn.added { animation: pop .35s; }
.qty button { transition: transform .12s; }
.qty button:hover { transform: scale(1.2); }
.chk:checked { animation: pop .3s; }
.tbl tr { transition: background .15s; }
.tbl tbody tr:hover, .tbl tr:hover td { background: rgba(255, 201, 51, .18); }
.brand span { transition: transform .15s; display: inline-block; }
.brand:hover span { transform: rotate(-2deg) scale(1.04); }
.brand:hover i { animation: bump .4s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.new-card .icon { align-self: center; }

/* toda la compra */
.group { margin-bottom: 18px; }
.group.leaving { animation: bounceOut .4s both; pointer-events: none; }
.group .subtotal { font-weight: 800; }
@media print {
  body { background: #fff; }
  .topbar, .back, .btn, .chk, .toolbar { display: none !important; }
  .card, .item, .total { box-shadow: none !important; animation: none !important; }
  .group { break-inside: avoid; background: #fff !important; }
}

/* compartir */
.share-tag { display: inline-flex; align-items: center; gap: 5px; align-self: flex-start; font-size: .72rem; font-weight: 700; background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 1px 9px; }
.members { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.members li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 2px solid var(--ink); border-radius: 14px; background: #fff; animation: bounceIn .5s both; }
.members li:nth-child(2) { animation-delay: .06s; } .members li:nth-child(3) { animation-delay: .12s; } .members li:nth-child(n+4) { animation-delay: .18s; }
.members .who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.members .who small { opacity: .7; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 50%; background: var(--yellow); font-weight: 800; }
.members li:nth-child(even) .avatar { background: var(--pink); }
.members li:nth-child(3n) .avatar { background: var(--blue); }
.list-head h1 small { font-size: .72rem; }
