:root {
    --ink: #10233f;
    --navy: #091526;
    --panel: #12233b;
    --muted: #718096;
    --line: #dce4ee;
    --paper: #f4f7fb;
    --white: #ffffff;
    --mint: #27d5a4;
    --mint-dark: #0a805f;
    --red: #f34f64;
    --red-dark: #a71d34;
    --amber: #ffbd4a;
    --shadow: 0 24px 70px rgba(15, 35, 64, .12);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 0 0, rgba(39, 213, 164, .11), transparent 30rem),
        var(--paper);
    font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
a { color: inherit; }

.site-header {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
    padding: 0 clamp(18px, 4vw, 54px);
    color: var(--white);
    background: rgba(9, 21, 38, .96);
    backdrop-filter: blur(12px);
}
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 700; text-decoration: none; }
.brand-mark {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    color: var(--navy);
    border-radius: 11px;
    background: var(--mint);
    font-size: 19px;
}
.header-actions { display: flex; align-items: center; gap: 20px; font-size: 14px; }
.header-actions a { text-decoration: none; }
.header-actions form { margin: 0; }
.link-button { padding: 0; color: inherit; border: 0; background: none; cursor: pointer; }

.primary-button, .secondary-button, .ghost-button, .reason-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 20px;
    border: 0;
    border-radius: 12px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.primary-button { color: var(--navy); background: var(--mint); box-shadow: 0 10px 28px rgba(39, 213, 164, .23); }
.secondary-button { color: var(--white); background: var(--ink); }
.ghost-button { min-height: 34px; padding: 0 11px; color: #d7e1ee; border: 1px solid #364861; background: transparent; font-size: 12px; }
.reason-button { width: 100%; margin-top: 18px; color: var(--red-dark); border: 1px solid #ffbdc6; background: #fff3f5; }

.scanner-page { width: min(1320px, calc(100% - 36px)); margin: 0 auto; padding: 42px 0 72px; }
.scanner-intro { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 26px; }
.scanner-intro h1 { margin: 12px 0 5px; font-size: clamp(30px, 5vw, 48px); letter-spacing: -.045em; }
.scanner-intro p { max-width: 680px; margin: 0; color: var(--muted); line-height: 1.6; }
.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 11px;
    color: #0b7257;
    border: 1px solid #a8eed9;
    border-radius: 999px;
    background: #e9fbf5;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.live-pill span { width: 7px; height: 7px; border-radius: 50%; background: var(--mint-dark); box-shadow: 0 0 0 5px rgba(39, 213, 164, .16); }
.staff-chip { display: flex; flex-direction: column; min-width: 180px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); box-shadow: 0 9px 26px rgba(15, 35, 64, .05); }
.staff-chip span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.staff-chip strong { margin-top: 3px; }

.scanner-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(340px, .7fr); gap: 22px; align-items: start; }
.camera-card, .result-card, .history-card { border: 1px solid var(--line); border-radius: 22px; background: var(--white); box-shadow: var(--shadow); }
.camera-card { overflow: hidden; }
.camera-topbar { display: flex; min-height: 54px; align-items: center; justify-content: space-between; padding: 0 18px; color: #dce7f4; background: var(--navy); font-size: 13px; }
.camera-topbar > div { display: flex; align-items: center; gap: 9px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.status-dot.live { background: var(--mint); box-shadow: 0 0 0 5px rgba(39, 213, 164, .14); }
.status-dot.error { background: var(--red); }
.qr-reader { position: relative; min-height: 530px; overflow: hidden; color: var(--white); background: #07101d; }
.qr-reader video { width: 100% !important; min-height: 530px; object-fit: cover; }
.qr-reader > div:not(.camera-placeholder) { border: 0 !important; }
.qr-reader img[alt="Info icon"] { display: none; }
.camera-placeholder { position: absolute; z-index: 3; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 30px; text-align: center; background: radial-gradient(circle, #172d49 0, #07101d 64%); }
.camera-placeholder h2 { margin: 28px 0 5px; }
.camera-placeholder p { margin: 0 0 22px; color: #9fb0c6; }
.scan-corners { width: 142px; height: 142px; border: 2px solid rgba(39, 213, 164, .2); border-radius: 16px; box-shadow: inset 0 0 0 5px rgba(39, 213, 164, .04); }
.scan-corners::before { content: ""; display: block; width: 35px; height: 35px; margin: -2px; border-top: 4px solid var(--mint); border-left: 4px solid var(--mint); border-radius: 12px 0 0; }
.camera-help { padding: 13px 18px; color: #7b2836; background: #fff1f3; font-size: 13px; line-height: 1.5; }
.manual-entry { padding: 18px; border-top: 1px solid var(--line); }
.manual-entry summary { color: var(--muted); font-size: 13px; cursor: pointer; }
.manual-entry form { display: grid; grid-template-columns: 1fr auto; gap: 9px; margin-top: 13px; }
.manual-entry input, .form-stack input { width: 100%; min-height: 46px; padding: 0 13px; color: var(--ink); border: 1px solid #cdd8e6; border-radius: 11px; background: var(--white); outline: none; }
.manual-entry input:focus, .form-stack input:focus { border-color: var(--mint-dark); box-shadow: 0 0 0 4px rgba(39, 213, 164, .12); }

.result-column { display: grid; gap: 22px; }
.result-card { min-height: 360px; padding: 28px; transition: border .2s, transform .2s, background .2s; }
.result-card.result-valid { color: #084f3e; border: 2px solid #54ddb6; background: linear-gradient(145deg, #f5fffc, #dff9f1); transform: translateY(-2px); }
.result-card.result-invalid { color: #75182a; border: 2px solid #ff8292; background: linear-gradient(145deg, #fff9fa, #ffe7eb); transform: translateY(-2px); }
.result-icon { display: grid; width: 54px; height: 54px; place-items: center; color: var(--white); border-radius: 17px; background: #9caabd; font-size: 27px; font-weight: 800; }
.result-valid .result-icon { background: var(--mint-dark); }
.result-invalid .result-icon { background: var(--red-dark); }
.result-label { display: block; margin-top: 21px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.result-card h2 { margin: 7px 0 9px; font-size: 24px; line-height: 1.2; letter-spacing: -.025em; }
.result-card > p { margin: 0; color: currentColor; opacity: .78; line-height: 1.55; }
.ticket-details { display: grid; gap: 9px; margin: 22px 0 0; }
.ticket-details div { display: flex; justify-content: space-between; gap: 15px; padding-top: 9px; border-top: 1px solid rgba(16, 35, 63, .13); }
.ticket-details dt { color: currentColor; opacity: .65; }
.ticket-details dd { margin: 0; font-weight: 700; text-align: right; }
.reason-detail { margin-top: 11px; padding: 13px; border-radius: 11px; background: rgba(255, 255, 255, .7); font-size: 13px; line-height: 1.5; }

.history-card { padding: 22px; box-shadow: 0 15px 42px rgba(15, 35, 64, .08); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.section-heading h2 { margin: 4px 0 0; font-size: 19px; }
.eyebrow { color: var(--mint-dark); font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.scan-history { display: grid; gap: 9px; margin: 17px 0 0; padding: 0; list-style: none; }
.history-item { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid #e8edf3; }
.history-item::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.history-item.valid::before { background: var(--mint-dark); }
.history-item strong { display: block; font-size: 13px; }
.history-item span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.history-item time { color: var(--muted); font-size: 11px; }
.empty-history { padding: 20px 0 8px; color: var(--muted); font-size: 13px; text-align: center; }

.auth-shell { min-height: calc(100vh - 70px); display: grid; place-items: center; padding: 28px; }
.auth-card { width: min(440px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 22px; background: var(--white); box-shadow: var(--shadow); }
.auth-card h1 { margin: 10px 0 7px; font-size: 31px; letter-spacing: -.04em; }
.auth-card > p { margin: 0 0 25px; color: var(--muted); }
.form-stack { display: grid; gap: 17px; }
.form-stack label { display: grid; gap: 7px; color: #4f6177; font-size: 13px; font-weight: 600; }
.form-alert { margin-bottom: 17px; padding: 12px; color: var(--red-dark); border-radius: 10px; background: #fff0f2; font-size: 13px; }

.ticket-page { min-height: calc(100vh - 70px); display: grid; align-content: center; width: min(960px, calc(100% - 34px)); margin: auto; padding: 50px 0; }
.eticket { overflow: hidden; color: var(--white); border-radius: 25px; background: var(--ink); box-shadow: 0 30px 90px rgba(9, 21, 38, .24); }
.ticket-banner { display: flex; justify-content: space-between; padding: 14px 26px; color: var(--navy); background: var(--mint); font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.ticket-body { display: grid; grid-template-columns: 1fr 260px; }
.ticket-copy { padding: clamp(30px, 5vw, 55px); }
.ticket-copy h1 { max-width: 560px; margin: 11px 0 32px; font-size: clamp(32px, 6vw, 54px); line-height: 1.05; letter-spacing: -.05em; }
.event-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.event-meta div { display: grid; gap: 6px; }
.event-meta span { color: #96a8be; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.event-meta strong { font-size: 14px; }
.qr-panel { display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 28px; color: var(--ink); background: var(--white); text-align: center; }
.qr-panel img { width: 210px; max-width: 100%; }
.qr-panel strong { margin-top: 7px; font-size: 22px; }
.qr-panel span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.download-button { margin-top: 30px; color: var(--navy); background: var(--mint); }
.ticket-warning { margin-top: 22px; padding: 11px; color: #8f1830; border-radius: 10px; background: #ffe3e8; }
.ticket-note { color: var(--muted); text-align: center; font-size: 12px; }

@media (max-width: 900px) {
    .scanner-grid { grid-template-columns: 1fr; }
    .qr-reader, .qr-reader video { min-height: 440px; }
    .result-column { grid-template-columns: 1fr 1fr; }
    .ticket-body { grid-template-columns: 1fr; }
    .qr-panel { padding: 30px; }
}

@media (max-width: 650px) {
    .site-header { min-height: 62px; }
    .brand span:last-child { display: none; }
    .scanner-page { width: min(100% - 22px, 1320px); padding-top: 25px; }
    .scanner-intro { align-items: start; flex-direction: column; }
    .scanner-intro h1 { margin-top: 10px; }
    .staff-chip { width: 100%; }
    .camera-card, .result-card, .history-card { border-radius: 17px; }
    .qr-reader, .qr-reader video { min-height: 390px; }
    .manual-entry form { grid-template-columns: 1fr; }
    .result-column { grid-template-columns: 1fr; }
    .result-card { min-height: 330px; padding: 23px; }
    .event-meta { grid-template-columns: 1fr; }
    .ticket-copy { padding: 30px 24px; }
    .ticket-banner { padding: 12px 18px; }
    .auth-card { padding: 28px 22px; }
}

@media print {
    .site-header, .download-button, .ticket-note { display: none; }
    .ticket-page { width: 100%; padding: 0; }
    .eticket { box-shadow: none; }
}
