/* ============================================================
   CHASH — Finanzas Familiares
   style.css — Diseño premium móvil-first
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:wght@300;400;500&display=swap');

/* --- Variables --- */
:root {
  --bg:           #080d1a;
  --bg-card:      #0f1629;
  --bg-card2:     #141c33;
  --border:       rgba(255,255,255,0.07);
  --accent:       #4f9cf9;
  --accent-glow:  rgba(79,156,249,0.25);
  --pink:         #f97bb0;
  --green:        #4fd1a5;
  --yellow:       #f9c84f;
  --red:          #f97b7b;
  --text:         #e8eaf6;
  --text-muted:   rgba(232,234,246,0.45);
  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --radius:       18px;
  --radius-sm:    10px;
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

/* --- Tema claro --- */
body.light {
  --bg:           #eef1f7;
  --bg-card:      #ffffff;
  --bg-card2:     #e7ebf4;
  --border:       rgba(15,25,50,0.12);
  --accent:       #2f7de0;
  --accent-glow:  rgba(47,125,224,0.2);
  --text:         #16203a;
  --text-muted:   rgba(22,32,58,0.55);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; overscroll-behavior-x: none; overscroll-behavior-y: auto; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* --- Screens --- */
.screen { display: none; height: 100dvh; flex-direction: column; }
.screen.active { display: flex; }

/* ============================================================
   LOGIN
   ============================================================ */
#screen-login {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 40% at 50% -10%, rgba(79,156,249,0.18) 0%, transparent 60%),
    radial-gradient(ellipse 50% 30% at 80% 80%, rgba(249,123,176,0.1) 0%, transparent 60%);
  justify-content: center;
  align-items: center;
  padding: 2rem 1.5rem;
  gap: 2rem;
}

.login-logo {
  text-align: center;
}
.login-logo h1 {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fff 40%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-logo p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.user-cards {
  display: flex;
  gap: 1rem;
  width: 100%;
  max-width: 360px;
}

.user-card {
  flex: 1;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.user-card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.2s;
}
.user-card[data-user="patricio"]::before { background: radial-gradient(circle at 50% 0%, rgba(79,156,249,0.2), transparent 70%); }
.user-card[data-user="tanya"]::before    { background: radial-gradient(circle at 50% 0%, rgba(249,123,176,0.2), transparent 70%); }
.user-card.active::before { opacity: 1; }
.user-card.active { border-color: var(--accent); transform: translateY(-2px); }
.user-card[data-user="tanya"].active { border-color: var(--pink); }

.user-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  margin: 0 auto 0.75rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-display);
}
.user-card[data-user="patricio"] .user-avatar { background: rgba(79,156,249,0.2); color: var(--accent); }
.user-card[data-user="tanya"] .user-avatar    { background: rgba(249,123,176,0.2); color: var(--pink); }

.user-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}
.user-role {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

#pin-section {
  width: 100%;
  max-width: 360px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.3s ease;
}
#pin-section.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.pin-label {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.pin-input-wrap {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

#pin-input {
  flex: 1;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1.5rem;
  font-family: var(--font-display);
  letter-spacing: 0.5em;
  text-align: center;
  padding: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
}
#pin-input:focus { border-color: var(--accent); }
#pin-input.shake { animation: shake 0.4s ease; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60%  { transform: translateX(-8px); }
  40%,80%  { transform: translateX(8px); }
}

.btn-login {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.875rem 1.25rem;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-login:active { transform: scale(0.95); opacity: 0.85; }

#selected-user { display: none; }

/* ============================================================
   APP SCREEN
   ============================================================ */
#screen-app {
  overflow: hidden;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar-logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fff, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.topbar-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-logout:active { background: var(--bg-card); }

/* Contenido principal */
#module-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* Nav inferior */
#main-nav {
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  flex-shrink: 0;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
#main-nav::-webkit-scrollbar { display: none; }

.nav-btn {
  flex: 1;
  min-width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.6rem 0.25rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-body);
  position: relative;
}
.nav-btn::after {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
  transition: width 0.2s;
}
.nav-btn.active { color: var(--accent); }
.nav-btn.active::after { width: 60%; }

.nav-icon { font-size: 1.2rem; }
.nav-label { font-size: 0.62rem; letter-spacing: 0.02em; }

/* ============================================================
   MÓDULO HOGAR — Componentes
   ============================================================ */
.module-header { margin-bottom: 1.25rem; }
.module-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
}
.module-subtitle { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.15rem; }

.cards-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 0.875rem 0.75rem;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.stat-green::before  { background: var(--green); }
.stat-red::before    { background: var(--red); }
.stat-blue::before   { background: var(--accent); }
.stat-yellow::before { background: var(--yellow); }

.stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; margin-top: 0.25rem; }

.who-split { margin-bottom: 1rem; }
.who-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  display: flex;
  gap: 1.5rem;
}
.who-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; }
.who-item strong { margin-left: auto; font-family: var(--font-display); }
.who-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.btn-quick {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-quick:active { transform: scale(0.96); }
.btn-primary   { background: var(--accent); color: #fff; grid-column: span 2; }
.btn-mic       { background: rgba(249,123,176,0.15); color: var(--pink); border: 1px solid rgba(249,123,176,0.3); }
.btn-cam       { background: rgba(249,200,79,0.1); color: var(--yellow); border: 1px solid rgba(249,200,79,0.25); }
.btn-secondary { background: rgba(79,209,165,0.1); color: var(--green); border: 1px solid rgba(79,209,165,0.25); }

.section-title {
  font-family: var(--font-display);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.list-gastos { display: flex; flex-direction: column; gap: 0.5rem; }

.gasto-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

.gasto-cat {
  width: 36px; height: 36px;
  background: var(--bg-card2);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.gasto-info { flex: 1; min-width: 0; }
.gasto-desc { font-size: 0.88rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gasto-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.1rem; }
.gasto-monto { font-family: var(--font-display); font-size: 0.95rem; font-weight: 700; flex-shrink: 0; }

.btn-del {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
  font-size: 0.9rem;
}

/* ============================================================
   QUICK FORM (Modal)
   ============================================================ */
.quick-form { display: flex; flex-direction: column; gap: 1rem; }

.quien-selector {
  display: flex;
  gap: 0.75rem;
}
.quien-btn {
  flex: 1;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-card2);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}
.quien-btn.active { border-color: var(--accent); color: var(--text); background: rgba(79,156,249,0.1); }

.monto-display {
  display: flex;
  align-items: center;
  background: var(--bg-card2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 1rem;
  transition: border-color 0.2s;
}
.monto-display:focus-within { border-color: var(--accent); }
.monto-currency { font-family: var(--font-display); font-size: 1.5rem; color: var(--text-muted); }
.monto-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  padding: 0.75rem 0.5rem;
  outline: none;
  width: 100%;
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.cat-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.6rem 0.25rem;
  background: var(--bg-card2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 1.2rem;
  color: var(--text);
}
.cat-btn small { font-size: 0.65rem; color: var(--text-muted); font-family: var(--font-body); }
.cat-btn.active { border-color: var(--accent); background: rgba(79,156,249,0.1); }
.cat-btn:active { transform: scale(0.93); }

.form-input {
  width: 100%;
  background: var(--bg-card2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.form-input:focus { border-color: var(--accent); }
.form-input option { background: var(--bg-card); }

/* ============================================================
   MODAL
   ============================================================ */
#modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: flex-end;
}
#modal.active { display: flex; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}

.modal-sheet {
  position: relative;
  width: 100%;
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.25rem 1.25rem calc(1.25rem + var(--safe-bottom));
  z-index: 1;
  animation: slideUp 0.3s ease;
  max-height: 92dvh;
  overflow-y: auto;
}

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

.modal-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 1.25rem;
}

#modal-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

#modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.btn-modal-cancel {
  flex: 1;
  padding: 0.875rem;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.95rem;
  cursor: pointer;
}
.btn-modal-ok {
  flex: 2;
  padding: 0.875rem;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-modal-ok:active { opacity: 0.85; }

/* ============================================================
   TOAST
   ============================================================ */
#toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-6rem);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  white-space: nowrap;
  z-index: 999;
  transition: transform 0.3s ease;
  max-width: 90vw;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.toast-success { border-color: var(--green); color: var(--green); }
#toast.toast-error   { border-color: var(--red); color: var(--red); }
#toast.toast-info    { border-color: var(--accent); color: var(--accent); }

/* ============================================================
   MIC PULSE
   ============================================================ */
.mic-pulse {
  font-size: 3rem;
  animation: pulse 1s ease infinite;
  display: inline-block;
}
@keyframes pulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.15); opacity: 0.7; }
}

/* ============================================================
   COMING SOON
   ============================================================ */
.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  gap: 1rem;
}
.coming-icon { font-size: 3.5rem; opacity: 0.4; }
.coming-soon h3 { font-family: var(--font-display); font-size: 1.2rem; color: var(--text-muted); }
.coming-soon p  { font-size: 0.85rem; color: var(--text-muted); max-width: 240px; line-height: 1.5; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
#module-content::-webkit-scrollbar { width: 0; }

/* ============================================================
   FASE 2 — Plantillas, Recurrentes, Métodos de pago
   ============================================================ */

/* Alert banner recurrentes pendientes */
.alert-banner {
  background: rgba(249,200,79,0.1);
  border: 1px solid rgba(249,200,79,0.35);
  color: var(--yellow);
  border-radius: var(--radius-sm);
  padding: .7rem 1rem;
  font-size: .83rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: background .2s;
}
.alert-banner:active { background: rgba(249,200,79,0.18); }

/* Plantillas scroll horizontal */
.plantillas-scroll {
  display: flex;
  gap: .6rem;
  overflow-x: auto;
  padding-bottom: .5rem;
  margin-bottom: 1rem;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.plantillas-scroll::-webkit-scrollbar { display: none; }

.plantilla-chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: .4rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: .5rem 1rem;
  color: var(--text);
  font-size: .82rem;
  font-family: var(--font-body);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.plantilla-chip:active { background: var(--bg-card2); transform: scale(.96); }

.periodo-chip {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 100px;
  padding: .45rem 1rem;
  color: var(--text-muted);
  font-size: .8rem;
  font-family: var(--font-body);
  cursor: pointer;
  white-space: nowrap;
}
.periodo-chip.active { border-color: var(--accent); color: var(--text); background: rgba(79,156,249,0.1); }

.recibo-thumb {
  width: 100%; max-height: 70vh; object-fit: contain; border-radius: var(--radius-sm);
}
.btn-attach {
  display: flex; align-items: center; gap: .5rem;
  background: var(--bg-card2); border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  padding: .65rem .9rem; color: var(--text-muted); font-size: .85rem; font-family: var(--font-body);
  cursor: pointer; width: 100%;
}
.btn-attach.has-file { border-style: solid; border-color: var(--accent); color: var(--text); }
.gasto-recibo-btn {
  background: none; border: none; font-size: 1rem; cursor: pointer; padding: 0 .3rem;
}

.cat-icon-preview-btn {
  flex-shrink: 0; width: 44px; height: 44px; font-size: 1.4rem;
  background: var(--bg-card2); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  cursor: default;
}
.icon-grid {
  display: flex; flex-wrap: wrap; gap: .35rem;
  max-height: 160px; overflow-y: auto;
  margin-top: .5rem; margin-bottom: .75rem;
  padding: .5rem; background: var(--bg-card2); border-radius: var(--radius-sm);
}
.icon-pick-btn {
  width: 38px; height: 38px; font-size: 1.2rem;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; flex-shrink: 0;
}
.icon-pick-btn:active { background: rgba(79,156,249,0.15); border-color: var(--accent); transform: scale(.95); }

.mov-resumen {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .6rem .9rem; margin-bottom: .75rem;
  color: var(--text-muted); font-size: .85rem;
}
.mov-resumen strong { color: var(--text); font-family: var(--font-display); font-size: 1rem; }
.mov-dia-header {
  display: flex; justify-content: space-between; align-items: center;
  margin: 1rem 0 .4rem; padding: 0 .2rem;
  color: var(--text-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em;
}
.mov-dia-header strong { color: var(--text-muted); font-size: .8rem; }
.mov-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; margin-bottom: .6rem;
}
.mov-nav-btn {
  width: 38px; height: 34px; font-size: 1.1rem;
  background: var(--bg-card); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); cursor: pointer; flex-shrink: 0;
}
.mov-nav-btn:disabled { opacity: .3; cursor: default; }
.mov-nav-btn:not(:disabled):active { border-color: var(--accent); }
.mov-nav-label {
  flex: 1; text-align: center;
  font-family: var(--font-display); font-weight: 700; font-size: .95rem; color: var(--text);
}
.chart-monto {
  font-size: .6rem; color: var(--text-muted); text-align: center; margin-top: .1rem;
}
.plantilla-monto {
  background: rgba(79,156,249,0.15);
  color: var(--accent);
  border-radius: 100px;
  padding: .1rem .45rem;
  font-size: .75rem;
  font-family: var(--font-display);
  font-weight: 700;
}
.plantilla-manage {
  border-style: dashed;
  color: var(--text-muted);
}

/* Plantilla row en modal */
.plantilla-row, .recurrente-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--bg-card2);
  border-radius: var(--radius-sm);
  padding: .65rem .75rem;
  border: 1px solid var(--border);
}
.recurrente-inactivo { opacity: .45; }
.plantilla-icon { font-size: 1.2rem; flex-shrink: 0; }
.plantilla-info { flex: 1; min-width: 0; }
.plantilla-nombre { font-size: .88rem; font-weight: 500; }
.plantilla-det { font-size: .72rem; color: var(--text-muted); margin-top: .1rem; }

/* Método de pago picker */
.metodo-picker {
  display: flex;
  gap: .5rem;
}
.metodo-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  padding: .6rem .25rem;
  background: var(--bg-card2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  transition: all .15s;
}
.metodo-btn small { font-size: .65rem; }
.metodo-btn.active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(79,156,249,.1);
}
.metodo-btn:active { transform: scale(.94); }

/* Toggle ON/OFF */
.btn-toggle {
  border: none;
  border-radius: 100px;
  padding: .25rem .6rem;
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-display);
}
.btn-toggle-on  { background: rgba(79,209,165,.2); color: var(--green); }
.btn-toggle-off { background: rgba(255,255,255,.07); color: var(--text-muted); }

/* Botón estrella en modal */
.btn-modal-star {
  padding: .875rem;
  background: rgba(249,200,79,.12);
  border: 1px solid rgba(249,200,79,.3);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  cursor: pointer;
  transition: all .15s;
}
.btn-modal-star:active { background: rgba(249,200,79,.22); }

/* Section title row */
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: .83rem;
  cursor: pointer;
  font-family: var(--font-body);
  padding: 0;
  margin-bottom: 1rem;
}
.btn-link-sm {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .75rem;
  cursor: pointer;
  font-family: var(--font-body);
  padding: 0;
}

/* Categorías extra */
.cat-grid { grid-template-columns: repeat(3, 1fr); }

.btn-sync {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  padding: .35rem .6rem;
  font-size: .9rem;
  cursor: pointer;
  transition: all .2s;
}
.btn-sync:active { background: var(--bg-card); color: var(--accent); }

/* ============================================================
   FASE 4 — Módulo Deudas
   ============================================================ */

.alert-red {
  background: rgba(249,123,123,0.1);
  border-color: rgba(249,123,123,0.35);
  color: var(--red);
}

.deuda-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .875rem;
  margin-bottom: .6rem;
}
.deuda-alerta { border-color: rgba(249,200,79,0.5); }

.deuda-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: .75rem;
}

.deuda-progress-wrap {
  height: 4px;
  background: var(--bg-card2);
  border-radius: 2px;
  margin-bottom: .6rem;
  overflow: hidden;
}
.deuda-progress-bar {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width .4s ease;
}

.deuda-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.text-alerta { color: var(--yellow); font-size: .75rem; }

.form-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.form-label {
  display: block;
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: .3rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Tabla amortización */
.amort-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
}
.amort-table th {
  background: var(--bg-card2);
  padding: .5rem .6rem;
  text-align: right;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.amort-table th:first-child { text-align: left; }
.amort-table td {
  padding: .45rem .6rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
}
.amort-table td:first-child {
  text-align: left;
  font-family: var(--font-body);
  color: var(--text-muted);
}

/* ============================================================
   FASE 5 — Préstamos familiares
   ============================================================ */
.prestamo-saldado {
  border-color: rgba(79,209,165,0.3);
  background: rgba(79,209,165,0.05);
}
.text-green { color: var(--green); }

/* ============================================================
   FASE 6 — Metas y Presupuesto
   ============================================================ */
.presupuesto-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: 1rem;
}
.presupuesto-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .7rem .875rem;
}
.presupuesto-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .88rem;
}
.presupuesto-edit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
}
.presupuesto-edit-row:last-child { border-bottom: none; }
.presupuesto-edit-row label { color: var(--text); }

/* ============================================================
   FASE 7 — Reportes
   ============================================================ */

/* Comparativa mes */
.reporte-comparativa {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1.25rem;
  gap: .5rem;
}
.comp-item { text-align: center; }
.comp-label { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.comp-valor { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; margin-top: .2rem; }
.comp-tendencia {
  text-align: center;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.comp-tendencia small { font-size: .65rem; font-family: var(--font-body); font-weight: 400; }
.tend-sube { color: var(--red); }
.tend-baja { color: var(--green); }
.tend-igual { color: var(--text-muted); }

/* Gráfico barras */
.chart-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem .75rem .5rem;
  margin-bottom: 1.25rem;
}
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 100px;
  margin-bottom: .5rem;
}
.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
}
.chart-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  gap: 1px;
}
.chart-bar-ing {
  flex: 1;
  background: var(--green);
  border-radius: 2px 2px 0 0;
  opacity: .7;
  min-height: 2px;
  transition: height .4s ease;
}
.chart-bar-gas {
  flex: 1;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: height .4s ease;
}
.chart-label {
  font-size: .55rem;
  color: var(--text-muted);
  letter-spacing: .02em;
}
.chart-legend {
  display: flex;
  gap: 1rem;
  justify-content: center;
  font-size: .72rem;
  margin-top: .25rem;
}
.legend-ing { color: var(--green); }
.legend-gas { color: var(--accent); }

/* Top categorías */
.top-cats { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }
.top-cat-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .65rem .875rem;
}
.top-cat-header {
  display: flex;
  justify-content: space-between;
  font-size: .88rem;
  margin-bottom: .4rem;
}

/* Exportar */
.export-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

/* Detalle por mes */
.mes-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .65rem .875rem;
  margin-bottom: .5rem;
}
.mes-nombre { font-size: .85rem; }
.mes-datos { display: flex; gap: .75rem; font-family: var(--font-display); font-size: .78rem; }
.mes-ing { color: var(--green); }
.mes-gas { color: var(--red); }
.bal-pos { color: var(--accent); }
.bal-neg { color: var(--red); }

/* ============================================================
   FASE 8 — Negocios
   ============================================================ */
.negocio-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .875rem;
  margin-bottom: .6rem;
}
.negocio-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: .6rem;
}
.negocio-actions {
  display: flex;
  gap: 1rem;
  border-top: 1px solid var(--border);
  padding-top: .5rem;
}
.text-red { color: var(--red); }
.color-picker {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}
.color-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all .15s;
}
.color-dot.active { border-color: #fff; transform: scale(1.15); }
.loading-spinner {
  text-align: center;
  padding: 3rem;
  font-size: 2rem;
  color: var(--text-muted);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   FASE 9 — Inversiones
   ============================================================ */
.inv-ganancia {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: .9rem;
}
.inv-ganancia-pos { background: rgba(79,209,165,0.1); color: var(--green); border: 1px solid rgba(79,209,165,0.3); }
.inv-ganancia-neg { background: rgba(249,123,123,0.1); color: var(--red);   border: 1px solid rgba(249,123,123,0.3); }
.inv-ganancia strong { font-family: var(--font-display); font-size: 1.1rem; }

.inv-distribucion { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.25rem; }
.inv-dist-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .6rem .875rem;
}
.inv-dist-header { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: .35rem; }

.inv-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .875rem;
  margin-bottom: .6rem;
}
.inv-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: .6rem; }
.inv-card-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); padding-top: .5rem; }
.inv-ticker { font-family: var(--font-display); font-size: 1rem; font-weight: 700; }
.inv-nombre { font-family: var(--font-body); font-size: .85rem; font-weight: 400; color: var(--text-muted); }
.inv-rend { font-family: var(--font-display); font-size: .85rem; font-weight: 700; }
.inv-rend-pos { color: var(--green); }
.inv-rend-neg { color: var(--red); }

/* ============================================================
   FASE 10 — Panel de alertas
   ============================================================ */
.alertas-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.alertas-titulo {
  font-family: var(--font-display);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  padding: .6rem .875rem;
  border-bottom: 1px solid var(--border);
}
.alerta-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .875rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
  font-size: .83rem;
}
.alerta-item:last-child { border-bottom: none; }
.alerta-item:active { background: var(--bg-card2); }
.alerta-texto { flex: 1; }
.alerta-arrow { color: var(--text-muted); font-size: .8rem; }
.alerta-error { border-left: 3px solid var(--red); }
.alerta-warn  { border-left: 3px solid var(--yellow); }
.alerta-info  { border-left: 3px solid var(--accent); }
