: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 26px; 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 {
  background: var(--card); border-radius: 14px; border: 1px solid var(--line);
  margin: 12px 18px 0; padding: 6px;
  height: 116px; /* 100px do anúncio + espaço para a etiqueta "Ad" */
  box-shadow: 0 2px 8px rgba(0,0,0,0.06); cursor: pointer;
  overflow: hidden !important; display: flex; flex-direction: column;
}
.ad-label { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; display: block; padding: 2px 6px 4px; }
.ad-banner ins.adsbygoogle { max-width: 100% !important; max-height: 100px !important; overflow: hidden !important; }

#ios-install-overlay {
  position: fixed; inset: 0; z-index: 9999; background: rgba(22, 22, 22, 0.92);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.ios-install-card {
  background: #fff; border-radius: 22px; padding: 34px 26px; max-width: 340px; width: 100%;
  text-align: center; box-sizing: border-box; box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.ios-install-icon { width: 68px; height: 68px; border-radius: 18px; margin-bottom: 16px; box-shadow: 0 6px 16px rgba(31,77,61,0.25); }
.ios-install-card h2 { font-size: 19px; color: var(--pine); margin: 0 0 8px; }
.ios-install-card p { font-size: 13.5px; color: var(--muted); margin: 0 0 18px; line-height: 1.4; }
.ios-install-steps { list-style: none; text-align: left; margin: 0; color: #1B1E1C; counter-reset: step; }
.ios-install-steps li { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; font-size: 14px; line-height: 1.4; counter-increment: step; }
.ios-install-steps li::before {
  content: counter(step); flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  background: var(--pine); color: #fff; font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 12.5px;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.ios-share-icon { font-weight: 700; }
.ios-install-video { width: 100%; max-height: 260px; border-radius: 12px; margin-bottom: 16px; background: #000; display: block; }

#android-install-btn {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: var(--pine); color: #fff; border: none; padding: 12px 20px; border-radius: 30px;
  font-size: 14px; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,0.25); cursor: pointer;
}
#android-install-btn.hidden { display: none; }

.streak-card {
  text-align: center; background: linear-gradient(165deg, var(--pine) 0%, var(--pine-light) 100%);
  border-radius: 18px; padding: 22px 16px; margin-bottom: 14px; color: #fff;
  box-shadow: 0 6px 20px rgba(31,77,61,0.18);
}
.streak-number { font-size: 40px; font-weight: 700; font-family: 'Space Grotesk', sans-serif; line-height: 1; display: flex; align-items: center; justify-content: center; gap: 6px; }
.streak-flame { font-size: 30px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15)); }
.streak-caption { font-size: 12.5px; opacity: 0.85; margin-top: 4px; }
.badges-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.badge-chip { width: 62px; text-align: center; }
.badge-medal {
  width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin: 0 auto 4px; background: rgba(255,255,255,0.14); border: 1.5px solid rgba(255,255,255,0.25);
  transition: transform .15s;
}
.badge-chip.earned .badge-medal { background: linear-gradient(160deg, var(--gold), #E5B347); border-color: rgba(255,255,255,0.5); box-shadow: 0 3px 10px rgba(0,0,0,0.2); }
.badge-chip:not(.earned) .badge-medal { opacity: 0.35; filter: grayscale(1); }
.badge-chip-label { font-size: 8.5px; line-height: 1.25; opacity: 0.9; }
.badge-chip:not(.earned) .badge-chip-label { opacity: 0.45; }

.summary-highlight {
  text-align: center; background: #EBF2EE; border-radius: 16px; padding: 18px; margin: 16px 0;
}
.summary-highlight-label { font-size: 12px; color: var(--pine); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.summary-highlight-value { font-size: 34px; font-weight: 700; color: var(--pine); font-family: 'IBM Plex Mono', monospace; margin: 4px 0; }
.trend-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.trend-chip.down { background: #E3F0E9; color: var(--pine-light); }
.trend-chip.up { background: #F5E9E5; color: var(--rust); }
.mvp-line { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink); background: var(--bg); border-radius: 10px; padding: 10px 12px; margin-top: 10px; }
.mvp-line .medal { font-size: 18px; }

.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; }

