/* ──────────────────────────────────────────────
   SISTEMA FINANCEIRO — Design tokens + base
   ────────────────────────────────────────────── */
:root {
  --bg:            #f7f6f2;
  --surface:       #f9f8f5;
  --surface-2:     #fbfbf9;
  --surface-off:   #f0ede8;
  --surface-dyn:   #e6e4df;
  --divider:       #dcd9d5;
  --border:        #d4d1ca;
  --text:          #28251d;
  --text-muted:    #7a7974;
  --text-faint:    #b0afa9;
  --text-inv:      #f9f8f4;
  --primary:       #01696f;
  --primary-h:     #0c4e54;
  --success:       #437a22;
  --warning:       #964219;
  --error:         #a13544;
  --blue:          #006494;
  --purple:        #7a39bb;
  --orange:        #da7101;
  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     14px;
  --radius-xl:     18px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.06);
  --shadow:        0 4px 14px rgba(0,0,0,.08);
  --shadow-lg:     0 12px 32px rgba(0,0,0,.12);
  --transition:    160ms cubic-bezier(.16,1,.3,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body { font-family: 'Satoshi', sans-serif; font-size: 15px; background: var(--bg); color: var(--text); line-height: 1.55; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
table { border-collapse: collapse; width: 100%; }

/* ── Layout ──────────────────────────────────── */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 24px 16px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.logo {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), var(--blue));
  color: var(--text-inv); font-weight: 700; font-size: 18px;
  display: grid; place-items: center; flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub  { font-size: 12px; color: var(--text-muted); }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: block; padding: 10px 12px; border-radius: var(--radius);
  color: var(--text); font-size: 14px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--surface-off); text-decoration: none; }
.nav-item.active { background: var(--surface-off); border-color: var(--border); }
.sidebar-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 16px; border-top: 1px solid var(--divider);
  font-size: 13px; color: var(--text-muted);
}
.btn-link { color: var(--error); font-size: 13px; font-weight: 500; }

/* ── Main ────────────────────────────────────── */
.main { padding: 28px; display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 22px; font-weight: 700; }

/* ── Alert / Flash ───────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 500; }
.alert-success { background: rgba(67,122,34,.12); color: var(--success); border: 1px solid rgba(67,122,34,.25); }
.alert-error   { background: rgba(161,53,68,.12);  color: var(--error);   border: 1px solid rgba(161,53,68,.25); }
.alert-warning { background: rgba(150,66,25,.12); color: var(--warning); border: 1px solid rgba(150,66,25,.25); }
.alert-info    { background: rgba(0,100,148,.10); color: var(--blue);    border: 1px solid rgba(0,100,148,.2); }

/* ── Cards ───────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-title { font-size: 13px; font-weight: 700; color: var(--text-muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .04em; }

/* ── Grids ───────────────────────────────────── */
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 16px; }

/* ── KPI ─────────────────────────────────────── */
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.kpi-sub   { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Badge ───────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.badge.success { background: rgba(67,122,34,.13);  color: var(--success); }
.badge.error   { background: rgba(161,53,68,.13);  color: var(--error); }
.badge.warning { background: rgba(150,66,25,.13);  color: var(--warning); }
.badge.blue    { background: rgba(0,100,148,.12);  color: var(--blue); }
.badge.purple  { background: rgba(122,57,187,.12); color: var(--purple); }
.badge.muted   { background: var(--surface-off);   color: var(--text-muted); }

/* ── Tabela ──────────────────────────────────── */
.table-wrap { overflow-x: auto; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--divider); font-size: 13.5px; text-align: left; }
th { color: var(--text-muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-off); }
.td-right { text-align: right; font-variant-numeric: tabular-nums; }
.td-mono  { font-family: monospace; font-size: 12px; }
.credit   { color: var(--success); font-weight: 600; }
.debit    { color: var(--error);   font-weight: 600; }

/* ── Formulários ─────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
input, select, textarea {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(1,105,111,.12);
}
textarea { min-height: 80px; resize: vertical; }

/* ── Botões ──────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 18px; border-radius: var(--radius); border: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-h); text-decoration: none; }
.btn-secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface-off); text-decoration: none; }
.btn-danger { background: var(--error); color: white; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-full { width: 100%; }

/* ── Toolbar / Filtros ───────────────────────── */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.toolbar input, .toolbar select { width: auto; flex: 1; min-width: 140px; }

/* ── Linha de stat ───────────────────────────── */
.stat-line { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--divider); font-size: 14px; }
.stat-line:last-child { border-bottom: none; }

/* Painel de detecção automática OFX */
.detect-box {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

/* ── Account card ────────────────────────────── */
.account-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--surface-2); margin-bottom: 10px;
}
.account-row:last-child { margin-bottom: 0; }
.account-tag { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.account-name { font-weight: 600; font-size: 14px; }
.account-sub  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Misc ────────────────────────────────────── */
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mb-2 { margin-bottom: 12px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 14px; }
.tag-chip { display: inline-block; padding: 4px 9px; border-radius: 999px; background: var(--surface-off); font-size: 11px; font-weight: 600; margin: 2px; }
.divider { border: none; border-top: 1px solid var(--divider); margin: 16px 0; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 1100px) {
  .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: relative; }
  .grid-4, .grid-3, .grid-2, .form-grid { grid-template-columns: 1fr; }
  .main { padding: 16px; }
}
