:root {
  --ink: #17120d;
  --muted: #756b60;
  --paper: #f6f2ea;
  --panel: #fffaf2;
  --line: #e5dbce;
  --coral: #e85d54;
  --jade: #0a7c68;
  --gold: #d69b2d;
  --night: #20252a;
  --blue: #2f6fbd;
  --shadow: 0 24px 60px rgba(42, 31, 18, 0.14);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 16% 2%, rgba(232, 93, 84, 0.22), transparent 24rem),
    radial-gradient(circle at 94% 34%, rgba(10, 124, 104, 0.16), transparent 20rem),
    linear-gradient(145deg, #f8f1e7 0%, #edf3f0 56%, #f6f2ea 100%);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  opacity: 0.55;
}

.app-shell {
  position: relative;
  width: min(100%, 430px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px calc(98px + env(safe-area-inset-bottom));
}

.login-screen,
.app-screen,
.screen {
  display: none;
}

.login-screen.active,
.app-screen.active,
.screen.active {
  display: block;
}

.login-screen {
  min-height: calc(100dvh - 120px);
  padding-top: 22px;
}

.login-art {
  position: relative;
  display: grid;
  place-items: center;
  width: 108px;
  height: 108px;
  margin-bottom: 24px;
  border-radius: 8px;
  background: var(--night);
  box-shadow: var(--shadow);
}

.login-art span {
  position: absolute;
  right: -18px;
  top: -16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gold);
}

.login-art svg {
  position: relative;
  width: 64px;
  height: 64px;
  fill: #fff7e8;
}

.login-art img,
.brand-mark img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.login-art circle {
  fill: var(--coral);
}

.login-copy {
  max-width: 340px;
  margin: 12px 0 22px;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.45;
}

.sync-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.login-form,
.login-shortcuts,
.scanner-actions,
.result-actions {
  display: grid;
  gap: 10px;
}

.login-form {
  padding: 16px;
  border: 1px solid rgba(229, 219, 206, 0.92);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.84);
  box-shadow: 0 16px 38px rgba(42, 31, 18, 0.1);
}

.login-shortcuts {
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
}

.login-shortcuts .full {
  grid-column: 1 / -1;
}

.install-card {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 2px 12px;
  align-items: center;
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid rgba(10, 124, 104, 0.22);
  border-radius: 8px;
  background: rgba(10, 124, 104, 0.1);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 10px 26px rgba(42, 31, 18, 0.06);
}

.install-card span {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--jade);
  color: #fff;
  font-weight: 900;
}

.install-card strong {
  display: block;
  font-weight: 950;
}

.install-card small {
  color: var(--muted);
  font-weight: 750;
}

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

.topbar.compact {
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.9rem, 8.6vw, 2.5rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.12rem;
}

.icon-button,
.text-button,
.action-button,
.primary-button,
.secondary-button,
.tab,
.customer-card {
  border: 0;
  cursor: pointer;
}

.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(23, 18, 13, 0.1);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.84);
  color: var(--ink);
  box-shadow: 0 10px 28px rgba(42, 31, 18, 0.08);
}

.hero-pass {
  position: relative;
  overflow: hidden;
  min-height: 310px;
  padding: 20px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 94% 96%, rgba(214, 155, 45, 0.62), transparent 42%),
    linear-gradient(135deg, rgba(32, 37, 42, 0.97), rgba(37, 68, 64, 0.94));
  color: #fff9ef;
  box-shadow: var(--shadow);
}

.pass-content,
.progress-label,
.section-title,
.result-head,
.campaign,
.customer-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.pass-content {
  position: relative;
  z-index: 1;
  align-items: flex-start;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: #fff7e8;
}

.brand-mark svg {
  width: 36px;
  height: 36px;
  fill: var(--coral);
}

.pass-content p {
  margin-bottom: 4px;
  color: rgba(255, 249, 239, 0.72);
  font-size: 0.86rem;
  font-weight: 750;
}

.pass-content h2 {
  color: #fff;
  font-size: 1.6rem;
}

.pass-points {
  margin-left: auto;
  text-align: right;
}

.pass-points strong {
  display: block;
  font-size: 2.25rem;
  line-height: 0.95;
}

.pass-points span {
  color: rgba(255, 249, 239, 0.72);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.progress-block {
  position: absolute;
  right: 20px;
  bottom: 20px;
  left: 20px;
  z-index: 1;
}

.progress-label {
  margin-bottom: 9px;
  color: rgba(255, 249, 239, 0.82);
  font-size: 0.82rem;
  font-weight: 850;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), #f7d57d);
  transition: width 320ms ease;
}

.pass-barcode {
  position: relative;
  z-index: 1;
  margin-top: 18px;
  padding: 12px 12px 10px;
  border: 1px solid rgba(255, 249, 239, 0.16);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.94);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 12px 28px rgba(16, 18, 20, 0.14);
}

.pass-barcode-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.pass-barcode-title .text-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.panel,
.stats-grid article,
.timeline-item,
.result-card,
.scanner-panel {
  border: 1px solid rgba(229, 219, 206, 0.92);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.84);
  box-shadow: 0 14px 36px rgba(42, 31, 18, 0.08);
  backdrop-filter: blur(18px);
}

.panel {
  margin-top: 16px;
  padding: 16px;
}

.text-button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  background: rgba(10, 124, 104, 0.12);
  color: var(--jade);
  font-size: 0.9rem;
  font-weight: 900;
}

.barcode-frame {
  margin-top: 14px;
  padding: 16px 14px 12px;
  border-radius: 8px;
  background: #fff;
  text-align: center;
}

.barcode-frame svg,
.pass-barcode svg {
  display: block;
  width: 100%;
  height: 92px;
}

.barcode-frame p,
.pass-barcode p {
  margin: 8px 0 0;
  color: var(--muted);
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 0.92rem;
  letter-spacing: 0.08em;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.action-button {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 86px;
  padding: 12px 8px;
  border-radius: 8px;
  background: #fffaf2;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 900;
  box-shadow: 0 10px 26px rgba(42, 31, 18, 0.08);
}

.action-button span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 1.18rem;
}

.reward-list,
.customer-list,
.campaign-list,
.timeline {
  display: grid;
  gap: 10px;
}

.reward-list,
.campaign-list {
  margin-top: 14px;
}

.reward {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.reward-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #f1e6d7;
  color: var(--ink);
  font-weight: 900;
}

.reward strong,
.customer-card strong,
.campaign strong,
.result-card strong,
.timeline-item strong {
  display: block;
  margin-bottom: 2px;
}

.reward span,
.customer-card small,
.campaign span,
.result-card span,
.timeline-item span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.reward.unlocked .reward-icon {
  background: rgba(10, 124, 104, 0.12);
  color: var(--jade);
}

.scanner-panel {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  height: 310px;
  background: var(--night);
}

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

.scan-overlay {
  position: absolute;
  inset: 68px 34px;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(23, 18, 13, 0.24);
}

.scanner-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 6px;
  padding: 20px;
  color: #fffaf2;
  text-align: center;
}

.scanner-empty span {
  color: rgba(255, 250, 242, 0.76);
  font-size: 0.9rem;
  font-weight: 750;
}

.scanner-actions {
  grid-template-columns: 1.4fr 0.8fr;
  margin-top: 12px;
}

.customer-result {
  margin-top: 14px;
}

.result-card {
  padding: 16px;
}

.result-card.warning {
  border-color: rgba(232, 93, 84, 0.45);
  background: #fff5f2;
}

.result-head {
  align-items: flex-start;
}

.result-head strong {
  font-size: 1.2rem;
}

.result-head b {
  color: var(--jade);
}

.result-actions {
  grid-template-columns: 1fr 1fr;
  margin-top: 14px;
}

.search-field {
  margin-bottom: 12px;
}

.customer-card {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.86);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 10px 26px rgba(42, 31, 18, 0.06);
}

.customer-card.selected {
  border-color: rgba(10, 124, 104, 0.4);
  background: rgba(10, 124, 104, 0.1);
}

.customer-card b {
  color: var(--jade);
  white-space: nowrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.stats-grid.wide article {
  min-height: 96px;
}

.stats-grid article {
  padding: 16px;
}

.stats-grid span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.stats-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1.85rem;
}

.campaign {
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.campaign b {
  color: var(--blue);
  font-size: 0.82rem;
  text-align: right;
}

.qr-card {
  display: grid;
  gap: 12px;
  justify-items: center;
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: #fff;
}

.qr-card img {
  display: block;
  width: min(100%, 236px);
  height: auto;
  image-rendering: pixelated;
}

.qr-card p {
  max-width: 100%;
  margin: 0;
  color: var(--muted);
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 0.78rem;
  overflow-wrap: anywhere;
  text-align: center;
}

.timeline {
  margin-top: 4px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px;
}

.timeline-item b {
  color: var(--jade);
}

.tabbar {
  position: fixed;
  right: max(12px, calc((100vw - 430px) / 2 + 12px));
  bottom: max(12px, env(safe-area-inset-bottom));
  left: max(12px, calc((100vw - 430px) / 2 + 12px));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-width: 406px;
  margin: 0 auto;
  padding: 8px;
  border: 1px solid rgba(229, 219, 206, 0.9);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.9);
  box-shadow: 0 16px 44px rgba(42, 31, 18, 0.16);
  backdrop-filter: blur(18px);
}

body:not(.is-staff) .tabbar {
  grid-template-columns: repeat(2, 1fr);
}

body:not(.is-staff) .staff-action {
  display: none;
}

body:not(.is-staff) .quick-actions {
  grid-template-columns: 1fr;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.tab {
  min-width: 0;
  min-height: 54px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.tab[hidden] {
  display: none;
}

.tab span {
  display: block;
  font-size: 1.04rem;
  line-height: 1;
}

.tab small {
  display: block;
  margin-top: 5px;
  font-size: 0.64rem;
}

.tab.active {
  background: var(--ink);
  color: #fffaf2;
}

.sheet {
  width: min(100% - 28px, 390px);
  margin: auto auto max(10px, env(safe-area-inset-bottom));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #fffaf2;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.sheet::backdrop {
  background: rgba(23, 18, 13, 0.42);
  backdrop-filter: blur(8px);
}

.sheet form {
  padding: 12px 16px 16px;
}

.sheet-handle {
  width: 44px;
  height: 5px;
  margin: 0 auto 14px;
  border-radius: 8px;
  background: #d8cabb;
}

.sheet h2 {
  margin-bottom: 16px;
  font-size: 1.35rem;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  resize: vertical;
  outline: 0;
}

select {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mode-button {
  min-height: 38px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.mode-button.active {
  background: var(--ink);
  color: #fff9ef;
}

.purchase-mode {
  display: none;
  gap: 10px;
}

.purchase-mode.active {
  display: grid;
}

.ticket-items {
  display: grid;
  gap: 8px;
}

.ticket-item-row {
  display: grid;
  grid-template-columns: 1.2fr 0.5fr 0.7fr 1fr;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ticket-item-row input,
.ticket-item-row select {
  min-height: 38px;
  font-size: 0.84rem;
}

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

.admin-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-row span,
.points-preview {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.merchant-points-list {
  display: grid;
  gap: 8px;
}

.merchant-points-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.merchant-points-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.merchant-points-row b {
  color: var(--jade);
  white-space: nowrap;
}

.admin-sublist {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.mini-admin {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f5ef;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
}

.mini-admin.is-disabled {
  opacity: 0.55;
  text-decoration: line-through;
}

.check-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 22px;
  min-height: 22px;
}

input:focus {
  border-color: var(--jade);
  box-shadow: 0 0 0 4px rgba(10, 124, 104, 0.12);
}

.hint {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.install-steps {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
  padding-left: 22px;
  color: var(--ink);
  font-weight: 850;
}

menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  border-radius: 8px;
  font-weight: 900;
}

.primary-button {
  background: var(--jade);
  color: #fff;
}

.secondary-button {
  background: #efe5d8;
  color: var(--ink);
}

.full {
  width: 100%;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  left: 18px;
  z-index: 10;
  max-width: 390px;
  margin: 0 auto;
  padding: 13px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fffaf2;
  font-weight: 850;
  text-align: center;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 370px) {
  .app-shell {
    padding-inline: 12px;
  }

  .quick-actions,
  .result-actions,
  .login-shortcuts {
    gap: 8px;
  }

  .action-button,
  .tab small {
    font-size: 0.72rem;
  }

  .stats-grid strong {
    font-size: 1.55rem;
  }

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

  .ticket-item-row select {
    grid-column: 1 / -1;
  }
}
