:root {
  --navy: #162538;
  --teal: #6b9e9d;
  --teal-deep: #3f7776;
  --copper: #b27057;
  --green: #17a673;
  --green-deep: #0c7a53;
  --green-soft: #e9f8f2;
  --amber: #d8792b;
  --amber-deep: #a64d15;
  --amber-soft: #fff4e8;
}

* {
  box-sizing: border-box;
}

html {
  background: #f7f4ee;
}

body {
  margin: 0;
  color: var(--navy);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  font: inherit;
  color: inherit;
}

.page {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100svh;
  overflow: hidden;
  padding: 24px 20px;
  background:
    radial-gradient(circle at 14% 10%, rgba(107, 158, 157, 0.16), transparent 28%),
    radial-gradient(circle at 88% 86%, rgba(178, 112, 87, 0.13), transparent 29%),
    linear-gradient(145deg, #fbfaf7, #f3f1eb);
}

.page.has-result {
  justify-content: flex-start;
  padding-top: 36px;
  padding-bottom: 36px;
}

.page.suspected {
  background:
    radial-gradient(circle at 14% 10%, rgba(216, 121, 43, 0.13), transparent 28%),
    radial-gradient(circle at 88% 86%, rgba(178, 112, 87, 0.14), transparent 29%),
    linear-gradient(145deg, #fbfaf7, #f5f0e8);
}

.ambient {
  position: absolute;
  z-index: -1;
  border-radius: 999px;
  border: 1px solid rgba(107, 158, 157, 0.16);
}

.a1 {
  width: 360px;
  height: 360px;
  top: -190px;
  left: -160px;
}

.a2 {
  width: 520px;
  height: 520px;
  right: -310px;
  bottom: -330px;
  border-color: rgba(178, 112, 87, 0.18);
}

.card {
  position: relative;
  width: min(100%, 710px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(22, 37, 56, 0.08);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow:
    0 28px 80px rgba(26, 41, 58, 0.12),
    0 3px 12px rgba(26, 41, 58, 0.06);
}

.accent {
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--teal), var(--copper));
}

.suspected .accent {
  background: linear-gradient(90deg, var(--amber), var(--copper));
}

.header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 27px 32px 22px;
  border-bottom: 1px solid #edf0f2;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: min(220px, 58vw);
  height: auto;
  object-fit: contain;
  object-position: left center;
}

/* ---- Scan panel (always under result) ---- */

.scan {
  padding: 28px 32px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
}

.has-result .scan {
  margin: 0 20px 8px;
  padding: 14px 16px;
  border: 1px solid #e8ecef;
  border-radius: 20px;
  background: #fbfcfc;
}

.scan-btn.scan-again {
  max-width: 240px;
  min-height: 48px;
  background: #fff;
  color: var(--navy);
  border: 1px solid #dfe4e7;
  box-shadow: none;
}

.scan-copy {
  display: grid;
  gap: 0;
  justify-items: center;
}

.scan-copy[hidden],
.scan-btn[hidden] {
  display: none;
}

.scan-title {
  margin: 8px 0 9px;
  color: var(--navy);
  font-size: clamp(28px, 6vw, 40px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.has-result .scan-title {
  font-size: clamp(22px, 5vw, 28px);
}

.scan-btn {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 320px;
  min-height: 52px;
  padding: 14px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--navy);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(22, 37, 56, 0.18);
}

.scan-btn:active {
  transform: translateY(1px);
}

.file-btn {
  cursor: pointer;
}

/* ---- Live scanner overlay ---- */

.scanner {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: #0f1a26;
  color: #f7f4ee;
}

.scanner[hidden] {
  display: none;
}

.scanner-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #0a121b;
}

.scanner-stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.scanner-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#scannerDebug {
  position: absolute;
  left: 8px;
  top: 8px;
  margin: 0;
  padding: 6px 8px;
  font: 11px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #d8ff7a;
  background: rgba(10, 18, 27, 0.72);
  border-radius: 6px;
  white-space: pre;
  pointer-events: none;
  z-index: 3;
}

.scanner-reticle {
  position: absolute;
  left: 50%;
  top: 46%;
  width: min(68vw, 280px);
  height: min(68vw, 280px);
  transform: translate(-50%, -50%);
  border: 1.5px solid rgba(247, 244, 238, 0.35);
  border-radius: 18px;
  box-shadow: 0 0 0 9999px rgba(15, 26, 38, 0.28);
  pointer-events: none;
}

.scanner-reticle[hidden] {
  display: none;
}

.scanner-bar {
  flex-shrink: 0;
  padding: 16px 18px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(15, 26, 38, 0.92), #162538);
  border-top: 1px solid rgba(107, 158, 157, 0.22);
  text-align: center;
}

.scanner-status {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.scanner-hint {
  margin: 6px 0 0;
  color: rgba(247, 244, 238, 0.72);
  font-size: 13px;
  line-height: 1.4;
}

.scanner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
}

.scanner-close,
.scanner-capture {
  display: inline-grid;
  place-items: center;
  min-width: 108px;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.scanner-close {
  border: 1px solid rgba(247, 244, 238, 0.22);
  background: transparent;
  color: #f7f4ee;
}

.scanner-capture {
  border: 0;
  background: var(--teal);
  color: #0f1a26;
}

.verify-inline {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 120px;
  width: 100%;
}

.verify-inline[hidden] {
  display: none;
}

.dots-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.dots-loader .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: none;
  animation: bounce 1.05s ease-in-out infinite;
}

.dots-loader .dot:nth-child(2) {
  background: var(--copper);
  animation-delay: 0.15s;
}

.dots-loader .dot:nth-child(3) {
  background: var(--navy);
  animation-delay: 0.3s;
}

.dots-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  40% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ---- Status / result ---- */

.status {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 34px 32px 33px;
  text-align: center;
  background: linear-gradient(180deg, rgba(247, 250, 249, 0.55), transparent);
}

.status[hidden],
.certificate[hidden] {
  display: none;
}

.status-icon {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  width: 86px;
  height: 86px;
  margin-bottom: 20px;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  box-shadow: 0 13px 32px rgba(23, 166, 115, 0.25);
}

.suspected .status-icon {
  background: var(--amber);
  box-shadow: 0 13px 32px rgba(216, 121, 43, 0.25);
}

.status-icon:before,
.status-icon:after {
  content: "";
  position: absolute;
  border-radius: inherit;
  pointer-events: none;
}

.status-icon:before {
  inset: 0;
  border: 1px solid currentColor;
  animation: ring 2.6s ease-out infinite;
}

.status-icon:after {
  inset: 7px;
  border: 1px solid rgba(255, 255, 255, 0.23);
}

.status-icon svg {
  position: relative;
  z-index: 1;
  width: 54px;
  height: 54px;
  display: block;
  fill: none;
  stroke: #fff;
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
  grid-area: 1 / 1;
}

.status-icon .icon-check {
  display: block;
}

.status-icon .icon-cross {
  display: none;
}

.suspected .status-icon .icon-check {
  display: none;
}

.suspected .status-icon .icon-cross {
  display: block;
}

.original .status-icon .icon-check,
.suspected .status-icon .icon-cross {
  animation: icon-pop 0.45s ease-out both;
}

@keyframes icon-pop {
  from {
    transform: scale(0.72);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes ring {
  0% {
    transform: scale(0.9);
    opacity: 0.55;
  }
  65%,
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

.eyebrow,
.kicker {
  margin: 0;
  color: var(--teal-deep);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.suspected .eyebrow {
  color: var(--amber-deep);
}

.status h1 {
  margin: 8px 0 9px;
  color: var(--green-deep);
  font-size: clamp(36px, 7vw, 50px);
  font-weight: 800;
  letter-spacing: 0.055em;
  line-height: 1;
}

.suspected .status h1 {
  color: var(--amber-deep);
  font-size: clamp(30px, 6vw, 44px);
}

.message {
  max-width: 450px;
  margin: 0 auto;
  color: #657386;
  font-size: 14px;
  line-height: 1.65;
}

.pill {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 17px;
  padding: 8px 12px;
  border: 1px solid #ccebdd;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-deep);
  font-size: 11px;
  font-weight: 750;
}

.suspected .pill {
  border-color: #f2d4b7;
  background: var(--amber-soft);
  color: var(--amber-deep);
}

.pill i {
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-style: normal;
}

.suspected .pill i {
  background: var(--amber);
}

.certificate {
  margin: 0 20px 20px;
  padding: 25px 24px 20px;
  border: 1px solid #e8ecef;
  border-radius: 20px;
  background: #fbfcfc;
}

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

.section-head h2 {
  margin: 4px 0 0;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.record {
  flex: none;
  padding: 6px 9px;
  border-radius: 7px;
  background: #eaf7f2;
  color: var(--green-deep);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.suspected .record {
  background: #f1f3f4;
  color: #657386;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  border: 1px solid #e7eaec;
  border-radius: 14px;
  background: #e7eaec;
}

.detail {
  min-width: 0;
  padding: 18px;
  background: #fff;
}

.wide {
  grid-column: 1 / -1;
}

.label {
  display: block;
  margin-bottom: 8px;
  color: #788697;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.065em;
  line-height: 1.35;
  text-transform: uppercase;
}

.value-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.value {
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.copy {
  display: grid;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: #f2f5f5;
  cursor: pointer;
}

.copy svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--teal-deep);
  stroke-width: 1.7;
}

.copy .copied {
  color: var(--green-deep);
  font-size: 10px;
  font-weight: 750;
}

.warning {
  display: none;
  gap: 12px;
  margin-top: 15px;
  padding: 14px;
  border: 1px solid #f2d7bd;
  border-radius: 12px;
  background: var(--amber-soft);
  text-align: left;
}

.status-warning {
  width: min(100%, 450px);
  margin-top: 20px;
}

.suspected .warning {
  display: flex;
}

.warning svg {
  flex: none;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--amber-deep);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--amber-deep);
}

.warning strong {
  display: block;
  color: #863d12;
  font-size: 13px;
}

.warning p {
  margin: 5px 0 0;
  color: #91603c;
  font-size: 12px;
  line-height: 1.5;
}

.details-toggle {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding: 11px 2px 3px;
  border: 0;
  background: transparent;
  color: #657386;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.details-toggle[hidden],
.technical[hidden] {
  display: none;
}

.view-cert-btn {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 46px;
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid #d5dde3;
  border-radius: 12px;
  background: #fff;
  color: var(--navy);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.view-cert-btn:active {
  transform: translateY(1px);
}

.view-cert-btn[hidden] {
  display: none;
}

.chevron {
  transition: 0.25s;
}

.details-toggle[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.technical {
  display: grid;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: 0.3s;
}

.technical.open {
  max-height: 180px;
  padding-top: 12px;
  opacity: 1;
}

.technical div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px dashed #e3e7e9;
  font-size: 11px;
}

.technical span {
  color: #85909e;
}

.technical strong {
  text-align: right;
  color: #4d5c6d;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 32px 25px;
}

.footer p {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: #8792a0;
  font-size: 10px;
}

.footer-logo {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
}

@media (max-width: 560px) {
  .page {
    padding: 16px 10px;
  }

  .page.has-result {
    padding-top: 16px;
    padding-bottom: 16px;
  }

  .card {
    border-radius: 23px;
  }

  .header {
    padding: 23px 20px 18px;
  }

  .brand-logo {
    width: min(180px, 52vw);
  }

  .scan {
    padding: 24px 18px 6px;
  }

  .has-result .scan {
    margin: 0 10px 6px;
    padding: 18px 14px 16px;
  }

  .status {
    padding: 28px 18px 27px;
  }

  .status-icon {
    width: 76px;
    height: 76px;
  }

  .status-icon svg {
    width: 49px;
    height: 49px;
  }

  .message {
    font-size: 15px;
  }

  .certificate {
    margin: 0 10px 10px;
    padding: 20px 14px 17px;
  }

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

  .wide {
    grid-column: auto;
  }

  .detail {
    padding: 19px 17px;
  }

  .label {
    font-size: 12px;
  }

  .value {
    font-size: 17px;
    line-height: 1.45;
  }

  .copy {
    min-width: 44px;
    height: 44px;
  }

  .section-head {
    align-items: flex-end;
  }

  .footer {
    padding: 10px 20px 21px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
