:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #072140;
  --muted: #6a7a8c;
  --line: #d8dee8;
  --primary: #3070b3;
  --primary-dark: #072140;
  --accent: #b81839;
  --danger: #b02a37;
  --warn: #997404;
  --ok: #198754;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a {
  color: var(--primary-dark);
  text-decoration: none;
}

.topbar {
  background: var(--primary-dark);
  border-bottom: 5px solid var(--primary);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.brand {
  color: #fff;
  display: grid;
  gap: 2px;
  font-weight: 800;
  font-size: 19px;
  line-height: 1.1;
}

.brand small {
  color: #c9d7e8;
  font-size: 13px;
  font-weight: 700;
}

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.nav a,
.tools-menu summary {
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 2px;
  background: transparent;
  color: #fff;
  font-weight: 700;
}

.tools-menu {
  position: relative;
}

.tools-menu summary {
  list-style: none;
  cursor: pointer;
  min-width: 44px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tools-menu summary::-webkit-details-marker {
  display: none;
}

.tools-menu-content {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(16, 24, 40, .16);
  z-index: 10;
}

.tools-menu-content a {
  display: block;
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
}

.tools-menu-content a:hover {
  background: #eef1f5;
}

main {
  width: min(1180px, calc(100% - 24px));
  margin: 22px auto 60px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 18px;
}

.card {
  border-top: 5px solid var(--primary);
}

.card h2,
.panel h2,
main > h1 {
  color: var(--primary-dark);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 14px 0;
}

.wallet-badge-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  text-decoration: none;
}

.wallet-badge-link img {
  display: block;
  height: 48px;
  width: auto;
  max-width: 100%;
  border: 0;
}

.guest-stats {
  display: flex;
  flex-wrap: nowrap;
  border: 1px solid var(--line);
  border-left: 5px solid var(--primary);
  border-radius: 2px;
  background: #fff;
  margin: 10px 0 16px;
  overflow-x: auto;
}

.guest-stat {
  flex: 1 0 0;
  min-width: 0;
  min-height: 70px;
  padding: 10px 10px;
  border-left: 1px solid var(--line);
}

.guest-stat:first-child {
  border-left: 0;
}

.guest-stat span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}

.guest-stat strong {
  display: block;
  margin-top: 3px;
  font-size: 24px;
  line-height: 1;
}

.add-guest-panel {
  margin-bottom: 16px;
}

.add-guest-panel summary,
.guest-edit-panel summary,
.waitlist-panel summary {
  cursor: pointer;
  font-weight: 800;
  font-size: 18px;
}

.waitlist-panel {
  margin-bottom: 16px;
}

.waitlist-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
}

.waitlist-actions > div {
  min-width: 150px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.waitlist-actions span,
.waitlist-actions strong {
  display: block;
}

.waitlist-actions strong {
  margin-top: 2px;
  font-size: 24px;
  line-height: 1;
}

.compact-table th,
.compact-table td {
  padding: 8px 10px;
}

.waitlist-table form {
  margin: 0;
}

.guest-edit-panel {
  margin: 12px 0 16px;
}

.manual-guest-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 12px;
  margin-top: 16px;
}

.manual-guest-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  min-width: 0;
}

.misc-settings {
  margin-top: 18px;
}

.misc-settings summary {
  cursor: pointer;
  font-weight: 800;
  font-size: 18px;
}

.misc-settings-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 12px;
  align-items: end;
  margin-top: 16px;
}

.misc-settings-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  min-width: 0;
}

.danger-zone {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.danger-zone h3 {
  margin: 0 0 8px;
  color: var(--danger);
}

.danger-zone-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.danger-zone-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  min-width: 0;
}

.email-editor-panel,
.email-preview-panel {
  margin-bottom: 16px;
}

.email-subject-label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  margin-bottom: 14px;
}

.email-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  gap: 14px;
  align-items: start;
}

.email-editor-column {
  min-width: 0;
}

.email-editor-heading {
  margin: 12px 0 8px;
  color: var(--primary-dark);
}

.email-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.email-toolbar button {
  min-height: 36px;
  padding: 7px 10px;
  background: var(--primary-dark);
}

.email-editor {
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 14px;
  background: #fff;
  line-height: 1.45;
  overflow: auto;
}

.email-editor:focus {
  outline: 3px solid rgba(48, 112, 179, .25);
}

.email-signature-editor {
  min-height: 180px;
}

.email-source-editor {
  margin-top: 10px;
}

.email-source-editor summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--primary-dark);
}

.email-source-editor textarea {
  width: 100%;
  min-height: 220px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 10px;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}

.email-placeholder-panel {
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 12px;
  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: #fff;
  color: var(--primary-dark);
  border: 1px solid var(--line);
}

.email-preview-subject {
  margin-bottom: 10px;
}

.email-preview-frame {
  width: 100%;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
}

.form-wide {
  grid-column: 1 / -1;
}

.button,
button,
input[type="submit"] {
  min-height: 44px;
  border: 0;
  border-radius: 2px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  padding: 11px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button.secondary,
button.secondary {
  background: var(--primary-dark);
}

.button.danger,
button.danger {
  background: var(--danger);
}

.dummy-edit-form {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.dummy-edit-form label {
  display: grid;
  gap: 5px;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

input,
select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 9px 10px;
  font: inherit;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #eaf1f8;
  color: var(--primary-dark);
}

.badge {
  display: inline-block;
  border-radius: 2px;
  padding: 4px 9px;
  font-weight: 700;
  font-size: 13px;
  background: #e9edf3;
}

.badge.ok {
  color: #fff;
  background: var(--ok);
}

.badge.open {
  color: #fff;
  background: var(--warn);
}

.badge.dummy {
  background: #eef1f5;
  color: var(--primary-dark);
  border: 1px solid var(--line);
}

.message {
  padding: 12px 14px;
  border-radius: 8px;
  margin: 12px 0;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 700;
}

.message.success {
  color: var(--ok);
}

.message.warning {
  color: var(--warn);
}

.message.error {
  color: var(--danger);
}

.checkin-title {
  font-size: clamp(28px, 5vw, 46px);
  line-height: 1.08;
  margin: 0 0 6px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.status-box {
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.status-box.done {
  border-color: var(--ok);
}

.status-label {
  color: var(--muted);
  font-size: 14px;
}

.status-value {
  font-weight: 900;
  font-size: 22px;
  margin-top: 6px;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.qr-card img {
  width: 100%;
  max-width: 260px;
  height: auto;
}

.qr-list-cell {
  width: 150px;
}

.qr-list-cell img {
  width: 112px;
  height: 112px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 22px;
  align-items: start;
}

.detail-qr {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  overflow-wrap: anywhere;
}

.detail-qr img {
  width: 100%;
  height: auto;
  display: block;
}

.delete-guest-form {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.event-access {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 24px;
  align-items: center;
}

.event-qr img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.scanner-body {
  background: #f5f7fa;
}

.scanner-main {
  width: min(760px, calc(100% - 24px));
}

.entry-body {
  background: var(--primary-dark);
}

.entry-main {
  width: min(680px, calc(100% - 20px));
  margin: 10px auto 28px;
}

.entry-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 2px;
  border-top: 6px solid var(--primary);
  padding: clamp(16px, 4vw, 26px);
}

.entry-institution {
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .02em;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.entry-top-actions {
  margin: -4px 0 14px;
}

.entry-back-link {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
  color: var(--primary-dark);
  font: inherit;
  font-weight: 800;
  padding: 10px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.entry-person {
  margin-bottom: 18px;
}

.entry-label,
.entry-email {
  color: var(--muted);
  font-size: 15px;
}

.entry-person h1 {
  margin: 4px 0;
  font-size: clamp(34px, 8vw, 58px);
  line-height: 1.02;
}

.entry-wallet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0 0 18px;
}

.entry-feedback {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  padding: 18px;
  border-radius: 2px;
  border: 4px solid var(--line);
  font-size: 21px;
  font-weight: 800;
  text-align: center;
}

.entry-feedback strong {
  display: grid;
  gap: 2px;
  font-size: clamp(30px, 8vw, 54px);
  line-height: 1;
}

.entry-feedback strong span {
  font-size: clamp(72px, 24vw, 150px);
  line-height: .86;
}

.entry-feedback-kicker {
  font-size: clamp(22px, 6vw, 34px);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.entry-feedback.success {
  color: #fff;
  border-color: var(--ok);
  background: var(--ok);
}

.entry-feedback.warning {
  color: var(--warn);
  border-color: var(--warn);
  background: #fff7e6;
}

.entry-feedback.error {
  color: var(--danger);
  border-color: var(--danger);
  background: #fff0f0;
}

.entry-counts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}

.entry-counts div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}

.entry-counts span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.entry-counts strong {
  display: block;
  font-size: 38px;
  line-height: 1;
  margin-top: 4px;
}

.entry-primary-form {
  display: grid;
  justify-items: center;
  margin: 20px 0 12px;
}

.entry-back-button {
  min-height: 64px;
  margin: 14px 0 4px;
  border-radius: 2px;
  background: var(--primary-dark);
  color: #fff;
  font-weight: 900;
  font-size: clamp(24px, 7vw, 38px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
}

.entry-primary-button {
  width: 100%;
  max-width: min(100%, 520px);
  aspect-ratio: 1 / 1;
  min-height: auto;
  display: grid;
  gap: 10px;
  place-items: center;
  align-content: center;
  font-size: clamp(42px, 12vw, 76px);
  line-height: .95;
  border-radius: 2px;
  background: var(--accent);
  text-align: center;
  padding: clamp(18px, 5vw, 34px);
  box-shadow: 0 18px 36px rgba(7, 33, 64, .22);
}

.entry-primary-button small {
  display: block;
  font-size: clamp(18px, 5vw, 30px);
  line-height: 1.1;
}

.entry-primary-button:disabled {
  background: var(--ok);
  color: #fff;
  opacity: 1;
}

.entry-partial {
  margin-top: 10px;
}

.entry-partial summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
  padding: 14px;
  list-style: none;
}

.entry-partial summary::-webkit-details-marker {
  display: none;
}

.entry-slots {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.entry-slot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.entry-slot.done {
  border-color: var(--ok);
  background: #f0f8f3;
}

.entry-slot.removed {
  border-color: var(--line);
  background: #eef1f5;
  opacity: .82;
}

.entry-slot span {
  display: block;
  color: var(--muted);
}

.entry-small-button {
  min-height: 48px;
  padding: 10px 14px;
}

.login-body {
  background: var(--primary-dark);
}

.login-main {
  width: min(440px, calc(100% - 24px));
  margin-top: 12vh;
}

.login-panel label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}

#reader {
  width: min(640px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.muted {
  color: var(--muted);
}

.wide {
  width: 100%;
}

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
  }

  .nav a,
  .tools-menu,
  .tools-menu summary,
  .button,
  button,
  input[type="submit"] {
    width: 100%;
  }

  .tools-menu-content {
    position: static;
    margin-top: 6px;
    box-shadow: none;
  }

  table {
    font-size: 14px;
  }

  th,
  td {
    padding: 8px;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .event-access {
    grid-template-columns: 1fr;
  }

  .email-editor-layout {
    grid-template-columns: 1fr;
  }

  .danger-zone-form {
    grid-template-columns: 1fr;
  }

  .entry-counts,
  .entry-slot {
    grid-template-columns: 1fr;
  }

  .qr-list-cell img {
    width: 92px;
    height: 92px;
  }
}

@media print {
  .topbar,
  .no-print,
  .actions {
    display: none !important;
  }

  body {
    background: #fff;
  }

  main {
    width: 100%;
    margin: 0;
  }

  .qr-card {
    break-inside: avoid;
  }
}
