:root {
  --bg: #f6f4ef; --surface: #ffffff; --ink: #1d1b18; --muted: #6b665e; --line: #e4dfd5;
  --accent: #7a1f2b; --accent-ink: #ffffff; --accent-soft: #f6e7e9;
  --ok: #1f7a46; --ok-soft: #e3f3e9; --warn: #9a6200; --warn-soft: #fdf1dc; --bad: #b3261e; --bad-soft: #fbe5e3;
  --wa: #1f8f4e; --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 16px; line-height: 1.45; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); } .small { font-size: .875rem; }
.hidden { display: none !important; }

/* Barra superior y pestañas */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--accent); color: var(--accent-ink); }
.topbar .row1 { display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.topbar .title { font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .who { font-size: .85rem; opacity: .9; }
@media (max-width: 560px) { .topbar .who { display: none; } }
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 0 12px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; color: rgba(255,255,255,.8); padding: 10px 12px; font: inherit; font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; cursor: pointer; }
.tabs button.on { color: #fff; border-bottom-color: #fff; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }

/* Tarjetas y formularios */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
label { display: block; font-weight: 600; font-size: .9rem; margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=tel], input[type=number], select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #cfc8bb; border-radius: 10px; background: #fff; color: var(--ink); }
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; padding: 10px 14px;
  border-radius: 10px; border: 1px solid #cfc8bb; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; min-height: 42px; }
.btn:hover { background: #faf8f4; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { color: var(--bad); border-color: #e6b8b4; }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: .875rem; }
.btn:disabled { opacity: .5; cursor: default; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

/* Indicadores */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .n { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: .85rem; }
.stat.big { grid-column: span 2; }
.meter { height: 10px; border-radius: 6px; background: #ece7dd; overflow: hidden; margin-top: 8px; }
.meter > div { height: 100%; background: var(--accent); }

/* Estados */
.tag { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.tag.espera { background: #eeeae2; color: #5c574f; }
.tag.aprobado { background: var(--warn-soft); color: var(--warn); }
.tag.enviado { background: #e5eefb; color: #1d4f91; }
.tag.registrado { background: var(--ok-soft); color: var(--ok); }
.tag.no_asiste { background: var(--bad-soft); color: var(--bad); }
.tag.entro { background: var(--ok); color: #fff; }
.tag.v { background: #f1ecf7; color: #5b3a87; }

/* Lista de invitados */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar input[type=text] { flex: 1 1 220px; width: auto; }
.toolbar select { width: auto; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item { display: grid; grid-template-columns: 52px 1fr auto; gap: 8px 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .pos { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; text-align: right; }
.item .name { font-weight: 600; }
.item .meta { font-size: .85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.item .acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
@media (max-width: 640px) {
  .item { grid-template-columns: 40px 1fr; }
  .item .acts { grid-column: 1 / -1; justify-content: flex-start; }
}
.empty { padding: 28px; text-align: center; color: var(--muted); }
.more { padding: 12px; text-align: center; }

/* Avisos */
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #222; color: #fff; padding: 12px 16px; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 100; max-width: calc(100% - 32px); display: flex; gap: 12px; align-items: center; }
#toast button { background: none; border: 0; color: #ffd28a; font: inherit; font-weight: 700; cursor: pointer; }
.note { background: var(--warn-soft); border: 1px solid #f0d9a8; border-radius: 10px; padding: 10px 12px; font-size: .9rem; }
.note.info { background: #eef3fb; border-color: #cfdcf2; }

/* Diálogo */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100% - 24px)); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(20,15,10,.45); }
dialog .dhead { padding: 16px 16px 0; } dialog .dbody { padding: 0 16px 16px; max-height: 70vh; overflow: auto; }

/* Portería */
.scanner { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3 / 4; max-height: 60vh; margin: 0 auto; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.85); border-radius: 18px; pointer-events: none; }
.verdict { border-radius: var(--radius); padding: 20px; text-align: center; color: #fff; margin: 12px 0; }
.verdict .big { font-size: 1.9rem; font-weight: 800; letter-spacing: .02em; }
.verdict .who { font-size: 1.3rem; font-weight: 600; margin-top: 4px; }
.verdict.ok { background: var(--ok); } .verdict.warn { background: #c27c00; } .verdict.bad { background: var(--bad); }

/* Tabla de usuarios */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.img-prev { max-width: 100%; max-height: 160px; border-radius: 8px; border: 1px solid var(--line); display: block; margin: 8px 0; background: #eee; }
.card-prev { width: 100%; max-width: 360px; border-radius: 12px; box-shadow: var(--shadow); display: block; }

/* Inicio de sesión */
.login { max-width: 380px; margin: 10vh auto; padding: 0 16px; }
.login .brand { text-align: center; margin-bottom: 16px; color: var(--accent); }

/* Galería de arte */
.art-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.art-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.art-item.on { border: 2px solid var(--ok); }
.art-item img { width: 100%; aspect-ratio: 1600 / 1467; object-fit: cover; display: block; background: #eee; }
.art-body { padding: 10px 12px 12px; }
.art-body .name { font-weight: 600; }
.arte-layout { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.arte-layout .arte-prev { position: sticky; top: 110px; }
@media (max-width: 800px) { .arte-layout { grid-template-columns: 1fr; } .arte-layout .arte-prev { position: static; } }

/* Interruptor */
.switch-row { display: flex; gap: 14px; align-items: center; }
.switch { position: relative; display: inline-block; width: 58px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #c9c2b6; border-radius: 32px; transition: .2s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; width: 26px; height: 26px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(26px); }
.switch input:focus-visible + .slider { outline: 3px solid var(--accent-soft); }
.on-txt { color: var(--ok); } .off-txt { color: var(--bad); }
/* Selección para aprobar */
.pick { display: flex; align-items: center; gap: 6px; justify-content: flex-end; cursor: pointer; }
.pick input { width: 20px; height: 20px; }
.item { grid-template-columns: 76px 1fr auto; }
@media (max-width: 640px) { .item { grid-template-columns: 64px 1fr; } }
.selbar { position: sticky; top: 104px; z-index: 5; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 10px; margin-bottom: 8px; }
.selbar span { flex: 1; font-weight: 600; }
.selbar .btn.primary { background: #fff; color: var(--accent); border-color: #fff; }
