:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --primary: #4f8cff;
  --primary-hover: #3a78f0;
  --green: #34c759;
  --red: #ff453a;
  --amber: #ff9f0a;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* Garante que o atributo `hidden` funcione mesmo em elementos com display custom
   (ex.: .modal-backdrop usa display:flex, que sobreporia o [hidden] do navegador). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 { margin: 0; font-size: 20px; }

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

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card .label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.card .value { font-size: 22px; font-weight: 600; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card.green .value { color: var(--green); }
.card.red .value { color: var(--red); }
.card.amber .value { color: var(--amber); }

/* Toolbar */
.toolbar { margin-bottom: 14px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
select, input, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }
#filterQ { flex: 1; min-width: 180px; }

/* Table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; }
td.num { font-variant-numeric: tabular-nums; }
.actions-col { text-align: right; width: 1%; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.paid { background: rgba(52,199,89,.15); color: var(--green); }
.badge.pending { background: rgba(255,159,10,.15); color: var(--amber); }
.badge.overdue { background: rgba(255,69,58,.15); color: var(--red); }
.kind-payable { color: var(--red); }
.kind-receivable { color: var(--green); }

/* Buttons */
.btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}
.btn:hover { background: var(--border); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-icon { padding: 6px 9px; margin-left: 4px; }
.btn-danger:hover { background: rgba(255,69,58,.2); border-color: var(--red); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 10; padding: 16px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%; max-width: 480px;
}
.modal h2 { margin: 0 0 16px; font-size: 18px; }
form label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
form label input, form label select, form label textarea { width: 100%; margin-top: 5px; color: var(--text); }
form .row { display: flex; gap: 12px; }
form .row label { flex: 1; }
label.checkbox { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.checkbox input { width: auto; margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.form-error { color: var(--red); font-size: 13px; margin: 0 0 12px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 12px 18px; border-radius: 8px; z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast.error { border-color: var(--red); }
