/* ============================================================
   APP.CSS — Layout y estilos globales
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  /* Evita scroll horizontal. clip es fiable en iOS (hidden no lo es en PWA
     instalada) y no crea contenedor de scroll ni rompe position:sticky. */
  overflow-x: clip;
  width: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: clip;
  max-width: 100%;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* ============================================================
   APP SHELL
   ============================================================ */

#app {
  display: flex;
  min-height: 100vh;
  overflow-x: clip;
  max-width: 100vw;
}

/* Loading Screen */
#loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  z-index: 9999;
  transition: opacity 0.3s;
}
#loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: var(--space-md);
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -3px;
}
.is-loading { opacity: 0.85; cursor: progress; }

/* Pull-to-refresh */
.ptr-indicator {
  position: fixed;
  top: -44px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  box-shadow: var(--shadow-md);
  opacity: 0;
  z-index: 200;
  pointer-events: none;
}
.ptr-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
}
.ptr-indicator.ready .ptr-spinner { border-top-color: var(--color-income); }
.ptr-indicator.spinning .ptr-spinner { animation: spin 0.7s linear infinite; }

/* Splash de inicio — reveal del logo (triángulo) + nombre + tagline. Se ve
   mientras la app carga, con un mínimo de ~1.2s, y luego #loading-screen
   hace fade-out. */
.splash-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.splash-logo {
  color: var(--accent);
  animation: splashLogoIn 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.splash-name {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  animation: splashUp 0.5s ease-out 0.22s both;
}
.splash-tagline {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  animation: splashUp 0.5s ease-out 0.42s both;
}
@keyframes splashLogoIn {
  from { opacity: 0; transform: scale(0.6) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes splashUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .splash-logo, .splash-name, .splash-tagline { animation: none; }
}

/* ============================================================
   SIDEBAR (Desktop)
   ============================================================ */

.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: var(--space-lg);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: var(--space-xl) 0 var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: var(--space-lg);
}

.sidebar-logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* Logo: variante por tema (img externo en vez de SVG inline de ~14KB).
   ondark = wordmark blanco (fondo oscuro), onlight = wordmark negro. */
.sidebar-logo-img { width: auto; display: block; }
.sidebar-logo--onlight { display: none; }
.theme-light .sidebar-logo--ondark { display: none; }
.theme-light .sidebar-logo--onlight { display: block; }
@media (prefers-color-scheme: light) {
  .theme-system .sidebar-logo--ondark { display: none; }
  .theme-system .sidebar-logo--onlight { display: block; }
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent);
  color: white;
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-color);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */

.main-content {
  flex: 1;
  min-width: 0;        /* permite que el flex item se contraiga (no fuerza ancho) */
  margin-left: 240px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: clip;    /* corta cualquier desborde horizontal del contenido */
}

.mobile-header {
  display: none;
  padding: var(--space-md) var(--space-lg);
  /* PWA instalada (standalone): con status-bar-style black-translucent +
     viewport-fit=cover, el contenido se dibuja DETRÁS de la barra de estado
     del iPhone. Reservamos su altura para que el título/tasa no queden bajo
     la hora. En navegador (sin inset) cae al padding normal. */
  padding-top: max(var(--space-md), env(safe-area-inset-top));
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.mobile-title {
  font-size: 1rem;
  font-weight: 700;
}

.menu-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
}

.menu-btn:hover {
  background: var(--bg-hover);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.current-rate {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  transition: color 0.2s;
}
/* Coloreo vs apertura del día: sube (devaluación) = rojo, baja = verde. */
.current-rate.rate-up { color: var(--color-expense); }
.current-rate.rate-down { color: var(--color-income); }
.rate-delta { font-size: 0.92em; font-weight: 700; white-space: nowrap; }

.page-content {
  flex: 1;
  padding: var(--space-xl);
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

/* ============================================================
   BOTTOM NAV — Liquid Glass pill (Webull / iOS 26)
   ============================================================ */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  left: 14px;
  right: 14px;
  width: auto;
  max-width: 460px;
  margin: 0 auto;
  height: 64px;
  border-radius: 32px;
  background: rgba(10,14,28,0.12);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow:
    0 10px 40px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.12);
  z-index: 100;
  overflow: hidden;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Specular highlight top edge — cristal mojado */
.bottom-nav::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, transparent 30%);
  pointer-events: none;
  z-index: 1;
}

/* Keyboard */
body.keyboard-open .bottom-nav,
body.page-new-transaction .bottom-nav {
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
}
body.keyboard-open .cat-edit-overlay {
  align-items: flex-start;
  padding-top: 8px;
}
body.keyboard-open .cat-edit-modal {
  max-height: 70vh;
}

.bottom-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 100%;
  padding: 0 10px;
  position: relative;
  z-index: 2;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1 1 0;
  min-width: 48px;
  padding: 8px 2px;
  color: rgba(255,255,255,0.92);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  background: none;
  border: none;
  position: relative;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item:active {
  transform: scale(0.94);
  transition: transform 0.1s ease;
}

/* Active item pops out above the pill */
.bottom-nav-item.active {
  color: #FFFFFF;
  transform: translateY(-14px);
}

.bottom-nav-item.active .nav-label {
  color: #5B8DFF;
  font-weight: 600;
}

/* Bubble behind active icon — hijo absoluto, no ::before
   para tener su propio backdrop-filter sin que el container lo aplaste */
.nav-bubble {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 96px;
  height: 48px;
  border-radius: 24px;
  background: radial-gradient(ellipse at 50% 35%,
    rgba(91,141,255,0.55) 0%,
    rgba(40,80,200,0.35) 60%,
    rgba(20,40,120,0.15) 100%);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow:
    0 6px 20px rgba(91,141,255,0.45),
    inset 0 1px 0 rgba(255,255,255,0.30);
  z-index: 0;
  pointer-events: none;
}

.bottom-nav-item.active .nav-bubble {
  display: block;
}

.bottom-nav-item .nav-icon {
  position: relative;
  z-index: 1;
  width: 24px;
  height: 24px;
}

.bottom-nav-item .nav-label {
  position: relative;
  z-index: 1;
}

/* ============================================================
   SIDEBAR OVERLAY (Mobile)
   ============================================================ */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================================
   STAT CARDS (Dashboard)
   ============================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: var(--space-xs);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* ── Hero balance card ── */
.hero-balance-card {
  background: linear-gradient(135deg, #1e3a8a, #1e40af);
  border-radius: var(--radius-lg);
  padding: 22px 20px 18px;
  margin-bottom: var(--space-md);
  color: #fff;
  box-shadow: 0 8px 24px rgba(30, 64, 175, 0.35);
  position: relative;
}
.hero-balance-title {
  font-size: 0.75rem;
  opacity: 0.65;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.hero-balance-amount {
  font-size: clamp(1.5rem, 9vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
  line-height: 1.05;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.hero-balance-amount.negative { color: #fca5a5; }

/* Botón ⋯ en la esquina del card balance — sutil con borde fino Sky */
.hero-balance-menu {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.hero-balance-menu:hover { background: rgba(0,0,0,0.4); }
.hero-balance-menu:active { transform: scale(0.92); }
.hero-ie-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.hero-ie-item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  cursor: pointer;
  padding: 6px 8px;
  margin: -6px -8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.hero-ie-item:hover,
.hero-ie-item:focus-visible { background: var(--bg-hover); }
.hero-ie-item:active { transform: scale(0.98); }
.hero-ie-arrow {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(134, 239, 172, 0.18);
  color: #86efac;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
}
.hero-ie-arrow.hero-ie-expense {
  background: rgba(252, 165, 165, 0.18);
  color: #fca5a5;
}
.hero-ie-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}
.hero-ie-lbl {
  font-size: 0.68rem;
  opacity: 0.55;
  font-weight: 500;
}
.hero-divider {
  width: 1px;
  height: 36px;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
}
.hero-ratio-bar {
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin-top: 14px;
  overflow: hidden;
}
.hero-ratio-fill {
  height: 100%;
  background: #86efac;
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* ── Rate + Converter 2-column grid ── */
.rate-converter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.rate-converter-grid .stat-card-rate,
.rate-converter-grid .stat-card-converter {
  grid-column: auto;
  margin-bottom: 0;
}

/* Rate hero card */
.stat-card-rate {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-xl);
  background: linear-gradient(135deg, var(--bg-card), var(--bg-tertiary));
  border-color: var(--color-warning);
  border-width: 1px;
}
.rate-converter-grid .stat-card-rate {
  padding: var(--space-md);
}
.rate-converter-grid .rate-value {
  font-size: 1.4rem;
}
.rate-converter-grid .converter-row {
  flex-direction: column;
  gap: 6px;
}
.rate-converter-grid .converter-input-group {
  width: 100%;
}
.rate-converter-grid .converter-input {
  min-width: 0;
  width: 100%;
}
.rate-converter-grid .converter-arrow {
  display: none;
}
.rate-converter-grid .converter-result {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-income);
  text-align: center;
  padding: 4px 0;
}

.rate-hero {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}

.rate-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--color-warning);
  letter-spacing: -0.03em;
}

.rate-unit {
  font-size: 1rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.rate-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  margin-bottom: 2px;
}

.rate-source {
  color: var(--text-tertiary);
}

.rate-trend {
  font-weight: 600;
}

.rate-trend.positive { color: var(--color-income); }
.rate-trend.negative { color: var(--color-expense); }

.rate-secondary {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 4px;
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}

.rate-time {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  opacity: 0.6;
  margin-bottom: 4px;
}

.rate-refresh-btn {
  display: inline-block;
  cursor: pointer;
  font-size: 0.9rem;
  opacity: 0.5;
  transition: opacity 0.2s, transform 0.3s;
  user-select: none;
}

.rate-refresh-btn:hover {
  opacity: 1;
}

.rate-refresh-btn:active {
  transform: rotate(180deg);
}

/* Conversor rápido */
.stat-card-converter {
  grid-column: 1 / -1;
}

.converter-title {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: var(--space-sm);
}

.converter-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.converter-input-group {
  display: flex;
  flex: 1;
  gap: 4px;
}

.converter-input {
  flex: 1;
  min-width: 0;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
}

.converter-select {
  width: auto;
  min-width: 70px;
}

.converter-arrow {
  font-size: 1.3rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.converter-result {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-warning);
  min-width: 80px;
  text-align: center;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.converter-rate-info {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin-top: 6px;
  text-align: center;
}

/* Floating action button — solo desktop. En mobile el bottom nav ya
   tiene su propio "+ Nuevo", el FAB encima duplicaba y los dos
   botones quedaban a 5px de distancia. */

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

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
}

/* ============================================================
   FORMS
   ============================================================ */

.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 14px 16px 14px 16px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-md);
  min-height: 52px;
  transition: box-shadow 0.15s;
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  box-shadow: var(--shadow-accent);
}

.form-input::placeholder,
.form-select::placeholder,
.form-textarea::placeholder {
  color: var(--text-tertiary);
}

.form-input.has-icon {
  padding-left: 44px;
}

/* Fix autofill: Safari/Chrome ponen fondo amarillo y texto ilegible */
.form-input:-webkit-autofill,
.form-input:-webkit-autofill:hover,
.form-input:-webkit-autofill:focus,
.form-input:-webkit-autofill:active {
  -webkit-background-clip: text;
  -webkit-text-fill-color: var(--text-primary) !important;
  transition: background-color 5000s ease-in-out 0s;
  box-shadow: inset 0 0 0 1000px var(--bg-secondary) !important;
  caret-color: var(--text-primary);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  min-height: 52px;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn-secondary:hover {
  background: rgba(0,112,224,0.08);
}

.btn-danger {
  background: var(--color-expense);
  color: white;
}

.btn-ghost {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.btn-ghost:hover {
  background: var(--bg-hover);
}

.btn-sm {
  padding: 4px 12px;
  font-size: 13px;
  min-height: auto;
}

/* FAB — botón flotante para nueva transacción */
.fab {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  font-size: 28px;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  z-index: 100;
  transition: transform 0.15s, opacity 0.2s;
}
.fab:active { transform: scale(0.92); }
.fab.hidden { opacity: 0; pointer-events: none; }

/* ============================================================
   TRANSACTION FORM — Numpad + monto gigante
   ============================================================ */

.tx-form-page {
  display: flex;
  flex-direction: column;
}

/* El acento del formulario refleja el tipo: verde ingreso, rojo gasto.
   Redefine --accent dentro del form → cursor, moneda activa y tecla check. */
.tx-form-page.tx-type-income {
  --accent: var(--color-income);
  --accent-hover: #1AB85E;
  --accent-text: #0A0A0A;
  --shadow-accent: 0 0 0 4px rgba(31,203,111,0.20);
}
.tx-form-page.tx-type-expense {
  --accent: var(--color-expense);
  --accent-hover: #D43A3A;
  --accent-text: #FFFFFF;
  --shadow-accent: 0 0 0 4px rgba(230,73,73,0.20);
}

.tx-type-toggle {
  display: flex;
  gap: 0;
  background: var(--bg-secondary);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin-bottom: var(--space-lg);
}
.tx-type-btn {
  flex: 1;
  min-width: 0;                 /* permite encoger con 3 botones */
  white-space: nowrap;
  padding: 10px 6px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  opacity: 0.5;
}
.tx-type-btn.active {
  background: var(--bg-card);
  opacity: 1;
  box-shadow: var(--shadow-sm);
}

.tx-amount-display {
  text-align: center;
  /* Antes flex:1 + min-height de la página creaban un vacío enorme arriba que
     empujaba el teclado (y "Guardar") fuera de pantalla. Ahora es compacto. */
  padding: var(--space-md) 0 var(--space-sm);
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.tx-amount-hero {
  font-size: 48px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: var(--space-md);
  min-height: 60px;
  position: relative;
  display: inline-block;
}
/* Cursor titilante tipo terminal */
.tx-amount-hero::after {
  content: '|';
  color: var(--accent);
  font-weight: 300;
  animation: blink 1s step-end infinite;
  margin-left: 2px;
}
@keyframes blink {
  50% { opacity: 0; }
}
.tx-currency-toggle {
  display: inline-flex;
  background: var(--bg-secondary);
  border-radius: var(--radius-pill);
  padding: 2px;
  margin: 0 auto var(--space-sm);
}
.tx-curr-btn {
  padding: 6px 16px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.tx-curr-btn.active {
  background: var(--accent);
  color: var(--accent-text);
}
.tx-conversion-live {
  font-size: 14px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.tx-chips-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: var(--space-sm) 0 var(--space-md);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tx-chips-scroll::-webkit-scrollbar { display: none; }

.chip {
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--border-strong); }
.chip-active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

/* Numpad — compacto para que entre en pantallas chicas */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 6px 0;
}
.numpad-key {
  padding: 8px 6px;
  /* Borde + superficie propia + sombra: antes la tecla y el panel usaban el
     mismo color y en modo claro los números parecían flotar sin botón. */
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.1s, box-shadow 0.1s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  min-height: 44px;
  /* min-width:0 + overflow:hidden: sin esto, en el grid de 4 columnas la tecla
     "Listo" no se encogía bajo su contenido y forzaba el teclado más ancho que
     la pantalla → scroll horizontal en toda la app (el teclado fixed sigue en
     layout aunque esté cerrado). */
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
}
.numpad-key:active {
  background: var(--bg-hover);
  transform: scale(0.95);
  box-shadow: none;
}
.numpad-key-dec { font-weight: 700; }
.numpad-key-del { font-size: 18px; color: var(--text-secondary); }
.numpad-key-clear {
  background: transparent;
  color: var(--color-warning);
  font-size: 15px;
  font-weight: 700;
}
.numpad-key-check {
  background: var(--accent) !important;
  color: var(--accent-text) !important;
  font-size: 15px !important;
  font-weight: 700 !important;
}
.numpad-key-check:active { opacity: 0.85; }

/* ============================================================
   TRANSACTION LIST — Search pill, filter toggle, items
   ============================================================ */

.tx-list-header {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: var(--space-sm);
}
.tx-search-pill {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  min-height: 44px;
}
.tx-search-pill svg { color: var(--text-tertiary); flex-shrink: 0; }
.tx-search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
}
.tx-search-input::placeholder { color: var(--text-tertiary); }

.tx-filter-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-pill);
  padding: 3px;
  margin-bottom: var(--space-sm);
}
.tx-filter-btn {
  flex: 1;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.tx-filter-btn.active {
  background: var(--accent);
  color: var(--accent-text);
}

.tx-filter-wallet-row {
  margin-bottom: var(--space-sm);
}

.tx-date-group {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  padding: var(--space-sm) 0 var(--space-xs);
  margin-top: var(--space-sm);
}

/* Body default typography */
body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Transaction date group headers */
.tx-date-group {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px 4px;
}

/* Transaction action sheet buttons */
.tx-action-btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-primary);
  font-family: inherit;
}
.tx-action-btn:hover { background: var(--bg-hover); }
.tx-action-danger    { color: var(--color-expense) !important; }

.wallet-preset-btn {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
}
.wallet-preset-btn:hover,
.wallet-preset-btn.active {
  background: var(--color-primary, #3b82f6);
  color: #fff;
  border-color: transparent;
}

.wallet-menu-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-primary);
}
.wallet-menu-item:hover {
  background: var(--bg-hover);
}
.wallet-menu-danger {
  color: var(--color-expense);
}

.btn-icon {
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
}
.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-fab {
  position: fixed;
  bottom: 80px;
  right: var(--space-lg);
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: white;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  z-index: 50;
}
.btn-fab:hover {
  transform: scale(1.05);
}
.btn-fab:active {
  transform: scale(0.95);
}

/* ============================================================
   TRANSACTION LIST
   ============================================================ */

.transaction-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.15s;
}
.transaction-item:hover {
  background: var(--bg-hover);
}
.transaction-item:last-child {
  border-bottom: none;
}

.transaction-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.transaction-icon.expense {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-expense);
}
.transaction-icon.income {
  background: rgba(34, 197, 94, 0.1);
  color: var(--color-income);
}
.transaction-icon.transfer {
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-transfer);
}

.transaction-info {
  flex: 1;
  min-width: 0;
}

.transaction-desc {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transaction-meta {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  display: flex;
  gap: var(--space-sm);
  margin-top: 2px;
}

.transaction-amounts {
  text-align: right;
  flex-shrink: 0;
}

.transaction-amount-original {
  font-weight: 800;
  font-size: 1rem;
}

.transaction-amount-usdt {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.transaction-receipt-thumb {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border-color);
  cursor: pointer;
  flex-shrink: 0;
}

/* ============================================================
   SYNC STATUS
   ============================================================ */

.sync-status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.sync-dot.synced { background: var(--color-income); }
.sync-dot.pending { background: var(--color-warning); animation: pulse 1s infinite; }
.sync-dot.offline { background: var(--color-expense); }
.sync-dot.error { background: var(--color-expense); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-xl);
  transform: translateY(20px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

/* ============================================================
   RECEIPT VIEWER (full screen)
   ============================================================ */

.receipt-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}
.receipt-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.receipt-viewer .close-btn {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
}

/* ============================================================
   BUDGET BAR
   ============================================================ */

.budget-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: var(--space-sm);
}

.budget-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.5s ease;
}

.budget-bar-fill.safe { background: var(--color-income); }
.budget-bar-fill.warning { background: var(--color-warning); }
.budget-bar-fill.danger { background: var(--color-expense); }

/* ============================================================
   CAMERA VIEW
   ============================================================ */

.camera-view {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 250;
  display: flex;
  flex-direction: column;
}
.camera-view video {
  flex: 1;
  width: 100%;
  object-fit: cover;
}
.camera-controls {
  display: flex;
  justify-content: center;
  gap: var(--space-xl);
  padding: var(--space-lg);
  background: rgba(0,0,0,0.5);
}
.camera-capture {
  width: 64px;
  height: 64px;
  border: 4px solid white;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.camera-capture:active {
  background: rgba(255,255,255,0.3);
}
.camera-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  color: white;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-sm);
}

/* ============================================================
   MISC
   ============================================================ */

.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-tertiary);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: empty-fade-in 0.4s ease both;
}
@keyframes empty-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.empty-state .empty-icon,
.empty-state .empty-icon-lg {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  margin-bottom: var(--space-lg);
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--accent);
  opacity: 1;
}
.empty-state h3 {
  color: var(--text-primary);
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.empty-state p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 260px;
  line-height: 1.5;
}
.empty-state .empty-cta {
  margin-top: var(--space-lg);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
.empty-state .empty-cta:active { transform: scale(0.96); }
.empty-state .empty-cta:hover { background: var(--accent-hover); }
.empty-state-sm {
  text-align: center;
  padding: var(--space-lg);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.tabs {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--space-xs);
}

.tab {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab:hover {
  color: var(--text-primary);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
}
.badge-paid { background: rgba(34, 197, 94, 0.1); color: var(--color-income); }
.badge-pending { background: rgba(245, 158, 11, 0.1); color: var(--color-warning); }
.badge-overdue { background: rgba(239, 68, 68, 0.1); color: var(--color-expense); }
.badge-draft { background: rgba(100, 116, 139, 0.1); color: var(--text-secondary); }

.tag {
  display: inline-block;
  padding: 2px 6px;
  font-size: 0.7rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* Selection */
::selection { background: rgba(59, 130, 246, 0.2); }

/* ============================================================
   PAGE HEADER — titulo + acciones consistentes
   ============================================================ */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin: 0;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.section-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  line-height: 1.5;
}

.actions-row {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.actions-row .btn {
  flex: 1 1 auto;
  min-width: max-content;
}

.app-footer {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

/* Filtros y barras de busqueda */
.filters-row {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  align-items: center;
}
.filters-row .form-input,
.filters-row .form-select {
  width: auto;
  flex: 1;
  min-width: 140px;
}
.search-input {
  flex: 2 !important;
  min-width: 180px !important;
}

/* Toast (notificaciones efímeras) */
.toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 500;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-success { background: var(--color-income); color: white; }
.toast-error { background: var(--color-expense); color: white; }
.toast-warning { background: var(--color-warning); color: #0a0a0b; }

/* Confirm dialog */
.confirm-modal {
  max-width: 380px;
  padding: var(--space-xl);
  text-align: center;
}
.confirm-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 var(--space-sm);
  letter-spacing: -0.02em;
}
.confirm-message {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0 0 var(--space-lg);
}
.confirm-actions {
  display: flex;
  gap: var(--space-sm);
}
.confirm-actions .btn {
  flex: 1;
  padding: 11px 16px;
}

/* ============================================================
   ITEM ACTIONS (bottom sheet / modal)
   ============================================================ */
.item-actions-modal {
  padding: 0;
  overflow: hidden;
  max-width: 420px;
}
.item-actions-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-color);
}
.item-actions-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  word-break: break-word;
}
.item-actions-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.item-actions-list {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
}
.item-action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 20px;
  background: transparent;
  border: none;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  border-radius: 0;
  transition: background 0.12s;
  min-height: 48px;
}
.item-action-btn:hover,
.item-action-btn:focus-visible {
  background: var(--bg-hover);
  outline: none;
}
.item-action-btn:active { background: var(--bg-tertiary); }
.item-action-btn.danger { color: var(--color-expense); }
.item-action-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  opacity: 0.8;
}
.item-action-btn.danger .item-action-icon { opacity: 1; }
.item-action-label { flex: 1; }
.item-action-cancel {
  border-top: 1px solid var(--border-color);
  justify-content: center;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Cards "tappable" — clickeable, con chevron y feedback */
.tappable {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.1s;
}
.tappable:active { transform: scale(0.997); }
.tappable:hover { background: var(--bg-hover); }
@media (hover: hover) {
  .tappable:hover { background: var(--bg-hover); }
}
.tappable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Wallet cards: layout limpio sin botones, chevron a la derecha */
.wallet-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px var(--space-md);
}
.wallet-card-info { flex: 1; min-width: 0; }
.wallet-card .wallet-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wallet-card .wallet-meta {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-top: 2px;
  font-weight: 500;
}
.wallet-chevron {
  font-size: 1.4rem;
  color: var(--text-tertiary);
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.6;
}

/* Invoice cards */
.invoice-card { padding: 14px var(--space-md); }
.invoice-card-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.invoice-card-info { flex: 1; min-width: 0; }
.invoice-card-number {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}
.invoice-card-client {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 1px;
}
.invoice-card-due {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-top: 1px;
}
.invoice-card-amounts {
  text-align: right;
  flex-shrink: 0;
}
.invoice-card-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.invoice-card-usdt {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   COMMAND PALETTE (Cmd+K)
   ============================================================ */
.cmd-palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 600;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.cmd-palette-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.cmd-palette {
  width: 100%;
  max-width: 540px;
  margin: 0 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.04) inset;
  overflow: hidden;
  transform: translateY(-8px) scale(0.98);
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.cmd-palette-overlay.show .cmd-palette { transform: translateY(0) scale(1); }
.cmd-palette-input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 16px 20px;
  font-size: 1rem;
  color: var(--text-primary);
  outline: none;
  border-bottom: 1px solid var(--border-color);
  font-family: inherit;
}
.cmd-palette-input::placeholder { color: var(--text-tertiary); }
.cmd-palette-list {
  max-height: 360px;
  overflow-y: auto;
  padding: 6px;
}
.cmd-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
}
.cmd-item.selected {
  background: var(--bg-tertiary);
}
.cmd-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 1rem;
  flex-shrink: 0;
}
.cmd-item.selected .cmd-icon { color: var(--text-primary); }
.cmd-label {
  flex: 1;
  font-size: 0.92rem;
  color: var(--text-primary);
  font-weight: 500;
}
.cmd-hint {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}
.cmd-item.selected .cmd-hint {
  background: var(--bg-hover);
}
.cmd-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.9rem;
}
.cmd-palette-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  font-size: 0.72rem;
  color: var(--text-tertiary);
}
.cmd-palette-footer kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg-tertiary);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border-color);
  margin-right: 2px;
}

/* ============================================================
   BUDGET ALERT BANNER (cuando presupuesto al 80%/100%)
   ============================================================ */
.budget-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  border: 1px solid;
  font-size: 0.88rem;
  line-height: 1.4;
}
.budget-alert.warning {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.3);
  color: var(--color-warning);
}
.budget-alert.danger {
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--color-expense);
}
.budget-alert-icon { font-size: 1.1rem; flex-shrink: 0; }
.budget-alert-text { flex: 1; color: var(--text-primary); }
.budget-alert-text strong { color: inherit; }

/* Auth wrapper */
.auth-wrapper {
  max-width: 400px;
  margin: 0 auto;
  padding: 48px 16px;
  text-align: center;
}
@media (max-width: 768px) {
  .auth-wrapper { padding: 24px 16px; }
}

/* Insight tip box */
.insight-box {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-secondary);
}
.insight-box-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}
.insight-box strong { color: var(--text-primary); font-weight: 600; }

/* Budget period toggle */
.budget-period-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-pill);
  padding: 3px;
  margin-bottom: var(--space-sm);
}
.period-btn {
  flex: 1;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.period-btn.active {
  background: var(--accent);
  color: var(--accent-text);
}
.quincena-selector {
  display: flex;
  gap: 4px;
  margin-bottom: var(--space-md);
}

/* Onboarding card (primeros pasos cuando dashboard vacio) */
.onboarding-card { padding: var(--space-lg); position: relative; }
.onboarding-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.onboarding-dismiss {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}
.onboarding-dismiss:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.onboarding-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.onboarding-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text-secondary);
}
.onboarding-list strong { color: var(--text-primary); }
.onboarding-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-income);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}
.onboarding-list kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  font-size: 0.78rem;
  margin: 0 2px;
}

/* Segmented control (toggle de tema, modo, etc.) */
.segmented {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: var(--radius-md);
  width: 100%;
}
.segmented-option {
  flex: 1;
  padding: 9px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  font-family: inherit;
}
.segmented-option.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.segmented-option:not(.active):hover {
  color: var(--text-primary);
}

/* Card description bajo header */
.card-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  line-height: 1.5;
}

/* View Transitions (theme toggle) */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 9999; }
html.vt-closing::view-transition-old(root) { z-index: 9999; }
html.vt-closing::view-transition-new(root) { z-index: 1; }

/* ============================================================
   POLISH — Sidebar logo gradient + skeletons + iconos
   ============================================================ */

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.sidebar-logo::before {
  content: '';
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--color-income), var(--accent));
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

/* Skeleton loaders (placeholders animados) */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 0%,
    var(--bg-hover) 50%,
    var(--bg-tertiary) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-text.lg { height: 24px; width: 60%; }
.skeleton-text.sm { height: 10px; width: 40%; }
.tx-skeleton-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-sm);
  border-bottom: 1px solid var(--border-color);
}
.tx-skeleton-icon { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.tx-skeleton-lines { flex: 1; }
.tx-skeleton-lines .skeleton-text { margin-bottom: 6px; }
.tx-skeleton-lines .skeleton-text:last-child { margin-bottom: 0; }
.skeleton-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}

/* Card hover lift (premium feel) */
.card { transition: transform 0.18s ease, border-color 0.18s; }
.stat-card { transition: transform 0.18s ease, border-color 0.18s; }
@media (hover: hover) {
  .stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--text-tertiary);
  }
}

/* Typography refine */
body { letter-spacing: -0.005em; }
.stat-value { font-variant-numeric: tabular-nums; }
.transaction-amount-original,
.transaction-amount-usdt,
.rate-value,
.converter-result,
.invoice-card-amount,
.budget-card-amount { font-variant-numeric: tabular-nums; }

/* Focus ring accesible */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* PWA install banner (aparece cuando es instalable) */
.pwa-install-banner {
  position: fixed;
  bottom: calc(88px + env(safe-area-inset-bottom, 0));
  left: 16px;
  right: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  z-index: 480;
  transform: translateY(120%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 480px;
  margin: 0 auto;
}
.pwa-install-banner.show { transform: translateY(0); }
.pwa-install-content {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pwa-install-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--color-income), var(--accent));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  flex-shrink: 0;
}
.pwa-install-text {
  flex: 1;
  font-size: 0.85rem;
  line-height: 1.3;
  color: var(--text-secondary);
}
.pwa-install-text strong { color: var(--text-primary); font-size: 0.9rem; }
@media (min-width: 768px) {
  .pwa-install-banner {
    bottom: 24px;
    left: auto;
    right: 24px;
    max-width: 380px;
  }
}

/* Banner offline (aparece cuando navigator.onLine = false) */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--color-expense);
  color: white;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  z-index: 999;
  transform: translateY(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.offline-banner.show {
  transform: translateY(0);
}
.offline-banner.online-restored {
  background: var(--color-income);
}

/* Page transitions (fade-in suave entre paginas) */
.page-content > * {
  animation: page-fade-in 0.22s ease-out;
}
@keyframes page-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   RATE + CONVERTER BAR — Tasa hero + conversor multi-moneda en una card
   ============================================================ */

.rate-converter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: 16px;
}

.rate-converter-tasa {
  flex: 0 0 auto;
  text-align: center;
  min-width: 100px;
}
.rate-converter-tasa-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--color-warning);
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.rate-converter-tasa-meta {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}
.rate-converter-cop-meta,
.rate-converter-bcv-meta {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.rate-spread {
  color: var(--text-secondary);
  font-weight: 600;
  margin-left: 4px;
}

/* ============================================================
   CALCULADORA REDISEÑADA — jerarquia clara
   ============================================================
   Layout vertical:
     1. Rates strip (pills compactos, info terciaria)
     2. Input row (input + select, interactivo)
     3. Result hero (USDT grande, primario)
     4. Equivalents list (filas label/value, secundario)
*/

.calc-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* 1) Rates strip — pills compactos, scaneable */
.calc-rates-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-color);
}
.calc-rate-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.calc-rate-pill-label {
  color: var(--text-tertiary);
  font-weight: 500;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.calc-rate-pill-value {
  color: var(--text-primary);
  font-weight: 700;
}
.calc-rate-pill-spread {
  background: transparent;
  border: 1px dashed var(--border-color);
}
.calc-rate-pill-spread .calc-rate-pill-value {
  color: var(--color-warning, #f59e0b);
}
.calc-refresh-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.calc-refresh-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

/* 2) Input row — el input es el elemento mas tappable e importante */
.calc-input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.calc-input {
  flex: 1 1 auto;
  min-width: 0;                       /* CRITICO: sin esto, flex no contrae y la barra rebalsa */
  width: auto;                        /* Override form-input width:100% que rompe flex */
  font-size: 1.75rem;
  font-weight: 700;
  text-align: right;
  letter-spacing: -0.02em;
  height: 64px;                       /* tappable + suficiente para ver texto grande */
  padding: 10px 18px;                 /* respiracion vertical, no 0 */
  font-variant-numeric: tabular-nums;
  background: var(--bg-secondary);
  color: var(--text-primary);
  caret-color: var(--color-income);   /* cursor verde, visible */
}
.calc-input::placeholder {
  color: var(--text-tertiary);
  font-weight: 500;
}
/* Display tappable del monto (reemplaza el input nativo → numpad de la app) */
.calc-amount-display {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1.75rem;
  font-weight: 700;
  text-align: right;
  letter-spacing: -0.02em;
  height: 64px;
  padding: 10px 18px;
  font-variant-numeric: tabular-nums;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  transition: box-shadow 0.15s;
}
/* Borde sólido (no translúcido): un glow con alpha 0.2 sobre fondo blanco se
   ve pálido/celeste. Con el color sólido se lee el azul real. */
.calc-amount-display.active { box-shadow: 0 0 0 2px var(--accent); }
/* Numpad del conversor — panel FIJO abajo (estilo teclado), no inline,
   asi nunca queda cortado por el borde de pantalla o el bottom-nav. */
.calc-numpad {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0));
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -8px 24px rgba(0,0,0,0.45);
  bottom: -360px;
  opacity: 0;
  pointer-events: none;
  max-width: 600px;
  margin: 0 auto;
}
.calc-numpad.open { opacity: 1; pointer-events: auto; }
.numpad-key {
  flex: 1 0 22%;
  min-width: 0;
  padding: 10px 4px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.1s, box-shadow 0.1s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  min-height: 44px;
}
.calc-select {
  flex: 0 0 auto;
  min-width: 110px;
  width: auto;                        /* Override form-select width:100% */
  font-size: 1rem;
  font-weight: 600;
  height: 64px;
}

/* 3) Result hero — USDT como protagonista absoluto */
.calc-result {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  padding: 8px 0;
}
.calc-result-value {
  font-size: 3rem;
  font-weight: 800;
  color: var(--color-income);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
}
.calc-result-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* 4) Equivalents list — filas label/value alineadas */
.calc-equivalents {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 1px; /* evita salto cuando esta vacio */
}
.calc-equivalents:empty {
  display: none;
}
.calc-equiv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.calc-equiv-row:hover {
  background: var(--bg-tertiary);
}
.calc-equiv-label {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  font-weight: 500;
}
.calc-equiv-value {
  color: var(--text-primary);
  font-weight: 600;
}
.calc-equiv-row-accent .calc-equiv-value {
  color: var(--text-primary);
  font-weight: 700;
}
.calc-equiv-error {
  text-align: center;
  padding: 12px;
  color: var(--color-expense);
  font-size: 0.85rem;
}

/* Tarjeta comparativa "$ BCV": pago directo vs cambio a Bs */
.calc-compare {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  border: 1px solid var(--border-color);
}
.calc-compare-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.calc-compare-label {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  font-weight: 500;
}
.calc-compare-value {
  color: var(--text-primary);
  font-weight: 600;
}
.calc-compare-row-best .calc-compare-label,
.calc-compare-row-best .calc-compare-value {
  color: var(--color-income);
  font-weight: 700;
}
.calc-compare-savings {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-color);
  text-align: center;
  color: var(--color-income);
  font-size: 0.85rem;
  font-weight: 600;
}

.rate-converter-divider {
  width: 1px;
  height: 40px;
  background: var(--border-color);
  flex-shrink: 0;
}

.rate-converter-form {
  flex: 1 1 220px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.rate-converter-input-group {
  display: flex;
  gap: 6px;
  flex: 1 1 0;
  min-width: 0;
}
.rate-converter-input {
  flex: 1 1 0;
  min-width: 0;
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
}
.rate-converter-select {
  width: auto;
  flex: 0 0 auto;
  min-width: 92px;
  font-size: 0.9rem;
}
.rate-converter-arrow {
  font-size: 1rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.rate-converter-result {
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-income);
  flex: 0 0 auto;
  min-width: 90px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Result block: USDT grande arriba, otras monedas pequeñas abajo */
.rate-converter-result-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 130px;
}
.rate-converter-usdt-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1;
}
.rate-converter-usdt-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-income);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.rate-converter-usdt-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.rate-converter-alt-line {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-height: 1em;
}

/* ============================================================
   THEME TOGGLE BUTTON (luna/sol minimalista)
   ============================================================ */
.theme-toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  position: relative;
  overflow: hidden;
}
.theme-toggle-btn:hover { background: var(--bg-hover); }
.theme-toggle-btn:active { transform: scale(0.92); }
.theme-toggle-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-icon {
  position: absolute;
  transition: opacity 0.25s, transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
/* Dark mode → mostrar SOL (porque clic = volver a claro) */
.theme-dark .theme-icon-sun { opacity: 1; transform: rotate(0deg) scale(1); }
.theme-dark .theme-icon-moon { opacity: 0; transform: rotate(-90deg) scale(0); pointer-events: none; }
/* Light mode → mostrar LUNA */
.theme-light .theme-icon-sun { opacity: 0; transform: rotate(90deg) scale(0); pointer-events: none; }
.theme-light .theme-icon-moon { opacity: 1; transform: rotate(0deg) scale(1); }
/* System mode: depende del SO */
.theme-system .theme-icon-sun { opacity: 1; transform: rotate(0deg) scale(1); }
.theme-system .theme-icon-moon { opacity: 0; transform: rotate(-90deg) scale(0); pointer-events: none; }
@media (prefers-color-scheme: light) {
  .theme-system .theme-icon-sun { opacity: 0; transform: rotate(90deg) scale(0); pointer-events: none; }
  .theme-system .theme-icon-moon { opacity: 1; transform: rotate(0deg) scale(1); }
}

/* WALLET PAGE — New card design */
.wallet-page-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.wallet-page-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.wallet-page-card:hover { border-color: var(--border-strong); }
.wallet-page-card:active { transform: scale(0.99); }

.wallet-page-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.wallet-page-flag { display: none; }
.wallet-page-logo-wrap {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.wallet-page-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 6px;
}
.wallet-page-info { flex: 1; min-width: 0; }
.wallet-page-name { font-weight: 700; font-size: 16px; color: var(--text-primary); }
.wallet-page-currency { font-size: 13px; color: var(--text-tertiary); margin-top: 2px; }
.wallet-page-chevron { color: var(--text-tertiary); font-size: 20px; }
.wallet-page-balance { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Color picker pills */
.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.color-pill {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.color-pill:hover { transform: scale(1.1); }
.color-pill.active { border-color: var(--text-primary); }

/* Mostrar el boton tambien en sidebar footer (desktop) */
.sidebar-footer .theme-toggle-btn { margin-top: 8px; }

/* ============================================================
   ICONOS LUCIDE — botones con icono inline + alineación
   ============================================================ */
.btn svg.lucide { display: inline-block; vertical-align: middle; margin-right: -2px; }
.btn-icon svg.lucide { margin-right: 0; }
.nav-icon { width: 20px; height: 20px; }
.lucide { display: inline-block; }

/* ============================================================
   ONBOARDING — Full-page welcome flow
   ============================================================ */
.ob-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: var(--space-lg);
}
.ob-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
}
.ob-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-md);
  background: var(--bg-tertiary);
}
.ob-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-tertiary);
  transition: all 0.2s;
}
.ob-step.active {
  color: var(--text-primary);
  font-weight: 600;
  background: var(--bg-card);
}
.ob-step.done { color: var(--color-income); }
.ob-step-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.ob-step.active .ob-step-dot {
  background: var(--accent);
  color: var(--accent-text);
}
.ob-step.done .ob-step-dot {
  background: var(--color-income);
  color: #fff;
}
.ob-step-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ob-body {
  padding: var(--space-xl) var(--space-lg) var(--space-lg);
  text-align: center;
}
.ob-icon { font-size: 48px; margin-bottom: var(--space-md); }
.ob-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.ob-subtitle { font-size: 14px; color: var(--text-secondary); line-height: 1.5; margin-bottom: var(--space-lg); }
.ob-actions { display: flex; flex-direction: column; gap: 10px; }

/* ============================================================
   CATEGORY MANAGER
   ============================================================ */
.cat-list { display: flex; flex-direction: column; }
.cat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 6px;
  min-height: 48px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.1s;
}
.cat-row:last-child { border-bottom: none; }
.cat-row:hover, .cat-row:focus-visible { background: var(--bg-tertiary); border-radius: 6px; outline: none; }
.cat-hidden { opacity: 0.4; }
.cat-row-handle { color: var(--text-tertiary); cursor: grab; width: 24px; text-align: center; flex-shrink: 0; touch-action: none; }
.cat-row-icon { width: 28px; text-align: center; flex-shrink: 0; }
.cat-row-name { flex: 1; font-size: 14px; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row-badge { font-size: 11px; color: var(--text-tertiary); background: var(--bg-secondary); padding: 2px 8px; border-radius: 999px; flex-shrink: 0; }
.cat-row-badge-hidden { color: var(--text-secondary); }
.cat-row-chevron { color: var(--text-tertiary); flex-shrink: 0; display: inline-flex; align-items: center; }
.cat-add-row {
  background: none;
  border: 1px dashed var(--border-color);
  color: var(--accent);
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
  transition: border-color 0.15s;
}
.cat-add-row:hover { border-color: var(--accent); }

/* Edit modal */
.cat-edit-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.cat-edit-modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}
.cat-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}
.cat-edit-header h3 { font-size: 16px; font-weight: 700; margin: 0; }
.cat-edit-body { padding: 16px 20px; }
.cat-edit-footer { padding: 12px 20px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--border-color); }

/* Icon picker */
.ce-icon-search { margin-bottom: 8px; }
.ce-icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}
.ce-icon-item {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.12s;
}
.ce-icon-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.ce-icon-item.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.ce-icon-empty { text-align: center; padding: 20px; color: var(--text-tertiary); font-size: 13px; }

/* Input de descripción en el form de transacción */
.tx-desc-input {
  width: 100%;
  margin-top: var(--space-sm);
  text-align: center;
  font-size: 15px;
}

/* ============================================================
   GOALS — Metas de ahorro
   ============================================================ */
.goal-card { cursor: pointer; }
.goal-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.goal-card-name { font-weight: 700; font-size: 1rem; display: inline-flex; align-items: center; gap: 4px; }
.goal-card-pct { font-weight: 700; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.goal-card-amounts {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 10px;
}
.goal-card-target { color: var(--text-tertiary); font-weight: 400; font-size: 0.85rem; }
.goal-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.goal-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   GLASS — efecto cristal en superficies flotantes.
   Restaurado del PR #53 (revertido por error). Solo donde
   backdrop-filter es soportado; sino, fallback opaco automático
   (las reglas base ya definen el color sólido).
   Aplicado a: bottom-nav, header sticky, modales/sheets.
   NO aplicado a cards de contenido (legibilidad + performance).
   ============================================================ */
@supports ((backdrop-filter: blur(20px)) or (-webkit-backdrop-filter: blur(20px))) {
  .theme-dark .modal,
  .theme-dark .item-actions-modal {
    background: rgba(24,24,27,0.82);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    backdrop-filter: blur(24px) saturate(180%);
  }
  .theme-light .modal,
  .theme-light .item-actions-modal {
    background: rgba(250,250,252,0.82);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    backdrop-filter: blur(24px) saturate(180%);
  }
  /* system theme sigue al SO */
  @media (prefers-color-scheme: dark) {
    .theme-system .modal, .theme-system .item-actions-modal { background: rgba(24,24,27,0.82); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); }
  }
  @media (prefers-color-scheme: light) {
    .theme-system .modal, .theme-system .item-actions-modal { background: rgba(250,250,252,0.82); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); }
  }
}
