html, body { height: 100%; overflow: hidden; }
body { display: flex; flex-direction: column; user-select: none; }
.muted { color: var(--ink-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.bar {
  display: flex; align-items: center; gap: 16px; padding: 10px 20px;
  background: var(--surface); border-bottom: 1px solid var(--line); min-height: 70px;
}
.bar-title { display: flex; align-items: center; gap: 12px; }
.bar-title > div { display: grid; line-height: 1.15; }
.bar-title strong { font-size: 20px; letter-spacing: -.01em; }
.bar-title span { font-size: 13px; }
.meal-pick select {
  min-height: 44px; padding: 0 38px 0 16px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--page); font-weight: 650; font-size: 16px; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%),
    linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 21px) 50%, calc(100% - 16px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.counts { display: flex; gap: 8px; flex: 1; overflow-x: auto; scrollbar-width: none; align-items: center; }
.count {
  display: flex; align-items: baseline; gap: 6px; padding: 6px 13px; border-radius: 999px;
  background: var(--page); white-space: nowrap; font-size: 14px; color: var(--ink-2);
}
.count b { display: inline-block; font-size: 19px; color: var(--ink); font-variant-numeric: tabular-nums; }
.count.total { background: var(--brand); color: rgba(255, 255, 255, .85); }
.count.total b { color: #fff; }
.count.bump b { animation: bump .45s var(--ease-out); }
@keyframes bump { 35% { transform: scale(1.35); } }
.sync {
  display: flex; align-items: center; gap: 10px; border: none; background: none; cursor: pointer;
  font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; padding: 8px; border-radius: 12px;
}
.sync:hover { background: var(--page); }

.banner { padding: 10px 20px; background: var(--no-soft); color: var(--no); font-weight: 600; font-size: 15px; }

.stage { flex: 1; display: grid; grid-template-columns: minmax(280px, 38%) 1fr; gap: 16px; padding: 16px; min-height: 0; }
@media (orientation: portrait) {
  .stage { grid-template-columns: 1fr; grid-template-rows: minmax(220px, 34%) 1fr; }
}

.camera { position: relative; border-radius: var(--radius); overflow: hidden; background: #0c120a; min-height: 0; container-type: size; }
.camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame {
  --c: rgba(255, 255, 255, .92); --l: 36px; --w: 5px;
  position: absolute; inset: 50% auto auto 50%; width: min(62cqw, 70cqh); aspect-ratio: 1;
  transform: translate(-50%, -50%); box-shadow: 0 0 0 9999px rgba(0, 0, 0, .34);
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--l) var(--w),
    linear-gradient(var(--c), var(--c)) top left / var(--w) var(--l),
    linear-gradient(var(--c), var(--c)) top right / var(--l) var(--w),
    linear-gradient(var(--c), var(--c)) top right / var(--w) var(--l),
    linear-gradient(var(--c), var(--c)) bottom left / var(--l) var(--w),
    linear-gradient(var(--c), var(--c)) bottom left / var(--w) var(--l),
    linear-gradient(var(--c), var(--c)) bottom right / var(--l) var(--w),
    linear-gradient(var(--c), var(--c)) bottom right / var(--w) var(--l);
  background-repeat: no-repeat;
}
.camera.reading .frame::after {
  content: ""; position: absolute; left: 7%; right: 7%; top: 8%; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, transparent, #b7f397 20%, #b7f397 80%, transparent);
  box-shadow: 0 0 14px 2px rgba(183, 243, 151, .7);
  animation: sweep 2.4s ease-in-out infinite alternate;
}
@keyframes sweep { to { top: 91%; } }
.camera.hit .frame { --c: #b7f397; animation: hit .4s var(--ease-out); }
.camera.hit::after {
  content: ""; position: absolute; inset: 0; background: #fff; pointer-events: none;
  animation: flash .35s ease-out forwards;
}
@keyframes hit { 40% { transform: translate(-50%, -50%) scale(.94); } }
@keyframes flash { from { opacity: .45; } to { opacity: 0; } }
.camera-state {
  position: absolute; left: 12px; bottom: 12px; margin: 0; padding: 7px 13px; border-radius: 999px;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 8px; backdrop-filter: blur(6px);
}
.camera.mirror video { transform: scaleX(-1); }
.flip {
  position: absolute; right: 12px; top: 12px; width: 52px; height: 52px; border-radius: 50%; border: 0;
  display: grid; place-items: center; color: #fff; background: rgba(0, 0, 0, .5); cursor: pointer;
  backdrop-filter: blur(6px); transition: transform .2s var(--ease-out), background .15s;
}
.flip[hidden] { display: none; }
.flip:hover { background: rgba(0, 0, 0, .65); }
.flip:active { transform: scale(.92) rotate(-30deg); }
.camera.reading .camera-state::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: #b7f397;
  box-shadow: 0 0 0 3px rgba(183, 243, 151, .25);
}

.panel { position: relative; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; min-height: 0; display: flex; }
.idle { flex: 1; display: grid; grid-template-rows: 1fr auto; padding: 24px 28px; min-height: 0; animation: fade .25s ease-out; }
.idle-hint { display: grid; place-content: center; text-align: center; justify-items: center; gap: 6px; color: var(--ink-2); }
.qr-badge {
  width: 104px; height: 104px; border-radius: 30px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
}
.idle-hint h1 { margin: 18px 0 0; font-size: 30px; color: var(--ink); letter-spacing: -.02em; }
.idle-hint p { margin: 2px 0 0; font-size: 17px; }
.recent h2 { margin: 0 0 8px; font-size: 14px; font-weight: 650; color: var(--ink-3); }
.recent ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 32vh; overflow: hidden; }
.recent li { display: flex; gap: 12px; align-items: baseline; padding: 9px 0; border-top: 1px solid var(--line); font-size: 15px; }
.recent li.new { animation: arrive .45s var(--ease-out); }
.recent li time { color: var(--ink-3); font-variant-numeric: tabular-nums; width: 46px; flex: none; }
.recent li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.recent li small { color: var(--ink-3); font-size: 13px; white-space: nowrap; }
@keyframes arrive { from { opacity: 0; transform: translateY(-8px); background: var(--brand-soft); } }
@keyframes fade { from { opacity: 0; } }

/* A verdict fills the panel in its colour, to be read from across the line. */
.card {
  flex: 1; display: grid; grid-template-rows: auto 1fr auto; padding: 28px 32px; gap: 20px;
  --tone: var(--ink-2); background: var(--tone); color: #fff;
  animation: enter .28s var(--ease-out); container-type: size;
}
.card.ok { --tone: var(--ok); }
.card.no { --tone: var(--no); }
.card.warn { --tone: var(--warn); }
.card.ask { --tone: var(--info); }
.card.pending { opacity: .6; transition: opacity .2s; }
.card.shake { animation: enter .28s var(--ease-out), shake .42s .1s cubic-bezier(.36,.07,.19,.97); }
@keyframes enter { from { opacity: 0; transform: scale(.97); } }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

.verdict { display: flex; align-items: center; justify-content: center; gap: 16px; font-size: 38px; font-weight: 800; line-height: 1.05; letter-spacing: -.02em; }
.badge {
  width: 60px; height: 60px; flex: none; border-radius: 50%; background: #fff; color: var(--tone);
  display: grid; place-items: center; animation: badge .4s var(--ease-out);
}
.badge path { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 32; stroke-dashoffset: 32; animation: draw .4s .12s ease-out forwards; }
@keyframes badge { from { transform: scale(.4); } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* The person is the middle of the card: the face is what the kitchen checks
   against whoever holds up the QR. */
/* The photo takes what the menu buttons below leave, so they never cover the name. */
.body { display: grid; align-content: center; justify-items: center; gap: 18px; min-height: 0; text-align: center; container-type: size; }
.who { --photo: clamp(64px, 34cqh, 190px); display: grid; justify-items: center; gap: 14px; min-height: 0; }
.photo {
  position: relative; width: var(--photo); height: var(--photo); border-radius: 50%; overflow: hidden; flex: none;
  background: rgba(255, 255, 255, .2); border: 6px solid #fff; box-shadow: 0 14px 40px rgba(0, 0, 0, .22);
  animation: rise .35s .05s var(--ease-out) backwards;
}
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s; }
.photo img.loaded { opacity: 1; }
.initials { display: grid; place-items: center; font-size: calc(var(--photo) * .34); font-weight: 750; color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.94); } }
.who-text { display: grid; gap: 6px; min-width: 0; justify-items: center; }
.who-text .name { font-size: clamp(26px, 10cqh, 48px); font-weight: 780; line-height: 1.05; letter-spacing: -.02em; overflow-wrap: anywhere; text-wrap: balance; }
.who-text .meta { font-size: 19px; color: rgba(255, 255, 255, .86); }
.reason {
  max-width: 36em; font-size: 23px; font-weight: 650; line-height: 1.3; white-space: pre-line;
  background: rgba(0, 0, 0, .14); border-radius: 14px; padding: 14px 20px;
}
.note { max-width: 36em; font-size: 17px; font-weight: 650; background: rgba(255, 255, 255, .16); border-radius: 12px; padding: 10px 14px; }
.price {
  font-size: 24px; font-weight: 750; letter-spacing: -.01em;
  background: #fff; color: var(--tone); border-radius: 14px; padding: 10px 18px;
  animation: rise .3s .1s var(--ease-out) backwards;
}

.actions { display: grid; gap: 14px; }
/* Big targets: the menu is picked fast, with a tray in the other hand. */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.choice {
  min-height: 128px; border-radius: 22px; border: 0; background: #fff; color: var(--ink);
  display: grid; place-content: center; gap: 6px; padding: 14px 18px; cursor: pointer; text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .14); transition: transform .1s;
  animation: rise .3s var(--ease-out) backwards;
}
.choice:nth-child(2) { animation-delay: .04s; }
.choice:nth-child(3) { animation-delay: .08s; }
.choice b { font-size: 27px; line-height: 1.15; letter-spacing: -.01em; }
.choice small { font-size: 19px; color: var(--tone); font-weight: 700; }
.choice:active, .override:active { transform: scale(.97); }
.override {
  min-height: 74px; font-size: 22px; border-radius: 18px; border: 0; background: #fff; color: var(--tone);
  font-weight: 750; cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .12); transition: transform .1s;
}
.cancel {
  min-height: 64px; border-radius: 18px; border: 2px solid rgba(255, 255, 255, .55); background: transparent;
  color: #fff; font-size: 18px; font-weight: 650; cursor: pointer; transition: background .15s, transform .1s;
}
.cancel:hover { background: rgba(255, 255, 255, .1); }
.cancel:active { transform: scale(.98); }
.row { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.row .stamp { color: rgba(255, 255, 255, .85); font-size: 16px; font-weight: 600; }
.timer { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .25); overflow: hidden; }
.timer > i { display: block; height: 100%; background: #fff; transform-origin: left; animation: drain linear forwards; }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.undo { min-height: 48px; background: rgba(255, 255, 255, .16); border-color: transparent; color: #fff; }
.undo:hover { border-color: transparent; background: rgba(255, 255, 255, .26); }

/* A solid page, not the station blurred behind: nothing half-seen competes with it. */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; background: #f3f5f0; }
.start-box {
  width: min(440px, 100%); display: grid; gap: 22px; padding: 32px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 1px 2px rgba(20, 30, 10, .04), 0 18px 44px rgba(20, 30, 10, .08);
  animation: enter .3s var(--ease-out);
}
.start-head { display: flex; align-items: center; gap: 12px; }
.start-head .mark { width: 36px; height: 36px; }
.start-brand { display: grid; line-height: 1.25; }
.start-brand strong { font-size: 15px; letter-spacing: -.01em; }
.start-brand span { font-size: 13px; }
.start-copy { display: grid; gap: 8px; }
.start-box h1 { margin: 0; font-size: 26px; font-weight: 750; letter-spacing: -.025em; line-height: 1.15; }
.start-box p { margin: 0; font-size: 15.5px; line-height: 1.5; }
.start-account { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: #fafbf8; }
.start-account .avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-size: 15px; font-weight: 700; }
.start-account div { display: grid; min-width: 0; line-height: 1.3; }
.start-account strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.start-account span { font-size: 13px; }
.btn.big { min-height: 56px; font-size: 18px; border-radius: 14px; }
.start-links { display: flex; gap: 10px; }
.start-links > * { flex: 1; min-height: 46px; border-radius: 12px; font-size: 15px; }
.start-links .ghost { background: none; border-color: transparent; color: var(--ink-2); }
.overlay[hidden] { display: none; }

/* One real input, for the tablet's keyboard and paste, drawn as six boxes. */
.otp { position: relative; }
.otp[hidden] { display: none; }
.otp input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; caret-color: transparent; cursor: text; }
.boxes { display: grid; grid-template-columns: repeat(3, 1fr) 12px repeat(3, 1fr); gap: 10px; }
.boxes span {
  height: 68px; display: grid; place-items: center; border: 1.5px solid var(--line); border-radius: 14px;
  font-size: 30px; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
.boxes b { align-self: center; height: 2px; border-radius: 1px; background: var(--line); }
.otp:focus-within .boxes span.on { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(56, 106, 32, .16); }
.otp:focus-within .boxes span.on:empty::after { content: ""; width: 2px; height: 30px; background: var(--ink); animation: blink 1.1s steps(1) infinite; }
.otp.invalid .boxes span { border-color: var(--no); }
@keyframes blink { 50% { opacity: 0; } }
.error { color: var(--no); font-weight: 600; }

/* Modo de prueba: local development only. */
.test-bar {
  position: fixed; left: 28px; bottom: 28px; z-index: 20; width: min(340px, calc(100vw - 56px));
  background: rgba(17, 20, 15, .9); color: #fff; border-radius: 16px; padding: 6px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .35); backdrop-filter: blur(10px);
}
.test-head {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 0; border-radius: 10px;
  background: none; color: #fff; font-size: 13px; font-weight: 700; cursor: pointer; text-align: left;
}
.test-head:hover { background: rgba(255, 255, 255, .08); }
.test-dot { width: 8px; height: 8px; border-radius: 50%; background: #f5b800; box-shadow: 0 0 0 3px rgba(245, 184, 0, .25); }
.test-hint { margin-left: auto; font-weight: 500; color: rgba(255, 255, 255, .55); }
.test-cases { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; max-height: 50vh; overflow: auto; }
.test-bar.closed .test-cases { display: none; }
.test-case {
  display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 9px;
  background: rgba(255, 255, 255, .07); color: #fff; font-size: 12.5px; font-weight: 600; text-align: left; cursor: pointer;
  transition: background .12s, transform .08s;
}
.test-case::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--tone); }
.test-case:hover { background: rgba(255, 255, 255, .14); }
.test-case:active { transform: scale(.97); }
.test-case.ok { --tone: #4caf50; }
.test-case.ask { --tone: #5b8def; }
.test-case.no { --tone: #ef5350; }
.test-case.warn { --tone: #f5b800; }

dialog { border: none; border-radius: 20px; padding: 26px; width: min(520px, 92vw); box-shadow: 0 24px 60px rgba(0, 0, 0, .2); }
dialog::backdrop { background: rgba(10, 20, 5, .35); }
dialog h2 { margin-top: 0; font-size: 20px; }
dialog ul { padding-left: 18px; line-height: 1.5; }

@media (max-width: 900px) {
  .bar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .counts { order: 3; flex-basis: 100%; }
  .stage { padding: 12px; gap: 12px; }
  .card { padding: 24px; }
  .verdict { font-size: 32px; }
}
