:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #17201d;
  --muted: #66736e;
  --line: #e2e8e5;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --pos: #15803d;
  --neg: #c2410c;
  --danger: #b91c1c;
  --radius: 14px;
  --viz-1: #2a78d6;
  --viz-2: #eb6834;
  --st-good: #0ca30c;
  --st-warning: #fab219;
  --st-critical: #d03b3b;
  --track: #e8edeb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1412;
    --card: #17201d;
    --text: #e8eeeb;
    --muted: #93a19b;
    --line: #26322e;
    --accent: #2dd4bf;
    --accent-ink: #062a26;
    --pos: #4ade80;
    --neg: #fb923c;
    --danger: #f87171;
    --viz-1: #3987e5;
    --viz-2: #d95926;
    --track: #26322e;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.4rem; margin: .5rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .6rem; }
main { max-width: 640px; margin: 0 auto; padding: 0 16px; }

.top {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 640px; margin: 0 auto; padding: 14px 16px;
}
.brand { font-weight: 700; color: var(--text); font-size: 1.1rem; }
.me { font-size: .9rem; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; margin: 1rem 0; }
.empty { color: var(--muted); text-align: center; padding: 2rem 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

.flash { border-radius: 10px; padding: 10px 14px; margin: .5rem 0 1rem; background: color-mix(in srgb, var(--pos) 14%, var(--card)); }
.flash.err { background: color-mix(in srgb, var(--danger) 14%, var(--card)); }

.hero { text-align: center; padding: 1rem 0 1.25rem; }
.hero .label { display: block; color: var(--muted); font-size: .9rem; }
.hero .big { font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.accounts { list-style: none; margin: 0; padding: 4px 16px; }
.accounts li { border-bottom: 1px solid var(--line); }
.accounts li:last-child { border-bottom: 0; }
.accounts li > a, .accounts li.total, .accounts li.row-between {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 0; color: var(--text);
}
.accounts li.total { font-weight: 700; }
.accounts small { display: block; color: var(--muted); font-size: .8rem; }
.accounts span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }

.cats li { display: flex; align-items: center; gap: 8px; }
.cats li > a { flex: 1; min-width: 0; }
.order { display: flex; gap: 4px; }
.order button {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 1rem; cursor: pointer;
}
.order button:disabled { opacity: .3; cursor: default; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 10px; min-width: 0; }
.stat .label { display: block; font-size: .78rem; color: var(--muted); }
.stat span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; font-size: clamp(.78rem, 3.6vw, .95rem); white-space: nowrap; }

.txlist { list-style: none; margin: 1rem 0; padding: 0; }
.txdate { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; margin: 1rem 0 .3rem; }
.tx {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 6px; color: var(--text);
}
.txmain { display: flex; flex-direction: column; min-width: 0; }
.txmain strong { font-weight: 600; }
.txmain .desc { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txmain .sub { font-size: .8rem; color: var(--muted); }
.amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.neutral { color: var(--muted); }

.monthnav { display: flex; justify-content: space-between; align-items: center; margin: .5rem 0 1rem; }
.monthnav a { font-size: 1.6rem; padding: 0 14px; line-height: 1; }
.filters { display: flex; gap: 8px; margin-bottom: 1rem; }
.filters select { flex: 1; }

.form label { display: block; margin-bottom: 14px; font-size: .9rem; color: var(--muted); }
.form h2 { margin-top: .5rem; }
input, select {
  display: block; width: 100%; margin-top: 4px; padding: 11px 12px;
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
input.amount { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; text-align: center; padding: 9px 4px; border-radius: 10px;
  border: 1px solid var(--line); color: var(--text); font-size: .9rem; cursor: pointer;
}
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.btn {
  display: inline-block; padding: 11px 18px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.center.actions { justify-content: center; }
.login { max-width: 380px; margin: 3rem auto; }

.fab {
  position: fixed; right: 18px; bottom: calc(76px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; line-height: 1; box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
.bottom {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}
.bottom a { color: var(--muted); font-size: .85rem; padding: 6px 10px; }
.bottom a.on { color: var(--accent); font-weight: 600; }

/* Filtros e etiquetas */
.chip { display: inline-flex; gap: 8px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; margin: 0 0 .5rem; font-size: .9rem; }
.chip a { color: var(--muted); }
.center { text-align: center; }

/* Orçamento */
.budget-hero { margin-bottom: 1rem; }
.budget-hero .label { color: var(--muted); font-size: .85rem; }
.budget-hero .big { display: block; font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0 8px; }
.bbar { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; margin: 8px 0 6px; }
.bbar span { display: block; height: 100%; border-radius: 4px; background: var(--st-good); }
.bbar.warning span { background: var(--st-warning); }
.bbar.critical span { background: var(--st-critical); }
.budget-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.budget-list a { display: block; color: var(--text); }
.status { font-size: .85rem; color: var(--text); white-space: nowrap; }
.status > span { display: inline-flex; width: 18px; height: 18px; border-radius: 50%; align-items: center; justify-content: center; font-size: .7rem; font-weight: 700; color: #fff; }
.status.good > span { background: var(--st-good); }
.status.warning > span { background: var(--st-warning); color: #3a2a00; }
.status.critical > span { background: var(--st-critical); }
.budget-input { display: flex !important; align-items: center; justify-content: space-between; gap: 12px; color: var(--text) !important; }
.budget-input span { flex: 1; }
.budget-input input { width: 120px; margin: 0; text-align: right; }
.budget-mini { display: block; color: var(--text); margin: 1rem 0 .5rem; }
.budget-mini strong { display: block; }

/* Resumo: barras horizontais (uma série) */
.hbars { list-style: none; margin: 0; padding: 8px 16px; }
.hbars li a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 8px 0; color: var(--text); }
.hb-name { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-val { font-size: .9rem; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.hb-val small { color: var(--muted); margin-left: 4px; }
.hb-track { grid-column: 1 / -1; height: 8px; }
.hb-bar { display: block; height: 100%; min-width: 2px; background: var(--viz-1); border-radius: 0 4px 4px 0; }
.hbars li a:hover .hb-bar { filter: brightness(1.1); }

/* Resumo: colunas por mês (duas séries) */
.legend { display: flex; gap: 16px; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sw.s1, .b.s1 { background: var(--viz-1); }
.sw.s2, .b.s2 { background: var(--viz-2); }
.cols { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; height: 160px; align-items: end; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.col { display: flex; flex-direction: column; height: 100%; color: var(--muted); }
.col-bars { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.b { width: 40%; max-width: 18px; min-height: 1px; border-radius: 4px 4px 0 0; }
.col-label { text-align: center; font-size: .75rem; padding-top: 4px; transform: translateY(20px); }
.col.on .col-label { color: var(--text); font-weight: 700; }
.col:hover .b { filter: brightness(1.1); }
.mtable { width: 100%; border-collapse: collapse; margin-top: 28px; font-size: .85rem; font-variant-numeric: tabular-nums; }
.mtable th { color: var(--muted); font-weight: 500; text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.mtable td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.mtable th:first-child, .mtable td:first-child { text-align: left; }
.mtable tr.on td { font-weight: 700; }
.mtable tr:last-child td { border-bottom: 0; }
