:root {
  color-scheme: light;
  --paper: #fffaf2;
  --ink: #201b18;
  --muted: #6c625b;
  --line: #d8cabd;
  --red: #c8171f;
  --green: #118241;
  --gold: #e6b53f;
  --black: #111111;
  --surface: #ffffff;
  --soft: #f5efe7;
  --shadow: 0 18px 45px rgba(45, 30, 18, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(200, 23, 31, 0.08), rgba(17, 130, 65, 0.08)),
    var(--paper);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.brand-mini {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}

.brand-mini img {
  width: 42px;
  height: 46px;
  object-fit: contain;
}

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

.page {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(216, 202, 189, 0.88);
  box-shadow: var(--shadow);
}

.entry-page {
  max-width: 680px;
  margin: 8vh auto 0;
  padding: clamp(28px, 6vw, 56px);
  text-align: center;
}

.entry-logo {
  width: 116px;
  height: 130px;
  object-fit: contain;
  margin-bottom: 22px;
}

.entry-page h1 {
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1.08;
  margin-bottom: 12px;
}

.entry-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 30px;
}

.admin-entry-links {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.login-layout {
  min-height: calc(100vh - 80px);
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  overflow: hidden;
}

.ceremony-panel {
  position: relative;
  padding: 42px;
  background:
    linear-gradient(145deg, rgba(200, 23, 31, 0.94), rgba(200, 23, 31, 0.8) 42%, rgba(17, 130, 65, 0.9));
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 620px;
  overflow: hidden;
}

.ceremony-panel::after {
  content: "";
  position: absolute;
  inset: auto -60px -16px 12%;
  height: 58px;
  background: linear-gradient(90deg, #fff 0 52%, var(--green) 52% 73%, var(--black) 73% 88%, var(--gold) 88%);
  transform: rotate(-13deg);
  opacity: 0.9;
  z-index: 0;
}

.ceremony-panel > * {
  position: relative;
  z-index: 1;
}

.logo-lockup {
  position: relative;
  z-index: 1;
}

.logo-lockup img {
  width: 132px;
  height: 148px;
  object-fit: contain;
  background: #fff;
  padding: 7px;
}

.conference-title {
  position: relative;
  z-index: 1;
  margin-top: 72px;
}

.eyebrow {
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.84rem;
  font-weight: 700;
  opacity: 0.88;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

.conference-title h1 {
  max-width: 520px;
  font-size: clamp(2.1rem, 4vw, 4.1rem);
  line-height: 1.04;
}

.conference-title p {
  max-width: 460px;
  margin: 18px 0 0;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.9);
}

.login-panel {
  padding: 46px;
  display: flex;
  align-items: center;
}

.login-card,
.admin-panel,
.form-paper {
  width: 100%;
}

.login-card h2,
.admin-panel h2 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  margin-bottom: 10px;
}

.lead {
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 26px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field.span-2,
.form-row.span-2 {
  grid-column: 1 / -1;
}

label {
  color: #3e342f;
  font-size: 0.86rem;
  font-weight: 700;
}

/* Chinese helper translations for testing. Hide before launch with:
   .cn-tip { display: none !important; }
*/
.cn-tip {
  color: #8b7c72;
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.25;
  margin-top: 2px;
}

body.hide-cn .cn-tip {
  display: none !important;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #f3eee8;
  color: #9b8e84;
  cursor: not-allowed;
}

.field.is-disabled label,
.field.is-disabled .cn-tip {
  opacity: 0.56;
}

.switch-row {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  gap: 10px;
  padding: 12px;
}

.switch-row input {
  width: auto;
}

.import-box {
  border-top: 1px solid var(--line);
  margin-top: 24px;
  padding-top: 20px;
}

.import-box h3 {
  font-size: 1rem;
  margin-bottom: 4px;
}

.details-table {
  min-width: 2200px;
}

.details-table th,
.details-table td {
  min-width: 150px;
}

.file-input-native {
  height: 1px;
  opacity: 0;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

.file-picker {
  margin-top: 10px;
}

.file-name {
  color: var(--muted);
  display: block;
  margin-top: 8px;
}

.cn-tip.inline {
  display: inline;
  margin-left: 4px;
}

.btn .cn-tip {
  color: inherit;
  font-size: 0.68rem;
  opacity: 0.72;
}

.ceremony-panel .cn-tip {
  color: rgba(255, 255, 255, 0.82);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 12px 12px;
  outline: none;
}

textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(17, 130, 65, 0.12);
}

.btn {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 11px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  text-decoration: none;
}

.btn-primary {
  color: #fff;
  background: var(--green);
}

.btn-secondary {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.btn-danger {
  color: #fff;
  background: var(--red);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.notice {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 6px;
  display: none;
  line-height: 1.45;
}

.notice.show {
  display: block;
}

.notice.error {
  color: #8f1118;
  background: #fff0f1;
  border: 1px solid #f3c7ca;
}

.notice.success {
  color: #0b6631;
  background: #eefaf3;
  border: 1px solid #bce5cd;
}

.form-page {
  background: #f1eadf;
}

.form-paper {
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 46px);
}

.paper-header {
  text-align: center;
  padding-bottom: 22px;
  border-bottom: 2px solid #231f20;
}

.paper-header img {
  display: block;
  width: 92px;
  height: 104px;
  object-fit: contain;
  margin: 0 auto 14px;
}

.paper-header h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 2.5vw, 2.1rem);
  line-height: 1.4;
  text-transform: uppercase;
}

.paper-meta {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 14px;
  align-items: end;
  margin-top: 20px;
}

.form-title-band {
  display: grid;
  grid-template-columns: 1fr 168px;
  gap: 24px;
  align-items: center;
  margin: 36px 0 24px;
}

.form-title-band h2 {
  font-family: Georgia, "Times New Roman", serif;
  text-align: center;
  font-size: clamp(1.4rem, 3vw, 2rem);
  text-transform: uppercase;
}

.photo-box {
  position: relative;
  width: 100%;
  height: 168px;
  border: 2px solid #2f2925;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.photo-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.photo-box.has-image span {
  display: none;
}

.photo-box.has-image img {
  display: block;
}

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

.photo-actions input {
  display: none;
}

#cameraInput,
#galleryInput {
  display: none;
}

.form-section {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.form-section h3 {
  margin-bottom: 14px;
  font-size: 1rem;
  text-transform: uppercase;
}

.registration-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
}

.form-row {
  grid-column: span 6;
}

.form-row.span-3 {
  grid-column: span 3;
}

.form-row.span-4 {
  grid-column: span 4;
}

.form-row.span-6 {
  grid-column: span 6;
}

.form-row.span-12 {
  grid-column: 1 / -1;
}

.date-group {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 8px;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.radio-pill {
  flex: 1 1 112px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 11px 12px;
}

.radio-pill input {
  width: auto;
}

.admin-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
}

.admin-shell {
  background: #f5f7fb;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.admin-sidebar {
  background: #ffffff;
  border-right: 1px solid #e6eaf0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 14px;
}

.admin-sidebar img {
  height: 44px;
  object-fit: contain;
  width: 44px;
}

.admin-sidebar strong {
  color: #222831;
  margin: 6px 0 14px;
}

.admin-sidebar a {
  border-radius: 6px;
  color: #4b5563;
  font-weight: 700;
  padding: 12px 14px;
  text-decoration: none;
}

.admin-sidebar a.active,
.admin-sidebar a:hover {
  background: #eef2ff;
  color: #4f46e5;
}

.admin-main {
  min-width: 0;
  padding: 18px;
}

.admin-topbar {
  align-items: center;
  background: #ffffff;
  border: 1px solid #e6eaf0;
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 14px 18px;
}

.admin-topbar h1 {
  font-size: 1.3rem;
}

.metric-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.mobile-qr-panel {
  align-items: center;
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr) 190px;
  margin-bottom: 16px;
}

.mobile-qr-panel[hidden] {
  display: none;
}

.mobile-qr-panel img {
  background: #fff;
  border: 1px solid #e6eaf0;
  border-radius: 8px;
  height: 190px;
  justify-self: end;
  padding: 8px;
  width: 190px;
}

.mobile-qr-address {
  background: #f5f7fb;
  border: 1px solid #e6eaf0;
  border-radius: 6px;
  color: #111827;
  font-weight: 700;
  line-height: 1.4;
  margin-top: 12px;
  overflow-wrap: anywhere;
  padding: 12px;
}

.metric-card {
  background: #fff;
  border: 1px solid #e6eaf0;
  padding: 18px;
}

.metric-card span,
.metric-card small {
  color: #6b7280;
  display: block;
}

.metric-card strong {
  color: #111827;
  display: block;
  font-size: 2rem;
  margin: 8px 0;
}

.section-heading-row {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.checkin-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.checkin-summary span {
  background: #f5f7fb;
  border: 1px solid #e6eaf0;
  border-radius: 6px;
  color: #4b5563;
  padding: 9px 12px;
}

.checkin-summary strong {
  color: #111827;
}

.checkin-table {
  min-width: 1150px;
}

.whitelist-list-table {
  min-width: 860px;
}

.whitelist-list-table th:nth-child(4),
.whitelist-list-table td:nth-child(4) {
  min-width: 190px;
}

.table-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
}

.btn-small {
  font-size: 0.84rem;
  min-height: 34px;
  padding: 7px 10px;
}

.status-pill {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 700;
  min-height: 24px;
  padding: 3px 9px;
}

.status-pill.ok {
  background: #e9f8ef;
  color: #0b6631;
}

.status-pill.muted {
  background: #f1f2f4;
  color: #6b7280;
}

.admin-panel {
  background: #fff;
  border: 1px solid var(--line);
  padding: 22px;
  min-width: 0;
}

.qr-result {
  border: 1px solid var(--line);
  margin-top: 22px;
  padding: 20px;
  text-align: center;
}

.qr-result img {
  display: block;
  height: 220px;
  margin: 14px auto;
  width: 220px;
}

.verify-shell {
  max-width: 680px;
}

.ticket-shell {
  max-width: 640px;
}

.scanner-shell {
  max-width: 880px;
}

.verify-card,
.ticket-card {
  padding: 34px;
  text-align: center;
}

.ticket-qr {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  height: 280px;
  margin: 22px auto 16px;
  padding: 8px;
  width: 280px;
}

.ticket-card h2 {
  font-size: 1.35rem;
  margin-bottom: 6px;
}

.ticket-address {
  background: #f5f7fb;
  border: 1px solid #e6eaf0;
  border-radius: 6px;
  color: #111827;
  font-size: 0.9rem;
  line-height: 1.4;
  margin-top: 18px;
  overflow-wrap: anywhere;
  padding: 12px;
  text-align: left;
}

.mobile-scan-panel {
  margin-top: 20px;
  position: relative;
}

.mobile-scan-panel[hidden] {
  display: none;
}

.mobile-scan-panel video {
  aspect-ratio: 4 / 5;
  background: #111827;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  margin: 0 auto;
  max-height: 420px;
  object-fit: cover;
  width: min(100%, 360px);
}

.scan-frame {
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.22);
  height: 190px;
  left: 50%;
  pointer-events: none;
  position: absolute;
  top: 44%;
  transform: translate(-50%, -50%);
  width: 190px;
}

.scan-actions {
  justify-content: center;
}

.scanner-card {
  padding: 34px;
}

.scanner-card .entry-logo,
.scanner-card .eyebrow,
.scanner-card h1 {
  display: block;
  text-align: center;
}

.scanner-card .entry-logo {
  margin-left: auto;
  margin-right: auto;
}

.scanner-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(220px, 0.75fr) minmax(300px, 1.25fr);
  margin-top: 22px;
}

.scanner-grid-single {
  grid-template-columns: 1fr;
}

.scanner-input-field input {
  border-color: var(--green);
  font-size: 1.15rem;
  font-weight: 700;
  min-height: 54px;
}

.verify-details {
  display: grid;
  gap: 8px;
  grid-template-columns: 160px 1fr;
  margin: 22px 0;
  text-align: left;
}

.verify-details dt {
  color: var(--muted);
  font-weight: 700;
}

.verify-details dd {
  margin: 0;
}

.scanner-details {
  border: 1px solid var(--line);
  margin-top: 22px;
  padding: 18px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid #eadfd4;
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
}

th {
  color: #3b302b;
  background: #f7f0e8;
  white-space: nowrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 700;
  background: #f1eadf;
}

.status-on {
  color: #0b6631;
}

.status-off {
  color: #8f1118;
}

@media (max-width: 860px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    flex-direction: row;
    overflow-x: auto;
  }

  .admin-main {
    padding: 10px;
  }

  .admin-topbar,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .admin-topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .login-layout,
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .mobile-qr-panel {
    grid-template-columns: 1fr;
  }

  .mobile-qr-panel img {
    justify-self: start;
  }

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

  .entry-links {
    grid-template-columns: 1fr;
  }

  .ceremony-panel {
    min-height: 430px;
  }

  .ceremony-panel::after {
    bottom: -58px;
  }

  .field-grid,
  .paper-meta,
  .form-title-band {
    grid-template-columns: 1fr;
  }

  .form-title-band {
    justify-items: center;
  }

  .photo-uploader {
    width: min(260px, 100%);
  }

  .form-row,
  .form-row.span-3,
  .form-row.span-4,
  .form-row.span-6 {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 12px;
  }

  .ceremony-panel,
  .login-panel {
    padding: 24px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .date-group,
  .photo-actions {
    grid-template-columns: 1fr;
  }
}
