/* =========================================================
   Gestora Pessoal — Design System
   Dark theme dashboard, pastel accent cards
   ========================================================= */

:root {
  --bg: #0b1020;
  --bg-elevated: #10162a;
  --card-bg: #121a2f;
  --card-border: #1f2a44;
  --sidebar-bg: #0a0e1c;
  --text-primary: #f3f5fb;
  --text-secondary: #9aa4bf;
  --text-muted: #6b7590;
  --accent-gold: #f2b53d;
  --accent-gold-dark: #d99a1f;
  --green: #33c17a;
  --green-bg: #d9f5e6;
  --red: #ef5163;
  --red-bg: #fbdde1;
  --purple: #8b7cf6;
  --purple-bg: #e9e5fd;
  --blue: #4c8bf5;
  --blue-bg: #dfeafe;
  --yellow-bg: #fbf0d6;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(0,0,0,0.25);
  --sidebar-width: 250px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ---------- Layout ---------- */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--card-border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}
.sidebar-brand .logo-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.sidebar-brand .brand-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}
.sidebar-brand .brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.nav-group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 6px;
}

.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-link:hover { background: var(--bg-elevated); color: var(--text-primary); }
.nav-link.active {
  background: rgba(242, 181, 61, 0.12);
  color: var(--accent-gold);
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  font-size: 12px;
  color: var(--text-muted);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 60px;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}
.topbar h1 {
  font-size: 28px;
  margin: 0 0 4px;
  font-weight: 800;
}
.topbar .subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.updated-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-secondary);
}
.updated-chip strong { color: var(--text-primary); display:block; font-size: 13px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.user-chip .greet { font-size: 12px; color: var(--text-secondary); }
.user-chip .name { font-weight: 700; font-size: 14px; }

/* ---------- Filters bar ---------- */
.filters-bar {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 24px;
}
.filter-box {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  min-width: 140px;
}
.filter-box label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-gold);
  font-weight: 700;
  margin-bottom: 2px;
}
.filter-box select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 14px;
  width: 100%;
  appearance: none;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-weight: 700;
  font-size: 14px;
  transition: transform .1s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent-gold); color: #1a1300; }
.btn-secondary { background: var(--card-bg); border: 1px solid var(--card-border); color: var(--text-primary); }
.btn-ghost { background: transparent; border: 1px solid var(--card-border); color: var(--text-secondary); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  color: #1a1a2e;
  position: relative;
  overflow: hidden;
}
.stat-card.green { background: var(--green-bg); }
.stat-card.red { background: var(--red-bg); }
.stat-card.purple { background: var(--purple-bg); }
.stat-card.blue { background: var(--blue-bg); }
.stat-card.yellow { background: var(--yellow-bg); }

.stat-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}
.stat-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.6);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.stat-trend {
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}
.stat-trend.up { color: #1a7a43; }
.stat-trend.down { color: #b3222f; }
.stat-trend small { display: block; font-weight: 500; opacity: .7; font-size: 10px; }

.stat-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  opacity: .75;
  margin-bottom: 4px;
}
.stat-value { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.stat-foot { font-size: 12px; opacity: .7; }

/* ---------- Generic panel/card ---------- */
.panel-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1100px) {
  .panel-grid { grid-template-columns: 1fr; }
}
.panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.panel-header h2 { font-size: 16px; margin: 0; font-weight: 700; }
.panel-header .link { font-size: 12px; color: var(--accent-gold); font-weight: 700; }
.panel-header .muted { font-size: 12px; color: var(--text-muted); }

/* category list */
.cat-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--card-border); }
.cat-row:last-child { border-bottom: none; }
.cat-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.cat-info { flex: 1; min-width: 0; }
.cat-info .cat-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.cat-bar-track { height: 6px; border-radius: 4px; background: var(--bg-elevated); overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 4px; }
.cat-amount { text-align: right; font-size: 13px; white-space: nowrap; }
.cat-amount .pct { display: block; font-size: 11px; color: var(--text-muted); }

.total-row { display: flex; justify-content: space-between; padding-top: 14px; margin-top: 6px; border-top: 1px solid var(--card-border); font-weight: 700; }

/* resumo financeiro rows */
.summary-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--card-border); }
.summary-row:last-child { border-bottom: none; }
.summary-row .ic { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.summary-row .label { flex: 1; font-size: 14px; color: var(--text-secondary); }
.summary-row .val { font-weight: 700; font-size: 15px; }
.val.pos { color: var(--green); }
.val.neg { color: var(--red); }

/* goals */
.goal-item { margin-bottom: 16px; }
.goal-item:last-child { margin-bottom: 0; }
.goal-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.goal-top .ic { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.goal-top .title { font-weight: 600; font-size: 14px; }
.goal-bar-track { height: 8px; border-radius: 5px; background: var(--bg-elevated); overflow: hidden; margin-bottom: 6px; }
.goal-bar-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--purple), var(--blue)); }
.goal-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

/* transactions list */
.tx-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--card-border); }
.tx-row:last-child { border-bottom: none; }
.tx-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.tx-icon.in { background: var(--green-bg); color: var(--green); }
.tx-icon.out { background: var(--red-bg); color: var(--red); }
.tx-icon.transfer { background: var(--blue-bg); color: var(--blue); }
.tx-info { flex: 1; min-width: 0; }
.tx-info .tx-name { font-size: 14px; font-weight: 600; }
.tx-info .tx-date { font-size: 12px; color: var(--text-muted); }
.tx-amount { font-weight: 700; font-size: 14px; white-space: nowrap; }
.tx-amount.pos { color: var(--green); }
.tx-amount.neg { color: var(--red); }

/* tip banner */
.tip-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(90deg, rgba(242,181,61,0.14), rgba(242,181,61,0.04));
  border: 1px solid rgba(242,181,61,0.3);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-top: 24px;
}
.tip-banner .tip-icon { font-size: 20px; }
.tip-banner .tip-text { flex: 1; font-size: 14px; }
.tip-banner .tip-text strong { color: var(--accent-gold); }
.tip-banner .chevron { color: var(--text-muted); font-size: 18px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--card-border);
}
table.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--card-border);
  vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: var(--bg-elevated); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge.green { background: var(--green-bg); color: #1a7a43; }
.badge.red { background: var(--red-bg); color: #b3222f; }
.badge.blue { background: var(--blue-bg); color: #2255a8; }
.badge.yellow { background: var(--yellow-bg); color: #8a6d1a; }
.badge.purple { background: var(--purple-bg); color: #5840d6; }
.badge.gray { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--card-border); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 700; color: var(--text-secondary); }
.field input, .field select, .field textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 14px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent-gold);
}

/* ---------- Progress / budget bars ---------- */
.budget-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-lg); padding: 18px; margin-bottom: 14px; }
.budget-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.budget-top .cat { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; }
.budget-top .amounts { font-size: 13px; color: var(--text-secondary); }
.budget-top .amounts strong { color: var(--text-primary); }
.budget-track { height: 10px; border-radius: 6px; background: var(--bg-elevated); overflow: hidden; }
.budget-fill { height: 100%; border-radius: 6px; }
.budget-note { margin-top: 8px; font-size: 12px; color: var(--text-muted); }

/* ---------- Bank connection cards ---------- */
.bank-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap: 16px; }
.bank-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-lg); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.bank-card .bank-top { display: flex; align-items: center; gap: 12px; }
.bank-logo { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; background: var(--bg-elevated); }
.bank-name { font-weight: 700; font-size: 15px; }
.bank-status { font-size: 12px; color: var(--text-muted); }
.bank-balance { font-size: 20px; font-weight: 800; }
.connect-card { border: 2px dashed var(--card-border); display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; padding: 30px 18px; text-align: center; color: var(--text-secondary); }
.connect-card .plus { width: 46px; height: 46px; border-radius: 50%; background: var(--bg-elevated); display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--accent-gold); }

.info-box {
  background: rgba(76,139,245,0.08);
  border: 1px solid rgba(76,139,245,0.3);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.info-box .ic { font-size: 16px; }

.hidden { display: none !important; }

/* ---------- Tarefas ---------- */
.task-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--card-border); }
.task-row:last-child { border-bottom: none; }
.task-check { margin: 0; }
.check-btn {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--text-muted); background: transparent;
  color: #1a1300; font-size: 13px; font-weight: 800; line-height: 1;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.check-btn:hover { border-color: var(--green); background: rgba(51,193,122,.15); }
.task-row.done .check-btn { background: var(--green); border-color: var(--green); }
.task-row.done .task-title { text-decoration: line-through; color: var(--text-muted); }
.task-info { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.task-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; overflow-wrap: anywhere; }
.task-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.task-meta form { margin: 0; }
.task-date { font-size: 12px; color: var(--text-secondary); min-width: 76px; text-align: right; }

/* empty state */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .big-icon { font-size: 36px; margin-bottom: 10px; }

/* responsive */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto; padding: 12px; }
  .sidebar-footer { display: none; }
  .nav-group-label { display: none; }
  .nav-list { flex-direction: row; }
  .main { padding: 20px; }
}
