:root {
  --ink: #4d332d;
  --muted: #8d746d;
  --paper: #fffaf6;
  --panel: #fffdfb;
  --peach: #f3c7b2;
  --rose: #df977d;
  --sand: #ebc99e;
  --cocoa: #8a4636;
  --success: #257a49;
  --danger: #b33333;
  --line: rgba(77, 51, 45, 0.15);
  --shadow: 0 24px 70px rgba(116, 61, 44, 0.18);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(255, 251, 246, 0.94), rgba(239, 176, 151, 0.5)),
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.9), transparent 34%),
    #edb399;
  color: var(--ink);
}

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

button,
a {
  touch-action: manipulation;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 28px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 560px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 0.96;
  letter-spacing: 0;
  text-transform: capitalize;
}

h2 {
  font-size: 28px;
  line-height: 1.12;
}

.eyebrow,
.label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 10px 30px rgba(77, 51, 45, 0.08);
}

.tab-button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.tab-button.active {
  color: #fff;
  background: var(--cocoa);
  box-shadow: 0 10px 22px rgba(138, 70, 54, 0.25);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel-grid,
.ticket-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 440px);
  gap: 28px;
  align-items: start;
}

.checkin-grid {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
}

.panel,
.table-section {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 253, 251, 0.76);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel {
  padding: 28px;
}

.panel h2 {
  margin-top: 8px;
  margin-bottom: 20px;
}

.body-copy,
.helper-text {
  color: var(--muted);
  line-height: 1.55;
}

.form-stack,
.manual-form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  outline: none;
}

textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(138, 70, 54, 0.32);
  outline-offset: 2px;
}

.primary-button,
.ghost-button,
.whatsapp-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 20px;
  border: 1px solid transparent;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}

.primary-button {
  color: #fff;
  background: #151110;
  box-shadow: 0 16px 28px rgba(21, 17, 16, 0.22);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.58);
  border-color: var(--line);
  color: var(--ink);
}

.whatsapp-button {
  width: 100%;
  margin-top: 16px;
  background: var(--success);
  color: #fff;
}

.whatsapp-button.disabled {
  pointer-events: none;
  opacity: 0.48;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.phone-preview {
  display: grid;
  justify-items: center;
}

.ticket-card {
  position: relative;
  width: min(100%, 400px);
  overflow: hidden;
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.ticket-card::before,
.ticket-card::after {
  content: "";
  position: absolute;
  left: -12px;
  bottom: 232px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--peach);
  z-index: 2;
}

.ticket-card::after {
  left: auto;
  right: -12px;
}

.ticket-hero {
  min-height: 168px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 26px;
  background: linear-gradient(145deg, #f6cfbd, #f1b79f);
  text-align: center;
}

.ticket-hero p {
  color: #d39a56;
  font-size: 10px;
  letter-spacing: 0.52em;
  text-transform: uppercase;
}

.ticket-hero h2 {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--cocoa);
  font-size: 22px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ticket-hero span {
  color: #e2ac52;
  font-family: "Brush Script MT", "Segoe Script", cursive;
  font-size: 27px;
}

.ticket-body {
  position: relative;
  min-height: 248px;
  padding: 28px 26px 30px;
}

.ticket-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  padding-bottom: 24px;
  text-align: center;
}

.ticket-meta > div + div {
  border-left: 1px solid rgba(138, 70, 54, 0.24);
}

.ticket-meta span,
.ticket-meta small {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.ticket-meta strong {
  display: block;
  margin-top: 7px;
  color: var(--cocoa);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.05;
}

.ticket-body h3 {
  margin: 8px 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
}

.ticket-no {
  color: var(--cocoa);
  font-weight: 900;
  letter-spacing: 0.14em;
}

.pill {
  position: absolute;
  right: 26px;
  bottom: 36px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #b98268, #955844);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 0 10px 20px rgba(138, 70, 54, 0.22);
}

.ticket-stub {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 196px;
  gap: 18px;
  min-height: 232px;
  padding: 28px 26px;
  border-top: 1px dashed rgba(138, 70, 54, 0.32);
  background: linear-gradient(145deg, #eac59a, #f0d8b5);
}

.ticket-stub p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.85;
}

.ticket-stub .stub-brand {
  margin-bottom: 8px;
  color: var(--cocoa);
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.qr-box {
  display: grid;
  width: 196px;
  height: 196px;
  place-items: center;
  border-radius: 8px;
  background: #fffdfb;
  padding: 10px;
  box-shadow: 0 10px 24px rgba(138, 70, 54, 0.18);
}

.qr-box img,
.qr-box canvas {
  width: 176px !important;
  height: 176px !important;
}

.table-section {
  margin-top: 28px;
  overflow: hidden;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 26px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-weight: 650;
}

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

.table-button {
  min-height: 38px;
  padding: 0 14px;
  font-size: 13px;
}

.table-input {
  min-height: 42px;
  padding: 9px 11px;
  background: #fff;
}

.editing-row td {
  background: rgba(255, 250, 246, 0.72);
}

.locked-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.status-chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.status-chip.issued {
  background: var(--cocoa);
}

.status-chip.checked {
  background: var(--success);
}

.compact {
  transform-origin: top center;
}

.status-card,
.result-state {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.62);
}

.status-card strong,
.result-state strong {
  font-size: 20px;
}

.status-card span,
.result-state span {
  color: var(--muted);
}

.status-card.checked,
.result-state.success {
  border-color: rgba(37, 122, 73, 0.38);
  background: rgba(37, 122, 73, 0.08);
}

.result-state.danger {
  border-color: rgba(179, 51, 51, 0.38);
  background: rgba(179, 51, 51, 0.08);
}

.scanner-frame {
  position: relative;
  display: grid;
  min-height: 280px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #201716;
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-empty {
  position: absolute;
  inset: auto 24px 24px;
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 250, 246, 0.92);
  color: var(--ink);
  text-align: center;
}

.manual-form {
  margin-top: 18px;
}

.guest-detail {
  display: grid;
  gap: 12px;
  margin: 22px 0 0;
}

.guest-detail div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

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

dd {
  margin: 0;
  font-weight: 900;
  text-align: right;
}

.settings-panel {
  max-width: 780px;
}

.firebase-connection {
  margin-top: 18px;
  text-align: center;
}

.attendee-mode .topbar {
  display: none;
}

.attendee-mode .app-shell {
  padding-top: 24px;
}

.attendee-mode #ticket-view {
  display: block;
}

.attendee-mode #owner-view,
.attendee-mode #checkin-view,
.attendee-mode .firebase-connection {
  display: none;
}

.attendee-mode .ticket-layout {
  grid-template-columns: minmax(0, 420px);
  justify-content: center;
}

.attendee-mode #ticket-view > .ticket-layout > .panel {
  display: none;
}

@media (max-width: 880px) {
  .app-shell {
    width: min(100% - 20px, 620px);
    padding-top: 18px;
  }

  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs {
    overflow-x: auto;
    border-radius: 8px;
  }

  .tab-button {
    flex: 1 0 auto;
  }

  .panel-grid,
  .ticket-layout,
  .checkin-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 22px;
  }

  .ticket-card {
    max-width: 420px;
  }
}

@media (max-width: 440px) {
  .ticket-body,
  .ticket-stub,
  .ticket-hero {
    padding-left: 20px;
    padding-right: 20px;
  }

  .ticket-stub {
    grid-template-columns: 1fr;
  }

  .pill {
    position: static;
    margin-top: 18px;
  }

  .qr-box {
    justify-self: center;
  }
}
