/* ── Reset & Variables ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #020617;
  --navy:    #020617;    /* kept for JS compat */
  --navy2:   #0F172A;
  --navy3:   #1E293B;
  --gold:    #22C55E;    /* repurposed: was gold accent, now green CTA/positive */
  --gold2:   #16A34A;    /* darker green hover */
  --white:   #F8FAFC;
  --muted:   #94A3B8;
  --danger:  #EF4444;
  --warn:    #F59E0B;
  --ok:      #22C55E;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-head: 'IBM Plex Sans', system-ui, sans-serif;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
  --transition: .2s ease;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ─────────────────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; line-height: 1.2; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
a { color: var(--gold); text-decoration: none; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
  width: 220px;
  background: var(--navy2);
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 0 24px 28px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-logo h1 {
  font-size: 1.4rem;
  color: var(--white);
  letter-spacing: .5px;
}
.sidebar-logo span { font-family: var(--font-body); font-size: .75rem; color: var(--muted); }

nav { margin-top: 16px; flex: 1; }

nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 24px;
  color: var(--muted);
  font-size: .92rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  border-left: 3px solid transparent;
}
nav a:hover { color: var(--white); background: rgba(34,197,94,0.06); }
nav a.active { color: var(--ok); border-left-color: var(--ok); background: rgba(34,197,94,0.08); }

nav a svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: .78rem;
  color: var(--muted);
}

/* ── Main content ────────────────────────────────────────────────────────── */
#main {
  margin-left: 220px;
  flex: 1;
  padding: 32px;
  max-width: 1100px;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--navy2);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-sm { padding: 16px; }

/* ── Grid helpers ────────────────────────────────────────────────────────── */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }

/* ── Franja cards ────────────────────────────────────────────────────────── */
.franja-card {
  background: var(--navy2);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 20px;
}
.franja-card .label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.franja-card .name { font-family: var(--font-head); font-size: 1.25rem; margin: 2px 0 12px; font-weight: 600; }
.franja-card .amounts { display: flex; justify-content: space-between; font-size: .88rem; margin-bottom: 8px; }
.franja-card .spent { color: var(--white); font-weight: 600; }
.franja-card .limit { color: var(--muted); }

/* ── Progress bar ────────────────────────────────────────────────────────── */
.progress-track {
  height: 8px;
  background: rgba(255,255,255,.08);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .5s ease;
}
.progress-fill.ok     { background: var(--ok); }
.progress-fill.warn   { background: var(--warn); }
.progress-fill.danger { background: var(--danger); }
.progress-fill.gold   { background: var(--gold); }

.franja-pct { font-size: .78rem; margin-top: 6px; color: var(--muted); }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid;
}
.alert-item.warning  { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.25); }
.alert-item.critical { background: rgba(239,68,68,0.08);  border-color: rgba(239,68,68,0.25); }
.alert-item.info     { background: rgba(34,197,94,0.08);  border-color: rgba(34,197,94,0.25); }
.alert-icon { font-size: 1.1rem; margin-top: 2px; }
.alert-msg  { font-size: .88rem; line-height: 1.5; }
.alert-advice { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.alert-dismiss { margin-left: auto; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; transition: color var(--transition); }
.alert-dismiss:hover { color: var(--white); }

/* ── Transactions table ──────────────────────────────────────────────────── */
.tx-table { width: 100%; border-collapse: collapse; }
.tx-table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); padding: 0 12px 10px; }
.tx-table td { padding: 11px 12px; border-top: 1px solid rgba(255,255,255,.05); font-size: .9rem; }
.tx-table tr:hover td { background: rgba(255,255,255,.03); }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: .73rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge.necesidades { background: rgba(59,130,246,0.15);  color: #60A5FA; }
.badge.gustos      { background: rgba(168,85,247,0.15);  color: #C084FC; }
.badge.ahorro      { background: rgba(34,197,94,0.15);   color: var(--ok); }
.badge.review      { background: rgba(239,68,68,0.15);   color: var(--danger); }
.badge.ingreso     { background: rgba(34,197,94,0.12);   color: var(--ok); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px;
  font-family: var(--font-body); font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition); border: none;
}
.btn-primary   { background: var(--gold); color: var(--bg); }
.btn-primary:hover { background: var(--gold2); }
.btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.25);
}
.btn-ghost     { background: transparent; color: var(--muted); border: 1px solid rgba(255,255,255,.12); }
.btn-ghost:hover   { color: var(--white); border-color: rgba(255,255,255,.3); }
.btn-ghost:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.25);
}
.btn-danger    { background: rgba(239,68,68,.15); color: var(--danger); border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover  { background: rgba(239,68,68,.25); }
.btn-danger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.25);
}
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Form elements ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.form-group input, .form-group select {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid var(--color-border);
  border-radius: 0;
  color: var(--color-text);
  padding: 10px 0 10px 0;
  font-family: var(--font-body);
  font-size: .92rem;
  transition: border-color var(--transition);
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-bottom-color: var(--color-accent);
  box-shadow: none;
}
.form-group input::placeholder { color: var(--color-text-secondary); opacity: 0.7; }

/* ── Connection status ───────────────────────────────────────────────────── */
.conn-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--navy2);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
}
.conn-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.conn-icon.gmail { background: rgba(234,67,53,.15); }
.conn-icon.mp    { background: rgba(0,158,226,.15); }
.conn-info { flex: 1; }
.conn-info .conn-name { font-weight: 600; font-size: .95rem; }
.conn-info .conn-status { font-size: .8rem; }
.conn-info .conn-status.connected { color: var(--ok); }
.conn-info .conn-status.disconnected { color: var(--muted); }

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 { color: var(--white); }

/* ── Search / filter bar ─────────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.filter-bar input, .filter-bar select {
  background: var(--navy2);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  color: var(--white);
  padding: 8px 14px;
  font-size: .88rem;
  font-family: var(--font-body);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.filter-bar input:focus, .filter-bar select:focus {
  outline: none;
  border-color: var(--ok);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.25);
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.72);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--navy2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 32px;
  width: 420px;
  max-width: 95vw;
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal h3 { color: var(--white); margin-bottom: 20px; }

/* ── Stat pill ───────────────────────────────────────────────────────────── */
.stat-pill {
  background: var(--navy3);
  border-radius: 8px;
  padding: 10px 16px;
  display: flex; align-items: center; gap: 10px;
}
.stat-pill .val { font-size: 1.2rem; font-weight: 700; color: var(--white); }
.stat-pill .lbl { font-size: .75rem; color: var(--muted); }

/* ── Onboarding (página completa, dos columnas como el login) ─────────────── */
#onboarding-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex;
  z-index: 999;
}
.onboarding-info {
  flex: 1;
  display: flex; flex-direction: column; justify-content: center;
  padding: 60px;
  background: var(--bg);
}
.onboarding-form-wrap {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 48px 60px;
  overflow-y: auto;
}
.onboarding-box {
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
  width: 100%;
  max-width: 440px;
}
.onboarding-box h1 { color: var(--white); margin-bottom: 6px; }
.onboarding-box p  { color: var(--muted); margin-bottom: 28px; font-size: .93rem; }
@media (max-width: 860px) {
  .onboarding-info { display: none; }
  .onboarding-form-wrap { padding: 40px 24px; align-items: flex-start; }
}
@media (max-width: 480px) {
  .onboarding-form-wrap { padding: 28px 16px; }
  .auth-form-wrap { padding: 28px 16px; }
}
.pct-row { display: flex; gap: 12px; }
.pct-row .form-group { flex: 1; }
.pct-hint { font-size: .78rem; color: var(--muted); margin-top: -10px; margin-bottom: 16px; }

/* ── Section titles ──────────────────────────────────────────────────────── */
.section-title {
  font-size: .78rem; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin-bottom: 14px;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--navy2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: .88rem;
  box-shadow: var(--shadow);
  transform: translateY(80px);
  opacity: 0;
  transition: all .3s ease;
  z-index: 1000;
  max-width: 320px;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { border-color: rgba(34,197,94,0.4); }
#toast.error   { border-color: rgba(239,68,68,0.4); }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty svg { opacity: .25; margin-bottom: 12px; }

/* ── Divider ─────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid rgba(255,255,255,.07); margin: 20px 0; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
#hamburger { display: none; }

@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.open { transform: translateX(0); }
  #main { margin-left: 0; padding: 16px; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  #hamburger {
    display: flex; position: fixed; top: 12px; left: 12px;
    z-index: 200; background: var(--navy2);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px; padding: 8px; cursor: pointer;
    color: var(--white); align-items: center; justify-content: center;
  }
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--navy3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--navy3); }

/* ── Loading spinner ─────────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(34,197,94,0.15);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Inline sync indicator ───────────────────────────────────────────────── */
.sync-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .75rem; color: var(--muted); padding: 4px 10px;
  background: rgba(255,255,255,.04); border-radius: 99px;
}

/* ── Summary metrics (dashboard) ────────────────────────────────────────── */
.summary-metrics {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.metric-box {
  flex: 1;
  min-width: 130px;
  padding: 16px;
  border-radius: 12px;
  background: var(--navy2);
  border: 1px solid rgba(255,255,255,.06);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.metric-value { font-size: 22px; font-weight: 700; }
.metric-box.income .metric-value { color: var(--ok); }
.metric-box.expense .metric-value { color: var(--danger); }
.metric-box.positive .metric-value { color: var(--ok); }
.metric-box.negative .metric-value { color: var(--danger); }
.metric-box.pending .metric-value { color: var(--warn); }

/* Chat screen */
.chat-bubble-user {
  align-self: flex-end;
  background: var(--gold);
  color: var(--bg);
  border-radius: 14px 14px 4px 14px;
  padding: 12px 16px;
  max-width: 80%;
  font-size: .88rem;
  line-height: 1.55;
}
.chat-bubble-assistant {
  align-self: flex-start;
  background: var(--navy2);
  color: var(--white);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 14px 14px 14px 4px;
  padding: 12px 16px;
  max-width: 80%;
  font-size: .88rem;
  line-height: 1.55;
}

/* ─── Auth (login / registro) ───────────────────────────────────────────── */
#auth-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex;
  background: var(--color-bg);
  padding: 0;
}
.auth-info {
  flex: 1;
  display: flex; flex-direction: column; justify-content: center;
  padding: 60px;
  background: var(--color-bg);
}
.auth-form-wrap {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 60px;
  background: var(--color-bg);
  overflow-y: auto;
}
.auth-box {
  width: 100%; max-width: 400px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  box-shadow: none;
  padding: 36px 32px;
}
.auth-brand h1 { color: var(--color-accent); font-size: 1.6rem; letter-spacing: -.02em; }
.auth-brand p  { color: var(--color-text-secondary); font-size: .9rem; margin: 6px 0 24px; }
.auth-tabs {
  display: flex; gap: 4px; margin-bottom: 22px;
  background: transparent; border: 1px solid var(--color-border);
  border-radius: 10px; padding: 4px;
}
.auth-tabs button {
  flex: 1; padding: 9px 0; border: 0; border-radius: 8px;
  background: transparent; color: var(--color-text-secondary);
  font-family: inherit; font-size: .88rem; font-weight: 600; cursor: pointer;
  transition: var(--transition);
}
.auth-tabs button.active { background: var(--color-border); color: var(--color-text); }
.auth-submit { width: 100%; justify-content: center; padding: 13px; margin-top: 6px; }
@media (max-width: 860px) {
  .auth-info { display: none; }
  .auth-form-wrap { padding: 40px 24px; }
}
@media (max-width: 480px) {
  .auth-form-wrap { padding: 28px 16px; }
}

/* ─── Notificaciones (campana + panel) ──────────────────────────────────── */
.bell-btn, .logout-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 9px 10px; margin-bottom: 4px;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); font-family: inherit; font-size: .82rem;
  cursor: pointer; transition: var(--transition); text-align: left;
}
.bell-btn:hover, .logout-btn:hover { background: var(--navy3); color: var(--white); }
.bell-badge {
  margin-left: auto; min-width: 18px; text-align: center;
  background: var(--danger); color: #fff;
  font-size: .65rem; font-weight: 700; border-radius: 99px; padding: 1px 6px;
}
.notif-panel {
  position: fixed; left: 230px; bottom: 20px; z-index: 90;
  width: 340px; max-height: 60vh; overflow-y: auto;
  background: var(--navy2); border: 1px solid var(--navy3);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.notif-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--navy3);
  color: var(--white); position: sticky; top: 0; background: var(--navy2);
}
.notif-header button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; }
.notif-item { padding: 14px 16px; border-bottom: 1px solid var(--navy3); }
.notif-item.critical { border-left: 3px solid var(--danger); }
.notif-item.warning  { border-left: 3px solid var(--warn); }
.notif-msg    { color: var(--white); font-size: .86rem; }
.notif-advice { color: var(--muted); font-size: .8rem; margin-top: 6px; font-style: italic; }
.notif-dismiss {
  margin-top: 8px; background: none; border: 1px solid var(--navy3);
  border-radius: 6px; color: var(--muted); font-size: .72rem;
  padding: 4px 10px; cursor: pointer; transition: var(--transition);
}
.notif-dismiss:hover { color: var(--white); border-color: var(--muted); }
.notif-empty { padding: 24px 16px; color: var(--muted); font-size: .85rem; text-align: center; }
@media (max-width: 768px) {
  .notif-panel { left: 12px; right: 12px; width: auto; }
}

/* ─── Gráficos del dashboard ───────────────────────────────────────────── */
.charts-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px;
}
@media (max-width: 900px) { .charts-row { grid-template-columns: 1fr; } }
.chart-card { min-height: 220px; }
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; flex-shrink: 0; }
.donut circle { transition: stroke-dasharray .6s ease; }
.donut-center { fill: var(--white); font-size: 13px; font-weight: 700; font-family: var(--font-body); }
.donut-legend { display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .82rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.history-bars { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.hbar-row { display: flex; align-items: center; gap: 10px; }
.hbar-label { color: var(--muted); font-size: .76rem; width: 58px; flex-shrink: 0; }
.hbar-track {
  flex: 1; display: flex; height: 18px; border-radius: 5px;
  overflow: hidden; background: var(--bg);
}
.hbar-seg { height: 100%; transition: width .5s ease; }
.hbar-total { color: var(--white); font-size: .76rem; font-weight: 600; width: 80px; text-align: right; flex-shrink: 0; }

/* ─── Badges de transferencia/duplicado ─────────────────────────────────── */
.badge.transfer  { background: rgba(91,141,239,.15); color: #5B8DEF; }
.badge.duplicate { background: rgba(148,163,184,.15); color: var(--muted); text-decoration: line-through; }

/* ─── Login social ──────────────────────────────────────────────────────── */
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 22px 0 14px; color: var(--muted); font-size: .78rem;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--navy3);
}
.social-login { display: flex; flex-direction: column; gap: 8px; }
.social-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px; border-radius: 10px;
  border: 1.5px solid var(--color-border);
  background: transparent;
  color: var(--color-text); font-family: inherit; font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
}
.social-btn:hover:not(:disabled) { border-color: var(--color-accent); background: transparent; }
.social-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ─── Temas de color (60/30/10) ─────────────────────────────────────────── */
/* Neo-Fintech: grafito + violeta + verde neón (default refinado) */
html[data-theme="neo"] {
  --bg:    #0B0B14;
  --navy2: #15152A;
  --navy3: #232342;
  --gold:  #A3E635;      /* acento lima para CTAs y positivos */
  --gold2: #84CC16;
  --white: #F4F4FB;
  --muted: #9D9DBE;
  --accent-primary: #7C3AED;
}

/* Clásico Confiable: azul marino + esmeralda + gris claro */
html[data-theme="classic"] {
  --bg:    #F1F5F9;
  --navy2: #FFFFFF;
  --navy3: #E2E8F0;
  --gold:  #059669;      /* esmeralda para CTAs y saldos positivos */
  --gold2: #047857;
  --white: #1E3A8A;      /* texto principal azul marino */
  --muted: #64748B;
  --accent-primary: #1E3A8A;
  --shadow: 0 4px 18px rgba(30,58,138,.10);
}

/* Finanzas Zen: arena + salvia + terracota */
html[data-theme="zen"] {
  --bg:    #F5F1E8;
  --navy2: #FDFBF6;
  --navy3: #E5DFD0;
  --gold:  #C97B4A;      /* terracota para acentos y logros */
  --gold2: #B5683B;
  --white: #3D4A3F;      /* texto verde bosque apagado */
  --muted: #8A9182;
  --accent-primary: #84A98C;
  --shadow: 0 4px 18px rgba(61,74,63,.10);

  /* CSS variables para compatibilidad con HTML */
  --color-bg: #F5F1E8;
  --color-bg-secondary: #FDFBF6;
  --color-accent: #C97B4A;
  --color-text: #3D4A3F;
  --color-text-secondary: #8A9182;
  --color-gain: #22C55E;
  --color-loss: #EF4444;
  --color-border: #E5DFD0;
}

.theme-row { display: flex; gap: 8px; margin-bottom: 10px; }
.theme-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--navy3); cursor: pointer; transition: var(--transition);
}
.theme-dot:hover { transform: scale(1.2); border-color: var(--muted); }

/* ─── Bottom nav (formato app en mobile) ────────────────────────────────── */
#bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 80;
  background: var(--navy2); border-top: 1px solid var(--navy3);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
#bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0; color: var(--muted); text-decoration: none;
  font-size: .62rem; font-weight: 600; border-radius: 8px;
  transition: var(--transition);
}
#bottom-nav a svg { width: 20px; height: 20px; }
#bottom-nav a.active { color: var(--gold); }
#more-nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0; color: var(--muted); background: none; border: none;
  font-family: inherit; font-size: .62rem; font-weight: 600; border-radius: 8px;
  transition: var(--transition); cursor: pointer;
}
#more-nav-btn svg { width: 20px; height: 20px; }
#more-nav-btn.active { color: var(--gold); }

#more-backdrop {
  position: fixed; inset: 0; z-index: 89;
  background: rgba(0,0,0,.5);
}
#more-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  background: var(--navy2); border-top: 1px solid var(--navy3);
  border-radius: 16px 16px 0 0;
  padding: 8px 8px calc(12px + env(safe-area-inset-bottom));
}
.more-sheet-handle {
  width: 36px; height: 4px; border-radius: 99px;
  background: var(--navy3); margin: 4px auto 10px;
}
#more-sheet nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
#more-sheet nav a {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 4px; color: var(--white); text-decoration: none;
  font-size: .72rem; font-weight: 600; border-radius: 10px;
  transition: var(--transition);
}
#more-sheet nav a:active { background: var(--navy3); }
#more-sheet nav a.active { color: var(--gold); }
#more-sheet nav a svg { width: 22px; height: 22px; }

@media (max-width: 768px) {
  #bottom-nav { display: flex; }
  #sidebar { display: none; }
  #hamburger { display: none !important; }
  #main { padding-bottom: 84px; }
  .notif-panel { bottom: 76px; }
}
@media (min-width: 769px) {
  #more-sheet, #more-backdrop { display: none !important; }
}

/* ─── Metas ─────────────────────────────────────────────────────────────── */
.goal-card {
  padding: 14px 0; border-bottom: 1px solid var(--navy3);
}
.goal-card:last-child { border-bottom: 0; }
.goal-card.done { opacity: .75; }
.goal-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; margin-bottom: 8px; flex-wrap: wrap;
}
.goal-head strong { color: var(--white); font-size: .95rem; }
.goal-amounts { color: var(--muted); font-size: .8rem; }
.goal-actions {
  display: flex; justify-content: space-between; align-items: center; margin-top: 8px;
}
.progress-fill.gold { background: var(--gold); }
.btn-link {
  background: none; border: 0; color: var(--gold); cursor: pointer;
  font-family: inherit; font-size: .78rem; font-weight: 600; padding: 2px 8px;
}
.btn-link.danger { color: var(--danger); }
.btn-link:hover { text-decoration: underline; }
.subgoal {
  display: flex; align-items: center; gap: 10px;
  margin: 6px 0 0 14px; padding: 6px 10px;
  background: var(--bg); border-radius: 8px;
  color: var(--white); font-size: .82rem;
}
.subgoal span:first-child { flex: 1; }

/* ─── Gastos fijos ──────────────────────────────────────────────────────── */
.recurring-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--navy3);
  font-size: .86rem;
}
.recurring-row:last-child { border-bottom: 0; }
.recurring-row.inactive { opacity: .45; }
.rec-name { color: var(--white); flex: 1; }
.rec-detail { color: var(--muted); font-size: .76rem; }
.rec-amount { color: var(--white); font-weight: 600; }

/* ─── Salidas por categoría (estilo MP) ─────────────────────────────────── */
.cat-list { display: flex; flex-direction: column; gap: 4px; }
.cat-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.cat-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.cat-info { flex: 1; min-width: 0; }
.cat-name { color: var(--white); font-size: .86rem; margin-bottom: 4px; }
.cat-bar-track { height: 5px; border-radius: 3px; background: var(--navy3); overflow: hidden; }
.cat-bar { height: 100%; border-radius: 3px; transition: width .5s ease; }
.cat-amounts { text-align: right; flex-shrink: 0; }
.cat-amount { color: var(--white); font-size: .86rem; font-weight: 600; }
.cat-pct { color: var(--muted); font-size: .72rem; }
.cat-total {
  display: flex; justify-content: space-between; margin-top: 10px;
  padding-top: 10px; border-top: 1px solid var(--navy3);
  color: var(--muted); font-size: .86rem;
}
.cat-total strong { color: var(--white); }

.metric-sub { display: block; color: var(--muted); font-size: .68rem; margin-top: 3px; }

/* ─── Acciones de gasto compartido ──────────────────────────────────────── */
.split-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn-ghost {
  background: transparent; border: 1px solid var(--navy3); color: var(--muted);
}
.btn-ghost:hover { color: var(--white); border-color: var(--muted); }

/* ─── Investments Page ──────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; gap: 16px; margin-bottom: 24px;
}
.page-header h2 { margin: 0; }
.btn-icon {
  background: var(--navy2); border: 1px solid var(--navy3);
  color: var(--white); width: 40px; height: 40px; border-radius: 8px;
  cursor: pointer; font-size: 1.2rem; transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--navy3); color: var(--gold); }

.tab-nav {
  display: flex; gap: 12px; margin-bottom: 24px; border-bottom: 1px solid var(--navy3);
  padding-bottom: 0;
}
.tab-btn {
  background: none; border: 0; color: var(--muted);
  font-family: inherit; font-size: .95rem; font-weight: 500;
  padding: 12px 16px; cursor: pointer;
  border-bottom: 3px solid transparent; transition: var(--transition);
}
.tab-btn:hover { color: var(--white); }
.tab-btn.active {
  color: var(--gold); border-bottom-color: var(--gold);
}

table {
  width: 100%; border-collapse: collapse;
}
thead { border-bottom: 1px solid var(--navy3); }
th {
  text-align: left; padding: 12px 8px; color: var(--muted);
  font-size: .82rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px;
}
td {
  padding: 12px 8px; border-bottom: 1px solid var(--navy3);
  color: var(--white); font-size: .9rem;
}
tbody tr:hover { background: rgba(255,255,255,0.02); }

.color-gain { color: var(--ok); }
.color-loss { color: var(--danger); }

.upload-form h3 { margin-bottom: 8px; }
.upload-form p { color: var(--muted); margin-bottom: 12px; }

.upload-zone {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 40px !important; text-align: center;
  border: 2px dashed var(--navy3) !important; border-radius: var(--radius) !important;
  cursor: pointer; transition: all var(--transition) !important;
}
.upload-zone:hover {
  border-color: var(--gold) !important; background: rgba(34,197,94,0.03) !important;
}
.upload-zone p { margin: 8px 0; color: var(--muted); }

#upload-status {
  margin-top: 20px; padding: 16px; border-radius: 8px;
  background: rgba(255,255,255,0.02);
}
.success-msg { border-left: 4px solid var(--ok); }
.success-msg p { color: var(--white); margin: 4px 0; }

.error-msg { border-left: 4px solid var(--danger); }
.error-msg p { color: var(--white); margin: 4px 0; }

.empty {
  text-align: center; padding: 40px 20px;
  color: var(--muted); font-size: .95rem;
}

.error {
  color: var(--danger); padding: 16px; background: rgba(239,68,68,0.1);
  border-radius: 8px; border-left: 4px solid var(--danger);
}

/* ─── Medios de pago (badges + desglose) ────────────────────────────────── */
.pm-badge {
  display: inline-block; padding: 1px 8px; border-radius: 99px;
  font-size: .68rem; font-weight: 600; margin-left: 6px; vertical-align: middle;
}
.pm-badge.credito       { background: rgba(201,123,74,.15);  color: var(--gold); }
.pm-badge.debito        { background: rgba(91,141,239,.15);  color: #5B8DEF; }
.pm-badge.qr            { background: rgba(132,169,140,.18);  color: #5E8C6A; }
.pm-badge.transferencia { background: rgba(168,85,247,.15);  color: #A855F7; }
.pm-badge.efectivo      { background: rgba(34,197,94,.15);   color: var(--ok); }
.pm-badge.otro          { background: rgba(148,163,184,.15); color: var(--muted); }

/* ─── Inversiones: look plano beige (sin baches blancos) ─────────────────── */
.inv-page .card,
.inv-surface {
  background: transparent;
  border: 1px solid var(--navy3);
  box-shadow: none;
}
.inv-metrics {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; margin-bottom: 24px;
}
@media (max-width: 700px) { .inv-metrics { grid-template-columns: 1fr 1fr; } }
.inv-metric {
  background: transparent; border: 1px solid var(--navy3);
  border-radius: 12px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.inv-metric .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.inv-metric .val { font-size: 1.25rem; font-weight: 700; color: var(--white); }
.inv-metric .val.gain { color: var(--ok); }
.inv-metric .val.loss { color: var(--danger); }
.inv-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px;
}
@media (max-width: 900px) { .inv-grid { grid-template-columns: 1fr; } }
.inv-block {
  background: transparent; border: 1px solid var(--navy3);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.inv-tag {
  display: inline-block; padding: 1px 7px; border-radius: 6px;
  font-size: .66rem; font-weight: 600; margin-left: 6px;
  background: var(--navy3); color: var(--muted); text-transform: uppercase;
}
.inv-tag.crypto { background: rgba(201,123,74,.16); color: var(--gold); }
.inv-tag.stock  { background: rgba(91,141,239,.14); color: #5B8DEF; }
.inv-page .upload-zone { background: transparent; }
.inv-toolbar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-left: auto;
}
.inv-pricehint { font-size: .72rem; color: var(--muted); margin-top: 6px; }
.linechart-wrap { width: 100%; }
.linechart { width: 100%; height: 220px; }
.linechart-grid { stroke: var(--navy3); stroke-width: 1; }
.linechart-axis { fill: var(--muted); font-size: 9px; font-family: var(--font-body); }
.linechart-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; }
.inv-holding-row { cursor: pointer; }
.inv-holding-row:hover { background: rgba(255,255,255,.03); }
.inv-detail-row td { padding: 16px; background: rgba(255,255,255,.02); }
.inv-ticker-detail .section-title { margin-top: 0; }

/* Toggle tipo (gasto/ingreso) en alta manual */
.type-toggle { display: flex; gap: 6px; margin-bottom: 16px; }
.type-toggle button {
  flex: 1; padding: 9px 0; border: 1px solid var(--navy3); border-radius: 8px;
  background: transparent; color: var(--muted); font-family: inherit;
  font-weight: 600; font-size: .85rem; cursor: pointer; transition: var(--transition);
}
.type-toggle button.active { border-color: var(--gold); color: var(--gold); }
