:root {
  --bg: #f2f5f8;
  --surface: #ffffff;
  --ink: #17212b;
  --muted: #6b7a8c;
  --line: #e2e8ef;
  --green: #0e8a62;
  --green-soft: #e2f3ec;
  --red: #d6455b;
  --red-soft: #fbe9ec;
  --accent: #2e5aac;
  --accent-soft: #e8eefb;
  --amber: #e0a93e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 33, 43, 0.05), 0 8px 24px rgba(23, 33, 43, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 15px;
}

h1, h2, h3, .big-number, .tab-btn {
  font-family: "Bricolage Grotesque", "Inter", sans-serif;
}

.hidden { display: none !important; }

/* ---------- Login ---------- */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px;
  width: min(380px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card p { margin: 0 0 10px; color: var(--muted); }

/* ---------- Shell ---------- */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 5;
}
header .brand { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
header .brand span { color: var(--green); }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
.tab-btn {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.tab-btn.active { background: var(--ink); color: #fff; }
#logout-btn {
  margin-left: auto;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

main { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }

/* ---------- Hero (pulso do mês) ---------- */
.hero {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
  margin-bottom: 20px;
}
.hero-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hero-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; }
.big-number { font-size: clamp(34px, 6vw, 52px); font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 18px; font-variant-numeric: tabular-nums; }
.big-number.positive { color: var(--green); }
.big-number.negative { color: var(--red); }

.pulse-bar {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
}
.pulse-bar .in { background: var(--green); }
.pulse-bar .out { background: var(--red); }
.pulse-legend { display: flex; justify-content: space-between; margin-top: 10px; font-size: 14px; color: var(--muted); }
.pulse-legend b { color: var(--ink); font-variant-numeric: tabular-nums; }

select, input, button.primary, button.ghost {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: var(--surface);
  color: var(--ink);
}
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary {
  background: var(--ink);
  color: #fff;
  border: none;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 18px;
}
button.primary:hover { background: #263445; }
button.ghost { cursor: pointer; color: var(--muted); background: transparent; }
button.danger-link { border: none; background: none; color: var(--red); cursor: pointer; font-size: 13px; }

/* ---------- Grid de cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.card h3 { margin: 0 0 14px; font-size: 15px; }
.card canvas { max-height: 260px; }

/* Orçado x realizado */
.budget-row { margin-bottom: 14px; }
.budget-row .head { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 5px; }
.budget-row .head b { font-variant-numeric: tabular-nums; }
.budget-track { height: 9px; border-radius: 999px; background: var(--line); overflow: hidden; }
.budget-fill { height: 100%; border-radius: 999px; background: var(--green); }
.budget-fill.warn { background: var(--amber); }
.budget-fill.over { background: var(--red); }

/* ---------- Tabelas ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.05em; padding: 8px 10px; }
td { padding: 10px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.month-heading { margin: 26px 0 8px; font-size: 16px; }
.amount-in { color: var(--green); font-weight: 600; }
.amount-out { color: var(--red); font-weight: 600; }
.chip { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; background: var(--accent-soft); color: var(--accent); }
.chip.warn { background: #fdf3dd; color: #9a7016; }

/* ---------- Formulários em linha ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; margin-bottom: 8px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.checkbox-inline { flex-direction: row !important; align-items: center; padding-bottom: 10px; }

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 14px;
  box-shadow: var(--shadow);
}

.empty { color: var(--muted); text-align: center; padding: 28px 0; }

@media (max-width: 640px) {
  header { padding: 12px 14px; gap: 10px; }
  main { padding: 16px 12px 48px; }
}
