/* Meu Mês — fontes do sistema, sem recursos externos. */
:root {
  --bg: #EEF0F2; --card: #FFFFFF; --text: #14181B; --muted: #59626A; --line: #DDE2E6; --field: #F5F7F8;
  --accent: #1F7A4D; --accent-ink: #FFFFFF; --accent-soft: #E2F2E9;
  --bal: #0D2018; --bal-ink: #FFFFFF; --bal-muted: #B9CCC1; --bal-track: rgba(255,255,255,.16);
  --ok: #3DD68C; --warn: #F5C84B; --bad: #FF6F61;
  --danger: #B3261E; --danger-ink: #FFFFFF; --danger-soft: #FCEBE9;
  --warn-bg: #FFF5D6; --warn-ink: #5C4300; --ok-bg: #E2F2E9; --ok-ink: #11512F;
  --c0: #1F7A4D; --c1: #2B67C9; --c2: #C0531A; --c3: #7652C2;
  --radius: 20px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 2px 8px rgba(16,24,40,.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B0D0E; --card: #16191C; --text: #E9EDF0; --muted: #9EA8B0; --line: #2A3035; --field: #1E2226;
    --accent: #43B67D; --accent-ink: #06140C; --accent-soft: #13291D;
    --bal: #0F2A1D; --bal-ink: #FFFFFF; --bal-muted: #A9C4B4; --bal-track: rgba(255,255,255,.14);
    --danger: #FF8A80; --danger-ink: #2A0906; --danger-soft: #2B1513;
    --warn-bg: #2A2310; --warn-ink: #F3D57C; --ok-bg: #13291D; --ok-ink: #9BE2BC;
    --c0: #43B67D; --c1: #6E9EF2; --c2: #F0925C; --c3: #B39CF2;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; margin-bottom: 12px; }
p { margin: 0 0 12px; }
strong { font-weight: 700; }
button, input { font: inherit; color: inherit; }
img { display: block; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; }
.error { color: var(--danger); font-size: .92rem; min-height: 1.2em; margin: 4px 0 10px; }
.error:empty { min-height: 0; margin: 0; }
.noscript { padding: 24px; text-align: center; }

/* ---------- telas ---------- */
.screen { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; }
.screen.center { display: grid; place-items: center; padding: 24px; text-align: center; }
.auth { padding: 32px 16px 24px; display: flex; flex-direction: column; gap: 16px; }
.brand { text-align: center; display: grid; justify-items: center; gap: 8px; }
.brand img { border-radius: 16px; }
.brand h1 { font-size: 1.6rem; }
.links { display: grid; gap: 4px; justify-items: center; }
.content { padding: 4px 16px 32px; display: grid; gap: 14px; }

/* ---------- topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 8px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(12px); backdrop-filter: saturate(160%) blur(12px);
}
.topbar > h1 { flex: 1; text-align: center; }
.month-nav { display: flex; align-items: center; gap: 2px; flex: 1; justify-content: center; min-width: 0; }
.month-title { display: grid; justify-items: center; min-width: 0; }
.month-title h1 { font-size: 1.12rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.icon-btn, .icon-spacer {
  width: 44px; height: 44px; flex: 0 0 44px; display: inline-grid; place-items: center; border-radius: 14px;
  border: 0; background: transparent; cursor: pointer;
}
.icon-btn:active { background: var(--line); }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.balance { background: var(--bal); color: var(--bal-ink); }
.balance h2 { color: var(--bal-muted); font-weight: 600; font-size: .95rem; margin-bottom: 4px; }
.balance-value { font-size: 2.15rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 14px; font-variant-numeric: tabular-nums; min-height: 1.2em; }
.balance.negative .balance-value { color: var(--bad); }
.balance-msg { color: var(--bal-muted); font-size: .92rem; margin: 10px 0 0; }
.balance.negative .balance-msg { color: var(--bal-ink); font-weight: 600; }
.bar { height: 10px; border-radius: 99px; background: var(--bal-track); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--ok); transition: width .25s ease, background-color .25s; }
.balance[data-level="warn"] .bar > span { background: var(--warn); }
.balance[data-level="bad"] .bar > span { background: var(--bad); }

.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mini { display: grid; gap: 2px; padding: 14px 16px; }
.mini span { font-size: .88rem; }
.mini strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ---------- formulários ---------- */
.grid2 { display: grid; gap: 12px; }
@media (min-width: 420px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.grid2 .field { margin-bottom: 0; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
label { font-weight: 600; font-size: .92rem; }
input[type=text], input[type=password] {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--field); font-size: 1.05rem; outline: none; appearance: none; -webkit-appearance: none;
}
input:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
input:disabled { opacity: .55; }
.money { position: relative; }
.money > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; pointer-events: none; }
.money input { padding-left: 46px; font-variant-numeric: tabular-nums; font-weight: 600; }
.pw { position: relative; }
.pw input { padding-right: 92px; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-height: 44px; min-width: 80px;
  border: 0; background: transparent; color: var(--accent); font-weight: 700; font-size: .9rem; cursor: pointer; border-radius: 12px;
}
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; font-weight: 500; margin-bottom: 8px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: 0 0 auto; margin: 0; }
.strength { display: flex; align-items: center; gap: 10px; min-height: 20px; }
.strength-bar { flex: 1; height: 6px; background: var(--line); border-radius: 9px; overflow: hidden; }
.strength-bar span { display: block; height: 100%; width: 0; background: var(--bad); transition: width .2s; }
.strength-bar span[data-score="2"] { background: var(--warn); }
.strength-bar span[data-score="3"], .strength-bar span[data-score="4"] { background: var(--accent); }

/* ---------- chips ---------- */
.chips { border: 0; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.chips legend { font-weight: 600; font-size: .92rem; padding: 0; margin-bottom: 8px; }
.chip { position: relative; display: inline-flex; font-weight: 600; }
.chip input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--field); font-size: .94rem; transition: background-color .15s, color .15s;
}
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- botões ---------- */
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1.5px solid transparent; font-weight: 700;
  font-size: 1rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.danger { background: var(--danger); color: var(--danger-ink); }
.btn.danger-ghost { background: transparent; color: var(--danger); border-color: transparent; margin-right: auto; padding: 0 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:not(:disabled):active { transform: scale(.985); }
.btn:focus-visible, .link:focus-visible, .icon-btn:focus-visible, .tx:focus-visible, .pw-toggle:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.link { background: none; border: 0; color: var(--accent); font-weight: 600; min-height: 44px; padding: 0 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link.small { min-height: 28px; font-size: .8rem; padding: 0 6px; }
.stack { display: grid; gap: 10px; margin-bottom: 8px; }

/* ---------- alertas ---------- */
.alert { border-radius: 14px; padding: 12px 14px; font-size: .92rem; margin: 0 0 12px; }
.alert.warn { background: var(--warn-bg); color: var(--warn-ink); }
.alert.ok { background: var(--ok-bg); color: var(--ok-ink); }
.danger-zone h2 { color: var(--danger); }

/* ---------- categorias ---------- */
.cat-list, .tx-list { list-style: none; margin: 0; padding: 0; }
.cat-row { padding: 8px 0; }
.cat-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: .95rem; }
.cat-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.cat-val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.cat-val small { color: var(--muted); font-weight: 500; }
.cat-bar { height: 8px; background: var(--field); border-radius: 9px; overflow: hidden; }
.cat-fill { display: block; height: 100%; border-radius: inherit; transition: width .25s; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; display: inline-block; }
[data-cat="0"] { --cat: var(--c0); } [data-cat="1"] { --cat: var(--c1); }
[data-cat="2"] { --cat: var(--c2); } [data-cat="3"] { --cat: var(--c3); }
.dot, .cat-fill { background: var(--cat); }

/* ---------- lançamentos ---------- */
.empty { color: var(--muted); text-align: center; padding: 18px 8px; margin: 0; }
.tx-list li + li { border-top: 1px solid var(--line); }
.tx {
  width: 100%; min-height: 60px; display: flex; align-items: center; gap: 12px; text-align: left;
  background: none; border: 0; padding: 10px 4px; cursor: pointer; border-radius: 12px;
}
.tx:active { background: var(--field); }
.tx-main { flex: 1; min-width: 0; display: grid; }
.tx-desc { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-meta { font-size: .82rem; color: var(--muted); }
.tx-val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- instalação ---------- */
.steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
.version { text-align: center; color: var(--muted); font-size: .82rem; margin: 8px 0 0; }

/* ---------- diálogo ---------- */
dialog {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); border: 0; padding: 0; border-radius: var(--radius);
  background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(8, 12, 10, .55); }
.dlg-form { padding: 20px; display: grid; gap: 4px; }
.dlg-title { font-size: 1.15rem; margin-bottom: 8px; }
.dlg-text { color: var(--muted); }
.dlg-form > label { margin-top: 4px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: .95rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); z-index: 50; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.loading .content { opacity: .6; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
