/* =========================================================
   FINANZAS · Sistema de diseño
   Concepto: "Libro mayor moderno" (modern ledger)
   — cifras en mono tabular, acento de color por contexto
   (Personal = índigo, Empresa = verde azulado),
   tinta verde/roja clásica de contabilidad para ingreso/gasto.
   ========================================================= */

:root {
  /* Paleta base */
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #FBFBFC;
  --ink: #12141C;
  --ink-soft: #3A3F4B;
  --muted: #6B7280;
  --muted-2: #9AA1AC;
  --line: #E6E8EC;
  --line-strong: #DADDE3;

  /* Semántica: ingreso / gasto */
  --income: #157F52;
  --income-soft: #E7F5EE;
  --expense: #C23B34;
  --expense-soft: #FBEAE8;

  /* Contexto: personal / empresa */
  --personal: #4F46E5;
  --personal-soft: #EEEDFC;
  --empresa: #0F766E;
  --empresa-soft: #E6F5F3;

  /* Forma */
  --radius-lg: 20px;
  --radius: 16px;
  --radius-sm: 10px;

  /* Sombra */
  --shadow-sm: 0 1px 2px rgba(18,20,28,.05), 0 1px 1px rgba(18,20,28,.03);
  --shadow-md: 0 10px 30px -12px rgba(18,20,28,.18);
  --shadow-lg: 0 20px 50px -16px rgba(18,20,28,.24);

  /* Tipografía */
  --font-display: "Sora", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15.5px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body {
  padding-bottom: 92px; /* espacio para bottom nav */
}

body.no-nav { padding-bottom: 0; }

h1, h2, h3, h4, .display-face {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  color: var(--ink);
}

.text-muted-2 { color: var(--muted-2) !important; }
.text-muted  { color: var(--muted) !important; }

.mono, .amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

a { text-decoration: none; }

/* =========================================================
   Header de app (móvil-first)
   ========================================================= */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(245,246,248,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
}

.app-header .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header .brand .bi {
  color: var(--personal);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 1.05rem;
  transition: background .15s ease, transform .1s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active { transform: scale(.94); }

.page-title {
  font-weight: 700;
  font-size: 1.35rem;
  margin: 0;
}
.page-sub {
  color: var(--muted);
  font-size: .85rem;
  margin: 2px 0 0;
}

/* =========================================================
   Bottom navigation (Navegación inferior con botón flotante)
   ========================================================= */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
}

.bottom-nav .nav-inner {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--muted-2);
  font-size: .68rem;
  font-weight: 600;
  width: 60px;
  padding: 6px 0 4px;
  border-radius: 12px;
  text-decoration: none;
  transition: color .15s ease;
}

.bottom-nav .nav-item .bi {
  font-size: 1.28rem;
  line-height: 1;
}

.bottom-nav .nav-item.active {
  color: var(--personal);
}

.bottom-nav .nav-item:not(.fab):active {
  transform: scale(.94);
}

/* Botón flotante central (+) */
.bottom-nav .fab {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: var(--ink);
  color: #fff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -24px;
  box-shadow: var(--shadow-lg);
  font-size: 1.4rem;
  transition: transform .15s ease, background .15s ease;
}

.bottom-nav .fab:active {
  transform: scale(.92);
}

/* =========================================================
   Contenedor de página
   ========================================================= */
.app-main {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 18px 24px;
}

/* =========================================================
   Ledger Card — elemento firma del sistema
   ========================================================= */
.ledger-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: relative;
}

.ledger-card--personal { border-left: 4px solid var(--personal); }
.ledger-card--empresa  { border-left: 4px solid var(--empresa); }

.ledger-card .lc-head {
  padding: 18px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ledger-card .lc-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 5px 10px;
  border-radius: 999px;
}
.tag-personal { background: var(--personal-soft); color: var(--personal); }
.tag-empresa  { background: var(--empresa-soft); color: var(--empresa); }
.tag-income   { background: var(--income-soft); color: var(--income); }
.tag-expense  { background: var(--expense-soft); color: var(--expense); }

.ledger-card .lc-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem;
}
.icon-personal { background: var(--personal-soft); color: var(--personal); }
.icon-empresa  { background: var(--empresa-soft); color: var(--empresa); }

.ledger-card .lc-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0;
}

.lc-rows { padding: 2px 20px 18px; }
.lc-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 9px 0;
  border-top: 1px dashed var(--line);
}
.lc-row:first-child { border-top: none; }
.lc-row .lc-label {
  color: var(--muted);
  font-size: .82rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.lc-row .lc-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: .98rem;
}
.lc-row.balance {
  border-top: 1px solid var(--line-strong);
  margin-top: 4px;
  padding-top: 12px;
}
.lc-row.balance .lc-label { color: var(--ink-soft); font-weight: 600; }
.lc-row.balance .lc-value { font-size: 1.15rem; font-weight: 700; }

.value-income { color: var(--income); }
.value-expense { color: var(--expense); }

.ledger-card .lc-footer {
  padding: 12px 20px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.ledger-card.clickable { cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.ledger-card.clickable:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.ledger-card.clickable:active { transform: translateY(0); }

/* =========================================================
   Tarjeta de movimiento (Historial)
   ========================================================= */
.tx-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.tx-thumb {
  width: 46px; height: 46px;
  border-radius: 13px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.tx-info { flex: 1; min-width: 0; }
.tx-name {
  font-weight: 600;
  font-size: .93rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-meta {
  font-size: .76rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.tx-amount-wrap {
  text-align: right;
  flex-shrink: 0;
}
.tx-amount {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: .95rem;
}
.tx-see {
  border: none;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: .72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  margin-top: 4px;
  border: 1px solid var(--line);
}

/* =========================================================
   Pills de filtro / contexto
   ========================================================= */
.pill-group {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}
.pill-group .pill {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: .82rem;
  padding: 7px 16px;
  border-radius: 999px;
  transition: all .15s ease;
}
.pill-group .pill.active {
  background: var(--ink);
  color: #fff;
}

/* =========================================================
   Selección grande tipo tarjeta (Nuevo Movimiento)
   ========================================================= */
.choice-card {
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .15s ease;
  width: 100%;
  height: 100%;
}
.choice-card .bi { font-size: 1.6rem; }
.choice-card .choice-label {
  display: block;
  margin-top: 10px;
  font-weight: 700;
  font-family: var(--font-display);
  font-size: .95rem;
}
.choice-card .choice-sub {
  font-size: .74rem;
  color: var(--muted);
}
.choice-card.income-choice .bi { color: var(--income); }
.choice-card.expense-choice .bi { color: var(--expense); }
.choice-card.personal-choice .bi { color: var(--personal); }
.choice-card.empresa-choice .bi { color: var(--empresa); }

.choice-card.selected {
  border-color: var(--ink);
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}
.choice-card.selected.income-choice { border-color: var(--income); background: var(--income-soft); }
.choice-card.selected.expense-choice { border-color: var(--expense); background: var(--expense-soft); }
.choice-card.selected.personal-choice { border-color: var(--personal); background: var(--personal-soft); }
.choice-card.selected.empresa-choice { border-color: var(--empresa); background: var(--empresa-soft); }

/* =========================================================
   Steps indicator
   ========================================================= */
.steps-track {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 22px;
}
.steps-track .step-dot {
  height: 4px;
  flex: 1;
  border-radius: 999px;
  background: var(--line-strong);
}
.steps-track .step-dot.done { background: var(--ink); }

/* =========================================================
   Formularios
   ========================================================= */
.form-label {
  font-weight: 600;
  font-size: .82rem;
  color: var(--ink-soft);
}
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  padding: 11px 14px;
  font-size: .95rem;
  background: var(--surface);
}
.form-control:focus, .form-select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(18,20,28,.06);
}

.upload-box {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s ease;
  background: var(--surface-2);
}
.upload-box:hover { border-color: var(--personal); color: var(--personal); }
.upload-box .bi { font-size: 1.6rem; display: block; margin-bottom: 6px; }
.upload-preview {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-top: 12px;
  display: none;
}

/* =========================================================
   Botones
   ========================================================= */
.btn-ink {
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-weight: 600;
  font-size: .95rem;
  transition: transform .1s ease, background .15s ease;
}
.btn-ink:hover { background: #232634; color: #fff; }
.btn-ink:active { transform: scale(.98); }

.btn-outline-soft {
  background: var(--surface);
  border: 1.5px solid var(--line);
  color: var(--ink-soft);
  border-radius: var(--radius-sm);
  font-weight: 600;
  padding: 12px 18px;
  transition: all .15s ease;
}
.btn-outline-soft:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--ink); }

.btn-danger-soft {
  background: var(--expense-soft);
  color: var(--expense);
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  padding: 12px 18px;
}
.btn-danger-soft:hover { background: #f6d9d6; color: var(--expense); }

/* =========================================================
   Login
   ========================================================= */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(680px 380px at 12% -8%, rgba(79,70,229,.10), transparent 60%),
    radial-gradient(680px 380px at 100% 0%, rgba(15,118,110,.10), transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 36px 30px 30px;
  box-shadow: var(--shadow-lg);
}
.login-mark {
  width: 52px; height: 52px;
  border-radius: 16px;
  background: var(--ink);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 18px;
}
.login-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.login-card p.lead-sub {
  color: var(--muted);
  font-size: .88rem;
  margin-bottom: 26px;
}
.input-icon-wrap { position: relative; }
.input-icon-wrap .bi {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted-2);
  font-size: 1rem;
}
.input-icon-wrap .form-control { padding-left: 40px; }
.input-icon-wrap .toggle-pass {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--muted-2);
  font-size: 1rem;
  padding: 4px 6px;
}

/* =========================================================
   Empty state
   ========================================================= */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty-state .bi { font-size: 2.2rem; color: var(--muted-2); margin-bottom: 10px; display: block; }

/* =========================================================
   Detalle de movimiento
   ========================================================= */
.detail-photo {
  width: 100%;
  height: 240px;
  border-radius: var(--radius-lg);
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.detail-photo-placeholder {
  width: 100%;
  height: 240px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.4rem;
  border: 1px solid var(--line);
}
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 0;
  border-top: 1px dashed var(--line);
}
.detail-row:first-child { border-top: none; }
.detail-row .d-label { color: var(--muted); font-size: .84rem; }
.detail-row .d-value { font-weight: 600; font-size: .92rem; }

/* =========================================================
   Resumen mensual — gráfico de barras simple
   ========================================================= */
.month-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 8px;
  margin-bottom: 18px;
}
.month-switch button {
  border: none;
  background: var(--surface-2);
  width: 34px; height: 34px;
  border-radius: 10px;
  color: var(--ink-soft);
}
.month-switch .month-label {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: capitalize;
}

.stat-mini {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.stat-mini .stat-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 700;
}
.stat-mini .stat-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.02rem;
  margin-top: 4px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 18px 10px;
  box-shadow: var(--shadow-sm);
}
.bars-legend {
  display: flex;
  gap: 16px;
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: 14px;
}
.bars-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.bars-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  height: 160px;
  padding: 0 2px;
}
.bar-group {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  height: 100%;
  position: relative;
}
.bar {
  width: 40%;
  border-radius: 6px 6px 3px 3px;
  min-height: 4px;
  transition: height .5s cubic-bezier(.22,1,.36,1);
}
.bar-income { background: var(--income); }
.bar-expense { background: var(--expense); }
.bars-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 2px;
}
.bars-axis span {
  flex: 1;
  text-align: center;
  font-size: .68rem;
  color: var(--muted-2);
  font-weight: 600;
  text-transform: capitalize;
}

/* Utilidades */
.section-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 26px 0 12px;
}
.section-label:first-child { margin-top: 0; }

@media (min-width: 576px) {
  .app-main { padding-top: 26px; }
}