/* ─────────────────────────────────────────────
   FinanzasPro — Design Tokens & Global Styles
   ───────────────────────────────────────────── */

:root {
  --bg:      #f5f2ec;
  --card:    #ffffff;
  --card2:   #f0ede6;
  --sidebar: #edeae2;
  --border:  rgba(0,0,0,0.07);
  --red:     #b84040;
  --gold:    #c97a2f;
  --indigo:  #4a5fa8;
  --green:   #3a7a5c;
  --text:    #1a1916;
  --sub:     #8c8880;
  --muted:   #ccc9c0;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; height: 100vh; overflow: hidden; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 3px; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
select option { background: #fff; color: var(--text); }

/* ── Mono numbers ── */
.mono { font-family: 'JetBrains Mono', monospace; }

/* ── Layout ── */
.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  flex-shrink: 0;
  overflow: hidden;
  transition: width .2s ease;
}
.sidebar.expanded { width: 220px; }
.sidebar.collapsed { width: 68px; }

.main-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.page {
  padding: 28px 32px;
  flex: 1;
}

/* ── Sidebar nav ── */
.sidebar-header {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 20px;
  justify-content: space-between;
  gap: 10px;
}
.sidebar.collapsed .sidebar-header { justify-content: center; }

.logo-icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--red), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0; color: #fff;
}
.logo-text { font-size: 15px; font-weight: 800; letter-spacing: -0.3px; white-space: nowrap; }

.sidebar-toggle {
  background: transparent; border: none;
  color: var(--sub); font-size: 16px; padding: 4px;
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--text); }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }

.nav-item {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--sub);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  margin-bottom: 4px;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}
.sidebar.collapsed .nav-item { justify-content: center; padding: 11px 0; }

.nav-item:hover { background: rgba(204,201,192,0.5); color: var(--text); }
.nav-item.active { background: rgba(184,64,64,0.1); color: var(--text); font-weight: 700; }
.nav-item.active .nav-dot { display: block; }
.nav-item.add-item {
  background: linear-gradient(135deg, rgba(184,64,64,0.2), rgba(201,122,47,0.2));
  border-color: rgba(184,64,64,0.27);
  color: var(--text);
}

.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-icon.big { font-size: 20px; }
.nav-dot { display: none; width: 4px; height: 4px; border-radius: 50%; background: var(--red); margin-left: auto; }

.sidebar-user {
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
}
.sidebar.collapsed .user-info { justify-content: center; }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(74,95,168,0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--indigo);
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { font-size: 11px; color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.logout-btn {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  margin: 0 8px 14px;
  width: calc(100% - 16px);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--sub); font-size: 13px; font-weight: 600;
  transition: all .15s;
}
.sidebar.collapsed .logout-btn { justify-content: center; }
.logout-btn:hover { background: rgba(184,64,64,0.07); color: var(--red); border-color: rgba(184,64,64,0.27); }

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.card:hover.clickable { box-shadow: 0 4px 16px rgba(0,0,0,0.10); }
.card.no-pad { padding: 0; overflow: hidden; }

/* ── Grid helpers ── */
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-28 { margin-bottom: 28px; }

/* ── Stat ── */
.stat-label { font-size: 12px; color: var(--sub); text-transform: uppercase; letter-spacing: .8px; margin-bottom: 4px; }
.stat-value { font-size: 26px; font-weight: 700; font-family: 'JetBrains Mono', monospace; line-height: 1; }
.stat-sub { font-size: 12px; color: var(--sub); margin-top: 4px; }

/* ── Badge ── */
.badge {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 6px;
  text-transform: uppercase; letter-spacing: .5px;
}

/* ── Tag buttons ── */
.tag {
  padding: 5px 14px;
  border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--sub);
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.tag.active { background: rgba(184,64,64,0.13); color: var(--red); border-color: rgba(184,64,64,0.33); }
.tag.income.active { background: rgba(58,122,92,0.13); color: var(--green); border-color: rgba(58,122,92,0.33); }
.tag.transfer.active { background: rgba(201,122,47,0.13); color: var(--gold); border-color: rgba(201,122,47,0.33); }

/* ── Page header ── */
.page-title { font-size: 24px; font-weight: 800; color: var(--text); margin: 0; }
.page-sub { margin: 4px 0 0; color: var(--sub); font-size: 14px; }

/* ── Primary button ── */
.btn-primary {
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--red), var(--gold));
  border: none; border-radius: 10px;
  color: #fff; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: opacity .15s;
}
.btn-primary:hover { opacity: .88; }
.btn-primary.full { width: 100%; padding: 14px; font-size: 15px; }
.btn-primary.sm { padding: 9px 18px; font-size: 13px; }

.btn-secondary {
  padding: 9px 18px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--sub); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.btn-secondary:hover { border-color: var(--muted); color: var(--text); }

.btn-danger {
  padding: 9px 18px;
  background: rgba(184,64,64,0.07);
  border: 1px solid rgba(184,64,64,0.2);
  border-radius: 10px;
  color: var(--red); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.btn-danger:hover { background: rgba(184,64,64,0.15); }

/* ── Form inputs ── */
.form-label {
  display: block; font-size: 12px; color: var(--sub);
  margin-bottom: 6px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .6px;
}
.form-input {
  width: 100%; background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px;
  color: var(--text); font-size: 14px;
  outline: none; font-family: inherit;
  transition: border-color .15s;
}
.form-input:focus { border-color: var(--indigo); }
.form-input.full { width: 100%; }

/* ── Tables ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 14px 20px; text-align: left;
  font-size: 11px; color: var(--sub);
  font-weight: 700; text-transform: uppercase; letter-spacing: .8px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: var(--card2); }

/* ── Toggle switch ── */
.toggle {
  width: 40px; height: 22px; border-radius: 11px;
  background: var(--muted);
  cursor: pointer; position: relative;
  transition: background .2s; flex-shrink: 0;
  border: none;
}
.toggle.on { background: var(--green); }
.toggle::after {
  content: '';
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff;
  position: absolute; top: 3px; left: 3px;
  transition: left .2s;
}
.toggle.on::after { left: 21px; }

/* ── Tabs ── */
.tab-bar {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.tab-btn {
  padding: 10px 18px;
  background: transparent; border: none;
  border-bottom: 2px solid transparent;
  color: var(--sub); font-weight: 500; font-size: 14px;
  cursor: pointer; transition: all .15s; font-family: inherit;
  margin-bottom: -1px;
}
.tab-btn.active { border-bottom-color: var(--red); color: var(--text); font-weight: 700; }

/* ── Alert / notice ── */
.alert {
  padding: 10px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  margin-bottom: 16px;
}
.alert.success { background: rgba(58,122,92,0.1); color: var(--green); }
.alert.error { background: rgba(184,64,64,0.08); color: var(--red); }
.alert.warn { background: rgba(201,122,47,0.1); color: var(--gold); border: 1px solid rgba(201,122,47,0.2); }

/* ── Category dot ── */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }

/* ── Hide balance toggle ── */
.hb { transition: filter .2s; }
.hb-active .hb {
  filter: blur(7px);
  user-select: none;
  pointer-events: none;
}
.eye-btn {
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  color: var(--muted); cursor: pointer;
  font-size: 16px; padding: 4px 6px;
  border-radius: 6px; transition: color .15s;
  line-height: 1;
}
.eye-btn:hover { color: var(--sub); }
.sidebar.collapsed .eye-btn-wrap { justify-content: center; }

/* ── Transaction type icons ── */
.tx-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.tx-icon.income { background: rgba(58,122,92,0.13); }
.tx-icon.expense { background: rgba(184,64,64,0.13); }
.tx-icon.transfer { background: rgba(201,122,47,0.13); }
.tx-icon.debt { background: rgba(74,95,168,0.13); }

/* ── Ticker badge ── */
.ticker-badge {
  background: var(--card2); padding: 4px 10px;
  border-radius: 8px; font-weight: 700;
  color: var(--gold); font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
}

/* ── Coin icon ── */
.coin-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}

/* ── Login page ── */
.login-wrap {
  min-height: 100vh; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.login-card { width: 420px; }
.login-logo { text-align: center; margin-bottom: 40px; }
.login-logo-inner { display: inline-flex; align-items: center; gap: 12px; }
.login-logo-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--red), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff;
}
.login-app-name { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.login-app-sub { font-size: 12px; color: var(--sub); letter-spacing: 1px; text-transform: uppercase; }

/* ── Utility colors ── */
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-gold { color: var(--gold); }
.text-indigo { color: var(--indigo); }
.text-sub { color: var(--sub); }
.text-bold { font-weight: 700; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }

/* ── Flex helpers ── */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.ml-auto { margin-left: auto; }
.mt-auto { margin-top: auto; }

/* ── Progress bar ── */
.progress-bar { height: 6px; border-radius: 3px; background: var(--card2); }
.progress-fill { height: 6px; border-radius: 3px; transition: width .4s; }

/* ── Section divider ── */
.section-divider { border: none; border-top: 1px solid var(--border); margin: 0; }

/* ── Info box ── */
.info-box {
  background: rgba(201,122,47,0.07);
  border: 1px solid rgba(201,122,47,0.2);
  border-radius: 10px; padding: 12px 16px;
  font-size: 13px; color: var(--sub); line-height: 1.6;
}
.info-box strong { color: var(--gold); }

/* ── Connection box ── */
.connect-box {
  background: rgba(58,122,92,0.07);
  border: 1px solid rgba(58,122,92,0.2);
  border-radius: 12px; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}

/* ── Mobile header (visible only on mobile) ── */
.mobile-header {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}
.mobile-header-logo {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--red), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff; letter-spacing: -0.3px;
}
.mobile-menu-btn {
  background: transparent; border: none;
  font-size: 22px; cursor: pointer; color: var(--text);
  line-height: 1; padding: 0;
}

/* ── Mobile overlay ── */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
}
.mobile-overlay.active { display: block; }

/* ── Responsive — tablet (≤ 768px) ── */
@media (max-width: 768px) {
  .mobile-header { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    width: 220px !important;
    transform: translateX(-100%);
    transition: transform .25s ease, width .2s ease;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-toggle { display: none; }

  .page { padding: 20px 16px; }

  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }

  .login-card { width: 100%; }
  .login-wrap { padding: 20px 16px; align-items: flex-start; }
}

/* ── Responsive — mobile (≤ 480px) ── */
@media (max-width: 480px) {
  .grid-4 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .stat-value { font-size: 20px; }
  .page { padding: 16px 12px; }
  .card { padding: 16px; }
  .login-wrap { padding: 16px 12px; }
}
