:root {
  --bg: #0f172a;
  --surface: #111827;
  --surface-2: #1e293b;
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #38bdf8;
  --radius: 18px;
}

* { box-sizing: border-box; }

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

button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  padding: 28px 22px;
  background: #0b1220;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
}

.sidebar h1 { margin: 6px 0 10px; }
.sidebar-copy, .sidebar-footer, .eyebrow, .summary-card span { color: var(--muted); }

.eyebrow {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.menu {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.menu-item {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
  color: var(--muted);
  background: transparent;
}

.menu-item:hover, .menu-item.active {
  background: var(--surface-2);
  color: var(--text);
}

.main-content {
  padding: 30px;
  overflow: hidden;
}

.topbar, .section-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 26px;
}

.topbar h2, .panel h3, .section-toolbar h3 { margin: 5px 0 0; }
.topbar-actions, .bill-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.primary-button, .secondary-button, .whatsapp-button {
  border-radius: 12px;
  padding: 11px 14px;
  font-weight: 800;
}

.primary-button {
  border: 0;
  background: var(--primary);
  color: #052e16;
}

.secondary-button {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.whatsapp-button {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
}

.summary-grid, .goals-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.summary-card, .panel, .goal-card, .bill-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.summary-card { padding: 20px; }
.summary-card strong { display: block; margin-top: 12px; font-size: 1.55rem; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
  margin: 16px 0;
}

.panel { padding: 20px; min-width: 0; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 0.82rem; }

.badge, .priority {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.76rem;
  font-weight: 800;
}

.badge.receita, .badge.receber { background: rgba(34, 197, 94, 0.14); color: #86efac; }
.badge.despesa, .badge.pagar { background: rgba(239, 68, 68, 0.14); color: #fca5a5; }
.money.positive { color: #86efac; }
.money.negative { color: #fca5a5; }

.priority.overdue { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.priority.today { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }
.priority.soon { background: rgba(56, 189, 248, 0.14); color: #7dd3fc; }
.priority.future { background: rgba(148, 163, 184, 0.12); color: #cbd5e1; }
.priority.done { background: rgba(34, 197, 94, 0.12); color: #86efac; }

.page-section { display: none; }
.page-section.active { display: block; }

.goal-card { padding: 20px; }
.goal-progress { height: 10px; overflow: hidden; border-radius: 999px; background: var(--surface-2); margin: 15px 0 10px; }
.goal-progress > div { height: 100%; background: var(--primary); }
.goal-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.88rem; }

.cards-list, .agenda-list { display: grid; gap: 12px; }

.bill-card { padding: 18px; }
.bill-card.completed { opacity: 0.66; }
.bill-main { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.bill-main h3 { margin: 10px 0 6px; }
.bill-main p { margin: 0; color: var(--muted); }
.bill-title-row { display: flex; gap: 8px; flex-wrap: wrap; }
.bill-actions { margin-top: 16px; }

.agenda-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0b1220;
}

.agenda-item > div { display: grid; gap: 5px; }
.agenda-item span:not(.priority) { color: var(--muted); font-size: 0.87rem; }

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

dialog {
  width: min(560px, calc(100% - 32px));
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
}

dialog::backdrop { background: rgba(2, 6, 23, 0.76); }
dialog form { padding: 22px; }
.modal-heading { display: flex; justify-content: space-between; align-items: start; margin-bottom: 18px; }
.modal-heading h3 { margin: 5px 0 0; }
.icon-button { border: 0; background: transparent; color: var(--text); font-size: 1.7rem; }

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 14px;
}

input, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0b1220;
  color: var(--text);
  padding: 11px 12px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.full-width { width: 100%; }

.delete-button {
  border: 1px solid var(--border);
  background: transparent;
  color: #fca5a5;
  border-radius: 9px;
  padding: 7px 10px;
}

canvas { max-height: 320px; }

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .summary-grid, .goals-grid, .dashboard-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  .main-content { padding: 18px; }
  .topbar, .section-toolbar { align-items: stretch; flex-direction: column; }
  .topbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .summary-grid, .goals-grid, .dashboard-grid, .form-grid { grid-template-columns: 1fr; }
  .sidebar { padding: 20px 18px; }
  .menu { grid-template-columns: repeat(2, 1fr); }
  .menu-item { text-align: center; padding: 10px 8px; }
  .bill-main, .agenda-item { flex-direction: column; align-items: stretch; }
  .bill-main > strong { font-size: 1.2rem; }
}
