/* Perfil público — "cartão de cidadão" fictício. Mobile-first. */
:root {
  --red-900: #3d0606;
  --red-800: #5a0b0b;
  --red-700: #7a0f0f;
  --red-600: #9b1616;
  --red-500: #b71c1c;
  --gold-300: #f3dc9a;
  --gold-400: #e4c46a;
  --gold-500: #c9a227;
  --gold-600: #a67f12;
  --ivory: #fbf6ea;
  --ivory-2: #f3ead4;
  --ink: #2a1a14;
  --ink-soft: #6b5446;
  --tier: #c9a227;
  --radius: 18px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --serif-zh: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; background: var(--red-900); min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--sans);
  color: var(--ink);
  background: radial-gradient(120% 60vh at 50% 0%, var(--red-600) 0%, var(--red-800) 60%, var(--red-900) 100%) no-repeat, var(--red-900);
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

/* Padrão decorativo "guilhochê" discreto */
.bg-pattern {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background:
    repeating-radial-gradient(circle at 50% 120%, transparent 0 22px, rgba(228,196,106,.05) 22px 23px),
    repeating-linear-gradient(45deg, transparent 0 14px, rgba(255,255,255,.018) 14px 15px);
}

/* ---------- Barra superior ---------- */
.gov-bar {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  color: var(--gold-300);
  background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,0));
  border-bottom: 1px solid rgba(228,196,106,.25);
}
.gov-bar__mark { width: 26px; height: 26px; fill: var(--gold-400); flex: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.gov-bar__text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.gov-bar__zh { font-family: var(--serif-zh); font-weight: 700; font-size: 15px; letter-spacing: .12em; }
.gov-bar__pt { font-size: 11px; opacity: .8; letter-spacing: .04em; text-transform: uppercase; }
.gov-bar__badge {
  margin-left: auto; flex: none;
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  padding: 4px 8px; border-radius: 999px;
  border: 1px solid rgba(228,196,106,.5); color: var(--gold-300);
}

/* ---------- Layout ---------- */
.wrap {
  position: relative; z-index: 1;
  width: 100%; max-width: 480px; margin: 0 auto;
  padding: 18px 16px 8px;
}

/* ---------- Cartão ---------- */
.card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,.6), rgba(255,255,255,0) 40%),
    repeating-linear-gradient(-45deg, var(--ivory) 0 6px, var(--ivory-2) 6px 7px);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px rgba(166,127,18,.6), 0 0 0 5px var(--red-800), 0 0 0 6px rgba(228,196,106,.55), 0 24px 60px rgba(0,0,0,.45);
  overflow: hidden;
  animation: rise .5s ease-out both;
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.card__head {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 14px 16px;
  color: var(--gold-300);
  background:
    linear-gradient(90deg, rgba(228,196,106,.12), transparent 30%, transparent 70%, rgba(228,196,106,.12)),
    linear-gradient(180deg, var(--red-600), var(--red-700));
  border-bottom: 2px solid var(--gold-500);
}
.seal { width: 48px; height: 48px; color: var(--gold-400); }
.card__title { display: flex; flex-direction: column; min-width: 0; }
.card__title-zh { font-family: var(--serif-zh); font-size: 22px; font-weight: 800; letter-spacing: .3em; line-height: 1.1; }
.card__title-pt { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; opacity: .85; }
.card__serial { text-align: right; font-size: 9.5px; letter-spacing: .08em; opacity: .9; display: flex; flex-direction: column; }
.card__serial strong { font-family: var(--mono); font-size: 11px; color: #fff; letter-spacing: .04em; }

.card__body {
  display: grid; grid-template-columns: 124px 1fr; gap: 14px 16px;
  padding: 18px 16px 8px;
}

.photo {
  position: relative; grid-row: span 1;
  width: 124px; aspect-ratio: 5 / 6;
  border-radius: 10px; overflow: hidden;
  background: #e9e1d3;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--gold-500), 0 6px 16px rgba(61,6,6,.25);
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo__corner { position: absolute; width: 16px; height: 16px; border: 2px solid var(--gold-500); }
.photo__corner--tl { top: 5px; left: 5px; border-right: 0; border-bottom: 0; }
.photo__corner--br { bottom: 5px; right: 5px; border-left: 0; border-top: 0; }
.photo__stamp {
  position: absolute; right: -6px; bottom: 10px;
  transform: rotate(-14deg);
  font-family: var(--serif-zh); font-weight: 800; font-size: 13px; letter-spacing: .15em;
  color: rgba(183,28,28,.85);
  padding: 3px 6px 3px 9px;
  border: 2px solid rgba(183,28,28,.8); border-radius: 6px;
  background: rgba(255,255,255,.35);
  mix-blend-mode: multiply;
}

.identity { align-self: center; min-width: 0; }
.identity__name { margin: 0; font-size: 24px; line-height: 1.15; font-weight: 800; letter-spacing: -.01em; word-break: break-word; }
.identity__zh { margin: 4px 0 0; font-family: var(--serif-zh); font-size: 26px; font-weight: 700; letter-spacing: .2em; color: var(--red-700); }
.identity__status { margin: 10px 0 0; display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-soft); }
.identity__status .dot { width: 8px; height: 8px; border-radius: 50%; background: #2e9e5b; box-shadow: 0 0 0 3px rgba(46,158,91,.18); }

.fields {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  margin: 0;
  border-top: 1px solid rgba(166,127,18,.35);
}
.field { padding: 9px 2px; border-bottom: 1px dashed rgba(166,127,18,.3); min-width: 0; }
.field:nth-child(odd):not(.field--wide) { padding-right: 10px; }
.field--wide { grid-column: 1 / -1; }
.field dt { font-family: var(--serif-zh); font-size: 11.5px; font-weight: 700; color: var(--red-700); letter-spacing: .08em; }
.field dt small { font-family: var(--sans); font-weight: 500; color: var(--ink-soft); letter-spacing: .02em; margin-left: 4px; text-transform: uppercase; font-size: 9.5px; }
.field dd { margin: 2px 0 0; font-size: 14.5px; font-weight: 600; overflow-wrap: anywhere; }
.mono { font-family: var(--mono); letter-spacing: .06em; }

/* ---------- Pontuação ---------- */
.score {
  position: relative;
  margin: 12px 12px 0;
  padding: 18px 16px 16px;
  border-radius: 14px;
  text-align: center;
  color: var(--gold-300);
  background:
    radial-gradient(90% 120% at 50% 0%, rgba(228,196,106,.18), transparent 60%),
    linear-gradient(180deg, var(--red-700), var(--red-900));
  box-shadow: inset 0 0 0 1px rgba(228,196,106,.45), inset 0 0 0 5px rgba(0,0,0,.12), 0 8px 18px rgba(61,6,6,.35);
  overflow: hidden;
}
.score::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-radial-gradient(circle at 50% 110%, transparent 0 16px, rgba(228,196,106,.06) 16px 17px);
}
.score__label { position: relative; display: flex; flex-direction: column; gap: 2px; }
.score__label span:first-child { font-family: var(--serif-zh); font-size: 15px; font-weight: 700; letter-spacing: .45em; padding-left: .45em; }
.score__label span:last-child { font-size: 11px; font-weight: 700; letter-spacing: .28em; opacity: .85; }
.score__value-wrap { position: relative; display: flex; justify-content: center; align-items: flex-start; }
.score__value {
  display: block;
  font-size: clamp(72px, 24vw, 104px);
  line-height: 1.02; font-weight: 900; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff6d6 0%, var(--gold-400) 45%, var(--gold-600) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,.25));
  margin: 4px 0 2px;
}
.score__delta {
  position: absolute; top: 6px; right: 6%;
  font-size: 22px; font-weight: 900; opacity: 0;
  transform: translateY(8px);
}
.score__delta.show { animation: delta 2.4s ease-out forwards; }
.score__delta.up { color: #7ee2a0; }
.score__delta.down { color: #ff9a8f; }
@keyframes delta {
  0% { opacity: 0; transform: translateY(10px) scale(.8); }
  15% { opacity: 1; transform: translateY(0) scale(1.15); }
  70% { opacity: 1; transform: translateY(-6px) scale(1); }
  100% { opacity: 0; transform: translateY(-16px); }
}
.score.flash-up { animation: flashUp 1.2s ease-out; }
.score.flash-down { animation: flashDown 1.2s ease-out; }
@keyframes flashUp { 0%, 100% { box-shadow: inset 0 0 0 1px rgba(228,196,106,.45), 0 8px 18px rgba(61,6,6,.35); } 30% { box-shadow: inset 0 0 0 2px #7ee2a0, 0 0 40px rgba(126,226,160,.55); } }
@keyframes flashDown { 0%, 100% { box-shadow: inset 0 0 0 1px rgba(228,196,106,.45), 0 8px 18px rgba(61,6,6,.35); } 30% { box-shadow: inset 0 0 0 2px #ff9a8f, 0 0 40px rgba(255,120,110,.55); } }

.score__stars { position: relative; font-size: 24px; letter-spacing: .18em; padding-left: .18em; }
.score__stars .on { color: var(--gold-400); text-shadow: 0 0 10px rgba(228,196,106,.6); }
.score__stars .off { color: rgba(228,196,106,.22); }

.score__chip {
  position: relative;
  display: inline-flex; gap: 8px; align-items: baseline;
  margin: 10px 0 14px;
  padding: 6px 16px; border-radius: 999px;
  background: var(--tier); color: #fff;
  font-weight: 800; letter-spacing: .08em; font-size: 14px; text-transform: uppercase;
  box-shadow: 0 0 0 2px rgba(255,255,255,.2), 0 4px 14px rgba(0,0,0,.3);
}
.score__chip span:first-child { font-family: var(--serif-zh); letter-spacing: .2em; }

.score__bar { position: relative; height: 12px; border-radius: 999px; background: rgba(0,0,0,.35); box-shadow: inset 0 0 0 1px rgba(228,196,106,.35); overflow: hidden; }
.score__bar-fill {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #c0392b 0%, #e07b24 45%, #c9a227 66%, #2e9e5b 88%);
  background-size: 480px 100%;
  transition: width .9s cubic-bezier(.2,.8,.2,1);
}
.score__bar-ticks { position: absolute; inset: 0; }
.score__bar-ticks i { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255,255,255,.35); }
.score__bar-ticks i:nth-child(1) { left: 53.33%; }
.score__bar-ticks i:nth-child(2) { left: 66.66%; }
.score__bar-ticks i:nth-child(3) { left: 80%; }
.score__bar-ticks i:nth-child(4) { display: none; }
.score__legend { position: relative; display: flex; justify-content: space-between; margin-top: 5px; font-size: 9.5px; opacity: .6; font-variant-numeric: tabular-nums; }
.score__legend span:nth-child(2) { position: absolute; left: 53.33%; transform: translateX(-50%); }
.score__legend span:nth-child(3) { position: absolute; left: 66.66%; transform: translateX(-50%); }
.score__legend span:nth-child(4) { position: absolute; left: 80%; transform: translateX(-50%); }

/* ---------- Rodapé do cartão ---------- */
.card__foot { padding: 14px 16px 16px; }
.barcode {
  height: 34px; border-radius: 3px;
  background:
    repeating-linear-gradient(90deg,
      var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 5px, transparent 5px 8px,
      var(--ink) 8px 11px, transparent 11px 12px, var(--ink) 12px 13px, transparent 13px 17px);
  opacity: .8;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.card__meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; font-size: 11px; color: var(--ink-soft); }
.conn { display: inline-flex; align-items: center; gap: 5px; }
.conn__dot { width: 7px; height: 7px; border-radius: 50%; background: #2e9e5b; }
.conn.offline .conn__dot { background: #c0392b; }
.conn.loading .conn__dot { background: var(--gold-500); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- Aviso / instalação / rodapé ---------- */
.notice { text-align: center; color: var(--gold-300); padding: 48px 12px; }
.notice h1 { font-family: var(--serif-zh); letter-spacing: .3em; font-size: 28px; margin: 0 0 8px; }
.notice p { color: #f6e7c8; opacity: .9; }
.btn-ghost { display: inline-block; margin-top: 12px; padding: 10px 18px; border-radius: 999px; color: var(--gold-300); border: 1px solid rgba(228,196,106,.6); text-decoration: none; }

.install { margin: 18px 0 4px; text-align: center; }
.btn-install {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 18px; border: 0; border-radius: 14px; cursor: pointer;
  font: inherit; font-weight: 800; font-size: 15px; letter-spacing: .02em;
  color: var(--red-900);
  background: linear-gradient(180deg, var(--gold-300), var(--gold-500));
  box-shadow: 0 6px 18px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.6);
}
.btn-install svg { width: 20px; height: 20px; }
.btn-install:active { transform: translateY(1px); }
.install__ios { color: #f6e7c8; font-size: 13.5px; line-height: 1.5; margin: 12px 4px 0; }
.install__ios svg { width: 16px; height: 16px; vertical-align: -3px; }

.footer {
  position: relative; z-index: 1;
  max-width: 480px; margin: 0 auto; padding: 18px 20px 28px;
  text-align: center; color: rgba(246,231,200,.72); font-size: 11.5px; line-height: 1.5;
}
.footer p { margin: 4px 0; }
.footer__main { color: var(--gold-300); font-weight: 700; letter-spacing: .12em; font-size: 12px; }
.footer__small { opacity: .7; font-size: 10.5px; }
.footer__contact { margin-bottom: 8px !important; }
.footer__contact a { color: var(--gold-300); }
.footer__legal { font-size: 10.5px; opacity: .55; letter-spacing: .04em; }

@media (max-width: 360px) {
  .card__body { grid-template-columns: 104px 1fr; }
  .photo { width: 104px; }
  .identity__name { font-size: 20px; }
  .card__serial { display: none; }
  .card__head { grid-template-columns: auto 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Página inicial ---------- */
.home { color: #f6e7c8; }
.home__hero { text-align: center; padding: 24px 4px 8px; }
.home__logo { border-radius: 24px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.home__hero h1 { font-family: var(--serif-zh); color: var(--gold-300); letter-spacing: .25em; font-size: 24px; margin: 18px 0 8px; }
.home__lead { line-height: 1.55; font-size: 15px; opacity: .92; }
.home .btn-install { text-decoration: none; margin: 14px 0 6px; }
.home__form { margin-top: 18px; background: rgba(0,0,0,.2); border: 1px solid rgba(228,196,106,.3); border-radius: 14px; padding: 14px; }
.home__form label { display: block; font-size: 13px; font-weight: 700; color: var(--gold-300); margin-bottom: 8px; }
.home__row { display: flex; gap: 8px; }
.home__row input { flex: 1; min-width: 0; padding: 12px; border-radius: 10px; border: 1px solid rgba(228,196,106,.5); background: rgba(255,255,255,.95); font: inherit; font-family: var(--mono); }
.home__row button { padding: 0 18px; border: 0; border-radius: 10px; font: inherit; font-weight: 800; color: var(--red-900); background: var(--gold-400); cursor: pointer; }
.home__admin { text-align: center; margin-top: 26px; font-size: 13px; }
.home__admin a { color: var(--gold-300); opacity: .8; }
