/* ═══════════════════════════════════════════════════════════════════════════
   FAMILYBILLS — style.css
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg:      #07090f;
  --surface: #0f1520;
  --surface2:#141d2e;
  --border:  #1a2235;
  --border2: #243044;
  --text:    #e8edf5;
  --muted:   #4a5a72;
  --muted2:  #2a3a52;
  --accent:  #3b7eff;
  --green:   #22c55e;
  --yellow:  #f59e0b;
  --red:     #ef4444;
  --orange:  #f97316;
  --purple:  #8b5cf6;
  --indigo:  #6366f1;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; width: 100%; overflow-x: hidden; }

body {
  font-family: 'DM Sans', sans-serif;
  background: #07090f;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ═══ APP SHELL ════════════════════════════════════════════════════════════ */
#app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
}

/* ═══ LOCK SCREEN ══════════════════════════════════════════════════════════ */
#lock-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  z-index: 999;
  display: flex; align-items: center; justify-content: center;
}

.lock-inner {
  display: flex; flex-direction: column; align-items: center;
  padding: 20px;
}
.lock-logo { font-size: 52px; margin-bottom: 16px; }
.lock-title { font-family: 'Syne', sans-serif; font-size: 30px; font-weight: 900; margin-bottom: 6px; }
.lock-sub { color: var(--muted); font-size: 14px; margin-bottom: 36px; }

.pin-dots { display: flex; gap: 18px; margin-bottom: 36px; }
.pin-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--muted2);
  transition: all 0.15s;
}
.pin-dot.filled { background: var(--accent); border-color: var(--accent); transform: scale(1.1); }
.pin-dot.error  { background: var(--red);    border-color: var(--red); }

.pin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 252px; }
.pin-key {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; height: 68px;
  font-family: 'Syne', sans-serif; font-size: 24px; font-weight: 800;
  color: var(--text); cursor: pointer;
  transition: all 0.1s; user-select: none;
}
.pin-key:active { background: var(--border2); transform: scale(0.93); }
.pin-zero { grid-column: 2; }
.pin-del  { font-size: 18px; color: var(--muted); }
.lock-error { color: var(--red); font-size: 13px; font-weight: 700; margin-top: 20px; min-height: 20px; letter-spacing: 0.5px; }

/* ═══ VIEWS ════════════════════════════════════════════════════════════════ */
.view { display: none; flex-direction: column; min-height: 100vh; }
.view.active { display: flex; }

/* ═══ TOPBAR ═══════════════════════════════════════════════════════════════ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 50;
}
.topbar-title { font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 800; }
.topbar-actions { display: flex; gap: 8px; }

.btn-primary { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 8px 14px; font-weight: 700; font-size: 13px; cursor: pointer; font-family: 'DM Sans', sans-serif; }
.btn-ghost   { background: var(--surface); color: var(--muted); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-weight: 700; font-size: 12px; cursor: pointer; font-family: 'DM Sans', sans-serif; }
.btn-back    { background: none; border: none; color: var(--accent); font-weight: 700; font-size: 14px; cursor: pointer; padding: 0; min-width: 60px; font-family: 'DM Sans', sans-serif; }
.btn-danger  { background: none; border: none; color: var(--red); font-weight: 700; font-size: 14px; cursor: pointer; padding: 0; min-width: 60px; text-align: right; font-family: 'DM Sans', sans-serif; }
.btn-full    { background: var(--accent); color: #fff; border: none; border-radius: 12px; padding: 14px; font-weight: 800; font-size: 15px; cursor: pointer; width: 100%; font-family: 'DM Sans', sans-serif; margin-top: 4px; }
.btn-dark    { background: var(--surface) !important; border: 1px solid var(--border); color: var(--muted) !important; }

/* ═══ SCROLL CONTENT ══════════════════════════════════════════════════════ */
.scroll-content { padding: 0 16px 120px; overflow-y: auto; flex: 1; }

/* ═══ PLAID BANNER ════════════════════════════════════════════════════════ */
.plaid-banner {
  margin: 14px 16px 0;
  background: linear-gradient(135deg, #1a1f3a, #0f1520);
  border: 1px solid #6366f133;
  border-radius: 14px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; transition: border-color 0.2s;
}
.plaid-banner:active { opacity: 0.85; }
.plaid-banner-left { display: flex; align-items: center; gap: 12px; }
.plaid-icon { font-size: 24px; }
.plaid-title { font-weight: 700; font-size: 14px; color: var(--text); }
.plaid-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }
.plaid-arrow { color: var(--indigo); font-size: 18px; font-weight: 700; }
.plaid-connected {
  margin: 10px 16px 0;
  background: #22c55e12; border: 1px solid #22c55e33;
  border-radius: 12px; padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 700; color: var(--green);
}
.plaid-refresh { background: none; border: 1px solid #22c55e44; color: var(--green); border-radius: 8px; padding: 4px 10px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: 'DM Sans', sans-serif; }

/* ═══ BALANCE CARD ════════════════════════════════════════════════════════ */
.balance-card {
  margin: 10px 16px 0;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: 16px; padding: 16px 18px; cursor: pointer;
}
.balance-row { display: flex; justify-content: space-between; align-items: flex-start; }
.card-label  { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700; }
.balance-amount { font-family: 'Syne', sans-serif; font-size: 28px; font-weight: 900; color: var(--text); margin-top: 4px; }
.balance-right  { text-align: right; }
.after-bills    { font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 900; margin-top: 4px; }
.balance-hint   { font-size: 11px; color: var(--muted); margin-top: 2px; }
.balance-tap    { font-size: 11px; color: var(--muted2); margin-top: 8px; text-align: right; }

/* ═══ SAVINGS CARD ════════════════════════════════════════════════════════ */
.savings-card {
  margin: 10px 16px 0;
  background: linear-gradient(135deg, #0d2a1a, #0f1520);
  border: 1px solid #22c55e22; border-radius: 16px; padding: 16px 18px; cursor: pointer;
}
.savings-row    { display: flex; justify-content: space-between; align-items: center; }
.savings-amount { font-family: 'Syne', sans-serif; font-size: 28px; font-weight: 900; color: var(--green); margin-top: 4px; }
.savings-icon   { font-size: 28px; }

/* ═══ INLINE EDIT ═════════════════════════════════════════════════════════ */
.inline-edit {
  margin: 8px 16px 0;
  display: flex; gap: 8px; align-items: center;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: 12px; padding: 10px 14px;
}
.inline-edit-prefix { color: var(--muted); font-size: 16px; font-weight: 700; }
.inline-edit-input  { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 18px; font-weight: 700; font-family: 'DM Sans', sans-serif; }

/* ═══ STATS ROW ═══════════════════════════════════════════════════════════ */
.stats-row { display: flex; gap: 8px; padding: 10px 16px 0; }
.stat-box  { flex: 1; border-radius: 12px; padding: 10px 8px; text-align: center; border: 1px solid; }
.stat-lbl  { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.stat-val  { font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 800; margin-top: 3px; }

/* ═══ ALERTS ══════════════════════════════════════════════════════════════ */
.alert       { margin: 10px 16px 0; border-radius: 12px; padding: 12px 14px; border: 1px solid; }
.alert-title { font-weight: 800; font-size: 13px; }
.alert-sub   { font-size: 12px; margin-top: 4px; color: var(--muted); }
.alert-orange { background: #f9731618; border-color: #f9731655; }
.alert-orange .alert-title { color: var(--orange); }
.alert-red    { background: #ef444418; border-color: #ef444455; }
.alert-red .alert-title { color: var(--red); }

/* ═══ FILTERS ═════════════════════════════════════════════════════════════ */
.filter-row { display: flex; gap: 6px; padding: 10px 16px 4px; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-btn {
  border: 1px solid var(--border); border-radius: 20px; padding: 5px 12px;
  font-size: 11px; font-weight: 700; cursor: pointer; white-space: nowrap; flex-shrink: 0;
  font-family: 'DM Sans', sans-serif; background: var(--surface); color: var(--muted);
  transition: all 0.15s;
}
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ═══ BILL CARDS ══════════════════════════════════════════════════════════ */
.bill-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 13px 14px; margin-bottom: 8px;
  cursor: pointer; transition: border-color 0.15s;
}
.bill-card:active { opacity: 0.8; }
.bill-info  { flex: 1; min-width: 0; }
.bill-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.bill-name  { font-weight: 700; color: var(--text); font-size: 14px; }
.bill-sub   { color: var(--muted); font-size: 12px; margin-top: 3px; }
.bill-amt   { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 15px; color: var(--text); }
.bill-name-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ═══ BADGES ══════════════════════════════════════════════════════════════ */
.badge {
  display: inline-block; border-radius: 6px; padding: 2px 8px;
  font-size: 10px; font-weight: 800; letter-spacing: 1px;
  white-space: nowrap; border: 1px solid;
}
.tag-freq { font-size: 10px; color: var(--muted2); font-weight: 600; }
.tag-var  { font-size: 10px; color: var(--yellow); font-weight: 700; background: #f59e0b18; border-radius: 4px; padding: 1px 6px; }

/* ═══ BUTTONS IN LIST ═════════════════════════════════════════════════════ */
.btn-pay    { border: none; border-radius: 8px; padding: 5px 10px; font-weight: 800; font-size: 11px; cursor: pointer; white-space: nowrap; font-family: 'DM Sans', sans-serif; color: #fff; }
.btn-pay-lg { border: none; border-radius: 12px; padding: 14px; font-weight: 800; font-size: 15px; cursor: pointer; width: 100%; font-family: 'DM Sans', sans-serif; color: #fff; margin-top: 4px; }
.btn-update { border: 1px solid #f59e0b44; border-radius: 6px; padding: 4px 8px; font-weight: 700; font-size: 11px; cursor: pointer; color: var(--yellow); background: #f59e0b18; font-family: 'DM Sans', sans-serif; }

/* ═══ CARDS ═══════════════════════════════════════════════════════════════ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px 16px; margin-bottom: 12px; }
.sec-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700; margin-bottom: 12px; }

/* ═══ DETAIL ══════════════════════════════════════════════════════════════ */
.detail-stats { display: flex; gap: 10px; margin-top: 16px; }
.detail-stat  { flex: 1; background: var(--bg); border-radius: 10px; padding: 12px 8px; text-align: center; }
.detail-stat-lbl { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.detail-stat-val { font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 800; color: var(--text); margin-top: 4px; }
.info-box       { border-radius: 10px; padding: 10px 14px; border: 1px solid; margin-top: 12px; }
.info-box-title { font-weight: 700; font-size: 13px; }
.info-box-sub   { font-size: 12px; margin-top: 4px; color: var(--muted); }

/* ═══ TOGGLE ══════════════════════════════════════════════════════════════ */
.toggle-row   { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.toggle-label { color: #94a3b8; font-size: 14px; flex: 1; padding-right: 12px; }
.toggle       { width: 44px; height: 24px; border-radius: 12px; border: none; cursor: pointer; position: relative; padding: 0; transition: background 0.2s; flex-shrink: 0; }
.toggle-knob  { width: 18px; height: 18px; background: #fff; border-radius: 50%; position: absolute; top: 3px; left: 3px; transition: transform 0.2s; pointer-events: none; }

/* ═══ FORM ════════════════════════════════════════════════════════════════ */
.form-input {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; color: var(--text);
  font-size: 14px; margin-bottom: 10px; outline: none;
  font-family: 'DM Sans', sans-serif; transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--accent); }
textarea.form-input { min-height: 80px; resize: vertical; }
select.form-input { appearance: none; }

/* ═══ MODALS ══════════════════════════════════════════════════════════════ */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.8); z-index: 300;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box   { background: var(--surface); border: 1px solid var(--border2); border-radius: 20px; padding: 24px; width: 310px; }
.modal-title { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 18px; margin-bottom: 6px; }
.modal-sub   { color: var(--muted); font-size: 13px; margin-bottom: 16px; line-height: 1.5; }
.modal-btns  { }
.amt-input-row { display: flex; align-items: center; gap: 8px; }
.amt-prefix    { color: var(--muted); font-size: 20px; font-weight: 700; }

/* ═══ EMPTY ═══════════════════════════════════════════════════════════════ */
.empty { text-align: center; color: var(--muted); margin-top: 60px; font-size: 15px; padding: 0 24px; line-height: 1.7; }
