/* Por Eles — visual mobile-first */
:root {
  --bg: #f7f3ec;
  --card: #ffffff;
  --ink: #1f2b2a;
  --muted: #6b7774;
  --line: #e9e2d6;
  --primary: #2c6b62;
  --primary-ink: #ffffff;
  --primary-soft: #e3efec;
  --accent: #e8a23d;
  --accent-soft: #fbf0dc;
  --danger: #b9443a;
  --danger-soft: #f8e6e3;
  --ok: #2f7d4f;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(31, 43, 42, .04), 0 6px 20px rgba(31, 43, 42, .05);
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: .4rem 0; }
a { color: var(--primary); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.fine { color: var(--muted); font-size: .8rem; text-align: center; margin: 1rem 0; }
.hint { font-size: .85rem; color: var(--muted); text-align: center; margin-top: .8rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.error-text { color: var(--danger); font-size: .9rem; margin: .3rem 0; }
.ok-text { color: var(--ok); }
.danger-text { color: var(--danger) !important; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; gap: .5rem; }
.row.gap { gap: .5rem; flex-wrap: wrap; }
.stack { display: grid; gap: .6rem; }
.center { display: block; margin: 1rem auto; }

/* ---------- Estrutura ---------- */
.screen { max-width: 560px; margin: 0 auto; padding: 1rem 1rem 2rem; }
.screen.with-nav { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 2rem); }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(.7rem + var(--safe-t)) 1rem .7rem;
  background: rgba(247, 243, 236, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .4rem; font-weight: 700; color: var(--primary); }
.brand-icon { width: 20px; height: 20px; fill: var(--accent); stroke: var(--accent); }
.family-name { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.demo-banner { background: var(--accent); color: #3b2a0c; text-align: center; font-size: .8rem; font-weight: 600; padding: calc(.35rem + var(--safe-t)) .5rem .35rem; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .72rem; font-weight: 500; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav .icon { width: 24px; height: 24px; }
.bottom-nav .nav-add .nav-icon { background: var(--primary); color: #fff; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; box-shadow: 0 4px 12px rgba(44, 107, 98, .35); margin-top: -12px; }
.bottom-nav .nav-add.active .nav-icon { background: var(--accent); }

.splash { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 1.2rem; }

/* ---------- Componentes ---------- */
.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.icon.tiny { width: 14px; height: 14px; color: var(--muted); }
.logo-mark { width: 56px; height: 56px; border-radius: 18px; background: var(--primary); display: grid; place-items: center; }
.logo-mark .icon { width: 30px; height: 30px; fill: var(--accent); stroke: var(--accent); }
.logo-mark.big { width: 72px; height: 72px; border-radius: 22px; margin: 0 auto .8rem; }
.logo-mark.big .icon { width: 38px; height: 38px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; margin: 0 0 1rem; border: 1px solid rgba(233, 226, 214, .6); }
.card.flush { padding: .2rem 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .7rem; font-weight: 700; color: var(--muted); margin-bottom: .4rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin: 1.2rem 0 .8rem; }
.section-head h1, .section-head h2 { margin: 0; }
.back-link { display: inline-flex; align-items: center; gap: .2rem; font-weight: 600; margin: .2rem 0 .8rem; }
.divider { text-align: center; color: var(--muted); margin: .2rem 0 1rem; font-size: .85rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 48px; padding: 0 1.2rem; border-radius: 14px; border: 0;
  font: inherit; font-weight: 600; cursor: pointer; text-align: center;
  transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 .9rem; font-size: .88rem; border-radius: 11px; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.secondary { background: var(--primary-soft); color: var(--primary); }
.btn.ghost { background: transparent; color: var(--primary); border: 1.5px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-ghost { background: transparent; color: var(--danger); border: 1.5px solid var(--danger-soft); margin-top: .5rem; }
.link { background: none; border: 0; padding: .2rem; font: inherit; color: var(--primary); font-weight: 600; cursor: pointer; }
.file-btn { cursor: pointer; }
.file-btn.loading { opacity: .5; pointer-events: none; }

.spinner { width: 28px; height: 28px; border: 3px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.sm { width: 18px; height: 18px; border-width: 2px; border-color: rgba(255, 255, 255, .4); border-top-color: currentColor; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formulários ---------- */
.field { display: block; margin: 0 0 .9rem; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; color: var(--ink); padding: 0; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* evita zoom no iPhone */
  color: var(--ink); background: #fbfaf7; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: .75rem .85rem; min-height: 48px; appearance: none; -webkit-appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2rem; }
input[type=date] { min-height: 48px; }
input[type=file] { padding: .6rem; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }
input:disabled { opacity: .6; }
textarea { resize: vertical; min-height: 70px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.inline-form { display: flex; gap: .5rem; }
.inline-form input { text-transform: uppercase; letter-spacing: .15em; font-weight: 700; }
.check { display: flex; align-items: center; gap: .4rem; font-size: .88rem; color: var(--muted); }
.check input { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--primary); appearance: auto; -webkit-appearance: checkbox; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; min-height: 42px; padding: 0 1rem; border-radius: 999px; border: 1.5px solid var(--line); background: #fbfaf7; font-weight: 600; font-size: .92rem; cursor: pointer; }
.chip input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-soft); }

.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 14px; padding: 4px; margin-bottom: 1rem; }
.segmented button { border: 0; background: transparent; font: inherit; font-weight: 600; padding: .65rem; border-radius: 10px; color: var(--muted); cursor: pointer; }
.segmented button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

.split-box { background: var(--bg); border-radius: var(--radius-sm); padding: .8rem; }
.split-box > span { margin-bottom: .4rem; }
.split-box .row { flex-wrap: wrap; }
.pct-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.pct-row:last-of-type { border-bottom: 0; }
.pct-input { display: flex; align-items: center; gap: .3rem; }
.pct-input input { width: 96px; text-align: right; min-height: 42px; padding: .5rem .6rem; }
.pct-input em { font-style: normal; color: var(--muted); font-weight: 600; }
.preview { margin-top: .6rem; }
.split-list { list-style: none; margin: .3rem 0; padding: 0; }
.split-list li { display: flex; justify-content: space-between; gap: .5rem; padding: .5rem 0; border-bottom: 1px dashed var(--line); }
.split-list li:last-child { border-bottom: 0; }

/* ---------- Painel ---------- */
.notice { display: block; background: var(--primary-soft); color: var(--ink); border-radius: var(--radius-sm); padding: .8rem 1rem; margin-bottom: 1rem; font-size: .92rem; }
.notice.warn { background: var(--accent-soft); }
.notice.action { display: flex; align-items: center; justify-content: space-between; gap: .6rem; color: var(--ink); }
.balance-card { background: linear-gradient(160deg, #ffffff 0%, #f3f8f6 100%); }
.transfer { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .4rem 0 .8rem; flex-wrap: wrap; }
.transfer-text { flex: 1 1 200px; }
.amount-big { display: block; font-size: 1.9rem; font-weight: 750; letter-spacing: -.02em; color: var(--ink); margin: .1rem 0; font-variant-numeric: tabular-nums; }
.amount-hero { font-size: 2.3rem; font-weight: 750; letter-spacing: -.02em; margin: .2rem 0 .8rem; font-variant-numeric: tabular-nums; }
.all-good { display: flex; align-items: center; gap: .5rem; font-weight: 600; color: var(--ok); padding: .4rem 0 .6rem; }
.all-good .icon { width: 22px; height: 22px; }
.stat { display: grid; margin-bottom: .6rem; }
.people { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; margin-top: .4rem; }
.people th { text-align: right; font-size: .75rem; color: var(--muted); font-weight: 600; padding: .3rem 0; }
.people td { padding: .55rem 0 .1rem; text-align: right; font-weight: 600; }
.people td:first-child { text-align: left; }
.people tr.diff td { text-align: left; font-weight: 400; font-size: .8rem; color: var(--muted); padding: 0 0 .55rem; border-bottom: 1px solid var(--line); }
.people tbody tr.diff:last-child td { border-bottom: 0; }
.bar-row { margin: .55rem 0; }
.bar-label { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: .25rem; }
.bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.month-select select { min-height: 40px; padding: .4rem 2rem .4rem .8rem; font-weight: 600; font-size: 16px; background-color: #fff; border-radius: 11px; }

/* ---------- Listas ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; color: var(--ink); border-bottom: 1px solid var(--line); }
.card .list .list-item { padding-left: 0; padding-right: 0; }
.card.flush .list-item { padding: .85rem 1.1rem; }
.list li:last-child .list-item, .list li.list-item:last-child { border-bottom: 0; }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.list-item .amount { font-weight: 700; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.list-item.cancelled .title, .list-item.cancelled .amount { text-decoration: line-through; color: var(--muted); }
.date-chip { flex: none; width: 48px; text-align: center; font-size: .75rem; font-weight: 700; color: var(--primary); background: var(--primary-soft); border-radius: 10px; padding: .45rem .2rem; line-height: 1.1; }
.tag { display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase; color: var(--danger); background: var(--danger-soft); border-radius: 6px; padding: .1rem .4rem; text-decoration: none; margin-top: .2rem; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .8rem; }
.filters .check { grid-column: 1 / -1; }
.filters select { min-height: 42px; font-size: 16px; padding: .5rem 2rem .5rem .7rem; background-color: #fff; }
.total-line { display: flex; justify-content: space-between; align-items: baseline; padding: 0 .2rem .6rem; color: var(--muted); }
.total-line strong { color: var(--ink); font-size: 1.15rem; }
.fab { position: fixed; right: max(1rem, calc(50% - 280px + 1rem)); bottom: calc(var(--nav-h) + var(--safe-b) + 1rem); width: 56px; height: 56px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 20px rgba(44, 107, 98, .35); z-index: 8; }
.fab .icon { width: 26px; height: 26px; }

.detail.cancelled h1, .detail.cancelled .amount-hero { text-decoration: line-through; color: var(--muted); }
.facts { margin: 0; display: grid; gap: .6rem; }
.facts div { display: grid; grid-template-columns: 120px 1fr; gap: .6rem; }
.facts dt { color: var(--muted); font-size: .88rem; }
.facts dd { margin: 0; font-weight: 500; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 .9rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 .9rem .3rem; font-size: .92rem; }
.timeline li::before { content: ""; position: absolute; left: -1.25rem; top: .35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; }
.timeline li span { display: block; }

.invite { display: grid; gap: .8rem; background: var(--accent-soft); border-color: #f2dfbd; }
.invite-code { font-size: 2rem; font-weight: 800; letter-spacing: .25em; color: var(--ink); font-variant-numeric: tabular-nums; }
.invite.compact .invite-code { font-size: 1.6rem; }

.empty { text-align: center; padding: 2rem 1rem; }
.empty-icon .icon { width: 40px; height: 40px; color: var(--accent); fill: var(--accent-soft); }
.empty .btn { margin-top: .8rem; }

/* ---------- Login ---------- */
.auth-screen { padding-top: calc(2rem + var(--safe-t)); }
.auth-hero { text-align: center; margin: 1rem 0 1.4rem; }
.auth-hero h1 { font-size: 2rem; }
.auth-hero p { max-width: 380px; margin: 0 auto; }
.auth-links { text-align: center; margin-top: .6rem; }

/* ---------- Diálogo e aviso ---------- */
dialog { border: 0; border-radius: 22px; padding: 0; width: min(92vw, 420px); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); color: var(--ink); }
dialog::backdrop { background: rgba(20, 30, 28, .45); }
.dialog-body { padding: 1.3rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 1rem); transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: .8rem 1.1rem; border-radius: 14px; font-size: .92rem;
  max-width: min(92vw, 480px); width: max-content; opacity: 0; pointer-events: none; transition: .25s ease; z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); }

@media (min-width: 600px) {
  .screen { padding-top: 1.5rem; }
  .bottom-nav { max-width: 560px; margin: 0 auto; border-radius: 22px 22px 0 0; border: 1px solid var(--line); }
}
