/* =====================================================================
   SABIS E-Ticketing UI — brand tokens (education brand guideline)
   Primary Green  #006233  trust · growth · excellence   — brand, primary actions, headings
   Accent Gold    #C8983C  achievement · prestige         — highlights, active markers, dividers
                           (decorative only: 2.6:1 on white, never body text; --accent-700 for text)
   White          #FFFFFF  clarity · space                — cards, inputs
   Warm Beige     #F5F2E8  balance · calm                 — page and subtle surfaces
   Taupe Brown    #685A52  stability · tradition          — secondary text, metadata
   Type: Playfair Display (headlines) · Montserrat (subheadings, buttons, numbers) · Inter (body)
   ===================================================================== */
:root {
    --brand: #006233;
    --brand-700: #004D28;
    --brand-900: #0B3A24;
    --accent: #C8983C;
    --accent-600: #B08430;
    --accent-700: #7A5A1E;
    --accent-50: #FAF3E4;
    --success: #1E7B4A;
    --success-700: #0F5C36;
    --success-50: #E8F3EC;
    --surface: #EFE9DA;
    --surface-50: #F7F4EC;

    --text: #1F2A24;
    --muted: #685A52;
    --bg: #FAF8F3;
    --card: #FFFFFF;
    --line: #E7E1D4;
    --line-strong: #D6CDBA;

    --danger: #C62828;
    --danger-50: #FDEDED;
    --warning-50: #FAF3E4;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(11, 58, 36, .03), 0 6px 24px rgba(11, 58, 36, .05);
    /* Spacing scale: one rhythm for gaps and padding across the app. */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --gutter: 24px;
    --focus-ring: 0 0 0 3px rgba(0, 98, 51, .16);
    --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
    --font-head: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15.5px/1.65 var(--font-body); }
a { color: var(--brand); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
/* Headlines in the serif (H1 page titles, H2 section titles); H3 subsections in Montserrat. */
h1, h2 { font-family: var(--font-display); color: var(--brand-900); letter-spacing: 0; }
h3 { font-family: var(--font-head); color: var(--brand-900); }
h1 { font-size: 2rem; font-weight: 700; line-height: 1.2; margin: 0; }
h2 { font-size: 1.35rem; font-weight: 600; line-height: 1.3; margin: 0 0 var(--space-4); }
h3 { font-size: .95rem; font-weight: 600; margin: 1.3rem 0 .5rem; }
code { white-space: nowrap; font-family: Consolas, Menlo, monospace; font-size: .88em; background: var(--surface-50); color: var(--brand-700); padding: 1px 6px; border-radius: 5px; letter-spacing: .5px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.text-red { color: var(--danger); }
.text-teal { color: var(--success-700); font-weight: 600; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------------------------------------------------------------- brand */
.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--brand); }
.brand:hover { text-decoration: none; }
.brand img.logo { width: auto; max-width: 220px; display: block; object-fit: contain; }
.brand small { display: block; font-family: var(--font-body); font-size: .72rem; font-weight: 500; color: var(--muted); letter-spacing: .02em; margin-top: -2px; }

/* ---------------------------------------------------------------- layout */







main { max-width: 1240px; margin: 0 auto; padding: var(--space-6) var(--gutter) var(--space-7); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin: 0 0 var(--space-6); flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-5) 28px; margin-bottom: var(--space-5); box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: var(--space-5); align-items: start; margin-bottom: var(--space-5); }
.grid-2 > .card { margin-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }

/* ---------------------------------------------------------------- header & menu */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.topbar { position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 2px 10px rgba(11, 58, 36, .04); }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: var(--space-2) var(--gutter); display: flex; align-items: center; gap: var(--space-5); min-height: 72px; }
.brand-logo { flex: none; display: flex; align-items: center; }
.brand-logo img.logo { height: 48px; width: auto; max-width: 280px; object-fit: contain; }
.mainnav { display: flex; align-items: center; gap: .25rem; flex: 1; min-width: 0; }
.nav-link { display: inline-flex; align-items: center; gap: .45rem; padding: .55rem .85rem; border-radius: var(--radius-sm); color: #3A3531; font-family: var(--font-head); font-weight: 600; font-size: .88rem; white-space: nowrap; cursor: pointer; list-style: none; user-select: none; }
.nav-link::-webkit-details-marker { display: none; }
.nav-link:hover { background: var(--surface-50); color: var(--brand); text-decoration: none; }
.nav-link.active, .nav-folder.active > .nav-link { color: var(--brand); background: var(--surface-50); box-shadow: inset 0 -2px 0 var(--accent); }
.nav-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.caret { width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); margin-left: .1rem; transition: transform .15s; opacity: .7; }
.nav-folder[open] > .nav-link { background: var(--surface-50); color: var(--brand); }
.nav-folder[open] > .nav-link .caret { transform: rotate(-135deg) translateY(-1px); }
.nav-folder { position: relative; }
.nav-panel { position: absolute; top: calc(100% + 8px); left: 0; min-width: 260px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 16px 40px rgba(11, 58, 36, .16); padding: .4rem; display: flex; flex-direction: column; z-index: 40; }
.nav-panel-right { left: auto; right: 0; }
.nav-item { display: flex; flex-direction: column; gap: .05rem; padding: .55rem .75rem; border-radius: var(--radius-sm); color: var(--text); text-align: left; width: 100%; background: none; border: 0; font: inherit; cursor: pointer; border-left: 3px solid transparent; }
.nav-item strong { font-weight: 600; font-size: .92rem; }
.nav-item small { color: var(--muted); font-size: .78rem; font-weight: 400; }
.nav-item:hover { background: var(--surface-50); text-decoration: none; }
.nav-item:hover strong { color: var(--brand); }
.nav-item.active { background: var(--surface-50); border-left-color: var(--accent); }
.nav-item.active strong { color: var(--brand); }
.nav-panel-head { padding: .55rem .75rem .6rem; border-bottom: 1px solid var(--line); margin-bottom: .3rem; display: flex; flex-direction: column; }
.nav-panel-head small { color: var(--muted); }
.nav-signout strong { color: var(--danger); }
.nav-user { margin-left: auto; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: #fff; font-family: var(--font-head); font-weight: 600; font-size: .8rem; box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--accent); }
.menu-toggle { display: none; margin-left: auto; width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--line-strong); background: #fff; cursor: pointer; place-items: center; }
.burger, .burger::before, .burger::after { display: block; width: 20px; height: 2px; background: var(--brand); border-radius: 2px; position: relative; transition: transform .2s, background .2s; }
.burger::before, .burger::after { content: ""; position: absolute; left: 0; }
.burger::before { top: -6px; }
.burger::after { top: 6px; }
.menu-open .burger { background: transparent; }
.menu-open .burger::before { transform: translateY(6px) rotate(45deg); }
.menu-open .burger::after { transform: translateY(-6px) rotate(-45deg); }

.eventbar { background: var(--surface-50); border-bottom: 1px solid var(--line); }
.eventbar-inner { max-width: 1280px; margin: 0 auto; padding: var(--space-2) var(--gutter); display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.eventbar-label { font-family: var(--font-head); font-size: .68rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.event-switch { display: flex; align-items: center; gap: .5rem; margin: 0; padding: .1rem .3rem .1rem .8rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; min-width: 0; max-width: 100%; }
.btn.btn-sm { min-height: 34px; padding: .35rem .9rem; font-size: .82rem; }

@media (max-width: 1080px) {
    .nav-link { padding: .5rem .65rem; }
    .nav-icon { display: none; }
}
@media (max-width: 880px) {
    .topbar-inner { flex-wrap: wrap; gap: .5rem; min-height: 60px; }
    .brand-logo img.logo { height: 40px; max-width: 220px; }
    .menu-toggle { display: grid; }
    .mainnav { display: none; order: 3; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: .15rem; padding: .25rem 0 .75rem; }
    .menu-open .mainnav { display: flex; }
    .nav-link { width: 100%; border-radius: var(--radius-sm); padding: .7rem .75rem; }
    .nav-icon { display: block; }
    .nav-link .caret { margin-left: auto; }
    .nav-panel { position: static; box-shadow: none; border: 0; border-left: 2px solid var(--surface); border-radius: 0; margin: .1rem 0 .35rem 1.25rem; padding: 0 0 0 .25rem; min-width: 0; }
    .nav-user { margin-left: 0; border-top: 1px solid var(--line); padding-top: .35rem; margin-top: .25rem; }
    .event-switch { flex: 1 1 100%; }
    .event-switch select { width: 100%; }
    .eventbar-label { display: none; }
}

/* ---------------------------------------------------------------- forms */
label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 500; color: #3A3531; }
input, select, textarea { font: inherit; color: var(--text); padding: .7rem .9rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; width: 100%; min-width: 0; transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: #A39A92; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus-ring); }
/* Error state only once the user has interacted, so empty required fields don't start red. */
input:user-invalid, select:user-invalid, textarea:user-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-50); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-50); color: var(--muted); }
input[type=checkbox] { width: 1.05rem; height: 1.05rem; accent-color: var(--brand); }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
.checks { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px var(--space-5); }
.form-grid .span-2 { grid-column: 1 / -1; }
.inline-form, .filters { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.filters input[type=search] { flex: 1 1 260px; }
.filters select { width: auto; flex: 0 1 200px; }
.inline-form select { width: auto; }

/* Buttons (guideline: primary = solid green, secondary = green outline, tertiary = warm beige)
   .btn-primary  = solid green, the main action of a screen
   .btn-brand    = deep green, key brand UI (e.g. save/create)
   .btn          = green outline, secondary actions
   .btn-secondary= warm beige, low-emphasis actions ("View course") */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; font: inherit; font-family: var(--font-head); font-weight: 600; font-size: .88rem; letter-spacing: .01em; min-height: 42px; padding: .6rem 1.3rem; border-radius: var(--radius-sm); border: 1.5px solid var(--brand); background: #fff; color: var(--brand); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, transform .05s; }
.btn:hover { background: var(--success-50); border-color: var(--brand-700); color: var(--brand-700); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { background: #ECE8E0; border-color: #ECE8E0; color: #A39A92; box-shadow: none; opacity: 1; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(0, 98, 51, .18); }
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.btn-brand { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.btn-brand:hover { background: var(--brand-900); border-color: var(--brand-900); color: #fff; }
.btn-secondary { background: var(--surface-50); border-color: var(--surface); color: var(--brand-900); }
.btn-secondary:hover { background: var(--surface); border-color: var(--line-strong); color: var(--brand-900); }
.btn-danger { color: var(--danger); border-color: #F1C4C4; background: #fff; }
.btn-danger:hover { background: var(--danger-50); border-color: var(--danger); }
.btn-block { width: 100%; }
.btn-lg { font-size: 1.05rem; padding: .85rem 1.5rem; }
.btn .arrow::after { content: "→"; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); font-weight: 500; cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.danger-zone { margin-top: 1.25rem; padding-top: .75rem; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- feedback */
.flash { padding: 14px 18px; border-radius: var(--radius-sm); margin-bottom: var(--space-5); border: 1px solid; font-weight: 500; }
.flash-success { background: var(--success-50); border-color: #B9DBC6; color: var(--success-700); }
.flash-error { background: var(--danger-50); border-color: #F4C7C7; color: #991B1B; }
.flash-warning { background: var(--accent-50); border-color: #EBD3A6; color: var(--accent-700); }
.badge { display: inline-block; font-family: var(--font-head); font-size: .66rem; font-weight: 600; padding: 3px 9px; border-radius: 4px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.badge-blue { background: var(--brand); color: #fff; }
.badge-green { background: var(--success-50); color: var(--success-700); }
.badge-red { background: var(--danger-50); color: #B91C1C; }
.badge-grey { background: #EFEBE4; color: var(--muted); }
.badge-orange { background: var(--accent-50); color: var(--accent-700); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px var(--space-4); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { white-space: nowrap; font-family: var(--font-head); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; background: var(--surface-50); }
thead th:first-child { border-top-left-radius: 8px; }
thead th:last-child { border-top-right-radius: 8px; }
tbody tr:hover td { background: #FCFBF7; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; color: var(--brand-900); border-top: 2px solid var(--line-strong); }
tr.disabled { opacity: .55; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; }
.row-menu summary { cursor: pointer; color: var(--brand); font-size: .85rem; font-weight: 500; }
.row-menu form { margin-top: .5rem; min-width: 200px; }

/* ---------------------------------------------------------------- dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }
.stat { position: relative; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 20px 18px 22px; gap: 2px; color: var(--text); box-shadow: var(--shadow); overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand); }
a.stat:hover { text-decoration: none; border-color: var(--line-strong); }
.stat span { font-family: var(--font-head); font-size: .74rem; color: var(--muted); font-weight: 600; }
.stat strong { font-family: var(--font-head); font-weight: 700; font-size: 2.1rem; line-height: 1.2; margin-top: 4px; color: var(--brand-900); font-variant-numeric: tabular-nums; }
.stat em { font-style: normal; font-size: .78rem; color: var(--muted); }
.stat-green::before { background: var(--success); }
.stat-green strong { color: var(--success-700); }
.stat-amber::before { background: var(--accent); }
.stat-red::before { background: var(--danger); }
.progress { height: 10px; background: var(--surface-50); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-bottom: var(--space-5); }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--brand), var(--success)); transition: width .3s; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: var(--space-2); align-items: baseline; padding: var(--space-3) 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.feed li:last-child { border-bottom: 0; }
.feed time { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.bars { display: flex; flex-direction: column; gap: var(--space-3); }
.bar-row { display: grid; grid-template-columns: 120px 1fr 44px; gap: var(--space-3); align-items: center; font-size: .88rem; }
.bar-row strong { text-align: right; color: var(--brand-900); }
.bar { background: var(--surface-50); border-radius: 999px; height: 12px; overflow: hidden; }
.bar > div { background: var(--brand); height: 100%; border-radius: 999px; }

/* ---------------------------------------------------------------- attendee */
.details { display: grid; grid-template-columns: max-content 1fr; gap: 10px var(--space-5); margin: 0 0 var(--space-5); }
.details dt { color: var(--muted); font-size: .85rem; }
.details dd { margin: 0; }
.ticket-summary { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; }
.qr-box svg { display: block; width: 150px; height: 150px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.small-qr svg { width: 120px; height: 120px; }
.result-card { position: relative; overflow: hidden; }
.result-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; }
.result-card.ok::before { background: var(--success); }
.result-card.ok h2 { color: var(--success-700); }
.result-card.bad::before { background: var(--danger); }
.result-card.bad h2 { color: #B91C1C; }
.result-card.warn::before { background: var(--accent); }
.match-row { display: flex; gap: 1rem; align-items: center; justify-content: space-between; padding: .7rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }

/* ---------------------------------------------------------------- auth (sign-in)
   One centred form on white; a short gold rule above the heading. */
body.auth-body { background: #fff; }
main.auth-split { max-width: none; padding: 0; min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; }
.auth-panel { width: 100%; display: flex; justify-content: center; padding: 3rem 1.5rem; }
.auth-form { width: 100%; max-width: 440px; }
.auth-logo { display: flex; align-items: center; margin-bottom: 1.6rem; }
.auth-logo img.logo { height: 48px; width: auto; max-width: 240px; }
.auth-rule { display: block; width: 72px; height: 2px; background: var(--accent); margin: 0 0 1.4rem; }
.auth-form h1 { font-size: clamp(2.1rem, 3.4vw, 2.6rem); font-weight: 700; line-height: 1.15; color: var(--brand); }
.auth-lead { color: var(--muted); font-size: 1rem; margin: .5rem 0 1.8rem; }
.auth-fields { display: flex; flex-direction: column; gap: 1.2rem; }
.auth-fields label { font-size: .95rem; color: var(--muted); }
.auth-fields input[type=email], .auth-fields input[type=password] { padding: .8rem 1rem; font-size: 1rem; border-radius: 4px; }
.auth-row { display: flex; align-items: center; }
.auth-row label.check { color: var(--text); font-weight: 400; cursor: pointer; }
.auth-row input[type=checkbox] { accent-color: var(--brand); cursor: pointer; }
.auth-fields .btn-lg { border-radius: 4px; padding: .9rem 1.5rem; font-size: 1.05rem; margin-top: .2rem; }

@media (max-width: 880px) {
    main.auth-split { place-items: start center; }
    .auth-panel { padding: max(40px, 8dvh) 24px 32px; }
    .auth-form h1 { font-size: 2.1rem; }
    .auth-lead { font-size: .95rem; margin-bottom: 1.5rem; }
}

/* ---------------------------------------------------------------- scanner */
main.scan-main { max-width: 560px; padding-top: 1rem; }
.scan-camera { position: relative; background: var(--brand-900); border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3; }
.scan-camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 14% 22%; border: 3px solid var(--accent); border-radius: 18px; box-shadow: 0 0 0 999px rgba(11, 58, 36, .35); pointer-events: none; }
.scan-hint { position: absolute; left: 0; right: 0; bottom: .7rem; text-align: center; color: #fff; font-size: .85rem; font-weight: 500; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.scan-controls { display: flex; gap: var(--space-3); margin: var(--space-4) 0; }
.scan-controls .btn { flex: 1; }
.scan-controls select { flex: 1; }
.scan-manual { display: flex; gap: .5rem; margin-bottom: .8rem; }
.scan-result { border-radius: var(--radius); padding: 20px var(--space-5); border: 2px solid var(--line); background: var(--card); min-height: 120px; box-shadow: var(--shadow); }
.scan-result .scan-title { font-family: var(--font-display); font-size: 1.55rem; font-weight: 700; line-height: 1.2; color: var(--brand-900); }
.scan-result .scan-sub { margin-top: .3rem; }
.scan-result .scan-name { font-family: var(--font-head); font-size: 1.35rem; font-weight: 600; margin-top: .6rem; }
.scan-result dl { margin: .45rem 0 0; }
.scan-result .actions { margin-top: 1rem; }
.scan-result.pending { opacity: .65; }
.scan-result.valid { border-color: var(--accent); background: var(--accent-50); }
.scan-result.valid .scan-title { color: var(--brand-900); }
.scan-result.checked_in { border-color: var(--success); background: var(--success-50); }
.scan-result.checked_in .scan-title { color: var(--success-700); }
.scan-result.already_used, .scan-result.invalid, .scan-result.revoked, .scan-result.error, .scan-result.wrong_event, .scan-result.event_inactive { border-color: var(--danger); background: var(--danger-50); }
.scan-result.already_used .scan-title, .scan-result.invalid .scan-title, .scan-result.revoked .scan-title, .scan-result.error .scan-title, .scan-result.wrong_event .scan-title, .scan-result.event_inactive .scan-title { color: #B91C1C; }
.scan-result.not_open, .scan-result.closed { border-color: var(--accent); background: var(--accent-50); }
.scan-result.not_open .scan-title, .scan-result.closed .scan-title { color: var(--accent-700); }

/* ---------------------------------------------------------------- public ticket */
body.ticket-body { background: var(--bg); }
main.ticket-page { max-width: 440px; padding-top: 1.25rem; }
.ticket-brand { display: flex; justify-content: center; margin-bottom: 1rem; }
.ticket-brand .brand { background: #fff; padding: .4rem .9rem; border-radius: 14px; box-shadow: var(--shadow); }
.ticket-brand img.logo { height: 40px !important; width: auto; max-width: 240px; }
.eticket { background: #fff; border-radius: 20px; overflow: hidden; box-shadow: 0 10px 40px rgba(11, 58, 36, .14); }
.eticket-head { background: linear-gradient(112deg, var(--brand) 0 84%, var(--accent) 84% 85.4%, var(--brand-700) 85.4% 100%); color: #fff; padding: 1.3rem 3.6rem 1.3rem 1.5rem; position: relative; border-bottom: 4px solid var(--accent); }
.eticket-head .eyebrow { font-family: var(--font-head); font-size: .68rem; letter-spacing: .22em; text-transform: uppercase; color: #E9D9B4; font-weight: 600; }
.eticket-head .event { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; position: relative; z-index: 1; }
.eticket-head .when { color: #E9D9B4; font-size: .9rem; position: relative; z-index: 1; }
.eticket-body { padding: 1.5rem; }
.eticket .holder { font-family: var(--font-display); font-size: 1.55rem; font-weight: 700; color: var(--brand-900); margin: .15rem 0; }
.big-qr { margin: 1rem auto .5rem; max-width: 290px; padding: 10px; border: 2px dashed var(--line-strong); border-radius: 16px; }
.big-qr svg { width: 100%; height: auto; border: 0; }
.eticket .code { font-family: Consolas, Menlo, monospace; font-size: 1.3rem; letter-spacing: 3px; color: var(--brand-900); font-weight: 700; }
.eticket-actions { padding: 0 1.5rem 1.25rem; }
.eticket-foot { background: var(--surface-50); color: var(--muted); font-size: .78rem; text-align: center; padding: .8rem 1rem; border-top: 2px dashed var(--line-strong); }
.stamp { display: inline-block; margin: 1.2rem 0 .6rem; padding: .4rem 1.1rem; border: 3px solid; border-radius: 10px; font-family: var(--font-head); font-weight: 700; font-size: 1.3rem; text-transform: uppercase; transform: rotate(-4deg); }
.stamp-green { color: var(--success-700); }
.stamp-red { color: var(--danger); }

/* ---------------------------------------------------------------- events */

.event-switch select { border: 0; background: transparent; padding: .3rem 1.6rem .3rem .1rem; font-weight: 600; color: var(--brand-900); font-size: .88rem; box-shadow: none; min-width: 0; text-overflow: ellipsis; }
.event-switch select:focus { box-shadow: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #A39A92; }
.dot-open { background: var(--success); box-shadow: 0 0 0 3px rgba(30, 123, 74, .22); }
.dot-not_open { background: var(--accent); }
.dot-event_inactive { background: var(--danger); }
.event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--space-5); }
.event-card { display: flex; flex-direction: column; gap: var(--space-2); margin: 0; }
.event-card.is-current { border-color: var(--brand); box-shadow: inset 0 3px 0 var(--accent), var(--shadow); }
.event-card h2 { margin: .35rem 0 0; font-size: 1.25rem; }
.event-card-head { display: flex; gap: .35rem; flex-wrap: wrap; }
.event-meta { margin: 0; color: var(--text); font-weight: 500; }
.event-numbers { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); margin: var(--space-3) 0 var(--space-4); padding: var(--space-4) var(--space-3); background: var(--surface-50); border-radius: var(--radius-sm); text-align: center; }
.event-numbers strong { display: block; font-family: var(--font-head); font-size: 1.35rem; color: var(--brand-900); }
.event-numbers span { font-family: var(--font-head); font-size: .68rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.event-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; background: linear-gradient(112deg, var(--brand) 0 88%, var(--accent) 88% 88.6%, var(--brand-700) 88.6% 100%); color: #fff; border-radius: var(--radius); padding: 28px 5rem 28px 32px; margin-bottom: var(--space-5); box-shadow: var(--shadow); }
.event-banner h1 { color: #fff; font-size: 1.6rem; }
.event-banner p { margin: .15rem 0 0; color: #E9D9B4; font-size: .9rem; }
.event-banner .badge { font-size: .72rem; }
.checkin-notice { display: flex; gap: var(--space-3); align-items: center; padding: 14px 18px; border-radius: var(--radius-sm); margin-bottom: var(--space-5); font-weight: 500; }
.checkin-notice.open { background: var(--success-50); color: var(--success-700); }
.checkin-notice.not_open { background: var(--accent-50); color: var(--accent-700); }
.checkin-notice.closed, .checkin-notice.event_inactive { background: var(--danger-50); color: #991B1B; }
.gate-status { padding: .55rem .9rem; border-radius: var(--radius-sm); margin-bottom: .8rem; font-size: .88rem; }
.gate-status.is-ok { background: var(--surface-50); color: var(--muted); }
.gate-status.is-offline { background: var(--danger-50); color: #991B1B; }
.gate-status.is-warning { background: var(--accent-50); color: var(--accent-700); }
.gate-status .gate-flags { margin: .35rem 0 .5rem; padding-left: 1.1rem; }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .8rem 1rem 1rem; margin: 0; }
.fieldset legend { font-family: var(--font-head); font-weight: 600; color: var(--brand-900); padding: 0 .35rem; }
.status-help { margin: 0; padding-left: 1.1rem; }
.empty-state { text-align: center; padding: 2.5rem 1.5rem; }
.pw-meter { height: 6px; background: var(--surface-50); border-radius: 999px; overflow: hidden; margin-top: -.35rem; }
.pw-meter > div { height: 100%; width: 0; background: var(--danger); transition: width .2s, background .2s; }

/* ---------------------------------------------------------------- modal */
.modal { border: 0; padding: 0; border-radius: 18px; max-width: 460px; width: calc(100% - 32px); box-shadow: 0 24px 60px rgba(11, 58, 36, .25); color: var(--text); }
.modal::backdrop { background: rgba(11, 58, 36, .45); backdrop-filter: blur(2px); }
.modal-body { padding: 28px 28px var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); }
.modal-body h2 { margin: 0; font-size: 1.2rem; }
.modal-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--danger-50); color: var(--danger); display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: 1.4rem; }
.modal-warning { margin: 0; color: #991B1B; font-weight: 500; }
.modal-counts { margin: 0; padding: .7rem 1rem .7rem 2rem; background: var(--danger-50); border-radius: var(--radius-sm); color: #7F1D1D; }
.modal-counts li { margin: .15rem 0; }
.modal-actions { justify-content: flex-end; margin-top: .4rem; }
.modal input.is-match { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-50); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #B91C1C; border-color: #B91C1C; color: #fff; }
.btn-danger-solid:disabled:hover { background: var(--danger); }

/* ---------------------------------------------------------------- responsive / print */
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .stat strong { font-size: 1.7rem; }
    .card { padding: 20px; }
    h1 { font-size: 1.6rem; }
    main { padding: var(--space-5) 18px var(--space-6); }
}
@media print {
    .topbar, .actions, .filters { display: none; }
    body { background: #fff; }
    .card, .stat { box-shadow: none; }
}

/* ---------------------------------------------------------------- registration fields */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
.card-head h2 { margin: 0; }
table.compact th, table.compact td { padding-top: .45rem; padding-bottom: .45rem; vertical-align: middle; }
.fields-table input:not([type=checkbox]) { min-width: 150px; }
.fields-table tr.disabled td { color: var(--muted); }
.fields-table tr.is-editing td { background: var(--surface-50); }
.fields-table input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
.order-buttons { display: inline-flex; gap: .25rem; }
.order-buttons .btn[disabled] { opacity: .35; }
.nowrap { white-space: nowrap; }
.field-help { display: block; font-size: .78rem; font-weight: 400; color: var(--muted); margin-top: .2rem; }
.check-inline { align-self: end; padding-bottom: .6rem; }
[data-options-row][hidden] { display: none; }

/* ---------------------------------------------------------------- email setup */
.setup-steps { padding-left: 1.2rem; margin: .4rem 0; }
.setup-steps li { margin: .35rem 0; }
.copy-field { display: block; width: 100%; margin-top: .3rem; font-family: Consolas, Menlo, monospace; font-size: .8rem; }

/* ---------------------------------------------------------------- public registration */
main.public-page { max-width: 560px; padding-top: 1.25rem; }
main.public-page h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
main.public-page .qr-box { display: flex; justify-content: center; margin: 1rem 0 .25rem; }
main.public-page p.code { text-align: center; font-size: 1.1rem; letter-spacing: 2px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.capacity-bar { margin: .5rem 0 .35rem; }
.event-numbers .of { font-size: .75em; color: var(--muted); font-weight: 600; }

/* ---------------------------------------------------------------- delivery queue */
.queue-stats { display: flex; flex-wrap: wrap; gap: .5rem; margin: .25rem 0 .75rem; }
.queue-stats span { background: var(--surface-50); border: 1px solid var(--line); border-radius: 999px; padding: .15rem .7rem; font-size: .82rem; }
.queue-stats span strong { font-variant-numeric: tabular-nums; }
.queue-stats span.is-failed { background: #FEF2F2; border-color: #FECACA; color: #B91C1C; }
.queue-stats span.is-sent { background: var(--success-50); border-color: #B9DBC6; color: var(--success-700); }

/* ---------------------------------------------------------------- staff assignment grid */
.grid-table th.grid-event { min-width: 140px; text-align: center; vertical-align: top; }
.grid-table th.grid-event a { display: block; font-weight: 600; }
.grid-table th.grid-event small { display: block; font-weight: 400; color: var(--muted); margin-bottom: .25rem; }
.grid-table th.grid-event .check { justify-content: center; color: var(--muted); font-size: .78rem; }
.grid-table td.grid-cell { text-align: center; }
.grid-table td.grid-cell .check { justify-content: center; margin: 0; }
.grid-table td.grid-cell input { width: 20px; height: 20px; }
.grid-table .is-highlight { background: var(--surface-50); }

/* ---------------------------------------------------------------- lists: toolbar, users */
.list-toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: 1rem; }
.list-toolbar input[type=search] { flex: 1 1 260px; }
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 3px; gap: 2px; background: var(--surface-50); }
.segmented button { font: inherit; font-family: var(--font-head); font-size: .8rem; font-weight: 600; color: var(--muted); background: transparent; border: 0; border-radius: 6px; padding: .4rem .75rem; cursor: pointer; }
.segmented button:hover { color: var(--brand); }
.segmented button span { font-weight: 500; opacity: .75; margin-left: .15rem; }
.segmented button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.users-card { padding-bottom: var(--space-4); }
.users-table td { vertical-align: middle; }
.users-table .avatar { width: 36px; height: 36px; flex: none; box-shadow: none; background: var(--surface-50); color: var(--brand); border: 1px solid var(--accent); }
.user-cell { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.user-cell strong { overflow-wrap: anywhere; }
.avatar.avatar-lg { width: 48px; height: 48px; font-size: 1rem; flex: none; }
.users-table tr.is-disabled td:not(.row-actions) { opacity: .55; }
.row-actions { text-align: right; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip { display: inline-block; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .76rem; padding: .15rem .55rem; border-radius: 999px; background: var(--surface-50); border: 1px solid var(--line); color: var(--text); font-weight: 500; }
.chip.is-muted { color: var(--muted); border-style: dashed; }
.chip-more { color: var(--brand); }
.warn-link { color: var(--accent-700); font-weight: 600; }
.modal.modal-wide { max-width: 620px; }
.modal-section { border-top: 1px solid var(--line); padding-top: .9rem; margin-top: .3rem; display: flex; flex-direction: column; gap: .6rem; }
.modal-section h3 { margin: 0; }
.modal-section .inline-form > input, .modal-section .inline-form > select { flex: 1 1 220px; width: auto; }
.modal-body h2 + .muted { margin-top: .15rem; }
.modal-body .user-cell h2 { margin: 0; }

/* Phones and narrow windows: each user becomes a card; labels come from data-label. */
@media (max-width: 880px) {
    .users-table thead { display: none; }
    .users-table, .users-table tbody { display: block; }
    .users-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .55rem 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
    .users-table tr:last-child { border-bottom: 0; }
    .users-table tbody tr:hover td { background: none; }
    .users-table td { display: block; padding: 0; border: 0; text-align: left; }
    .users-table td[data-label]::before { content: attr(data-label); display: block; font-family: var(--font-head); font-size: .64rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: .2rem; }
    .users-table td[data-label="User"], .users-table td[data-label="Works at"], .users-table .row-actions { grid-column: 1 / -1; }
    .users-table td[data-label="User"]::before { display: none; }
    .users-table .row-actions .btn { width: 100%; }
    .list-toolbar .segmented { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .segmented button { flex: 1 0 auto; white-space: nowrap; padding: .4rem .5rem; }
}

/* ------------------------------------------------------------------ utilities
   Small layout tweaks that used to be style="..." attributes on the page. They
   are classes so the Content-Security-Policy can refuse inline styles entirely
   (see send_security_headers() in src/helpers.php). */
.m-0 { margin: 0; }
.mt-tight { margin: .2rem 0 0; }
.fw-normal { font-weight: 400; }
.measure { max-width: 720px; }
.inline-block { display: inline-block; }
.self-end { align-self: end; }
.field-grow { flex: 1 1 220px; }
.field-grow-sm { flex: 1 1 160px; }
.field-grow-md { flex: 1 1 200px; }
.field-w-sm { width: 80px; }
.field-w-md { width: 180px; }
.field-w-lg { width: 170px; }
.log-tail { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-50); padding: 12px; border-radius: 10px; }
.setup-main { max-width: 980px; margin: 24px auto; padding: 0 16px; }
.setup-unlock { max-width: 420px; }

/* Bars whose length is data ([data-percent]); assets/app.js sets the width. */
.progress > div[data-percent],
.bar > div[data-percent] { width: 0; }
.logo-34 { height: 34px; }
.logo-38 { height: 38px; }
.logo-48 { height: 48px; }
.error-page { font-family: system-ui, sans-serif; max-width: 520px; margin: 12vh auto; padding: 24px; border: 1px solid var(--line); border-radius: 12px; }
.error-page h1 { color: var(--brand-900); font-family: Georgia, serif; font-size: 1.4rem; margin: 0 0 .5rem; }

/* Attendees: the list is swapped in while the search box is typed (assets/attendees.js).
   It dims rather than emptying, so the page keeps its height and the list does not jump
   under a thumb that is about to tap a row. */
[data-attendee-results] { transition: opacity .15s ease; }
[data-attendee-results].is-searching { opacity: .5; }
@media (prefers-reduced-motion: reduce) {
    [data-attendee-results] { transition: none; }
}

/* Per-event category picker (event_fields.php): a thumb-sized checkbox per category. */
.category-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.category-picker .check { min-height: 44px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; margin: 0; }
.category-picker .check:has(:checked) { border-color: var(--brand); background: var(--surface-50); }
.category-picker .check span { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }


/* Version footer: one quiet line under every page. */
.app-version { display: flex; align-items: center; justify-content: center; gap: .4rem; min-height: 3rem; padding: 0 1rem; margin-top: 1.5rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .75rem; letter-spacing: .02em; }
body.auth-body .app-version { margin-top: 0; border-top: 0; }
body.auth-body main.auth-split { min-height: calc(100vh - 3rem); min-height: calc(100dvh - 3rem); }
@media print { .app-version { display: none; } }
