/* Como en Casa · hoja única de las cuatro mini-apps (pension, hoy, turno, reparto).
   Paleta del logo: verde hoja, naranja, marrón tronco, crema. Móvil primero. */
:root {
  --crema: #FAF3E4; --papel: #FFFDF8; --tinta: #2A1C10; --tinta2: #6A5644; --linea: #E8DCC6;
  --verde: #22A447; --verde-f: #15752F; --verde-s: #E4F4E8;
  --naranja: #E8552B; --naranja-f: #B23D12; --naranja-s: #FCE9DF;
  --marron: #7A4A21; --marron-s: #F1E6D6; --rojo: #B3261E; --ambar: #8A5A00; --ambar-s: #FCEFC9;
  --r: 16px; --sombra: 0 1px 2px rgba(60, 35, 10, .06), 0 6px 20px rgba(60, 35, 10, .07);
  --sal: cubic-bezier(.23, 1, .32, 1);
}
* { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
body { margin: 0; background: var(--crema); color: var(--tinta); font: 16px/1.45 ui-rounded, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; min-height: 100dvh; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.55rem; line-height: 1.15; letter-spacing: -.01em; font-weight: 800; }
h2 { font-size: 1.05rem; font-weight: 800; }
h3 { font-size: .95rem; font-weight: 700; }
small, .sub { color: var(--tinta2); font-size: .875rem; }
img { max-width: 100%; display: block; }
svg.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button, a, [role="button"], summary, label.opt { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--verde-f); }
input, select, textarea { font: inherit; font-size: 16px; color: var(--tinta); }
:focus-visible { outline: 3px solid var(--naranja); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- marco de la demo ---- */
.demo { display: flex; align-items: center; gap: 8px; padding: calc(4px + env(safe-area-inset-top, 0px)) 12px 4px; background: var(--tinta); color: #F3E6CF; font-size: .75rem; }
.demo b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demo span { margin-left: auto; opacity: .85; white-space: nowrap; }
.demo button { background: none; border: 1px solid rgba(255, 255, 255, .35); border-radius: 99px; padding: 2px 10px; min-height: 28px; font-size: .75rem; white-space: nowrap; }
.cab { display: flex; align-items: center; gap: 8px; padding: 8px 12px 6px; background: var(--papel); border-bottom: 1px solid var(--linea); }
.cab .marca { flex: none; }
.cab .marca img { height: 46px; width: auto; }
.apps { display: flex; flex: 1; justify-content: flex-end; gap: 2px; min-width: 0; }
.apps a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 56px; min-height: 48px; padding: 4px 6px; border-radius: 12px; font-size: .6875rem; font-weight: 600; color: var(--tinta2); text-decoration: none; transition: transform .12s var(--sal), background .12s; }
.apps a[aria-current] { background: var(--verde-s); color: var(--verde-f); }
.apps a:active { transform: scale(.95); }
.seg { display: flex; gap: 4px; padding: 8px 12px; overflow-x: auto; scrollbar-width: none; background: var(--papel); border-bottom: 1px solid var(--linea); position: sticky; top: 0; z-index: 5; }
.seg::-webkit-scrollbar { display: none; }
.seg a { flex: 1 0 auto; text-align: center; min-height: 40px; padding: 9px 14px; border-radius: 99px; background: var(--marron-s); color: var(--tinta); font-size: .875rem; font-weight: 700; text-decoration: none; white-space: nowrap; transition: transform .12s var(--sal); }
.seg a[aria-current] { background: var(--marron); color: #fff; }
.seg a:active { transform: scale(.96); }
#app { max-width: 520px; margin: 0 auto; padding: 16px 16px 120px; display: grid; gap: 14px; align-content: start; }
body.ancho #app { max-width: 1120px; }
.cols { display: grid; gap: 14px; align-items: start; }
.cols > * { display: grid; gap: 14px; min-width: 0; }

/* ---- piezas ---- */
.card { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--r); padding: 14px; box-shadow: var(--sombra); display: grid; gap: 10px; min-width: 0; }
.card.plana { box-shadow: none; }
.fila { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fila > .cre { flex: 1; min-width: 0; }
.corta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entre { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pila { display: grid; gap: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 14px; border: 1.5px solid transparent; background: var(--verde-f); color: #fff; font-weight: 700; text-decoration: none; text-align: center; transition: transform .12s var(--sal), background .12s, opacity .12s; }
.btn:active { transform: scale(.97); }
.btn.n { background: var(--naranja-f); }
.btn.s { background: var(--papel); color: var(--tinta); border-color: var(--linea); }
.btn.g { background: transparent; color: var(--tinta2); min-height: 44px; }
.btn.ch { min-height: 44px; padding: 6px 12px; border-radius: 12px; font-size: .875rem; }
.btn.blo { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: .75rem; font-weight: 700; background: var(--marron-s); color: var(--marron); white-space: nowrap; }
.tag.v { background: var(--verde-s); color: var(--verde-f); }
.tag.n { background: var(--naranja-s); color: var(--naranja-f); }
.tag.a { background: var(--ambar-s); color: var(--ambar); }
.tag.r { background: #F9DEDC; color: var(--rojo); }
.campo { display: grid; gap: 4px; font-size: .875rem; font-weight: 600; color: var(--tinta2); }
.campo input, .campo select { width: 100%; min-height: 48px; padding: 10px 12px; border: 1.5px solid var(--linea); border-radius: 12px; background: #fff; font-weight: 500; }
.campo input:focus { outline: none; border-color: var(--verde); box-shadow: 0 0 0 3px var(--verde-s); }
.opt { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 10px 12px; text-align: left; background: #fff; border: 1.5px solid var(--linea); border-radius: 14px; transition: transform .12s var(--sal), border-color .12s, background .12s; }
.opt:active { transform: scale(.985); }
.opt::before { content: ""; flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #C9B99C; background: #fff; transition: border .12s; }
.opt[aria-pressed="true"] { border-color: var(--verde); background: var(--verde-s); }
.opt[aria-pressed="true"]::before { border: 6px solid var(--verde-f); }
.opt[disabled] { opacity: .55; pointer-events: none; background: var(--marron-s); }
.opt b { font-weight: 700; }
.opt .cre { flex: 1; min-width: 0; }
.rej { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.fr { display: grid; gap: 4px; min-height: 60px; padding: 8px 6px; text-align: center; background: #fff; border: 1.5px solid var(--linea); border-radius: 12px; transition: transform .12s var(--sal); }
.fr:active { transform: scale(.96); }
.fr b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.fr small { font-size: .75rem; }
.fr[aria-pressed="true"] { border-color: var(--verde); background: var(--verde-s); }
.fr[disabled] { background: var(--marron-s); opacity: .7; pointer-events: none; }
.med { height: 6px; border-radius: 99px; background: var(--marron-s); overflow: hidden; }
.med i { display: block; height: 100%; border-radius: 99px; background: var(--verde); transition: width .3s var(--sal); }
.med.n i { background: var(--naranja); }
.stat { display: grid; gap: 2px; }
.stat b { font-size: 1.45rem; line-height: 1.1; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats .stat b { font-size: clamp(1.1rem, 5.2vw, 1.45rem); }
.stat.g b { font-size: 2.3rem; color: var(--verde-f); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.lista { display: grid; }
.lista > * { padding: 10px 0; border-top: 1px solid var(--linea); }
.lista > :first-child { border-top: 0; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips button { flex: none; min-height: 40px; padding: 6px 14px; border-radius: 99px; border: 1.5px solid var(--linea); background: #fff; font-size: .875rem; font-weight: 600; }
.chips button[aria-pressed="true"] { background: var(--tinta); color: #fff; border-color: var(--tinta); }
.paso { width: 44px; height: 44px; flex: none; border-radius: 12px; border: 1.5px solid var(--linea); background: #fff; display: inline-grid; place-items: center; font-weight: 800; font-size: 1.1rem; }
.paso:active { background: var(--marron-s); }
.cant { width: 56px; min-height: 44px; text-align: center; border: 1.5px solid var(--linea); border-radius: 12px; background: #fff; font-weight: 700; }
.aviso { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--ambar-s); color: #5E3D00; font-size: .9rem; font-weight: 600; }
.aviso.v { background: var(--verde-s); color: #0E5321; }
.aviso.r { background: #F9DEDC; color: #7A1712; }
.vacio { text-align: center; color: var(--tinta2); padding: 22px 10px; }
details > summary { list-style: none; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "+"; font-size: 1.3rem; color: var(--tinta2); }
details[open] > summary::after { content: "–"; }
.pie { position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); background: rgba(250, 243, 228, .94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-top: 1px solid var(--linea); }
.pie > div { max-width: 488px; margin: 0 auto; display: grid; gap: 6px; }

/* ---- carné ---- */
.carne { background: linear-gradient(160deg, #1B8A3B, #15752F 55%, #0F5C24); color: #fff; border-radius: 22px; padding: 16px; display: grid; gap: 12px; box-shadow: 0 10px 30px rgba(21, 117, 47, .28); }
.carne small { color: #D6F2DD; }
.carne .qr { background: #fff; border-radius: 14px; padding: 6px; width: 132px; flex: none; }
.carne .qr svg { display: block; width: 100%; height: auto; }
.carne .gr { font-size: 3.4rem; line-height: .95; font-weight: 800; font-variant-numeric: tabular-nums; }
.pts { display: flex; flex-wrap: wrap; gap: 5px; }
.pts i { width: 14px; height: 14px; border-radius: 50%; background: rgba(255, 255, 255, .28); }
.pts i.o { background: #FFD9A0; }
.dias { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; align-items: end; height: 130px; }
.dias div { display: grid; gap: 4px; justify-items: center; align-content: end; height: 100%; font-size: .8rem; font-weight: 700; }
.dias i { width: 100%; max-width: 46px; border-radius: 8px 8px 3px 3px; background: var(--verde); min-height: 4px; }
.dias .hoy i { background: var(--naranja); }

/* ---- ticket de turno / estado ---- */
.ticket { text-align: center; padding: 22px 16px; }
.ticket .n { font-size: 5.2rem; line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--marron); }
.ticket.listo { background: var(--verde-f); color: #fff; border-color: var(--verde-f); }
.ticket.listo .n, .ticket.listo small { color: #fff; }
.ruta { display: flex; gap: 4px; }
.ruta span { flex: 1; text-align: center; font-size: .75rem; font-weight: 700; color: var(--tinta2); padding-top: 10px; border-top: 5px solid var(--linea); }
.ruta span.ok { border-color: var(--verde); color: var(--verde-f); }
.ped { border-left: 5px solid var(--linea); }
.ped.preparando { border-left-color: var(--naranja); }
.ped.listo { border-left-color: var(--verde); }
.ped .nn { font-size: 1.5rem; font-weight: 800; min-width: 44px; font-variant-numeric: tabular-nums; }
.lienzos { display: grid; grid-template-columns: 9fr 16fr; gap: 10px; align-items: start; }
.lienzos canvas { width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--linea); display: block; }

/* ---- hoja inferior y avisos ---- */
.velo { position: fixed; inset: 0; z-index: 20; background: rgba(42, 28, 16, .5); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .2s; }
.velo.ab { opacity: 1; }
.hoja { width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--papel); border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 12px; transform: translateY(100%); transition: transform .28s var(--sal); }
.velo.ab .hoja { transform: none; }
.hoja .monto { font-size: 2.4rem; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.hoja .yq { width: 150px; margin: 0 auto; border: 1px solid var(--linea); border-radius: 12px; overflow: hidden; }
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(92px + env(safe-area-inset-bottom, 0px)); z-index: 30; max-width: 496px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--tinta); color: #fff; font-weight: 600; font-size: .9rem; box-shadow: var(--sombra); transform: translateY(20px); opacity: 0; transition: transform .2s var(--sal), opacity .2s; }
.toast.ab { transform: none; opacity: 1; }
.toast button { margin-left: auto; flex: none; min-height: 40px; padding: 4px 12px; border-radius: 10px; border: 0; background: #FFD9A0; color: var(--tinta); font-weight: 800; }

/* ---- pantalla del local (televisor) ---- */
body.tv { background: #1C1209; color: #FBF1DC; }
body.tv .cab { display: none; }
body.tv .seg { background: #1C1209; border-color: #3A2916; position: static; opacity: .55; }
body.tv .seg a { background: #33230F; color: #E9D9BD; min-height: 32px; padding: 5px 12px; flex: 0 0 auto; }
body.tv .seg a[aria-current] { background: #E9D9BD; color: #1C1209; }
body.tv #app { max-width: none; padding: 2vh 3vw; grid-template-columns: 1fr 1.25fr; gap: 3vw; min-height: calc(100dvh - 100px); align-content: stretch; }
.tvc { border-radius: 2.5vw; padding: 2.5vh 2.5vw; background: #2A1B0C; display: grid; align-content: start; gap: 2vh; }
.tvc.ok { background: var(--verde-f); }
.tvc h2 { font-size: clamp(1.3rem, 3.2vw, 3.4rem); }
.tvn { display: flex; flex-wrap: wrap; gap: 1.6vw; }
.tvn b { font-size: clamp(2.6rem, 8.2vw, 9rem); line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; }
.tvc:not(.ok) .tvn b { font-size: clamp(2rem, 5vw, 5.4rem); color: #E9D9BD; }
.tvn b.nuevo { animation: canta 1.1s var(--sal) 3; }
@keyframes canta { 50% { transform: scale(1.14); color: #FFE08A; } }

@media (min-width: 860px) {
  body.ancho .cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  body.ancho .cols.c3 { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
  body.ancho #app { padding-bottom: 40px; }
  .cab { padding: 10px 24px; } .seg { padding: 8px 24px; } .seg a { flex: 0 0 auto; } .demo { padding-left: 24px; padding-right: 24px; }
  .apps a { flex-direction: row; gap: 6px; font-size: .875rem; padding: 6px 12px; }
}
@media (hover: hover) and (pointer: fine) {
  .btn:hover { filter: brightness(1.08); }
  .btn.s:hover, .opt:hover, .fr:hover, .chips button:hover { border-color: var(--marron); filter: none; }
  .apps a:hover { background: var(--marron-s); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
