/* ==========================================
   VARIABLES Y TEMAS
   ========================================== */

/* VARIABLES POR DEFECTO (TEMA CLASSIC GRAY) */
body[data-tema="classic"] {
  /* Página completa */
  --bg-pagina: #0f172a;
  --texto-pagina: #f8fafc;
  --texto-subtitulo: #94a3b8;
  --color-acento: #14b8a6;
  --color-acento-suave: rgba(20, 184, 166, 0.35);
  --banner-degradado-a: rgba(13, 148, 136, 0.95);
  --banner-degradado-b: rgba(15, 118, 110, 0.97);
  --banner-borde: #14b8a6;
  --sombra-logo: rgba(45, 212, 191, 0.45);
  /* Controles */
  --bg-buscador: #1e293b;
  --borde-buscador: #334155;
  --bg-buscador-focus: #0f172a;
  --bg-control: #111827;
  --bg-control-secundario: #334155;
  /* Carcasa */
  --bg-carcasa-top: #d1d5db;
  --bg-carcasa-bottom: #9ca3af;
  --borde-carcasa: #6b7280;
  --texto-carcasa: #1f2937;
  --texto-marca: #374151;
  --bg-pestanas: #6b7280;
  --bg-tab-activa: #f9fafb;
  --texto-tab-activa: #0f172a;
  --bg-lcd: #9ead86;
  --texto-lcd: #111827;
  --bg-input: #ffffff;
  --texto-input: #0f172a;
  --placeholder-input: #64748b;
}

/* TEMA CYBERPUNK (NEÓN OSCURO) */
body[data-tema="cyberpunk"] {
  /* Página completa */
  --bg-pagina: #020617;
  --texto-pagina: #e2e8f0;
  --texto-subtitulo: #7dd3fc;
  --color-acento: #38bdf8;
  --color-acento-suave: rgba(56, 189, 248, 0.35);
  --banner-degradado-a: rgba(8, 47, 73, 0.92);
  --banner-degradado-b: rgba(2, 6, 23, 0.96);
  --banner-borde: #38bdf8;
  --sombra-logo: rgba(56, 189, 248, 0.6);
  /* Controles */
  --bg-buscador: #0f172a;
  --borde-buscador: #164e63;
  --bg-buscador-focus: #082f49;
  --bg-control: #082f49;
  --bg-control-secundario: #1e293b;
  /* Carcasa */
  --bg-carcasa-top: #1e293b;
  --bg-carcasa-bottom: #0f172a;
  --borde-carcasa: #38bdf8;
  --texto-carcasa: #f8fafc;
  --texto-marca: #38bdf8;
  --bg-pestanas: #334155;
  --bg-tab-activa: #38bdf8;
  --texto-tab-activa: #0f172a;
  --bg-lcd: #020617;
  --texto-lcd: #34d399;
  --bg-input: #0f172a;
  --texto-input: #f8fafc;
  --placeholder-input: #64748b;
}

/* TEMA RETRO BEIGE 80S */
body[data-tema="retro"] {
  /* Página completa */
  --bg-pagina: #f3ecdd;
  --texto-pagina: #33302b;
  --texto-subtitulo: #857763;
  --color-acento: #c05621;
  --color-acento-suave: rgba(192, 86, 33, 0.3);
  --banner-degradado-a: rgba(146, 100, 54, 0.96);
  --banner-degradado-b: rgba(107, 68, 35, 0.97);
  --banner-borde: #d97706;
  --sombra-logo: rgba(217, 119, 6, 0.4);
  /* Controles */
  --bg-buscador: #fffaf0;
  --borde-buscador: #b5aba0;
  --bg-buscador-focus: #ffffff;
  --bg-control: #4a3b2c;
  --bg-control-secundario: #7a6a58;
  /* Carcasa */
  --bg-carcasa-top: #f5f0e1;
  --bg-carcasa-bottom: #d3cbbd;
  --borde-carcasa: #b5aba0;
  --texto-carcasa: #2c2521;
  --texto-marca: #5c5248;
  --bg-pestanas: #b5aba0;
  --bg-tab-activa: #fffaf0;
  --texto-tab-activa: #2c2521;
  --bg-lcd: #d1d8be;
  --texto-lcd: #283618;
  --bg-input: #ffffff;
  --texto-input: #2c2521;
  --placeholder-input: #8c827a;
}

/* ==========================================
   REGLAS GENERALES & BASE
   ========================================== */

* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-pagina);
  color: var(--texto-pagina);
  margin: 0;
  padding: 0 0 40px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* BANNER PRINCIPAL COMPACTO (COLOREADO POR TEMA) */
.banner-principal {
  width: 100%;
  background: linear-gradient(135deg, var(--banner-degradado-a), var(--banner-degradado-b));
  color: white;
  padding: 14px 20px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  margin-bottom: 25px;
  border-bottom: 3px solid var(--banner-borde);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.contenido-banner {
  max-width: 850px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  flex-wrap: wrap;
}

.banner-marca {
  display: flex;
  align-items: center;
  gap: 15px;
}

.banner-enlace {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 15px;
  color: inherit;
}

.banner-texto { text-align: left; }

.logo-header {
  border-radius: 8px;
  box-shadow: 0 0 10px var(--sombra-logo);
  transition: box-shadow 0.3s ease;
}

.banner-principal h1 {
  margin: 0;
  font-size: clamp(1.15rem, 2.5vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -0.5px;
}

.slogan {
  margin: 2px 0 0 0;
  font-size: clamp(0.78rem, 1.3vw, 0.9rem);
  opacity: 0.95;
}

/* SELECTOR DE TEMA */
.selector-tema-container .etiqueta-tema {
  font-size: 0.75rem;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
  text-align: left;
}

#selectTema {
  width: auto;
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: 6px;
  border: none;
  background: var(--bg-control);
  color: white;
  cursor: pointer;
}

/* CONTENEDOR APP */
.contenedor-app {
  max-width: 620px;
  width: 92%;
}

@media (min-width: 1024px) {
  .contenedor-app {
    max-width: 880px;
  }
}

.pantalla {
  display: none;
}

.pantalla.activa {
  display: block;
  animation: aparecer 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes aparecer {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================
   MENÚ PRINCIPAL Y BUSCADOR
   ========================================== */

#pantalla-menu h2 {
  text-align: center;
  color: var(--texto-pagina);
  font-size: 1.4rem;
  margin-bottom: 6px;
}

.subtitulo-menu {
  text-align: center;
  color: var(--texto-subtitulo);
  font-size: 0.9rem;
  margin-bottom: 15px;
}

.buscador-contenedor {
  position: relative;
  margin-bottom: 20px;
}

.buscador-contenedor input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background: var(--bg-buscador);
  border: 2px solid var(--borde-buscador);
  border-radius: 12px;
  color: var(--texto-pagina);
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.icono-buscador {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--placeholder-input);
  pointer-events: none;
}

.buscador-contenedor input::placeholder {
  color: var(--placeholder-input);
}

.buscador-contenedor input:focus {
  background: var(--bg-buscador-focus);
  outline: none;
  border-color: var(--color-acento);
  box-shadow: 0 0 10px var(--color-acento-suave);
}

.grid-menu {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (min-width: 550px) {
  .grid-menu {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

.mini-carcasa {
  background: linear-gradient(180deg, var(--bg-carcasa-top) 0%, var(--bg-carcasa-bottom) 100%);
  padding: 20px 18px;
  border-radius: 24px;
  box-shadow: 
    0 12px 25px rgba(0,0,0,0.5),
    inset 0 2px 4px rgba(255,255,255,0.4),
    inset 0 -3px 5px rgba(0,0,0,0.2);
  border: 3px solid var(--borde-carcasa);
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: space-between;
}

.mini-carcasa:hover {
  transform: translateY(-5px);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.6);
}

.mini-marca {
  width: 100%;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--texto-marca);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  border-bottom: 2px dashed rgba(0,0,0,0.15);
  padding-bottom: 4px;
}

.mini-marca span {
  font-size: 0.65rem;
  opacity: 0.8;
}

.mini-carcasa .imagen-tarjeta {
  width: 75px;
  height: 75px;
  margin: 10px 0;
}

.mini-carcasa .imagen-tarjeta img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 5px 8px rgba(0,0,0,0.3));
}

.mini-carcasa h3 {
  margin: 0 0 6px 0;
  font-size: 1.15rem;
  color: var(--texto-carcasa);
  font-weight: 800;
}

.mini-carcasa p {
  font-size: 0.82rem;
  color: var(--texto-carcasa);
  opacity: 0.85;
  margin-bottom: 15px;
  line-height: 1.3;
}

.btn-entrar {
  width: 100%;
  background: var(--bg-control);
  border: none;
  padding: 10px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 1px;
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.btn-entrar:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.btn-volver {
  background: var(--bg-control-secundario);
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: bold;
  cursor: pointer;
  margin-bottom: 15px;
  color: white;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

/* ==========================================
   ENLACES QUE SIMULAN BOTONES
   ========================================== */
a.mini-carcasa,
a.tab-btn,
a.btn-volver {
  text-decoration: none;
  color: inherit;
}

a.tab-btn {
  display: block;
  text-align: center;
}

span.tab-btn.activa {
  cursor: default;
}

span.btn-entrar {
  cursor: pointer;
}

/* ==========================================
   CARCASA INTERIOR Y CONTENIDOS
   ========================================== */

.carcasa-calculadora {
  background: linear-gradient(180deg, var(--bg-carcasa-top) 0%, var(--bg-carcasa-bottom) 100%);
  padding: clamp(18px, 4vw, 26px);
  border-radius: 28px;
  box-shadow: 0 15px 35px rgba(0,0,0,0.6), inset 0 2px 4px rgba(255,255,255,0.4);
  border: 4px solid var(--borde-carcasa);
  color: var(--texto-carcasa);
}

.ambiente-compras { border-top: 8px solid #10b981; }
.ambiente-estudiantes { border-top: 8px solid #3b82f6; }
.ambiente-salud { border-top: 8px solid #8b5cf6; }

.marca-calc {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--texto-marca);
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
}

.marca-calc span { font-size: 0.7rem; opacity: 0.8; }

/* PESTAÑAS (TABS): una sola línea; en pantallas estrechas se deslizan lateralmente */
.pestanas {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  background: var(--bg-pestanas);
  padding: 4px;
  border-radius: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.pestanas::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex: 1 0 auto;
  white-space: nowrap;
  background: transparent;
  border: none;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--texto-carcasa);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.activa {
  background: var(--bg-tab-activa);
  color: var(--texto-tab-activa);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* PISTAS DE DESPLAZAMIENTO: degradados en los bordes y flechas,
   visibles solo cuando quedan pestañas fuera de la vista */
.pestanas-envoltorio { position: relative; }

.pestanas-envoltorio::before,
.pestanas-envoltorio::after {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 30px;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.pestanas-envoltorio::before {
  left: 0;
  border-radius: 10px 0 0 10px;
  background: linear-gradient(90deg, var(--bg-pestanas) 25%, transparent);
}

.pestanas-envoltorio::after {
  right: 0;
  border-radius: 0 10px 10px 0;
  background: linear-gradient(270deg, var(--bg-pestanas) 25%, transparent);
}

.pestanas-envoltorio.puede-izq::before { opacity: 1; }
.pestanas-envoltorio.puede-der::after { opacity: 1; }

.flecha-tab {
  position: absolute;
  top: 5px;
  bottom: 5px;
  width: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--texto-carcasa);
  cursor: pointer;
  z-index: 2;
  transition: transform 0.15s ease;
}

.flecha-tab .icono { width: 16px; height: 16px; }

.flecha-tab:hover { transform: scale(1.12); }

.flecha-tab.flecha-izq { left: 3px; }
.flecha-tab.flecha-der { right: 3px; }

.flecha-tab[hidden] { display: none; }

.subtab-contenido {
  display: none;
}

.subtab-contenido.activa {
  display: block;
  animation: aparecer 0.2s ease;
}

/* INPUTS & SELECTS */
.instruccion-tab {
  font-size: 0.8rem;
  color: var(--texto-carcasa);
  font-weight: 600;
  margin: 0 0 10px 0;
}

.campo { margin-bottom: 12px; }

.campo label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--texto-carcasa);
  margin-bottom: 4px;
}

input, select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--borde-carcasa);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--bg-input);
  color: var(--texto-input);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

input::placeholder {
  color: var(--placeholder-input);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--color-acento);
}

/* BARRA DE PROGRESO DE PESOS */
.contenedor-progreso-pesos {
  margin: 12px 0 16px 0;
  background: rgba(0, 0, 0, 0.08);
  padding: 8px 12px;
  border-radius: 8px;
}

.info-progreso {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--texto-carcasa);
  margin-bottom: 5px;
}

.barra-progreso-bg {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  overflow: hidden;
}

.barra-progreso-fill {
  height: 100%;
  background: var(--color-acento);
  width: 0%;
  transition: width 0.3s ease, background-color 0.3s ease;
}

/* ==========================================
   FILAS DINÁMICAS Y BOTONES DE ACCIÓN
   ========================================== */

.fila-dinamica {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
  width: 100%;
}

.fila-dinamica input {
  flex: 1 1 auto;
  min-width: 100px; /* Asegura un tamaño mínimo visible para poder escribir */
}

.fila-dinamica select {
  flex: 0 0 130px; /* Ancho fijo para el selector de ponderación sin aplastar al input */
  min-width: 110px;
}

.fila-dinamica .ex-nota,
.fila-dinamica .p-nota,
.fila-dinamica .ebau-nota {
  flex: 1.2; /* Mayor proporción para la nota */
}

.fila-dinamica .ex-peso,
.fila-dinamica .p-peso,
.fila-dinamica .ebau-ponderacion {
  flex: 1; /* Proporción balanceada */
}

.btn-eliminar-fila {
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 8px;
  min-width: 44px; /* Tamaño mínimo táctil recomendado */
  min-height: 44px;
  padding: 0;
  cursor: pointer;
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 #b91c1c;
  transition: all 0.1s ease;
  flex-shrink: 0;
}

.btn-eliminar-fila:hover {
  background: #dc2626;
}

.btn-eliminar-fila:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #b91c1c;
}

.btn-secundario {
  width: 100%;
  background: var(--bg-control-secundario);
  color: white;
  border: none;
  padding: 8px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 0.8rem;
  cursor: pointer;
  margin-bottom: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

/* ==========================================
   PANTALLA LCD Y TECLADO
   ========================================== */

.pantalla-lcd {
  background-color: var(--bg-lcd);
  border: 4px inset var(--borde-carcasa);
  border-radius: 10px;
  padding: 12px;
  margin: 16px 0;
  overflow-x: auto; /* Permite scroll horizontal si el resultado es muy extenso */
  animation: parpadeo-lcd 4s infinite ease-in-out;
  will-change: opacity; /* Optimiza rendimiento de GPU en móviles */
}

@keyframes parpadeo-lcd {
  0% { opacity: 1; }
  50% { opacity: 0.94; }
  100% { opacity: 1; }
}

.etiqueta-lcd {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--texto-carcasa);
  opacity: 0.8;
  display: block;
  margin-bottom: 4px;
}

.texto-lcd {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--texto-lcd);
  text-align: center;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: break-word;
  /* VENTANA PERMANENTE: visible desde que carga la página,
     con resultado, mensaje de aviso o error */
  background: rgba(0, 0, 0, 0.22);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.3),
    inset 0 -1px 2px rgba(255, 255, 255, 0.07);
}

/* DESTELLO DEL RESULTADO: brilla el marco de la pantalla (sin escalar texto) */
@keyframes glow-lcd {
  0% { box-shadow: 0 0 0 0 rgba(20, 184, 166, 0); }
  35% { box-shadow: 0 0 20px 3px var(--color-acento-suave), inset 0 0 14px var(--color-acento-suave); }
  100% { box-shadow: 0 0 0 0 rgba(20, 184, 166, 0); }
}

.pantalla-lcd.animar-lcd {
  animation: glow-lcd 0.6s ease;
}

/* JERARQUÍA DEL RESULTADO: cifra protagonista + desglose secundario.
   La ventana oscura vive en .texto-lcd, aquí solo tipografía. */
.cifra-lcd {
  display: block;
  font-size: 1.75rem;
  letter-spacing: 0.5px;
}

.desglose-lcd {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  opacity: 0.9;
  margin-top: 6px;
  white-space: normal;
  text-align: center;
}

/* MENSAJES DE ERROR DE VALIDACIÓN */
.texto-lcd.texto-error {
  color: #b91c1c;
  text-align: left;
  font-size: 1rem;
}

body[data-tema="cyberpunk"] .texto-lcd.texto-error {
  color: #f87171;
}

.input-error {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.3);
}

/* BOTONES 3D */
.teclado-tactil { display: flex; gap: 12px; }

.btn-3d {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.btn-calcular {
  background: #10b981;
  color: white;
  box-shadow: 0 6px 0 #047857;
}

.btn-calcular:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #047857;
}

.btn-limpiar {
  background: #ef4444;
  color: white;
  box-shadow: 0 6px 0 #b91c1c;
}

.btn-limpiar:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #b91c1c;
}

/* ==========================================
   HISTORIAL, RETRO & SEO
   ========================================== */

.caja-historial {
  margin-top: 18px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  padding: 12px;
}

.titulo-historial {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--texto-carcasa);
  margin-bottom: 8px;
}

.lista-historial {
  list-style: none;
  padding: 0;
  margin: 0;
}

.lista-historial li {
  font-size: 0.85rem;
  color: var(--texto-carcasa);
  padding: 5px 0;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.15);
  font-weight: 600;
}

/* TERMINAL RETRO */
.descripcion-retro {
  background-color: #0a1a0a;
  border: 1px solid #33ff33;
  color: #ccffcc;
  font-family: 'Courier New', Courier, monospace;
  padding: 12px 15px;
  margin: 15px 0;
  border-radius: 6px;
}

.descripcion-retro h4 {
  margin-top: 0;
  color: #33ff33;
  text-transform: uppercase;
  font-size: 0.95rem;
}

.descripcion-retro p {
  margin-bottom: 0;
  font-size: 0.82rem;
}

/* BLOQUE SEO */
.seo-info-box {
  margin-top: 25px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.15);
  border: 2px dashed rgba(55, 65, 81, 0.4);
  border-radius: 12px;
  color: var(--texto-carcasa);
  line-height: 1.5;
}

.seo-info-box h3 {
  margin-top: 0;
  color: var(--texto-carcasa);
  font-size: 1rem;
  margin-bottom: 8px;
  font-weight: 800;
}

.seo-info-box p {
  font-size: 0.85rem;
  margin: 0;
  color: var(--texto-carcasa);
  opacity: 0.9;
}

/* ==========================================
   BOTÓN COPIAR RESULTADO
   ========================================== */

.btn-copiar {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-control-secundario);
  color: white;
  border: none;
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 0.78rem;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.btn-copiar:hover:not(:disabled) {
  filter: brightness(1.2);
}

.btn-copiar:disabled {
  cursor: default;
  opacity: 0.9;
}

/* ==========================================
   PREGUNTAS FRECUENTES (FAQ)
   ========================================== */

.faq-seccion {
  margin-top: 25px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.15);
  border: 2px dashed rgba(55, 65, 81, 0.4);
  border-radius: 12px;
  color: var(--texto-carcasa);
}

.faq-seccion h3 {
  margin-top: 0;
  margin-bottom: 12px;
  color: var(--texto-carcasa);
  font-size: 1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.faq-item {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}

.faq-item:last-child {
  margin-bottom: 0;
}

.faq-item summary {
  cursor: pointer;
  padding: 10px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--texto-carcasa);
}

.faq-item p {
  margin: 0;
  padding: 0 12px 12px;
  font-size: 0.83rem;
  line-height: 1.55;
  color: var(--texto-carcasa);
  opacity: 0.92;
}

/* ==========================================
   ICONOS SVG (HEREDAN COLOR ACTUAL)
   ========================================== */

svg.icono {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
}

/* ==========================================
   CLASES UTILITARIAS (SUSTITUYEN INLINE STYLES)
   ========================================== */

.titulo-tab {
  font-size: 1.1rem;
  margin-top: 5px;
  margin-bottom: 10px;
  color: var(--texto-carcasa);
}

.margen-superior { margin-top: 15px; }

.caja-historial .btn-secundario {
  margin-top: 10px;
}

/* FILA COMPARTIR: WhatsApp + botón nativo lado a lado */
.fila-compartir {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.fila-compartir .btn-secundario {
  flex: 1;
  margin-top: 0;
  margin-bottom: 0;
}

@media (max-width: 420px) {
  .fila-compartir {
    flex-direction: column;
  }
}

/* ==========================================
   CALCULADORAS RELACIONADAS
   ========================================== */

.relacionadas-seccion {
  margin-top: 25px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.15);
  border: 2px dashed rgba(55, 65, 81, 0.4);
  border-radius: 12px;
}

.guias-relacionadas {
  margin-top: 18px;
  border-style: solid;
  border-color: rgba(139, 92, 246, 0.35);
}

.relacionadas-seccion h3 {
  margin-top: 0;
  margin-bottom: 12px;
  color: var(--texto-carcasa);
  font-size: 1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.relacionadas-lista {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  background: var(--bg-pestanas);
  border-radius: 12px;
}

.relacionadas-lista .tab-btn {
  flex: 0 1 auto;
}

/* ==========================================
   HOME RICO - CATEGORÍAS Y TARJETAS COMPACTAS
   ========================================== */

.grid-menu-chica {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.tarjeta-chica {
  padding: 14px 10px;
  border-radius: 16px;
  box-shadow:
    0 8px 16px rgba(0, 0, 0, 0.45),
    inset 0 1px 3px rgba(255, 255, 255, 0.35);
}

.tarjeta-chica.ambiente-estudiantes {
  border-top: none;
  border-left: 6px solid #3b82f6;
}

.tarjeta-chica.ambiente-compras {
  border-top: none;
  border-left: 6px solid #10b981;
}

.tarjeta-chica.ambiente-salud {
  border-top: none;
  border-left: 6px solid #8b5cf6;
}

.tarjeta-chica:hover {
  transform: translateY(-4px);
}

.emoji-tarjeta {
  font-size: 1.9rem;
  line-height: 1;
  display: block;
  margin-bottom: 8px;
}

.tarjeta-chica h3 {
  font-size: 0.95rem;
  margin: 0 0 5px 0;
}

.tarjeta-chica p {
  font-size: 0.74rem;
  line-height: 1.3;
  margin-bottom: 0;
}

.titulo-categoria {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 800;
  color: var(--texto-pagina);
  margin: 24px 0 12px;
}

.seccion-categoria:first-child .titulo-categoria {
  margin-top: 6px;
}

.badge-num {
  font-size: 0.68rem;
  background: var(--bg-control-secundario);
  color: white;
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 800;
}

/* ==========================================
   AVISO CÁLCULO EN VIVO / HISTORIAL
   ========================================== */

.aviso-historial {
  font-size: 0.72rem;
  color: var(--texto-carcasa);
  opacity: 0.75;
  text-align: center;
  margin: 0 0 8px 0;
}

/* ==========================================
   GRÁFICO INTERÉS COMPUESTO
   ========================================== */

.grafico-caja {
  margin: 16px 0 8px 0;
  background-color: #10141f;
  border: 4px inset var(--borde-carcasa);
  border-radius: 10px;
  padding: 12px;
}

.grafico-caja canvas {
  display: block;
}

.grafico-leyenda {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-bottom: 6px;
}

.leyenda-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 800;
  color: #cbd5e1;
}

.punto-leyenda {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

.punto-aportado { background: #38bdf8; }
.punto-total { background: #10b981; }
.punto-aprobado { background: #10b981; }
.punto-suspenso { background: #ef4444; }

.grafico-vacio {
  text-align: center;
  font-size: 0.75rem;
  color: #94a3b8;
  margin: 40px 0;
}

/* ==========================================
   BARRA DE INSTALACIÓN PWA
   ========================================== */

.barra-instalar {
  width: 100%;
  background: linear-gradient(135deg, #052e2b, #0b3d38);
  border-bottom: 2px solid var(--color-acento);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 16px;
  font-size: 0.82rem;
}

.barra-instalar-texto {
  font-weight: 600;
}

.btn-barra-instalar {
  background: #10b981;
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.78rem;
  cursor: pointer;
  box-shadow: 0 3px 0 #047857;
  transition: transform 0.1s ease;
}

.btn-barra-instalar:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #047857;
}

.btn-cerrar-instalar {
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.btn-cerrar-instalar:hover {
  color: white;
}

/* ==========================================
   FOOTER DEL SITIO
   ========================================== */

.footer-sitio {
  width: 100%;
  margin-top: auto; /* Empuja el footer al final aunque la página sea corta */
  padding: 30px 16px 0;
}

.footer-caja {
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  background: rgba(0, 0, 0, 0.28);
  border-top: 3px solid var(--banner-borde);
  border-radius: 18px 18px 0 0;
  padding: 24px 26px 12px;
  color: var(--texto-subtitulo);
}

.footer-columnas {
  display: grid;
  grid-template-columns: 1.4fr repeat(auto-fit, minmax(150px, 1fr));
  gap: 20px;
}

.footer-marca {
  display: flex;
  align-items: center;
  gap: 11px;
}

.footer-marca img {
  border-radius: 8px;
  box-shadow: 0 0 8px var(--sombra-logo);
}

.footer-nombre {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--texto-pagina);
  letter-spacing: -0.3px;
}

.footer-eslogan {
  margin: 3px 0 0;
  font-size: 0.78rem;
  line-height: 1.35;
  max-width: 240px;
}

.footer-titulo {
  margin: 4px 0 9px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--texto-pagina);
}

.footer-nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.footer-nav a {
  color: var(--texto-subtitulo);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.15s ease;
}

.footer-nav a:hover,
.footer-nav a:focus-visible {
  color: var(--color-acento);
  text-decoration: underline;
}

.footer-legal {
  text-align: center;
  font-size: 0.74rem;
  opacity: 0.85;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  margin: 18px 0 0;
  padding-top: 11px;
  padding-bottom: 6px;
}

.footer-legal a {
  color: inherit;
  font-weight: 700;
}

.footer-legal a:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .footer-columnas {
    grid-template-columns: 1fr;
    gap: 16px;
    justify-items: center;
    text-align: center;
  }

  .footer-marca {
    flex-direction: column;
    text-align: center;
  }

  .footer-eslogan { max-width: none; }

  .footer-nav { align-items: center; }
}

/* ==========================================
   ACCESIBILIDAD
   ========================================== */

/* FOCO VISIBLE PARA QUIEN NAVEGA CON TECLADO */
:focus-visible {
  outline: 3px solid var(--color-acento);
  outline-offset: 2px;
  border-radius: 4px;
}

/* RESPETA LA PREFERENCIA DE REDUCIR ANIMACIONES DEL SISTEMA */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================
   TABLA DE AMORTIZACION - Cuota Prestamo
   ========================================================== */
.tabla-amortizacion-envoltorio {
  max-height: 340px;
  overflow-y: auto;
  margin-top: 14px;
  border-radius: 8px;
  border: 1px solid var(--borde-buscador);
}

.tabla-amortizacion {
  width: 100%;
  border-collapse: collapse;
  font-family: "Courier New", monospace;
  font-size: 0.85rem;
}

.tabla-amortizacion th {
  position: sticky;
  top: 0;
  background: var(--bg-control-secundario);
  color: var(--texto-pagina);
  padding: 8px 10px;
  text-align: right;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tabla-amortizacion th:first-child {
  text-align: left;
}

.tabla-amortizacion td {
  padding: 7px 10px;
  text-align: right;
  color: var(--texto-carcasa);
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.tabla-amortizacion td:first-child {
  text-align: left;
  font-weight: bold;
}

.tabla-amortizacion tbody tr:nth-child(even) {
  background: rgba(148, 163, 184, 0.12);
}

/* ==========================================
   BOTÓN DE EJEMPLO PRECARGADO
   ========================================== */

.btn-ejemplo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--color-acento);
  border: 1px dashed var(--color-acento);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  margin: 8px 0 14px;
  opacity: 0.85;
  transition: opacity 0.2s, border-color 0.2s, background 0.2s;
}

.btn-ejemplo:hover {
  opacity: 1;
  background: var(--color-acento-suave);
}

.btn-ejemplo:active {
  background: var(--color-acento-suave);
  opacity: 0.7;
}

.btn-ejemplo .icono {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke: currentColor;
}

/* ==========================================
   FÓRMULA EXPANDIBLE
   ========================================== */

.formula-expandible {
  margin: 12px 0 16px;
  border: 1px solid var(--borde-carcasa);
  border-radius: 8px;
  overflow: hidden;
}

.formula-expandible summary {
  padding: 8px 14px;
  font-size: 0.78rem;
  font-weight: bold;
  color: var(--color-acento);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  transition: background 0.2s;
}

.formula-expandible summary::-webkit-details-marker {
  display: none;
}

.formula-expandible summary::before {
  content: '▸';
  font-size: 0.7rem;
  transition: transform 0.2s;
}

.formula-expandible[open] summary::before {
  transform: rotate(90deg);
}

.formula-expandible summary:hover {
  background: var(--color-acento-suave);
}

.formula-contenido {
  padding: 10px 14px 14px;
  font-family: "Courier New", monospace;
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--texto-carcasa);
  border-top: 1px solid var(--borde-carcasa);
  background: rgba(148, 163, 184, 0.06);
}

.formula-contenido code {
  display: block;
  margin: 4px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.formula-contenido small {
  display: block;
  margin-top: 8px;
  font-family: inherit;
  font-size: 0.72rem;
  opacity: 0.75;
  line-height: 1.5;
}
