:root {
  --app-sidebar-bg: #101828;
  --app-sidebar-fg: #e2e8f0;
  --app-topbar-bg: #0b1120;
  --app-sidebar-width: 236px;
  --app-surface: #f5f7fb;
}

body.app-body {
  background: var(--app-surface);
}

.app-body a {
  text-decoration: none;
}

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

.app-topbar {
  background: var(--app-topbar-bg);
}

.app-topbar .navbar-brand,
.app-topbar .btn-link {
  color: #fff;
}

.app-shell {
  display: flex;
  min-height: calc(100vh - 56px);
}

.app-shell > .app-sidebar {
  width: var(--app-sidebar-width);
  flex: 0 0 var(--app-sidebar-width);
  background-color: var(--app-sidebar-bg);
}

.app-shell > .app-sidebar .offcanvas-body {
  background-color: var(--app-sidebar-bg);
}

.app-main {
  flex: 1 1 auto;
  min-width: 0; /* lets wide tables scroll instead of stretching the page */
}

@media (max-width: 991.98px) {
  .app-shell > .app-sidebar {
    width: 260px;
  }
}

.app-nav {
  padding: 0.75rem 0.5rem;
}

.app-nav .nav-link {
  color: var(--app-sidebar-fg);
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.15rem;
  font-size: 0.925rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.app-nav .nav-link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.app-nav .nav-link.active {
  background: #2563eb;
  color: #fff;
}

/* ------------------------------------------------------------ components */

.card {
  border: 1px solid #e6e9f0;
  border-radius: 0.75rem;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.1;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
}

.field-row {
  background: #fff;
  border: 1px solid #e6e9f0;
  border-radius: 0.6rem;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.field-row.is-hidden {
  opacity: 0.55;
}

.drag-handle {
  cursor: grab;
  color: #9ca3af;
}

.sortable-ghost {
  opacity: 0.4;
  background: #eef2ff;
}

/* ------------------------------------------------------------- check-in */

.checkin-result {
  border-radius: 0.75rem;
  padding: 1.25rem;
  text-align: center;
}

.checkin-result.success { background: #dcfce7; border: 2px solid #16a34a; }
.checkin-result.duplicate { background: #fef9c3; border: 2px solid #ca8a04; }
.checkin-result.not_found,
.checkin-result.not_admissible { background: #fee2e2; border: 2px solid #dc2626; }

.checkin-result .result-icon {
  font-size: 3rem;
  line-height: 1;
}

.checkin-scan-alert {
  position: sticky;
  z-index: 1090;
  top: calc(56px + 0.75rem);
  width: min(100%, 440px);
  margin: 0 auto 1rem;
}

.checkin-scan-alert[hidden] {
  display: none !important;
}

#qr-reader {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

/* -------------------------------------------------------------- public */

.public-body {
  background: #f8fafc;
}

.public-hero {
  color: #fff;
  padding: 3rem 0;
  background-size: cover;
  background-position: center;
}

.public-card {
  border-radius: 1rem;
  border: 1px solid #e6e9f0;
  background: #fff;
}

.registration-image-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: min(60vh, 360px);
  overflow: hidden;
  background: #f1f5f9;
}

.registration-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(60vh, 360px);
  object-fit: contain;
}

.ticket-qr img {
  width: min(220px, 100%);
  height: auto;
  aspect-ratio: 1;
}

.print-table-title {
  display: none;
}

.report-print-header {
  display: none;
}

.signature-pad {
  border: 1px dashed #9ca3af;
  border-radius: 0.5rem;
  background: #fff;
  touch-action: none;
  width: 100%;
  max-width: 420px;
  height: 160px;
}

@media print {
  .app-topbar,
  .app-sidebar,
  .no-print,
  .btn,
  .pagination {
    display: none !important;
  }
  .app-shell {
    display: block;
    min-height: 0;
  }
  .app-main > .container-fluid {
    padding: 0 !important;
  }
  .table-wrap {
    overflow: visible !important;
  }
  body,
  body.app-body {
    background: #fff !important;
  }
  .public-card { border: none; }
  .card,
  .table tr {
    break-inside: avoid;
  }
  a {
    color: inherit !important;
    text-decoration: none !important;
  }

  body.printing-table > * {
    display: none !important;
  }
  body.printing-table > .print-active {
    display: block !important;
    position: static !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }
  body.printing-table .print-active .print-table-title {
    display: flex !important;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 0 0.5rem !important;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #d5dce5;
    color: #243247 !important;
    font-size: 11pt !important;
    font-weight: 600;
    line-height: 1.35;
  }
  body.printing-table .print-active .printable-table {
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  body.printing-table .print-active .card-header {
    padding: 0 !important;
    border: 0 !important;
    background: #fff !important;
  }
  body.printing-table .print-active .card-header h2 {
    display: none !important;
  }
  body.printing-table .print-active .table-wrap {
    overflow: visible !important;
  }
  body.printing-table .print-active table {
    width: 100% !important;
    color: #111 !important;
    font-size: 9pt;
  }
  body.printing-table .print-active th,
  body.printing-table .print-active td {
    color: #111 !important;
    border: 1px solid #999 !important;
  }
  body.printing-table .print-active th {
    background: #eef2f7 !important;
    font-weight: 600;
  }
  body.printing-table .print-active td {
    background: #fff !important;
  }

  .reports-page .page-header {
    display: none !important;
  }
  .reports-page .report-print-header {
    display: block !important;
    margin-bottom: 0.75rem;
  }
  .reports-page .report-print-header .print-table-title {
    display: flex !important;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem !important;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #cbd5e1;
    color: #172b4d !important;
    font-size: 15pt !important;
    font-weight: 700;
    line-height: 1.25;
  }
  .reports-page .report-print-header .print-title-left {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
  }
  .reports-page .report-print-header .print-title-label {
    font-size: 15pt;
    font-weight: 700;
  }
  .reports-page .report-print-header .print-title-meta {
    color: #475467 !important;
    font-size: 8pt;
    font-weight: 400;
    line-height: 1.35;
  }
  .reports-page .report-print-header .print-title-count {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    white-space: nowrap;
  }
  .reports-page .report-print-header .print-title-count strong {
    color: #172b4d;
    font-size: 19pt;
    line-height: 1.1;
  }
  .reports-page .report-print-header .print-title-count span {
    color: #475467;
    font-size: 8pt;
    font-weight: 400;
  }
  .reports-page .report-summary {
    display: none !important;
  }
  .reports-page > .card,
  .reports-page .report-breakdown .card {
    margin-bottom: 0.5rem !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    break-inside: auto;
  }
  .reports-page .card-header {
    padding: 0.3rem 0 !important;
    border-bottom: 1px solid #d5dce5 !important;
    background: #fff !important;
  }
  .reports-page .card-header h2 {
    font-size: 10pt;
    font-weight: 700;
  }
  .reports-page .report-registrant-header {
    break-after: avoid;
  }
  .reports-page .report-card-event-meta,
  .reports-page .report-registrant-count,
  .reports-page .report-registrant-header .btn {
    display: none !important;
  }
  .reports-page .report-breakdown {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
    gap: 0.5rem !important;
    margin: 0 !important;
  }
  .reports-page .report-breakdown > div {
    width: auto !important;
    max-width: none !important;
    padding: 0 !important;
  }
  .reports-page .table {
    margin-bottom: 0 !important;
    font-size: 8pt !important;
  }
  .reports-page .table th,
  .reports-page .table td {
    padding: 0.25rem 0.35rem !important;
    border: 1px solid #cbd5e1 !important;
  }
  .reports-page .table thead th {
    background: #edf2f7 !important;
    color: #243247 !important;
    font-size: 7pt;
    font-weight: 600;
    letter-spacing: 0.035em;
    text-transform: uppercase;
  }
  .reports-page .table thead {
    display: table-header-group;
  }
  body.printing-report .reports-page {
    display: block !important;
  }
  .reports-page #report-registrants-table {
    break-inside: auto !important;
  }
  .reports-page #report-registrants-table tr {
    break-inside: avoid !important;
  }
  .reports-page .pagination,
  .reports-page .no-print {
    display: none !important;
  }
}
