:root {
  --bg: #f7f5fb;
  --surface: #ffffff;
  --text: #1f1b2e;
  --text-muted: #5b5568;
  --primary: #7c3aed;
  --primary-dark: #5b21b6;
  --border: #e2def2;
  --danger: #b91c1c;
  --ok: #15803d;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14111f;
    --surface: #1e1a2e;
    --text: #efeaf9;
    --text-muted: #b3aac6;
    --border: #35304a;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

.site-header {
  text-align: center;
  padding: 2rem 1rem 1rem;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.brand-icon { width: 32px; height: 32px; }

.tagline {
  color: var(--text-muted);
  font-style: italic;
  margin: .5rem 0 0;
}

.ad-slot {
  max-width: 728px;
  margin: 0 auto;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

#ad-slot-top { margin: 1rem auto; }

.ad-placeholder {
  color: var(--text-muted);
  font-size: .85rem;
}

.ad-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  text-decoration: none;
}

.ad-image,
.ad-video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.ad-house-cta {
  color: var(--primary-dark);
  font-weight: 700;
  font-size: .95rem;
  text-align: center;
  padding: 0 1rem;
}
.ad-house-cta:hover { text-decoration: underline; }

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.notice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: .92rem;
}

.notice-legal {
  color: var(--text-muted);
  margin-bottom: 0;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.25rem;
  margin: 0;
}

legend {
  font-weight: 700;
  padding: 0 .5rem;
  color: var(--primary-dark);
}

.persons-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 720px) {
  .persons-grid { grid-template-columns: 1fr 1fr; }
}

label {
  display: block;
  font-size: .88rem;
  font-weight: 600;
  margin: .75rem 0 .25rem;
}

input[type="text"],
input[type="date"],
input[type="time"] {
  width: 100%;
  padding: .6rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.cedula-status {
  display: block;
  min-height: 1.2em;
  font-size: .8rem;
  margin-top: .25rem;
}
.cedula-status.ok { color: var(--ok); }
.cedula-status.bad { color: var(--danger); }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  font-weight: 400;
  font-size: .85rem;
  margin-top: 1rem;
}
.checkbox-row input { margin-top: .2rem; }

.signature-label { margin-top: 1rem; }

.signature-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.signature-pad {
  width: 100%;
  height: 160px;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.clear-sig {
  display: block;
  width: 100%;
  padding: .4rem;
  border: none;
  border-top: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: .8rem;
  cursor: pointer;
}
.clear-sig:hover { background: var(--border); }

.encounter-card { margin-bottom: 1.25rem; }

.encounter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
@media (min-width: 640px) {
  .encounter-grid { grid-template-columns: 1fr 1fr; gap: 0 1rem; }
}

.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.preview-collapse {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 1.25rem;
  margin-bottom: 1.25rem;
}

.preview-collapse summary {
  cursor: pointer;
  padding: 1rem 0;
  font-weight: 600;
  color: var(--primary-dark);
}

.document-preview {
  white-space: pre-wrap;
  font-size: .88rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding: 1rem 0 1.25rem;
}

.download-area {
  text-align: center;
  padding: 1rem 0 2rem;
}

.download-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: .9rem 2rem;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, opacity .15s ease;
}

.download-btn:hover:not(:disabled) { background: var(--primary-dark); }

.download-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.download-hint {
  color: var(--text-muted);
  font-size: .82rem;
  margin-top: .6rem;
}

#app-content.gated {
  filter: blur(4px);
  opacity: .5;
  user-select: none;
}

.ad-modal-title {
  font-weight: 700;
  margin: 0 0 .75rem;
}

.ad-modal[hidden] {
  display: none;
}

.ad-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.ad-modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 760px;
  width: 100%;
  text-align: center;
}

.ad-wait-hint {
  color: var(--text-muted);
  font-size: .85rem;
  margin: .75rem 0 0;
}

.ad-continue-btn {
  margin-top: 1rem;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: .8rem 1.75rem;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
.ad-continue-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.site-footer {
  text-align: center;
  padding: 1.5rem 1rem 3rem;
  color: var(--text-muted);
  font-size: .8rem;
}

.visit-counter {
  margin: 1rem auto 0;
  max-width: 245px;
  background: linear-gradient(135deg, #4e1d5a, #2c0e33);
  border: 1px solid #7c3a8e;
  border-radius: 11px;
  padding: 1rem 1.15rem;
  text-align: center;
  box-shadow: 0 7px 21px rgba(0, 0, 0, .4);
}

.visit-counter-icon {
  font-size: 2.2rem;
  margin-bottom: .35rem;
}

.visit-counter-number {
  font-size: 2.45rem;
  font-weight: 800;
  color: #f3e8ff;
  letter-spacing: .5px;
  line-height: 1.1;
  text-shadow: 0 2px 7px rgba(124, 58, 142, .6);
}

.visit-counter-text {
  font-size: .875rem;
  color: #d8b4fe;
  font-weight: 400;
  margin-top: .15rem;
}
