:root {
  --ink: #082441;
  --blue: #1769aa;
  --blue-dark: #0d4f84;
  --line: #cbd8e5;
  --bg: #f4f7fa;
  --surface: #ffffff;
  --muted: #60758a;
  --secondary: #e5edf5;
  --danger: #a51d2d;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Arial, sans-serif; letter-spacing: 0; }
h1, h2, p { overflow-wrap: anywhere; }

.topbar { min-height: 60px; background: var(--surface); border-top: 5px solid var(--blue); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1180px) / 2)); }
.brand { display: inline-flex; align-items: center; flex: 0 0 auto; text-decoration: none; color: var(--ink); }
.brand-logo { display: block; width: 210px; height: 70px; object-fit: contain; }
nav { display: flex; align-items: center; gap: 18px; }
nav a { color: var(--ink); text-decoration: none; }
button.link-button { min-height: auto; padding: 0; border: 0; background: transparent; color: var(--ink); font: inherit; font-weight: 400; }

.page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }
.page-head, .action-band { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head > .event-context { flex: 1; margin-bottom: 0; }
.action-band { margin: 16px 0; justify-content: flex-end; }
.muted { color: var(--muted); }
.eyebrow { display: block; color: var(--muted); font-size: 13px; text-transform: uppercase; font-weight: 700; }

.button, button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; max-width: 100%; padding: 9px 16px; border: 1px solid transparent; border-radius: 4px; background: var(--blue); color: #ffffff; text-decoration: none; font: inherit; font-weight: 700; line-height: 1.25; text-align: center; white-space: normal; cursor: pointer; }
.button:hover, button:hover { background: var(--blue-dark); }
.button:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, .help:focus-visible { outline: 3px solid #f1b82d; outline-offset: 2px; }
.button.secondary, button.secondary { background: var(--secondary); border-color: #aebfd0; color: var(--ink); }
.button.secondary:hover, button.secondary:hover { background: #d5e1ec; }
.button.danger, button.danger { background: var(--danger); color: #ffffff; }
.compact-button { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.event-list { display: grid; gap: 20px; margin-top: 18px; }
.event-card { margin: 0; padding: 0; border: 1px solid var(--line); background: var(--surface); }
.event-row { display: grid; grid-template-columns: minmax(220px, 1fr) 120px 130px; gap: 20px; align-items: center; padding: 16px 18px; color: inherit; text-decoration: none; }
.event-row div:first-child { display: flex; flex-direction: column; }
.event-row > span:last-child { text-align: right; }
.event-stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 4px solid var(--blue); color: inherit; text-decoration: none; }
.event-stat-grid > div { min-width: 0; padding: 11px 14px 13px; border-right: 1px solid var(--line); }
.event-stat-grid > div:last-child { border-right: 0; }
.event-stat-grid span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.event-stat-grid strong { display: block; margin-top: 2px; font-size: 24px; line-height: 1; }
.guest-stat-grid { margin: 14px 0 20px; border: 1px solid var(--line); border-left: 4px solid var(--blue); background: var(--surface); }
.event-viewer-link { display: block; padding: 12px 18px; border-top: 1px solid var(--line); color: var(--blue-dark); font-weight: 700; text-decoration: none; }
.event-filter { display: flex; align-items: flex-end; gap: 10px; margin-top: 18px; padding: 14px 16px; }
.event-filter label { display: grid; gap: 6px; flex: 1 1 260px; max-width: 420px; font-weight: 700; }
.archive-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 18px; border-top: 1px solid var(--line); }
.delete-event { width: min(100%, 460px); }
.delete-event summary { color: var(--danger); text-align: right; }
.status, .badge, .summary-count { display: inline-block; padding: 4px 7px; background: #e5edf5; font-size: 12px; }

.event-context { border-left: 5px solid var(--blue); padding: 18px 22px; background: var(--surface); margin-bottom: 18px; }
.event-context h1 { margin: 3px 0 8px; }
.event-context.compact { padding: 10px 18px; }
.event-actions { display: flex; align-items: stretch; gap: 12px; flex-wrap: wrap; margin: 20px 0; }
.event-actions form { margin: 0; }
.subnav { display: flex; gap: 4px; flex-wrap: wrap; margin: 18px 0 24px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.subnav a { padding: 9px 12px; font-weight: 700; color: var(--ink); text-decoration: none; border-bottom: 3px solid transparent; }
.subnav a:hover { border-color: var(--blue); }

.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); margin: 14px 0 20px; }
.metrics.metrics-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metrics div { min-width: 0; padding: 14px 18px; border-right: 1px solid var(--line); }
.metrics div:last-child { border: 0; }
.metrics span { display: block; font-size: 12px; text-transform: uppercase; color: var(--muted); }
.metrics strong { font-size: 26px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid label, .stack label, .inline-form label { display: flex; flex-direction: column; gap: 7px; min-width: 0; font-weight: 700; }
.form-surface { padding: 20px; background: var(--surface); border: 1px solid var(--line); }
.form-wide { grid-column: 1 / -1; }
.panel-body { margin-top: 18px; }
.inline-form { display: flex; align-items: flex-end; justify-content: flex-start; gap: 14px; flex-wrap: wrap; }
.inline-form label { flex: 1 1 200px; }
.compact-form { margin: 14px 0 18px; }
.stack { display: grid; gap: 12px; margin-top: 12px; }
.spaced-form { margin-top: 12px; }
input, select, textarea { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 2px; padding: 9px 10px; background: var(--surface); font: inherit; color: var(--ink); }

label.check { display: inline-flex; flex-direction: row; align-items: center; gap: 9px; min-height: 28px; font-weight: 400; }
label.check input { flex: 0 0 18px; width: 18px; height: 18px; min-height: 18px; margin: 0; padding: 0; }
.check-group { display: flex; align-items: center; gap: 18px 28px; flex-wrap: wrap; padding: 8px 0; }
.label-line { display: inline-flex; align-items: center; gap: 7px; }
.help { position: relative; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 19px; width: 19px; height: 19px; border: 1px solid var(--muted); border-radius: 50%; color: var(--muted); background: var(--surface); font-size: 12px; font-weight: 700; cursor: help; }
.help::after { content: attr(data-tooltip); position: absolute; z-index: 20; left: 50%; bottom: calc(100% + 9px); width: min(280px, 75vw); padding: 9px 11px; border-radius: 3px; background: #172c40; color: #ffffff; font-size: 13px; font-weight: 400; line-height: 1.35; opacity: 0; pointer-events: none; transform: translateX(-50%); }
.help:hover::after, .help:focus::after { opacity: 1; }

.panel, section { margin: 24px 0; padding: 18px 0; border-top: 1px solid var(--line); }
.panel { padding: 17px 18px; background: var(--surface); border: 1px solid var(--line); }
summary { font-weight: 700; cursor: pointer; line-height: 1.4; }
.summary-count { margin-left: 7px; }
.permission-list { border-top: 1px solid var(--line); }
.permission-list > div { display: flex; justify-content: space-between; gap: 20px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.danger-zone { border-color: var(--danger); }
.danger-actions { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.danger-actions form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.search { display: flex; gap: 8px; margin: 20px 0; }
.search input { flex: 1; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: 11px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #eaf1f7; }
.guest-table { min-width: 920px; }
.row-actions { min-width: 190px; }
.row-actions > details { margin-top: 9px; }
.text-link { color: var(--blue-dark); font-weight: 700; }
.help-head { align-items: flex-start; }
.help-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; align-items: start; }
.help-toc { position: sticky; top: 18px; display: grid; min-width: 0; gap: 2px; padding: 14px 0; border-top: 4px solid var(--blue); }
.help-toc strong { padding: 4px 10px 8px; }
.help-toc a { min-width: 0; padding: 7px 10px; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.help-toc a:hover { background: #e5edf5; }
.help-content { min-width: 0; }
.help-section { scroll-margin-top: 18px; margin: 0; padding: 32px 0; border-top: 1px solid var(--line); }
.help-section:first-child { border-top: 4px solid var(--blue); }
.help-section h2 { margin: 4px 0 14px; font-size: 28px; }
.help-section h3 { margin-top: 24px; }
.help-section p, .help-section li, .help-section dd { line-height: 1.55; }
.help-kicker { color: var(--blue-dark); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.help-steps { display: grid; gap: 9px; padding-left: 24px; }
.help-note, .help-warning { margin: 18px 0; padding: 14px 16px; border-left: 4px solid var(--blue); background: #eef5fb; line-height: 1.5; }
.help-warning { border-left-color: #b07800; background: #fff7df; }
.help-shot { width: 100%; max-width: 100%; margin: 24px 0 4px; overflow: hidden; }
.help-shot img { display: block; width: 100%; max-width: 100%; height: auto; border: 1px solid var(--line); background: var(--surface); object-fit: contain; }
.help-shot figcaption { margin-top: 7px; color: var(--muted); font-size: 13px; }
.help-table { min-width: 720px; }
.help-code-grid { display: grid; grid-template-columns: max-content 1fr; gap: 7px 14px; margin: 16px 0; }
.help-code-grid code { color: var(--blue-dark); font-weight: 700; }
.help-faq { margin: 0; }
.help-faq dt { margin-top: 18px; font-weight: 700; }
.help-faq dd { margin: 5px 0 0; }
.help-checklist { display: grid; gap: 10px; }
.help-checklist label { display: flex; align-items: flex-start; gap: 10px; line-height: 1.45; }
.help-checklist input { flex: 0 0 18px; width: 18px; min-height: 18px; height: 18px; margin-top: 2px; }
.slot-admin { display: grid; gap: 8px; margin-top: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.waitlist-list { padding-left: 22px; }
.waitlist-list li { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(200px, 1fr); gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }

.alert { padding: 14px; border-left: 4px solid #b98400; background: #fff8df; }
.alert.error { border-color: var(--danger); background: #fff0f2; }
.login-panel { max-width: 420px; margin: 8vh auto; background: var(--surface); padding: 30px; border: 1px solid var(--line); }
.ticket-public { max-width: 560px; margin: 20px auto; text-align: center; background: var(--surface); padding: 28px; border: 1px solid var(--line); }
.ticket-brand-logo { display: block; width: min(230px, 70vw); height: auto; margin: -8px auto 8px; }
.ticket-qr { width: min(300px, 80vw); }
.wallet-buttons { display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; }
.wallet-buttons img { max-height: 48px; max-width: 250px; }
.scanner-body { background: var(--surface); }
.scanner-head { padding: 15px 18px; background: var(--ink); color: #ffffff; display: flex; gap: 15px; align-items: center; justify-content: space-between; }
.scanner-head button { min-height: 34px; padding: 5px 9px; }
.scanner-body main { max-width: 620px; margin: auto; padding: 16px; }
.scan-result h1 { font-size: 30px; }
.slot-list { display: grid; gap: 10px; margin: 18px 0; }
.slot-list label { display: flex; align-items: center; gap: 10px; padding: 13px; background: #eef3f8; }
.slot-list input { width: 18px; min-height: auto; }
.scan-primary { font-size: 19px; min-height: 58px; }
.email-editor-panel, .email-preview-panel { margin-bottom: 18px; }
.email-meta { margin-bottom: 18px; }
.email-editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(190px, 250px); gap: 18px; align-items: start; }
.email-editor-column { min-width: 0; }
.email-editor-heading { margin: 16px 0 8px; }
.email-toolbar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding: 9px; border: 1px solid var(--line); background: #edf3f8; }
.email-toolbar button { min-width: 38px; min-height: 36px; padding: 6px 10px; background: var(--surface); border-color: #aebfd0; color: var(--ink); }
.email-toolbar button:hover { background: #dce7f1; }
.email-editor { min-height: 250px; padding: 15px; border: 1px solid var(--line); background: var(--surface); line-height: 1.5; overflow: auto; }
.email-editor:focus { outline: 3px solid rgba(23, 105, 170, .22); outline-offset: 1px; }
.email-signature-editor { min-height: 170px; }
.email-source-editor { margin-top: 10px; }
.email-source-editor textarea { min-height: 220px; margin-top: 10px; font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: vertical; }
.email-placeholder-panel { padding: 14px; border: 1px solid var(--line); background: #f8fafc; }
.email-placeholder-panel h3 { margin-top: 0; }
.email-placeholder-list { display: grid; gap: 8px; }
.email-placeholder-list button { min-height: 36px; justify-content: flex-start; padding: 7px 10px; background: var(--surface); border-color: #aebfd0; color: var(--ink); }
.email-placeholder-list button:hover { background: #e5edf5; }
.email-form-actions { margin-top: 18px; }
.email-preview-subject { margin-bottom: 10px; }
.email-preview-content { width: 100%; min-height: 430px; padding: 20px; border: 1px solid var(--line); background: var(--surface); overflow: auto; }
.email-preview-content img { max-width: 100%; height: auto; }
.table-checkbox { width: 18px; height: 18px; min-height: 18px; padding: 0; }
.token-output { overflow-wrap: anywhere; padding: 15px; background: var(--surface); border: 1px solid var(--line); }
small { display: block; color: #805500; }

@media (max-width: 760px) {
  .topbar { padding: 10px 15px; align-items: flex-start; }
  .brand-logo { width: 160px; height: 54px; }
  .topbar nav { gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
  .page { padding: 18px 12px; }
  .event-row { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 14px 12px; }
  .event-row > span:last-child { grid-column: 1 / -1; text-align: left; }
  .event-stat-grid { grid-template-columns: repeat(5, minmax(82px, 1fr)); overflow-x: auto; }
  .event-stat-grid > div { padding: 10px 9px; }
  .event-stat-grid strong { font-size: 21px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics.metrics-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metrics div:nth-child(2n) { border-right: 0; }
  .metrics.metrics-three div { padding: 12px 8px; text-align: center; }
  .metrics.metrics-three div:nth-child(2) { border-right: 1px solid var(--line); }
  .metrics strong { font-size: 22px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-wide { grid-column: auto; }
  .event-actions, .event-actions form, .event-actions .button, .event-actions button { width: 100%; }
  .event-filter, .archive-actions { align-items: stretch; flex-direction: column; }
  .event-filter label { flex: none; width: 100%; max-width: none; }
  .delete-event { width: 100%; }
  .delete-event summary { text-align: left; }
  .action-band { justify-content: stretch; }
  .action-band .button { width: 100%; }
  .search { flex-direction: column; }
  .search button { width: 100%; }
  .permission-list > div, .waitlist-list li { grid-template-columns: 1fr; display: grid; gap: 3px; }
  .wallet-buttons { flex-direction: column; }
  .email-editor-layout { grid-template-columns: 1fr; }
  .email-placeholder-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .email-placeholder-list button { justify-content: center; }
  .help-layout { grid-template-columns: 1fr; gap: 14px; }
  .help-toc { position: static; grid-template-columns: minmax(0, 1fr); }
  .help-toc strong { grid-column: 1 / -1; }
  .help-toc a { padding: 8px 6px; }
  .help-section { padding: 26px 0; }
  .help-section h2 { font-size: 24px; }
}
