:root {
    color-scheme: light;
    --paper: #f7f6f2;
    --surface: #fff;
    --ink: #062c35;
    --muted: #5e7073;
    --line: #e1e5df;
    --coral: #dc5d42;
    --coral-dark: #b7442e;
    --peach: #fee3d9;
    --sage: #edf2eb;
    --success: #326047;
    --danger: #953d36;
    font-family: 'DM Sans', 'Segoe UI', Arial, sans-serif;
    color: var(--ink);
    background: var(--paper);
    font-synthesis: none;
    -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, summary { cursor: pointer; }
button { color: inherit; }
button, a { transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--coral-dark); outline-offset: 4px; }
h1, h2, p { margin: 0; }
p { line-height: 1.6; }
h1, h2 { overflow-wrap: anywhere; }
.icon { width: 22px; height: 22px; flex: none; display: block; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: fixed; z-index: 5; top: 12px; left: 12px; padding: 12px; background: var(--surface); color: var(--ink); }

.portal-shell { width: min(100%, 520px); margin: 0 auto; padding: 0 max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 100px; padding-top: env(safe-area-inset-top); border-bottom: 1px solid var(--line); }
.brand-logo { display: block; width: 116px; height: auto; }
.header-label { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--muted); }
.header-label .icon { width: 18px; height: 18px; }
.text-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 10px 8px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.text-button:active { background: var(--line); color: var(--ink); }
.text-button .icon { width: 18px; height: 18px; }
.eyebrow { display: block; font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: 1.8px; color: var(--coral-dark); }
.access-intro { padding: 30px 0 24px; }
.access-intro h1 { margin: 10px 0 12px; font-size: clamp(32px, 8.6vw, 42px); font-weight: 750; letter-spacing: -1.6px; line-height: 1.12; }
.access-intro h1 span { color: var(--coral-dark); }
.access-intro > p { max-width: 340px; color: var(--muted); font-size: 15px; line-height: 1.55; }
.access-card { border: 1px solid var(--line); border-radius: 24px; background: var(--surface); padding: 22px; box-shadow: 0 6px 24px rgb(6 44 53 / 3%); }
.access-card-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.icon-tile { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 14px; background: var(--peach); color: var(--coral-dark); }
.access-card-heading h2 { font-size: 19px; font-weight: 700; letter-spacing: -.4px; line-height: 1.3; }
.access-card-heading p { margin-top: 3px; font-size: 13px; color: var(--muted); }
.login { display: grid; gap: 18px; }
.form-field { min-width: 0; }
.form-field label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 650; }
.input-wrap { position: relative; }
.input-wrap > .icon { position: absolute; left: 15px; top: 16px; width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
.input-wrap input { display: block; width: 100%; min-height: 52px; border: 1px solid #b7c2c1; border-radius: 12px; background: #fcfcfa; padding: 13px 12px 13px 45px; color: var(--ink); font-size: 16px; line-height: 24px; outline: none; }
.input-wrap input::placeholder { color: #758183; opacity: 1; }
.input-wrap input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgb(6 44 53 / 12%); background: var(--surface); }
.field-hint { margin-top: 7px; font-size: 12px; color: var(--muted); }
.primary-button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 52px; padding: 14px 16px; border: 0; border-radius: 12px; background: var(--ink); color: var(--surface); font-size: 15px; font-weight: 650; line-height: 1.4; text-align: center; text-decoration: none; }
.primary-button > .icon:last-child { width: 18px; height: 18px; margin-left: auto; }
.login .primary-button > span { margin-right: auto; }
.primary-button:active { background: #18515b; }
.primary-button:disabled { opacity: .7; }
.access-note { display: flex; justify-content: center; align-items: flex-start; gap: 7px; padding-top: 16px; margin-top: 20px; border-top: 1px dashed var(--line); font-size: 11px; color: var(--muted); }
.access-note .icon { width: 14px; height: 14px; margin-top: 2px; }
.error { margin: 0 0 20px; padding: 14px 16px; border: 1px solid #e8b8aa; border-radius: 12px; background: #fff0e9; color: #873421; font-size: 14px; }

.wallet-intro { padding: 28px 0 24px; }
.welcome { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.wallet-intro h1 { margin: 5px 0 7px; font-size: 38px; line-height: 1.12; font-weight: 750; letter-spacing: -1.5px; }
.heading-dot { color: var(--coral); }
.wallet-intro > p:last-child { font-size: 15px; color: var(--muted); }
.entry-tip { display: flex; align-items: center; gap: 14px; padding: 17px; background: var(--ink); border-radius: 16px; color: var(--surface); }
.entry-tip > .icon { width: 27px; height: 27px; color: var(--peach); }
.entry-tip strong { display: block; font-size: 14px; line-height: 1.5; font-weight: 650; }
.entry-tip p > span { display: block; margin-top: 3px; font-size: 12px; line-height: 1.5; color: #d3dfda; }
.ticket-filters { display: flex; gap: 4px; padding: 5px; margin: 24px 0 14px; background: #e9ece6; border: 1px solid #e3e7e0; border-radius: 14px; }
.ticket-filters button { display: flex; align-items: center; justify-content: center; gap: 8px; flex: 1; min-width: 0; min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); padding: 10px 8px; font-size: 13px; font-weight: 650; line-height: 1.3; }
.ticket-filters button[aria-pressed="true"] { color: var(--ink); background: var(--surface); box-shadow: 0 2px 4px rgb(6 44 53 / 6%); }
.ticket-filters button > span { display: inline-grid; place-items: center; min-width: 22px; min-height: 22px; padding: 2px 5px; border-radius: 7px; background: #e9ece6; font-size: 11px; }
.ticket-filters button[aria-pressed="true"] > span { background: var(--peach); }
.list-summary { margin: 16px 2px 12px; color: var(--muted); font-size: 12px; }
.tickets { display: grid; gap: 18px; }
.ticket { min-width: 0; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: 0 4px 16px rgb(6 44 53 / 2%); }
.ticket-topline { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 18px 20px 0; }
.ticket-number { color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: 1.5px; }
.status { display: inline-flex; align-items: center; gap: 4px; padding: 5px 8px; border-radius: 7px; background: #eef0ed; color: var(--muted); font-size: 11px; line-height: 1.3; font-weight: 650; }
.status .icon { width: 13px; height: 13px; }
.status-valida { color: var(--success); background: var(--sage); }
.status-anulada, .status-invalida { color: var(--danger); background: #faece8; }
.status-pendiente { color: #815f20; background: #faf1db; }
.ticket-heading { display: flex; align-items: center; gap: 14px; padding: 18px 20px 22px; }
.ticket-info { flex: 1; min-width: 0; }
.ticket-info h2 { font-size: 21px; line-height: 1.3; letter-spacing: -.45px; font-weight: 700; }
.ticket-info p { margin-top: 6px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.ticket-thumbnail { display: block; flex: none; width: 64px; height: 76px; object-fit: contain; border-radius: 9px; background: var(--paper); }
.ticket-stub { position: relative; padding: 16px 20px 20px; border-top: 1px dashed #ccd5ce; }
.ticket-stub::before, .ticket-stub::after { content: ''; position: absolute; top: -8px; width: 14px; height: 14px; background: var(--paper); border: 1px solid var(--line); border-radius: 50%; }
.ticket-stub::before { left: -8px; border-left-color: var(--paper); border-bottom-color: var(--paper); transform: rotate(45deg); }
.ticket-stub::after { right: -8px; border-right-color: var(--paper); border-top-color: var(--paper); transform: rotate(45deg); }
.ticket-reference { margin-bottom: 15px; }
.ticket-reference > span { display: block; font-size: 10px; color: var(--muted); }
.code { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; overflow-wrap: anywhere; }
.ticket-reference .code { margin-top: 2px; font-size: 14px; line-height: 1.5; letter-spacing: .6px; }
.qr-open { min-height: 48px; padding: 12px 14px; }
.qr-open > .icon:first-child { width: 18px; height: 18px; }
.ticket-state-note { padding: 12px; border-radius: 10px; background: var(--paper); color: var(--muted); font-size: 13px; }
.empty-state { padding: 32px 20px; text-align: center; border: 1px dashed #bfcac2; border-radius: 20px; }
.empty-state > .icon { width: 36px; height: 36px; margin: 0 auto 16px; color: var(--coral-dark); }
.empty-state h2 { font-size: 19px; }
.empty-state p { color: var(--muted); font-size: 14px; margin-top: 12px; }
.empty-state > a { margin-top: 20px; }

.help-section { margin-top: 30px; }
.help-section h2 { margin-bottom: 9px; font-size: 13px; font-weight: 650; color: var(--muted); }
.help-section details { border-bottom: 1px solid var(--line); }
.help-section summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; list-style: none; min-height: 52px; padding: 13px 0; font-size: 14px; font-weight: 600; }
.help-section summary::-webkit-details-marker { display: none; }
.help-section summary .icon { width: 16px; height: 16px; color: var(--muted); transform: rotate(90deg); }
.help-section details[open] summary .icon { transform: rotate(-90deg); }
.help-section details > p { padding: 0 12px 18px 0; color: var(--muted); font-size: 14px; }
.site-footer { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 36px; text-align: center; color: var(--muted); font-size: 11px; line-height: 1.5; }
.footer-thread { width: 34px; height: 5px; border-top: 1px solid var(--coral); border-bottom: 1px solid var(--coral); border-radius: 50%; }

body.qr-modal-open { overflow: hidden; }
#qr-dialog { width: 100%; max-width: none; height: 100%; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; color: var(--ink); background: var(--paper); }
#qr-dialog[open] { display: flex; flex-direction: column; }
#qr-dialog::backdrop { background: rgb(6 30 36 / 75%); }
.qr-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex: none; min-height: 76px; padding: max(12px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); }
.qr-header > span { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 650; }
.qr-header > span .icon { color: var(--coral-dark); }
.qr-content { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 28px max(20px, env(safe-area-inset-right)) 24px max(20px, env(safe-area-inset-left)); text-align: center; }
#qr-title { max-width: 380px; margin: 10px auto 0; font-size: 24px; line-height: 1.25; letter-spacing: -.5px; }
.qr-order { color: var(--muted); font-size: 13px; margin-top: 8px; overflow-wrap: anywhere; }
.qr-frame { position: relative; display: grid; place-items: center; width: min(100%, 340px); aspect-ratio: 1; margin: 24px auto 16px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); padding: 10px; }
#qr-image { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.qr-loading { display: flex; flex-direction: column; align-items: center; gap: 16px; color: var(--muted); font-size: 14px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin 800ms linear infinite; }
.qr-error { padding: 16px; font-size: 14px; }
.qr-error > button { margin-top: 16px; }
.qr-error > a { display: flex; font-size: 12px; margin-top: 8px; }
#qr-code { font-size: 16px; letter-spacing: 1px; }
#qr-instruction { font-size: 13px; color: var(--muted); margin-top: 18px; }
.brightness-tip { display: inline-flex; justify-content: center; align-items: center; gap: 7px; padding: 10px 12px; margin-top: 18px; border-radius: 10px; background: var(--peach); font-size: 12px; }
.brightness-tip .icon { width: 17px; height: 17px; }
.qr-footer { flex: none; padding: 14px max(20px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: var(--surface); }
.qr-footer > p { margin-top: 10px; font-size: 11px; text-align: center; color: var(--muted); }
.qr-navigation[hidden] + p { margin-top: 0; }
.qr-navigation { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: var(--sage); color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 600; line-height: 1.4; }
.secondary-button:active:not(:disabled) { background: #d7e0d3; }
.secondary-button .icon { width: 16px; height: 16px; }
#qr-prev > .icon { transform: rotate(180deg); }
#qr-position { font-size: 12px; font-weight: 650; white-space: nowrap; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (hover: hover) {
    .primary-button:hover { background: #18515b; }
    .text-button:hover { background: var(--line); color: var(--ink); }
    .secondary-button:hover:not(:disabled) { background: #d7e0d3; }
    .help-section summary:hover { color: var(--coral-dark); }
}
@media (min-width: 700px) {
    .portal-shell { padding-top: 24px; }
    .site-header { min-height: 100px; }
    .access-intro { padding-top: 40px; }
    .access-card { padding: 28px; }
    #qr-dialog { width: min(92vw, 480px); height: auto; max-height: 92vh; max-height: 92dvh; margin: auto; border: 1px solid var(--line); border-radius: 24px; }
    .qr-content { flex: 0 1 auto; }
}
@media (max-width: 359px) {
    .portal-shell { padding-left: 16px; padding-right: 16px; }
    .brand-logo { width: 100px; }
    .header-label { font-size: 11px; gap: 5px; }
    .access-card { padding: 18px; }
    .access-card-heading { gap: 10px; }
    .access-card-heading h2 { font-size: 18px; }
    .access-card-heading p { font-size: 12px; }
    .ticket-topline, .ticket-heading, .ticket-stub { padding-left: 16px; padding-right: 16px; }
    .qr-navigation button { padding-left: 8px; padding-right: 8px; font-size: 12px; }
}
@media (min-width: 600px) and (max-height: 540px) {
    #qr-dialog { width: 100%; height: 100dvh; max-height: none; margin: 0; border: 0; border-radius: 0; }
    .qr-header { min-height: 60px; padding-top: 8px; padding-bottom: 8px; }
    .qr-content { display: grid; flex: 1; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 24px; row-gap: 6px; align-content: start; align-content: safe center; text-align: left; padding-top: 12px; padding-bottom: 12px; }
    .qr-content > .eyebrow { display: none; }
    .qr-frame { grid-column: 1; grid-row: 1 / span 5; width: min(100%, 260px, calc(100dvh - 195px)); margin: 0; align-self: center; justify-self: center; padding: 4px; border-radius: 12px; }
    #qr-title, .qr-order, #qr-code, #qr-instruction, .brightness-tip { grid-column: 2; margin: 0; max-width: 380px; }
    #qr-title { font-size: 19px; }
    #qr-code { font-size: 13px; }
    #qr-instruction { font-size: 12px; }
    .brightness-tip { justify-self: start; padding: 6px 9px; }
    .qr-footer { padding-top: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
    .qr-footer > p { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
