:root {
  --primary: #1976d2; /* Azul principal */
  --secondary: #40e0d0; /* Turquesa secundario */
  --bg-dark: #001e1c;
  --bg-light: #ffffff;
  --text-dark: #10122c; /* Texto oscuro en modo claro */
  --text-light: #fff;   /* Texto claro en modo oscuro */
  --error: #ff4444;
  --transition-speed: 0.3s;
}

/* Tema claro */
body[data-theme="light"] {
  background: var(--bg-light);
  color: var(--text-dark);
}
body[data-theme="light"] .tab-content,
body[data-theme="light"] input,
body[data-theme="light"] button {
  background: var(--bg-light);
  color: var(--text-dark);
}

/* Tema oscuro */
body[data-theme="dark"] {
  background: linear-gradient(135deg, #0f2027, #2c5364);
  color: var(--text-light);
}
body[data-theme="dark"] .tab-content,
body[data-theme="dark"] input,
body[data-theme="dark"] button {
  background: var(--bg-dark);
  color: var(--text-light);
}

/* Splash screen */
#splash {
  position: fixed;
  z-index: 9999;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-speed);
  background: transparent;
}
#splash:not(.splash-visible) {
  opacity: 0;
  pointer-events: none;
}
.splash-animated-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(120deg, #0f2027 0%, #2c5364 60%, #8f94fb 100%);
  animation: splashGradientMove 6s linear infinite alternate;
  filter: blur(2px) brightness(0.85);
}
@keyframes splashGradientMove {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}
.splash-content {
  position: relative;
  z-index: 2;
  text-align: center;
  color: #fff;
  background: rgba(16, 18, 44, 0.85);
  padding: 40px 28px;
  border-radius: 22px;
  box-shadow:
    0 2px 24px #8f94fb88,
    0 0 24px #00ffe5cc,
    0 0 120px #a770ef55 inset;
  backdrop-filter: blur(8px);
  animation: splash-in 1.1s cubic-bezier(.56,.12,.37,1.2);
}
.splash-content h1 {
  font-size: 2.5em;
  margin-bottom: 0.5em;
  letter-spacing: 1px;
  font-weight: 700;
  text-shadow: 0 0 24px #8f94fb, 0 0 12px #00ffe5, 0 0 2px #fff;
}
.splash-content p {
  font-size: 1.15em;
  margin-bottom: 1.5em;
  letter-spacing: 0.5px;
  color: #c6f0ff;
}
.splash-content button {
  font-size: 1.15em;
  font-weight: bold;
  padding: 14px 48px;
  background: linear-gradient(90deg, #00ffe5 10%, #8f94fb 90%);
  color: #10122c;
  border: none;
  border-radius: 100px;
  box-shadow:
    0 0 18px #00ffe5cc,
    0 0 40px #8f94fb55 inset;
  cursor: pointer;
  transition: background var(--transition-speed), color var(--transition-speed), box-shadow var(--transition-speed);
  position: relative;
  overflow: hidden;
}
.splash-content button::after {
  content: "";
  display: block;
  position: absolute;
  left: 10%;
  top: 0;
  width: 80%;
  height: 40%;
  background: linear-gradient(90deg, #fff8, #8f94fb44 70%, transparent 100%);
  opacity: 0.15;
  filter: blur(2px);
  pointer-events: none;
}
.splash-content button:hover {
  background: linear-gradient(90deg, #a770ef, #00ffe5 80%);
  color: #fff;
  box-shadow:
    0 0 32px #a770efcc,
    0 0 80px #00ffe5aa inset;
}

@keyframes splash-in {
  from { transform: scale(0.7) translateY(50px); opacity: 0;}
  to { transform: scale(1) translateY(0); opacity: 1;}
}

/* Estilos generales */
h1, h2, h3 {
  text-align: center;
  text-shadow: 0 0 5px var(--primary);
  color: inherit;
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 20px;
  font-size: 16px;
  background: var(--primary);
  border: none;
  border-radius: 8px 8px 0 0;
  color: var(--text-light);
  cursor: pointer;
  transition: background var(--transition-speed), box-shadow var(--transition-speed);
}
.tab-btn.active {
  background: var(--secondary);
  box-shadow: 0 0 15px var(--secondary);
}
.tab-btn:hover {
  background: var(--secondary);
}

.tab-content {
  display: none;
  background: var(--bg-light);
  color: var(--text-dark);
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 0 10px var(--primary) inset;
}
.tab-content.active {
  display: block;
}
body[data-theme="dark"] .tab-content {
  background: var(--bg-dark);
  color: var(--text-light);
}

.campo {
  margin-bottom: 15px;
}

label {
  display: block;
  margin-bottom: 5px;
  text-shadow: 0 0 4px var(--primary);
  color: inherit;
}

input[type="number"],
input[type="text"],
input[type="date"] {
  width: 100%;
  padding: 10px;
  font-size: 16px;
  border: none;
  border-radius: 5px;
  background: var(--bg-light);
  color: var(--text-dark);
  box-shadow: 0 0 8px var(--primary) inset;
  transition: box-shadow var(--transition-speed);
}
body[data-theme="dark"] input[type="number"],
body[data-theme="dark"] input[type="text"],
body[data-theme="dark"] input[type="date"] {
  background: var(--bg-dark);
  color: var(--text-light);
}

input[type="number"]:focus,
input[type="text"]:focus,
input[type="date"]:focus {
  outline: none;
  box-shadow: 0 0 12px var(--primary) inset;
}
input.error {
  border: 2px solid var(--error);
}
.facturas-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.factura-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
.factura-item input {
  flex: 1;
}
button {
  padding: 10px;
  margin-top: 10px;
  width: 100%;
  font-size: 16px;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  color: var(--text-light);
  cursor: pointer;
  box-shadow: 0 0 10px var(--primary);
  transition: background var(--transition-speed), box-shadow var(--transition-speed);
}
button:hover {
  background: var(--secondary);
  box-shadow: 0 0 15px var(--secondary);
}
.delete-btn {
  width: auto;
  padding: 5px 10px;
  font-size: 14px;
}
#error {
  text-align: center;
  font-weight: bold;
  font-size: 1.2em;
  margin-top: 10px;
  color: var(--error);
  text-shadow: 0 0 4px var(--error);
  display: none;
}
#resultado {
  text-align: center;
  font-weight: bold;
  font-size: 1.4em;
  margin-top: 15px;
  color: inherit;
  text-shadow: 0 0 6px var(--primary);
}
#historial {
  max-height: 300px;
  overflow-y: auto;
  font-size: 0.9em;
  color: inherit;
}
#historial div {
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pagination {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}
.config {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 20px;
}
.stats {
  margin-top: 20px;
  padding: 10px;
  background: var(--bg-dark);
  border-radius: 8px;
  text-align: center;
  color: var(--text-light);
}
body[data-theme="light"] .stats {
  background: var(--bg-light);
  color: var(--text-dark);
}
.feedback {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(90deg,#00ffe5,#8f94fb 80%);
  color: #10122c;
  font-weight: bold;
  padding: 12px 30px;
  border-radius: 100px;
  box-shadow: 0 0 18px #00ffe5cc;
  z-index: 9999;
  font-size: 1.1em;
  animation: feedbackfade 2.6s forwards;
  opacity: 0.98;
  pointer-events: none;
}
@keyframes feedbackfade {
  0% { opacity: 0; transform: translateX(-50%) scale(0.7);}
  10% { opacity: 1; transform: translateX(-50%) scale(1);}
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(0.7);}
}
button:focus-visible,
input:focus-visible {
  outline: 3px solid #a770ef;
  outline-offset: 2px;
}
input.error:focus-visible {
  outline: 3px solid var(--error);
}

/* RESPONSIVE */
@media (max-width: 600px) {
  .splash-content {
    padding: 20px 10px;
    font-size: 0.95em;
  }
  .tab-content {
    padding: 10px;
  }
  .tabs {
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
  }
  .tab-btn {
    width: 100%;
    font-size: 15px;
    border-radius: 8px;
    margin-bottom: 4px;
  }
  .config {
    flex-direction: column;
    gap: 5px;
    align-items: flex-end;
    margin-bottom: 10px;
  }
  .stats {
    font-size: 0.95em;
    padding: 7px;
  }
  #historial {
    max-height: 180px;
    font-size: 0.85em;
  }
  #resultado {
    font-size: 1.1em;
    margin-top: 10px;
  }
}
