/* Budget Builder — warm, mobile-first, one-handed. */
:root {
  --bg: #F6F4F1;
  --card: #FFFFFF;
  --ink: #26332C;
  --muted: #6E7A72;
  --line: #E7E2DB;
  --green: #2E7D57;
  --green-dark: #22603F;
  --green-soft: #E4F0E9;
  --amber: #A8731F;
  --amber-soft: #F7ECD8;
  --red: #B4423A;
  --red-soft: #F8E4E2;
  --radius: 16px;
  --nav-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.45;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom, 0px));
}

.hidden { display: none !important; }

h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; margin-bottom: 8px; }

button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
input, select {
  font: inherit;
  width: 100%;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
}
input:focus, select:focus { outline: none; border-color: var(--green); }
label { display: block; font-weight: 600; margin: 14px 0 6px; }

/* ---------- shared bits ---------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(38, 51, 44, 0.07);
}

.btn {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  background: var(--green);
  color: #fff;
}
.btn:active { background: var(--green-dark); }
.btn.secondary { background: var(--green-soft); color: var(--green-dark); }
.btn.ghost { background: none; color: var(--green-dark); text-decoration: underline; min-height: 44px; font-weight: 600; }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.small { display: inline-block; width: auto; min-height: 40px; padding: 8px 14px; font-size: 0.95rem; }
.btn:disabled { opacity: 0.5; }

.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; min-width: 0; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.muted { color: var(--muted); font-size: 0.9rem; }
.big-money { font-size: 2rem; font-weight: 800; letter-spacing: -0.5px; }
.money { font-variant-numeric: tabular-nums; font-weight: 700; }

.header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.icon-btn {
  min-width: 44px; min-height: 44px; border-radius: 12px;
  font-size: 1.3rem; display: flex; align-items: center; justify-content: center;
  background: var(--card); box-shadow: 0 1px 3px rgba(38,51,44,0.07);
}

/* ---------- progress bars ---------- */

.bar { height: 12px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar > div { height: 100%; border-radius: 6px; background: var(--green); transition: width 0.3s; }
.bar.warn > div { background: var(--amber); }
.bar.over > div { background: var(--red); }
.bar.big { height: 18px; border-radius: 9px; }

.cat-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.cat-row:last-child { border-bottom: none; }
.cat-row .bar { margin-top: 8px; }

/* ---------- left-to-assign pill ---------- */

.lta {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  font-weight: 700;
  font-size: 1.05rem;
  display: flex; justify-content: space-between; align-items: center;
}
.lta.ok { background: var(--green-soft); color: var(--green-dark); }
.lta.warn { background: var(--amber-soft); color: var(--amber); }
.lta.over { background: var(--red-soft); color: var(--red); }

/* ---------- bottom nav ---------- */

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; align-items: center;
  max-width: 480px; margin: 0 auto;
  z-index: 40;
}
.nav-btn {
  flex: 1; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 0.72rem; font-weight: 600; color: var(--muted);
}
.nav-btn.active { color: var(--green-dark); }
.nav-ico { font-size: 1.35rem; line-height: 1; }
.fab {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--green); color: #fff;
  font-size: 2.2rem; font-weight: 700; line-height: 1;
  margin-top: -26px;
  box-shadow: 0 4px 12px rgba(46, 125, 87, 0.45);
  flex: none;
  display: flex; align-items: center; justify-content: center;
}
.fab:active { background: var(--green-dark); }

/* ---------- modals ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(38, 51, 44, 0.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--card);
  width: 100%; max-width: 480px;
  border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  max-height: 88vh; overflow-y: auto;
  animation: rise 0.18s ease-out;
}
@keyframes rise { from { transform: translateY(40px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet h2 { margin-bottom: 14px; }
.sheet .btn { margin-top: 14px; }

/* ---------- keypad ---------- */

.pad-amount {
  text-align: center; font-size: 2.6rem; font-weight: 800;
  padding: 10px 0 18px; letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pad button {
  min-height: 58px; font-size: 1.5rem; font-weight: 700;
  background: var(--bg); border-radius: 14px;
}
.pad button:active { background: var(--green-soft); }

/* ---------- category picker grid ---------- */

.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.cat-grid button {
  min-height: 58px; padding: 10px;
  background: var(--bg); border-radius: 14px;
  font-weight: 600; font-size: 0.98rem;
}
.cat-grid button:active { background: var(--green-soft); }

/* ---------- lists ---------- */

.tx-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.tx-row:last-child { border-bottom: none; }
.tx-main { flex: 1; min-width: 0; }
.tx-main .note { color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.del-btn { color: var(--muted); font-size: 1.1rem; min-width: 40px; min-height: 40px; }

/* ---------- debts ---------- */

.debt-card { border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; background: var(--card); }
.debt-card.attack { border-color: var(--green); background: var(--green-soft); }
.attack-badge {
  display: inline-block; background: var(--green); color: #fff;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em;
  padding: 3px 10px; border-radius: 999px; margin-bottom: 6px; text-transform: uppercase;
}
.debt-card.paid { opacity: 0.75; }
.debt-card.paid .debt-name { text-decoration: line-through; }
.paid-badge {
  display: inline-block; background: var(--green-soft); color: var(--green-dark);
  font-size: 0.72rem; font-weight: 800; padding: 3px 10px; border-radius: 999px;
}
.debt-name { font-weight: 700; font-size: 1.05rem; }

/* ---------- celebration ---------- */

.celebrate {
  background: linear-gradient(135deg, var(--green) 0%, #3f9e70 60%, #59b384 100%);
  color: #fff; border-radius: var(--radius);
  padding: 22px 16px; text-align: center; margin-bottom: 14px;
  animation: glow 1.6s ease-in-out infinite alternate;
}
.celebrate h2 { color: #fff; }
@keyframes glow {
  from { box-shadow: 0 0 0 rgba(46, 125, 87, 0.0); }
  to { box-shadow: 0 0 24px rgba(46, 125, 87, 0.55); }
}

/* ---------- money coach ---------- */

.coach-list { padding-left: 20px; }
.coach-list li { margin: 6px 0; }
button.chip { cursor: pointer; border: 1px dashed transparent; }
button.chip:active { border-color: var(--green-dark); }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 999px;
  font-weight: 600; font-size: 0.95rem;
  opacity: 0; pointer-events: none; transition: all 0.25s;
  z-index: 60; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); }

/* ---------- login / setup ---------- */

.auth-wrap { padding-top: 10vh; max-width: 360px; margin: 0 auto; }
.logo {
  width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 16px; display: block;
}
.auth-wrap h1 { text-align: center; margin-bottom: 4px; }
.auth-sub { text-align: center; color: var(--muted); margin-bottom: 24px; }

.steps { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.steps span { width: 34px; height: 6px; border-radius: 3px; background: var(--line); }
.steps span.on { background: var(--green); }

.point-down { text-align: center; font-size: 2.4rem; color: var(--green); animation: bounce 1s infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(10px); } }

/* ---------- admin ---------- */

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat .n { font-size: 1.8rem; font-weight: 800; color: var(--green-dark); }
.user-card { border-bottom: 1px solid var(--line); padding: 12px 0; }
.user-card:last-child { border-bottom: none; }
.chip { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); }
.chip.off { background: var(--red-soft); color: var(--red); }
.chip.role { background: var(--amber-soft); color: var(--amber); }

@media (min-width: 480px) {
  body { background: #EEEAE4; }
  #app, .bottom-nav { box-shadow: 0 0 30px rgba(38,51,44,0.08); background-clip: padding-box; }
  #app { background: var(--bg); min-height: 100vh; }
}
