/* ── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0d0d;
  --bg2:       #161616;
  --bg3:       #1e1e1e;
  --border:    #2a2a2a;
  --border2:   #333;
  --red:       #c0392b;
  --red-light: #e74c3c;
  --red-dim:   #7d1f17;
  --green:     #27ae60;
  --green-dim: #1a6b3c;
  --text:      #e8e8e8;
  --text-muted:#888;
  --text-dim:  #555;
  --font:      'Segoe UI', system-ui, sans-serif;
  --mono:      'Consolas', 'Courier New', monospace;
  --sidebar-w: 220px;
  --radius:    6px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; }

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
}

.brand {
  padding: 28px 20px 24px;
  border-bottom: 1px solid var(--border);
}
.brand-quad {
  display: block;
  font-size: 22px; font-weight: 800; letter-spacing: 4px;
  color: var(--red-light);
}
.brand-sub {
  display: block;
  font-size: 10px; letter-spacing: 6px;
  color: var(--text-muted); margin-top: 2px;
}

.nav-links { list-style: none; padding: 16px 0; flex: 1; }
.nav-links li { }
.nav-links a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  text-decoration: none; font-size: 13px; font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.nav-links a svg {
  width: 18px; height: 18px; stroke: currentColor; fill: none;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.nav-links a:hover { color: var(--text); background: var(--bg3); }
.nav-links a.active {
  color: var(--red-light);
  border-left-color: var(--red-light);
  background: rgba(192,57,43,.1);
}

.nav-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.btn-print {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 9px 12px;
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text-muted); font-size: 12px; cursor: pointer;
  border-radius: var(--radius); transition: all .15s;
}
.btn-print svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width:1.5; stroke-linecap:round; stroke-linejoin:round; }
.btn-print:hover { color: var(--text); border-color: var(--red); }

/* ── Main content ─────────────────────────────────────────────────────── */
.content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 0;
  display: flex; flex-direction: column;
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 32px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 12px;
}

/* ── Filtros / form ───────────────────────────────────────────────────── */
.filtros { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filtros select, .filtros label {
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 6px 10px; border-radius: var(--radius);
  font-size: 12px; cursor: pointer;
}
.filtros label { display: flex; align-items: center; gap: 6px; }
.filtros label select { border: none; background: transparent; padding: 0; }
.filtros select:focus { outline: none; border-color: var(--red); }

/* ── Filtro de período (De/Até no cabeçalho) ─────────────────────────── */
.periodo-filtro {
  background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius);
  padding: 8px 16px; gap: 18px;
}
.periodo-filtro label {
  background: none; border: none; padding: 0; gap: 8px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted);
}
.periodo-filtro select {
  background: var(--bg); border: 1px solid var(--border2); color: var(--text);
  padding: 6px 12px; font-size: 13px; font-weight: 700; border-radius: 4px;
}
.periodo-filtro select:focus { border-color: var(--red); outline: none; }

.btn-clear {
  background: none; border: 1px solid var(--border2);
  color: var(--text-muted); padding: 6px 10px; border-radius: var(--radius);
  font-size: 11px; cursor: pointer; text-decoration: none;
  transition: all .15s;
}
.btn-clear:hover { color: var(--text); border-color: var(--red); }

/* ── Badges ───────────────────────────────────────────────────────────── */
.badge-pendente {
  background: var(--red-dim); color: #ff9e9e;
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px;
}

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap { padding: 0; overflow-x: auto; }

.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table thead tr {
  background: var(--bg3); border-bottom: 2px solid var(--border2);
}
.data-table th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 700; letter-spacing: .6px;
  color: var(--text-muted); text-transform: uppercase;
}
.data-table th.col-valor { text-align: right; }
.data-table td {
  padding: 9px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: rgba(255,255,255,.025); }

/* row status */
.row-pendente td { opacity: 1; }
.row-classificado td { }
.row-excluido td { opacity: .4; text-decoration: line-through; }

/* col widths */
.col-data   { width: 96px; color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.col-mes    { width: 72px; color: var(--text-muted); font-size: 12px; }
.col-descricao { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-valor  { text-align: right; white-space: nowrap; font-family: var(--mono); }
.col-acao   { width: 80px; text-align: center; }
.col-categoria { width: 220px; }
.col-fonte  { width: 110px; }

/* valores */
.positivo { color: var(--green); }
.negativo { color: var(--red-light); }
.neutro   { color: var(--text-muted); }

/* ── Selects de categoria ─────────────────────────────────────────────── */
.select-cat {
  width: 100%; background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 5px 8px; border-radius: var(--radius);
  font-size: 12px; cursor: pointer;
}
.select-cat:focus { outline: none; border-color: var(--red); }
optgroup { color: var(--text-muted); font-size: 11px; }
option { background: var(--bg2); color: var(--text); }

/* ── Fonte tags ───────────────────────────────────────────────────────── */
.fonte-tag {
  display: inline-block; padding: 2px 8px; border-radius: 3px;
  font-size: 10px; font-weight: 700; letter-spacing: .3px;
}
.fonte-btg_cc     { background: rgba(192,57,43,.2); color: #ff8c8c; border: 1px solid var(--red-dim); }
.fonte-btg_cartao { background: rgba(192,57,43,.15); color: #ffb0a0; border: 1px solid var(--red-dim); }
.fonte-btg_inv    { background: rgba(100,50,150,.25); color: #c0a0ff; border: 1px solid #5a3a8a; }
.fonte-xp         { background: rgba(30,80,160,.25); color: #90b8ff; border: 1px solid #2a50a0; }
.fonte-manual     { background: rgba(40,100,60,.25); color: #80d0a0; border: 1px solid #2a5a3a; }

label.banco-check {
  display: inline-flex; align-items: center; gap: 5px;
  cursor: pointer; user-select: none;
}
label.banco-check input[type="checkbox"] { cursor: pointer; margin: 0; }
.banco-filtros { flex-wrap: wrap; row-gap: 8px; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn-excluir, .btn-restaurar, .btn-edit-valor {
  background: none; border: 1px solid var(--border2);
  color: var(--text-muted); padding: 4px 8px; border-radius: var(--radius);
  font-size: 13px; cursor: pointer; transition: all .15s;
}
.btn-excluir:hover  { border-color: var(--red); color: var(--red-light); }
.btn-restaurar:hover { border-color: var(--green); color: var(--green); }
.btn-edit-valor:hover { border-color: var(--red); color: var(--text); }

/* ── Valor editável ───────────────────────────────────────────────────── */
.valor-editavel { cursor: pointer; }
.sem-valor { color: var(--red-light); font-style: italic; font-size: 11px; }
.input-valor {
  width: 120px; background: var(--bg3); border: 1px solid var(--red);
  color: var(--text); padding: 4px 8px; border-radius: var(--radius);
  font-family: var(--mono); font-size: 13px;
}
.hidden { display: none !important; }

/* ── Tag pendente ─────────────────────────────────────────────────────── */
.tag-pendente {
  display: inline-block;
  color: var(--red-light);
  font-size: 12px;
  margin-right: 5px;
  vertical-align: middle;
  opacity: .9;
}
.row-pendente .col-descricao { border-left: 2px solid var(--red-dim); padding-left: 12px; }

/* ── Empty state ──────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted); font-size: 14px;
}

/* ── DRE ──────────────────────────────────────────────────────────────── */
.dre-wrap { padding: 28px 32px; }
.dre-periodo { color: var(--text-muted); font-size: 12px; margin-bottom: 20px; }

.dre-table { width: 100%; max-width: 680px; border-collapse: collapse; }
.dre-table col.col-label { width: auto; }
.dre-table col.col-valor { width: 180px; }

.dre-table td { padding: 7px 14px; border-bottom: 1px solid var(--border); }
.dre-table .col-valor { text-align: right; font-family: var(--mono); }

.dre-section-header td { font-weight: 700; color: var(--text); background: var(--bg3); padding-top: 14px; }
.dre-section-header.deducao td { color: var(--text-muted); }
.dre-sub td { padding-left: 32px; color: var(--text-muted); font-size: 13px; }
.dre-total td { font-weight: 700; border-top: 2px solid var(--border2); background: var(--bg3); }
.dre-resultado td { font-size: 16px; font-weight: 800; border-top: 2px solid var(--red); background: rgba(192,57,43,.08); }
.dre-margem td { font-weight: 700; color: var(--text-muted); }
.dre-aviso td { color: #e8a000; font-size: 12px; border-top: 1px dashed #553; }

/* ── Charts ───────────────────────────────────────────────────────────── */
.chart-card {
  margin: 16px 32px; padding: 16px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.chart-card-sm {
  margin-bottom: 12px; padding: 12px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── KPI cards ────────────────────────────────────────────────────────── */
.kpi-periodo {
  padding: 16px 32px 0; font-size: 12px; color: var(--text-muted);
}
.kpi-periodo strong { color: var(--text); }
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px;
  padding: 12px 32px 0;
}
.kpi-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 6px;
  position: relative;
}
.kpi-label { font-size: 11px; font-weight: 700; letter-spacing: .6px; color: var(--text-muted); text-transform: uppercase; }
.kpi-value { font-size: 22px; font-weight: 800; font-family: var(--mono); color: var(--text); }
.kpi-var { font-size: 12px; font-weight: 600; }
.kpi-sub { font-size: 11px; color: var(--text-dim); }

/* Tooltip de ajuda (só CSS) nos cards de KPI */
.kpi-info {
  position: absolute; top: 14px; right: 14px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text-muted); font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: help; line-height: 1;
}
.kpi-info:hover { color: var(--text); border-color: var(--red); }
.kpi-info:hover::after {
  content: attr(data-tooltip);
  position: absolute; top: 22px; right: 0;
  width: 220px; background: var(--bg); border: 1px solid var(--border2);
  color: var(--text); font-size: 11px; font-weight: 400; line-height: 1.5;
  padding: 10px 12px; border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
  z-index: 50; text-align: left; text-transform: none; white-space: normal;
}

/* ── Tabela detalhada (Caixa) ─────────────────────────────────────────── */
.tabela-detalhada-card { margin: 0 32px 28px; }
.tabela-detalhada-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.tabela-detalhada-header .cat-card-title { margin-bottom: 0; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Categorias ───────────────────────────────────────────────────────── */
.categorias-wrap { display: flex; flex-direction: column; gap: 24px; padding: 28px 32px; }
.cat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.cat-card-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.cat-table { font-size: 12px; }
.cat-table td { padding: 6px 10px; }

/* Gráfico + lista de totais ao lado (comissão mensal por consultor / comparativo) */
.consultor-mensal-wrap { display: flex; gap: 20px; align-items: flex-start; }
.consultor-mensal-chart { flex: 1 1 auto; min-width: 0; margin-bottom: 0; }
.consultor-totais-side {
  flex: 0 0 200px; display: flex; flex-direction: column; gap: 10px;
  padding: 12px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.consultor-total-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.consultor-total-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.consultor-total-nome { flex: 1 1 auto; color: var(--text-muted); }
.consultor-total-valor { font-family: var(--mono); font-weight: 700; white-space: nowrap; }
.consultor-total-geral {
  padding-top: 10px; margin-top: 2px; border-top: 1px solid var(--border2);
}
.consultor-total-geral .consultor-total-nome { color: var(--text); font-weight: 700; }

@media (max-width: 900px) {
  .consultor-mensal-wrap { flex-direction: column; }
  .consultor-totais-side { flex: 1 1 auto; }
}

/* ── Abas de gráfico (Receita/Despesa mensal) ─────────────────────────── */
.chart-tabs {
  display: flex; gap: 3px; padding: 3px;
  background: var(--bg); border: 1px solid var(--border2); border-radius: 8px;
}
.chart-tab {
  background: transparent; border: none; color: var(--text-muted);
  padding: 8px 18px; border-radius: 6px; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all .15s;
}
.chart-tab:hover { color: var(--text); }
.chart-tab[data-target="receita"].active {
  color: #fff; background: #1f9d55;
  box-shadow: 0 1px 4px rgba(31,157,85,.5);
}
.chart-tab[data-target="despesa"].active {
  color: #fff; background: var(--red);
  box-shadow: 0 1px 4px rgba(192,57,43,.5);
}
.chart-tab[data-view="categoria"].active {
  color: #fff; background: #1f9d55;
  box-shadow: 0 1px 4px rgba(31,157,85,.5);
}
.chart-tab[data-view="banco"].active {
  color: #fff; background: var(--red);
  box-shadow: 0 1px 4px rgba(192,57,43,.5);
}
.chart-card-header {
  display: flex; justify-content: flex-end; margin-bottom: 12px;
}

/* ── Extratos ─────────────────────────────────────────────────────────── */
.extratos-grid { display: flex; flex-direction: column; gap: 24px; padding: 28px 32px; }

.instrucoes-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.instrucoes-card h2, .historico-card h2 {
  font-size: 15px; font-weight: 700; margin-bottom: 20px;
  color: var(--text);
}
.instrucoes-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px;
}
.instrucao-item {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.instrucao-header { margin-bottom: 10px; }
.instrucao-item ul { padding-left: 16px; }
.instrucao-item li { margin-bottom: 5px; line-height: 1.5; color: var(--text-muted); font-size: 12px; }
.instrucao-item strong { color: var(--text); }
.instrucao-item code { background: var(--bg); padding: 1px 5px; border-radius: 3px; font-family: var(--mono); font-size: 11px; color: var(--red-light); }

.instrucao-processo {
  background: rgba(192,57,43,.08); border: 1px solid var(--red-dim);
  padding: 12px 16px; border-radius: var(--radius); font-size: 13px; color: var(--text-muted);
}
.instrucao-processo em { color: var(--text); font-style: normal; font-weight: 600; }
.instrucao-processo code { background: var(--bg3); padding: 1px 6px; border-radius: 3px; font-family: var(--mono); color: var(--red-light); }

.historico-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}

/* ── Contas a Pagar ───────────────────────────────────────────────────── */
.pagamentos-mes-label { font-size: 13px; font-weight: 500; color: var(--text-muted); text-transform: capitalize; }

.btn-nova-conta {
  background: var(--red-dim); border: 1px solid var(--red);
  color: #fff; padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn-nova-conta:hover { background: var(--red); }

.alerta-vencidas {
  margin: 20px 32px 0; padding: 12px 18px;
  background: rgba(192,57,43,.18); border: 1px solid var(--red);
  color: #ffb0a0; border-radius: var(--radius); font-size: 13px;
}
.alerta-vencidas strong { color: #fff; }

.row-vencida td { background: rgba(192,57,43,.08); }
.row-vencida td:first-child { border-left: 3px solid var(--red-light); padding-left: 12px; }
.row-paga td { opacity: .55; }
.row-paga .col-venc, .row-paga .col-valor { text-decoration: line-through; }

.col-venc { white-space: nowrap; cursor: pointer; }
.venc-display { cursor: pointer; }
.input-venc, td .input-valor {
  width: 80px; background: var(--bg3); border: 1px solid var(--red);
  color: var(--text); padding: 4px 8px; border-radius: var(--radius);
  font-family: var(--mono); font-size: 13px;
}
.check-pago { width: 18px; height: 18px; cursor: pointer; accent-color: var(--red); }
td .valor-display { cursor: pointer; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-card {
  background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius);
  padding: 24px; width: 340px; display: flex; flex-direction: column; gap: 14px;
}
.modal-card h3 { font-size: 16px; margin-bottom: 4px; }
.modal-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-muted); }
.modal-card input, .modal-card select {
  background: var(--bg3); border: 1px solid var(--border2); color: var(--text);
  padding: 8px 10px; border-radius: var(--radius); font-size: 13px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.modal-aviso { width: 380px; }
.modal-aviso h3 { color: #ff9e9e; font-size: 15px; }
.aviso-lista { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.aviso-lista li {
  font-size: 13px; padding: 8px 12px;
  background: rgba(192,57,43,.12); border: 1px solid var(--red-dim);
  border-radius: var(--radius); color: var(--text);
}
.modal-aviso .btn-nova-conta { text-decoration: none; display: inline-flex; align-items: center; }

/* ── Assinaturas ──────────────────────────────────────────────────────── */
.assinaturas-kpi-grid { grid-template-columns: repeat(2, 1fr); max-width: 520px; margin-bottom: 8px; }
.assinaturas-table-wrap { padding: 20px 32px 32px; }
.assinaturas-table-wrap .data-table th:first-child,
.assinaturas-table-wrap .data-table td:first-child { padding-left: 0; }
.editavel { cursor: pointer; }
.editavel:hover { background: rgba(255,255,255,.04); }
.input-inline-edit {
  width: 100%; min-width: 60px; background: var(--bg3); border: 1px solid var(--red);
  color: var(--text); padding: 4px 8px; border-radius: var(--radius);
  font-family: var(--mono); font-size: 12px;
}
.col-renov { white-space: nowrap; font-size: 12px; }
.col-obs { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text-muted); }
.select-periodicidade, .select-area, .select-quempaga {
  width: 100%; background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 5px 6px; border-radius: var(--radius);
  font-size: 12px; cursor: pointer;
}

/* ── Print ────────────────────────────────────────────────────────────── */
@media print {
  body { background: white; color: black; }
  .sidebar { display: none; }
  .content { margin-left: 0; }
  .page-header { background: white; border-bottom: 2px solid #c0392b; }
  .page-header h1 { color: #c0392b; }
  .filtros, .btn-print, .col-acao, .select-cat, .btn-excluir, .btn-restaurar { display: none !important; }
  .data-table, .dre-table { color: black; }
  .data-table th, .dre-table td { border-color: #ccc; }
  .positivo { color: #1a7a3f; }
  .negativo { color: #c0392b; }
  .dre-section-header td, .dre-total td, .dre-resultado td { background: #f5f5f5; }
  .chart-card { page-break-inside: avoid; }
}
