[hidden] { display: none !important; }
:root {
  --brand: #B71C1C;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #e4e4e8;
  --bg: #f6f6f8;
  --card: #fff;
  --ok: #1b8a3a;
  --ok-bg: #e7f6ec;
  --bad: #c62828;
  --bad-bg: #fdecec;
  --warn: #9a6700;
  --warn-bg: #fff6dc;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); line-height: 1.45; font-size: 16px; -webkit-text-size-adjust: 100%; }
a { color: var(--brand); }
img { max-width: 100%; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .4rem; }
h2 { font-size: 1.2rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.wrap-wide { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* Cabecera pública */
.hero { background: var(--brand); color: #fff; padding: 28px 0 24px; }
.hero h1 { color: #fff; }
.hero p { margin: .2rem 0; opacity: .92; }
.hero .org { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
.site-foot { padding: 28px 0 40px; color: var(--muted); font-size: .85rem; text-align: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 16px 0; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }

/* Formularios */
label { display: block; font-weight: 600; font-size: .92rem; margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=datetime-local],
input[type=color], select, textarea {
  width: 100%; font: inherit; padding: 11px 12px; border: 1px solid #cfcfd6; border-radius: 10px; background: #fff; color: var(--ink);
}
input[type=color] { padding: 4px; height: 44px; }
textarea { min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.row { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 640px) { .row.two { grid-template-columns: 1fr 1fr; } .row.three { grid-template-columns: 1fr 1fr 1fr; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 700; border: 0;
  border-radius: 12px; padding: 13px 20px; background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; min-height: 48px; }
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid #cfcfd6; }
.btn.danger { background: var(--bad); }
.btn.small { padding: 7px 12px; min-height: 36px; font-size: .9rem; border-radius: 9px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.alert { border-radius: 12px; padding: 12px 14px; margin: 14px 0; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert ul { margin: 0; padding-left: 18px; }

/* Productos */
.product { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.product:last-child { border-bottom: 0; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; display: inline-block; vertical-align: middle; }
.product .info { flex: 1; min-width: 0; }
.product .name { font-weight: 700; }
.product .price { font-weight: 700; white-space: nowrap; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid #cfcfd6; background: #fff; font-size: 1.3rem; cursor: pointer; color: var(--ink); }
.qty input { width: 54px; text-align: center; padding: 8px 4px; }
.total { display: flex; justify-content: space-between; font-size: 1.15rem; font-weight: 800; padding-top: 12px; }

/* Tickets */
.tickets { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 560px) { .tickets { grid-template-columns: 1fr 1fr; } }
.ticket { background: #fff; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; text-align: center; }
.ticket .band { color: #fff; font-weight: 800; padding: 10px; font-size: 1.05rem; }
.ticket .qr svg { width: 100%; max-width: 260px; height: auto; display: block; margin: 8px auto 0; }
.ticket .code { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; font-size: 1rem; padding: 4px 0 14px; }
.ticket.used .qr { opacity: .15; }
.ticket .stamp { font-weight: 800; color: var(--muted); padding-bottom: 12px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 700; background: #eee; color: #333; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* Tablas (panel) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; background: #fff; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafafb; }
td.num, th.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 800; background: #fafafb; }

/* Panel */
.topbar { background: #1d1d1f; color: #fff; }
.topbar .wrap-wide { display: flex; align-items: center; gap: 18px; min-height: 56px; flex-wrap: wrap; }
.topbar a { color: #fff; text-decoration: none; opacity: .85; font-size: .95rem; }
.topbar a:hover, .topbar a.on { opacity: 1; text-decoration: underline; }
.topbar .brand { font-weight: 800; opacity: 1; margin-right: auto; }
.topbar .who { font-size: .85rem; opacity: .7; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 22px 0 6px; }
.page-head h1 { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 14px 0; }
@media (min-width: 800px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.kpi .v { font-size: 1.45rem; font-weight: 800; }
.kpi .l { font-size: .82rem; color: var(--muted); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.tabs a { padding: 8px 12px; border-radius: 9px; text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); font-size: .92rem; }
.tabs a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.inline-form { display: inline; }

/* Lector */
body.scanner { background: #111; color: #fff; min-height: 100vh; min-height: 100dvh; }
.scanner .bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; gap: 10px; }
.scanner .bar .who { font-weight: 700; }
.scanner .bar a, .scanner .bar button { color: #ddd; background: none; border: 0; font: inherit; text-decoration: underline; cursor: pointer; }
.viewport { position: relative; margin: 0 16px; border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 1 / 1; max-height: 58vh; }
.viewport video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewport .frame { position: absolute; inset: 14%; border: 3px solid rgba(255,255,255,.85); border-radius: 18px; pointer-events: none; }
.viewport .hint { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-size: .9rem; opacity: .85; }
.result { position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; z-index: 10; }
.result.show { display: flex; }
.result.ok { background: #1b8a3a; }
.result.bad { background: #c62828; }
.result.warn { background: #b26a00; }
.result .big { font-size: 2.3rem; font-weight: 900; line-height: 1.1; }
.result .prod { margin-top: 18px; font-size: 2rem; font-weight: 900; padding: 10px 22px; border-radius: 14px; background: rgba(255,255,255,.95); color: #111; }
.result .detail { margin-top: 14px; font-size: 1.15rem; }
.result .tap { margin-top: 28px; opacity: .85; }
.scanner .manual { margin: 14px 16px; display: flex; gap: 8px; }
.scanner .manual input { flex: 1; text-transform: uppercase; font-family: ui-monospace, Menlo, monospace; letter-spacing: .08em; }
.scanner .today { margin: 6px 16px 24px; font-size: .95rem; }
.scanner .today .pill { display: inline-flex; align-items: center; gap: 6px; background: #222; border-radius: 99px; padding: 5px 11px; margin: 4px 4px 0 0; }
.scanner .card { background: #1c1c1e; border-color: #2c2c2e; color: #fff; }
.scanner input { background: #fff; color: #111; }
.scanner .err { color: #ff8a80; }
