/* ============================================
   SISTEMA DE PRÉSTAMOS - TEMA FUTURISTA
   Paleta: base espacial profunda + acentos cian/violeta
   + ámbar para datos financieros (monospace)
   ============================================ */

:root {
  --bg-void: #070a14;
  --bg-panel: #0f1424;
  --bg-panel-2: #151c33;
  --border-soft: rgba(123, 97, 255, 0.18);
  --border-strong: rgba(0, 229, 199, 0.35);

  --text-main: #e8ecf7;
  --text-dim: #8a91ab;
  --text-faint: #565d78;

  --cian: #00e5c7;
  --violeta: #7b61ff;
  --ambar: #ffb020;
  --rojo: #ff5470;
  --verde: #2ee6a6;

  --grad-signature: linear-gradient(135deg, var(--cian) 0%, var(--violeta) 100%);
  --grad-glow: radial-gradient(circle at top right, rgba(123, 97, 255, 0.25), transparent 60%);
  --overlay-fondo: rgba(4, 6, 14, 0.75);
  --nav-fondo: rgba(15, 20, 36, 0.9);
  --texto-sobre-acento: #06111a;

  --radius: 16px;
  --radius-sm: 10px;
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

/* ===== MODO CLARO ===== */
[data-tema="claro"] {
  --bg-void: #f3f5fb;
  --bg-panel: #ffffff;
  --bg-panel-2: #eef1f9;
  --border-soft: rgba(123, 97, 255, 0.16);
  --border-strong: rgba(0, 168, 150, 0.4);

  --text-main: #12162a;
  --text-dim: #5b6178;
  --text-faint: #9aa0b8;

  --cian: #00a693;
  --violeta: #6d4fe0;
  --ambar: #b8790f;
  --rojo: #d63958;
  --verde: #16a476;

  --grad-glow: radial-gradient(circle at top right, rgba(123, 97, 255, 0.10), transparent 60%);
  --overlay-fondo: rgba(20, 22, 35, 0.45);
  --nav-fondo: rgba(255, 255, 255, 0.85);
  --texto-sobre-acento: #ffffff;
}

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

html {
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg-void);
  background-image: var(--grad-glow);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 90px; /* espacio para nav inferior mobile */
  transition: background-color 0.25s ease, color 0.25s ease;
}

.card, .stat, .item-lista, .campo input, .campo select, .campo textarea,
.nav-inferior, .modal-box, .btn-secundario, .tab {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--violeta); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== TIPOGRAFÍA ===== */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.mono { font-family: var(--font-mono); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cian);
}

/* ===== LAYOUT BASE ===== */
.pantalla {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 16px;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.topbar .marca {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-orbe {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  object-fit: contain;
  padding: 2px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.topbar h1 { font-size: 17px; }
.topbar .sub { font-size: 11px; color: var(--text-dim); }

/* ===== TARJETAS ===== */
.card {
  background: linear-gradient(180deg, var(--bg-panel) 0%, var(--bg-panel-2) 100%);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  padding: 1px;
  background: linear-gradient(135deg, rgba(0,229,199,0.25), transparent 40%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.card-glow {
  border: 1px solid var(--border-strong);
  box-shadow: 0 0 30px rgba(0, 229, 199, 0.08);
}

/* ===== KPI / STAT ===== */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.stat .valor {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--cian);
}

.stat .etiqueta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ===== BOTONES ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }

.btn-primario {
  background: var(--grad-signature);
  color: var(--texto-sobre-acento);
  box-shadow: 0 6px 20px rgba(0, 229, 199, 0.25);
}

.btn-secundario {
  background: var(--bg-panel-2);
  color: var(--text-main);
  border: 1px solid var(--border-soft);
}

.btn-whatsapp {
  background: #1fae5c;
  color: #fff;
}

.btn-peligro {
  background: rgba(255, 84, 112, 0.12);
  color: var(--rojo);
  border: 1px solid rgba(255, 84, 112, 0.35);
}

.btn-sm { padding: 9px 12px; font-size: 12.5px; width: auto; }
.btn-icono { width: 38px; height: 38px; border-radius: 10px; padding: 0; flex-shrink: 0; }

/* ===== FORMULARIOS ===== */
.campo { margin-bottom: 14px; }

.campo label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
}

.campo input,
.campo select,
.campo textarea {
  width: 100%;
  background: var(--bg-void);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease;
}

.campo input:focus,
.campo select:focus,
.campo textarea:focus {
  border-color: var(--cian);
  box-shadow: 0 0 0 3px rgba(0, 229, 199, 0.12);
}

.campo-fila { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ===== INPUT DE CONTRASEÑA CON OJITO ===== */
.input-clave-wrap { position: relative; }
.input-clave-wrap input { padding-right: 46px; }
.btn-ojo {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
.btn-ojo:active { color: var(--cian); }

.link-recuperar {
  display: block;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
  text-decoration: none;
  margin-top: 14px;
}
.link-recuperar span { color: var(--cian); font-weight: 600; }

/* ===== LISTAS ===== */
.item-lista {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--grad-signature);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--texto-sobre-acento);
  flex-shrink: 0;
}

.item-lista .info { flex: 1; min-width: 0; }
.item-lista .info .nombre { font-size: 14px; font-weight: 600; }
.item-lista .info .detalle { font-size: 12px; color: var(--text-dim); }

/* ===== BADGES / ESTADOS ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.badge-pendiente { background: rgba(255, 176, 32, 0.12); color: var(--ambar); }
.badge-pagada { background: rgba(46, 230, 166, 0.12); color: var(--verde); }
.badge-vencida { background: rgba(255, 84, 112, 0.12); color: var(--rojo); }
.badge-activo { background: rgba(0, 229, 199, 0.12); color: var(--cian); }
.badge-inactivo { background: rgba(138, 145, 171, 0.12); color: var(--text-dim); }

/* ===== NAV INFERIOR (MOBILE) ===== */
.nav-inferior {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--nav-fondo);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-around;
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-faint);
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 10px;
  transition: color 0.15s ease;
}

.nav-item svg { width: 20px; height: 20px; stroke: currentColor; }
.nav-item.activo { color: var(--cian); }

/* ===== LOGIN ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
  max-width: 420px;
  margin: 0 auto;
}

.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  object-fit: contain;
  padding: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  box-shadow: 0 0 40px rgba(0, 229, 199, 0.25);
  margin: 0 auto 20px;
  display: block;
}

.login-titulo { text-align: center; font-size: 22px; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 32px; }

/* ===== VACÍO / EMPTY STATE ===== */
.vacio {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-dim);
}

.vacio .icono-vacio {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  opacity: 0.4;
}

.vacio h3 { font-size: 15px; color: var(--text-main); margin-bottom: 6px; }
.vacio p { font-size: 13px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-fondo);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.abierto { display: flex; }

.modal-box {
  background: var(--bg-panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  animation: subir 0.25s ease;
}

@keyframes subir {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-cerrar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-void);
  border: 1px solid var(--border-soft);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
}

/* ===== FAB ===== */
.fab {
  position: fixed;
  bottom: 88px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--grad-signature);
  box-shadow: 0 8px 24px rgba(0, 229, 199, 0.35);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--texto-sobre-acento);
  cursor: pointer;
  z-index: 90;
  transition: transform 0.15s ease;
}

.fab:active { transform: scale(0.92); }

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  white-space: nowrap;
}

.tab.activo {
  background: var(--grad-signature);
  color: var(--texto-sobre-acento);
  border-color: transparent;
}

/* ===== UTILIDADES ===== */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-8 { margin-top: 8px; }
.mt-14 { margin-top: 14px; }
.mb-8 { margin-bottom: 8px; }
.text-dim { color: var(--text-dim); }
.text-cian { color: var(--cian); }
.text-ambar { color: var(--ambar); }
.text-rojo { color: var(--rojo); }
.text-verde { color: var(--verde); }
.text-sm { font-size: 12.5px; }
.text-center { text-align: center; }
.oculto { display: none !important; }
.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--border-soft);
  border-top-color: var(--cian);
  border-radius: 50%;
  animation: girar 0.7s linear infinite;
  margin: 0 auto;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* ===== TOASTS ===== */
#toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 460px;
}

.toast {
  background: var(--bg-panel-2);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--cian);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.25s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { border-left-color: var(--rojo); }
.toast-exito { border-left-color: var(--verde); }

@media (min-width: 640px) {
  .campo-fila { grid-template-columns: 1fr 1fr; }
}
