:root {
  --bg: #0a0c10;
  --bg-panel: #12151b;
  --bg-panel-2: #161b22;
  --border: #1c2128;
  --text: #d5dae0;
  --text-dim: #6b7480;
  --accent: #7ee0c4;
  --accent-2: #a5b4ff;
  --danger: #e08787;
  --warning: #e0b877;
  --radius: 16px;
  --cop: #7ee0c4;
  --usd: #a5b4ff;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Source Sans 3', system-ui, -apple-system, sans-serif;
  --nav-h: 68px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(10,12,16,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 9px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.topbar h1 { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.login-card {
  max-width: 340px;
  width: 100%;
  text-align: center;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 28px;
}
.login-card h1 { font-family: var(--font-display); font-size: 26px; margin: 0 0 8px; }
.login-card p { font-size: 14px; margin: 0; }

/* User badge */
.user-badge {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  padding: 0;
  overflow: hidden;
  background: var(--bg-panel-2);
  cursor: pointer;
}
.user-avatar { width: 100%; height: 100%; object-fit: cover; display: block; }

.icon-btn {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 12px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn-dot {
  position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger);
  border: 1.5px solid var(--bg-panel-2);
}

/* Dashboard greeting */
.dashboard-greeting { margin-bottom: 18px; }
.dashboard-greeting-hello { color: var(--accent); font-size: 12.5px; font-weight: 600; }
.dashboard-greeting-date { font-size: 14px; font-weight: 700; margin-top: 2px; }

.content {
  flex: 1;
  padding: 20px 20px calc(var(--nav-h) + 28px);
  width: 100%;
}

.view { display: none; }
.view.active { display: block; }

/* Bottom navigation */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  max-width: 560px;
  margin: 0 auto;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: #0d1014;
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-btn {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 48px;
  min-height: 48px;
  padding: 4px 6px;
  cursor: pointer;
  font-family: var(--font-body);
}
.nav-btn svg { width: 21px; height: 21px; }
.nav-btn span { font-size: 10.5px; font-weight: 600; }
.nav-btn.active { color: var(--accent); }
.nav-btn.active span { font-weight: 700; }

.nav-btn-fab {
  min-width: 52px;
  min-height: 52px;
  padding: 0;
}
.fab {
  width: 50px; height: 50px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  margin-top: -26px;
  box-shadow: 0 6px 18px rgba(126,224,196,0.35);
}
.fab svg { width: 22px; height: 22px; }

/* Buttons */
.btn {
  background: var(--accent);
  color: #0a0c10;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-body);
  min-height: 40px;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--bg-panel-2); color: var(--text); border: 1px solid var(--border); font-weight: 600; }
.btn.danger { background: var(--danger); color: #2a0f0f; }
.btn.success { background: var(--accent); color: #0a0c10; }
.btn.warning { background: var(--warning); color: #2a1f0a; }
.btn.success:disabled, .btn.warning:disabled, .btn.danger:disabled { opacity: 0.75; cursor: default; }
.btn.small { padding: 6px 12px; font-size: 12.5px; min-height: 32px; }
.btn.icon { padding: 8px 10px; }

/* Cards / Grid */
.grid { display: grid; gap: 14px; }
.grid.cols-1 { grid-template-columns: 1fr; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
@media (max-width: 480px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.card-title {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 600;
  margin: 0 0 10px;
}

.stat-value { font-family: var(--font-display); font-size: clamp(17px, 5.2vw, 24px); font-weight: 700; letter-spacing: -0.01em; overflow-wrap: break-word; }
.stat-sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.pill.cop { background: rgba(126,224,196,0.15); color: var(--cop); }
.pill.usd { background: rgba(165,180,255,0.15); color: var(--usd); }
.pill.pos { background: rgba(126,224,196,0.15); color: var(--accent); }
.pill.neg { background: rgba(224,135,135,0.15); color: var(--danger); }
.pill.warn { background: rgba(224,184,119,0.15); color: var(--warning); }
.pill.tipo { background: rgba(255,255,255,0.06); color: var(--text-dim); }
.pill svg { vertical-align: -1px; margin-right: 3px; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 11px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
th { color: var(--text-dim); font-weight: 700; text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table-wrap table { min-width: 480px; }

/* Transaction list (mobile card rows) */
.tx-list { display: flex; flex-direction: column; background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tx-item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.tx-item:last-child { border-bottom: none; }
.tx-icon { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tx-icon svg { width: 16px; height: 16px; }
.tx-icon.ingreso { background: rgba(126,224,196,0.12); color: var(--accent); }
.tx-icon.gasto { background: rgba(224,135,135,0.12); color: var(--danger); }
.tx-icon.transferencia { background: rgba(165,180,255,0.12); color: var(--accent-2); }
.tx-body { flex: 1; min-width: 0; }
.tx-title { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amount { font-family: var(--font-display); font-size: 14px; font-weight: 700; text-align: right; flex-shrink: 0; }
.tx-amount.ingreso { color: var(--accent); }
.tx-amount.gasto { color: var(--danger); }
.tx-del { flex-shrink: 0; }

.account-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
}
.account-card .balance { font-family: var(--font-display); font-size: 21px; font-weight: 700; margin: 6px 0; }
.account-card .actions { position: absolute; top: 14px; right: 14px; display: flex; gap: 6px; }

.progress-bar {
  height: 7px;
  background: var(--bg-panel-2);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-bar > div { height: 100%; background: var(--accent); border-radius: 999px; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}

/* Modal */
.modal-root:empty { display: none; }
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
  padding: 0;
}
.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
}
.modal h2 { margin-top: 0; font-family: var(--font-display); font-size: 19px; font-weight: 700; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  min-height: 44px;
}
.form-row.inline { display: flex; gap: 10px; }
.form-row.inline > div { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; min-height: auto; }

/* Custom select (reemplaza <select> nativo) */
.custom-select { position: relative; }
.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 15px;
  font-family: var(--font-body);
  min-height: 44px;
  cursor: pointer;
  text-align: left;
}
.custom-select-trigger:hover { border-color: var(--accent); }
.custom-select.open .custom-select-trigger { border-color: var(--accent); }
.custom-select-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-select-chevron { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-dim); transition: transform 0.15s; }
.custom-select.open .custom-select-chevron { transform: rotate(180deg); color: var(--accent); }
.custom-select-menu {
  display: none;
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 6px);
  z-index: 60;
  background: #171d29;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
}
.custom-select.open .custom-select-menu { display: block; }
.custom-select-option {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
.custom-select-option:hover { background: rgba(255,255,255,0.06); }
.custom-select-option.selected { background: rgba(126,224,196,0.14); color: var(--accent); font-weight: 700; }
.filters .custom-select { min-width: 170px; }
.filters .custom-select-trigger { min-height: 38px; padding: 7px 10px; font-size: 13px; }

.more-menu { display: flex; flex-direction: column; gap: 4px; }
.more-menu-item {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 10px;
  min-height: 48px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  text-align: left;
}
.more-menu-item:hover { background: var(--bg-panel-2); }
.more-menu-icon { width: 22px; height: 22px; color: var(--accent); flex-shrink: 0; display: flex; }
.more-menu-icon svg { width: 100%; height: 100%; }

.notif-item { display: flex; align-items: center; gap: 12px; padding: 10px; }
.notif-icon { width: 36px; height: 36px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-icon svg { width: 16px; height: 16px; }
.notif-icon.warn { background: rgba(224,184,119,0.15); color: var(--warning); }
.notif-icon.danger { background: rgba(224,135,135,0.15); color: var(--danger); }
.notif-title { font-size: 13.5px; font-weight: 600; }
.notif-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }

/* Account menu */
.account-menu { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 6px 0 20px; }
.account-menu-avatar {
  width: 72px; height: 72px; border-radius: 50%; object-fit: cover; display: block;
  border: 2px solid var(--border); margin-bottom: 14px;
}
.account-menu-name { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.account-menu-email { font-size: 13px; color: var(--text-dim); margin-top: 3px; }
.account-menu-divider { height: 1px; background: var(--border); margin: 4px 0 18px; }
.account-menu-logout {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.account-menu-logout svg { width: 16px; height: 16px; }

/* Toasts */
.toast-root {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 528px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 90; /* debajo del modal (100) para no tapar/bloquear su contenido */
}
.toast {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  animation: slidein 0.2s ease-out;
}
.toast.warn { border-left-color: var(--warning); }
.toast.danger { border-left-color: var(--danger); }
@keyframes slidein { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; flex-wrap: wrap; gap: 10px;
}
.section-header .section-title { font-size: 15px; font-weight: 700; }
.link-btn {
  appearance: none; background: transparent; border: none; cursor: pointer;
  color: var(--accent); font-size: 12.5px; font-weight: 600; font-family: var(--font-body);
  padding: 4px 0; min-height: 32px;
}

/* Dashboard hero */
.hero-card {
  background: linear-gradient(160deg, #182018 0%, #101512 60%, var(--bg-panel-2) 100%);
  border: 1px solid #223028;
  border-radius: 20px;
  padding: 22px 20px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}
.hero-glow {
  position: absolute; top: -40px; right: -40px; width: 140px; height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(126,224,196,0.14), transparent 70%);
  pointer-events: none;
}
.hero-label {
  position: relative; color: #8a9a92; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: 0.07em; font-weight: 600; margin-bottom: 8px;
}
.hero-value {
  position: relative; font-family: var(--font-display); font-size: clamp(24px, 8vw, 34px);
  font-weight: 700; letter-spacing: -0.01em; overflow-wrap: break-word;
}
.hero-trend {
  position: relative; display: flex; align-items: center; gap: 5px; margin-top: 8px;
  font-size: 12.5px; font-weight: 600;
}
.hero-trend svg { width: 12px; height: 12px; }
.hero-trend.pos { color: var(--accent); }
.hero-trend.neg { color: var(--danger); }
.quick-actions {
  position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 20px;
}
.quick-action {
  appearance: none; cursor: pointer; font-family: var(--font-body);
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px; padding: 10px 6px; display: flex; flex-direction: column;
  align-items: center; gap: 6px; min-height: 44px; justify-content: center;
  color: var(--text); font-size: 11px; font-weight: 600;
}
.quick-action svg { width: 17px; height: 17px; }
.quick-action.send svg { color: var(--accent); }
.quick-action.add svg { color: var(--accent-2); }
.quick-action.history svg { color: var(--warning); }

/* Mini stats */
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 22px; }
.mini-stat { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.mini-stat-label { color: var(--text-dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; margin-bottom: 6px; }
.mini-stat-value { font-family: var(--font-display); font-size: 18px; font-weight: 700; overflow-wrap: break-word; }
.mini-stat-value.pos { color: var(--accent); }
.mini-stat-value.neg { color: var(--danger); }

/* Accounts horizontal scroll */
.accounts-scroll {
  display: flex; gap: 10px; overflow-x: auto; margin: 0 -20px 24px; padding: 0 20px 4px;
  scrollbar-width: none;
}
.accounts-scroll::-webkit-scrollbar { display: none; }
.account-mini {
  flex-shrink: 0; width: 150px; background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px;
}
.account-mini-icon {
  width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center;
  justify-content: center; margin-bottom: 12px;
}
.account-mini-icon svg { width: 15px; height: 15px; }
.account-mini-name { font-size: 12px; font-weight: 600; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-mini-currency { font-size: 10.5px; color: var(--text-dim); margin-bottom: 10px; }
.account-mini-balance { font-family: var(--font-display); font-size: 15px; font-weight: 700; overflow-wrap: break-word; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; overflow-x: auto; }
.filters select, .filters input { background: var(--bg-panel-2); border: 1px solid var(--border); color: var(--text); padding: 9px 12px; border-radius: 10px; font-size: 13px; min-height: 40px; }

.text-dim { color: var(--text-dim); }
.mt-0 { margin-top: 0; }
