html, body { 
  overflow-x: hidden; 
  width: 100%; 
  margin: 0;
  padding: 0;
}

* { box-sizing: border-box; }

:root { 
  --navy: #002147; 
  --blue: #0067E6; 
  --urgent: #e11d48; 
  --bg: #f2f4f7; 
  --text: #1f2937; 
  --subtext: #6b7280;
  --success: #10b981; 
  --border: #e5e7eb;
  --gold: #d97706;
}

body { 
  font-family: 'Inter', -apple-system, sans-serif; 
  background-color: var(--bg); 
  color: var(--text); 
  padding-bottom: 100px; 
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}

#app-content {
  width: 100%;
  max-width: 1200px; 
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 20px rgba(0,0,0,0.05);
  margin: 0 auto;
}

.header { 
  background: #ffffff; 
  padding: 25px 20px; 
  border-bottom: 1px solid var(--border); 
}

/* --- BRANDING & LOGOS --- */
.brand-logo { height: 85px; width: auto; margin: -15px 0; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.05)); }
.login-logo { width: 450px; height: auto; margin-bottom: 25px; filter: drop-shadow(0 6px 12px rgba(0,0,0,0.15)); }

.brand-title { 
  font-size: 1.3rem; 
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--navy); 
  margin: 0;
  transition: color 0.3s;
}

.top-banner { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }

/* --- ANIMATIONS & LOADERS --- */
@keyframes fadePulse {
  0% { opacity: 0.3; transform: scale(0.98); filter: drop-shadow(0 0 10px rgba(0, 103, 230, 0.2)); }
  50% { opacity: 1; transform: scale(1.02); filter: drop-shadow(0 0 35px rgba(0, 103, 230, 0.8)); }
  100% { opacity: 0.3; transform: scale(0.98); filter: drop-shadow(0 0 10px rgba(0, 103, 230, 0.2)); }
}

body.is-loading .brand-logo { animation: fadePulse 2s ease-in-out infinite; }

#fullscreen-loader { 
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
  background: rgba(242,244,247,0.45); 
  backdrop-filter: blur(3px); 
  z-index: 99999; align-items: center; justify-content: center; 
}
body.is-loading #fullscreen-loader { display: flex; }
.giant-spin { width: 450px; height: auto; animation: fadePulse 2s ease-in-out infinite; }

/* --- CONTROLS & BUTTONS --- */
.app-month-select { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); font-family: 'Inter', sans-serif; font-weight: 700; color: var(--navy); background: #f8fafc; outline: none; font-size: 0.9rem;}
.label { font-size: 0.7rem; font-weight: 800; color: var(--subtext); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }

.header-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.btn-header { padding: 12px; background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 8px; font-weight: 800; color: var(--navy); cursor: pointer; font-family: 'Inter', sans-serif; font-size: 0.8rem; display: flex; align-items: center; justify-content: center; gap: 5px; transition: background 0.2s;}
.btn-header:active { background: #e2e8f0; }
.btn-savings { padding: 12px; border-radius: 8px; font-weight: 800; font-size: 0.75rem; cursor: pointer; flex: 1; font-family: 'Inter', sans-serif; text-transform: uppercase; border: none;}
button[onclick*="save"] { background: var(--blue) !important; color: white !important; width: 100%; padding: 18px; border-radius: 50px; border: none; font-weight: 800; margin-top: 25px; cursor: pointer; font-size: 1.05rem; font-family: 'Inter', sans-serif; box-shadow: 0 4px 12px rgba(0, 97, 255, 0.25); text-transform: uppercase; letter-spacing: 0.5px;}

/* Action Hub Specific Buttons */
.hub-btn { width: 100%; padding: 16px; margin-bottom: 12px; background: white; color: var(--navy); border: 2px solid #e2e8f0; border-radius: 12px; font-weight: 800; font-size: 1.05rem; cursor: pointer; text-align: left; display: flex; align-items: center; gap: 15px; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.hub-btn:active { background: #f8fafc; border-color: #cbd5e1; }

.toggle-container { background: #e5e7eb; border-radius: 99px; padding: 4px; display: flex; margin-bottom: 20px;}
.toggle-btn { flex: 1; border-radius: 99px; padding: 10px; font-weight: 700; font-size: 0.85rem; border: none; background: transparent; cursor: pointer; color: var(--subtext); font-family: 'Inter', sans-serif; transition: 0.2s;}
.toggle-btn.active { background: white; color: var(--navy); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

/* --- CARDS & LAYOUTS --- */
.home-row { display: flex; gap: 10px; margin: 15px 20px; }
.stat-box { flex: 1; background: white; padding: 15px 10px; border-radius: 12px; border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; box-shadow: 0 2px 4px rgba(0,0,0,0.02);}
.stat-title { font-size: 0.65rem; font-weight: 800; text-transform: uppercase; color: var(--subtext); margin-bottom: 8px; letter-spacing: 0.5px;}
.stat-val { font-size: 1.25rem; font-weight: 800; color: var(--navy); margin: 0;}

/* Block elements naturally fill space. Using width: auto prevents overflow */
.card, .snowball-card, .chart-container, .variance-card, .tx-card, .bal-card { 
  background: #ffffff; 
  border-radius: 14px; 
  border: 1px solid var(--border);
  margin: 15px 20px;
  width: auto; 
  overflow: hidden; 
  box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.chart-container { padding: 20px; height: 260px; display: flex; justify-content: center; align-items: center; position: relative; }
.upcoming-label { font-size: 0.8rem; font-weight: 800; color: var(--subtext); text-transform: uppercase; margin: 25px 20px 10px; letter-spacing: 0.5px; }

/* --- LISTS & ROWS --- */
.trigger { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; background: transparent; border: none; border-bottom: 1px solid #f1f5f9; cursor: pointer; text-align: left; transition: background 0.2s;}
.trigger:active { background: #f8fafc; }
.drawer { display: none; padding: 0; }
.cat-name { font-weight: 800; font-size: 1.05rem; color: var(--navy); }
.cat-bal { font-weight: 800; font-size: 1.1rem; color: var(--text); }
.row { padding: 18px 20px; border-bottom: 1px solid #f1f5f9; }

.upcoming-chip { background: white; border: 1px solid #e2e8f0; border-left: 4px solid var(--blue); padding: 15px; border-radius: 10px; min-width: 150px; margin-right: 12px; display: inline-block; box-shadow: 0 4px 6px rgba(0,0,0,0.03); }
.upcoming-chip.urgent { border-left-color: var(--urgent); background: #fef2f2; border-color: #fca5a5; }
.upcoming-scroll { display: flex; overflow-x: auto; padding: 5px 20px 20px; scrollbar-width: none; }
.upcoming-scroll::-webkit-scrollbar { display: none; }

.snowball-row { padding: 18px 20px; border-bottom: 1px solid #f1f5f9; display: flex; justify-content: space-between; align-items: center; }
.snowball-target { background: #f0fdf4; border-left: 4px solid var(--success);}
.target-badge { background: var(--success); color: white; padding: 3px 8px; border-radius: 6px; font-size: 0.55rem; font-weight: 800; display: inline-block; margin-bottom: 6px; border: 1px solid #86efac; letter-spacing: 0.5px;}

.cb-item { background: white; padding: 18px 20px; border-bottom: 1px solid #f1f5f9; display: flex; justify-content: space-between; align-items: center; }
.cb-desc { font-weight: 800; font-size: 1rem; color: var(--navy); margin-bottom: 4px; }
.cb-cat { font-size: 0.75rem; color: var(--subtext); font-weight: 600; }
.cb-bal { font-size: 0.75rem; color: var(--subtext); font-weight: 700; margin-top: 4px; text-align: right;}

.tx-top { padding: 12px 18px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; }
.badge { font-size: 0.65rem; font-weight: 800; padding: 4px 8px; border-radius: 6px; text-transform: uppercase; letter-spacing: 0.5px;}
.tx-mid { padding: 18px; }
.tx-mid h4 { margin: 0 0 6px 0; font-size: 1.05rem; color: var(--navy); font-weight: 800;}
.tx-mid p { margin: 0; font-size: 0.8rem; color: var(--subtext); font-weight: 600; }
.tx-actions { padding: 12px 15px; background: #f8fafc; border-top: 1px solid #e2e8f0; display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }

.cat-select { padding: 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 0.85rem; font-family: 'Inter', sans-serif; font-weight: 600; color: var(--navy); outline: none; background: white;}
.btn-choice { padding: 10px; border-radius: 8px; font-weight: 800; font-size: 0.75rem; border: none; cursor: pointer; font-family: 'Inter', sans-serif; text-transform: uppercase;}
.btn-approve { background: var(--success); color: white; }
.btn-reset { background: white; color: var(--subtext); border: 1px solid #cbd5e1; }

.bal-card { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px;}
.bal-card-name { font-weight: 800; color: var(--navy); font-size: 1.05rem; }
.bal-card-amt { font-weight: 900; color: var(--text); font-size: 1.2rem; }

.v-row { display: flex; padding: 15px 20px; border-bottom: 1px solid #f1f5f9; font-size: 0.85rem; align-items: center; }
.v-header { font-weight: 800; color: var(--subtext); text-transform: uppercase; font-size: 0.7rem; background: #f8fafc; border-top: 1px solid #e2e8f0; letter-spacing: 0.5px; padding: 12px 20px;}

/* --- MODALS & OVERLAYS --- */
.modal-bg, .modal-overlay { 
  display:none; position:fixed; top:0; left:0; width:100%; height:100%; 
  background:rgba(0,0,0,0.6); z-index:20000; justify-content:center; align-items:flex-end; 
  backdrop-filter: blur(2px);
} 
.modal-box { background:white; padding:30px 25px; border-radius:24px 24px 0 0; width:100%; max-width:500px; max-height:90vh; overflow-y:auto; box-sizing: border-box; box-shadow: 0 -10px 25px rgba(0,0,0,0.1);}
.modal-label { display: block; font-size: 0.75rem; font-weight: 800; color: var(--subtext); text-transform: uppercase; margin-top: 18px; margin-bottom: 6px; letter-spacing: 0.5px;}
.modal-input, .cb-selector, .home-filter-select, .savings-input { width: 100%; padding: 14px; border: 1px solid #cbd5e1; border-radius: 10px; font-size: 1rem; box-sizing: border-box; background: #f8fafc; color: var(--navy); font-family: 'Inter', sans-serif; font-weight: 600; outline: none; transition: border-color 0.2s;}
.modal-input:focus, .cb-selector:focus, .savings-input:focus { border-color: var(--blue); background: white;}
.modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

/* --- TABS & NAVIGATION --- */
.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px);} to { opacity: 1; transform: translateY(0);} }

#toast { display:none; position:fixed; bottom:90px; left:50%; transform:translateX(-50%); z-index:999999; background:var(--navy); color:white; padding:12px 24px; border-radius:50px; font-size:0.85rem; font-weight:700; box-shadow:0 10px 25px rgba(0,33,71,0.3); text-align: center; white-space: nowrap; }

.bottom-nav { 
  position: fixed; bottom: 0; left: 0; right: 0; margin: 0 auto;
  width: 100%; max-width: 1200px; 
  background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); 
  border-top: 1px solid var(--border); display: flex; padding: 12px 0 25px;
}
.nav-btn { flex: 1; background: none; border: none; color: var(--subtext); font-size: 0.65rem; font-weight: 700; cursor: pointer; font-family: 'Inter', sans-serif; transition: color 0.2s;}
.nav-btn.active { color: #0067E6; filter: drop-shadow(0 0 5px rgba(0,103,230,0.4)); }
.nav-btn svg { width: 24px; height: 24px; margin-bottom: 4px; display: block; margin: 0 auto 4px; fill: currentColor; }

/* --- APPROVED STAGING CARDS --- */
.tx-card.approved { border: 1px solid var(--success); background: #f0fdf4; box-shadow: 0 4px 10px rgba(16, 185, 129, 0.1); }
.tx-card.approved .tx-top { background: #dcfce7; border-bottom: 1px solid #bbf7d0; }
.tx-card.approved h4 { color: #065f46; }

/* Styles for Pending Items */
.pending-item { background: rgba(0, 103, 230, 0.04) !important; border-left: 4px dashed #0067E6 !important; opacity: 0.8; }
.pending-badge { font-size: 0.55rem; background: #eef6ff; color: #0067E6; padding: 2px 6px; border-radius: 4px; font-weight: 800; margin-left: 8px; border: 1px solid #bfdbfe; vertical-align: middle; }

/* --- BULLETPROOF MOBILE FIX --- */
@media screen and (max-width: 768px) {
  /* By removing width: 100%, block elements automatically shrink to fit the screen minus their margins */
  .card, .tx-card, .bal-card, .chart-container, .variance-card {
    margin: 12px 15px !important;
  }
  .home-row { margin: 12px 15px !important; }
}