*{box-sizing:border-box}
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
  background:#0b1020;
  color:#fff;
}

/* Top bar */
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:14px 16px;
  background:linear-gradient(90deg,#3b82f6,#0ea5e9,#16a34a);
}
.topbar-actions{
  display:flex;
  gap:10px;
  align-items:center;
  flex:1;
  justify-content:center;
  padding:0 10px;
}
.topbtn{
  border:none;
  border-radius:12px;
  padding:8px 10px;
  font-weight:700;
  font-size:12px;
  color:white;
  cursor:pointer;
  box-shadow:0 6px 18px rgba(0,0,0,.18);
  white-space:nowrap;
}
.topbtn-expense{ background:#ef4444; }
.topbtn-money{ background:#22c55e; }
.topbtn:active{ transform: translateY(1px); }
.brand{
  font-weight:900;
  letter-spacing:.08em;
}
.hamburger{
  font-size:26px;
  background:none;
  border:none;
  color:white;
}

/* Layout */
.container{padding:16px}
.metrics-row{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:12px;
}
.metric{
  background:#111827;
  border-radius:16px;
  padding:12px;
  text-align:center;
}
.metric span{
  font-size:11px;
  opacity:.75;
}
.metric strong{
  display:block;
  margin-top:4px;
  font-size:16px;
}

/* Surplus */
.surplus-card{
  margin-top:14px;
  background:#020617;
  border:2px solid #22c55e;
  border-radius:18px;
  padding:14px;
  text-align:center;
  font-size:16px;
}

/* Sections */
.nextPay,.feed{
  margin-top:16px;
  background:#020617;
  border-radius:16px;
  padding:14px;
}
.feed h4,.nextPay h4{
  margin:0 0 8px 0;
}
.feedItem{
  padding:10px 0;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.feedItem:last-child{border:none}

/* Buttons */
.action{
  margin-top:14px;
  width:100%;
  padding:14px;
  border-radius:16px;
  font-weight:600;
  border:none;
  color:white;
}
.secondary{
  background:#111827;
  border:1px solid rgba(255,255,255,.12);
}
.primary{
  background:linear-gradient(90deg,#3b82f6,#0ea5e9,#16a34a);
}
.primary.danger{ background:#ef4444; }
.primary.success{ background:#22c55e; }
.primary.danger{ background:#ef4444; }
.primary.success{ background:#22c55e; }


/* Menu */
.menu{
  position:fixed;
  top:0;
  right:-200px;
  width:190px;
  height:100%;
  background:#020617;
  padding:14px;
  transition:right .25s ease;
  z-index:20;
}
.menu.open{right:0}
.menuTop{
  display:flex;
  justify-content:space-between;
  margin-bottom:12px;
}
.menu button{
  width:100%;
  padding:10px;
  margin-bottom:8px;
  background:#111827;
  border:none;
  border-radius:12px;
  color:white;
}

/* Modals */
.backdrop{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.6);
  display:none;
  z-index:10;
}
.backdrop.show{display:block}
.modal{
  display:none;
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.7);
  align-items:center;
  justify-content:center;
  z-index:30;
}
.modal.show{display:flex}
.card{
  background:#020617;
  border-radius:20px;
  padding:18px;
  width:100%;
  max-width:420px;
  position:relative;
  /* Allow tall modals (e.g., Monthly payday fields) to scroll so action buttons stay reachable on mobile. */
  max-height:90vh;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
}
.card h3{margin-top:0}
.close{
  position:absolute;
  top:12px;
  right:12px;
  background:none;
  border:none;
  color:white;
  font-size:18px;
}
input,select{
  width:100%;
  padding:12px;
  border-radius:14px;
  border:none;
  background:#111827;
  color:white;
  margin-bottom:10px;
}

/* Mobile */
@media(max-width:640px){
  .metrics-row{grid-template-columns:1fr 1fr}
  .topbar{padding:12px 12px}
  .brand{font-size:13px}
  .topbar-actions{gap:8px; padding:0 6px}
  .topbtn{padding:7px 9px; font-size:11px; border-radius:11px}
}


/* Surplus coloring */
.surplus-positive { color: #22c55e; }
.surplus-zero { color: #ffffff; }
.surplus-negative { color: #ef4444; }

.feedItem.pastDue {
  border-left: 4px solid #ef4444;
  background: rgba(239,68,68,0.08);
}

.calendar-grid{
  display:grid;
  grid-template-columns: repeat(7,1fr);
  gap:6px;
}
.cal-header{
  grid-column: span 7;
  text-align:center;
  font-weight:600;
  margin-bottom:6px;
}
.cal-day-head{
  font-size:12px;
  opacity:.7;
  text-align:center;
}
.cal-day{
  background:#1f2933;
  border-radius:8px;
  padding:6px;
  min-height:60px;
  cursor:pointer;
}
.cal-num{
  font-size:12px;
}
.dots{
  margin-top:4px;
}
.dot{
  display:inline-block;
  width:6px;
  height:6px;
  border-radius:50%;
  margin-right:4px;
}
.dot.red{background:#ef4444;}
.dot.green{background:#22c55e;}
.dot.blue{background:#3b82f6;}

/* Themed Buttons */
.themed-btn{
  background:linear-gradient(135deg,#0284c7,#0d9488);
  color:#fff;
  border:none;
  border-radius:10px;
  padding:10px 14px;
  font-weight:600;
  cursor:pointer;
}
.themed-btn.secondary{
  background:#1c1f3a;
  color:#cfd4ff;
  border:1px solid #2d3260;
}
.dev-reset{
  margin-top:12px;
  background:#3a1c1c;
  color:#ffd6d6;
  border:1px solid #5a2a2a;
}
.empty-note{opacity:.7;margin-top:8px;}

/* ===== Gradient Button Theme (Global) ===== */
button,
.menu button,
.themed-btn {
  background: linear-gradient(135deg,#0284c7,#0d9488);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}

button:hover,
.menu button:hover,
.themed-btn:hover {
  opacity: 0.95;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

.themed-btn.secondary,
.menu button.secondary {
  background: linear-gradient(135deg,#1c1f3a,#2d3260);
  color: #cfd4ff;
}

.menu button {
  width: 100%;
  margin-bottom: 8px;
}
/* ========================================= */

/* ===== Restore Charcoal Menu Buttons ===== */
.menu button {
  background: #1c1f3a !important;
  color: #e6e9ff !important;
  border: 1px solid #2d3260 !important;
  border-radius: 12px;
}

.menu button:hover {
  background: #24285a !important;
}
/* ======================================= */

/* ===== Confirm / Payday Button ===== */
button.confirm,
button.confirm-payday,
button.primary.confirm {
  background: linear-gradient(135deg,#2ecc71,#27ae60) !important;
  color: #ffffff !important;
}

button.confirm:hover,
button.confirm-payday:hover,
button.primary.confirm:hover {
  box-shadow: 0 0 0 2px rgba(46,204,113,.25);
}
/* ===================================== */

/* ================= NEWSFEED ================= */

.feedRow{
  display:flex;
  align-items:center;
}

.feedText{
  text-align:left;
}

.feedActions{
  margin-left:auto;
  display:flex;
  gap:6px;
}

.feedActions button{
  font-size:12px;
  padding:4px 8px;
  border-radius:8px;
  font-weight:600;
  cursor:pointer;
}

/* Pay (full) */
.btn-pay{
  background:linear-gradient(135deg,#2ecc71,#27ae60);
  color:#fff;
  border:none;
}

/* Pay Partial (light yellow) */
.btn-pay-partial{
  background:linear-gradient(135deg,#fff9c4,#ffe066);
  color:#1c1f3a;
  border:none;
}

/* Row states */
.row-upcoming{
  background:rgba(241,196,15,0.15);
}
.row-overdue{
  background:rgba(231,76,60,0.15);
}
.row-paid{
  background:rgba(46,204,113,0.15);
}

/* =========================================== */

/* ===== NEWSFEED FINAL ===== */
.feedRow{
  display:flex;
  align-items:center;
}
.feedText{
  text-align:left;
}
.feedActions{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:6px;
}
.feedActions button{
  font-size:12px;
  padding:4px 8px;
  border-radius:8px;
  font-weight:600;
  cursor:pointer;
}

/* Pay full */
.btn-pay{
  background:linear-gradient(135deg,#2ecc71,#27ae60);
  color:#fff;
  border:none;
}

/* Pay partial */
.btn-pay-partial{
  background:linear-gradient(135deg,#fff9c4,#ffe066);
  color:#1c1f3a;
  border:none;
}

/* Paid checkmark */
.paid-check{
  color:#2ecc71;
  font-weight:700;
  font-size:13px;
}

/* Row states */
.row-upcoming{background:rgba(241,196,15,0.15);}
.row-overdue{background:rgba(231,76,60,0.15);}
.row-paid{background:rgba(46,204,113,0.15);}

.payday-card{background:#111827;border-radius:12px;padding:12px;margin-bottom:12px;}
.payday-countdown{font-size:12px;color:#22c55e;margin-top:4px;}
.payday-actions{margin-top:8px;display:flex;gap:8px;}
.btn-confirm{background:linear-gradient(135deg,#22c55e,#16a34a);color:#fff;border:none;border-radius:8px;padding:6px 12px;}
.btn-confirm:disabled{opacity:.5;}
.btn-change{background:linear-gradient(135deg,#374151,#1f2933);color:#fff;border:none;border-radius:8px;padding:6px 12px;}


/* Ledger/News Feed tabs */
.feedTabs{
  display:flex;
  align-items:center;
  gap:10px;
  margin:0 0 8px 0;
}
.feedTab{
  cursor:pointer;
  user-select:none;
  opacity:.65;
  font-weight:700;
}
.feedTabSep{
  opacity:.35;
}
.feedTab-active{
  opacity:1;
  text-decoration:underline;
  text-underline-offset:6px;
}

.feed-tab {
  cursor: pointer;
  pointer-events: auto;
  opacity: .6;
}
.feed-tab:hover {
  opacity: 1;
}


/* Ledger amount highlights */
.ledger-income {
  background: rgba(0, 180, 90, 0.08);
}

.ledger-expense {
  background: rgba(200, 50, 50, 0.08);
}


/* Ledger-only amount styling */
#ledgerFeed .ledger-amount{font-size:13px;}


/* v36: Date display */
.dateDisplay{
  margin: 10px 0 6px 0;
  font-weight: 700;
  opacity: .9;
  text-align: left;
}

/* v36: History modal */
.historyWrap{
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 12px;
  margin-top: 10px;
}
.historyHint{
  font-size: 12px;
  opacity: .7;
  margin-bottom: 6px;
}
.historyMonthsBtn{
  width: 100%;
  text-align: left;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  color: inherit;
  cursor: pointer;
  margin-bottom: 8px;
}
.historyMonthsBtn.active{
  border-color: rgba(46, 204, 113, .6);
}
.historyMeta{
  font-size: 14px;
  margin-bottom: 10px;
}
.historyLedger{
  max-height: 52vh;
  overflow: auto;
  padding-right: 6px;
}
@media (max-width: 520px){
  .historyWrap{ grid-template-columns: 1fr; }
}

/* v36: bill remove */
.btn-remove{
  background: rgba(239,68,68,.15);
  border: 1px solid rgba(239,68,68,.35);
  color: #ef4444;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  margin-left: 6px;
}
.btn-remove:hover{ background: rgba(239,68,68,.22); }

/* =========================
   Auth Gate (minimal / non-intrusive)
   - Only visible when unauthenticated
   - Does not alter authenticated UI
========================= */
.authGate{
  position:fixed;
  inset:0;
  z-index:100;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  background:rgba(0,0,0,.78);
}
.authCard{
  width:100%;
  max-width:420px;
  background:#020617;
  border-radius:20px;
  padding:18px;
  box-shadow:0 18px 40px rgba(0,0,0,.5);
  border:1px solid rgba(255,255,255,.10);
}
.authBrand{
  font-weight:900;
  letter-spacing:.08em;
  text-align:center;
  margin-bottom:12px;
}
.authTabs{
  display:flex;
  gap:10px;
  margin-bottom:12px;
}
.authTab{
  flex:1;
  padding:10px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.12);
  background:#111827;
  color:#fff;
  font-weight:700;
  cursor:pointer;
}
.authTabActive{
  background:linear-gradient(90deg,#3b82f6,#0ea5e9,#16a34a);
  border:none;
}
.authForm .primary{
  width:100%;
  padding:12px;
  border-radius:14px;
  font-weight:800;
  cursor:pointer;
}
.authError{
  margin-bottom:10px;
  background:rgba(239,68,68,.12);
  border:1px solid rgba(239,68,68,.35);
  padding:10px;
  border-radius:14px;
  color:#fff;
  font-size:13px;
}
.authHint{
  margin-top:10px;
  font-size:12px;
  opacity:.75;
  text-align:center;
}

/* When auth gate is up, prevent interacting with underlying app */
body.authMode header,
body.authMode main,
body.authMode aside{
  pointer-events:none;
  user-select:none;
}
/* Fix #1: Bills modal containment — keep inputs/close visible and make bill list scrollable */
#billsModal .card{
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#billList{
  overflow-y: auto;
  max-height: 40vh;
}




/* Auth recovery link: explicit visible row under password submit */
.forgotPasswordRow{
  display:block;
  width:100%;
  text-align:center;
  margin-top:8px;
}
.authForgot{
  display:inline-block;
  background:transparent;
  border:0;
  color:#93c5fd;
  cursor:pointer;
  font-size:13px;
  margin:0 auto;
  padding:8px 10px;
  text-decoration:underline;
}
.authForgot:hover{ color:#bfdbfe; }


/* =========================
   Login-screen PWA install prompt
   - Auth screen only
   - Lightweight, native-feeling, non-intrusive
========================= */
.installSection{
  margin-top:14px;
  padding-top:14px;
  border-top:1px solid rgba(255,255,255,.10);
  text-align:center;
}
.installSection[hidden]{ display:none !important; }
.installButton{
  width:100%;
  border:1px solid rgba(59,130,246,.45);
  background:rgba(59,130,246,.12);
  color:#e5f0ff;
  border-radius:14px;
  padding:11px 12px;
  font-weight:800;
  letter-spacing:.01em;
  cursor:pointer;
  box-shadow:0 10px 24px rgba(59,130,246,.08);
}
.installButton:hover,
.installButton:focus-visible{
  background:rgba(59,130,246,.18);
  outline:2px solid rgba(59,130,246,.35);
  outline-offset:2px;
}
.installButton:disabled{
  opacity:.65;
  cursor:not-allowed;
}
.installHint{
  margin-top:8px;
  color:rgba(229,231,235,.72);
  font-size:12px;
  line-height:1.35;
}
.installSuccess{
  color:rgba(134,239,172,.9);
}
@media (max-width:520px){
  .installSection{ margin-top:12px; padding-top:12px; }
  .installButton{ padding:10px 12px; }
}
