/* Finanzas — Kinetic Noir tokens */
:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1c1c1c;
  --surface-3: #232323;
  --border: #2a2a2a;
  --text: #f5f5f5;
  --text-muted: #8a8a8a;
  --text-dim: #5a5a5a;
  --accent: #00E5A0;
  --accent-2: #00C989;
  --amber: #FFB800;
  --danger: #FF4747;
  --blue: #4D9FFF;
  --purple: #B87EFF;
  --pink: #FF6B9D;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'SF Pro Display', system-ui, sans-serif;
  font-size: 15px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(80px + var(--safe-bottom));
}

/* Layout */
.app {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 16px;
}

/* Typography */
.page-sub { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.page-title { font-size: 28px; font-weight: 800; letter-spacing: -0.8px; line-height: 1.1; }
.label-xs { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; }
.label-sm { font-size: 12px; color: var(--text-muted); }
.value-xl { font-size: 34px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; }
.value-lg { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.1; }
.value-md { font-size: 18px; font-weight: 600; }
.value-sm { font-size: 14px; font-weight: 500; }

/* Page header */
.page-header {
  padding: 12px 0 20px;
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}
.card-elevated { background: var(--surface-2); }
.card-hero {
  background: linear-gradient(135deg, #0f2420 0%, #14181c 100%);
  border-color: rgba(0, 229, 160, 0.2);
}

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-start { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 11px; font-weight: 500;
}
.chip.accent { background: rgba(0, 229, 160, 0.12); color: var(--accent); border-color: rgba(0, 229, 160, 0.3); }
.chip.amber { background: rgba(255, 184, 0, 0.12); color: var(--amber); border-color: rgba(255, 184, 0, 0.3); }
.chip.blue { background: rgba(77, 159, 255, 0.12); color: var(--blue); border-color: rgba(77, 159, 255, 0.3); }
.chip.purple { background: rgba(184, 126, 255, 0.12); color: var(--purple); border-color: rgba(184, 126, 255, 0.3); }
.chip.danger { background: rgba(255, 71, 71, 0.12); color: var(--danger); border-color: rgba(255, 71, 71, 0.3); }

/* Progress */
.progress {
  height: 6px; background: rgba(255, 255, 255, 0.06);
  border-radius: 3px; overflow: hidden; margin-top: 10px;
}
.progress-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.4s; }
.progress-bar.amber { background: var(--amber); }
.progress-bar.danger { background: var(--danger); }
.progress-bar.blue { background: var(--blue); }
.progress-bar.purple { background: var(--purple); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 18px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.98); opacity: 0.9; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #000;
  border: 0;
  font-weight: 700;
}
.btn-block { width: 100%; }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 10px 0 calc(10px + var(--safe-bottom));
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-dim);
  font-size: 10px; font-weight: 500;
  flex: 1;
  text-decoration: none;
  padding: 4px 0;
}
.nav-item.active { color: var(--accent); }
.nav-icon { font-size: 22px; line-height: 1; }

/* FAB */
.fab {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  right: 20px;
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #000;
  border: 0;
  border-radius: 50%;
  font-size: 28px; font-weight: 300;
  box-shadow: 0 8px 24px rgba(0, 229, 160, 0.35);
  cursor: pointer;
  z-index: 40;
  display: flex; align-items: center; justify-content: center;
}
.fab:active { transform: scale(0.95); }

/* Sec header */
.sec-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 18px 0 10px;
}
.sec-title { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.9px; font-weight: 700; }
.sec-link { font-size: 12px; color: var(--accent); font-weight: 500; text-decoration: none; cursor: pointer; }

/* Delta */
.delta-up { color: var(--accent); font-size: 13px; font-weight: 500; }
.delta-down { color: var(--danger); font-size: 13px; font-weight: 500; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 24px;
  background: radial-gradient(circle at top, rgba(0, 229, 160, 0.08), transparent 60%), var(--bg);
}
.login-brand {
  font-size: 38px; font-weight: 800; letter-spacing: -1.5px;
  background: linear-gradient(135deg, #00E5A0 0%, #4D9FFF 50%, #B87EFF 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}
.login-sub { color: var(--text-muted); margin-bottom: 32px; font-size: 14px; }
.login-google {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 24px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px; font-weight: 600;
  text-decoration: none;
}
.login-error {
  padding: 10px 14px;
  background: rgba(255, 71, 71, 0.12);
  border: 1px solid rgba(255, 71, 71, 0.3);
  color: #FFB4A9;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 20px;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-sub { font-size: 13px; line-height: 1.4; }

/* Utilities */
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* Toggle segmented */
.toggle-bar {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 3px;
  margin: 10px 0;
}
.toggle-seg {
  flex: 1; text-align: center; padding: 8px;
  font-size: 12px; color: var(--text-muted);
  border-radius: 9px; cursor: pointer;
  user-select: none;
}
.toggle-seg.active {
  font-weight: 600; background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.tab-bar {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 4px;
  margin: 10px 0;
}
.tab-pill {
  flex: 1; padding: 9px 8px; text-align: center;
  font-size: 12px; font-weight: 500;
  color: var(--text-muted);
  border-radius: 9px; cursor: pointer;
  user-select: none;
}
.tab-pill.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Group total header */
.group-total {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 14px 4px 10px;
}
.group-total-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.group-total-sub { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.group-total-value { font-size: 16px; font-weight: 700; }

/* Account card */
.acct-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: inherit;
  cursor: pointer;
}
.acct-card:active { transform: scale(0.98); }
.acct-card.debt { border-color: rgba(255, 71, 71, 0.15); }
.acct-logo {
  width: 40px; height: 40px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
  flex-shrink: 0; color: #fff;
  background: linear-gradient(135deg, #666, #444);
}
.acct-body { flex: 1; min-width: 0; }
.acct-name { font-size: 14px; font-weight: 600; }
.acct-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.acct-value { text-align: right; white-space: nowrap; }
.acct-amt { font-size: 15px; font-weight: 700; }
.acct-delta { font-size: 11px; margin-top: 2px; color: var(--text-muted); }

/* Modal sheet */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  display: flex; align-items: flex-end;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}
.modal-sheet {
  width: 100%;
  background: var(--surface-2);
  border-radius: 28px 28px 0 0;
  padding: 14px 20px calc(28px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  max-height: 92%;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-backdrop.show .modal-sheet { transform: translateY(0); }
.grip { width: 40px; height: 4px; background: #444; border-radius: 2px; margin: 0 auto 16px; }

/* Capture amount display */
.amount-display {
  text-align: center;
  padding: 20px 0 16px;
}
.amount-sign { font-size: 24px; color: var(--text-muted); font-weight: 500; vertical-align: top; margin-right: 4px; }
.amount-value {
  font-size: 56px; font-weight: 800;
  letter-spacing: -2px; line-height: 1.1;
}
.amount-dim { color: var(--text-dim); }

/* Numpad */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.num-btn {
  padding: 16px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 22px; font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s;
}
.num-btn:active { transform: scale(0.95); background: var(--surface-2); }
.num-btn.action {
  color: var(--accent);
  font-size: 18px;
}

/* Category chips */
.cat-chips {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 10px 0;
}
.cat-chip {
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.cat-chip:active { transform: scale(0.96); }
.cat-chip.suggested {
  background: rgba(0, 229, 160, 0.15);
  color: var(--accent);
  border-color: rgba(0, 229, 160, 0.4);
}
.cat-chip.selected {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #000; font-weight: 600;
  border-color: var(--accent);
}

/* Option rows in modal */
.opt-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0;
  font-size: 13px;
}
.opt-label { color: var(--text-muted); }
.opt-pill {
  padding: 4px 10px;
  background: var(--surface);
  border-radius: 12px;
  font-size: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
}
.opt-pill.selected {
  background: rgba(0, 229, 160, 0.15);
  color: var(--accent);
  border-color: rgba(0, 229, 160, 0.4);
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(90px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 18px;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Drill-down overlay */
.drill {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 90;
  overflow-y: auto;
  padding-bottom: calc(80px + var(--safe-bottom));
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.drill.open { transform: translateX(0); }

/* Nav back */
.nav-back {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px 8px;
}
.back-btn {
  width: 36px; height: 36px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; cursor: pointer;
  color: var(--text);
}

/* Timeline tx */
.tx-row {
  display: flex; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.tx-row:last-child { border: 0; }
.tx-icon {
  width: 38px; height: 38px;
  background: var(--surface-2);
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.tx-body { flex: 1; min-width: 0; }
.tx-title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.tx-amount { font-size: 14px; font-weight: 600; text-align: right; white-space: nowrap; }
.tx-amount.pos { color: var(--accent); }

/* Institution logos (bank colors) */
.logo-1 { background: linear-gradient(135deg, #EC0000, #B40000); }  /* Santander */
.logo-2 { background: linear-gradient(135deg, #6A00F4, #3D00A8); }  /* Tenpo */
.logo-3 { background: linear-gradient(135deg, #1D3B7A, #0E1F42); }  /* BCI */
.logo-4 { background: linear-gradient(135deg, #64B32C, #3E7F16); }  /* Falabella */
.logo-5 { background: linear-gradient(135deg, #F5A623, #C97A00); }  /* Copec */
.logo-6 { background: linear-gradient(135deg, #F7931A, #C87214); }  /* Bitcoin */
.logo-7 { background: linear-gradient(135deg, #EC7000, #B45000); }  /* Itaú */
.logo-debt { background: linear-gradient(135deg, var(--danger), #B40000); }
