:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f9;
  --navy: #0b182d;
  --navy-2: #12284a;
  --ink: #0f172a;
  --muted: #475569;
  --border: #d8e2ee;
  --primary: #0369a1;
  --primary-hover: #075985;
  --amber: #d97706;
  --amber-bg: #fef3c7;
  --emerald: #047857;
  --emerald-bg: #d1fae5;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(11, 24, 45, 0.06);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 18px; }

/* Top legal urgency bar */
.top-alert {
  background: var(--navy);
  color: #e2e8f0;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.top-alert-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
}
.top-alert strong { color: #fbbf24; }
.top-alert a { color: #7dd3fc; font-weight: 600; }

/* Header & Navigation */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 2px 10px rgba(11, 24, 45, 0.04);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--navy);
  text-decoration: none;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.brand small {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.xp-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--navy);
}
.xp-chip.pro {
  background: var(--emerald-bg);
  border-color: #6ee7b7;
  color: #065f46;
}

/* Primary app tabs */
.app-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.app-nav::-webkit-scrollbar { display: none; }
.app-nav-inner {
  display: flex;
  gap: 4px;
  padding: 8px 0;
  min-width: max-content;
}
.nav-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.nav-tab:hover { background: var(--surface-2); color: var(--navy); }
.nav-tab.active {
  background: var(--navy);
  color: #fff;
}
.nav-tab .tag-free {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--emerald-bg);
  color: #065f46;
}
.nav-tab.active .tag-free {
  background: rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 60%, #103a62 100%);
  color: #f8fafc;
  padding: 36px 0 32px;
  border-bottom: 3px solid #f59e0b;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 24px;
  align-items: center;
}
.hero h1 {
  margin: 10px 0 12px;
  font-size: clamp(26px, 3.6vw, 40px);
  line-height: 1.13;
  letter-spacing: -0.025em;
}
.hero p.lead {
  margin: 0 0 18px;
  color: #cbd5e1;
  font-size: 16px;
  max-width: 58ch;
}
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.boe-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(125, 211, 252, 0.35);
  color: #e0f2fe;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
}
.boe-badge.amber {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(251, 191, 36, 0.45);
  color: #fde68a;
}

.countdown-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}
.cd-box {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 12px;
}
.cd-days {
  font-size: 24px;
  font-weight: 800;
  color: #fbbf24;
  line-height: 1.1;
}
.cd-label { font-size: 12px; color: #e2e8f0; margin-top: 4px; font-weight: 600; }
.cd-date { font-size: 11px; color: #94a3b8; margin-top: 2px; }

/* Sprint card in hero */
.sprint-card {
  background: #ffffff;
  color: var(--ink);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255,255,255,0.15);
}
.sprint-card h2 { margin: 6px 0 6px; font-size: 21px; color: var(--navy); }
.sprint-card p { margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.sprint-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 12px;
  padding: 8px 11px;
  background: var(--surface-2);
  border-radius: 10px;
}

/* Main workspace */
main.app-main { padding: 26px 0 54px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.card h2 { margin: 6px 0 6px; font-size: 22px; color: var(--navy); line-height: 1.25; }
.card h3 { margin: 0 0 10px; font-size: 17px; color: var(--navy); }
.muted { color: var(--muted); font-size: 14px; margin: 0; }

/* Pills & Badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--navy);
}
.pill-emerald { background: var(--emerald-bg); color: #065f46; }
.pill-amber { background: var(--amber-bg); color: #92400e; }
.pill-blue { background: #e0f2fe; color: #075985; }
.pill-danger { background: var(--danger-bg); color: #991b1b; }

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 17px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: all 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-amber { background: #f59e0b; color: #0b182d; }
.btn-amber:hover { background: #d97706; color: #fff; }
.btn-secondary { background: var(--navy); color: #fff; }
.btn-secondary:hover { background: var(--navy-2); }
.btn-outline { background: #fff; color: var(--navy); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-2); border-color: #94a3b8; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--navy); background: var(--surface-2); }
.btn-whatsapp { background: #16a34a; color: #fff; }
.btn-whatsapp:hover { background: #15803d; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  padding: 0;
  margin-left: 8px;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* Segmented control */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.seg-btn {
  border: none;
  background: transparent;
  padding: 7px 13px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.seg-btn.active { background: #fff; color: var(--navy); box-shadow: 0 2px 6px rgba(0,0,0,0.08); }

/* Grids & Forms */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}
.form-grid .span-2 { grid-column: 1 / -1; }
.form-sec {
  margin: 18px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 14.5px;
  color: var(--navy);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}
input, select, textarea {
  font-family: inherit;
  font-size: 14.5px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(3, 105, 161, 0.25);
  border-color: var(--primary);
}
.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}
.check-inline {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  cursor: pointer;
}
.check-inline input { width: auto; }

/* Notices */
.notice {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  margin: 12px 0;
  border: 1px solid transparent;
}
.notice-info { background: #f0f9ff; border-color: #bae6fd; color: #0c4a6e; }
.notice-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.notice-ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.notice-danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* Result metrics */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.kpi-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 13px;
}
.kpi-label { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.kpi-val { font-size: 22px; font-weight: 800; color: var(--navy); margin-top: 4px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Quiz UI */
.track-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.track-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.track-card.selected { border: 2px solid var(--primary); background: #f0f9ff; }
.track-card strong { font-size: 15px; color: var(--navy); }
.track-card span { font-size: 12.5px; color: var(--muted); }

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.progress-bar {
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #0284c7, #0ea5e9);
  transition: width 0.25s ease;
}
.quiz-question {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 16px;
  line-height: 1.4;
}
.opt-list { display: grid; gap: 10px; }
.opt-btn {
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 14.5px;
  padding: 13px 15px;
  border-radius: 11px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: all 0.12s ease;
}
.opt-btn:hover:not(:disabled) { border-color: var(--primary); background: #f8fafc; }
.opt-letter {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--navy);
  font-weight: 800;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.opt-btn.correct { border-color: var(--emerald); background: #ecfdf5; }
.opt-btn.correct .opt-letter { background: var(--emerald); color: #fff; }
.opt-btn.wrong { border-color: var(--danger); background: #fef2f2; }
.opt-btn.wrong .opt-letter { background: var(--danger); color: #fff; }

.quiz-exp {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 11px;
  background: #f8fafc;
  border-left: 4px solid var(--primary);
  font-size: 14px;
}
.quiz-exp.ok { border-left-color: var(--emerald); background: #ecfdf5; }
.quiz-exp.bad { border-left-color: var(--danger); background: #fef2f2; }

/* Lessons & Flashcards */
.lesson-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  background: #fff;
  overflow: hidden;
}
.lesson-trigger {
  width: 100%;
  text-align: left;
  background: #fff;
  border: none;
  padding: 15px 18px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-family: inherit;
}
.lesson-trigger:hover { background: #f8fafc; }
.lesson-body {
  padding: 0 18px 18px;
  border-top: 1px solid var(--surface-2);
}
.lesson-body h4 { margin: 14px 0 6px; color: var(--navy); font-size: 15px; }
.lesson-body ul { margin: 0; padding-left: 20px; }
.lesson-body li { margin-bottom: 6px; font-size: 14px; color: #1e293b; }

.flashcard {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  min-height: 210px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease;
}
.flashcard:hover { border-color: var(--primary); }
.flashcard-q { font-size: 19px; font-weight: 800; color: var(--navy); }
.flashcard-a { font-size: 16px; color: #065f46; font-weight: 600; margin-top: 14px; padding-top: 14px; border-top: 1px dashed #a7f3d0; }

/* Pricing */
.pricing-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 15px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.pricing-card.featured {
  border-color: var(--primary);
  box-shadow: 0 14px 32px rgba(3, 105, 161, 0.12);
  position: relative;
}
.price-big { font-size: 34px; font-weight: 900; color: var(--navy); margin: 10px 0 4px; }
.price-strike { font-size: 16px; color: #94a3b8; text-decoration: line-through; margin-left: 6px; font-weight: 600; }
.price-list { list-style: none; padding: 0; margin: 14px 0 18px; }
.price-list li { padding: 5px 0; font-size: 13.5px; color: #334155; }
.price-list li::before { content: '✓ '; color: var(--emerald); font-weight: 800; }

/* Signature pad & BOE Anexo V preview */
.sig-wrap { margin-top: 16px; }
.sig-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13.5px; }
#a5-canvas {
  width: 100%;
  max-width: 520px;
  height: 130px;
  border: 1.5px dashed #94a3b8;
  border-radius: 10px;
  background: #fff;
  touch-action: none;
  display: block;
}

.boe-doc {
  background: #fff;
  color: #111827;
  border: 1px solid #cbd5e1;
  padding: 24px;
  border-radius: 8px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 12.5px;
  line-height: 1.45;
}
.boe-doc-header { text-align: center; border-bottom: 2px solid #0f172a; padding-bottom: 10px; margin-bottom: 14px; }
.boe-doc-tag { font-family: var(--font); font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; color: #334155; }
.boe-doc h2 { font-family: var(--font); font-size: 14.5px; margin: 6px 0 0; color: #0f172a; }
.boe-doc h3 { font-family: var(--font); font-size: 11.5px; margin: 12px 0 6px; background: #f1f5f9; padding: 4px 8px; border-left: 3px solid #0f172a; }
.boe-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.boe-table th, .boe-table td { border: 1px solid #94a3b8; padding: 5px 8px; text-align: left; font-size: 12px; }
.boe-table th { background: #f8fafc; font-family: var(--font); font-size: 11px; width: 22%; color: #334155; }
.boe-obs { border: 1px solid #94a3b8; padding: 8px; min-height: 36px; font-size: 12px; }
.boe-legal-p { text-align: justify; margin: 7px 0; font-size: 11.5px; }
.boe-place { margin: 12px 0; font-size: 12px; }
.boe-sig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
.boe-sig-box, .boe-sig-single { border: 1px solid #94a3b8; padding: 10px; text-align: center; font-size: 11.5px; }
.boe-sig-single { max-width: 360px; margin: 10px auto; }
.boe-sig-title { font-family: var(--font); font-weight: 700; font-size: 11px; margin-bottom: 4px; }
.boe-note { font-size: 10.5px; color: #475569; margin-top: 10px; font-style: italic; }
.boe-doc-foot { margin-top: 12px; padding-top: 6px; border-top: 1px solid #e2e8f0; font-family: var(--font); font-size: 10px; color: #64748b; text-align: center; }

/* Tables */
.data-table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td { border-bottom: 1px solid var(--border); padding: 10px 10px; text-align: left; }
.data-table th { background: var(--surface-2); color: var(--navy); font-weight: 700; font-size: 12px; text-transform: uppercase; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 24, 45, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 16px;
  max-width: 480px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
}
.modal h3 { margin: 0 0 8px; color: var(--navy); }

/* Footer */
.site-footer {
  background: var(--navy);
  color: #cbd5e1;
  padding: 34px 0;
  font-size: 13px;
}
.site-footer a { color: #93c5fd; }
.footer-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 24px; }
.footer-disclaimer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 12px;
  color: #94a3b8;
}

#print-root { display: none; }

/* Responsive */
@media (max-width: 880px) {
  .hero-grid, .grid-3, .grid-4, .kpi-grid, .footer-grid { grid-template-columns: 1fr; }
  .grid-2, .form-grid { grid-template-columns: 1fr; }
  .countdown-grid { grid-template-columns: 1fr; }
}

/* Official A4 Print for Anexo V */
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  .boe-doc { border: none; padding: 0; box-shadow: none; }
}
