:root {
  --bg: #0b1220;
  --bg-card: #131c2e;
  --bg-card-2: #1a2436;
  --border: #253248;
  --text: #eef2f8;
  --text-dim: #9aa7bd;
  --verde: #2fbf71;
  --rojo: #ef5b5b;
  --azul: #4f8cff;
  --amarillo: #e6b34d;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font-family: inherit; }

#app {
  min-height: 100dvh;
  padding-bottom: calc(76px + var(--safe-bottom));
}

/* ── Header ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  background: var(--bg);
}
.topbar h1 { font-size: 20px; margin: 0; }
.topbar .sub { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.topbar button.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
}

/* ── Contenido ──────────────────────────────────────────── */
.view { padding: 0 16px 24px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.card + .card { margin-top: 0; }
.card-title { font-size: 13px; color: var(--text-dim); margin: 0 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.card-tap { cursor: pointer; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-row + .card-row { margin-top: 8px; }

.monto { font-variant-numeric: tabular-nums; font-weight: 600; }
.monto.ingreso { color: var(--verde); }
.monto.egreso { color: var(--rojo); }
.pill {
  display: inline-block;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-card-2);
  color: var(--text-dim);
}
.pill.activa { color: var(--verde); background: rgba(47,191,113,.12); }
.pill.cerrada { color: var(--text-dim); }

h2.section { font-size: 15px; margin: 18px 0 8px; color: var(--text-dim); }

.vacio { color: var(--text-dim); text-align: center; padding: 30px 10px; font-size: 14px; }

/* ── Formularios ────────────────────────────────────────── */
label { display: block; font-size: 13px; color: var(--text-dim); margin: 12px 0 6px; }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=password], select, textarea {
  width: 100%;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 12px;
  font-size: 16px;
}
textarea { resize: vertical; min-height: 60px; }
.fila-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--azul); color: #fff; }
.btn-secondary { background: var(--bg-card-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: rgba(239,91,91,.12); color: var(--rojo); border: 1px solid rgba(239,91,91,.3); }
.btn[disabled] { opacity: .5; }
.btn-row { display: flex; gap: 10px; margin-top: 16px; }
.btn-row .btn { width: auto; flex: 1; }

.toggle-group { display: flex; gap: 8px; }
.toggle-group button {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card-2);
  color: var(--text-dim);
  font-weight: 600;
}
.toggle-group button.activo { background: var(--azul); color: #fff; border-color: var(--azul); }
.toggle-group button.activo.tipo-ingreso { background: var(--verde); border-color: var(--verde); }
.toggle-group button.activo.tipo-egreso { background: var(--rojo); border-color: var(--rojo); }

.error-msg { color: var(--rojo); font-size: 13px; margin-top: 10px; }
.info-msg { color: var(--text-dim); font-size: 13px; margin-top: 10px; }

/* ── Bottom nav ─────────────────────────────────────────── */
.bottomnav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 8px 4px calc(8px + var(--safe-bottom));
  z-index: 10;
}
.bottomnav button {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  padding: 4px 0;
}
.bottomnav button .ic { font-size: 20px; }
.bottomnav button.activo { color: var(--azul); }
.bottomnav button.fab .ic {
  background: var(--azul);
  color: #fff;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-top: -18px;
}

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end;
  z-index: 20;
}
.modal-sheet {
  background: var(--bg);
  width: 100%;
  max-height: 92dvh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(24px + var(--safe-bottom));
}
.modal-sheet h2 { margin: 4px 0 4px; font-size: 18px; }
.modal-close {
  float: right;
  background: var(--bg-card-2);
  border: none;
  color: var(--text);
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 16px;
}

/* ── Login ──────────────────────────────────────────────── */
.login-wrap {
  min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 24px;
}
.login-wrap .logo { font-size: 40px; text-align: center; margin-bottom: 4px; }
.login-wrap h1 { text-align: center; font-size: 20px; margin: 0 0 4px; }
.login-wrap .sub { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }

/* ── Foto / dropzone ────────────────────────────────────── */
.foto-preview {
  width: 100%;
  border-radius: 12px;
  margin-top: 10px;
  border: 1px solid var(--border);
  max-height: 240px;
  object-fit: cover;
}
.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: 22px 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
