/* ==========================================================================
   Finanzas Dúo — Sistema Visual Fintech Esmeralda (Inspirado en Finora)
   ========================================================================== */

:root {
  --bg-body: #F6F8F7;
  --bg-card: #FFFFFF;
  --bg-subtle: #F2F6F4;

  --border-card: #EAEFEF;
  --border-input: #DCE5E2;

  --emerald-start: #0D6E52;
  --emerald-end: #064E3B;
  --emerald-gradient: linear-gradient(135deg, #0D6E52 0%, #064E3B 100%);
  --emerald-hover: linear-gradient(135deg, #0F7D5D 0%, #075B45 100%);

  --mint-bg: #E6F4EF;
  --mint-hover: #D6EDE5;
  --mint-icon: #0B6B4F;

  --text-main: #0F1F1A;
  --text-secondary: #4A5D56;
  --text-muted: #768982;

  --status-green: #10B981;
  --status-green-bg: #DCFCE7;
  --status-green-text: #065F46;

  --status-amber: #F59E0B;
  --status-amber-bg: #FEF3C7;
  --status-amber-text: #92400E;

  --status-red: #EF4444;
  --status-red-bg: #FEE2E2;
  --status-red-text: #991B1B;

  --radius-card: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --shadow-card: 0 6px 24px rgba(6, 78, 59, 0.045), 0 1px 2px rgba(6, 78, 59, 0.03);
  --shadow-hero: 0 16px 34px rgba(6, 78, 59, 0.18);
  --shadow-modal: 0 24px 48px rgba(15, 31, 26, 0.2);

  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

[hidden] {
  display: none !important;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-main);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3, h4, p {
  margin: 0;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.mb-md { margin-bottom: 1rem; }
.mb-lg { margin-bottom: 1.35rem; }

/* Ajuste de íconos Lucide */
svg.lucide {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
}

/* ==========================================================================
   Layout Principal: Sidebar en PC / App Shell en Móvil
   ========================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border-card);
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.35rem;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--emerald-gradient);
  color: #FFFFFF;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 14px rgba(13, 110, 82, 0.25);
}

.brand-logo svg.lucide {
  width: 22px;
  height: 22px;
}

.brand-title {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-tag {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav-link {
  appearance: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.78rem 0.95rem;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.nav-link:focus,
.nav-link:focus-visible {
  outline: none;
}

.nav-link:hover {
  background: var(--mint-bg);
  color: var(--mint-icon);
}

.nav-link.active {
  background: var(--emerald-gradient);
  color: #FFFFFF;
  box-shadow: 0 6px 16px rgba(13, 110, 82, 0.22);
}

.sidebar-footer {
  border-top: 1px solid var(--border-card);
  padding-top: 1rem;
}

.sidebar-footer-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.55rem;
}

.sidebar-backup-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

/* Área de Contenido */
.workspace {
  width: 100%;
  max-width: 960px;
  min-width: 0;
  margin: 0 auto;
  padding: 1.5rem 2rem 3.5rem;
  overflow-x: hidden;
}

.main-content {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.greeting-kicker {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--mint-icon);
}

.greeting-name {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-main);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.month-pill {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-pill);
  padding: 0.22rem 0.35rem;
  box-shadow: var(--shadow-card);
}

.month-pill input[type="month"] {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main);
  padding: 0.25rem 0.35rem;
  outline: none;
  cursor: pointer;
}

.topbar-backup {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

/* ==========================================================================
   Botones y Controles Comunes
   ========================================================================== */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 14px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.68rem 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.16s ease, background-color 0.16s ease;
  white-space: nowrap;
}

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

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-block {
  width: 100%;
}

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

.btn-emerald {
  background: var(--emerald-gradient);
  color: #FFFFFF;
  box-shadow: 0 6px 16px rgba(13, 110, 82, 0.2);
}

.btn-emerald:hover:not(:disabled) {
  background: var(--emerald-hover);
}

.btn-mint {
  background: var(--mint-bg);
  color: var(--mint-icon);
}

.btn-mint:hover:not(:disabled) {
  background: var(--mint-hover);
}

.btn-light {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border-color: var(--border-card);
}

.btn-light:hover:not(:disabled) {
  background: #E7EFEC;
}

.btn-white-emerald {
  background: #FFFFFF;
  color: var(--emerald-end);
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.btn-white-emerald:hover:not(:disabled) {
  background: var(--mint-bg);
}

.btn-danger-soft {
  background: var(--status-red-bg);
  color: var(--status-red-text);
}

.icon-circle-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-circle-btn:hover {
  background: var(--mint-bg);
  color: var(--mint-icon);
}

.icon-pill-btn {
  appearance: none;
  border: 1px solid var(--border-card);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  padding: 0.45rem 0.8rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: all 0.15s ease;
}

.icon-pill-btn:hover {
  background: var(--mint-bg);
  color: var(--mint-icon);
  border-color: #C4E4D9;
}

.link-emerald-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--emerald-start);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
}

.link-emerald-btn:hover {
  background: var(--mint-bg);
}

/* ==========================================================================
   Pestañas y Superficies Base
   ========================================================================== */

.tab-panel {
  display: none;
  animation: fadeSlide 0.2s ease;
}

.tab-panel.active {
  display: block;
}

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

.surface-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 1.35rem;
  box-shadow: var(--shadow-card);
}

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.screen-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.screen-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.card-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}

.card-section-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.card-section-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

/* ==========================================================================
   Pestaña 1: Inicio — Hero Card Esmeralda y Acciones Rápidas
   ========================================================================== */

.emerald-hero-card {
  position: relative;
  overflow: hidden;
  background: var(--emerald-gradient);
  color: #FFFFFF;
  border-radius: var(--radius-card);
  padding: 1.5rem;
  box-shadow: var(--shadow-hero);
  margin-bottom: 1.35rem;
}

.emerald-hero-card::before {
  content: '';
  position: absolute;
  right: -45px;
  top: -45px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(52, 211, 153, 0.25) 0%, rgba(16, 185, 129, 0) 70%);
  pointer-events: none;
}

.hero-card-deco {
  position: absolute;
  top: 1.25rem;
  right: 1.35rem;
  pointer-events: none;
}

.deco-mini-card {
  width: 96px;
  height: 62px;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(4px);
  padding: 0.55rem 0.65rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.deco-chip {
  width: 20px;
  height: 14px;
  border-radius: 4px;
  background: rgba(253, 224, 71, 0.72);
}

.deco-brand {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  align-self: flex-end;
  opacity: 0.9;
}

.hero-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  position: relative;
  z-index: 1;
}

.hero-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.hero-tag {
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.16);
  padding: 0.22rem 0.65rem;
  border-radius: var(--radius-pill);
  margin-right: 6.5rem;
}

.hero-amount-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.35rem;
  position: relative;
  z-index: 1;
}

.hero-amount {
  font-size: 2.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.hero-eye-btn {
  appearance: none;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #FFFFFF;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.hero-eye-btn:hover {
  background: rgba(255, 255, 255, 0.26);
}

.hero-split-pill {
  display: inline-flex;
  align-items: center;
  margin-top: 0.55rem;
  background: rgba(6, 46, 34, 0.36);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
  color: #D1FAE5;
}

.hero-bottom-stats {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: center;
}

.hero-stat-divider {
  width: 1px;
  height: 38px;
  background: rgba(255, 255, 255, 0.18);
}

.hero-stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.hero-stat-label {
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.8);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.hero-stat-label svg.lucide {
  width: 14px;
  height: 14px;
}

.hero-stat-value {
  font-size: 1.15rem;
  font-weight: 800;
}

.hero-stat-sub {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.72);
}

/* Banner compacto de alerta en Inicio */
.compact-alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.85rem 1.1rem;
  border-radius: 16px;
  margin-bottom: 1rem;
  font-size: 0.84rem;
  font-weight: 600;
}

.compact-alert-banner.warn {
  background: var(--status-amber-bg);
  color: var(--status-amber-text);
  border: 1px solid #FDE68A;
}

.compact-alert-banner.danger {
  background: var(--status-red-bg);
  color: var(--status-red-text);
  border: 1px solid #FECACA;
}

.compact-alert-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* 4 Acciones Rápidas (Mint Rounded Squares) */
.quick-actions-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.4rem;
}

.quick-action-item {
  appearance: none;
  border: 1px solid var(--border-card);
  background: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 0.95rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform 0.14s ease, border-color 0.14s ease;
  font-family: inherit;
}

.quick-action-item:hover {
  transform: translateY(-2px);
  border-color: #BBE3D5;
}

.qa-icon-box {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: var(--mint-bg);
  color: var(--mint-icon);
  display: grid;
  place-items: center;
  transition: background-color 0.15s ease;
}

.quick-action-item:hover .qa-icon-box {
  background: var(--mint-hover);
}

.qa-icon-box svg.lucide {
  width: 22px;
  height: 22px;
}

.qa-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

/* ==========================================================================
   Movimientos Agrupados por Fecha y Círculos Pastel
   ========================================================================== */

.grouped-tx-container {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.tx-date-group-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: capitalize;
  margin-bottom: 0.45rem;
  padding-left: 0.15rem;
}

.tx-group-card {
  display: flex;
  flex-direction: column;
}

.tx-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.78rem 0.25rem;
  border-bottom: 1px solid var(--border-card);
}

.tx-row:last-child {
  border-bottom: none;
}

.tx-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  flex: 1;
}

/* Íconos circulares pastel por categoría */
.cat-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.cat-Comida { background: #FFE8E0; color: #EA580C; }
.cat-Vivienda { background: #E0E7FF; color: #4F46E5; }
.cat-Transporte { background: #DBEAFE; color: #2563EB; }
.cat-Salidas { background: #F3E8FF; color: #9333EA; }
.cat-Salud { background: #FCE7F3; color: #DB2777; }
.cat-Mascotas { background: #FEF3C7; color: #B45309; }
.cat-Otros { background: #D1FAE5; color: #059669; }
.cat-global { background: var(--mint-bg); color: var(--mint-icon); }

.tx-details {
  min-width: 0;
}

.tx-title-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.tx-title {
  font-size: 0.93rem;
  font-weight: 700;
  color: var(--text-main);
}

.tx-sub-line {
  font-size: 0.77rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Etiquetas / Pills */
.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.pill-badge.mint {
  background: var(--mint-bg);
  color: var(--mint-icon);
}

.pill-badge.couple {
  background: #E0F2FE;
  color: #0369A1;
}

.pill-badge.third-pending {
  background: var(--status-amber-bg);
  color: var(--status-amber-text);
}

.pill-badge.third-done {
  background: var(--status-green-bg);
  color: var(--status-green-text);
}

.pill-badge.danger {
  background: var(--status-red-bg);
  color: var(--status-red-text);
}

.tx-right-side {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.tx-amount-box {
  text-align: right;
}

.tx-price {
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--text-main);
}

.tx-price.third-pending {
  color: #B45309;
}

.tx-price.reimbursed-plus {
  color: #0D6E52;
}

.tx-price-note {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.tx-quick-btns {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.chip-action-btn {
  appearance: none;
  border: 1px solid #C4E4D9;
  background: var(--mint-bg);
  color: var(--mint-icon);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.28rem 0.6rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.chip-action-btn:hover {
  background: var(--mint-hover);
}

/* ==========================================================================
   Pestaña 2: Análisis — Pill Tabs, Bar Chart y Top Categorías
   ========================================================================== */

.period-pill-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  padding: 0.28rem;
  border-radius: var(--radius-pill);
  margin-bottom: 0.95rem;
  box-shadow: var(--shadow-card);
}

.period-pill {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  padding: 0.58rem 0.75rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.18s ease;
}

.period-pill.active {
  background: var(--emerald-gradient);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(13, 110, 82, 0.24);
}

.type-pills-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  margin-bottom: 1.15rem;
  scrollbar-width: none;
}

.type-pills-row::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  appearance: none;
  border: 1px solid var(--border-card);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.filter-chip:hover {
  background: var(--mint-bg);
  color: var(--mint-icon);
}

.filter-chip.active {
  background: var(--emerald-start);
  border-color: var(--emerald-start);
  color: #FFFFFF;
}

.analytics-kicker {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.analytics-big-total {
  font-size: 1.95rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: 0.1rem;
}

.analytics-delta {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--emerald-start);
  margin-top: 0.15rem;
  margin-bottom: 1rem;
}

.bar-chart-container {
  position: relative;
  width: 100%;
  height: 240px;
}

/* Top Categorías */
.top-categories-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.top-cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
}

.top-cat-left {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex: 1;
  min-width: 0;
}

.top-cat-mid {
  flex: 1;
}

.top-cat-name-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.mini-bar-track {
  height: 7px;
  background: var(--bg-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--emerald-start);
}

.top-cat-right {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  text-align: right;
}

.top-cat-pct {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 42px;
}

.top-cat-amount {
  font-size: 0.92rem;
  font-weight: 800;
  min-width: 88px;
}

/* Buscador e Historial */
.history-filters-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 1.1rem;
}

.search-input-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--border-input);
  background: var(--bg-subtle);
  border-radius: 12px;
  padding: 0 0.75rem;
}

.search-input-box svg.lucide {
  color: var(--text-muted);
  width: 16px;
  height: 16px;
}

.search-input-box input {
  border: none;
  background: transparent;
  width: 100%;
  padding: 0.58rem 0;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-main);
  outline: none;
}

.history-filters-grid select {
  border: 1px solid var(--border-input);
  background: var(--bg-subtle);
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
}

/* ==========================================================================
   Pestaña 3: Presupuesto, Donut Chart y Money Tip
   ========================================================================== */

.hero-pill-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  border-radius: var(--radius-pill);
  padding: 0.42rem 0.85rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.hero-pill-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.hero-progress-track {
  height: 10px;
  width: 100%;
  background: rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin: 1.1rem 0 0.75rem;
}

.hero-progress-fill {
  height: 100%;
  background: #FFFFFF;
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

.hero-progress-fill.warn { background: #FDE68A; }
.hero-progress-fill.danger { background: #FCA5A5; }

.budget-hero-foot {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

.budget-insights-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1.15rem;
  align-items: stretch;
}

.donut-breakdown-layout {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.donut-chart-box {
  position: relative;
  width: 176px;
  height: 176px;
  flex-shrink: 0;
}

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

.donut-center-label strong {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
}

.donut-center-label span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.donut-legend {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.donut-legend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 220px;
  font-size: 0.81rem;
}

.donut-legend-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Money Tip / Consejo Financiero */
.money-tip-card {
  border-radius: var(--radius-card);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.75rem;
  border: 1px solid #CBE7DD;
  background: var(--mint-bg);
}

.money-tip-card.tip-warn {
  background: #FFFBEB;
  border-color: #FDE68A;
}

.money-tip-card.tip-danger {
  background: #FEF2F2;
  border-color: #FECACA;
}

.tip-icon-badge {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #FFFFFF;
  color: var(--mint-icon);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-card);
}

.money-tip-card.tip-warn .tip-icon-badge { color: #D97706; }
.money-tip-card.tip-danger .tip-icon-badge { color: #DC2626; }

.tip-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
}

.tip-body {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Límites Editables */
.global-limit-inline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  background: var(--bg-subtle);
  border-radius: 16px;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.gl-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.gl-info strong {
  display: block;
  font-size: 0.92rem;
}

.gl-info small {
  color: var(--text-muted);
  font-size: 0.76rem;
}

.category-limits-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.95rem;
}

.cat-limit-card {
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 0.95rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.cat-limit-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.cat-limit-title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 0.92rem;
}

.compact-currency {
  width: 138px;
}

.limit-bar-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--bg-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.25s ease, background-color 0.2s ease;
  background: var(--status-green);
}

.progress-bar-fill.status-green { background: var(--status-green); }
.progress-bar-fill.status-amber { background: var(--status-amber); }
.progress-bar-fill.status-red { background: var(--status-red); }

/* ==========================================================================
   Pestaña 4: Tarjetas Estilo Banca Moderna y Terceros
   ========================================================================== */

.bank-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.15rem;
}

.modern-bank-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}

.bank-plastic {
  padding: 1.35rem;
  color: #FFFFFF;
  position: relative;
  overflow: hidden;
}

.bank-plastic.theme-0 {
  background: linear-gradient(135deg, #0D6E52 0%, #042F24 100%);
}

.bank-plastic.theme-1 {
  background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
}

.bank-plastic.theme-2 {
  background: linear-gradient(135deg, #0F766E 0%, #134E4A 100%);
}

.plastic-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}

.plastic-bank {
  font-size: 0.73rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.85;
}

.plastic-name {
  font-size: 1.12rem;
  font-weight: 800;
  margin-top: 0.1rem;
}

.plastic-chip {
  width: 34px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, #FDE68A, #F59E0B);
  opacity: 0.9;
}

.plastic-available-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.plastic-avail-label {
  font-size: 0.74rem;
  opacity: 0.8;
  display: block;
}

.plastic-avail-val {
  font-size: 1.5rem;
  font-weight: 800;
}

.plastic-limit {
  font-size: 0.76rem;
  opacity: 0.85;
  text-align: right;
}

.plastic-dual-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-pill);
  overflow: hidden;
  display: flex;
}

.dual-seg-own {
  background: #34D399;
  height: 100%;
}

.dual-seg-third {
  background: #FBBF24;
  height: 100%;
}

.bank-card-tray {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.tray-split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  background: var(--bg-subtle);
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  font-size: 0.78rem;
}

.tray-split-grid strong {
  display: block;
  font-size: 0.9rem;
  margin-top: 0.1rem;
}

.tray-dates-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tray-dates {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Cuentas por cobrar a terceros */
.tp-receivables-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.tp-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-card);
  border-radius: 16px;
  background: var(--bg-subtle);
  flex-wrap: wrap;
}

/* ==========================================================================
   Pestaña 5: Préstamo Bancario con Anillo Circular
   ========================================================================== */

.loan-hero-layout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.loan-hero-left {
  flex: 1;
}

.loan-ring-wrap {
  position: relative;
  width: 112px;
  height: 112px;
  flex-shrink: 0;
}

.loan-ring-svg {
  width: 112px;
  height: 112px;
  transform: rotate(-90deg);
}

.loan-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 9;
}

.loan-ring-progress {
  fill: none;
  stroke: #FFFFFF;
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.35s ease;
}

.loan-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.15rem;
}

.loan-ring-text small {
  font-size: 0.66rem;
  font-weight: 600;
  opacity: 0.85;
}

.loan-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.1rem;
}

.loan-stat-tile {
  background: var(--bg-subtle);
  border-radius: 16px;
  padding: 0.9rem 1rem;
}

.loan-stat-tile span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.loan-stat-tile strong {
  font-size: 1.05rem;
  font-weight: 800;
}

/* ==========================================================================
   Estados Vacíos
   ========================================================================== */

.empty-box {
  text-align: center;
  padding: 2.2rem 1rem;
  color: var(--text-muted);
}

.empty-box h4 {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0.5rem 0 0.25rem;
}

.empty-box p {
  font-size: 0.83rem;
  max-width: 360px;
  margin: 0 auto 1rem;
}

/* ==========================================================================
   Modales / Bottom Sheets y Formularios
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 31, 26, 0.48);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-sheet {
  width: 100%;
  max-width: 500px;
  background: var(--bg-card);
  border-radius: 24px;
  box-shadow: var(--shadow-modal);
  padding: 1.35rem 1.5rem 1.5rem;
  animation: modalFadeIn 0.18s ease;
  max-height: 92vh;
  overflow-y: auto;
}

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

.sheet-handle {
  display: none;
  width: 42px;
  height: 5px;
  border-radius: var(--radius-pill);
  background: #D3DFDB;
  margin: 0 auto 0.75rem;
}

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

.modal-head h3 {
  font-size: 1.12rem;
  font-weight: 800;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-group label {
  font-size: 0.79rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.field-group input,
.field-group select {
  width: 100%;
  border: 1px solid var(--border-input);
  background: var(--bg-subtle);
  border-radius: 12px;
  padding: 0.62rem 0.8rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.field-group input:focus,
.field-group select:focus {
  background: #FFFFFF;
  border-color: var(--emerald-start);
  box-shadow: 0 0 0 3px rgba(13, 110, 82, 0.12);
}

.currency-field {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-input);
  background: var(--bg-subtle);
  border-radius: 12px;
  overflow: hidden;
}

.currency-field:focus-within {
  background: #FFFFFF;
  border-color: var(--emerald-start);
  box-shadow: 0 0 0 3px rgba(13, 110, 82, 0.12);
}

.currency-field span {
  padding: 0 0.68rem;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--mint-icon);
}

.currency-field input {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0.58rem 0.65rem 0.58rem 0;
  width: 100%;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.currency-field-lg input {
  font-size: 1.12rem;
  font-weight: 800;
}

/* Segmented Pills para Tipo de Gasto */
.segmented-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-subtle);
  padding: 0.25rem;
  border-radius: 14px;
  gap: 0.25rem;
}

.seg-pill {
  position: relative;
  cursor: pointer;
}

.seg-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.seg-pill span {
  display: block;
  text-align: center;
  padding: 0.52rem 0.35rem;
  border-radius: 11px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.seg-pill input:checked + span {
  background: var(--emerald-gradient);
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(13, 110, 82, 0.22);
}

.mint-callout-box {
  background: var(--mint-bg);
  border: 1px solid #C4E4D9;
  border-radius: 16px;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.callout-note {
  font-size: 0.75rem;
  color: var(--mint-icon);
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

/* ==========================================================================
   Barra Inferior Móvil, FAB y Toasts
   ========================================================================== */

.mobile-bottom-nav {
  display: none;
}

.mobile-fab {
  display: none;
}

.toast-container {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 140;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--emerald-end);
  color: #FFFFFF;
  font-size: 0.83rem;
  font-weight: 700;
  padding: 0.7rem 1.05rem;
  border-radius: 14px;
  box-shadow: var(--shadow-hero);
  animation: fadeSlide 0.2s ease;
}

/* ==========================================================================
   Responsividad: Tablets y Móviles (<= 768px)
   ========================================================================== */

@media (max-width: 960px) {
  .budget-insights-grid,
  .bank-cards-grid,
  .category-limits-list {
    grid-template-columns: 1fr;
  }

  .history-filters-grid {
    grid-template-columns: 1fr;
  }

  .loan-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .sidebar {
    display: none;
  }

  .workspace {
    padding: 16px 16px 0;
    max-width: 100%;
    overflow-x: hidden;
  }

  main,
  .main-content {
    padding-bottom: 90px;
    width: 100%;
    max-width: 100%;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    margin-bottom: 1.15rem;
  }

  .topbar-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
  }

  .greeting-name {
    font-size: 1.22rem;
  }

  .hide-xs {
    display: none;
  }

  .icon-pill-btn {
    padding: 0.45rem 0.6rem;
  }

  .hero-card-deco {
    display: none;
  }

  .hero-tag {
    margin-right: 0;
  }

  .hero-amount {
    font-size: 1.8rem;
  }

  .hero-bottom-stats {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .hero-stat-divider {
    display: none;
  }

  .quick-actions-row {
    gap: 0.55rem;
  }

  .quick-action-item {
    padding: 0.75rem 0.35rem;
    border-radius: 16px;
    min-width: 0;
  }

  .qa-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }

  .qa-label {
    font-size: 0.73rem;
    text-align: center;
    line-height: 1.2;
  }

  .donut-breakdown-layout {
    flex-direction: column;
    align-items: center;
  }

  .loan-hero-layout {
    flex-direction: column-reverse;
    align-items: flex-start;
  }

  .tx-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.55rem;
  }

  .tx-right-side {
    width: 100%;
    justify-content: space-between;
    padding-left: 3.25rem;
    flex-wrap: wrap;
  }

  .tx-amount-box {
    text-align: left;
  }

  /* Barra de navegación inferior fija exactamente al ancho de pantalla */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: auto;
    z-index: 60;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-card);
    box-shadow: 0 -4px 20px rgba(6, 78, 59, 0.06);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-nav-item {
    appearance: none;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 11px;
    line-height: 1.2;
    font-weight: 600;
    padding: 2px 2px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    transition: color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-nav-item span {
    display: block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-nav-item:focus,
  .mobile-nav-item:focus-visible,
  .mobile-nav-item:active {
    outline: none;
    box-shadow: none;
  }

  .mobile-nav-item.active {
    color: var(--emerald-start);
    font-weight: 800;
  }

  /* Botón flotante (+) posicionado sin cortes ni colisiones */
  .mobile-fab {
    position: fixed;
    right: 16px;
    bottom: 84px;
    z-index: 65;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    outline: none;
    background: var(--emerald-gradient);
    color: #FFFFFF;
    display: grid;
    place-items: center;
    box-shadow: 0 10px 24px rgba(6, 78, 59, 0.32);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-fab:focus,
  .mobile-fab:focus-visible {
    outline: none;
  }

  .mobile-fab svg.lucide {
    width: 24px;
    height: 24px;
  }

  /* Bottom Sheet para móviles */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-sheet {
    max-width: 100%;
    border-radius: 24px 24px 0 0;
    padding: 0.75rem 1.2rem 1.6rem;
    animation: sheetSlideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  }

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

  .sheet-handle {
    display: block;
  }

  .form-grid-2 {
    grid-template-columns: 1fr;
  }

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

  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 88px;
  }
}

@media (max-width: 480px) {
  .workspace {
    padding: 12px 14px 0;
  }

  .surface-card,
  .emerald-hero-card,
  .money-tip-card {
    padding: 1.1rem;
    max-width: 100%;
  }

  .hero-amount {
    font-size: 1.65rem;
  }

  .hero-split-pill {
    display: flex;
    flex-wrap: wrap;
    font-size: 0.72rem;
    max-width: 100%;
  }

  .compact-alert-banner {
    flex-wrap: wrap;
    padding: 0.75rem 0.9rem;
    font-size: 0.79rem;
  }

  .compact-alert-left {
    min-width: 0;
    flex: 1 1 190px;
  }

  .quick-actions-row {
    gap: 0.45rem;
  }

  .quick-action-item {
    padding: 0.65rem 0.25rem;
  }

  .qa-icon-box {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .qa-label {
    font-size: 11px;
  }

  .type-pills-row {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .filter-chip {
    padding: 0.38rem 0.68rem;
    font-size: 0.75rem;
  }

  .tx-right-side {
    padding-left: 0;
    gap: 0.45rem;
  }

  .top-cat-amount {
    min-width: auto;
    font-size: 0.85rem;
  }

  .top-cat-pct {
    min-width: 34px;
    font-size: 0.76rem;
  }

  .cat-limit-card {
    padding: 0.85rem;
  }

  .compact-currency {
    width: 116px;
    flex-shrink: 0;
  }

  .limit-bar-meta {
    flex-wrap: wrap;
    gap: 0.3rem;
  }

  .tray-split-grid {
    gap: 0.45rem;
    padding: 0.55rem 0.65rem;
    font-size: 0.73rem;
  }

  .loan-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }

  .loan-stat-tile {
    padding: 0.75rem;
    min-width: 0;
  }

  .loan-stat-tile strong {
    font-size: 0.92rem;
    word-break: break-word;
  }
}

@media (max-width: 400px) {
  .topbar-actions {
    gap: 0.4rem;
  }

  .month-pill {
    padding: 0.15rem 0.2rem;
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 80px);
    justify-content: space-between;
  }

  .month-pill .icon-circle-btn {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
  }

  .month-pill input[type="month"] {
    font-size: 0.76rem;
    padding: 0.18rem 0.12rem;
    min-width: 0;
    width: 100%;
  }

  .topbar-backup {
    gap: 0.35rem;
    flex-shrink: 0;
  }

  .topbar-backup .icon-pill-btn {
    width: 35px;
    height: 35px;
    padding: 0;
    justify-content: center;
  }

  .mobile-nav-item {
    font-size: 10px;
  }
}


/* ==========================================================================
   Pantalla de Inicio de Sesión (Supabase Auth), Perfiles y Tiempo Real
   ========================================================================== */

.auth-screen {
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  padding: 1.25rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 85% 12%, rgba(13, 110, 82, 0.12) 0%, rgba(13, 110, 82, 0) 48%),
    radial-gradient(circle at 12% 88%, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0) 45%),
    var(--bg-body);
}

.auth-card {
  width: 100%;
  max-width: 416px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 24px;
  padding: 2.1rem 1.85rem;
  box-shadow: 0 18px 42px rgba(6, 78, 59, 0.08), 0 1px 3px rgba(6, 78, 59, 0.04);
}

.auth-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-logo {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  margin: 0 auto 0.85rem;
}

.auth-logo svg.lucide {
  width: 28px;
  height: 28px;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-main);
}

.auth-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.auth-notice-box {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  background: var(--mint-bg);
  border: 1px solid #C2E5D8;
  color: var(--mint-icon);
  border-radius: 14px;
  padding: 0.85rem 0.95rem;
  margin-bottom: 1.15rem;
  font-size: 0.79rem;
  line-height: 1.45;
}

.auth-notice-box strong {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 0.15rem;
}

.auth-notice-box code {
  background: rgba(255, 255, 255, 0.75);
  padding: 0.08rem 0.35rem;
  border-radius: 5px;
  font-size: 0.74rem;
  font-weight: 700;
}

.auth-error-box {
  background: var(--status-red-bg);
  border: 1px solid #FECACA;
  color: var(--status-red-text);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font-size: 0.81rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.input-icon-wrap {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--border-input);
  background: var(--bg-subtle);
  border-radius: 13px;
  padding: 0 0.8rem;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.input-icon-wrap:focus-within {
  background: #FFFFFF;
  border-color: var(--emerald-start);
  box-shadow: 0 0 0 3px rgba(13, 110, 82, 0.12);
}

.input-icon-wrap > svg.lucide {
  color: var(--text-muted);
  width: 17px;
  height: 17px;
}

.input-icon-wrap input {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0.72rem 0 !important;
  width: 100%;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
}

.pwd-eye-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 0.25rem;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  border-radius: 8px;
}

.pwd-eye-btn:hover {
  color: var(--emerald-start);
}

.auth-submit-btn {
  margin-top: 0.35rem;
  padding: 0.82rem 1.1rem;
  font-size: 0.94rem;
}

.auth-footnote {
  margin-top: 1.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-card);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.auth-footnote svg.lucide {
  width: 15px;
  height: 15px;
  color: var(--mint-icon);
}

/* Indicador Realtime y Barra de Sincronización */
.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-green);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

.sync-indicator.syncing .sync-dot {
  background: var(--status-amber);
}

.sync-indicator.offline .sync-dot {
  background: var(--status-red);
  box-shadow: none;
}

.cloud-loading-bar {
  height: 3px;
  width: 100%;
  border-radius: var(--radius-pill);
  margin-bottom: 0.75rem;
  background: linear-gradient(90deg, #E6F4EF 0%, #0D6E52 50%, #E6F4EF 100%);
  background-size: 200% 100%;
  animation: shimmerLoad 1.1s linear infinite;
}

@keyframes shimmerLoad {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Controles de Usuario, Avatares e Insignias de Autor */
.sidebar-user-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-card);
  border-radius: 14px;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.75rem;
}

.user-profile-trigger {
  appearance: none;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  min-width: 0;
  flex: 1;
  padding: 0;
}

.user-trigger-meta {
  min-width: 0;
}

.user-trigger-meta strong {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-trigger-meta small {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.author-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--emerald-start);
  color: #FFFFFF;
  font-size: 0.82rem;
  font-weight: 800;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.author-avatar.sm {
  width: 30px;
  height: 30px;
  font-size: 0.76rem;
}

.greeting-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.user-top-controls {
  display: none;
  align-items: center;
  gap: 0.4rem;
}

.avatar-chip-btn {
  appearance: none;
  border: 2px solid #FFFFFF;
  background: transparent;
  padding: 0;
  border-radius: 50%;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}

/* Badge discreto de autor en cada fila de movimiento */
.author-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.12rem 0.5rem 0.12rem 0.18rem;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  white-space: nowrap;
}

.author-mini-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--emerald-start);
  color: #FFFFFF;
  font-size: 0.6rem;
  font-weight: 800;
  display: inline-grid;
  place-items: center;
  text-transform: uppercase;
}

/* Filtros duales en Análisis */
.filter-bar-dual {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}

.filter-bar-dual .type-pills-row {
  margin-bottom: 0;
}

/* Selector de colores de avatar */
.avatar-color-picker {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.color-swatch-opt {
  position: relative;
  cursor: pointer;
}

.color-swatch-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.color-swatch-opt span {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: block;
  border: 3px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.color-swatch-opt input:checked + span {
  transform: scale(1.1);
  border-color: #FFFFFF;
  box-shadow: 0 0 0 2.5px var(--text-main);
}

@media (max-width: 768px) {
  .user-top-controls {
    display: inline-flex;
  }

  .filter-bar-dual {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
}

@media (max-width: 400px) {
  .auth-card {
    padding: 1.55rem 1.2rem;
    border-radius: 20px;
  }

  .auth-title {
    font-size: 1.32rem;
  }

  .logout-pill {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
  }
}
