@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --ink: #16213E;
  --ink-light: #233258;
  --ink-faint: #2C3B63;
  --paper: #FBF7EF;
  --paper-dark: #F0E9D8;
  --line: #DED2B4;
  --green: #2F6D4F;
  --green-bg: #E5EFE8;
  --amber: #AD5F1D;
  --amber-bg: #F8E9D7;
  --red: #A63446;
  --red-bg: #F6E1E4;
  --gold: #B8892B;
  --gold-bg: #F3E7C9;
  --text: #231F1A;
  --muted: #7C7669;
  --font-display: 'Fraunces', serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--text);
}

a { color: inherit; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}

.page-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  margin: 4px 0 24px;
}

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  padding: 24px;
}
.login-card {
  background: var(--paper);
  border-radius: 14px;
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-header { background: var(--ink); padding: 28px 32px; }
.login-header .eyebrow { margin-bottom: 8px; }
.login-header h1 { font-family: var(--font-display); color: var(--paper); font-weight: 700; font-size: 30px; margin: 0; }
.login-body { padding: 28px 32px; display: flex; flex-direction: column; gap: 18px; }

.role-toggle { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.role-toggle label {
  flex: 1;
  text-align: center;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fff;
  cursor: pointer;
  border-right: 1px solid var(--line);
}
.role-toggle label:last-child { border-right: none; }
.role-toggle input { display: none; }
.role-toggle input:checked + span { color: var(--paper); }
.role-toggle label:has(input:checked) { background: var(--ink); color: var(--paper); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field-label { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.field input, .field select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: var(--font-body);
  background: #fff;
  color: var(--text);
}
.field input:focus, .field select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  background: var(--ink);
  color: var(--paper);
}
.btn:hover { opacity: 0.9; }
.btn-block { width: 100%; padding: 12px; }
.btn-link { background: none; border: none; padding: 0; font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn-link:hover { text-decoration: underline; }
.btn-link:disabled { color: var(--muted) !important; opacity: 0.5; cursor: not-allowed; text-decoration: none; }

.error-box { color: var(--red); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.hint-box { border-top: 1px dashed var(--line); padding-top: 12px; color: var(--muted); font-size: 12px; font-family: var(--font-mono); }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { background: var(--ink); width: 230px; flex-shrink: 0; display: flex; flex-direction: column; justify-content: space-between; }
.sidebar-top { padding: 28px 24px; }
.sidebar-top .eyebrow { margin-bottom: 4px; }
.sidebar-top .brand { font-family: var(--font-display); color: var(--paper); font-weight: 700; font-size: 24px; }
.nav { display: flex; flex-direction: column; gap: 4px; padding: 0 12px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  color: #B9C1D9;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.nav-item.active { background: var(--ink-light); color: var(--paper); font-weight: 600; }
.nav-swatch { width: 6px; height: 18px; border-radius: 2px; flex-shrink: 0; }
.sidebar-bottom { padding: 24px; border-top: 1px solid var(--ink-faint); }
.sidebar-user { display: flex; align-items: center; gap: 8px; color: #B9C1D9; margin-bottom: 12px; font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.sidebar-bottom a { color: #B9C1D9; font-size: 14px; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.sidebar-bottom a:hover { text-decoration: underline; }

.main { flex: 1; padding: 32px; max-width: 1200px; }

/* Cards */
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
.card-flat { border: none; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .app { flex-direction: column; }
  .sidebar { width: 100%; }
}

.stat-label { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.stat-value { font-size: 24px; font-weight: 600; }

/* Filter pills */
.pill-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.pill-toggle a { padding: 7px 14px; font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; text-decoration: none; background: #fff; color: var(--text); }
.pill-toggle a.active { background: var(--ink); color: var(--paper); }

/* Table */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead tr { border-bottom: 1px solid var(--line); }
th { text-align: left; padding: 8px 6px; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
td { padding: 8px 6px; border-bottom: 1px solid var(--paper-dark); vertical-align: middle; }
.text-right { text-align: right; }
.empty-row { text-align: center; padding: 24px; color: var(--muted); }

/* Badges */
.badge { display: inline-block; padding: 4px 8px; border-radius: 4px; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.badge-pendente { background: var(--amber-bg); color: var(--amber); }
.badge-pago { background: var(--green-bg); color: var(--green); }
.badge-atrasado { background: var(--red-bg); color: var(--red); }
.badge-mes { background: var(--red-bg); color: var(--red); font-size: 10px; padding: 2px 6px; margin: 2px; display: inline-block; }
.overdue-flag { color: var(--red); margin-left: 4px; }

/* Form rows */
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form-row .field { flex: 1; min-width: 140px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; padding: 9px 0; font-size: 13px; color: var(--muted); }

.month-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 6px; }
@media (max-width: 700px) { .month-grid { grid-template-columns: repeat(4, 1fr); } }
.month-btn { border: 1px solid var(--line); border-radius: 6px; padding: 8px 0; text-align: center; font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; background: #fff; cursor: pointer; }
.month-btn.active { background: var(--red); border-color: var(--red); color: #fff; }

/* Simple CSS bar chart */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 220px; padding-top: 10px; }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-pair { display: flex; gap: 4px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bar { width: 16px; border-radius: 3px 3px 0 0; }
.bar-receita { background: var(--green); }
.bar-despesa { background: var(--amber); }
.bar-label { margin-top: 8px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 16px; margin-top: 12px; font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.section-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.flash-success { background: var(--green-bg); color: var(--green); }
.flash-error { background: var(--red-bg); color: var(--red); }
