/* Meu amiguinho agiota — estilos */
:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f1f0ec;
  --border: #e3e1da;
  --text: #17201b;
  --text-2: #52514e;
  --muted: #858379;
  --brand: #13694a;
  --brand-2: #0e5239;
  --brand-soft: #e3f2ea;
  --gold: #f5b72c;
  --good: #0f7b47;
  --bad: #c43a39;
  --warn: #b77a00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948; --other: #8a8984;
  --grid: #ebe9e3;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121513;
  --surface: #1a1d1b;
  --surface-2: #222624;
  --border: #2e3330;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #8d8c84;
  --brand: #3fbf8a;
  --brand-2: #5fd3a2;
  --brand-soft: #16362a;
  --good: #3fbf8a;
  --bad: #ef7676;
  --warn: #e0a83a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767; --other: #77766f;
  --grid: #2a2e2c;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; color: var(--text-2); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* botões e campos */
button, .btn { font: inherit; border: 0; border-radius: 10px; padding: .6rem 1rem; cursor: pointer; background: var(--brand); color: #fff; font-weight: 600; display: inline-flex; align-items: center; gap: .4rem; text-decoration: none; justify-content: center; }
:root[data-theme="dark"] button:not(.ghost):not(.danger):not(.link):not(.chip), :root[data-theme="dark"] .btn { color: #0b1a13; }
button:hover, .btn:hover { filter: brightness(1.06); }
button:disabled { opacity: .55; cursor: default; }
button.ghost, .btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
button.danger { background: transparent; color: var(--bad); border: 1px solid var(--border); }
button.link { background: none; color: var(--brand); padding: 0; font-weight: 600; }
button.small, .btn.small { padding: .35rem .7rem; font-size: .85rem; border-radius: 8px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
label { display: block; font-size: .85rem; color: var(--text-2); font-weight: 600; margin-bottom: .3rem; }
input, select, textarea { font: inherit; width: 100%; padding: .6rem .7rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
textarea { resize: vertical; min-height: 64px; }
input[type="checkbox"] { width: auto; accent-color: var(--brand); }
input[type="color"] { padding: 2px; height: 40px; }
.field { margin-bottom: .85rem; }
.row { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; color: var(--text); font-size: .95rem; margin: .4rem 0; }

/* estrutura do app */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: .75rem; letter-spacing: 0; }
.topbar .spacer { flex: 1; }
.iconbtn { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); width: 38px; height: 38px; padding: 0; border-radius: 10px; }
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 57px); }
.sidenav { background: var(--surface); border-right: 1px solid var(--border); padding: 1rem .6rem; display: flex; flex-direction: column; gap: .2rem; }
.sidenav a { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border-radius: 10px; color: var(--text-2); text-decoration: none; font-weight: 600; }
.sidenav a.active { background: var(--brand-soft); color: var(--brand); }
.sidenav a:hover:not(.active) { background: var(--surface-2); }
main { padding: 1.25rem; max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .spacer { flex: 1; }
.bottomnav { display: none; }
.fab { position: fixed; right: 1.2rem; bottom: 1.2rem; width: 58px; height: 58px; border-radius: 50%; font-size: 1.8rem; padding: 0; box-shadow: 0 6px 20px rgba(19, 105, 74, .35); z-index: 30; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidenav { display: none; }
  main { padding: 1rem .8rem 6rem; }
  .bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 25; padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav a { flex: 1; text-align: center; padding: .45rem 0 .5rem; font-size: .7rem; color: var(--muted); text-decoration: none; font-weight: 600; }
  .bottomnav a span { display: block; font-size: 1.25rem; line-height: 1.3; }
  .bottomnav a.active { color: var(--brand); }
  .fab { bottom: 4.6rem; }
  .brand small { display: none; }
}

/* cartões */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .75rem; }
.card-head .spacer { flex: 1; }
.grid { display: grid; gap: 1rem; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); margin-bottom: 1rem; }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-bottom: 1rem; }
@media (max-width: 420px) { .grid.two, .grid.three { grid-template-columns: 1fr; } }
.kpi .label { font-size: .8rem; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 1.6rem; font-weight: 750; margin-top: .2rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: .82rem; margin-top: .2rem; color: var(--text-2); }
.delta .up { color: var(--bad); font-weight: 700; }
.delta .down { color: var(--good); font-weight: 700; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

/* gráficos */
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 300px; }
.chart-box.short { height: 200px; }
.donut-wrap { display: grid; grid-template-columns: minmax(170px, 220px) 1fr; gap: 1rem; align-items: center; }
@media (max-width: 520px) { .donut-wrap { grid-template-columns: 1fr; } .donut-wrap .chart-box { height: 220px; } }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; text-align: center; }
.donut-center b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.donut-center span { font-size: .75rem; color: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .15rem; }
.legend li { display: grid; grid-template-columns: 12px 1fr auto auto; gap: .55rem; align-items: center; padding: .35rem .4rem; border-radius: 8px; cursor: pointer; font-size: .9rem; }
.legend li:hover { background: var(--surface-2); }
.legend .sw { width: 12px; height: 12px; border-radius: 4px; }
.legend .val { font-variant-numeric: tabular-nums; font-weight: 600; }
.legend .pct { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .82rem; min-width: 2.8rem; text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.empty .big { font-size: 2.4rem; }

/* barras de orçamento */
.budget { margin-bottom: .8rem; }
.budget .top { display: flex; justify-content: space-between; font-size: .9rem; gap: .5rem; }
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: .3rem; }
.meter > div { height: 100%; border-radius: 4px; background: var(--brand); }
.meter.warn > div { background: var(--warn); }
.meter.over > div { background: var(--bad); }
.tag { display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; font-weight: 700; padding: .1rem .45rem; border-radius: 6px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.tag.warn { background: #fff2d6; color: #7a5200; }
.tag.over { background: #fde3e3; color: #9b2626; }
.tag.ok { background: var(--brand-soft); color: var(--brand); }
:root[data-theme="dark"] .tag.warn { background: #3a2d10; color: #f0c56b; }
:root[data-theme="dark"] .tag.over { background: #3d1c1c; color: #f4a3a3; }

/* listas e tabelas */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: .7rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); font-size: 1.1rem; flex: none; }
.list .main { flex: 1; min-width: 0; }
.list .main > b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.list .main > span { font-size: .8rem; color: var(--muted); }
.list .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); padding: .55rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
td.r, th.r { text-align: right; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-bottom: 1rem; }
.filters > div { min-width: 140px; flex: 1; }
.filters label { font-size: .75rem; }
.totals { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-bottom: .75rem; font-size: .92rem; }
.entries-mobile { display: none; }
@media (max-width: 760px) { .entries-table { display: none; } .entries-mobile { display: block; } }

/* chips */
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); padding: .35rem .75rem; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
:root[data-theme="dark"] .chip.on { color: #0b1a13; }

/* janela (modal) */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 15, 12, .45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 560px; padding: 1.2rem 1.25rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal-head { display: flex; align-items: center; margin-bottom: 1rem; gap: .5rem; }
.modal-head h2 { flex: 1; }
.modal-foot { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 1rem; }
.seg button { background: transparent; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg button.on.out { color: var(--bad); }
.seg button.on.in { color: var(--good); }
.amount-input { font-size: 1.8rem; font-weight: 750; text-align: center; padding: .5rem; letter-spacing: -.02em; }
.methods { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .4rem; }
.methods button { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); font-weight: 600; font-size: .85rem; padding: .5rem; }
.methods button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: .4rem; max-height: 220px; overflow-y: auto; padding: 2px; }
.cat-grid button { flex-direction: column; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); padding: .45rem .3rem; font-size: .76rem; font-weight: 600; gap: .1rem; line-height: 1.15; }
.cat-grid button .e { font-size: 1.3rem; }
.cat-grid button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
details.more { margin-top: .4rem; }
details.more summary { cursor: pointer; font-weight: 600; color: var(--brand); margin-bottom: .6rem; }

/* aviso */
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: #17201b; color: #fff; padding: .7rem 1.1rem; border-radius: 12px; z-index: 80; font-weight: 600; box-shadow: 0 8px 30px rgba(0, 0, 0, .3); max-width: 92vw; }
.toast.err { background: #a52b2a; }
@media (max-width: 860px) { .toast { bottom: 5.5rem; } }

/* login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), transparent), var(--bg); }
.login-card { width: 100%; max-width: 400px; }
.login-card .hero { text-align: center; margin-bottom: 1.4rem; }
.login-card .hero img { width: 84px; height: 84px; }
.login-card .hero h1 { margin-top: .6rem; font-size: 1.6rem; letter-spacing: -.02em; }
.login-card .hero p { margin: .35rem 0 0; color: var(--text-2); }
.footer-note { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 1rem; }

/* admin */
.fam { margin-bottom: 1rem; }
.fam-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
.fam-head h2 { flex: 1; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); }
.status-dot.on { background: var(--good); }
.status-dot.off { background: var(--bad); }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; }
code { background: var(--surface-2); padding: .1rem .35rem; border-radius: 6px; font-size: .85em; word-break: break-all; }
.wa-preview { background: #e7ffdb; color: #111; border-radius: 10px; padding: .6rem .8rem; font-size: .88rem; white-space: pre-wrap; }
:root[data-theme="dark"] .wa-preview { background: #144d37; color: #e9fbe9; }
