:root {
  color-scheme: light;
  --bg: #eef5f4;
  --ink: #17202a;
  --muted: #667085;
  --line: #dde3ee;
  --brand: #0f766e;
  --brand-dark: #0b5f59;
  --brand-soft: #dff7f3;
  --neon-green: #39ff14;
  --surface: #ffffff;
  --danger: #b42318;
  --success: #067647;
  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: #f4f6f8;
  color: var(--ink);
}

button,
input,
a {
  font: inherit;
}

.app-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  background: linear-gradient(180deg, #332f31 0%, #3d3b3d 37%, #c6c7c8 72%, #f6f7f8 100%);
  position: relative;
  overflow-x: hidden;
  box-shadow: 0 0 60px rgba(16, 24, 40, .10);
}

body[data-screen]:not([data-screen="home"]) .app-shell {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfb 100%);
}

.screen {
  display: none;
  min-height: 100vh;
  padding: max(14px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
}

.screen.is-active {
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 8px 0 0;
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 12px;
}

.brand::before {
  display: none;
}

.store-name,
.result-header span {
  color: var(--brand);
  display: block;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.brand-logo {
  width: min(28vw, 100px);
  height: auto;
  display: block;
}

.brand .store-name {
  color: #f4f1ef;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(13px, 3.8vw, 18px);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
  text-align: right;
  max-width: 45vw;
}

h1,
h2,
p {
  margin: 0;
}

h2 {
  font-size: 24px;
  line-height: 1.1;
  margin-top: 4px;
}

p {
  color: var(--muted);
  line-height: 1.55;
  margin-top: 14px;
}

.brand p {
  grid-column: 1 / -1;
  color: #fff;
  font-size: clamp(13px, 3.6vw, 17px);
  line-height: 1.35;
  margin: 22px auto 0;
  max-width: 320px;
  text-align: center;
}

.hero-frame-stack {
  position: relative;
  display: grid;
  place-items: center;
  margin: 14px -18px 0;
  min-height: min(39vh, 310px);
}

.hero-frame-stack img {
  width: min(74vw, 320px);
  height: auto;
  display: block;
}

.upload-copy {
  text-align: center;
  margin-top: 26px;
}

.upload-copy h2 {
  color: #3b393b;
  font-size: clamp(17px, 4.9vw, 23px);
  font-weight: 900;
  letter-spacing: .01em;
}

.upload-copy p {
  color: #3f3d3f;
  font-size: clamp(11px, 3.2vw, 14px);
  line-height: 1.18;
  margin-top: 12px;
}

.upload-zone {
  margin: 26px auto 0;
  width: min(72%, 280px);
  min-height: 50px;
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0 28px;
  background: linear-gradient(180deg, #2f2d2f 0%, #14ace7 74%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 16px 30px rgba(14, 92, 130, .22);
  color: #fff;
}

.upload-zone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-zone strong {
  color: #fff;
  font-size: clamp(20px, 5.8vw, 28px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: .01em;
}

@media (max-height: 720px) {
  .screen {
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .brand {
    padding-top: 4px;
  }

  .brand-logo {
    width: min(25vw, 88px);
  }

  .brand .store-name {
    font-size: clamp(12px, 3.5vw, 16px);
  }

  .brand p {
    font-size: clamp(12px, 3.3vw, 15px);
    margin-top: 16px;
    max-width: 300px;
  }

  .hero-frame-stack {
    margin-top: 10px;
    min-height: min(37vh, 250px);
  }

  .hero-frame-stack img {
    width: min(66vw, 275px);
  }

  .upload-copy h2 {
    font-size: clamp(16px, 4.5vw, 20px);
  }

  .upload-copy p {
    font-size: clamp(10px, 3vw, 13px);
    margin-top: 8px;
  }

  .upload-copy {
    margin-top: 18px;
  }

  .upload-zone {
    margin-top: 18px;
    min-height: 46px;
  }

  .upload-zone strong {
    font-size: clamp(18px, 5.2vw, 24px);
  }
}

#previewCanvas {
  display: none;
}

.review-photo {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #eef2f7;
  box-shadow: 0 16px 34px rgba(16, 24, 40, .10);
}

.review-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  margin-top: 12px;
  text-align: center;
}

.primary-action {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  text-decoration: none;
  font-weight: 800;
  margin-top: 18px;
  box-shadow: 0 12px 24px rgba(15, 118, 110, .22);
}

.primary-action:disabled {
  background: #a9b8c6;
}

.primary-action:not(:disabled):active {
  background: var(--brand-dark);
}

.secondary-action {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(15, 118, 110, .22);
  border-radius: 8px;
  background: #fff;
  color: var(--brand);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.text-action {
  align-self: center;
  border: 0;
  color: var(--brand);
  background: transparent;
  margin-top: 16px;
  font-weight: 700;
}

.admin-intro {
  margin: -4px 0 18px;
}

#screenLoading {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.face-scan {
  width: min(78vw, 300px);
  aspect-ratio: 4 / 5;
  border-radius: 8px;
  background: #eef2f7;
  overflow: hidden;
  position: relative;
  margin-bottom: 24px;
  box-shadow: 0 18px 46px rgba(15, 118, 110, .16);
}

.face-scan img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.face-outline {
  position: absolute;
  inset: 9% 14%;
  filter:
    drop-shadow(0 0 8px rgba(57, 255, 20, .95))
    drop-shadow(0 0 18px rgba(57, 255, 20, .65));
}

.face-outline path {
  fill: rgba(57, 255, 20, .08);
  stroke: var(--neon-green);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 80 34;
  animation: traceFace 1.6s linear infinite;
}

.scan-sweep {
  position: absolute;
  left: 11%;
  right: 11%;
  top: 12%;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(57, 255, 20, .98), transparent);
  box-shadow:
    0 0 16px rgba(57, 255, 20, .95),
    0 0 34px rgba(57, 255, 20, .62);
  animation: scanSweep 2.2s ease-in-out infinite;
}

@keyframes traceFace {
  to {
    stroke-dashoffset: -228;
  }
}

@keyframes scanSweep {
  0%,
  100% {
    transform: translateY(0);
    opacity: .35;
  }

  50% {
    transform: translateY(210px);
    opacity: 1;
  }
}

.result-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.back-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 32px;
  line-height: 1;
  display: grid;
  place-items: center;
  text-decoration: none;
}

.result-image {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #eef2f7;
  display: block;
}

.result-summary {
  border: 1px solid rgba(15, 118, 110, .16);
  border-radius: 8px;
  background: #f0fdfa;
  color: #134e4a;
  line-height: 1.45;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-weight: 700;
}

.share-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 10px;
  margin-top: 14px;
  box-shadow: 0 12px 28px rgba(16, 24, 40, .06);
}

.share-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.share-card a {
  color: var(--brand);
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.admin-form {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(16, 24, 40, .08);
}

.admin-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}

.admin-form input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 0 14px;
  background: #fff;
}

.admin-form input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, .12);
  outline: none;
}

.created-link,
.usage-summary,
.tenant-list {
  margin-top: 18px;
}

.created-link {
  border: 1px solid #abefc6;
  border-radius: 8px;
  background: #ecfdf3;
  padding: 14px;
  display: grid;
  gap: 8px;
  box-shadow: 0 12px 24px rgba(6, 118, 71, .10);
}

.created-link span,
.tenant-list h3 {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.created-link a,
.usage-row a {
  color: var(--brand);
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.usage-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.usage-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 6px;
  box-shadow: 0 10px 22px rgba(16, 24, 40, .06);
}

.usage-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.usage-summary strong {
  font-size: 24px;
  line-height: 1;
}

.usage-summary small {
  grid-column: 1 / -1;
  color: var(--muted);
  line-height: 1.4;
}

.tenant-list {
  display: grid;
  gap: 10px;
}

.tenant-list h3 {
  margin: 6px 0 2px;
}

.tenant-list p {
  margin-top: 0;
}

.usage-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 12px 28px rgba(16, 24, 40, .06);
}

.usage-row {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) 76px 108px;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.usage-row:first-child {
  border-top: 0;
}

.usage-head {
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.usage-row span:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.usage-row strong {
  font-size: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(calc(100% - 32px), 440px);
  transform: translate(-50%, 130%);
  transition: transform .25s ease;
  padding: 13px 14px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  line-height: 1.35;
  z-index: 10;
}

.toast.is-visible {
  transform: translate(-50%, 0);
}
