:root {
  color-scheme: light;
  --bg: oklch(0.975 0.004 275);
  --card: #fff;
  --ink: oklch(0.22 0.025 275);
  --mut: oklch(0.47 0.015 275);
  --line: oklch(0.9 0.008 275);
  --acc: oklch(0.47 0.18 278);
  --acc-hover: oklch(0.41 0.18 278);
  --acc-soft: oklch(0.95 0.025 278);
  --ok: oklch(0.38 0.105 155);
  --warn: oklch(0.48 0.1 75);
  --bad: oklch(0.46 0.17 25);
  --nav: #17182a;
  --nav-ink: #f5f5fa;
  --nav-mut: #a9aabb;
  --r: 14px;
}
* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 'Outfit', sans-serif; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: var(--acc); }
h1, h2, h3, p { text-wrap: pretty; }
h1 { font-size: 26px; line-height: 1.18; letter-spacing: -.025em; margin: 3px 0 0; }
h2 { font-size: 16px; line-height: 1.3; letter-spacing: -.012em; margin: 0 0 17px; }
h3 { letter-spacing: -.015em; }
.hide { display: none !important; }
.mut { color: var(--mut); }
.r { text-align: right; }
.eyebrow { display: block; color: var(--mut); font-size: 10px; font-weight: 800; letter-spacing: .13em; }
.app { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
nav { position: sticky; top: 0; height: 100vh; background: var(--nav); color: var(--nav-ink); padding: 25px 12px; display: flex; flex-direction: column; gap: 3px; z-index: 5; }
.brand { display: flex; gap: 11px; align-items: center; padding: 0 13px; color: var(--nav-ink); font-size: 16px; font-weight: 760; letter-spacing: -.025em; white-space: nowrap; }
.brand i { width: 29px; height: 29px; display: block; position: relative; flex: none; border-radius: 8px; background: #7565ed; }
.brand i:before { content: ''; position: absolute; inset: 7px; background: linear-gradient(#fff 0 0) 0 0/5px 5px no-repeat, linear-gradient(#fff 0 0) 100% 0/5px 5px no-repeat, linear-gradient(#fff 0 0) 0 100%/5px 5px no-repeat, linear-gradient(#fff 0 0) 100% 100%/5px 5px no-repeat; }
.nav-caption { margin: 47px 13px 10px; font-size: 10px; font-weight: 750; letter-spacing: .13em; color: #85879e; }
nav button { display: flex; align-items: center; gap: 11px; min-height: 42px; width: 100%; padding: 9px 12px; border: 0; border-radius: 9px; background: transparent; color: var(--nav-mut); text-align: left; font-size: 13px; font-weight: 610; transition: background .18s ease, color .18s ease; }
nav button svg, .icon-btn svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
nav button:hover { background: #292b43; color: #fff; }
nav button.on { background: #353058; color: #fff; }
nav button.on svg { color: #b3a8ff; }
.nav-footer { display: flex; align-items: center; gap: 9px; margin: auto 13px 0; padding-top: 18px; border-top: 1px solid #303149; font-size: 11px; color: var(--nav-mut); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #67caa5; box-shadow: 0 0 0 3px #67caa522; }
main { width: min(100%, 1470px); min-width: 0; margin: 0 auto; padding: 34px clamp(20px, 3.5vw, 52px) 70px; }
header.top { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 25px; }
.page-heading p { color: var(--mut); margin: 4px 0 0; }
.header-tools { display: flex; align-items: center; gap: 16px; }
.event-control { min-width: 222px; }
.event-control label { margin-bottom: 4px; }
.userbox { display: flex; align-items: center; gap: 9px; padding-left: 16px; border-left: 1px solid var(--line); }
.avatar { display: grid; place-items: center; width: 33px; height: 33px; flex: none; border-radius: 9px; background: var(--acc-soft); color: var(--acc); font-weight: 800; }
.user-meta { min-width: 92px; line-height: 1.22; }
.user-meta b { display: block; max-width: 135px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.user-meta span { color: var(--mut); font-size: 11px; }
.icon-btn { width: 33px; height: 33px; flex: none; display: grid; place-items: center; padding: 0; color: var(--mut); background: transparent; border: 0; border-radius: 8px; }
.icon-btn:hover { color: var(--ink); background: var(--line); }
select, input, textarea { width: 100%; min-height: 40px; background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; color: var(--ink); outline: 0; }
input::placeholder, textarea::placeholder { color: oklch(.49 .012 275); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, .type:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
label { display: block; margin-bottom: 5px; color: var(--mut); font-size: 11px; font-weight: 700; letter-spacing: .035em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.grid { display: grid; gap: 15px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.f { display: grid; gap: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 40px; padding: 9px 15px; background: var(--acc); border: 1px solid var(--acc); border-radius: 9px; color: #fff; font-weight: 700; text-align: center; text-decoration: none; transition: background .18s ease, border-color .18s ease, transform .18s ease; }
.btn:hover:not(:disabled) { background: var(--acc-hover); border-color: var(--acc-hover); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.sec { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn.sec:hover:not(:disabled) { background: var(--bg); border-color: oklch(.78 .01 275); }
.btn.sm { min-height: 32px; padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.light { color: #29204a; background: #fff; border-color: #fff; }
.btn.light:hover { background: #eeebff; border-color: #eeebff; }
.btn.outline-light { border-color: #8a83b1; background: transparent; color: #fff; }
.btn.outline-light:hover { background: #ffffff18; border-color: #b7b0d8; }
.overview-banner { display: flex; align-items: end; justify-content: space-between; gap: 22px; min-height: 178px; margin-bottom: 18px; padding: 26px 30px; background: linear-gradient(110deg,#25213e,#37305f 72%,#4c3d7b); border-radius: 14px; color: #fff; overflow: hidden; }
.overview-banner .eyebrow { color: #c2badf; }
.overview-banner h2 { font-size: 26px; line-height: 1.2; margin: 12px 0 5px; color: #fff; }
.overview-banner p { margin: 0; color: #d3cee7; }
.overview-actions { display: flex; gap: 8px; flex-wrap: wrap; flex: none; }
.kpi { min-height: 125px; padding: 19px; }
.kpi small { color: var(--mut); font-size: 11px; font-weight: 650; }
.kpi b { display: block; margin-top: 12px; font-size: 27px; line-height: 1.1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi:first-child b { color: var(--acc); }
.bar { height: 7px; margin-top: 8px; border-radius: 5px; overflow: hidden; background: var(--bg); }
.bar i { display: block; height: 100%; border-radius: 5px; background: var(--acc); }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; color: var(--mut); font-size: 10px; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg); }
.pill { display: inline-block; border-radius: 6px; padding: 4px 8px; font-size: 11px; font-weight: 740; white-space: nowrap; }
.p-valid,.p-paid { background: oklch(.93 .04 155); color: var(--ok); }
.p-used,.p-pending { background: oklch(.96 .04 80); color: var(--warn); }
.p-cancelled,.p-rejected,.p-expired,.p-refunded { background: oklch(.95 .035 25); color: var(--bad); }
.types { display: grid; gap: 9px; }
.type { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); text-align: left; cursor: pointer; }
.type:hover { border-color: oklch(.7 .07 278); }
.type.on { border-color: var(--acc); background: var(--acc-soft); }
.type b { font-size: 15px; }
.qty { display: flex; align-items: center; gap: 7px; }
.qty button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--ink); font-size: 20px; }
.qty button:hover { background: var(--bg); }
.qty input { width: 62px; text-align: center; }
.total { font-size: 27px; font-weight: 800; letter-spacing: -.025em; }
.res { margin-top: 17px; padding: 24px; border-radius: 11px; text-align: center; }
.res.ok { background: oklch(.94 .035 155); color: var(--ok); }
.res.used { background: oklch(.95 .04 80); color: var(--warn); }
.res.bad { background: oklch(.95 .04 25); color: var(--bad); }
.res h3 { margin: 0; font-size: 22px; }
.res p { margin: 5px 0 0; color: var(--ink); }
#reader { width: 100%; max-width: 420px; margin: auto; border-radius: 10px; overflow: hidden; }
.tix { display: grid; grid-template-columns: repeat(auto-fill,minmax(190px,1fr)); gap: 10px; margin-top: 15px; }
.tix .t { padding: 14px; border: 1px solid var(--line); border-radius: 10px; text-align: center; }
.tix img { width: 150px; height: 150px; background: #fff; border-radius: 7px; }
.tix .c { color: var(--mut); font: 600 11px ui-monospace,Menlo,monospace; letter-spacing: .07em; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); padding: 11px 18px; border-radius: 9px; background: var(--ink); color: var(--card); font-weight: 650; z-index: 20; }
.note { padding: 12px 14px; border-radius: 9px; background: oklch(.96 .04 80); color: var(--ink); font-size: 13px; }
.note.good { background: oklch(.94 .035 155); }
code { padding: 2px 5px; border-radius: 4px; background: var(--bg); font-size: 12px; overflow-wrap: anywhere; }
#login { min-height: 100vh; padding: 6vh 20px 40px; background: linear-gradient(180deg,#202039 0 35%,var(--bg) 35%); }
#loginForm { max-width: 410px; margin: 6vh auto 0; padding: 32px; gap: 18px; }
#login .brand { padding: 0; color: var(--ink); }
.login-heading { margin-top: 18px; }
.login-heading h1 { margin-top: 7px; font-size: 24px; }
.login-heading p { margin: 7px 0 0; color: var(--mut); }
#loginForm .btn { width: 100%; }
.demo-link { display: flex; justify-content: center; gap: 7px; color: var(--acc); font-size: 12px; font-weight: 720; text-decoration: none; }
.demo-link:hover { text-decoration: underline; }
@media (max-width: 1120px) {
  .app { grid-template-columns: 190px minmax(0,1fr); }
  .user-meta { display: none; }
  .g4 { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 820px) {
  .app { display: block; }
  nav { position: fixed; inset: auto 0 0; height: auto; padding: 7px max(6px,env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(6px,env(safe-area-inset-left)); flex-direction: row; justify-content: space-around; gap: 2px; border-top: 1px solid #333348; }
  nav .brand, .nav-caption, .nav-footer { display: none; }
  nav button { width: auto; min-width: 58px; flex: 1; flex-direction: column; gap: 3px; padding: 7px 3px; font-size: 10px; line-height: 1.15; text-align: center; justify-content: center; }
  nav button svg { width: 19px; height: 19px; }
  main { padding: 23px 18px calc(110px + env(safe-area-inset-bottom)); }
  .top { align-items: start !important; }
  .header-tools { width: 100%; justify-content: space-between; }
  .event-control { flex: 1; min-width: 0; }
  .userbox { gap: 2px; align-self: end; padding-left: 9px; }
  .avatar { display: none; }
  .overview-banner { align-items: start; flex-direction: column; }
  .overview-actions { width: 100%; }
  .g2,.g3 { grid-template-columns: 1fr; }
  .toast { bottom: calc(86px + env(safe-area-inset-bottom)); }
}
@media (max-width: 500px) {
  h1 { font-size: 23px; }
  .overview-banner { padding: 23px; }
  .overview-banner h2 { font-size: 23px; }
  .overview-actions .btn { flex: 1; }
  .g4 { gap: 10px; }
  .kpi { min-height: 102px; padding: 14px; }
  .kpi b { font-size: 22px; }
  .card { padding: 16px; }
  #v-sale .row:has(.total) { align-items: stretch; }
  #saleBtn { width: 100%; }
}
@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --bg: #141521; --card: #1d1e2c; --ink: #f1f0f6; --mut: #aaaabc; --line: #343547; --acc: #a095ff; --acc-hover: #b0a7ff; --acc-soft: #302b49; --ok: #89dbb1; --warn: #f1c580; --bad: #f5a59e; }
  .overview-banner { background: linear-gradient(110deg,#29233f,#42336b); }
  .p-valid,.p-paid { background: #244036; }
  .p-used,.p-pending,.note { background: #423724; }
  .p-cancelled,.p-rejected,.p-expired,.p-refunded { background: #492b31; }
  .res.ok,.note.good { background: #244036; }
  .res.used { background: #423724; }
  .res.bad { background: #492b31; }
  .btn { color: #181323; }
  .btn.light { color: #29204a; }
}
@media (prefers-reduced-motion: reduce) { *,*:before,*:after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Ajustes: una sola columna cuando no caben dos (las tablas de usuarios y los formularios se cortaban) */
@media (max-width: 1280px) { #v-setup > .g2 { grid-template-columns: 1fr; } }

/* ---- Modal propio ---- */
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.danger:hover:not(:disabled) { background: var(--bad); border-color: var(--bad); filter: brightness(.92); }
.modal { width: min(440px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 16px; background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line), 0 28px 80px -24px rgba(20,16,40,.5); }
.modal::backdrop { background: oklch(.18 .03 275 / .55); backdrop-filter: blur(3px); }
.modal[open] { animation: modal-in .18s ease-out; }
.modal[open]::backdrop { animation: modal-fade .18s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes modal-fade { from { opacity: 0; } }
.modal form { padding: 24px; }
.modal header { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.m-icon { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--acc-soft); color: var(--acc); }
.m-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.modal.danger .m-icon { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.modal h2 { margin: 2px 0 4px; font-size: 18px; letter-spacing: -.01em; }
.modal header p { margin: 0; color: var(--mut); font-size: 14px; line-height: 1.5; }
.m-fields { display: grid; gap: 14px; }
.m-field label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.m-field.error input { border-color: var(--bad); }
.m-msg { display: block; margin-top: 5px; color: var(--bad); font-size: 12.5px; font-weight: 500; }
.m-hint { display: block; margin-top: 5px; color: var(--mut); font-size: 12.5px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 84px; }
.pw-toggle { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); padding: 6px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--acc); font-size: 12.5px; font-weight: 600; }
.pw-toggle:hover { background: var(--acc-soft); }
.m-error { margin: 14px 0 0; padding: 10px 12px; border-radius: 9px; background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); font-size: 13.5px; font-weight: 500; }
.modal footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
@media (max-width: 560px) {
  .modal { width: 100%; max-width: none; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  .modal[open] { animation-name: sheet-in; }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
  .modal form { padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); }
  .modal footer .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { .modal[open], .modal[open]::backdrop { animation: none; } }
.m-check { display: flex; align-items: flex-start; gap: 10px; margin: 0 !important; font-weight: 500 !important; cursor: pointer; line-height: 1.45; }
.m-check input { flex: none; width: 18px; min-height: 0; height: 18px; margin-top: 2px; accent-color: var(--acc); }
.modal select { width: 100%; }
