:root {
  --green: #0b6b3a;
  --green-2: #0f8a4b;
  --green-soft: #eaf7ef;
  --black: #0b0f0d;
  --ink: #17201b;
  --muted: #67736c;
  --line: #dfe7e2;
  --white: #ffffff;
  --danger: #b42318;
  --shadow: 0 24px 70px rgba(8, 34, 21, 0.12);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 5%, rgba(15, 138, 75, .12), transparent 31rem),
    linear-gradient(180deg, #f8fbf9 0%, #ffffff 35%, #f5f9f6 100%);
  color: var(--ink);
  min-height: 100vh;
}

button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }

.topbar {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.02em;
}
.brand b { color: var(--green); }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  padding: 7px;
  border-radius: 11px;
  background: var(--black);
}
.brand-mark span { border: 3px solid var(--white); border-radius: 2px; }
.brand-mark span:last-child { background: var(--green-2); border-color: var(--green-2); }

.ghost-btn, .text-btn, .icon-btn, .secondary-btn, .primary-btn {
  border: 0;
  border-radius: 12px;
  transition: .2s ease;
}
.ghost-btn {
  background: rgba(255,255,255,.7);
  color: var(--black);
  padding: 11px 15px;
  border: 1px solid var(--line);
}
.ghost-btn:hover, .secondary-btn:hover { border-color: #b9c9bf; background: #fff; }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.hero {
  min-height: 610px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 500px);
  gap: 70px;
  align-items: center;
  padding: 55px 0 75px;
}
.hero-copy { max-width: 620px; }
.eyebrow {
  display: inline-block;
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 22px;
  color: var(--black);
  font-size: clamp(46px, 6vw, 76px);
  line-height: .98;
  letter-spacing: -.055em;
}
.hero-copy p {
  max-width: 580px;
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.75;
  color: var(--muted);
}

.generator-card, .result-card, .modal-card {
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(204,218,209,.9);
  box-shadow: var(--shadow);
}
.generator-card { padding: 30px; border-radius: var(--radius-lg); }
.card-header, .section-heading, .modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}
.card-header { margin-bottom: 28px; }
.card-kicker { margin-bottom: 5px; color: var(--green); font-size: 11px; font-weight: 900; letter-spacing: .13em; }
.card-header h2, .section-heading h2, .modal-header h2 { margin: 0; font-size: 27px; letter-spacing: -.03em; }
.status-pill, .success-badge {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid #cfe8d7;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  padding: 8px 11px;
}
label { display: block; margin-bottom: 9px; font-size: 14px; font-weight: 780; }
.input-wrap { position: relative; }
.input-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--green);
  font-weight: 900;
}
input {
  width: 100%;
  height: 58px;
  border: 1px solid #cad7cf;
  border-radius: 13px;
  background: #fff;
  color: var(--black);
  padding: 0 16px 0 44px;
  outline: none;
}
input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(11,107,58,.10); }
.field-hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.form-error { min-height: 19px; margin: 9px 0 0; color: var(--danger); font-size: 13px; }
.primary-btn {
  width: 100%;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
  padding: 0 18px;
}
.primary-btn:hover { background: #08572f; transform: translateY(-1px); }

.result-section, .history-section { padding: 65px 0 85px; border-top: 1px solid rgba(210,222,214,.85); }
.section-heading { margin-bottom: 28px; }
.section-heading h2 { font-size: 34px; }
.section-subtitle { margin: 7px 0 0; color: var(--muted); }
.text-btn { background: transparent; color: var(--green); padding: 8px 0; font-weight: 800; }
.text-btn:hover { color: #064a28; }
.danger-text { color: var(--danger); }

.result-card {
  display: grid;
  grid-template-columns: minmax(300px, .85fr) minmax(0, 1.15fr);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.qr-preview-panel {
  min-height: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 45px;
  background: var(--black);
}
.qr-frame {
  width: min(310px, 100%);
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  background: #fff;
  padding: 22px;
  border-radius: 22px;
}
#qrcode, #qrcode img, #qrcode canvas { width: 100% !important; height: 100% !important; display: block; }
.qr-size-label { color: #aeb8b2; font-size: 12px; }
.result-details { padding: 48px; display: flex; flex-direction: column; justify-content: center; }
.result-details h3 { margin: 18px 0 6px; font-size: 29px; letter-spacing: -.03em; }
#resultLink { color: var(--green); text-decoration: none; overflow-wrap: anywhere; }
.action-grid { margin-top: 30px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.secondary-btn {
  min-height: 52px;
  background: #fff;
  color: var(--black);
  border: 1px solid var(--line);
  font-weight: 780;
  padding: 0 16px;
}
.action-grid .primary-btn { min-height: 52px; }
.camera-note {
  margin-top: 26px;
  padding: 17px;
  display: flex;
  gap: 13px;
  background: var(--green-soft);
  border: 1px solid #cee6d5;
  border-radius: 14px;
}
.camera-note p { margin: 4px 0 0; color: #466052; font-size: 13px; line-height: 1.55; }
.camera-icon { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 10px; background: var(--green); color: #fff; font-weight: 900; }

.history-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.history-card {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 16px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.86);
}
.history-qr { width: 92px; height: 92px; background: white; border-radius: 12px; border: 1px solid var(--line); overflow: hidden; }
.history-qr img { width: 100%; height: 100%; object-fit: contain; display: block; }
.history-info { min-width: 0; }
.history-info strong { display: block; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-url { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-date { display: block; margin-top: 5px; color: #9aa49e; font-size: 11px; }
.history-actions { margin-top: 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.history-actions button { border: 0; background: transparent; color: var(--green); font-weight: 800; padding: 0; font-size: 12px; }
.empty-state { padding: 60px 20px; text-align: center; border: 1px dashed #cddbd2; border-radius: 20px; background: rgba(255,255,255,.55); }
.empty-icon { font-size: 30px; color: var(--green); }
.empty-state h3 { margin: 12px 0 7px; }
.empty-state p { margin: 0; color: var(--muted); }

footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 40px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}
footer p { margin: 0; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3,10,6,.72); backdrop-filter: blur(8px); }
.modal-card { position: relative; width: min(720px, 100%); border-radius: 24px; padding: 24px; }
.icon-btn { width: 40px; height: 40px; background: #f0f4f1; color: var(--black); font-size: 24px; }
.scanner-stage { position: relative; margin-top: 22px; min-height: 360px; overflow: hidden; border-radius: 18px; background: #080c0a; }
#scannerVideo { width: 100%; height: 100%; min-height: 360px; object-fit: cover; display: block; }
.scan-frame { position: absolute; width: 210px; height: 210px; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.scan-frame span { position: absolute; width: 42px; height: 42px; border-color: #4ee28d; border-style: solid; }
.scan-frame span:nth-child(1) { left: 0; top: 0; border-width: 4px 0 0 4px; border-radius: 12px 0 0 0; }
.scan-frame span:nth-child(2) { right: 0; top: 0; border-width: 4px 4px 0 0; border-radius: 0 12px 0 0; }
.scan-frame span:nth-child(3) { left: 0; bottom: 0; border-width: 0 0 4px 4px; border-radius: 0 0 0 12px; }
.scan-frame span:nth-child(4) { right: 0; bottom: 0; border-width: 0 4px 4px 0; border-radius: 0 0 12px 0; }
.scanner-status { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.scanner-result { margin-top: 15px; padding: 15px; border-radius: 14px; background: var(--green-soft); border: 1px solid #cee6d5; }
.scanner-result a { display: block; margin: 6px 0 12px; color: var(--green); overflow-wrap: anywhere; }
.scanner-result .primary-btn { width: auto; display: inline-flex; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  transform: translate(-50%, 30px);
  opacity: 0;
  pointer-events: none;
  background: var(--black);
  color: #fff;
  padding: 12px 17px;
  border-radius: 999px;
  box-shadow: 0 14px 40px rgba(0,0,0,.2);
  font-size: 13px;
  font-weight: 750;
  transition: .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 940px) {
  .hero { grid-template-columns: 1fr; gap: 38px; padding-top: 35px; }
  .hero-copy { max-width: 720px; }
  .result-card { grid-template-columns: 1fr; }
  .history-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .topbar, main, footer { width: min(100% - 24px, 1180px); }
  .topbar { min-height: 72px; }
  .brand { font-size: 18px; }
  .ghost-btn { padding: 9px 11px; font-size: 13px; }
  .hero { padding: 34px 0 55px; }
  h1 { font-size: 48px; }
  .hero-copy p { font-size: 16px; }
  .generator-card { padding: 22px; border-radius: 22px; }
  .card-header { flex-direction: column; }
  .result-section, .history-section { padding: 48px 0 60px; }
  .section-heading { align-items: flex-end; }
  .section-heading h2 { font-size: 28px; }
  .qr-preview-panel { min-height: 390px; padding: 30px; }
  .result-details { padding: 28px 22px; }
  .action-grid { grid-template-columns: 1fr; }
  .history-grid { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
  .modal-card { padding: 18px; }
  .scanner-stage, #scannerVideo { min-height: 300px; }
}

/* Estado visual do leitor após reconhecer um QR */
.scanner-green-tint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(7, 116, 62, .08), rgba(7, 116, 62, .18));
  mix-blend-mode: screen;
  transition: .25s ease;
}

.scanner-stage.detected .scanner-green-tint {
  background: rgba(8, 137, 73, .38);
  mix-blend-mode: normal;
}

.scan-frame.detected span {
  border-color: #79ffb2;
  filter: drop-shadow(0 0 10px rgba(91, 255, 160, .95));
}

.scanner-detected-popup {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 50%;
  width: min(430px, calc(100% - 34px));
  transform: translate(-50%, -50%);
  padding: 28px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(7, 112, 59, .97), rgba(5, 80, 43, .98));
  color: #fff;
  box-shadow: 0 24px 70px rgba(0,0,0,.34);
  text-align: center;
  animation: scannerPopupIn .24s ease both;
}

@keyframes scannerPopupIn {
  from { opacity: 0; transform: translate(-50%, -47%) scale(.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.detected-check {
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--green);
  background: #fff;
  font-size: 27px;
  font-weight: 950;
  box-shadow: 0 10px 30px rgba(0,0,0,.16);
}

.detected-kicker {
  display: block;
  margin-bottom: 7px;
  color: #b8ffd5;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .11em;
}

.scanner-detected-popup h3 {
  margin: 0 0 10px;
  font-size: 25px;
  letter-spacing: -.03em;
}

.detected-host {
  margin: 0 0 4px;
  font-weight: 850;
  font-size: 17px;
}

.detected-url {
  display: block;
  max-height: 46px;
  overflow: hidden;
  margin-bottom: 20px;
  color: rgba(255,255,255,.78);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.detected-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.scanner-open-site-btn,
.scanner-scan-again-btn {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  font-weight: 850;
  padding: 0 14px;
}

.scanner-open-site-btn {
  background: #fff;
  color: var(--green);
}

.scanner-open-site-btn:hover { background: #f0fff6; }
.scanner-open-site-btn:disabled { opacity: .55; cursor: not-allowed; }

.scanner-scan-again-btn {
  color: #fff;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25);
}

.scanner-scan-again-btn:hover { background: rgba(255,255,255,.2); }

@media (max-width: 620px) {
  .scanner-detected-popup { padding: 22px 18px; }
  .detected-actions { grid-template-columns: 1fr; }
}
