/* ==========================================================================
   Finanzas · Consola Financiera v2.1
   Inspirado en tara7ara.com & Expense Manager Console
   Paleta: Deep Black (#000000) & Cyber Electric Blue (#3b82f6 / #38bdf8)
   ========================================================================== */

:root {
  --bg: #000000;
  --bg-subtle: #05070c;
  --card: #090c14;
  --card-hover: #0e1320;
  --card-border: rgba(255, 255, 255, 0.07);
  --card-border-hover: rgba(59, 130, 246, 0.38);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-dim: #64748b;
  
  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --accent-dark: #1d4ed8;
  --accent-cyan: #38bdf8;
  --accent-subtle: rgba(59, 130, 246, 0.12);
  --accent-border: rgba(59, 130, 246, 0.28);
  
  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.12);
  --success: #10b981;
  --success-subtle: rgba(16, 185, 129, 0.12);
  
  --gradient-card: linear-gradient(180deg, rgba(255, 255, 255, 0.035) 0%, rgba(255, 255, 255, 0) 100%);
  --gradient-accent: linear-gradient(135deg, #2563eb 0%, #3b82f6 50%, #60a5fa 100%);
  --gradient-hero: linear-gradient(135deg, rgba(37, 99, 235, 0.15) 0%, rgba(9, 12, 20, 0.8) 100%);
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, monospace;
  
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;
  
  --sidebar-w: 240px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  background-color: var(--bg);
}

body {
  background-color: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  overflow-x: hidden;
  position: relative;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* === Ambient Glow (Inspirado en tara7ara.com) === */
.bg-glow {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 1100px;
  height: 520px;
  background: radial-gradient(circle at 50% 0%, rgba(37, 99, 235, 0.16) 0%, rgba(59, 130, 246, 0.04) 45%, transparent 75%);
  pointer-events: none;
  z-index: 0;
}

/* === Status Badges & Pills === */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  color: var(--accent-light);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.02em;
}

.dot-pulse {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.tag-accent {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* === Brand & Icon Wrappers === */
.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(37, 99, 235, 0.05) 100%);
  border: 1px solid rgba(59, 130, 246, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-light);
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.15);
}

.brand-icon.small {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ==========================================================================
   PANTALLA DE ACCESO (Fintech Grade)
   ========================================================================== */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  z-index: 1;
}

.login-card {
  background: var(--card);
  background-image: var(--gradient-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 2.75rem 2.25rem;
  width: 100%;
  max-width: 410px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 80px rgba(59, 130, 246, 0.08);
  position: relative;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.5rem;
}

.login-card h1 {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 1rem 0 0.35rem;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 2rem;
  line-height: 1.45;
}

.login-error {
  background: var(--danger-subtle);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-bottom: 1.25rem;
}

/* ==========================================================================
   BOTONES & CONTROLES
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  text-decoration: none;
  line-height: 1.2;
}

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

.btn-primary {
  background: var(--gradient-accent);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
  filter: brightness(1.1);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  border: 1px solid var(--card-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-full { width: 100%; }

.btn-icon {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.text-danger { color: var(--danger) !important; }
.text-danger:hover { background: var(--danger-subtle) !important; }

/* ==========================================================================
   FORMULARIOS & INPUTS
   ========================================================================== */
.form-group {
  margin-bottom: 1.15rem;
}

.form-group label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.45rem;
}

.input-icon-wrap {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.input-icon-wrap input {
  padding-left: 40px !important;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select {
  width: 100%;
  background: #05070c;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.7rem 0.9rem;
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

input:focus, select:focus {
  border-color: var(--accent);
  background: #080b13;
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px rgba(59, 130, 246, 0.25);
}

.form-row {
  display: flex;
  gap: 0.75rem;
}

.amount-wrap {
  position: relative;
}

.currency-tag {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-light);
  background: var(--accent-subtle);
  padding: 3px 8px;
  border-radius: 4px;
}

.amount-wrap input {
  padding-left: 64px !important;
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* Date Input DD/MM/AAAA con selector nativo y accesos rápidos */
.date-input-container {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.date-input-container input#form-date {
  padding-right: 40px !important;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.btn-date-picker {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-date-picker:hover {
  color: var(--accent-light);
  background: var(--accent-subtle);
  border-color: rgba(59, 130, 246, 0.25);
}

.hidden-native-picker {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  opacity: 0;
  pointer-events: none;
  border: none;
  padding: 0;
  margin: 0;
  z-index: -1;
}

.date-quick-chips {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.date-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.date-chip:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent-light);
}

.date-chip:active {
  transform: scale(0.96);
}

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */
.app {
  display: flex;
  min-height: 100dvh;
  position: relative;
  z-index: 1;
}

/* === SIDEBAR (Desktop) === */
.sidebar {
  display: none;
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--card-border);
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--card-border);
}

.brand-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.65rem 0.9rem;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  width: 100%;
  text-align: left;
}

.sidebar-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.sidebar-btn.active {
  background: var(--accent-subtle);
  border-color: var(--accent-border);
  color: var(--accent-light);
  font-weight: 600;
}

.sidebar-footer {
  padding: 1rem 0.75rem;
  border-top: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-status {
  margin-bottom: 0.5rem;
  width: 100%;
  justify-content: flex-start;
}

.sidebar-action {
  font-size: 0.82rem;
  padding: 0.55rem 0.75rem;
}

/* === MAIN CONTENT === */
.main-content {
  flex: 1;
  padding-bottom: calc(90px + var(--safe-bottom));
  min-height: 100dvh;
  width: 100%;
}

/* === HEADERS === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
}

.header.mobile-only {
  padding-top: calc(max(var(--safe-top), 16px) + 12px);
  padding-bottom: 12px;
  padding-left: max(env(safe-area-inset-left, 0px), 1.25rem);
  padding-right: max(env(safe-area-inset-right, 0px), 1.25rem);
  min-height: calc(var(--safe-top) + 66px);
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-brand .brand-icon.small {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25) 0%, rgba(37, 99, 235, 0.08) 100%);
  border: 1px solid rgba(59, 130, 246, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-light);
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.2);
  flex-shrink: 0;
}

.mobile-brand .brand-name {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.header.mobile-only .header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header.mobile-only .header-actions .btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.header.mobile-only .header-actions .btn-icon:active {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent-light);
  transform: scale(0.94);
}

.header.mobile-only .header-actions #btn-logout:active {
  background: var(--danger-subtle);
  border-color: var(--danger);
  color: var(--danger);
}

.header-titles h1 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* === VIEWS === */
.view {
  display: none;
  padding: 1.25rem;
  max-width: 1120px;
  margin: 0 auto;
}

.view.active { display: block; }

/* ==========================================================================
   1. TIMEFRAME SELECTOR BAR (Inspirado en consolas profesionales)
   ========================================================================== */
.timeframe-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 10px;
}

.timeframe-pills {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}

.timeframe-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.timeframe-btn:hover {
  color: #ffffff;
}

.timeframe-btn.active {
  background: var(--accent-subtle);
  color: var(--accent-light);
  font-weight: 600;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.timeframe-date-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* ==========================================================================
   2. RESUMEN FINANCIERO: Hero Card + Sparkline + Stats Column
   ========================================================================== */
.summary-composite-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* Hero Interactive Card */
.card-hero-interactive {
  background: var(--card);
  background-image: var(--gradient-hero);
  border: 1px solid rgba(59, 130, 246, 0.28);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), 0 0 40px rgba(59, 130, 246, 0.08);
}

.card-glow {
  position: absolute;
  top: -40px;
  right: -40px;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.2) 0%, transparent 70%);
  pointer-events: none;
}

.card-hero-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  position: relative;
  z-index: 2;
}

.hero-label-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  padding: 2px 8px;
  border-radius: 4px;
  align-self: flex-start;
}

.hero-amount-display {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-top: 4px;
}

.currency-symbol-hero {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-dim);
}

.metric-val {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.metric-val.compact {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.metric-meta-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.metric-chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  color: var(--text-primary);
}

.metric-chip-dim {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

/* Sparkline / Trend Area Chart */
.sparkline-wrapper {
  margin-top: 0.75rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  z-index: 2;
}

.sparkline-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
}

.sparkline-sublabel {
  color: var(--text-dim);
  font-weight: 500;
}

.sparkline-hover-info {
  font-family: var(--font-mono);
  color: var(--accent-light);
  font-size: 0.72rem;
}

.sparkline-container {
  width: 100%;
  height: 110px;
  position: relative;
  cursor: crosshair;
}

.sparkline-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Columna de tarjetas complementarias */
.card-stats-column {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

.card-stat-card {
  background: var(--card);
  background-image: var(--gradient-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
}

.card-stat-card:hover {
  border-color: var(--card-border-hover);
  transform: translateY(-2px);
}

.card-header-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  color: var(--text-dim);
}

.live-dot-wrap {
  display: flex;
  align-items: center;
}

.apple-pay-badge-mini {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent-light);
}

.card-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  display: block;
  margin-bottom: 0.25rem;
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   3. DISTRIBUCIÓN: Donut Chart Interactivo + Ranking
   ========================================================================== */
.section-card {
  background: var(--card);
  background-image: var(--gradient-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-wrap: wrap;
  gap: 10px;
}

.section-tag-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.section-tag-row h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Switcher de Vista Anillo vs Ranking */
.view-switch-pills {
  display: inline-flex;
  align-items: center;
  background: #05070c;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-pill);
  padding: 2px;
  gap: 2px;
}

.switch-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s ease;
}

.switch-pill:hover { color: #ffffff; }

.switch-pill.active {
  background: var(--accent-subtle);
  color: var(--accent-light);
  font-weight: 600;
}

.distribution-views-container {
  width: 100%;
  position: relative;
  min-height: 280px;
}

/* Donut Stage */
.donut-interactive-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 0;
  max-width: 520px;
  margin: 0 auto;
  animation: distFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.distribution-bars-wrap {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  animation: distFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes distFadeIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.donut-center-stage {
  position: relative;
  width: 230px;
  height: 230px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-slice {
  cursor: pointer;
  transition: stroke-width 0.25s ease, filter 0.25s ease, opacity 0.2s ease;
}

.donut-slice:hover {
  stroke-width: 26;
  filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.6));
}

.donut-readout {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.donut-readout-label {
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.donut-readout-amount {
  font-family: var(--font-mono);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  margin: 2px 0;
}

.donut-readout-sub {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-cyan);
  font-weight: 600;
}

.donut-legend-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 1.25rem;
  max-width: 380px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.legend-chip:hover {
  background: var(--card-hover);
  border-color: var(--card-border-hover);
}

.legend-chip.active {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: #ffffff;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

/* Spotlight banner */
.spotlight-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.1) 0%, rgba(9, 12, 20, 0.4) 100%);
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
}

.spotlight-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-cyan);
}

/* Ranking Category Bars */
.category-bars {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.category-bar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.category-bar-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.category-icon-box {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.category-bar-item:hover .category-icon-box {
  transform: scale(1.08);
}

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

.category-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.35rem;
}

.category-bar-name {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: capitalize;
  color: var(--text-primary);
}

.category-bar-amount {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.category-bar-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.category-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   4. ACTIVIDAD: Movimientos Recientes & Filtros Segmentados
   ========================================================================== */
.activity-filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.activity-quick-filters {
  display: inline-flex;
  align-items: center;
  background: #05070c;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-pill);
  padding: 2px;
  gap: 2px;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-pill:hover { color: #ffffff; }

.filter-pill.active {
  background: var(--accent-subtle);
  color: var(--accent-light);
  font-weight: 600;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-light);
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.link-btn:hover { color: #ffffff; }

/* Lista de Movimientos con Timeline */
.transaction-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tx-date-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0.25rem 0.35rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  margin-bottom: 0.35rem;
}

.tx-date-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tx-date-subtotal {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  padding: 1px 7px;
  border-radius: 4px;
}

.transaction-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  user-select: none;
  position: relative;
  overflow: hidden;
  animation: slideFadeIn 0.35s ease both;
}

@keyframes slideFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (hover: hover) and (pointer: fine) {
  .transaction-item:hover {
    background: var(--card-hover);
    border-color: var(--card-border-hover);
    transform: translateY(-1px);
  }
  .transaction-item:hover .tx-icon-box {
    transform: scale(1.05);
  }
  .transaction-item:hover .tx-merchant {
    color: var(--accent-light);
  }
  .transaction-item:hover .tx-actions-hover {
    display: flex;
  }
}

.transaction-item:active {
  transform: scale(0.99);
  background: rgba(255, 255, 255, 0.05);
}

.tx-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

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

.tx-merchant {
  font-size: 0.92rem;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s;
}

.tx-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  font-size: 0.74rem;
  color: var(--text-dim);
  flex-wrap: wrap;
}

.tx-category-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1px 7px;
  border-radius: 4px;
  text-transform: capitalize;
  color: var(--text-secondary);
}

.tx-source-apple {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-light);
  font-size: 0.7rem;
}

.tx-amount-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tx-amount {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: #f87171;
  flex-shrink: 0;
}

/* Botones de acción flotantes */
.tx-actions-hover {
  display: none;
  align-items: center;
  gap: 4px;
}

.tx-btn-action {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.tx-btn-action:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--text-dim);
}

.empty-state-icon {
  margin-bottom: 1rem;
  color: var(--text-dim);
  opacity: 0.4;
  animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ==========================================================================
   FILTROS VISTA HISTORIAL
   ========================================================================== */
.filters-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 1rem;
}

.filters-grid {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.search-wrap {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.search-input {
  padding-left: 36px !important;
}

.date-range-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-sep {
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* ==========================================================================
   NAVEGACIÓN MOBILE FLOTANTE & FAB
   ========================================================================== */
.fab {
  position: fixed;
  bottom: calc(84px + var(--safe-bottom));
  right: 1.25rem;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--gradient-accent);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45);
  cursor: pointer;
  z-index: 45;
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.fab:active { transform: scale(0.92); }

.bottom-nav {
  position: fixed;
  bottom: calc(14px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 2.5rem);
  max-width: 380px;
  background: rgba(10, 13, 20, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-pill);
  display: flex;
  justify-content: space-around;
  padding: 6px 12px;
  z-index: 50;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7);
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn.active {
  color: var(--accent-light);
  background: var(--accent-subtle);
}

.nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   MODALES (Glassmorphism & Centered Layout)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
}

.modal-overlay.open { display: flex; }

.modal {
  background: #090c14;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 1.75rem 1.5rem;
  padding-bottom: calc(1.75rem + var(--safe-bottom));
  animation: slideUp 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
}

.modal-lg { max-width: 640px; }

/* Modal Confirmación In-App (Sin alertas nativas) */
#confirm-overlay {
  z-index: 120 !important;
  align-items: center !important;
  padding: 1.25rem !important;
}

.modal-confirm {
  max-width: 410px;
  text-align: center;
  padding: 2rem 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: var(--radius-lg);
}

.confirm-icon-box {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--danger-subtle);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.15rem;
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.25);
}

.confirm-content h3 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.45rem;
  color: #ffffff;
}

.confirm-content p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.confirm-preview-box {
  background: #05070c;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
}

.confirm-tx-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.confirm-tx-merchant {
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.confirm-tx-meta {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.confirm-tx-amount {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--danger);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  margin-top: 1.5rem;
  width: 100%;
}

.confirm-actions .btn {
  flex: 1;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-title-group h2 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.btn-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* Category Grid in Modal */
.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.category-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  background: #05070c;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.category-chip:hover {
  background: #0d121c;
  border-color: rgba(255, 255, 255, 0.15);
}

.category-chip.selected {
  border-color: var(--accent);
  background: var(--accent-subtle);
  color: var(--accent-light);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

.category-chip-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: capitalize;
  text-align: center;
  color: var(--text-secondary);
}

.category-chip.selected .category-chip-label {
  color: #ffffff;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 1.5rem;
}

/* ==========================================================================
   CONFIGURACIÓN & AJUSTES
   ========================================================================== */
.settings-section {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.settings-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.settings-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.api-keys-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.api-key-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #05070c;
  border: 1px solid var(--card-border);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}

.api-key-info { flex: 1; }
.api-key-name { font-weight: 600; font-size: 0.85rem; }
.api-key-preview { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-dim); }
.api-key-status {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}
.api-key-status.active { background: var(--success-subtle); color: var(--success); }
.api-key-status.revoked { background: var(--danger-subtle); color: var(--danger); }

.copyable {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #05070c;
  border: 1px solid var(--card-border);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-top: 0.45rem;
}

.copyable code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-light);
  word-break: break-all;
}

.btn-copy {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.btn-copy:hover { color: #ffffff; }

.new-key-result {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
}

.key-warning {
  font-size: 0.8rem;
  color: var(--accent-cyan);
  font-weight: 600;
}

.shortcut-steps {
  background: #05070c;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 1.15rem;
  font-size: 0.82rem;
  line-height: 1.6;
}

.shortcut-steps ol { padding-left: 1.25rem; }
.shortcut-steps li { margin-bottom: 0.65rem; }
.shortcut-steps ul { padding-left: 1rem; margin-top: 0.35rem; }
.shortcut-steps code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-light);
}

.shortcut-steps pre {
  background: #000000;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
  overflow-x: auto;
}

.shortcut-steps pre code { background: none; padding: 0; }

/* === TOAST NOTIFICATIONS === */
.toast {
  position: fixed;
  bottom: calc(90px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(40px);
  background: #090c14;
  border: 1px solid var(--card-border);
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7);
  z-index: 200;
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success { border-color: rgba(16, 185, 129, 0.4); }
.toast.error { border-color: rgba(239, 68, 68, 0.4); }

/* ==========================================================================
   RESPONSIVE DESIGN (Desktop >= 768px)
   ========================================================================== */
.mobile-only { display: flex; }
.desktop-only { display: none !important; }

@media (min-width: 768px) {
  .mobile-only { display: none !important; }
  .desktop-only { display: flex !important; }

  .sidebar { display: flex; }

  .main-content {
    margin-left: var(--sidebar-w);
    padding-bottom: 2rem;
  }

  .header {
    padding: 1.5rem 2.25rem;
  }

  .view {
    padding: 2rem 2.25rem;
  }

  /* Resumen Financiero Composite Grid */
  .summary-composite-grid {
    grid-template-columns: 1.5fr 1fr;
    gap: 1.25rem;
  }

  .card-stats-column {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .category-bars {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .filters-grid {
    flex-direction: row;
    align-items: center;
  }

  .search-wrap { flex: 1.5; }
  .filter-item { flex: 1; }
  .date-range-wrap { flex: 1.4; }

  /* Modals centrados en pantalla completa en Desktop */
  .modal-overlay {
    align-items: center;
    padding: 1.5rem;
  }

  .modal {
    border-radius: var(--radius-lg);
    max-height: 85vh;
    animation: zoomIn 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  @keyframes zoomIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
  }

  .category-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .toast {
    bottom: 2rem;
  }
}

.legend-chip.active {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent-light);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.25);
}

@media (max-width: 767px) {
  /* 1. Header mobile con safe area y espaciado holgado */
  .header.mobile-only {
    padding-top: calc(max(var(--safe-top), 16px) + 12px);
    padding-bottom: 12px;
    padding-left: max(env(safe-area-inset-left, 0px), 1rem);
    padding-right: max(env(safe-area-inset-right, 0px), 1rem);
  }

  .view {
    padding: 1rem 1rem calc(90px + var(--safe-bottom));
  }

  /* 2. Hero Card & Métricas en móvil */
  .metric-val { font-size: 2rem; }
  .hero-amount-display { font-size: 2.3rem; }
  .sparkline-wrapper { padding: 0.75rem 0.5rem 0.25rem; }

  /* 3. Selector temporal sin desbordes */
  .timeframe-bar {
    gap: 8px;
    margin-bottom: 1rem;
  }

  .timeframe-pills {
    width: 100%;
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px;
  }
  .timeframe-pills::-webkit-scrollbar { display: none; }

  .timeframe-btn {
    flex: 1;
    text-align: center;
    padding: 6px 8px;
    font-size: 0.74rem;
    white-space: nowrap;
  }

  /* 4. Donut Stage en móvil */
  .donut-center-stage { width: 185px; height: 185px; }
  .donut-readout-amount { font-size: 1.22rem; }
  .donut-readout-pct { font-size: 0.8rem; }
  .donut-legend-chips { gap: 6px; }
  .legend-chip { padding: 5px 9px; font-size: 0.72rem; }

  /* 5. Transacciones en móvil: Importe prominente, sin apreturas */
  .transaction-item {
    padding: 0.8rem 0.95rem;
    gap: 10px;
  }

  .tx-icon-box {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    flex-shrink: 0;
  }

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

  .tx-merchant {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tx-meta {
    gap: 6px;
    margin-top: 3px;
    font-size: 0.7rem;
    flex-wrap: nowrap;
    overflow: hidden;
  }

  .tx-category-badge {
    max-width: 90px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Contenedor del importe alineado verticalmente a la derecha */
  .tx-amount-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 6px;
    text-align: right;
  }

  .tx-amount {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
    color: #f87171;
    white-space: nowrap;
    letter-spacing: -0.02em;
    text-align: right;
  }

  /* Micro-acciones debajo del importe: siempre accesibles pero sin apretar el ancho */
  .tx-actions-hover {
    display: flex !important;
    align-items: center;
    gap: 5px;
    opacity: 0.75;
  }

  .tx-btn-action {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border-radius: 5px;
    padding: 3px 6px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .tx-btn-action:active {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(0.92);
  }

  /* Feedback táctil en móvil para evitar estados "hover pegados" */
  .btn:active,
  .btn-icon:active,
  .card-stat-card:active,
  .category-bar-item:active,
  .transaction-item:active,
  .nav-btn:active {
    transform: scale(0.98);
    opacity: 0.92;
  }
}
