:root {
  --plum: #2d174f;
  --plum-deep: #1e1038;
  --violet: #8057db;
  --lilac: #f0ebff;
  --silver: #c9c6cf;
  --silver-pale: #eeeef2;
  --paper: #fff;
  --canvas: #f8f8fa;
  --ink: #25232a;
  --muted: #686572;
  --critical: #4a2028;
  --critical-surface: #fff1f3;
  --attention: #5d4510;
  --attention-surface: #fff8e7;
  --favorable: #243d39;
  --favorable-surface: #f1f7f5;
  --shadow: 0 12px 32px rgba(29,20,47,.08);
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

.app-shell {
  width: 100%;
  max-width: 1360px;
  margin: auto;
  padding: 24px clamp(16px, 3vw, 48px) 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 36px;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  color: var(--plum);
  font-family: ui-serif, Georgia, serif;
  font-size: 2.15rem;
  font-weight: 800;
  letter-spacing: -.12em;
  text-decoration: none;
}

.period-label {
  margin: 0;
  border: 1px solid var(--silver);
  border-radius: 99px;
  padding: 8px 13px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

.intro {
  max-width: 700px;
  margin-bottom: 32px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--violet);
  font-size: .7rem;
  font-weight: 850;
  letter-spacing: .13em;
}

.intro h1 {
  margin: 0 0 13px;
  color: var(--plum-deep);
  font-size: clamp(2rem, 3.8vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -.055em;
}

.intro > p:last-child,
.panel-heading p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

/* ==========================================================================
   GRILLA Y WORKSPACE RESPONSIVE
   ========================================================================== */

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  align-items: start;
}

@media (min-width: 920px) {
  .workspace {
    grid-template-columns: minmax(320px, 420px) 1fr;
  }
}

.data-panel,
.insight-card {
  border: 1px solid var(--silver-pale);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
  width: 100%;
}

.data-panel {
  padding: 24px;
}

.panel-heading {
  margin-bottom: 20px;
}

h2 {
  margin: 0 0 7px;
  color: var(--plum-deep);
  font-size: 1.2rem;
  letter-spacing: -.025em;
}

/* ==========================================================================
   FORMULARIO E INPUTS
   ========================================================================== */

form {
  display: grid;
  gap: 16px;
}

.field-group {
  display: grid;
  gap: 6px;
}

label {
  font-size: .9rem;
  font-weight: 800;
}

.field-help {
  margin: 0;
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.45;
}

.currency-input {
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--silver);
  border-radius: 10px;
  background: #fff;
  width: 100%;
}

.currency-input:focus-within {
  outline: 3px solid #dfd2ff;
  border-color: var(--violet);
}

.currency-input span {
  padding-left: 13px;
  color: var(--plum);
  font-weight: 800;
}

input {
  width: 100%;
  padding: 12px 13px 12px 7px;
  border: 0;
  outline: 0;
  color: var(--ink);
  font: inherit;
  font-weight: 650;
}

input::placeholder {
  color: #9995a0;
  font-size: .79rem;
  font-weight: 500;
}

.field-error {
  display: none;
  min-height: 1.2em;
  margin: 0;
  color: var(--critical);
  font-size: .76rem;
  overflow-wrap: anywhere;
}

.field-group.has-error .currency-input {
  border-color: var(--critical);
  background: #fff9fa;
}

.field-group.has-error .field-error {
  display: block;
}

#read-button {
  margin-top: 1rem;
  padding: .85rem 1.2rem;
  border: 0;
  border-radius: 10px;
  background: #392361;
  color: white;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

#read-button:focus-visible {
  outline: 3px solid #aa86d9;
  outline-offset: 3px;
}

#reading-status,
#validation-summary {
  padding: 1rem;
  border: 1px solid #cdb7e3;
  border-radius: 10px;
  background: #faf4ff;
}

#validation-summary a {
  color: #552c75;
}

/* ==========================================================================
   PANEL DE RESULTADOS Y TARJETAS COMPACTAS
   ========================================================================== */

.results {
  display: grid;
  gap: 24px;
  width: 100%;
}

.insight-card {
  padding: 24px;
}

.insight-header {
  display: flex;
  justify-content: space-between;
  gap: 15px;
}

.metric-card-compact {
  background: #ffffff;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink);
  width: 100%;
  word-break: break-word;
  overflow-wrap: break-word;
}

.metric-card-compact p {
  margin: 0;
}

[hidden] {
  display: none !important;
}

/* ==========================================================================
   MURO DE VALOR (GATING) & MODAL DE CAPTURA DE CORREO
   ========================================================================== */

.gating-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(30, 16, 56, 0.72);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn 0.3s ease;
}

.gating-card {
  background: var(--paper);
  border: 1px solid var(--silver-pale);
  border-radius: 18px;
  padding: 32px 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  text-align: left;
}

.gating-card h3 {
  color: var(--plum-deep);
  font-size: 1.35rem;
  margin: 0 0 10px;
  line-height: 1.25;
}

.gating-card p {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0 0 20px;
}

.gating-form {
  display: grid;
  gap: 12px;
}

.gating-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--silver);
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
  background: #fff;
  color: var(--ink);
}

.gating-input:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px #dfd2ff;
}

.gating-submit-btn {
  background: var(--plum);
  color: #fff;
  font-weight: 700;
  border: 0;
  border-radius: 10px;
  padding: 14px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s ease;
  margin-top: 6px;
  width: 100%;
}

.gating-submit-btn:hover {
  background: var(--plum-deep);
}

.voluntary-support-box {
  margin-top: 24px;
  padding: 16px;
  background: var(--silver-pale);
  border-radius: 12px;
  text-align: center;
  font-size: 0.88rem;
  color: var(--ink);
}

.voluntary-support-link {
  display: inline-block;
  margin-top: 6px;
  color: var(--plum-deep);
  font-weight: 700;
  text-decoration: underline;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   PROTECCIÓN DE IMPRESIÓN Y ATOPADO (@media print)
   ========================================================================== */

@media print {
  /* Ocultar contenido protegido si la vista está bloqueada */
  body.is-gated #results,
  body.is-gated #gated-content,
  body.is-gated #block-3,
  body.is-gated #block-4,
  body.is-gated #block-5 {
    display: none !important;
  }

  /* Ocultar interfaces secundarias en impresión cuando ya se desbloqueó */
  body:not(.is-gated) .data-panel,
  body:not(.is-gated) .topbar,
  body:not(.is-gated) #read-button,
  body:not(.is-gated) .checkout-btn,
  body:not(.is-gated) .voluntary-support-box,
  body:not(.is-gated) .gating-overlay {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
  }

  .app-shell {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .workspace {
    display: block !important;
  }

  .insight-card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    margin-bottom: 20px !important;
  }
}

/* Media query para móviles pequeños */
@media (max-width: 480px) {
  .app-shell {
    padding: 16px;
  }
  .data-panel,
  .insight-card {
    padding: 18px;
  }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}