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

body {
  font-family: 'Fira Code', monospace;
  background: #000;
  color: #39ff14;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scanline overlay */
.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0, 0, 0, 0.18) 3px,
    rgba(0, 0, 0, 0.18) 4px
  );
}

/* ── HEADER ──────────────────────────────────────────────────── */
header {
  padding: 20px 30px 10px;
  border-bottom: 1px solid #39ff1430;
  background: #000;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.back-btn {
  color: #39ff14;
  text-decoration: none;
  font-size: 0.85rem;
  border: 1px solid #39ff1460;
  padding: 6px 14px;
  border-radius: 20px;
  transition: all 0.2s;
  white-space: nowrap;
}

.back-btn:hover {
  background: #39ff14;
  color: #000;
}

.title {
  font-family: 'Nosifer', cursive;
  color: #fff;
  font-size: 2.8rem;
  line-height: 1;
  text-shadow: 0 0 20px #39ff1466;
}

.subtitle {
  font-size: 1rem;
  color: #39ff1499;
  letter-spacing: 0.15em;
}

.computed-at {
  font-size: 0.6rem;
  color: #39ff1444;
  letter-spacing: 0.12em;
  margin-left: auto;
}

/* ── MAIN ────────────────────────────────────────────────────── */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 30px 20px 80px;
}

/* ── SECTION ─────────────────────────────────────────────────── */
.section {
  margin-bottom: 48px;
}

.section-title {
  font-size: 0.75rem;
  letter-spacing: 0.22em;
  color: #39ff14cc;
  text-transform: uppercase;
  margin-bottom: 20px;
  border-left: 3px solid #39ff14;
  padding-left: 12px;
}

.title-sub {
  font-family: 'Fira Code', monospace;
  font-size: 1.2rem;
  color: #39ff1499;
  font-weight: 400;
}

/* ── TOTALES GRID ────────────────────────────────────────────── */
.totales-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 36px;
}

.stat-card {
  border: 1px solid #39ff1440;
  background: #050505;
  padding: 20px 18px 14px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--accent, #39ff14);
}

.stat-card:hover {
  border-color: #39ff1488;
  box-shadow: 0 0 20px #39ff1420;
}

.stat-label {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: #39ff1499;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 12px currentColor;
  line-height: 1;
  margin-bottom: 12px;
}

.stat-bar {
  height: 2px;
  background: #111;
  border-radius: 1px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  width: 100%;
  opacity: 0.7;
  animation: barPulse 3s ease-in-out infinite alternate;
}

.stat-sub {
  font-size: 0.62rem;
  color: #39ff1466;
  letter-spacing: 0.08em;
  margin-top: 6px;
}

@keyframes barPulse {
  from { opacity: 0.4; }
  to   { opacity: 1; }
}

/* ── CHARTS ROW ──────────────────────────────────────────────── */
.charts-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.charts-row--center {
  justify-content: center;
}

/* ── CHARTS (legacy + new) ───────────────────────────────────── */
.charts-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.chart-box {
  border: 1px solid #39ff1430;
  background: #050505;
  padding: 24px 20px 20px;
  position: relative;
  flex: 1;
  min-width: 260px;
}

.chart-box--wide {
  grid-column: 1 / -1;
  flex: 0 0 100%;
}

.chart-box--sm {
  flex: 0 0 240px;
  min-width: 200px;
}

.chart-box--md {
  flex: 1;
  min-width: 300px;
  max-width: 500px;
}

/* ── COMP CARDS ──────────────────────────────────────────────── */
.comp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.comp-card {
  border: 1px solid var(--c, #39ff14);
  background: #050505;
  padding: 18px 16px 14px;
  position: relative;
  overflow: hidden;
}

.comp-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--c, #39ff14);
}

.comp-card-header {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 14px;
  padding-left: 4px;
}

.comp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  padding: 4px 4px;
  border-bottom: 1px solid #39ff1410;
}

.comp-row span {
  color: #39ff1499;
  letter-spacing: 0.05em;
}

.comp-row strong {
  color: #fff;
  font-size: 0.82rem;
}

.sim-bar {
  height: 3px;
  background: #111;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 12px;
}

.sim-bar-fill {
  height: 100%;
  border-radius: 2px;
  opacity: 0.8;
  transition: width 0.8s ease;
}

/* ── SUBTEMA CARDS ───────────────────────────────────────────── */
.temas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.subtema-card {
  border: 1px solid #39ff1430;
  background: #050505;
  padding: 18px 16px;
}

.subtema-card-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid #39ff1420;
}

.subtema-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 0.65rem;
}

.subtema-name {
  flex: 0 0 110px;
  color: #39ff14aa;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.subtema-bar-wrap {
  flex: 1;
  height: 4px;
  background: #111;
  border-radius: 2px;
  overflow: hidden;
}

.subtema-bar {
  height: 100%;
  border-radius: 2px;
  border: none;
  opacity: 0.75;
}

.subtema-n {
  flex: 0 0 36px;
  text-align: right;
  color: #39ff1488;
  font-size: 0.6rem;
}

.chart-title {
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  color: #39ff14cc;
  margin-bottom: 20px;
  text-transform: uppercase;
}

canvas {
  max-height: 300px;
}

/* ── LOADING ─────────────────────────────────────────────────── */
.loading {
  text-align: center;
  font-size: 1rem;
  color: #39ff14;
  letter-spacing: 0.2em;
  padding: 60px 0;
}

.blink {
  animation: blink 1s step-start infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ── FOOTER ──────────────────────────────────────────────────── */
footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  background: #000;
  border-top: 1px solid #39ff1430;
  padding: 10px 0;
  text-align: center;
  font-family: 'Fira Code', monospace;
  color: #39ff14;
  font-size: 0.8rem;
  z-index: 10;
}

footer a {
  color: #39ff14;
  text-decoration: none;
  transition: color 0.2s;
}

footer a:hover { color: #fff; }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .totales-grid { grid-template-columns: repeat(3, 1fr); }
  .charts-row { flex-wrap: wrap; }
  .chart-box--sm { flex: 1 1 200px; }
}

@media (max-width: 768px) {
  .totales-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-section { grid-template-columns: 1fr; }
  .charts-row { flex-direction: column; }
  .chart-box--sm, .chart-box--md { flex: 0 0 auto; width: 100%; }
  .comp-grid { grid-template-columns: 1fr; }
  .temas-grid { grid-template-columns: 1fr; }
  .title { font-size: 2rem; }
  .stat-value { font-size: 1.6rem; }
}

@media (max-width: 480px) {
  .totales-grid { grid-template-columns: 1fr 1fr; }
  .title { font-size: 1.5rem; }
}
