:root {
  --cream: #F6F4EC;
  --accent: #2f6b4f;
  --text: #1e3628;
  --text-55: rgba(30, 54, 40, 0.55);
  --text-50: rgba(30, 54, 40, 0.5);
  --text-45: rgba(30, 54, 40, 0.45);
  --text-40: rgba(30, 54, 40, 0.4);
  --text-08: rgba(30, 54, 40, 0.08);
  --text-10: rgba(30, 54, 40, 0.1);
  --text-14: rgba(30, 54, 40, 0.14);
  --income-top: #12180f;
  --income-body: #1f4a35;
  --income-label: #9cc9ab;
  --danger: #b23a3a;
  --white: #fff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--cream);
  font-family: 'Manrope', system-ui, sans-serif;
  color: var(--text);
}

#app { min-height: 100%; }

button, input, textarea, select { font-family: inherit; }

a { color: inherit; text-decoration: none; }

.clickable { cursor: pointer; }
.clickable:hover { filter: brightness(0.97); }

/* ---------- Auth screens ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 28px;
  padding: 36px 32px;
}
.auth-title { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.auth-sub { font-size: 13px; font-weight: 600; color: var(--text-50); margin-bottom: 24px; }
.field { margin-bottom: 14px; }
.field-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-45); margin-bottom: 6px; display: block;
}
.field input, .field textarea {
  width: 100%; background: var(--cream); border: none; border-radius: 12px;
  padding: 12px 14px; font-size: 14px; font-weight: 700; color: var(--text);
}
.field textarea { font-weight: 600; resize: vertical; min-height: 96px; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); }
.btn-primary {
  background: var(--accent); color: #fff; border: none; border-radius: 14px;
  padding: 14px; font-size: 14px; font-weight: 800; width: 100%; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.auth-switch { text-align: center; font-size: 13px; font-weight: 600; color: var(--text-50); margin-top: 18px; }
.auth-switch a { color: var(--accent); font-weight: 800; cursor: pointer; }
.auth-error {
  background: rgba(178, 58, 58, 0.1); color: var(--danger); font-size: 13px; font-weight: 700;
  border-radius: 10px; padding: 10px 12px; margin-bottom: 14px;
}

/* ---------- App shell ---------- */
.shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 220px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--text-08);
  display: flex; flex-direction: column; padding: 24px 16px;
}
.sidebar-title { font-size: 17px; font-weight: 800; color: var(--text); padding: 0 8px; margin-bottom: 28px; }
.navitem {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px;
  margin-bottom: 2px; font-size: 14px; font-weight: 700;
}
.navitem:hover { background: rgba(30, 54, 40, 0.06); }
.navitem.active { background: #e4ecdf; color: var(--accent); }
.navitem:not(.active) { color: var(--text-40); }
.navitem .dot { width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.sidebar-spacer { flex: 1; }
.sidebar-add {
  background: var(--accent); color: #fff; text-align: center; padding: 12px; border-radius: 12px;
  font-size: 13px; font-weight: 800; cursor: pointer;
}

.main { flex: 1; overflow-y: auto; padding: 36px 40px; }
.main.no-scroll { overflow: hidden; display: flex; flex-direction: column; padding: 0; }

/* ---------- Home ---------- */
.greeting { font-size: 24px; font-weight: 800; margin-bottom: 24px; }
.home-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 32px; }
.hero-card { background: var(--accent); border-radius: 22px; padding: 22px; color: #fff; }
.hero-donut {
  width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; margin-bottom: 14px;
}
.hero-donut-inner {
  width: 44px; height: 44px; border-radius: 50%; background: var(--accent); display: flex;
  align-items: center; justify-content: center; font-size: 12px; font-weight: 800;
}
.eyebrow { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.75; margin-bottom: 2px; }
.hero-amount { font-size: 22px; font-weight: 800; }
.hero-sub { font-size: 12px; opacity: 0.85; }

.summary-card { background: #fff; border-radius: 22px; padding: 22px; }
.summary-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-45); margin-bottom: 16px; }
.summary-row { display: flex; gap: 12px; margin-bottom: 16px; }
.summary-item-label { font-size: 11px; font-weight: 700; color: var(--text-45); margin-bottom: 4px; }
.summary-item-value { font-size: 18px; font-weight: 800; }
.summary-link { font-size: 13px; font-weight: 700; color: var(--accent); cursor: pointer; }

.section-title { font-size: 16px; font-weight: 800; margin-bottom: 14px; margin-top: 4px; }
.top-cats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 32px; }
.top-cat-card { border-radius: 18px; padding: 16px; cursor: pointer; }
.top-cat-icon {
  width: 30px; height: 30px; border-radius: 9px; color: #fff; font-weight: 800; font-size: 12px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 10px;
}
.top-cat-name { font-size: 13px; font-weight: 800; margin-bottom: 6px; }
.top-cat-nums { font-size: 11px; font-weight: 700; color: var(--text-50); margin-bottom: 8px; }

.bar-track { height: 5px; border-radius: 3px; background: var(--text-10); overflow: hidden; }
.bar-fill { height: 100%; }

.upcoming-card { background: #fff; border-radius: 22px; padding: 22px; max-width: 480px; }
.upcoming-empty { font-size: 13px; font-weight: 600; color: var(--text-45); margin-bottom: 14px; }
.upcoming-add { font-size: 13px; font-weight: 700; color: var(--accent); }

/* ---------- Family / Business budget screen ---------- */
.budget-header {
  flex-shrink: 0; padding: 36px 40px 20px; display: flex; align-items: center; justify-content: space-between;
}
.budget-month { font-size: 26px; font-weight: 800; }
.budget-sub { font-size: 13px; font-weight: 600; color: var(--text-50); }
.header-right { display: flex; align-items: center; gap: 14px; }
.month-nav { display: flex; gap: 6px; }
.month-btn {
  width: 32px; height: 32px; border-radius: 50%; background: var(--text-08); display: flex;
  align-items: center; justify-content: center; font-size: 16px; font-weight: 800; cursor: pointer; border: none;
}
.month-btn:disabled { opacity: 0.35; cursor: default; }
.mode-toggle { display: flex; background: var(--text-08); border-radius: 12px; padding: 4px; gap: 4px; }
.mode-btn {
  padding: 9px 18px; border-radius: 9px; font-size: 13px; font-weight: 700; cursor: pointer; border: none; background: none;
}

.budget-body { flex: 1; overflow-y: auto; padding: 0 40px 40px; }

.income-card { border-radius: 18px; overflow: hidden; margin-bottom: 22px; }
.income-top { background: var(--income-top); padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; }
.income-top-title { font-size: 14px; font-weight: 800; color: #fff; }
.income-body-row { background: var(--income-body); padding: 16px 18px; display: flex; flex-wrap: wrap; gap: 24px; align-items: baseline; }
.income-item { display: flex; gap: 8px; align-items: baseline; }
.income-item-name { font-size: 13px; font-weight: 700; color: var(--income-label); }
.income-item-amount { font-size: 13px; font-weight: 800; color: #fff; }
.income-add { font-size: 12px; font-weight: 700; color: var(--income-label); cursor: pointer; }
.income-balance { font-size: 13px; font-weight: 700; color: var(--income-label); margin-left: auto; }
.income-balance span { color: #fff; }

.groups-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.group-card { border-radius: 18px; }
.group-header { padding: 12px 16px; display: flex; justify-content: space-between; color: #fff; border-radius: 18px 18px 0 0; }
.group-header-name { font-size: 14px; font-weight: 800; }
.group-header-total { font-size: 14px; font-weight: 800; }
.group-body { padding: 16px; display: flex; flex-direction: column; gap: 13px; border-radius: 0 0 18px 18px; }
.line-row { cursor: pointer; }
.line-row-top { display: flex; justify-content: space-between; margin-bottom: 6px; }
.line-row-name { font-size: 13px; font-weight: 700; color: var(--text); }
.line-row-amount { font-size: 13px; font-weight: 700; color: var(--text); }
.line-track { height: 5px; border-radius: 3px; background: rgba(30, 54, 40, 0.14); overflow: hidden; }
.add-line-link { font-size: 12px; font-weight: 700; cursor: pointer; margin-top: 2px; }
.add-group-card {
  border: 2px dashed var(--text-10); border-radius: 18px; display: flex; align-items: center; justify-content: center;
  min-height: 80px; font-size: 13px; font-weight: 700; color: var(--text-45); cursor: pointer;
}
.add-group-card:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Line detail (transactions) ---------- */
.detail-back { font-size: 13px; font-weight: 700; color: var(--text-50); margin-bottom: 16px; cursor: pointer; display: inline-block; }
.detail-title { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.detail-sub { font-size: 13px; font-weight: 700; color: var(--text-50); margin-bottom: 20px; }
.txn-list { max-width: 560px; display: flex; flex-direction: column; gap: 10px; }
.txn-row { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 16px; padding: 14px 16px; }
.txn-avatar {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 800; flex-shrink: 0;
}
.txn-note { font-size: 14px; font-weight: 800; }
.txn-meta { font-size: 12px; font-weight: 600; color: var(--text-50); }
.txn-amount { font-size: 14px; font-weight: 800; }
.txn-delete {
  font-size: 11px; font-weight: 700; color: var(--text-40); cursor: pointer; padding: 4px 8px; flex-shrink: 0;
}
.txn-delete:hover { color: var(--danger); }
.txn-empty { font-size: 13px; font-weight: 600; color: var(--text-45); }

/* ---------- Add Transaction ---------- */
.add-txn-wrap { max-width: 480px; }
.add-amount-input {
  width: 100%; border: none; background: none; font-size: 48px; font-weight: 800; color: var(--text);
  text-align: center; margin: 12px 0 4px;
}
.add-amount-input:focus { outline: none; }
.add-amount-sub { text-align: center; font-size: 13px; font-weight: 600; color: var(--text-50); margin-bottom: 28px; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip {
  padding: 10px 16px; border-radius: 14px; font-size: 13px; font-weight: 700; cursor: pointer;
  border: 2px solid transparent; background: var(--cream);
}
.chip.active { border-color: currentColor; }

/* ---------- Profile / Settings ---------- */
.profile-wrap { max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.card-link {
  padding: 16px; border-radius: 14px; display: flex; align-items: center; justify-content: space-between; cursor: pointer;
}
.card-link.accent { background: var(--accent); color: #fff; }
.card-link.outline { border: 1.5px solid var(--text-10); }
.card-link-title { font-size: 14px; font-weight: 800; }
.card-link-sub { font-size: 12px; opacity: 0.8; }
.card-link.outline .card-link-sub { color: var(--text-45); opacity: 1; }
.members-list { display: flex; flex-direction: column; gap: 8px; }
.member-row { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 10px 12px; }
.member-remove { font-size: 11px; font-weight: 700; color: var(--text-40); cursor: pointer; }
.member-remove:hover { color: var(--danger); }
.logout-link { text-align: center; font-size: 13px; font-weight: 700; color: var(--danger); margin-top: 8px; cursor: pointer; }

/* ---------- Financial Accounts ---------- */
.fa-list { display: flex; flex-direction: column; gap: 10px; max-width: 560px; margin-bottom: 24px; }
.fa-row { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 16px; padding: 14px 16px; }
.owner-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.fa-name { font-size: 14px; font-weight: 800; }
.fa-meta { font-size: 12px; font-weight: 600; color: var(--text-50); }
.fa-owner { font-size: 12px; font-weight: 700; color: var(--text-50); margin-left: auto; }
.fa-remove { font-size: 11px; font-weight: 700; color: var(--text-40); cursor: pointer; margin-left: 8px; }
.fa-remove:hover { color: var(--danger); }
.fa-form { max-width: 420px; background: #fff; border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.fa-form-row { display: flex; gap: 10px; }
.fa-form-row .field { flex: 1; margin-bottom: 0; }
.owner-picker { display: flex; gap: 8px; }
.owner-chip { padding: 9px 14px; border-radius: 12px; font-size: 12px; font-weight: 700; cursor: pointer; background: var(--cream); border: 2px solid transparent; }
.owner-chip.active { border-color: var(--accent); color: var(--accent); }

/* ---------- Report Issue ---------- */
.report-wrap { max-width: 480px; }
.report-success { font-size: 14px; font-weight: 700; color: var(--accent); background: #e4ecdf; border-radius: 14px; padding: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff;
  padding: 12px 20px; border-radius: 12px; font-size: 13px; font-weight: 700; z-index: 100;
}

@media (max-width: 900px) {
  .home-grid { grid-template-columns: 1fr; }
  .top-cats-grid { grid-template-columns: repeat(2, 1fr); }
  .groups-grid { grid-template-columns: 1fr; }
  .budget-header { flex-direction: column; align-items: flex-start; gap: 14px; }
}
