:root {
  --green: #0fbf63;
  --blue: #0877d9;
  --ink: #102033;
  --muted: #64748b;
  --surface: rgba(255, 255, 255, 0.86);
  --line: rgba(15, 23, 42, 0.1);
  --shadow: 0 18px 50px rgba(15, 35, 70, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans Thai", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 0%, rgba(8, 119, 217, 0.2), transparent 32%),
    radial-gradient(circle at 90% 12%, rgba(15, 191, 99, 0.2), transparent 26%),
    linear-gradient(180deg, #f6fbff 0%, #eaf7f0 100%);
}

body.share-open {
  overflow: hidden;
}

.app-shell,
.admin-shell {
  width: min(100%, 440px);
  margin: 0 auto;
  padding: 10px 12px calc(24px + env(safe-area-inset-bottom));
}

.hero {
  overflow: hidden;
  display: grid;
  place-items: center;
  border-radius: 24px;
  box-shadow: var(--shadow);
  background: #fff;
}

.hero img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(72svh, 660px);
  object-fit: contain;
  background: #fff;
}

.hero-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.hero-actions .share-btn {
  margin-top: 0;
}

.panel {
  margin-top: 14px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(15, 35, 70, 0.1);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-weight: 900;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  line-height: 1.16;
}

.event-card h1 {
  font-size: 25px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chips span {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(8, 119, 217, 0.1);
  color: #075da9;
  font-size: 13px;
  font-weight: 800;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 18px;
  font-weight: 900;
}

.section-title strong {
  color: #d61f3c;
  font-size: 22px;
}

.qr {
  display: block;
  width: min(100%, 320px);
  margin: 16px auto 8px;
  border-radius: 22px;
}

.payment-card p {
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

label,
fieldset {
  display: block;
  margin: 0 0 14px;
  border: 0;
  padding: 0;
}

label span,
legend {
  display: block;
  margin-bottom: 7px;
  color: #334155;
  font-weight: 900;
}

input[type="text"],
input[type="tel"],
input:not([type]) {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0 16px;
  background: rgba(248, 250, 252, 0.9);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  outline: none;
}

input:focus {
  border-color: rgba(15, 191, 99, 0.75);
  box-shadow: 0 0 0 4px rgba(15, 191, 99, 0.13);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.06);
}

.segmented label {
  margin: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  margin: 0;
  padding: 12px 8px;
  border-radius: 15px;
  color: #475569;
  text-align: center;
}

.segmented input:checked + span {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(15, 35, 70, 0.12);
}

.upload-box {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 150px;
  overflow: hidden;
  border: 2px dashed rgba(8, 119, 217, 0.32);
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(8, 119, 217, 0.08), rgba(15, 191, 99, 0.08));
  text-align: center;
}

.upload-box input {
  display: none;
}

.upload-icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0;
  border-radius: 18px;
  background: var(--blue);
  color: #fff;
  font-size: 34px;
  line-height: 1;
}

.upload-box strong {
  position: relative;
  z-index: 1;
  margin-top: 12px;
  font-size: 20px;
}

.upload-box small {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-weight: 700;
}

.upload-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-box:has(.upload-preview:not([hidden])) {
  min-height: 240px;
  border-style: solid;
  background: #0f172a;
}

.upload-box:has(.upload-preview:not([hidden]))::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, transparent 30%, rgba(15, 23, 42, 0.72));
}

.upload-box:has(.upload-preview:not([hidden])) .upload-icon {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--blue);
  font-size: 28px;
}

.upload-box:has(.upload-preview:not([hidden])) strong,
.upload-box:has(.upload-preview:not([hidden])) small {
  color: #fff;
  text-shadow: 0 2px 10px rgba(15, 23, 42, 0.45);
}

.primary-btn,
.share-btn,
.back-link,
.admin-link,
.table-title button {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 18px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.action-link,
.back-link {
  display: inline-grid;
  place-items: center;
  text-decoration: none;
}

.primary-btn {
  background: linear-gradient(135deg, var(--green), #07a6df);
  color: #fff;
  box-shadow: 0 12px 26px rgba(15, 191, 99, 0.28);
}

.share-btn {
  margin-top: 10px;
  background: #fff;
  color: #06a84d;
  border: 1px solid rgba(6, 199, 85, 0.24);
}

.share-sheet[hidden] {
  display: none;
}

.share-sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.share-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.34);
  backdrop-filter: blur(10px);
}

.share-sheet__panel {
  position: absolute;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 12px;
  width: min(100% - 24px, 500px);
  margin: 0 auto;
  padding: 10px 14px 14px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 70px rgba(15, 35, 70, 0.28);
}

.share-sheet__handle {
  width: 44px;
  height: 5px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: #dbe4ee;
}

.share-sheet h2 {
  margin: 0;
  font-size: 24px;
}

.share-sheet p {
  margin: 3px 0 14px;
  color: var(--muted);
  font-weight: 700;
}

.share-option,
.share-cancel {
  width: 100%;
  min-height: 64px;
  border: 0;
  border-radius: 20px;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.share-option {
  display: grid;
  gap: 2px;
  margin-top: 10px;
  padding: 12px 16px;
  color: #fff;
}

.share-option span {
  font-size: 19px;
  font-weight: 900;
}

.share-option small {
  color: rgba(255, 255, 255, 0.86);
  font-weight: 700;
}

.share-option--line {
  background: linear-gradient(135deg, #06c755, #00a84b);
}

.share-option--facebook {
  background: linear-gradient(135deg, #1877f2, #0b5fcc);
}

.share-cancel {
  margin-top: 10px;
  background: #f1f5f9;
  color: #334155;
  text-align: center;
  font-weight: 900;
}

.back-link {
  width: auto;
  min-height: 42px;
  margin: 0 0 12px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--blue);
  font-weight: 900;
}

.status {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.success-popup[hidden] {
  display: none;
}

.success-popup {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(12px);
}

.success-popup__card {
  display: grid;
  width: min(100%, 340px);
  min-height: 150px;
  place-items: center;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 80px rgba(15, 35, 70, 0.26);
}

.success-popup__card strong {
  color: var(--green);
  font-size: clamp(32px, 9vw, 46px);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.register-flow[hidden] {
  display: none;
}

.admin-shell {
  max-width: 980px;
  width: min(100%, 980px);
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
}

.admin-header h1 {
  font-size: 26px;
}

.admin-link {
  display: inline-grid;
  place-items: center;
  width: auto;
  padding: 0 18px;
  text-decoration: none;
  background: #fff;
  color: var(--blue);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stats div,
.table-panel,
.row {
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(15, 35, 70, 0.1);
}

.stats div {
  padding: 16px 12px;
}

.stats span {
  display: block;
  font-size: 30px;
  font-weight: 900;
}

.stats small {
  color: var(--muted);
  font-weight: 800;
}

.table-panel {
  margin-top: 12px;
  padding: 14px;
}

.table-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.table-title button {
  width: auto;
  min-height: 44px;
  padding: 0 16px;
  background: var(--ink);
  color: #fff;
}

.rows {
  display: grid;
  gap: 10px;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 14px;
}

.row strong {
  display: block;
  font-size: 18px;
}

.row span,
.row small {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.row-code {
  margin-top: 3px;
  color: var(--blue);
  font-weight: 900;
}

.row-admin {
  margin-top: 2px;
  font-size: 12px;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row-actions a {
  align-self: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(8, 119, 217, 0.1);
  color: var(--blue);
  font-weight: 900;
  text-decoration: none;
}

.icon-btn {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 0;
  border-radius: 13px;
  background: rgba(15, 23, 42, 0.08);
  color: var(--ink);
  font: inherit;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.icon-btn--danger {
  background: rgba(214, 31, 60, 0.1);
  color: #d61f3c;
}

.admin-modal[hidden] {
  display: none;
}

.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
}

.admin-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.34);
  backdrop-filter: blur(10px);
}

.admin-modal__card {
  position: absolute;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 12px;
  width: min(100% - 24px, 460px);
  margin: 0 auto;
  padding: 18px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(15, 35, 70, 0.28);
}

.admin-modal__card h2 {
  margin: 0;
  font-size: 24px;
}

.admin-modal__card p {
  margin: 4px 0 14px;
  color: var(--muted);
  font-weight: 700;
}

.admin-modal__card.is-delete .edit-only {
  display: none;
}

.admin-modal__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-cancel,
.modal-save {
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.modal-cancel {
  background: #f1f5f9;
  color: #334155;
}

.modal-save {
  background: linear-gradient(135deg, var(--green), #07a6df);
  color: #fff;
}

.modal-save--danger {
  background: #d61f3c;
}

@media (max-width: 620px) {
  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-actions {
    width: 100%;
  }

  .admin-link {
    width: 100%;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .row-actions {
    display: grid;
    grid-template-columns: 1fr 38px 38px;
  }
}

@media (max-width: 380px) {
  .hero-actions {
    grid-template-columns: 1fr;
  }
}

.sheet-body {
  background:
    radial-gradient(circle at 14% 0%, rgba(8, 119, 217, 0.12), transparent 28%),
    radial-gradient(circle at 88% 8%, rgba(15, 191, 99, 0.18), transparent 25%),
    #eef4f8;
}

.sheet-page {
  width: 297mm;
  min-height: 210mm;
  margin: 16px auto;
  padding: 10mm;
  background: #fff;
  color: #111827;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.15);
}

.sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 6mm;
  padding: 8mm;
  border-radius: 8mm;
  background: linear-gradient(135deg, #0fbf63 0%, #0877d9 100%);
  color: #fff;
}

.sheet-brand p {
  margin: 0 0 2mm;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 900;
}

.sheet-brand h1 {
  font-size: 22pt;
  color: #fff;
}

.sheet-brand span {
  display: block;
  margin-top: 2mm;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 700;
}

.sheet-actions {
  display: flex;
  gap: 10px;
}

.print-btn,
.save-pdf-btn {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.save-pdf-btn {
  background: #fff;
  color: #0877d9;
}

.sheet-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4mm;
  margin-bottom: 6mm;
}

.sheet-summary div {
  min-height: 18mm;
  padding: 4mm;
  border: 1px solid #dbeafe;
  border-radius: 5mm;
  background: #f8fbff;
}

.sheet-summary small,
.sheet-summary strong {
  display: block;
}

.sheet-summary small {
  color: #64748b;
  font-size: 9pt;
  font-weight: 800;
}

.sheet-summary strong {
  margin-top: 1mm;
  color: #0f315f;
  font-size: 14pt;
  font-weight: 900;
}

.registration-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 4mm;
  font-size: 11.5pt;
  break-inside: auto;
}

.registration-table th,
.registration-table td {
  height: 14mm;
  border: 1px solid #d7e0ea;
  padding: 2mm 3mm;
  vertical-align: middle;
}

.registration-table th {
  background: #0f315f;
  color: #fff;
  text-align: center;
  font-weight: 900;
}

.registration-table tbody tr:nth-child(even) {
  background: #f8fbff;
}

.registration-table tr {
  break-inside: avoid;
}

.col-no {
  width: 17mm;
  text-align: center;
}

.col-name {
  width: 48mm;
}

.col-phone {
  width: 36mm;
  text-align: center;
}

.col-paid {
  width: 22mm;
  text-align: center;
}

.col-sign {
  width: 73mm;
}

.payment-checkbox {
  width: 6mm;
  height: 6mm;
  margin: 0;
  border: 1.5px solid #0f315f;
  accent-color: var(--green);
}

.signature-line {
  display: block;
  min-height: 8mm;
  border-bottom: 1.4px dashed #94a3b8;
}

.sheet-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 6mm;
  color: #475569;
  font-size: 10pt;
  font-weight: 700;
}

@media print {
  @page {
    size: A4 landscape;
    margin: 6mm;
  }

  body {
    background: #fff;
  }

  .sheet-page {
    width: auto;
    min-height: auto;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }

  .sheet-header {
    padding: 6mm;
  }

  .sheet-actions {
    display: none;
  }

  .sheet-summary div {
    background: #f8fbff;
  }

  .registration-table {
    font-size: 10.5pt;
  }

  .registration-table th,
  .registration-table td {
    height: 14mm;
    padding: 1.8mm 2.4mm;
  }

  .sheet-header,
  .sheet-summary div,
  .registration-table,
  .registration-table th,
  .registration-table td {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
