/* ============================================================
   Flujo de Caja — control de gastos e ingresos
   Paleta: tinta profunda + verde billete + óxido + oro tarjeta
   ============================================================ */

:root {
  --bg: #10161a;
  --surface: #1a2227;
  --surface-2: #212b31;
  --border: #2c3940;
  --text: #e8edef;
  --text-dim: #8fa3ab;
  --text-faint: #5c6e75;

  --green: #4fbe8c;
  --green-soft: #4fbe8c22;
  --rust: #e4785b;
  --rust-soft: #e4785b22;
  --gold: #e8b84b;
  --blue: #6fa8dc;

  --cat-efectivo: #5fb3a3;
  --cat-servicios: #6fa8dc;
  --cat-impuestos: #e4785b;
  --cat-tarjeta: #e8b84b;
  --cat-otro: #8b8fa3;
  --cat-sueldo: #4fbe8c;
  --cat-freelance: #7fd1ae;
  --cat-extra: #a8e6c9;
  --cat-otroingreso: #8fa3ab;

  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --radius: 10px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

.hidden { display: none !important; }

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

a { color: var(--gold); }

/* ---------- Marca ---------- */
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}
.brand-mark::before { content: "📒 "; }
.brand-sub {
  font-size: 0.72rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---------- Pantalla de autenticación ---------- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, #1c2a2530 0%, transparent 45%),
    radial-gradient(circle at 85% 90%, #2a201830 0%, transparent 45%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.auth-card .brand { align-items: center; text-align: center; margin-bottom: 24px; }

.auth-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 9px 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}
.auth-tab.active {
  background: var(--surface);
  color: var(--text);
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-dim);
  font-weight: 500;
}

.hint { font-size: 0.72rem; color: var(--text-faint); font-weight: 400; }

input, select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus {
  border-color: var(--green);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s;
}
.btn-primary {
  background: var(--green);
  color: #0b1512;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-faint); }

.form-error {
  color: var(--rust);
  font-size: 0.8rem;
  min-height: 1em;
  margin: 0;
}

/* ---------- App principal ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-name { color: var(--text-dim); font-size: 0.85rem; }

.clock {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.month-picker input {
  padding: 7px 10px;
  font-size: 0.85rem;
}

/* ---------- Modal (cambio de contraseña) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: #05080ac0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-card { max-width: 360px; }
.modal-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 18px;
  text-align: center;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.modal-actions .btn { flex: 1; }

.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 28px 60px;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 22px;
  align-items: start;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 14px;
}

.col-left { display: flex; flex-direction: column; gap: 18px; }

/* ---------- Tarjeta de balance (elemento firma: papel de libro contable) ---------- */
.ledger-card {
  position: relative;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 22px 22px 18px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  overflow: hidden;
}
.ledger-texture {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 27px,
    #ffffff08 28px
  );
  pointer-events: none;
}
.eyebrow {
  position: relative;
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.balance-amount {
  position: relative;
  font-family: var(--font-mono);
  font-size: 2.4rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}
.balance-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-dim);
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}
.balance-row strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.balance-general {
  position: relative;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 0.78rem;
  color: var(--text-faint);
}
.balance-general strong {
  font-family: var(--font-mono);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 5px;
}
.dot-green { background: var(--green); }
.dot-rust { background: var(--rust); }

/* ---------- Formulario de movimiento ---------- */
.form-card form { display: flex; flex-direction: column; gap: 14px; }

.type-toggle {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 4px;
}
.type-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 8px 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}
.type-btn.active[data-type="gasto"] { background: var(--rust-soft); color: var(--rust); }
.type-btn.active[data-type="ingreso"] { background: var(--green-soft); color: var(--green); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---------- Gráfico ---------- */
.chart-card canvas { max-height: 240px; }
.empty-note {
  color: var(--text-faint);
  font-size: 0.85rem;
  text-align: center;
  padding: 20px 0;
}

.category-ranking {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.rank-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rank-row-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}
.rank-label { color: var(--text-dim); font-weight: 500; }
.rank-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.rank-bar-bg {
  height: 6px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.rank-bar-fill {
  height: 100%;
  border-radius: 4px;
}

/* ---------- Cinta de movimientos ---------- */
.ledger-list-card { min-height: 400px; }
.ledger-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.filters { display: flex; gap: 8px; }
.filters select { padding: 7px 10px; font-size: 0.8rem; }

.tx-list {
  display: flex;
  flex-direction: column;
}

.tx-row {
  display: grid;
  grid-template-columns: 3px 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 13px 4px;
  border-bottom: 1px dashed var(--border);
}
.tx-row:last-child { border-bottom: none; }

.tx-stripe { width: 3px; height: 32px; border-radius: 2px; }

.tx-info { min-width: 0; }
.tx-desc {
  font-weight: 500;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-meta {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 2px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.tx-cat-badge {
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}

.tx-amount {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tx-amount.gasto { color: var(--rust); }
.tx-amount.ingreso { color: var(--green); }

.tx-actions { display: flex; gap: 6px; }
.tx-action-btn {
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: 6px;
}
.tx-action-btn:hover { color: var(--text); background: var(--surface-2); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px #00000055;
  z-index: 100;
}
.toast.error { border-color: var(--rust); color: var(--rust); }
.toast.success { border-color: var(--green); color: var(--green); }
