@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,700&family=DM+Serif+Display&display=swap');

:root {
  --ground: #F6F1EA;
  --surface: #FFFFFF;
  --sunken: #EDE6DB;
  --ink: #26272E;
  --ink-2: #4A4B55;
  --muted: #5A5B66;
  --line: #E4DCCF;
  --line-strong: #CFC6B8;
  --primary: #42434D;
  --star: #E0A100;
  --star-line: #A87400;
  --danger: #8A1C2B;
  --serif: 'DM Serif Display', Georgia, serif;
  --sans: 'DM Sans', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--primary); }
h1, h2 { font-family: var(--serif); font-weight: 400; margin: 0; line-height: 1.1; }
p { margin: 0; line-height: 1.5; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Cliente ---------- */
.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--ground); }
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand b { font-family: var(--serif); font-weight: 400; font-size: 20px; line-height: 1.1; }
.brand span { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.progress { font-size: 12px; color: var(--muted); }
.chip { font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 999px; background: var(--primary); color: #fff; border: 0; }
.screen { flex: 1; padding: 22px 20px 32px; display: flex; flex-direction: column; gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack-lg { display: flex; flex-direction: column; gap: 16px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.h1 { font-size: 32px; }
.lead { font-size: 15px; color: var(--ink-2); }
.small { font-size: 13px; color: var(--muted); }
.center { text-align: center; }

.card { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; text-align: left; width: 100%; }
button.card { border-color: var(--line-strong); cursor: pointer; }
button.card:active { transform: scale(.99); }
.card.done { background: var(--sunken); color: var(--ink-2); }
.card.off { opacity: .55; }
.card .grow { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card .title { font-size: 15px; font-weight: 700; line-height: 1.25; }
.card .sub { font-size: 13px; color: var(--muted); }
.card .action { flex-shrink: 0; font-size: 13px; font-weight: 700; color: var(--primary); }

.badge { flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; color: #fff; }
.badge.sm { width: 28px; height: 28px; font-size: 13px; }
.badge.lg { width: 112px; height: 112px; font-family: var(--serif); font-weight: 400; font-size: 56px; }
.badge.ring { background: #fff !important; color: var(--ink-2); border: 2px solid; }

.btn { height: 54px; border: 0; border-radius: 27px; background: var(--primary); color: #fff; font-size: 16px; font-weight: 700; cursor: pointer; width: 100%; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { height: 40px; width: auto; padding: 0 16px; font-size: 13px; border-radius: 20px; }
.btn.ghost { background: transparent; color: var(--primary); text-decoration: underline; height: 44px; font-size: 14px; font-weight: 500; }
.btn.outline { background: var(--surface); color: var(--primary); border: 1.5px solid var(--line-strong); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 700; }
.field label span { font-weight: 400; color: var(--muted); }
.input { height: 48px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); font-size: 16px; width: 100%; }
.input:focus, .btn:focus-visible, button:focus-visible { outline: 3px solid #E0A10088; outline-offset: 2px; }
.checks { display: flex; flex-direction: column; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.4; }
.check input { width: 22px; height: 22px; margin: 0; flex-shrink: 0; accent-color: var(--primary); }

.notice { padding: 12px 14px; border-radius: 12px; background: #FBEFD5; color: #5C3D00; font-size: 14px; }
.error { padding: 12px 14px; border-radius: 12px; background: #F7E1E3; color: #6E1420; font-size: 14px; }

.q { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.q-title { font-size: 17px; font-weight: 700; }
.q-help { font-size: 13px; line-height: 1.4; color: var(--muted); }
.scale { display: flex; justify-content: space-between; }
.star { width: 52px; height: 52px; padding: 0; border: 0; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.dot { width: 48px; height: 48px; padding: 0; border-radius: 50%; border: 1.5px solid var(--line-strong); background: var(--surface); font-size: 16px; font-weight: 700; cursor: pointer; }
.ends { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--ink-2); }
.ends span { display: flex; align-items: center; gap: 6px; }

.coupon { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 20px; background: var(--surface); border: 2px dashed var(--primary); border-radius: 16px; text-align: center; }
.coupon code { font-family: var(--serif); font-size: 34px; letter-spacing: .04em; }
.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; }
.waiting { display: flex; gap: 8px; padding: 8px 0; }
.waiting i { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); animation: pulse 1.2s infinite ease-in-out; }
.waiting i:nth-child(2) { animation-delay: .2s; }
.waiting i:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .waiting i { animation: none; } }

/* ---------- Staff ---------- */
.staff { display: flex; min-height: 100dvh; }
.side { width: 320px; flex-shrink: 0; padding: 28px 24px; display: flex; flex-direction: column; gap: 24px; background: var(--ink); color: var(--ground); }
.side .muted { color: #CFC6B8; font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 12px; background: #3A3B44; }
.stat b { font-size: 26px; }
.stat span { font-size: 12px; color: #CFC6B8; }
.wine-row { display: flex; align-items: center; gap: 10px; }
.wine-row .name { flex: 1; font-size: 13px; line-height: 1.3; }
.wine-row .name.out { text-decoration: line-through; color: #8E8F99; }
.toggle { height: 36px; padding: 0 10px; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; background: transparent; color: var(--ground); border: 1px solid #8E8F99; }
.toggle.on { background: var(--ground); color: var(--ink); border-color: var(--ground); }
.main { flex: 1; padding: 28px 32px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.main-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter { height: 44px; min-width: 44px; padding: 0 14px; border-radius: 22px; font-size: 14px; font-weight: 700; cursor: pointer; background: var(--surface); border: 1.5px solid var(--line-strong); }
.order { display: flex; align-items: center; gap: 18px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.order .mesa { width: 84px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; }
.order .mesa span { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.order .mesa b { font-family: var(--serif); font-weight: 400; font-size: 40px; line-height: 1; }
.order .badge { width: 56px; height: 56px; font-size: 24px; }
.order .info { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.order .info b { font-size: 18px; }
.order .info span { font-size: 14px; color: var(--ink-2); }
.order .btn { width: auto; height: 48px; padding: 0 22px; font-size: 15px; }
.empty { padding: 48px; text-align: center; font-size: 16px; color: var(--ink-2); border: 2px dashed var(--line-strong); border-radius: 14px; }
.pin-box { max-width: 360px; margin: 15vh auto; padding: 28px; background: var(--surface); border-radius: 16px; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 860px) {
  .staff { flex-direction: column; }
  .side { width: auto; }
  .order { flex-wrap: wrap; }
}

/* ---------- Ranking ---------- */
.tv { min-height: 100dvh; padding: 48px 56px; display: flex; gap: 48px; background: #1F1A1D; color: var(--ground); }
.tv .left { flex: 1; display: flex; flex-direction: column; gap: 26px; min-width: 0; }
.tv .kicker { font-size: 14px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #CFC6B8; }
.tv h1 { font-size: 56px; }
.rank { display: flex; align-items: center; gap: 20px; padding: 16px 20px; border-radius: 16px; background: #2A2326; border: 1px solid #2A2326; }
.rank.first { background: #3A2A2F; border-color: #6B4A52; }
.rank .pos { width: 40px; font-family: var(--serif); font-size: 36px; color: #CFC6B8; }
.rank .badge { width: 56px; height: 56px; font-size: 24px; }
.rank .mid { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.rank .mid b { font-size: 22px; }
.bar { height: 8px; border-radius: 4px; background: #3A3236; overflow: hidden; }
.bar > div { height: 100%; border-radius: 4px; background: var(--star); transition: width .6s ease; }
.bar.light > div { background: var(--ground); }
.rank .score { width: 120px; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; }
.rank .score b { font-family: var(--serif); font-weight: 400; font-size: 40px; line-height: 1; }
.rank .score span { font-size: 14px; color: #CFC6B8; }
.tv .right { width: 340px; flex-shrink: 0; display: flex; flex-direction: column; gap: 22px; }
.panel { display: flex; flex-direction: column; gap: 16px; padding: 24px; border-radius: 20px; background: #2E2629; }
.qr-card { display: flex; align-items: center; gap: 18px; padding: 20px; border-radius: 20px; background: var(--ground); color: var(--ink); }
.qr-card img { width: 120px; height: 120px; flex-shrink: 0; }
@media (max-width: 900px) { .tv { flex-direction: column; padding: 24px 16px; } .tv .right { width: auto; } .tv h1 { font-size: 36px; } }

/* ---------- Admin ---------- */
.admin { max-width: 880px; margin: 0 auto; padding: 32px 20px 64px; display: flex; flex-direction: column; gap: 24px; }
.box { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.wine-edit { display: grid; grid-template-columns: 36px minmax(0, 1fr) 64px 110px; gap: 10px; align-items: center; }
.wine-edit input[type=color] { width: 64px; height: 44px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions .btn { width: auto; padding: 0 20px; height: 44px; font-size: 14px; }
.mode { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: #FBEFD5; color: #5C3D00; }
@media (max-width: 640px) { .grid2, .grid4 { grid-template-columns: minmax(0, 1fr); } .wine-edit { grid-template-columns: 30px minmax(0, 1fr) 56px; } .wine-edit select { grid-column: 2 / -1; } }

/* ---------- Tabletents (impresión) ---------- */
.tents { display: none; }
@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; }
  .admin > *:not(.tents) { display: none !important; }
  .tents { display: grid !important; grid-template-columns: repeat(2, 1fr); gap: 8mm; }
  .tent { break-inside: avoid; border: 1px dashed #999; border-radius: 4mm; padding: 8mm; display: flex; flex-direction: column; align-items: center; gap: 4mm; text-align: center; color: #26272E; }
  .tent .num { font-family: var(--serif); font-size: 40pt; line-height: 1; }
  .tent img { width: 50mm; height: 50mm; }
  .tent .t1 { font-size: 14pt; font-weight: 700; }
  .tent .t2 { font-size: 10pt; }
}
