/* =====================================================
   PORTAL REDE — Módulo Financeiro
   Segmented control · KPIs · Gráficos CSS/SVG · Score
   ===================================================== */

/* ---------- Cabeçalho do módulo + seletor de visão ---------- */

.fin-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.fin-views {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  padding: 3px;
  gap: 2px;
}
.fin-views a {
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  transition: background-color .2s var(--ease), color .2s var(--ease);
  white-space: nowrap;
}
.fin-views a:hover { color: var(--pine); background: var(--pine-soft); text-decoration: none; }
.fin-views a.on { background: var(--pine); color: #fff; }

/* ---------- Faixa de posição de caixa ---------- */

.cash-strip {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--pine-deep);
  border-radius: var(--radius);
  padding: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.cash-cell {
  flex: 1;
  min-width: 170px;
  padding: 16px 22px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background-color .18s var(--ease);
}
a.cash-cell:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }
.cash-cell .ck {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: rgba(255, 255, 255, .55);
}
.cash-cell .cv {
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  margin-top: 3px;
  white-space: nowrap;
}
.cash-cell .cv.lime { color: var(--lime); }
.cash-cell .cv.red  { color: #FF9B7E; }
.cash-cell .cs { font-size: 12px; color: rgba(255, 255, 255, .55); margin-top: 2px; }
.cash-cell .cs.alert { color: #FF9B7E; font-weight: 600; }

.cash-op {
  display: flex;
  align-items: center;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: rgba(255, 255, 255, .35);
  padding: 0 4px;
}

.cash-cell.result {
  background: rgba(59, 214, 232, .12);
  border: 1px solid rgba(59, 214, 232, .3);
}

@media (max-width: 860px) {
  .cash-op { display: none; }
  .cash-cell { min-width: calc(50% - 6px); }
}

/* ---------- KPIs ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.kpi .k {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-faint);
}
.kpi .v {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 4px;
  color: var(--ink);
}
.kpi .v.pos { color: var(--success); }
.kpi .v.neg { color: var(--danger); }
.kpi .s { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }

/* ---------- Grade do dashboard ---------- */

.fin-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 1000px) { .fin-grid { grid-template-columns: 1fr; } }

/* ---------- Gráfico de barras (faturamento x despesa) ---------- */

.bars-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 220px;
  padding-top: 10px;
}
.bars-month {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  height: 100%;
  min-width: 0;
}
.bars-pair {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  width: 100%;
  height: 100%;
  justify-content: center;
}
.bar {
  width: 38%;
  max-width: 22px;
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: opacity .15s var(--ease);
}
.bar:hover { opacity: .75; }
.bar.rev { background: var(--pine); }
.bar.exp { background: var(--lime); }
.bars-label {
  font-size: 10.5px;
  color: var(--ink-faint);
  white-space: nowrap;
  text-transform: capitalize;
}
.chart-legend {
  display: flex;
  gap: 18px;
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-top: 12px;
}
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Donut (conic-gradient) ---------- */

.donut-wrap { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.donut {
  width: 168px; height: 168px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}
.donut::after {
  content: "";
  position: absolute;
  inset: 34px;
  border-radius: 50%;
  background: var(--surface);
}
.donut-legend { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 9px; }
.donut-legend .dl {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
}
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.donut-legend .dl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend .dl-val { font-weight: 600; white-space: nowrap; }
.donut-legend .dl-pct { color: var(--ink-faint); font-size: 12px; width: 44px; text-align: right; }

/* ---------- Payback por sócio ---------- */

.payback-row { padding: 13px 0; border-bottom: 1px solid var(--line); }
.payback-row:last-child { border-bottom: none; }
.payback-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.payback-top .pname { font-weight: 600; font-size: 14px; flex: 1; }
.payback-top .pval { font-size: 12.5px; color: var(--ink-soft); }
.pb-track {
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--pine-soft);
  border: 1px solid var(--line);
  overflow: hidden;
}
.pb-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--pine);
  transition: width .8s var(--ease);
}
.pb-fill.done { background: var(--success); }
.payback-done {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--success);
}

/* ---------- Insights ---------- */

.insight {
  display: flex;
  gap: 13px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.insight:last-child { border-bottom: none; }
.insight-ico {
  width: 34px; height: 34px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.insight-ico.good { background: var(--success-soft); color: var(--success); }
.insight-ico.bad  { background: var(--danger-soft); color: var(--danger); }
.insight-ico.warn { background: var(--warn-soft); color: var(--warn); }
.insight-ico.info { background: var(--pine-soft); color: var(--pine); }
.insight .it { font-weight: 600; font-size: 14px; }
.insight .ix { font-size: 13px; color: var(--ink-soft); line-height: 1.55; }

/* ---------- Score (velocímetro + scorecard) ---------- */

.score-panel { display: flex; gap: 28px; flex-wrap: wrap; }
.score-gauge { text-align: center; flex-shrink: 0; }
.score-gauge svg { display: block; }
.score-num {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: -56px;
}
.score-grade-label { font-size: 13px; font-weight: 700; margin-top: 0; }

.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  padding: 7px 16px 7px 9px;
  font-weight: 700;
  font-size: 13.5px;
}
.score-badge .medal {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
}

.score-body { flex: 1; min-width: 260px; }
.score-body > p { font-size: 14px; color: var(--ink-soft); line-height: 1.6; margin: 0 0 16px; }

.score-criteria { display: flex; flex-direction: column; gap: 4px; }
.score-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.score-item.ok { color: var(--ink-soft); }
.score-item.miss { background: var(--warn-soft); }
.score-item .si-ico { flex-shrink: 0; margin-top: 2px; }
.score-item.ok .si-ico { color: var(--success); }
.score-item.miss .si-ico { color: var(--warn); }
.score-item .si-label { font-weight: 600; color: var(--ink); }
.score-item .si-pts { margin-left: auto; font-weight: 700; white-space: nowrap; color: var(--ink-faint); font-size: 12.5px; }
.score-item .si-tip { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; line-height: 1.5; }

/* ---------- Pílulas de seleção (tipo / forma de pagamento) ---------- */

.kind-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.kind-pills label {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  padding: 9px 18px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface);
  transition: background-color .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}
.kind-pills label:hover { border-color: var(--pine); color: var(--pine); }
.kind-pills input { display: none; }
.kind-pills label:has(input:checked) {
  background: var(--pine);
  border-color: var(--pine);
  color: #fff;
}

/* ---------- Tabela de lançamentos ---------- */

.fin-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  overflow-x: auto;
}
.fin-tab {
  padding: 9px 16px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
}
.fin-tab:hover { color: var(--pine); text-decoration: none; }
.fin-tab.on { color: var(--pine); border-bottom-color: var(--lime); }

.amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.amount.in { color: var(--success); }
.amount.out { color: var(--ink); }

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
}
.status-pill.paid { background: var(--success-soft); color: var(--success); }
.status-pill.pending { background: var(--warn-soft); color: var(--warn); }
.status-pill.overdue { background: var(--danger-soft); color: var(--danger); }

/* Popover de baixa: modal centrado (não é cortado pela tabela) */
.pay-pop { display: inline-block; }
.pay-pop summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
}
.pay-pop summary::-webkit-details-marker { display: none; }
.pay-pop[open] > .qpop-backdrop {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(13, 27, 20, .45);
}
.pay-pop[open] > .pay-pop-body {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 96;
  width: min(300px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
}
.pay-pop-body .field { margin-bottom: 10px; }
.pay-pop-body label { font-size: 12px; }

/* ---------- DRE / Balancete ---------- */

.report-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.report-table th, .report-table td { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.report-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); }
.report-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.report-table tr.total td { font-weight: 700; border-top: 1px solid var(--line-strong); background: var(--paper); }
.report-table tr.subtotal td { font-weight: 600; }
.report-table tr.result td { font-family: var(--font-display); font-weight: 700; background: var(--pine-soft); }
.report-table .neg { color: var(--danger); }
.report-table .pos { color: var(--success); }
.report-table .indent { padding-left: 30px; color: var(--ink-soft); }

.month-nav { display: flex; align-items: center; gap: 10px; }
.month-nav .mlabel { font-weight: 700; font-family: var(--font-display); font-size: 16px; min-width: 160px; text-align: center; text-transform: capitalize; }

/* ---------- Configurações ---------- */

.fin-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  align-items: start;
}

@media (prefers-reduced-motion: reduce) {
  .pb-fill, .bar { transition: none; }
}
