/* Meu Financeiro — visual clean e moderno, tema escuro e claro */
:root {
  --bg: #0b1210; --bg2: #101a17; --card: #14211d; --card2: #1a2a25; --line: #233630;
  --text: #e8f1ee; --muted: #8fa59e; --faint: #5f746d;
  --accent: #2ee6a6; --accent2: #18b885; --accent-ink: #062a1e;
  --rec: #2ee6a6; --desp: #ff6b81; --transf: #7aa7ff; --warn: #ffc857;
  --radius: 18px; --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: "Segoe UI Variable Text", "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  --sat: var(--safe-area-inset-top, env(safe-area-inset-top, 0px)); --sab: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f3f6f5; --bg2: #ffffff; --card: #ffffff; --card2: #f1f5f3; --line: #e1e8e5;
  --text: #11201b; --muted: #5d6f69; --faint: #94a49f;
  --accent: #10b981; --accent2: #059669; --accent-ink: #ffffff;
  --rec: #0d9f6e; --desp: #e5484d; --transf: #3b6fe0; --warn: #c98a00;
  --shadow: 0 8px 24px rgba(16, 40, 32, .08);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 22px 16px; border-right: 1px solid var(--line); background: var(--bg2); display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; padding: 0 6px; }
.brand__logo { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 13px; font-weight: 900; background: linear-gradient(135deg, var(--accent), #2fb8ff); color: #04241a; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: var(--muted); font-weight: 600; transition: .15s; }
.nav a i { font-style: normal; width: 22px; text-align: center; font-size: 17px; }
.nav a:hover { background: var(--card2); color: var(--text); }
.nav a.on { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.side__add { margin-top: 4px; }
.sync { margin-top: auto; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; padding: 10px 8px; }
.sync .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.sync .dot.ok { background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
.sync .dot.busy { background: var(--warn); animation: pulse 1s infinite; }
.sync .dot.bad { background: var(--desp); }
@keyframes pulse { 50% { opacity: .35; } }
.main { padding: 28px clamp(16px, 3vw, 40px) 60px; max-width: 1180px; width: 100%; min-width: 0; }
.fab { display: none; }

/* ---------- cabeçalho de página ---------- */
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.head p { margin: 2px 0 0; color: var(--muted); }
.month { display: inline-flex; align-items: center; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.month button { border: 0; background: none; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; color: var(--muted); font-size: 16px; }
.month button:hover { background: var(--card2); color: var(--text); }
.month b { min-width: 132px; text-align: center; font-size: 14.5px; cursor: pointer; }

/* ---------- cartões ---------- */
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h2 { margin: 0 0 14px; font-size: 15px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h2 small { font-weight: 500; color: var(--muted); font-size: 12.5px; }
.card h2 a { font-size: 12.5px; color: var(--accent); font-weight: 600; }
.stat__label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat__value { font-size: 25px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; white-space: nowrap; }
.stat__sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat--hero { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--card)), var(--card) 70%); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.pos { color: var(--rec); } .neg { color: var(--desp); } .tr { color: var(--transf); }
.mt { margin-top: 14px; }

/* gráfico de rosca */
.donut { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut__svg { position: relative; flex: none; }
.donut__mid { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-size: 12px; color: var(--muted); }
.donut__mid b { display: block; color: var(--text); font-size: 16px; }
.legend { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 8px; }
.legend div { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend b { font-weight: 700; }
.legend em { font-style: normal; color: var(--muted); font-size: 12px; width: 38px; text-align: right; }

/* barras */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding-top: 8px; }
.bars__col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; gap: 6px; }
.bars__pair { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.bars__b { width: min(16px, 40%); border-radius: 6px 6px 2px 2px; transition: height .4s; }
.bars__b.rec { background: var(--rec); } .bars__b.desp { background: var(--desp); }
.bars__lbl { font-size: 11.5px; color: var(--muted); }
.bars__col.cur .bars__lbl { color: var(--text); font-weight: 700; }
.keys { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.keys i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }

/* barra de progresso */
.prog { height: 8px; background: var(--card2); border-radius: 99px; overflow: hidden; }
.prog > div { height: 100%; border-radius: 99px; background: var(--accent); transition: width .4s; }
.prog > div.warn { background: var(--warn); } .prog > div.bad { background: var(--desp); }

/* ---------- listas ---------- */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 6px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 10px; }
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--card2); }
.ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; flex: none; }
.item__main { flex: 1; min-width: 0; }
.item__t { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item__s { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item__v { text-align: right; font-weight: 750; white-space: nowrap; }
.item__v small { display: block; font-weight: 500; font-size: 11.5px; color: var(--muted); }
.check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--faint); display: grid; place-items: center; flex: none; cursor: pointer; background: none; font-size: 13px; color: transparent; transition: .15s; }
.check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check:hover { border-color: var(--accent); }
.day { font-size: 12.5px; color: var(--muted); font-weight: 700; padding: 16px 6px 4px; display: flex; justify-content: space-between; }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--card2); color: var(--muted); margin-left: 4px; vertical-align: 1px; }
.tag.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.tag.bad { background: color-mix(in srgb, var(--desp) 16%, transparent); color: var(--desp); }

/* ---------- filtros ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--muted); padding: 7px 13px; border-radius: 99px; cursor: pointer; font-weight: 600; font-size: 13px; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.search { flex: 1; min-width: 180px; }
.summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.summary > div { flex: 1; min-width: 120px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; }
.summary small { color: var(--muted); font-size: 12px; font-weight: 600; display: block; }
.summary b { font-size: 17px; }

/* ---------- formulários ---------- */
input, select, textarea { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; outline: none; transition: border .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.toolbar select, .toolbar input { width: auto; padding: 8px 12px; border-radius: 99px; }
.toolbar select { padding-right: 30px; }
.toolbar .search { width: auto; }
label.f { display: block; }
label.f > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fgrid .full { grid-column: 1 / -1; }
.seg { display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px 6px; border-radius: 10px; cursor: pointer; font-weight: 650; color: var(--muted); font-size: 13.5px; }
.seg button.on { background: var(--card2); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.seg.tipo button.on[data-v="despesa"] { background: var(--desp); color: #fff; }
.seg.tipo button.on[data-v="receita"] { background: var(--rec); color: var(--accent-ink); }
.seg.tipo button.on[data-v="transf"] { background: var(--transf); color: #fff; }
.money { display: flex; align-items: center; gap: 8px; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 6px 16px; }
.money span { font-size: 20px; color: var(--muted); font-weight: 700; }
.money input { border: 0; background: none; font-size: 30px; font-weight: 800; padding: 6px 0; letter-spacing: -.02em; }
.catgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.catbtn { border: 1px solid var(--line); background: var(--bg2); border-radius: 14px; padding: 10px 4px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.catbtn b { font-size: 20px; line-height: 1; }
.catbtn.on { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 12%, var(--bg2)); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 2px; cursor: pointer; font-weight: 600; }
.switch input { display: none; }
.switch i { width: 44px; height: 26px; border-radius: 99px; background: var(--line); position: relative; transition: .2s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { left: 21px; }
.hint { font-size: 12.5px; color: var(--muted); }
.note { background: var(--card2); border-radius: 12px; padding: 10px 13px; font-size: 13px; color: var(--muted); }
.note b { color: var(--text); }
.drop { border: 1.5px dashed var(--line); border-radius: 14px; padding: 14px; text-align: center; cursor: pointer; color: var(--muted); font-size: 13.5px; }
.drop:hover { border-color: var(--accent); color: var(--text); }

/* ---------- botões ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card2); color: var(--text); padding: 10px 16px; border-radius: 12px; cursor: pointer; font-weight: 700; font-size: 14px; transition: .15s; }
.btn:hover { filter: brightness(1.08); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--danger { background: transparent; color: var(--desp); border-color: color-mix(in srgb, var(--desp) 40%, var(--line)); }
.btn--ghost { background: transparent; }
.btn--sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn--block { width: 100%; }
.icon-btn { border: 0; background: none; cursor: pointer; width: 36px; height: 36px; border-radius: 10px; color: var(--muted); font-size: 16px; }
.icon-btn:hover { background: var(--card2); color: var(--text); }

/* ---------- folha (modal) ---------- */
.sheet-wrap { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; opacity: 0; pointer-events: none; transition: opacity .2s; }
.sheet-wrap.open { opacity: 1; pointer-events: auto; }
.sheet { width: min(560px, 100%); max-height: min(92vh, 860px); background: var(--bg2); border: 1px solid var(--line); border-radius: 22px; display: flex; flex-direction: column; box-shadow: var(--shadow); transform: translateY(14px); transition: transform .22s; }
.sheet-wrap.open .sheet { transform: none; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.sheet__head h3 { margin: 0; font-size: 18px; }
.sheet__body { padding: 8px 18px 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.sheet__foot { padding: 12px 18px calc(14px + var(--sab)); border-top: 1px solid var(--line); display: flex; gap: 8px; }
.sheet__foot:empty { display: none; }
.sheet__foot .grow { flex: 1; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(400px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin: 6px 0 0; font-size: 24px; }

.toast { position: fixed; left: 50%; bottom: calc(26px + var(--sab)); transform: translate(-50%, 30px); background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; opacity: 0; transition: .25s; z-index: 99; pointer-events: none; max-width: calc(100vw - 30px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- celular ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 30; flex-direction: row; padding: 6px 6px calc(6px + var(--sab)); border-right: 0; border-top: 1px solid var(--line); gap: 0; }
  .brand, .side__add, .sync { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11px; flex: 1; text-align: center; }
  .nav a i { font-size: 19px; }
  .main { padding: calc(16px + var(--sat)) 14px calc(96px + var(--sab)); }
  .fab { display: grid; place-items: center; position: fixed; right: 18px; bottom: calc(78px + var(--sab)); width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 30px; font-weight: 400; box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 35%, transparent); z-index: 31; cursor: pointer; }
  .g4 { grid-template-columns: 1fr 1fr; }
  .g3, .g2 { grid-template-columns: 1fr; }
  .head h1 { font-size: 22px; }
  .stat__value { font-size: 20px; }
  .card { padding: 15px; }
  .sheet-wrap { place-items: end center; }
  .sheet { border-radius: 22px 22px 0 0; max-height: 94vh; border-bottom: 0; transform: translateY(40px); }
  .bars { height: 140px; gap: 6px; }
  .mobile-sync { display: flex !important; }
  .summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .summary > div { min-width: 0; padding: 8px 10px; }
  .summary b { font-size: 14px; white-space: nowrap; }
}
.mobile-sync { display: none !important; }
