:root {
  --bg: #14212c;
  --bg2: #1b2a38;
  --card: #1f303f;
  --card2: #27394a;
  --line: #32485c;
  --text: #eaf1f2;
  --muted: #8fa3af;
  --primary: #2f9e8d;      /* teal Gatodico */
  --primary-d: #26806f;
  --green: #34c9a3;
  --red: #ff6b6b;
  --amber: #f2b53b;
  --violet: #e6b84e;       /* dorado (moneda) */
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overscroll-behavior-y: none;
}

.screen { min-height: 100vh; }
.hidden { display: none !important; }

/* ---------- AUTH ---------- */
#auth {
  display: flex; align-items: center; justify-content: center;
  padding: 24px; min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, #1d3b3a, var(--bg));
}
.logo-img {
  width: 96px; height: 96px; border-radius: 24px; margin-bottom: 12px;
  object-fit: cover;
}
.auth-box {
  width: 100%; max-width: 360px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 32px 24px; text-align: center;
}
.auth-box .logo { font-size: 48px; margin-bottom: 8px; }
.auth-box h1 { font-size: 26px; margin-bottom: 4px; }
.auth-box .sub { color: var(--muted); margin-bottom: 24px; font-size: 14px; }
.auth-box input { margin-bottom: 12px; }

input, select {
  width: 100%; padding: 14px 16px;
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 12px; color: var(--text); font-size: 16px;
  outline: none;
}
input:focus, select:focus { border-color: var(--primary); }

button {
  width: 100%; padding: 14px; border: none; border-radius: 12px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: transform .06s, opacity .2s;
}
button:active { transform: scale(0.98); }
.primary { background: var(--primary); color: #fff; }
.primary:active { background: var(--primary-d); }
.ghost { background: transparent; color: var(--muted); }
.danger { background: var(--red); color: #fff; }
.logout { width: auto; padding: 8px 14px; background: var(--card2); color: var(--muted); font-size: 13px; }

.error {
  background: rgba(255,92,114,.15); color: var(--red);
  border: 1px solid rgba(255,92,114,.3);
  padding: 10px; border-radius: 10px; margin-bottom: 12px; font-size: 14px;
}

/* ---------- TOPBAR ---------- */
#app { padding: 16px 16px 100px; max-width: 640px; margin: 0 auto; }
.topbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 8px 0 16px;
}
.hello { font-size: 14px; color: var(--muted); }
.month-nav { display: flex; align-items: center; gap: 12px; margin-top: 2px; }
.month-nav button {
  width: 32px; height: 32px; padding: 0; border-radius: 8px;
  background: var(--card2); color: var(--text); font-size: 20px; line-height: 1;
}
.month-nav span { font-size: 18px; font-weight: 700; min-width: 130px; text-align: center; text-transform: capitalize; }

/* ---------- CARDS ---------- */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.card-label { font-size: 13px; color: var(--muted); }
.card-value { font-size: 22px; font-weight: 700; }
.card.income .card-value { color: var(--green); }
.card.expense .card-value { color: var(--red); }
.card.available .card-value { color: var(--primary); }
.card.savings .card-value { color: var(--violet); }

/* ---------- PROGRESS ---------- */
.progress-wrap {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 20px;
}
.progress-labels { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.progress-labels b { color: var(--text); }
.progress-bar { height: 10px; background: var(--bg2); border-radius: 6px; overflow: hidden; }
#progressFill { height: 100%; width: 0; background: linear-gradient(90deg, var(--green), #27d17f); transition: width .4s; }
.total-final { margin-top: 12px; font-size: 14px; color: var(--muted); text-align: center; }
.total-final b { color: var(--violet); font-size: 16px; }

/* ---------- SECTION ---------- */
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.section-head h2 { font-size: 18px; }
.hint { font-size: 12px; color: var(--muted); }

/* botones de gasto exprés */
.quick-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 24px;
}
.quick-btn {
  width: auto; padding: 12px 4px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--text);
}
.quick-btn:active { background: var(--card2); border-color: var(--primary); }
.q-icon { font-size: 24px; line-height: 1; }
.q-label { font-size: 11px; color: var(--muted); font-weight: 500; }
@media (max-width: 380px) { .quick-grid { grid-template-columns: repeat(3, 1fr); } }
.head-actions { display: flex; gap: 8px; }
.mini { width: auto; padding: 8px 12px; font-size: 12px; background: var(--card2); color: var(--text); font-weight: 500; }

/* ---------- EXPENSE LIST ---------- */
.expense-list { display: flex; flex-direction: column; gap: 10px; }
.exp {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px;
}
.exp.paid { opacity: .55; }
.exp-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  background: var(--bg2);
}
.exp-main { flex: 1; min-width: 0; }
.exp-icon.plain { background: transparent; }
.exp-icon.plain .bank-badge { width: 40px; height: 40px; font-size: 18px; }
.exp-title { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.card-logo { height: 16px; width: auto; background: #fff; border-radius: 3px; padding: 2px 4px; }
.exp-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.exp-right { text-align: right; flex-shrink: 0; }
.exp-amount { font-weight: 700; font-size: 16px; }
.exp-badge { display: inline-block; font-size: 10px; padding: 2px 7px; border-radius: 20px; margin-top: 4px; }
.badge-paid { background: rgba(46,204,113,.18); color: var(--green); }
.badge-pending { background: rgba(255,176,32,.18); color: var(--amber); }
.tag-recurring { font-size: 10px; color: var(--primary); }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; line-height: 1.6; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 20px; bottom: 24px;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 32px; line-height: 1;
  box-shadow: 0 8px 24px rgba(47,158,141,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}

/* ---------- MODAL ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-box {
  width: 100%; max-width: 480px;
  background: var(--card); border-top-left-radius: 24px; border-top-right-radius: 24px;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto;
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-box h3 { margin-bottom: 16px; font-size: 20px; }
.modal-box label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.checks { display: flex; gap: 20px; margin: 18px 0 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); margin: 0; }
.check input { width: auto; }
/* chips de banco */
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  width: auto; display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px 7px 8px; border-radius: 20px;
  background: var(--bg2); border: 1px solid var(--line);
  color: var(--text); font-size: 13px; font-weight: 500;
}
.chip.active { border-color: var(--primary); background: rgba(79,124,255,.15); }
.bank-badge {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700;
}
/* logos de tarjeta */
.logo-row { display: flex; flex-wrap: wrap; gap: 10px; }
.logo-chip {
  width: auto; padding: 8px 12px; border-radius: 12px;
  background: #fff; border: 2px solid transparent;
  display: flex; align-items: center; justify-content: center;
}
.logo-chip.active { border-color: var(--primary); }
.logo-chip img { height: 22px; width: auto; display: block; }

/* cuotas: campos en el modal de gasto */
.check-row { margin: 16px 0 4px; }
.cuotas-row { display: flex; gap: 12px; }
.cuotas-row > div { flex: 1; }
.cuota-preview { margin-top: 10px; font-size: 14px; color: var(--primary); text-align: center; }
.cuota-preview b { color: var(--text); }

/* cuotas: tarjetas de la lista de cuotas activas */
.installments-list { display: flex; flex-direction: column; gap: 14px; max-height: 60vh; overflow-y: auto; }
.inst-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.inst-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.inst-title { display: flex; gap: 10px; align-items: center; }
.inst-name { font-weight: 600; font-size: 15px; }
.inst-meta { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.inst-del { width: auto; background: transparent; padding: 4px; font-size: 16px; }
.inst-numbers { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin: 8px 0; }
.inst-numbers b { color: var(--text); }
.inst-card .progress-bar { height: 8px; }
.inst-card .progress-bar div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--green)); border-radius: 6px; }
.inst-range { font-size: 12px; color: var(--muted); text-align: center; margin-top: 8px; }

.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.modal-actions button { flex: 1; }
@media (min-width: 520px) { .modal { align-items: center; } .modal-box { border-radius: 24px; } }
