:root {
  --azul: #1f4e79;
  --azul-claro: #2f6db0;
  --verde: #2e7d32;
  --rojo: #c62828;
  --gris-bg: #f4f6f9;
  --gris-borde: #e1e6ee;
  --texto: #1b2733;
  --texto-suave: #5b6b7b;
  --sombra: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--gris-bg);
  color: var(--texto);
  font-size: 14px;
}
a { color: var(--azul-claro); }
h1, h2, h3 { margin: 0 0 .4em; color: var(--azul); }

/* ---------- Login / registro ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-card {
  background: #fff; border-radius: 14px; box-shadow: var(--sombra);
  width: 100%; max-width: 440px; padding: 32px;
}
.brand { text-align: center; margin-bottom: 24px; }
.brand .logo { font-size: 28px; font-weight: 800; color: var(--azul); }
.brand .sub { color: var(--texto-suave); font-size: 13px; }
.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tabs button {
  flex: 1; padding: 10px; border: none; background: var(--gris-bg); border-radius: 8px;
  cursor: pointer; font-weight: 600; color: var(--texto-suave);
}
.tabs button.active { background: var(--azul); color: #fff; }

/* ---------- Layout app ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; background: var(--azul); color: #fff; padding: 22px 16px; flex-shrink: 0;
}
.sidebar .logo { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.sidebar .user { font-size: 12px; opacity: .8; margin-bottom: 26px; word-break: break-word; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 8px;
  color: #dbe6f2; text-decoration: none; margin-bottom: 4px; cursor: pointer; font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a.active { background: rgba(255,255,255,.18); color: #fff; }
.impersonar-bar { background: #8a4b00; color: #fff; padding: 8px 16px; display: flex; align-items: center; gap: 12px; font-size: 13px; }
.impersonar-bar button { margin-left: auto; }
.nav a { justify-content: space-between; }
.nav-badge:not(:empty) { background: #e53935; color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 7px; min-width: 18px; text-align: center; }
.badge.pendiente { background: #fff3cd; color: #8a6d00; }
.badge.validada { background: #e4f5e6; color: var(--verde); }
.badge.revocado { background: #fdeaea; color: var(--rojo); }
.badge.activo { background: #e4f5e6; color: var(--verde); }
.nav .sep { height: 1px; background: rgba(255,255,255,.15); margin: 16px 4px; }
.main { flex: 1; padding: 28px 34px; max-width: 1100px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }

/* ---------- Componentes ---------- */
.card {
  background: #fff; border-radius: 12px; box-shadow: var(--sombra); padding: 22px; margin-bottom: 20px;
}
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .sidebar { width: 64px; }
  .sidebar .logo, .sidebar .user, .nav a span { display: none; }
}

label { display: block; font-size: 12px; font-weight: 600; color: var(--texto-suave); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--gris-borde); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--texto);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul-claro); border-color: transparent; }
.field { margin-bottom: 14px; }
.checkline { display: flex; align-items: center; gap: 8px; }
.checkline input { width: auto; }

button.btn {
  background: var(--azul); color: #fff; border: none; padding: 10px 18px; border-radius: 8px;
  font-weight: 600; cursor: pointer; font-size: 14px;
}
button.btn:hover { background: var(--azul-claro); }
button.btn.secondary { background: #fff; color: var(--azul); border: 1px solid var(--gris-borde); }
button.btn.danger { background: var(--rojo); }
button.btn.ghost { background: transparent; color: var(--texto-suave); }
button.btn.sm { padding: 6px 12px; font-size: 13px; }
button:disabled { opacity: .55; cursor: not-allowed; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--gris-borde); }
th { font-size: 12px; text-transform: uppercase; color: var(--texto-suave); letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: #fafcff; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.ingreso { background: #e4f5e6; color: var(--verde); }
.badge.gasto { background: #fdeaea; color: var(--rojo); }

.stat { text-align: center; }
.stat .v { font-size: 22px; font-weight: 800; color: var(--azul); }
.stat .l { font-size: 12px; color: var(--texto-suave); }
.error { color: var(--rojo); font-size: 13px; margin: 8px 0; }
.muted { color: var(--texto-suave); }
.right { text-align: right; }
.mt { margin-top: 16px; }

.lineas-tabla input { padding: 7px 8px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(120px);
  background: #1b2733; color: #fff; padding: 12px 20px; border-radius: 8px; box-shadow: var(--sombra);
  transition: transform .3s ease; z-index: 999; max-width: 90%;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--verde); }
.toast.err { background: var(--rojo); }

.totales { max-width: 320px; margin-left: auto; }
.totales .line { display: flex; justify-content: space-between; padding: 5px 0; }
.totales .line.total { border-top: 2px solid var(--gris-borde); font-weight: 800; font-size: 17px; margin-top: 6px; padding-top: 10px; }
