:root {
  --tinta: #16213E;
  --mar: #1B4B66;
  --mar-claro: #DCE9EF;
  --oro: #C9962C;
  --oro-suave: #F3E6C8;
  --verde: #2E9E6D;
  --verde-suave: #E1F3EA;
  --rojo: #D1495B;
  --rojo-suave: #FBE6E9;
  --papel: #F5F3EE;
  --linea: #E4E0D6;
  --gris: #7C8698;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--papel);
  color: var(--tinta);
  font-family: 'Inter', -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sw-display { font-family: 'Sora', sans-serif; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--papel);
  display: flex;
  flex-direction: column;
  position: relative;
}

button { font-family: inherit; border: none; background: none; cursor: pointer; }
input, select, textarea { font-family: inherit; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--linea); border-radius: 999px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.anim { animation: fadeIn .25s ease; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  background: var(--tinta);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box { width: 100%; max-width: 340px; }
.login-logo { display: flex; flex-direction: column; align-items: center; margin-bottom: 32px; }
.login-icon {
  width: 52px; height: 52px; border-radius: 14px; background: var(--oro);
  display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.login-title { color: #fff; font-weight: 700; font-size: 26px; margin-top: 14px; }
.login-sub { color: #9BA9C4; font-size: 14px; margin-top: 2px; }
.login-card { background: #fff; border-radius: 18px; padding: 26px; }
.login-hint { text-align: center; font-size: 12px; color: var(--gris); margin-top: 16px; line-height: 1.6; }

/* ---------- Campos ---------- */
.field { display: block; margin-bottom: 16px; }
.field-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--gris); }
.field-req { color: var(--rojo); }
.field-hint { display: block; font-size: 11px; color: var(--gris); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--linea);
  font-size: 14px; outline: none; background: #fff; margin-top: 6px;
}
.input:focus { border-color: var(--mar); }
textarea.input { resize: none; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--mar); color: #fff; }
.btn-gold { background: var(--oro); color: #fff; }
.btn-danger { background: var(--rojo); color: #fff; }
.btn-ghost { background: transparent; color: var(--mar); border: 1.5px solid var(--linea); }
.btn-subtle { background: var(--papel); color: var(--tinta); border: 1.5px solid var(--linea); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { padding: 8px; border-radius: 10px; display: inline-flex; align-items:center; justify-content:center; }

/* ---------- Header ---------- */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; background: var(--tinta); color: #fff;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { width: 32px; height: 32px; border-radius: 9px; background: var(--oro); display:flex; align-items:center; justify-content:center; }
.header-name { font-weight: 700; font-size: 15px; line-height: 1.1; }
.header-sub { font-size: 11px; color: #9BA9C4; }

/* ---------- Contenido / navegación ---------- */
.content { flex: 1; overflow-y: auto; padding-bottom: 84px; }
.view { padding: 20px; }

.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: 480px; display: flex; justify-content: space-around;
  background: #fff; border-top: 1px solid var(--linea);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 0; color: var(--gris); font-size: 10.5px; font-weight: 600;
}
.nav-btn.active { color: var(--mar); }
.nav-dot { height: 3px; width: 18px; border-radius: 3px; background: transparent; }
.nav-btn.active .nav-dot { background: var(--oro); }

/* ---------- Tarjetas ---------- */
.card { background: #fff; border: 1px solid var(--linea); border-radius: 16px; padding: 16px; }

/* ---------- Dashboard ---------- */
.balance-card { border-radius: 18px; padding: 20px; margin-bottom: 20px; background: var(--tinta); color: #fff; }
.balance-top { display: flex; align-items: center; justify-content: space-between; font-size: 11px; text-transform: uppercase; color: #9BA9C4; letter-spacing: .04em; }
.balance-amount { font-weight: 700; font-size: 30px; margin-top: 4px; }
.balance-row { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; }

.period-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.period-label { font-size: 12px; font-weight: 600; color: var(--gris); margin-bottom: 8px; }
.period-balance { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.period-line { font-size: 11px; display: block; }

.chart-card { margin-bottom: 20px; }
.chart-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; }

.bar-item { margin-bottom: 10px; }
.bar-top { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.bar-track { height: 6px; border-radius: 4px; background: var(--papel); }
.bar-fill { height: 6px; border-radius: 4px; }

/* ---------- Pill / etiquetas ---------- */
.pill {
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px;
}
.pill-ingreso { background: var(--verde-suave); color: var(--verde); }
.pill-egreso { background: var(--rojo-suave); color: var(--rojo); }

/* ---------- Toggle tipo / clasificación ---------- */
.toggle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggle-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.toggle-btn {
  border-radius: 12px; padding: 10px; font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--linea); background: var(--papel); color: var(--gris);
}
.toggle-btn.active-ingreso { background: var(--verde-suave); color: var(--verde); border-color: var(--verde); }
.toggle-btn.active-egreso { background: var(--rojo-suave); color: var(--rojo); border-color: var(--rojo); }
.toggle-btn.active-clasif { background: var(--mar-claro); color: var(--mar); border-color: var(--mar); }

/* ---------- Historico ---------- */
.search-bar {
  display: flex; align-items: center; gap: 8px; background: #fff; border: 1.5px solid var(--linea);
  border-radius: 12px; padding: 8px 12px; margin-bottom: 10px;
}
.search-bar input { flex: 1; border: none; outline: none; font-size: 14px; }
.filters-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.list-row {
  display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--linea);
  border-radius: 14px; padding: 14px; margin-bottom: 8px;
}
.list-row:hover { background: #FAFAF7; }
.list-main { flex: 1; min-width: 0; }
.list-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.list-date { font-size: 11px; color: var(--gris); }
.list-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-desc { font-size: 12px; color: var(--gris); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-right { text-align: right; flex-shrink: 0; }
.list-amount { font-weight: 700; font-size: 14px; }
.list-actions { display: flex; gap: 4px; justify-content: flex-end; margin-top: 6px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(22,33,62,.45); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-box { background: #fff; border-radius: 18px; padding: 20px; width: 100%; max-width: 300px; }
.modal-text { font-size: 14px; font-weight: 500; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  padding: 10px 16px; border-radius: 12px; color: #fff; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 8px; z-index: 60; box-shadow: 0 8px 20px rgba(0,0,0,.15);
}
.toast-ok { background: var(--tinta); }
.toast-error { background: var(--rojo); }

/* ---------- Usuarios ---------- */
.user-row {
  display: flex; align-items: center; justify-content: space-between; background: #fff;
  border: 1px solid var(--linea); border-radius: 14px; padding: 14px; margin-bottom: 8px;
}
.user-left { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 10px; background: var(--mar-claro);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--mar);
}
.user-name { font-size: 14px; font-weight: 600; }
.user-sub { font-size: 12px; color: var(--gris); }

/* ---------- Estado de carga / error ---------- */
.loading-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--gris); font-size: 14px; }
.error-text { color: var(--rojo); font-size: 13px; display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.empty-state { text-align: center; padding: 40px 0; font-size: 13px; color: var(--gris); }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
