:root {
  --cor-primaria: #6366f1;
  --cor-primaria-forte: #818cf8;
  --cor-fundo: #0c0d12;
  --cor-superficie: #14151d;
  --cor-superficie-2: #191b25;
  --cor-superficie-hover: #1f212c;
  --cor-texto: #eceef4;
  --cor-texto-suave: #8b8fa3;
  --cor-texto-fraco: #5c5f70;
  --cor-borda: #24262f;
  --cor-borda-forte: #33353f;
  --verde: #34d399;
  --amarelo: #fbbf24;
  --vermelho: #f87171;
  --azul: #60a5fa;
  --roxo: #a78bfa;
  --sombra-card: 0 1px 2px rgba(0,0,0,.3), 0 0 0 1px rgba(255,255,255,.02);
  --sombra-hover: 0 8px 30px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.04);
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--cor-fundo);
  color: var(--cor-texto);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 12% 0%, rgba(99,102,241,.10), transparent 40%),
    radial-gradient(circle at 90% 15%, rgba(167,139,250,.06), transparent 35%);
  background-attachment: fixed;
}

h1, h2, h3, h4, h5, h6 { letter-spacing: -.02em; font-weight: 650; }

a { transition: color .12s ease; }

::selection { background: rgba(99,102,241,.35); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--cor-borda-forte); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #454857; }

.app-wrapper { display: flex; min-height: 100vh; }

/* ---------- SIDEBAR ---------- */
.sidebar {
  width: 246px;
  background: var(--cor-superficie);
  border-right: 1px solid var(--cor-borda);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: fixed;
  height: 100vh;
  z-index: 10;
}

.sidebar-brand {
  font-weight: 700;
  font-size: 1.05rem;
  padding: 4px 22px 22px;
  color: var(--cor-texto);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -.01em;
}

.sidebar-brand img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: invert(1) brightness(1.6);
}

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 1px; padding: 0 12px; }

.sidebar-nav a {
  padding: 9px 12px;
  color: var(--cor-texto-suave);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 500;
  border-radius: 9px;
  display: flex;
  align-items: center;
  position: relative;
  transition: background .12s ease, color .12s ease;
}
.sidebar-footer a {
  padding: 9px 12px;
  color: var(--cor-texto-suave);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 500;
  border-radius: 9px;
  display: flex;
  align-items: center;
  transition: background .12s ease, color .12s ease;
}

.sidebar-nav a i, .sidebar-footer a i { width: 18px; margin-right: 10px; font-size: .8rem; opacity: .75; }

.sidebar-nav a:hover { background: var(--cor-superficie-hover); color: var(--cor-texto); }

.sidebar-nav a.active {
  background: color-mix(in srgb, var(--cor-primaria) 16%, transparent);
  color: var(--cor-primaria-forte);
  font-weight: 600;
}
.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--cor-primaria-forte);
  border-radius: 0 3px 3px 0;
}
.sidebar-nav a.active i { opacity: 1; }

.sidebar-footer { padding: 12px 12px 0; margin-top: 8px; border-top: 1px solid var(--cor-borda); }

/* ---------- CONTENT ---------- */
.content {
  margin-left: 246px;
  padding: 30px 36px 60px;
  width: calc(100% - 246px);
}

.card-lumo {
  background: var(--cor-superficie);
  border: 1px solid var(--cor-borda);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: var(--sombra-card);
  margin-bottom: 20px;
  transition: box-shadow .18s ease, border-color .18s ease, transform .18s ease;
}
.card-lumo:hover { box-shadow: var(--sombra-hover); border-color: var(--cor-borda-forte); transform: translateY(-1px); }

.kpi-value { font-size: 1.55rem; font-weight: 700; letter-spacing: -.01em; color: var(--cor-texto); }
.kpi-label { font-size: 0.78rem; color: var(--cor-texto-suave); margin-bottom: 8px; font-weight: 500; }

.kpi-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: .92rem; margin-bottom: 12px;
}

.kpi-card { transition: background .2s ease, border-color .2s ease; }
.kpi-card.is-positivo { background: color-mix(in srgb, var(--verde) 8%, var(--cor-superficie)); border-color: color-mix(in srgb, var(--verde) 30%, var(--cor-borda)); }
.kpi-card.is-negativo { background: color-mix(in srgb, var(--vermelho) 8%, var(--cor-superficie)); border-color: color-mix(in srgb, var(--vermelho) 30%, var(--cor-borda)); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
}
.pill::before { content:''; width:6px; height:6px; border-radius:50%; background: currentColor; flex-shrink: 0; }

.table-lumo { color: var(--cor-texto); }
.table-lumo th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--cor-texto-suave); border-bottom: 1px solid var(--cor-borda); font-weight: 600; padding-bottom: 10px; background: transparent; }
.table-lumo td { vertical-align: middle; font-size: 0.87rem; padding-top: 12px; padding-bottom: 12px; border-color: var(--cor-borda); }
.table-lumo tbody tr { transition: background .1s ease; }
.table-lumo tbody tr:hover { background: var(--cor-superficie-hover); }
.table-lumo tbody tr.is-pago { background: color-mix(in srgb, var(--verde) 7%, transparent); }
.table-lumo tbody tr.is-inadimplente { background: color-mix(in srgb, var(--vermelho) 7%, transparent); }
.table > :not(caption) > * > * { background: transparent; color: var(--cor-texto); }

.btn { border-radius: 9px; font-size: .86rem; font-weight: 500; transition: all .12s ease; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--cor-primaria); border-color: var(--cor-primaria); }
.btn-primary:hover { background: var(--cor-primaria-forte); border-color: var(--cor-primaria-forte); box-shadow: 0 4px 14px color-mix(in srgb, var(--cor-primaria) 45%, transparent); transform: translateY(-1px); }
.btn-outline-primary { color: var(--cor-primaria-forte); border-color: var(--cor-primaria); }
.btn-outline-primary:hover { background: var(--cor-primaria); color: #fff; }
.btn-outline-secondary { color: var(--cor-texto-suave); border-color: var(--cor-borda-forte); }
.btn-outline-secondary:hover { background: var(--cor-superficie-hover); color: var(--cor-texto); border-color: var(--cor-borda-forte); }
.btn-outline-success { color: var(--verde); border-color: color-mix(in srgb, var(--verde) 45%, transparent); }
.btn-outline-success:hover { background: var(--verde); color: #06251a; }
.btn-outline-danger { color: var(--vermelho); border-color: color-mix(in srgb, var(--vermelho) 45%, transparent); }
.btn-outline-danger:hover { background: var(--vermelho); color: #2a0b0b; }
.btn-outline-warning { color: var(--amarelo); border-color: color-mix(in srgb, var(--amarelo) 45%, transparent); }
.btn-close { filter: invert(1) grayscale(1) brightness(1.6); }

.form-control, .form-select {
  border-radius: 9px; border-color: var(--cor-borda-forte); font-size: .89rem;
  background: var(--cor-fundo); color: var(--cor-texto);
}
.form-control:focus, .form-select:focus {
  border-color: var(--cor-primaria); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cor-primaria) 25%, transparent);
  background: var(--cor-fundo); color: var(--cor-texto);
}
.form-control::placeholder { color: var(--cor-texto-fraco); }
.form-label { font-size: .82rem; font-weight: 500; color: var(--cor-texto-suave); margin-bottom: 6px; }
.form-select option { background: var(--cor-superficie); color: var(--cor-texto); }
.form-check-input { background-color: var(--cor-fundo); border-color: var(--cor-borda-forte); }
.form-check-input:checked { background-color: var(--cor-primaria); border-color: var(--cor-primaria); }
.input-group-text { background: var(--cor-superficie-hover); border-color: var(--cor-borda-forte); color: var(--cor-texto-suave); }

.insight-item { padding: 9px 0; border-bottom: 1px dashed var(--cor-borda); font-size: 0.87rem; display:flex; gap:8px; align-items:flex-start; color: var(--cor-texto); }
.insight-item:last-child { border-bottom: none; }

.section-title {
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -.01em;
  color: var(--cor-texto);
}

.badge-grupo { font-size: 0.7rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.badge-fixa { background: color-mix(in srgb, var(--cor-primaria) 18%, transparent); color: var(--cor-primaria-forte); }
.badge-variavel { background: color-mix(in srgb, var(--amarelo) 18%, transparent); color: var(--amarelo); }

.tag-recorrente { background: color-mix(in srgb, var(--verde) 18%, transparent); color: var(--verde); font-size:.72rem; font-weight:600; padding:2px 9px; border-radius:999px; }
.tag-avulso { background: color-mix(in srgb, var(--azul) 18%, transparent); color: var(--azul); font-size:.72rem; font-weight:600; padding:2px 9px; border-radius:999px; }

.scenario-item { display:flex; align-items:center; justify-content:space-between; padding:8px 0; border-bottom:1px solid var(--cor-borda); font-size:.86rem; }
.scenario-item:last-child { border-bottom:none; }

/* ---------- linha de despesa arrastavel ---------- */
.despesa-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease;
}
.despesa-row:hover { background: var(--cor-superficie-hover); border-color: var(--cor-borda); }
.despesa-row.dragging { opacity: .4; }
.despesa-row.is-pago { background: color-mix(in srgb, var(--verde) 7%, transparent); border-color: color-mix(in srgb, var(--verde) 25%, var(--cor-borda)); }
.despesa-row .drag-handle { cursor: grab; color: var(--cor-texto-fraco); font-size: .85rem; padding: 4px; }
.despesa-row .drag-handle:active { cursor: grabbing; }

a:focus-visible, button:focus-visible, .btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--cor-primaria-forte);
  outline-offset: 2px;
}

.icon-btn {
  width: 28px; height: 28px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--cor-borda-forte); background: var(--cor-fundo); color: var(--cor-texto-suave);
  font-size: .74rem; transition: all .12s ease; cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { border-color: var(--cor-primaria); color: var(--cor-primaria-forte); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.danger:hover { border-color: var(--vermelho); color: var(--vermelho); }
.icon-btn.success-on { background: color-mix(in srgb, var(--verde) 18%, transparent); border-color: color-mix(in srgb, var(--verde) 45%, transparent); color: var(--verde); }
.icon-btn.danger-on { background: color-mix(in srgb, var(--vermelho) 18%, transparent); border-color: color-mix(in srgb, var(--vermelho) 45%, transparent); color: var(--vermelho); }

.date-editable { border: none; background: transparent; font-size: .82rem; color: var(--cor-texto-suave); padding: 2px 4px; border-radius: 6px; cursor: pointer; }
.date-editable:hover { background: var(--cor-superficie-hover); }
.date-editable::-webkit-calendar-picker-indicator { filter: invert(.6); }

.funil-etapa { background: var(--cor-fundo); border: 1px solid var(--cor-borda); border-radius: 12px; padding: 14px; text-align: center; }
.funil-etapa input { text-align: center; font-size: 1.3rem; font-weight: 700; border: none; background: transparent; width: 100%; color: var(--cor-primaria-forte); }
.funil-etapa input:focus { outline: none; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 4px;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cor-primaria), var(--roxo)); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; flex-shrink: 0;
}
.user-chip .user-name { font-size: .82rem; font-weight: 600; color: var(--cor-texto); line-height: 1.1; }
.user-chip .user-role { font-size: .72rem; color: var(--cor-texto-suave); }

.period-caption { font-size: .78rem; color: var(--cor-texto-suave); }

.modal-content { background: var(--cor-superficie); border: 1px solid var(--cor-borda); color: var(--cor-texto); }
.modal-header, .modal-footer { border-color: var(--cor-borda); }
.progress { background: var(--cor-fundo) !important; }
.alert-success { background: color-mix(in srgb, var(--verde) 15%, transparent); color: var(--verde); border-color: color-mix(in srgb, var(--verde) 30%, transparent); }
.alert-danger { background: color-mix(in srgb, var(--vermelho) 15%, transparent); color: var(--vermelho); border-color: color-mix(in srgb, var(--vermelho) 30%, transparent); }

.text-success { color: var(--verde) !important; }
.text-danger { color: var(--vermelho) !important; }
.text-warning { color: var(--amarelo) !important; }
.text-primary { color: var(--cor-primaria-forte) !important; }
.text-muted { color: var(--cor-texto-suave) !important; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.content > .card-lumo, .content > .row { animation: fadeInUp .28s ease both; }

@media print {
  .sidebar, .no-print { display: none !important; }
  .content { margin-left: 0 !important; width: 100% !important; padding: 0 !important; }
  body { background: #fff !important; color: #111 !important; }
  .card-lumo { background: #fff !important; border-color: #ddd !important; color: #111 !important; box-shadow: none !important; }
  .text-success { color: #0f9d63 !important; } .text-danger { color: #d13c3c !important; } .text-primary { color: #4338ca !important; } .text-muted { color: #555 !important; }
}

@media (max-width: 900px) {
  .sidebar { position: static; width: 100%; height: auto; }
  .content { margin-left: 0; width: 100%; padding: 20px; }
  .app-wrapper { flex-direction: column; }
}
