:root {
  --primary: #1f7a3a;
  --primary-2: #2e9e44;
  --acento: #f08a24;
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface2: #eef1e8;
  --text: #1d2420;
  --muted: #5e6b63;
  --border: #dde3d8;
  --rojo: #c8402f;
  --azul: #3a7bd5;
  --sombra: 0 2px 10px rgba(20, 40, 25, .08);
  --sobre-primario: #ffffff;
  --radio: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #4cc26a; --primary-2: #5fd17c; --acento: #ffa64d;
    --bg: #111613; --surface: #1a211c; --surface2: #232c25; --text: #eef3ee; --muted: #a2b0a6; --border: #2e3a31;
    --sombra: 0 2px 12px rgba(0, 0, 0, .4); --sobre-primario: #0b2412; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary: #4cc26a; --primary-2: #5fd17c; --acento: #ffa64d;
  --bg: #111613; --surface: #1a211c; --surface2: #232c25; --text: #eef3ee; --muted: #a2b0a6; --border: #2e3a31;
  --sombra: 0 2px 12px rgba(0, 0, 0, .4); --sobre-primario: #0b2412; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.45;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
p { margin: .3rem 0 .8rem; }
.muted { color: var(--muted); font-size: .9rem; }
.chico { font-size: .8rem; }

/* Intro */
#intro {
  position: fixed; inset: 0; z-index: 100; background: linear-gradient(160deg, #1f7a3a, #2e9e44 60%, #f08a24);
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff;
  transition: opacity .5s ease, visibility .5s;
}
#intro.fuera { opacity: 0; visibility: hidden; pointer-events: none; }
.intro-canasta { position: relative; width: 140px; height: 140px; }
.canasta { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); font-size: 84px; animation: rebote .5s ease 1.1s; }
.cae { position: absolute; top: -40px; font-size: 32px; opacity: 0; animation: cae .7s cubic-bezier(.5, 0, .7, 1) forwards; }
.c1 { left: 20px; animation-delay: .1s; } .c2 { left: 55px; animation-delay: .3s; } .c3 { left: 90px; animation-delay: .5s; }
.c4 { left: 38px; animation-delay: .7s; } .c5 { left: 75px; animation-delay: .9s; }
@keyframes cae { 0% { opacity: 0; transform: translateY(0); } 20% { opacity: 1; } 100% { opacity: 1; transform: translateY(95px) scale(.8); } }
@keyframes rebote { 50% { transform: translateX(-50%) scale(1.12); } }
.intro-nombre { font-size: 2rem; margin-top: 18px; letter-spacing: .5px; animation: aparece .6s ease .4s both; }
.intro-lema { opacity: .9; margin-top: 4px; animation: aparece .6s ease .7s both; }
@keyframes aparece { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .cae, .canasta, .intro-nombre, .intro-lema { animation: none; opacity: 1; } }

/* Barra superior y navegación */
.barra {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.marca { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-size: 1.1rem; }
.marca img { width: 30px; height: 30px; border-radius: 8px; }
.marca b { color: var(--primary); }
.btn-icono { border: 1px solid var(--border); background: var(--surface2); border-radius: 50%; width: 38px; height: 38px; font-size: 18px; cursor: pointer; }
.nav-abajo {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.nav-abajo a { display: flex; flex-direction: column; align-items: center; padding: 7px 2px 8px; font-size: .72rem; text-decoration: none; color: var(--muted); }
.nav-abajo a span { font-size: 1.3rem; }
.nav-abajo a.activa { color: var(--primary); font-weight: 700; }

main { max-width: 860px; margin: 0 auto; padding: 16px; outline: none; }

/* Tarjetas y elementos */
.tarjeta { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radio); padding: 16px; margin-bottom: 14px; box-shadow: var(--sombra); }
.tarjeta.hero { background: linear-gradient(135deg, #1f7a3a, #2e9e44); color: #fff; border: none; }
.tarjeta.hero .muted { color: rgba(255, 255, 255, .85); }
.fila { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.fila.entre { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); border-radius: 12px; padding: 10px 14px; font-size: .95rem; font-weight: 600;
  cursor: pointer; text-decoration: none; min-height: 44px;
}
.btn.primario { background: var(--primary); border-color: var(--primary); color: var(--sobre-primario); }
.btn.acento { background: var(--acento); border-color: var(--acento); color: #fff; }
.btn.blanco { background: #fff; color: #1f7a3a; border-color: #fff; }
.btn.peligro { color: var(--rojo); }
.btn.chico { min-height: 34px; padding: 6px 10px; font-size: .82rem; border-radius: 10px; }
.btn.grande { width: 100%; padding: 14px; font-size: 1.05rem; }
.btn:disabled { opacity: .6; cursor: wait; }

label { display: block; font-size: .85rem; font-weight: 600; margin: 8px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-2); outline-offset: 1px; }
.dinero { position: relative; }
.dinero::before { content: "$"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; }
.dinero input { padding-left: 26px; font-size: 1.4rem; font-weight: 700; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 7px 12px; font-size: .86rem; cursor: pointer; user-select: none; }
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--sobre-primario); }
.chip.no.on { background: var(--rojo); border-color: var(--rojo); }
/* Casillas con forma de chip (formulario de persona) */
label.chip { display: inline-flex; align-items: center; margin: 0; font-weight: 400; }
label.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
label.chip:has(input:checked) { background: var(--primary); border-color: var(--primary); color: var(--sobre-primario); }
label.chip.no:has(input:checked) { background: var(--rojo); border-color: var(--rojo); color: #fff; }
label.chip:has(input:focus-visible) { outline: 2px solid var(--primary-2); outline-offset: 2px; }
.variante { margin-top: 8px; padding-left: 10px; border-left: 3px solid var(--acento); }

.opcion { border: 2px solid var(--border); border-radius: 14px; padding: 12px; cursor: pointer; background: var(--surface); text-align: left; font: inherit; color: var(--text); }
.opcion.on { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.opcion b { display: block; margin-bottom: 2px; }

.persona { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.persona:last-child { border-bottom: none; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--surface2); display: grid; place-items: center; font-size: 22px; flex: none; }
.persona .info { flex: 1; min-width: 0; }

/* Resultado */
.cifra { font-size: 2rem; font-weight: 800; }
.barra-gasto { height: 12px; background: var(--surface2); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.barra-gasto > div { height: 100%; background: var(--primary-2); border-radius: 99px; }
.plato { display: flex; height: 26px; border-radius: 8px; overflow: hidden; margin: 8px 0; }
.plato > div { height: 100%; }
.leyenda { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; }
.indicadores { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.indicadores div { background: var(--surface2); border-radius: 12px; padding: 10px 4px; }
.indicadores b { display: block; font-size: 1.2rem; }
.aviso { background: color-mix(in srgb, var(--acento) 14%, var(--surface)); border-left: 4px solid var(--acento); padding: 10px 12px; border-radius: 10px; margin: 8px 0; font-size: .9rem; }
.ok { background: color-mix(in srgb, var(--primary-2) 14%, var(--surface)); border-left-color: var(--primary-2); }
/* Dibujito de cada producto (o su inicial si no hay uno correcto) */
.ico { display: inline-block; width: 1.4em; text-align: center; }
.ico-letra { display: inline-flex; align-items: center; justify-content: center; width: 1.3em; height: 1.3em; border-radius: 50%; color: #fff; font-size: .8em; font-weight: 800; vertical-align: -0.15em; margin: 0 .05em; }
/* Acompañamientos del menú (sopa, guarnición, agua, fruta) */
.acompana { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 2px 0 4px; color: var(--muted); }
/* Premium */
.planes-premium { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 10px 0; }
.plan-premium { border: 1px solid var(--border); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; background: var(--surface2); }
.plan-premium .btn { margin-top: auto; }
.precio-premium { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.precio-premium small { font-size: .9rem; font-weight: 500; color: var(--muted); }
.amigos-premium { border-top: 1px dashed var(--border); margin-top: 14px; padding-top: 12px; }

.tienda h3 { display: flex; justify-content: space-between; }
.item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: none; }
.item input[type=checkbox] { width: 22px; height: 22px; min-height: 0; margin-top: 2px; flex: none; accent-color: var(--primary); }
.item .info { flex: 1; min-width: 0; }
.item .precio { font-weight: 700; white-space: nowrap; }
.item.hecho .info { text-decoration: line-through; opacity: .55; }
.item .acciones { display: flex; gap: 10px; font-size: .78rem; margin-top: 2px; flex-wrap: wrap; }
.etiqueta { display: inline-block; font-size: .7rem; padding: 1px 7px; border-radius: 99px; background: var(--surface2); color: var(--muted); }
.etiqueta.aprox { background: color-mix(in srgb, var(--acento) 20%, var(--surface)); color: var(--text); }

/* Menú */
.dia { border-left: 4px solid var(--border); }
.dia.hoy { border-left-color: var(--acento); }
.comida { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px dashed var(--border); }
.comida:first-of-type { border-top: none; }
.comida .tipo { font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); width: 74px; flex: none; padding-top: 3px; }
.comida .nombre { font-weight: 600; }
.videos { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.yt { background: #e62117; color: #fff; border-color: #e62117; }
.tt { background: #111; color: #fff; border-color: #111; }
.embed { position: relative; padding-top: 56.25%; border-radius: 12px; overflow: hidden; margin-top: 8px; background: #000; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Tablas */
.tabla-env { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; }
td.num, th.num { text-align: right; white-space: nowrap; }
.barato { color: var(--primary); font-weight: 700; }

/* Menú "Más" */
.lista-mas a { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; font-weight: 600; }
.lista-mas a span { font-size: 1.3rem; width: 30px; text-align: center; }
details { border-bottom: 1px solid var(--border); padding: 10px 0; }
summary { cursor: pointer; font-weight: 600; }

/* Admin y botones de panel */
.acts { display: flex; gap: 6px; flex-wrap: wrap; }
.abtn { border: 1px solid var(--border); background: var(--surface2); color: var(--text); border-radius: 8px; padding: 5px 9px; font-size: .72rem; cursor: pointer; white-space: nowrap; font-weight: 600; }
.abtn:hover { border-color: var(--primary); }
.abtn.prem { background: linear-gradient(135deg, #f59e0b, #f97316); color: #fff; border: none; }
.abtn.comp { background: rgba(96, 165, 250, .18); color: #3b82f6; border-color: transparent; }
.abtn.pause { color: #d99a00; } .abtn.off { color: #e05252; }
.estado { font-size: .72rem; padding: 2px 8px; border-radius: 99px; background: var(--surface2); }
.estado.act { background: #fef3c7; color: #92400e; } .estado.comp { background: #dbeafe; color: #1e40af; } .estado.paused { background: #fee2e2; color: #991b1b; }

/* Modal y avisos */
dialog { border: none; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: 90vh; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
#modal-cuerpo { padding: 18px; margin: 0; }
#toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--primary); color: #fff;
  padding: 12px 20px; border-radius: 12px; font-size: .9rem; font-weight: 600; opacity: 0; transition: .3s; z-index: 200;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3); pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--rojo); }

.vacio { text-align: center; padding: 30px 10px; color: var(--muted); }
.vacio .grande { font-size: 3rem; }

@media print {
  .barra, .nav-abajo, .no-imprimir, #toast { display: none !important; }
  body { padding: 0; background: #fff; }
  .tarjeta { box-shadow: none; break-inside: avoid; }
}
