:root {
  --pine: #1F4D3D;
  --pine-light: #2E6B54;
  --gold: #C9962B;
  --rust: #A8452E;
  --bg: #F1F3EF;
  --card: #FFFFFF;
  --ink: #1B1E1C;
  --muted: #6E7570;
  --line: #E4E7E2;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--ink); max-width: 480px; margin: 0 auto; min-height: 100vh; }
h1, h2, h3, .display { font-family: 'Space Grotesk', sans-serif; }
.mono { font-family: 'IBM Plex Mono', monospace; font-weight: 600; }
.hidden { display: none !important; }

.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card { background: var(--card); border-radius: 20px; padding: 36px 26px; width: 100%; max-width: 380px; box-shadow: 0 8px 30px rgba(31,77,61,0.08); border: 1px solid var(--line); }
h1.display { color: var(--pine); font-size: 30px; font-weight: 700; margin-bottom: 4px; }
.logo-mark { width: 72px; height: 72px; border-radius: 18px; display: block; margin: 0 auto 14px; }
h2.display { font-size: 21px; font-weight: 600; }
.subtitle { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; margin-top: 4px; line-height: 1.4; }

#auth-tabs { display: flex; margin-bottom: 18px; border-radius: 30px; overflow: hidden; background: var(--bg); padding: 3px; }
.tab-btn { flex: 1; padding: 9px; border: none; background: none; cursor: pointer; font-weight: 600; border-radius: 26px; font-size: 13px; color: var(--muted); }
.tab-btn.active { background: var(--pine); color: #fff; }

.auth-form { display: flex; flex-direction: column; gap: 12px; }
input[type=email], input[type=password], input[type=text], input[type=number], input[type=date] {
  padding: 13px 14px; border: 1.5px solid var(--line); border-radius: 12px; font-size: 16px; font-family: 'Inter', sans-serif;
}
select { padding: 13px 14px; border: 1.5px solid var(--line); border-radius: 12px; font-size: 16px; font-family: 'Inter', sans-serif; background: #fff; }
button { cursor: pointer; }
.primary-btn { background: var(--pine); color: #fff; border: none; padding: 14px; border-radius: 12px; font-weight: 600; font-size: 15px; width: 100%; font-family: 'Inter', sans-serif; }
.secondary-btn { background: transparent; color: var(--pine); border: 1.5px solid var(--pine); padding: 14px; border-radius: 12px; font-weight: 600; margin-top: 10px; width: 100%; font-family: 'Inter', sans-serif; }
.error { color: var(--rust); font-size: 13px; min-height: 16px; }

.invite-code-box { background: #EBF2EE; border: 1.5px dashed var(--pine); border-radius: 14px; padding: 22px; text-align: center; font-size: 28px; font-weight: 600; letter-spacing: 5px; color: var(--pine); margin: 18px 0; font-family: 'IBM Plex Mono', monospace; }

#main-screen { display: block; padding-bottom: 78px; }
#main-header { padding: calc(22px + env(safe-area-inset-top)) 20px 46px; background: var(--pine); color: #fff; border-radius: 0 0 24px 24px; position: relative; }
.header-top { display: flex; justify-content: space-between; align-items: flex-start; }
#house-name-display { font-weight: 700; font-size: 19px; font-family: 'Space Grotesk', sans-serif; }
.role-badge { font-size: 10.5px; background: rgba(255,255,255,0.18); padding: 3px 9px; border-radius: 20px; margin-top: 4px; display: inline-block; }
#balance-summary { font-size: 22px; font-weight: 700; margin-top: 14px; font-family: 'IBM Plex Mono', monospace; }
#balance-label { font-size: 12px; opacity: 0.75; margin-top: 2px; }
.icon-btn { background: rgba(255,255,255,0.15); border: none; color: #fff; font-size: 16px; width: 38px; height: 38px; border-radius: 50%; position: relative; display: flex; align-items: center; justify-content: center; }
.notif-dot { position: absolute; top: 4px; right: 6px; width: 8px; height: 8px; background: var(--rust); border-radius: 50%; }

#tab-content { padding: 18px 18px 10px; }
h3.section-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin: 18px 0 10px; font-weight: 600; }
h3.section-label:first-child { margin-top: 4px; }
.premium-tag { text-transform: none; font-weight: 500; background: #F0EBD8; color: var(--gold); padding: 2px 8px; border-radius: 10px; font-size: 10px; }

.list-item { background: var(--card); border-radius: 14px; padding: 15px; margin-bottom: 9px; display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--line); gap: 10px; }
.desc { font-weight: 600; font-size: 14px; }
.meta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.amount { font-size: 15px; }
.amount.positive { color: var(--pine-light); }
.amount.negative { color: var(--rust); }
.balance-row { display: flex; justify-content: space-between; padding: 9px 2px; font-size: 14px; border-bottom: 1px solid var(--line); }
.balance-row:last-child { border-bottom: none; }
.restricted-note { display: flex; align-items: center; gap: 6px; background: #FBF3E4; color: #8a6a1f; font-size: 12px; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.checkbox { width: 21px; height: 21px; border-radius: 7px; border: 1.5px solid var(--line); flex-shrink: 0; cursor: pointer; appearance: none; }
.checkbox:checked { background: var(--pine); border-color: var(--pine); }
.done { text-decoration: line-through; opacity: 0.45; }

#bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; background: var(--card); border-top: 1px solid var(--line); display: flex; padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); }
.nav-btn { flex: 1; border: none; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; font-size: 10.5px; font-weight: 600; color: var(--muted); }
.nav-btn.active { color: var(--pine); }
.nav-icon { font-size: 19px; padding: 5px 14px; border-radius: 14px; transition: background-color .2s; }
.nav-icon svg { width: 21px; height: 21px; display: block; }
.nav-btn.active .nav-icon { background: #EBF2EE; }
.nav-btn.active .nav-icon svg { fill-opacity: 0.35 !important; }

.icon-btn svg { display: block; }

.member-chip { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 9px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--pine); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; font-family: 'Space Grotesk', sans-serif; flex-shrink: 0; }
.role-tag { font-size: 10.5px; padding: 2px 8px; border-radius: 20px; font-weight: 600; margin-left: auto; border: none; background: var(--bg); color: var(--muted); }
.role-tag.owner { background: #EBF2EE; color: var(--pine); }
.role-tag.adult { background: #F0EBD8; color: var(--gold); }
.role-tag.restricted { background: #F5E9E5; color: var(--rust); }

.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 2px; font-size: 14px; border-bottom: 1px solid var(--line); }
.toggle-row input[type=checkbox] { width: 40px; height: 22px; appearance: none; background: var(--line); border-radius: 20px; position: relative; cursor: pointer; }
.toggle-row input[type=checkbox]:checked { background: var(--pine); }
.toggle-row input[type=checkbox]::before { content:''; position:absolute; width:18px; height:18px; border-radius:50%; background:#fff; top:2px; left:2px; transition:.2s; }
.toggle-row input[type=checkbox]:checked::before { left: 20px; }

.fab { position: fixed; bottom: 90px; right: max(20px, calc(50vw - 240px + 20px)); width: 56px; height: 56px; border-radius: 50%; background: var(--pine); color: #fff; font-size: 26px; border: none; box-shadow: 0 4px 12px rgba(0,0,0,0.25); }

#modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: flex-end; justify-content: center; z-index: 100; }
#modal-content { background: #fff; width: 100%; max-width: 480px; border-radius: 20px 20px 0 0; padding: 24px; max-height: 85vh; overflow-y: auto; }
#modal-content form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
#modal-content h3 { font-family: 'Space Grotesk', sans-serif; }

.day-cell { flex: 1; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 2px; cursor: pointer; }
.day-cell.selected { background: var(--pine); border-color: var(--pine); color: #fff; }
.day-cell .dow { font-size: 10px; color: var(--muted); }
.day-cell.selected .dow { color: rgba(255,255,255,0.8); }
.day-cell .dnum { font-weight: 700; font-size: 13px; }
.day-cell .dicons { font-size: 13px; margin-top: 2px; }

.recurrence-options { display: flex; gap: 6px; flex-wrap: wrap; }
.recurrence-chip { font-size: 12px; background: var(--bg); color: var(--muted); padding: 7px 12px; border-radius: 20px; border: 1.5px solid transparent; cursor: pointer; }
.recurrence-chip.selected { background: #EBF2EE; color: var(--pine); border-color: var(--pine); font-weight: 600; }

.reaction-row { display: flex; gap: 8px; margin-top: 4px; }
.reaction-btn { font-size: 12px; background: var(--card); border: 1px solid var(--line); padding: 5px 10px; border-radius: 20px; }

.category-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; background: var(--bg); padding: 4px 10px; border-radius: 20px; margin-right: 4px; cursor: pointer; border: 1.5px solid transparent; }
.category-pill.selected { background: #EBF2EE; border-color: var(--pine); color: var(--pine); font-weight: 600; }

.ad-banner { position: absolute; bottom: 12px; right: 16px; background: rgba(255,255,255,0.95); border-radius: 10px; padding: 6px 10px; max-width: 170px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); z-index: 5; cursor: pointer; }
.ad-label { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 2px; }
.ad-content { font-size: 10.5px; color: var(--ink); line-height: 1.25; }

.ios-install-banner { position: fixed; bottom: 0; left: 0; right: 0; background: var(--pine); color: #fff; padding: 14px 18px; display: flex; align-items: center; gap: 12px; z-index: 200; }
.ios-install-banner p { font-size: 13px; flex: 1; margin: 0; }
.ios-install-banner button { background: rgba(255,255,255,0.2); border: none; color: #fff; padding: 8px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; }

.activity-log-collapsed .list-item:nth-child(n+5) { display: none; }
.activity-log-collapsed.expanded .list-item:nth-child(n+5) { display: flex; }
.history-collapsed .list-item:nth-child(n+5) { display: none; }
.history-collapsed.expanded .list-item:nth-child(n+5) { display: flex; }
