:root { font-family: system-ui, sans-serif; color: #1f2937; background: #f6f7fb; }
.lookup-ticket { margin: .75rem 0; padding: 1rem; border: 1px solid #e2e8f0; border-radius: 8px; }
.lookup-ticket-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.lookup-ticket-heading h3 { margin: 0; font-size: 1.05rem; }
.lookup-ticket-event { margin: .4rem 0; font-weight: 600; }
.lookup-ticket-code { margin: .4rem 0; font-family: monospace; }
.lookup-ticket-contact p { margin: .2rem 0; font-size: .9rem; }
.lookup-ticket-attendance { margin: .6rem 0; font-size: .9rem; }
details.lookup-ticket-days { margin-top: .5rem; }
.lookup-ticket-days summary { font-size: .9rem; color: #1d4ed8; }
.lookup-ticket-days table { margin-top: .5rem; font-size: .85rem; }
.lookup-ticket-days th, .lookup-ticket-days td { padding: .45rem; }
.lookup-attended-at { display: block; margin-top: .25rem; color: #64748b; }
#ticket-lookup-dialog { width: min(44rem, calc(100% - 1rem)); max-height: 90dvh; box-sizing: border-box; padding: 1rem; border: 0; border-radius: 12px; color: #1f2937; }
#ticket-lookup-dialog::backdrop { background: rgba(15, 23, 42, .55); }
#ticket-lookup-dialog [hidden] { display: none !important; }
.lookup-header, .lookup-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.lookup-header { justify-content: space-between; }
.lookup-header h2 { margin: 0; font-size: 1.25rem; }
.lookup-actions { margin-top: .75rem; }
#close-ticket-lookup, #lookup-camera-stop { background: #475569; }
#lookup-reader { max-width: 420px; margin: .75rem auto; }
#lookup-reader video { max-width: 100%; }
#lookup-results { overflow-wrap: anywhere; }
.lookup-fields { margin: .5rem 0; }
.lookup-fields > div { padding: .4rem 0; border-bottom: 1px solid #e2e8f0; }
.lookup-fields dt { color: #64748b; font-size: .85rem; }
.lookup-fields dd { margin: .15rem 0 0; }
.lookup-list { padding-left: 1.25rem; }
.lookup-list > li { margin: .75rem 0; padding: .5rem; background: #f8fafc; border-radius: 6px; }
#ticket-lookup-dialog button:disabled { opacity: .55; cursor: wait; }
body { max-width: 640px; margin: 8vh auto; padding: 2rem; background: white; border-radius: 12px; box-shadow: 0 8px 30px #0001; }
h1 { margin-top: 0; }
label { display: block; margin: 1rem 0; }
input { display: block; width: 100%; box-sizing: border-box; margin-top: .35rem; padding: .7rem; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; }
button { padding: .7rem 1rem; border: 0; border-radius: 6px; background: #2563eb; color: white; font: inherit; cursor: pointer; }
button:hover { background: #1d4ed8; }
pre { overflow-x: auto; padding: 1rem; background: #f1f5f9; border-radius: 6px; }
@media (max-width: 700px) { body { margin: 0; min-height: 100vh; box-sizing: border-box; border-radius: 0; padding: 1.5rem; } }

a.button { display: inline-block; padding: .7rem 1rem; border-radius: 6px; background: #2563eb; color: white; text-decoration: none; }
a.button:hover { background: #1d4ed8; }

body.events-page { max-width: 1200px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .65rem; border-bottom: 1px solid #e2e8f0; text-align: left; vertical-align: top; }
th { background: #f1f5f9; }
tbody tr:hover { background: #f8fafc; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.detail-grid div { padding: 1rem; background: #f1f5f9; border-radius: 6px; }
.detail-grid dt { color: #64748b; font-size: .9rem; }
.detail-grid dd { margin: .3rem 0 0; font-weight: 600; }
details { margin-top: 2rem; }
summary { cursor: pointer; }

.error {
    color: red;
    font-weight: bold;
}
body.events-page { position: relative; }
.events-account-row { display: flex; justify-content: flex-start; min-height: 2rem; }
.logout-form { display: flex; align-items: center; justify-content: flex-start; gap: .65rem; }
.logout-button { padding: .35rem .6rem; font-size: .8rem; }
.logged-user { font-size: .85rem; color: #64748b; }
.events-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .75rem; }
.events-heading-row h1 { margin: 0; font-size: 1.5rem; }
#open-ticket-lookup { margin-left: auto; }
.events-filter { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; margin: 1.25rem 0; padding: 1rem; background: #f1f5f9; border-radius: 6px; }
.events-filter label { margin: 0; font-size: .9rem; }
.events-filter input[type="date"] { width: auto; min-width: 9rem; margin-top: .25rem; padding: .45rem; background: white; }
.events-filter .checkbox-label { display: flex; align-items: center; gap: .4rem; padding-bottom: .55rem; }
.events-filter input[type="checkbox"] { display: inline-block; width: auto; margin: 0; }
.events-filter button { padding: .5rem .8rem; }
.tickets-table .center { text-align: center; }
.tickets-table svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; padding: 0; border-radius: 50%; }
.admit-button { background: #16a34a; }
.admit-button:hover { background: #15803d; }
.undo-button { background: #dc6b19; }
.undo-button:hover { background: #c2550d; }
.substitute-icon, .attendance-icon { display: inline-flex; align-items: center; justify-content: center; }
.substitute-icon { color: #7c3aed; }
.attendance-yes { color: #15803d; }
.attendance-no { color: #94a3b8; }
.status-badge { display: inline-block; padding: .25rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.status-active { color: #166534; background: #dcfce7; }
.status-pending { color: #9a3412; background: #ffedd5; }
.status-other { color: #475569; background: #e2e8f0; }
.muted { color: #94a3b8; }
.result-modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 1rem; background: rgba(15, 23, 42, .55); cursor: pointer; }
.result-modal[hidden] { display: none; }
.result-modal-card { width: min(28rem, 100%); padding: 2rem; border-radius: 12px; background: white; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); text-align: center; }
.result-modal-icon { display: grid; place-items: center; width: 4rem; height: 4rem; margin: 0 auto 1rem; border: .25rem solid currentColor; border-radius: 50%; font-size: 2.75rem; font-weight: 700; line-height: 1; }
.result-modal-card p { margin: 0 0 1rem; font-size: 1.05rem; }
.result-modal-card small { display: block; margin-top: 1rem; color: #64748b; }
.result-success .result-modal-icon { color: #16a34a; }
.result-error .result-modal-icon { color: #dc2626; }
.result-warning .result-modal-icon { color: #eab308; }
.force-button { background: #eab308; color: #422006; }
.force-button:hover { background: #ca8a04; }
.attendance-action:disabled, .force-button:disabled { opacity: .55; cursor: wait; }
.substitute-admit { background: #eab308; color: #422006; }
.substitute-admit:hover { background: #ca8a04; }
.attendance-substitute { color: #eab308; }
.qr-controls { margin: 1.5rem 0; }
.qr-controls > button { vertical-align: middle; }
#ticket-search-button { display: inline-flex; align-items: center; justify-content: center; padding: .7rem; }
#ticket-search-button svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
#ticket-search-dialog { width: min(26rem, calc(100% - 2rem)); box-sizing: border-box; padding: 1.25rem; border: 0; border-radius: 12px; color: #1f2937; }
#ticket-search-dialog::backdrop { background: rgba(15, 23, 42, .55); }
#ticket-search-dialog h2 { margin: 0; font-size: 1.25rem; }
#ticket-search-dialog label { margin: .75rem 0 .35rem; }
.ticket-search-actions { display: flex; gap: .5rem; margin-top: 1rem; }
#ticket-search-close, #ticket-search-reset { background: #475569; }
.tickets-table tbody tr.ticket-search-match > td { background: #fef3c7; border-bottom-color: #eab308; }
.tickets-table tbody tr.ticket-search-match > td:first-child { box-shadow: inset 4px 0 #ca8a04; }
#ticket-search-status { margin: .5rem 0; font-size: .9rem; overflow-wrap: anywhere; }
.qr-controls [hidden], .result-modal-card [hidden] { display: none !important; }
#qr-reader { max-width: 480px; margin-top: 1rem; }
#qr-reader video { max-width: 100%; }
#qr-status { color: #475569; }
#qr-status:empty { display: none; }
#stop-scan-button { background: #475569; }
.result-modal-card button { margin: .25rem; }
.qr-controls button:disabled, .result-modal-card button:disabled { opacity: .55; cursor: wait; }

@media (max-width: 700px) {
    .events-account-row { min-height: 0; }
    .logout-form { flex-wrap: wrap; gap: .4rem; }
    .events-heading-row { margin-top: .65rem; }
    .events-heading-row h1 { font-size: 1.25rem; }
    #open-ticket-lookup { padding: .5rem .7rem; font-size: .9rem; }
    body.event-detail-page { padding: .75rem 1rem; }
    .event-detail-page > p:first-child { margin: 0 0 .5rem; font-size: .85rem; }
    body.event-detail-page > h1 { margin: 0 0 .5rem; font-size: 1.25rem; line-height: 1.25; }
    .event-detail-page .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .35rem; margin: .5rem 0; }
    .event-detail-page .detail-grid div { min-width: 0; padding: .4rem .6rem; }
    .event-detail-page .detail-grid dt { font-size: .75rem; line-height: 1.2; }
    .event-detail-page .detail-grid dd { margin-top: .15rem; font-size: .85rem; line-height: 1.3; overflow-wrap: anywhere; }
    .event-detail-page .qr-controls { margin: .75rem 0; }
    .event-detail-page #tickets-content > h2 { margin: .75rem 0 .5rem; font-size: 1.1rem; }
}
