:root {
  --navy: #143358;
  --navy-deep: #0d2645;
  --cream: #F5EFE0;
  --cream-dim: rgba(245,239,224,0.58);
  --cream-faint: rgba(245,239,224,0.07);
  --cream-border: rgba(245,239,224,0.12);
  --coral: #F26B5E;
  --coral-glow: rgba(242,107,94,0.20);
  --teal: #5DA8A3;
  --green: #5DA87F;
  --red: #e05c4a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--navy-deep);
  color: var(--cream);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  min-height: 100vh;
}

body { display: flex; flex-direction: column; }

.hidden { display: none !important; }

/* ─── Header ─── */
header {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--cream-border);
  background: rgba(13,38,69,0.95);
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand .logo { width: 34px; height: 34px; border-radius: 50%; overflow: hidden; flex-shrink: 0; }
.brand .logo svg { display: block; width: 100%; height: 100%; }
.brand .name { font-size: 14px; font-weight: 700; color: var(--cream); letter-spacing: -0.01em; line-height: 1.1; }
.brand .sub { font-size: 9px; color: var(--cream-dim); letter-spacing: 0.14em; text-transform: uppercase; margin-top: 3px; font-weight: 600; }

/* ─── Layout ─── */
main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }

/* ─── Tela 1 — input ─── */
.hero { max-width: 480px; width: 100%; text-align: center; }

.kicker {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--teal);
  font-size: 10.5px; letter-spacing: 0.16em;
  text-transform: uppercase; font-weight: 700;
  margin-bottom: 16px;
  background: rgba(93,168,163,0.10);
  border: 1px solid rgba(93,168,163,0.25);
  padding: 6px 12px; border-radius: 999px;
}
.kicker svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

h1 {
  font-size: 34px; font-weight: 800;
  line-height: 1.05; letter-spacing: -0.03em;
  color: var(--cream); margin-bottom: 10px;
}

.lead {
  font-size: 14px; color: var(--cream-dim);
  max-width: 380px; margin: 0 auto 24px;
  line-height: 1.6;
}

.card {
  background: var(--cream-faint);
  border: 1px solid var(--cream-border);
  padding: 24px;
  border-radius: 18px;
  margin-bottom: 16px;
  text-align: left;
}

.label {
  font-size: 10.5px; color: var(--cream-dim);
  letter-spacing: 0.12em; text-transform: uppercase;
  font-weight: 700; margin-bottom: 10px;
}

.code-input {
  width: 100%; padding: 18px 14px;
  font-size: 40px; font-weight: 900;
  letter-spacing: 0.14em; text-align: center;
  border: 1.5px solid var(--cream-border);
  border-radius: 12px;
  background: rgba(245,239,224,0.05);
  color: var(--cream); outline: none;
  text-transform: uppercase;
  font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  transition: border-color .2s, background .2s;
}
.code-input:focus {
  border-color: rgba(242,107,94,0.55);
  background: rgba(245,239,224,0.08);
}
.code-input::placeholder { color: rgba(245,239,224,0.22); letter-spacing: 0.12em; }
.code-input.error { border-color: var(--red); }

.submit {
  width: 100%; margin-top: 12px;
  background: rgba(245,239,224,0.10);
  color: var(--cream);
  border: 1px solid var(--cream-border);
  border-radius: 10px;
  padding: 13px; font-size: 13.5px;
  font-weight: 600; letter-spacing: 0.01em;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s, border-color .15s;
  font-family: inherit;
}
.submit:hover:not(:disabled) {
  background: rgba(245,239,224,0.14);
  border-color: rgba(245,239,224,0.22);
}
.submit:disabled { opacity: 0.4; cursor: not-allowed; }

.trust { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 14px; }
.trust .badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: var(--cream-faint);
  border: 1px solid var(--cream-border);
  border-radius: 999px;
  font-size: 11px; color: var(--cream-dim); font-weight: 600;
}
.trust .badge svg { width: 12px; height: 12px; stroke: var(--green); stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.error-msg {
  background: rgba(224,92,74,0.12);
  border: 1px solid rgba(224,92,74,0.30);
  color: #f08070;
  padding: 11px 14px; border-radius: 10px;
  font-size: 13px; margin-top: 10px;
  display: flex; align-items: center; gap: 8px;
  font-weight: 600;
}

/* ─── Footer ─── */
footer {
  padding: 16px 24px;
  border-top: 1px solid var(--cream-border);
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--cream-dim);
}
footer .links { display: flex; gap: 16px; flex-wrap: wrap; }
footer a { color: var(--cream-dim); text-decoration: none; transition: color .15s; }
footer a:hover { color: var(--cream); }

/* ─── Tela 2 — resultado ─── */
.result-wrap { max-width: 700px; width: 100%; margin: 0 auto; padding: 0 16px; }

.result-hdr {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 14px; flex-wrap: wrap; gap: 10px;
}
.result-meta { display: flex; align-items: center; gap: 10px; }
.result-meta .mini-logo { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; flex-shrink: 0; }
.result-meta .info .tag { font-size: 11px; color: var(--cream-dim); font-family: ui-monospace, monospace; font-weight: 600; }
.result-meta .info .title { font-size: 13px; color: var(--cream); font-weight: 700; margin-top: 1px; }

.expiry-badge {
  font-size: 10.5px; color: var(--coral);
  background: rgba(242,107,94,0.12);
  border: 1px solid rgba(242,107,94,0.25);
  padding: 4px 10px; border-radius: 999px;
  font-weight: 800; font-family: ui-monospace, monospace;
}

.copy-big {
  width: 100%; padding: 17px;
  font-size: 15px; margin-bottom: 14px;
  box-shadow: 0 6px 20px var(--coral-glow);
  background: var(--coral); color: #fff;
  border: none; border-radius: 12px;
  font-weight: 800; letter-spacing: 0.02em;
  cursor: pointer;
  display: flex; align-items: center; gap: 10px; justify-content: center;
  transition: opacity .15s;
  font-family: inherit;
}
.copy-big:hover { opacity: 0.90; }
.copy-big.done { background: var(--green); box-shadow: 0 6px 20px rgba(93,168,127,0.25); }
.copy-big.tampered { background: var(--red); cursor: not-allowed; }
.copy-big svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }

.leito-list { display: flex; flex-direction: column; gap: 10px; }

.leito-card {
  background: var(--cream-faint);
  border: 1px solid var(--cream-border);
  border-radius: 12px; overflow: hidden;
}
.leito-head {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(245,239,224,0.04);
  border-bottom: 1px solid var(--cream-border); gap: 10px;
}
.leito-head .lh-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.leito-head .lh-badge {
  font-size: 12px; font-weight: 800;
  background: rgba(245,239,224,0.10);
  border: 1px solid var(--cream-border);
  color: var(--cream);
  padding: 4px 10px; border-radius: 7px;
  letter-spacing: 0.04em; flex-shrink: 0;
}
.leito-head .lh-count { font-size: 11px; color: var(--cream-dim); font-family: ui-monospace, monospace; }

.leito-copy {
  background: var(--coral); color: #fff;
  border: none; border-radius: 8px;
  padding: 7px 13px; font-size: 11.5px;
  font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  font-family: inherit; transition: opacity .15s; flex-shrink: 0;
}
.leito-copy:hover { opacity: 0.88; }
.leito-copy.done { background: var(--green); }
.leito-copy.tampered { background: var(--red); cursor: not-allowed; }
.leito-copy svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.leito-body {
  padding: 12px 14px;
  font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px; color: var(--cream);
  line-height: 1.65; white-space: pre-wrap;
  word-wrap: break-word; user-select: all;
}

.note-preview {
  background: var(--cream-faint);
  border: 1px solid var(--cream-border);
  border-radius: 12px; padding: 16px;
  font-size: 13px; color: var(--cream);
  line-height: 1.65;
  font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap; word-wrap: break-word; user-select: all;
}

.hint { margin-top: 12px; font-size: 12px; color: var(--cream-dim); text-align: center; }
.hint b { color: var(--cream); }

.actions-row { display: flex; gap: 10px; margin-top: 18px; justify-content: center; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--cream-border);
  color: var(--cream-dim);
  border-radius: 10px; padding: 10px 20px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: border-color .15s, color .15s;
}
.btn-outline:hover { border-color: rgba(245,239,224,0.28); color: var(--cream); }

.btn-navy {
  background: var(--coral); color: #fff;
  border: none; border-radius: 10px;
  padding: 11px 22px; font-size: 13.5px;
  font-weight: 700; cursor: pointer; font-family: inherit;
}

/* ─── Tela 3 — erro ─── */
.err-icon {
  width: 72px; height: 72px;
  background: rgba(224,92,74,0.12);
  border: 1px solid rgba(224,92,74,0.25);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
}
.err-icon svg { width: 38px; height: 38px; stroke: var(--red); fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
#erro-title { font-size: 26px; }

/* Security warning */
.sec-warn {
  background: rgba(224,92,74,0.15);
  border: 1px solid rgba(224,92,74,0.35);
  color: #f08070;
  padding: 13px 18px; border-radius: 10px;
  font-size: 13px; font-weight: 700;
  text-align: center; margin-bottom: 14px; line-height: 1.5;
}

.loading-spinner {
  display: inline-block; width: 17px; height: 17px;
  border: 2.5px solid rgba(245,239,224,0.20);
  border-top-color: var(--cream);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) { h1 { font-size: 28px; } .code-input { font-size: 34px; } }
@media (max-width: 580px) {
  h1 { font-size: 24px; }
  .code-input { font-size: 30px; padding: 15px 12px; }
  footer { flex-direction: column; text-align: center; }
}
