/* Página de reportes (reportes.html). El papel imita el PDF real: src/features/exports/pdf/report-view-html.ts. */
:root {
  --p-text: #123a2b;
  --p-muted: #5e7b6f;
  --p-deep: #14523a;
  --p-accent: #1c7b55;
  --p-line: #e4f1e8;
  --p-ok: #1d8b52;
  --p-bad: #b43a35;
  --p-warn: #a9780a;
}

/* ---------- Portada ---------- */
.r-hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  margin-top: 28px;
}

.r-link {
  font-weight: 700;
  text-decoration: none;
}

.r-link:hover {
  text-decoration: underline;
}

.r-minis {
  position: relative;
  display: block;
  height: 560px;
  perspective: 1600px;
}

.r-mini {
  position: absolute;
  width: 640px;
  transform-origin: top left;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.r-mini .sheet {
  box-shadow: var(--shadow-lg);
}

.r-mini .hs {
  display: none;
}

.r-mini-front {
  left: 40px;
  top: 30px;
  transform: scale(0.62) rotateY(-16deg) rotateX(5deg) rotateZ(1deg);
}

.r-mini-back {
  left: 170px;
  top: 0;
  transform: scale(0.56) rotateY(-16deg) rotateX(5deg) rotateZ(4deg);
  opacity: 0.9;
}

.r-minis:hover .r-mini-front,
.r-minis:focus-visible .r-mini-front {
  transform: scale(0.64) rotateY(0) rotateX(0) rotateZ(0);
}

.r-minis:hover .r-mini-back {
  transform: scale(0.56) translateX(60px) rotateZ(6deg);
}

/* ---------- Visor ---------- */
#visor:focus {
  outline: none;
}

.r-layout {
  display: grid;
  grid-template-columns: minmax(0, 680px) minmax(280px, 1fr);
  gap: 32px;
  align-items: start;
  justify-content: center;
}

.r-viewer {
  min-width: 0;
}

.r-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.r-seg {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.r-seg button {
  border: 0;
  background: none;
  font: inherit;
  font-weight: 700;
  color: var(--muted);
  padding: 8px 18px;
  min-height: 40px;
  border-radius: 999px;
  cursor: pointer;
}

.r-seg button[aria-pressed="true"] {
  background: var(--accent-strong);
  color: #fff;
}

.r-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--muted);
  cursor: pointer;
  min-height: 40px;
}

.r-switch input {
  position: absolute;
  opacity: 0;
}

.r-switch span {
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: #c9ddd1;
  position: relative;
  transition: background 0.2s;
}

.r-switch span::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}

.r-switch input:checked + span {
  background: var(--accent);
}

.r-switch input:checked + span::after {
  transform: translateX(16px);
}

.r-switch input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sheet .sm {
  display: none;
}

.r-nudge {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  translate: -50% 0;
  z-index: 70;
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  min-height: 48px;
  background: var(--accent-strong);
  color: #fff;
  font: inherit;
  font-weight: 800;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  white-space: nowrap;
  animation: tip-in 0.25s ease;
}

.r-nudge[hidden] {
  display: none;
}

.r-viewport {
  overflow: hidden;
  border-radius: 6px;
  touch-action: pan-y;
  transition: height 0.35s ease;
  padding: 0;
}

.r-track {
  display: flex;
  align-items: flex-start;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  user-select: none;
}

.r-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  font-weight: 700;
  color: var(--muted);
}

.r-arrow {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent-strong);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.r-arrow:disabled {
  opacity: 0.35;
  cursor: default;
}

.r-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.r-thumbs button {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 8px 12px;
  min-height: 44px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.r-thumbs button span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
  font-size: 0.75rem;
}

.r-thumbs button[aria-current] {
  border-color: var(--accent);
  color: var(--accent-strong);
  box-shadow: 0 0 0 1px var(--accent);
}

.r-thumbs button[aria-current] span {
  background: var(--accent-strong);
  color: #fff;
}

/* ---------- El papel ---------- */
.sheet {
  flex: 0 0 100%;
  min-width: 0;
  background: #fff;
  color: var(--p-text);
  aspect-ratio: 8.5 / 11;
  display: flex;
  flex-direction: column;
  padding: 40px 44px 22px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 1px 2px rgba(18, 58, 43, 0.06), 0 10px 30px rgba(18, 58, 43, 0.1);
  border-radius: 4px;
}

.r-viewport .sheet {
  box-shadow: none;
  border: 1px solid var(--border);
}

.sheet-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.p-foot {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--p-muted);
  border-top: 1px solid var(--p-line);
  padding-top: 8px;
}

.p-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.p-head > div {
  flex: 1;
}

.p-head img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.p-kicker {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--p-muted);
  text-transform: uppercase;
}

.p-head h3 {
  font-size: 26px;
  margin: 2px 0 0;
  color: var(--p-text);
}

.sheet h4 {
  font-size: 11.5px;
  margin: 0 0 10px;
  color: var(--p-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding-right: 30px;
}

.p-hero {
  position: relative;
  background: var(--p-deep);
  color: #fff;
  border-radius: 16px;
  padding: 18px 20px;
}

.p-hero .l {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.8;
  padding-right: 30px;
}

.p-hero .n {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.15;
}

.verdict {
  display: inline-block;
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 12.5px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.16);
  margin-top: 4px;
}

.verdict.good {
  background: rgba(127, 224, 168, 0.25);
}

.verdict.badv {
  background: rgba(255, 140, 130, 0.28);
}

.trio {
  display: flex;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.trio > div {
  flex: 1;
  padding: 8px 12px;
  min-width: 0;
}

.trio > div + div {
  border-left: 1px solid rgba(255, 255, 255, 0.18);
}

.trio .k {
  font-size: 11px;
  font-weight: 800;
  opacity: 0.75;
}

.trio .v {
  font-size: 17px;
  font-weight: 800;
}

.chips {
  margin-top: 10px;
}

.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  border-radius: 7px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.14);
  margin: 0 5px 4px 0;
}

.p-box {
  position: relative;
  border: 1px solid var(--p-line);
  border-radius: 12px;
  padding: 14px 16px;
}

.sheet table {
  width: 100%;
  border-collapse: collapse;
}

.sheet td,
.sheet th {
  padding: 6px 4px;
  border-bottom: 1px solid var(--p-line);
  text-align: left;
  vertical-align: middle;
}

.sheet tr:last-child td {
  border-bottom: 0;
}

.sheet th {
  font-size: 10px;
  color: var(--p-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.sheet .r {
  text-align: right;
  white-space: nowrap;
}

.sheet b {
  font-weight: 800;
}

.sheet .ok {
  color: var(--p-ok);
  font-weight: 800;
}

.sheet .bad {
  color: var(--p-bad);
  font-weight: 800;
}

.p-note {
  font-size: 11.5px;
  color: var(--p-muted);
  margin-top: 6px;
}

.barcell {
  width: 24%;
}

.barc {
  height: 7px;
  background: var(--p-line);
  border-radius: 4px;
}

.barc i {
  display: block;
  height: 7px;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
}

tr.cat {
  cursor: pointer;
}

tr.cat:hover td,
tr.cat.sel td {
  background: #f1f8f4;
}

tr.cat:focus-visible {
  outline: 2px solid var(--p-accent);
}

.cols {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 140px;
}

.col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  font: inherit;
  font-size: 10.5px;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.col i {
  display: block;
  width: 100%;
  background: #c9ddd1;
  border-radius: 6px 6px 2px 2px;
  transition: height 0.4s ease;
}

.col.cur i {
  background: var(--p-accent);
}

.col:hover i,
.col.sel i {
  filter: brightness(0.9);
  box-shadow: 0 0 0 2px var(--p-deep);
}

.col em {
  font-style: normal;
  font-weight: 800;
  margin-bottom: 3px;
}

.col span {
  color: var(--p-muted);
  margin-top: 4px;
}

.pm {
  display: flex;
  gap: 5px;
  height: 150px;
  position: relative;
}

.pm .z {
  position: absolute;
  left: 0;
  right: 0;
  top: 64px;
  border-top: 1px solid #9db5a9;
}

.pm .c {
  flex: 1;
  display: flex;
  flex-direction: column;
  font: inherit;
  font-size: 10px;
  text-align: center;
  color: var(--p-muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  border-radius: 4px;
}

.pm .t,
.pm .b {
  height: 64px;
  display: flex;
  flex-direction: column;
}

.pm .t {
  justify-content: flex-end;
}

.pm i {
  display: block;
  width: 100%;
  border-radius: 3px;
}

.pm span {
  margin-top: 6px;
}

.pm button.c:hover,
.pm .c.sel {
  background: #f1f8f4;
}

.ln {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 6px 0;
  border-bottom: 1px solid var(--p-line);
}

.ln:last-child {
  border-bottom: 0;
}

.ic {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  text-align: center;
  line-height: 20px;
  font-size: 10px;
  font-weight: 800;
}

.ic.ok {
  background: #e3f4ea;
}

.ic.bad {
  background: #fbe7e5;
}

.banner {
  border-radius: 10px;
  padding: 9px 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.banner.bad {
  background: #fbe7e5;
  color: var(--p-bad);
}

.banner.ok {
  background: #e3f4ea;
  color: var(--p-ok);
}

.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}

.stat {
  flex: 1 1 45%;
  min-width: 0;
}

.stat .k {
  font-size: 11px;
  color: var(--p-muted);
  font-weight: 800;
}

.stat .v {
  font-size: 20px;
  font-weight: 800;
}

.stat .v small {
  font-size: 13px;
  color: var(--p-muted);
}

.usage {
  position: relative;
  height: 7px;
  border-radius: 4px;
  background: var(--p-line);
  margin-top: 6px;
}

.usage i {
  display: block;
  height: 7px;
  border-radius: 4px;
  background: var(--p-accent);
  transition: width 0.4s ease;
}

.usage b {
  position: absolute;
  left: 30%;
  top: -3px;
  height: 13px;
  border-left: 2px solid var(--p-muted);
}

.tag {
  font-size: 10px;
  font-weight: 800;
  border-radius: 5px;
  padding: 1px 6px;
  background: #fbf1d9;
  color: var(--p-warn);
}

.p-logros {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.logro {
  display: flex;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--p-line);
  border-radius: 12px;
  padding: 12px 14px;
}

.logro .e {
  font-size: 26px;
}

.logro b {
  display: block;
  font-size: 14px;
}

.logro span {
  font-size: 12px;
  color: var(--p-muted);
}

.p-thanks {
  margin-top: auto;
  text-align: center;
  color: var(--p-muted);
  font-weight: 700;
}

/* Lo que cambió con «Juega con el ejemplo». */
.flash {
  animation: flash 1.4s ease;
  border-radius: 6px;
}

@keyframes flash {
  0%,
  35% {
    background-color: rgba(47, 168, 119, 0.35);
    box-shadow: 0 0 0 4px rgba(47, 168, 119, 0.35);
  }
  100% {
    background-color: transparent;
    box-shadow: 0 0 0 4px transparent;
  }
}

/* ---------- Puntos de ayuda ---------- */
.hs {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: #2fa877;
  cursor: pointer;
  z-index: 2;
}

.hs::before {
  content: "?";
  color: #fff;
  font: 800 13px/26px "Plus Jakarta Sans", system-ui, sans-serif;
}

.hs::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(47, 168, 119, 0.55);
  animation: pulse 2.2s ease-out infinite;
}

.hs[aria-expanded] {
  background: var(--p-deep);
  box-shadow: 0 0 0 3px #fff;
}

.hs:focus-visible {
  outline: 3px solid #f2c94c;
}

@keyframes pulse {
  70%,
  100% {
    box-shadow: 0 0 0 12px rgba(47, 168, 119, 0);
  }
}

.no-help .hs {
  display: none;
}

.r-tip {
  position: fixed;
  z-index: 80;
  width: 300px;
  background: var(--accent-strong);
  color: #fff;
  border-radius: 16px;
  padding: 14px 40px 14px 16px;
  box-shadow: var(--shadow-lg);
  animation: tip-in 0.2s ease;
}

.r-tip[hidden] {
  display: none;
}

.r-tip strong {
  display: block;
  margin-bottom: 4px;
}

.r-tip p {
  margin: 0;
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.88);
}

.r-tip button {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 36px;
  height: 36px;
  border: 0;
  background: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
}

@keyframes tip-in {
  from {
    opacity: 0;
    translate: 0 6px;
  }
}

/* ---------- Juega con el ejemplo ---------- */
.r-panel {
  position: sticky;
  top: 84px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.r-panel h3 {
  font-size: 1.35rem;
  color: var(--accent-strong);
  margin: 6px 0 4px;
}

.r-small {
  font-size: 0.9rem;
  margin: 0;
}

.r-control {
  border-top: 1px solid var(--border);
  padding: 14px 0 10px;
  margin-top: 14px;
}

.r-control + .r-control {
  margin-top: 0;
}

.r-control label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.95rem;
}

.r-control output {
  color: var(--expense);
  font-weight: 800;
}

.r-control input[type="range"] {
  width: 100%;
  margin: 12px 0 4px;
  accent-color: var(--accent);
  min-height: 28px;
}

.r-check {
  justify-content: flex-start !important;
  cursor: pointer;
  min-height: 32px;
}

.r-check input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  flex: none;
}

.r-check b {
  margin-left: auto;
  color: var(--muted);
}

.r-goto {
  border: 0;
  background: none;
  padding: 6px 0;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
}

.r-goto:hover {
  text-decoration: underline;
}

.r-summary {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, #0f3d2c, #14523a);
  color: #fff;
}

.r-summary div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
}

.r-summary span {
  font-size: 0.8rem;
  opacity: 0.75;
  font-weight: 600;
  min-width: 108px;
}

.r-summary b {
  font-weight: 800;
}

.r-summary em {
  font-style: normal;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 1px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
}

.r-summary .ok {
  color: #9be7bd;
}

.r-summary .bad {
  color: #ffb2aa;
}

.r-lesson {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 600;
}

.r-reset {
  margin-top: 12px;
  border: 1px solid var(--border);
  background: none;
  border-radius: 999px;
  padding: 8px 16px;
  min-height: 40px;
  font: inherit;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}

/* ---------- Planes ---------- */
.r-plans {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}

.r-plans table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.r-plans th,
.r-plans td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
}

.r-plans tbody tr:last-child > * {
  border-bottom: 0;
}

.r-plans thead th {
  font-weight: 800;
  color: var(--accent-strong);
}

.r-plans tbody th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
}

.r-plans td {
  font-weight: 800;
  font-size: 1.1rem;
}

.r-plans .r-full {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* ---------- Tamaños ---------- */
@media (max-width: 1080px) {
  .r-layout {
    grid-template-columns: minmax(0, 680px);
  }

  .r-panel {
    position: static;
  }
}

@media (max-width: 960px) {
  .r-hero-actions {
    justify-content: center;
  }

  .hero-points {
    justify-content: center;
  }

  .r-minis {
    height: 420px;
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
  }

  .r-mini-front {
    left: 6%;
    transform: scale(0.48) rotateY(-14deg) rotateX(5deg) rotateZ(1deg);
  }

  .r-mini-back {
    left: 30%;
    transform: scale(0.43) rotateY(-14deg) rotateX(5deg) rotateZ(4deg);
  }

  .r-minis:hover .r-mini-front {
    transform: scale(0.5);
  }

  .r-minis:hover .r-mini-back {
    transform: scale(0.43) translateX(40px) rotateZ(6deg);
  }
}

@media (max-width: 640px) {
  .r-minis {
    height: 340px;
  }

  .r-mini-front {
    left: 2%;
    transform: scale(0.4) rotateY(-12deg) rotateZ(1deg);
  }

  .r-mini-back {
    left: 26%;
    transform: scale(0.36) rotateY(-12deg) rotateZ(4deg);
  }

  .r-minis:hover .r-mini-front {
    transform: scale(0.4);
  }

  .sheet {
    aspect-ratio: auto;
    padding: 20px 14px 14px;
    font-size: 12.5px;
  }

  .p-head h3 {
    font-size: 21px;
  }

  .p-head img {
    width: 52px;
    height: 52px;
  }

  .p-hero {
    padding: 16px 14px;
  }

  .p-hero .n {
    font-size: 32px;
  }

  .trio > div {
    padding: 7px 8px;
  }

  .trio .k {
    font-size: 10px;
    line-height: 1.25;
  }

  .trio .v {
    font-size: 14px;
  }

  .p-hero .l {
    font-size: 12px;
  }

  .sheet .lg {
    display: none;
  }

  .sheet .sm {
    display: inline;
  }

  .r-toolbar {
    flex-wrap: wrap;
  }

  .r-seg button {
    padding: 8px 14px;
  }

  .r-thumbs {
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }

  .p-box {
    padding: 12px;
  }

  .barcell {
    display: none;
  }

  .sheet td,
  .sheet th {
    padding: 6px 3px;
  }

  .stat {
    flex-basis: 40%;
  }

  .stat .v {
    font-size: 17px;
  }

  .cols {
    gap: 4px;
  }

  .pm {
    gap: 2px;
  }

  .r-panel {
    padding: 18px 16px;
  }

  .r-tip {
    left: 12px !important;
    right: 12px;
    bottom: 12px;
    top: auto !important;
    width: auto;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .r-plans th,
  .r-plans td {
    padding: 12px 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .r-track,
  .r-viewport,
  .r-mini {
    transition: none;
  }

  .hs::after,
  .flash {
    animation: none;
  }
}
