:root {
  --blue: #4a90e2;
  --blue-dark: #2c3e50;
  --dark: #1a252f;
  --bg: #f4f7fb;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1a252f;
  --text-soft: #64748b;
  --green: #16a34a;
  --green-bg: #e9f9ee;
  --red: #dc2626;
  --red-bg: #fdeeee;
  --amber-bg: #fff4e0;
  --amber: #b45309;
  --radius: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, .amount-display, .balance-amount, .confirm-amount, .detail-amount {
  font-family: 'Manrope', 'Inter', sans-serif;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.hidden { display: none !important; }

.app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: env(safe-area-inset-bottom);
}

@media (min-width: 460px) {
  body { background: #e6ecf3; }
  .app {
    min-height: 100vh;
    box-shadow: 0 0 40px rgba(26, 37, 47, 0.12);
  }
}

.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  padding: 24px 20px 24px;
  animation: fade-in 0.2s ease;
}
.screen.active { display: flex; }

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Botones ---------- */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 16px;
  padding: 14px 20px;
  transition: transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; }
.btn-lg { padding: 18px 20px; font-size: 17px; min-height: 58px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:disabled { opacity: 0.45; }
.btn-outline { background: #fff; color: var(--blue-dark); border: 2px solid var(--border); }
.btn-text { background: transparent; color: var(--text-soft); font-weight: 600; padding: 10px; }
.btn-danger-text { background: transparent; color: var(--red); border: 2px solid var(--red-bg); background: var(--red-bg); }
.btn-small { background: var(--bg); color: var(--blue-dark); font-size: 14px; padding: 10px 16px; border-radius: 10px; font-weight: 700; white-space: nowrap; }
.link-btn { background: none; border: none; color: var(--blue); font-weight: 700; font-size: 14px; }

/* ---------- Login ---------- */
.login-wrap {
  margin-top: 12vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}
.logo-badge {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--dark);
  color: #fff;
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.login-title { font-size: 30px; font-weight: 800; margin: 0; }
.login-sub { color: var(--text-soft); margin: 0 0 20px; font-size: 16px; }
.demo-banner {
  background: var(--amber-bg);
  color: var(--amber);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 100px;
  margin-bottom: 28px;
}
.login-form { width: 100%; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.login-pin { width: 100%; display: flex; flex-direction: column; }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 20px 0 6px; }
.pin-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
}
.pin-dot.filled { background: var(--blue); border-color: var(--blue); }
.admin-link {
  display: block;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  margin-top: 22px;
}
.home-feria { margin: 2px 0 0; color: var(--text-soft); font-size: 13px; font-weight: 600; }
.coupon-input {
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-family: 'Manrope', sans-serif;
}
.cur-icon { width: 1em; height: 1em; vertical-align: -0.12em; margin-right: 4px; border-radius: 50%; object-fit: cover; }
.field-label { font-size: 14px; font-weight: 600; color: var(--text-soft); margin-left: 4px; }
.text-input {
  width: 100%;
  padding: 16px 16px;
  font-size: 17px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: #fff;
  margin-bottom: 10px;
}
.text-input:focus { outline: none; border-color: var(--blue); }

/* ---------- Home ---------- */
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.home-greeting { margin: 0; color: var(--text-soft); font-size: 15px; }
.home-name { margin: 0; font-size: 24px; font-weight: 800; }
.icon-btn { background: none; border: none; padding: 0; }
.avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px;
  font-family: 'Manrope', sans-serif;
}
.avatar-lg { width: 76px; height: 76px; font-size: 30px; }

.balance-card {
  background: linear-gradient(135deg, var(--dark), var(--blue-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 22px;
}
.balance-top { display: flex; align-items: center; justify-content: space-between; }
.balance-label { font-size: 14px; opacity: 0.8; font-weight: 600; }
.eye-btn { background: rgba(255,255,255,0.12); border: none; color: #fff; padding: 8px; border-radius: 10px; display: flex; }
.balance-amount { font-size: 38px; font-weight: 800; margin: 10px 0 0; letter-spacing: -0.5px; }

.actions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 26px;
}
.action-card {
  background: var(--card);
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 6px rgba(26,37,47,0.06);
}
.action-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.action-icon-blue { background: #e5f0fc; color: var(--blue); }
.action-icon-green { background: var(--green-bg); color: var(--green); }
.action-icon-amber { background: var(--amber-bg); color: var(--amber); }
.action-icon-slate { background: #eef1f5; color: var(--blue-dark); }
.action-label { font-size: 13px; font-weight: 700; color: var(--text); }

.section-block { flex: 1; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-title { font-size: 16px; font-weight: 800; margin: 0; }

/* ---------- Movimientos ---------- */
.movements-list { display: flex; flex-direction: column; gap: 10px; }
.movement-row {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: none;
  width: 100%;
  text-align: left;
  box-shadow: 0 1px 3px rgba(26,37,47,0.05);
}
.movement-icon {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.movement-icon.in { background: var(--green-bg); color: var(--green); }
.movement-icon.out { background: var(--red-bg); color: var(--red); }
.movement-body { flex: 1; min-width: 0; }
.movement-name { font-weight: 700; font-size: 15px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.movement-date { font-size: 13px; color: var(--text-soft); margin: 2px 0 0; }
.movement-amount { font-weight: 800; font-size: 15px; white-space: nowrap; }
.movement-amount.in { color: var(--green); }
.movement-amount.out { color: var(--red); }
.empty-text { text-align: center; color: var(--text-soft); margin-top: 40px; font-size: 15px; }

.bottom-nav {
  display: flex;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--bg);
}
.nav-item {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 0;
}
.nav-item.active { color: var(--blue); }

/* ---------- Flujos (enviar / cargar / recibir / etc) ---------- */
.flow-header { display: flex; flex-direction: column; margin-bottom: 20px; }
.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--blue-dark);
  font-weight: 700;
  font-size: 15px;
  padding: 8px 0;
  align-self: flex-start;
  margin-left: -4px;
}
.flow-title { font-size: 22px; font-weight: 800; margin: 6px 0 0; }
.flow-hint { color: var(--text-soft); font-size: 15px; margin: 0 0 18px; }

/* Contactos */
.contact-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.contact-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px;
  width: 100%;
  text-align: left;
  box-shadow: 0 1px 3px rgba(26,37,47,0.05);
}
.contact-name { font-weight: 700; font-size: 15px; margin: 0; }
.contact-alias { font-size: 13px; color: var(--text-soft); margin: 1px 0 0; }
.new-contact-form { margin-top: 16px; display: flex; flex-direction: column; }

/* Monto / teclado */
.amount-display {
  text-align: center;
  font-size: 46px;
  font-weight: 800;
  margin: 10px 0 4px;
  letter-spacing: -1px;
}
.amount-error { text-align: center; color: var(--red); font-size: 14px; font-weight: 600; min-height: 20px; margin: 0 0 6px; }
.quick-chips { display: flex; gap: 8px; justify-content: center; margin-bottom: 18px; flex-wrap: wrap; }
.chip {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 100px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 14px;
  color: var(--blue-dark);
}
.chip.selected { border-color: var(--blue); color: var(--blue); background: #eaf2fc; }

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
  flex: 1;
  align-content: center;
}
.key {
  background: #fff;
  border: none;
  border-radius: 14px;
  font-size: 22px;
  font-weight: 700;
  padding: 16px 0;
  box-shadow: 0 1px 3px rgba(26,37,47,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}
.key:active { background: #eef2f6; }
.key-del { color: var(--red); }

/* Confirmar */
.confirm-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(26,37,47,0.06);
}
.confirm-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.confirm-icon-blue { background: #e5f0fc; color: var(--blue); }
.confirm-icon-amber { background: var(--amber-bg); color: var(--amber); }
.confirm-text { font-size: 16px; color: var(--text-soft); margin: 0; }
.confirm-amount { font-size: 34px; font-weight: 800; margin: 8px 0; }
.confirm-note { font-size: 13px; color: var(--text-soft); margin: 0; }

/* Éxito */
.success-wrap {
  margin: auto 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.success-icon {
  width: 90px; height: 90px;
  border-radius: 50%;
  background: var(--green-bg);
  color: var(--green);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.success-title { font-size: 26px; font-weight: 800; margin: 0; }
.success-text { color: var(--text-soft); font-size: 16px; margin: 8px 0 30px; max-width: 300px; }

/* Recibir */
.qr-wrap {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
  box-shadow: 0 2px 8px rgba(26,37,47,0.06);
}
.receive-data { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.receive-row {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 1px 3px rgba(26,37,47,0.05);
}
.receive-label { display: block; font-size: 12px; color: var(--text-soft); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.receive-value { display: block; font-size: 16px; font-weight: 700; margin-top: 2px; }

/* Detalle movimiento */
.detail-card { text-align: center; margin-top: 20px; }
.detail-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.detail-amount { font-size: 32px; font-weight: 800; margin: 0; }
.detail-title { color: var(--text-soft); font-size: 16px; margin: 6px 0 24px; }
.detail-info { background: var(--card); border-radius: var(--radius-sm); padding: 6px 16px; box-shadow: 0 1px 3px rgba(26,37,47,0.05); }
.detail-info-row { display: flex; justify-content: space-between; padding: 14px 0; font-size: 15px; }
.detail-info-row:not(:last-child) { border-bottom: 1px solid var(--border); }
.detail-info-row span:first-child { color: var(--text-soft); font-weight: 600; }
.detail-info-row span:last-child { font-weight: 700; }
.detail-status { color: var(--green) !important; }

/* Perfil */
.profile-card { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 24px; }
.profile-name { font-size: 22px; font-weight: 800; margin: 10px 0 0; }
.profile-sub { color: var(--text-soft); font-size: 14px; margin: 0; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--dark);
  color: #fff;
  padding: 12px 20px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 999;
  max-width: 90%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
