/* Paleta — light Apple-ish, dark Nord. Mesma do source_editor com ajustes pra shell. */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --text: #1d1d1f;
  --muted: #6b7280;
  --dim: #9ca3af;
  --border: #d2d2d7;
  --border-soft: #e5e7eb;
  --border-row: #f0f0f0;
  --accent: #0a2a66;
  --accent-text: #ffffff;
  --accent-soft: #dbeafe;
  --pos: #047857;
  --neg: #b91c1c;
  --danger: #b91c1c;
  --shadow: 0 1px 3px rgba(0,0,0,0.05);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #2e3440;            /* nord0 */
  --surface: #3b4252;       /* nord1 */
  --surface-alt: #434c5e;   /* nord2 */
  --text: #eceff4;          /* nord6 */
  --muted: #d8dee9;         /* nord4 */
  --dim: #81a1c1;           /* nord9 */
  --border: #4c566a;        /* nord3 */
  --border-soft: #434c5e;
  --border-row: #3b4252;
  --accent: #5e81ac;        /* nord10 */
  --accent-text: #eceff4;
  --accent-soft: #3b4f6b;
  --pos: #a3be8c;           /* nord14 */
  --neg: #bf616a;           /* nord11 */
  --danger: #bf616a;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  gap: 16px;
}
.brand-link {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.modules {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
}
.mod-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.mod-btn:hover { background: var(--surface-alt); color: var(--text); }
.mod-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}
:root[data-theme="dark"] .mod-btn.active { color: var(--accent-text); }
.topbar-actions {
  display: flex;
  gap: 8px;
}
#btn-theme {
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
#btn-theme:hover { background: var(--surface-alt); }

/* Content */
.content {
  padding: 24px 24px 48px;
  width: 100%;
  margin: 0;
}

h1 { font-size: 20px; margin: 0 0 16px; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 20px 0 10px; font-weight: 600; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }

/* Tables */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  overflow: hidden;
}
table.data th, table.data td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-row);
}
table.data thead th {
  background: var(--surface-alt);
  font-weight: 600;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-alt); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.dim { color: var(--dim); }

/* Grid mensal — lavanderia */
.grid-mes {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  overflow: hidden;
}
.grid-mes th, .grid-mes td {
  padding: 4px 6px;
  text-align: center;
  border-right: 1px solid var(--border-row);
  border-bottom: 1px solid var(--border-row);
}
.grid-mes thead th {
  background: var(--surface-alt);
  color: var(--muted);
  font-weight: 600;
  font-size: 10px;
  position: sticky;
  top: 0;
}
.grid-mes th.peca, .grid-mes td.peca {
  text-align: left;
  font-weight: 500;
  background: var(--surface-alt);
  color: var(--text);
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 130px;
}
.grid-mes thead th.peca { z-index: 2; }
.grid-mes td.qtd { color: var(--text); padding: 0; }
.grid-mes td.qtd input {
  width: 100%;
  min-width: 32px;
  padding: 4px 2px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: center;
  border-radius: 3px;
  -moz-appearance: textfield;
}
.grid-mes td.qtd input::-webkit-outer-spin-button,
.grid-mes td.qtd input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.grid-mes td.qtd input:hover { background: var(--surface); border-color: var(--border-soft); }
.grid-mes td.qtd input:focus { outline: none; background: var(--surface); border-color: var(--accent); }
.grid-mes td.qtd input.dirty { background: #fef9c3; }
:root[data-theme="dark"] .grid-mes td.qtd input.dirty { background: #4a4530; }
.grid-mes td.qtd input.saved { background: #d1fae5; }
:root[data-theme="dark"] .grid-mes td.qtd input.saved { background: #3a4a3a; }
.grid-mes td.qtd input.error { background: #fee2e2; border-color: var(--danger); }
:root[data-theme="dark"] .grid-mes td.qtd input.error { background: #4a3030; border-color: var(--danger); }

.save-indicator.ok { color: var(--pos); }
.save-indicator.err { color: var(--neg); }
.grid-mes th.total, .grid-mes td.total {
  background: var(--surface-alt);
  font-weight: 600;
}
.grid-mes td.total.num { text-align: right; padding-right: 8px; }
.grid-mes tfoot td {
  background: var(--surface-alt);
  font-weight: 600;
  border-top: 2px solid var(--border);
}

/* Resumo */
.metric-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.metric {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 140px;
  box-shadow: var(--shadow);
}
.metric .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.metric .value { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.metric .sub { font-size: 11px; color: var(--dim); margin-top: 2px; }

/* Filters */
.filters { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filters label { font-size: 12px; color: var(--muted); }
.filters select, .filters input {
  padding: 5px 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}

/* Empty / hint */
.hint {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* Wrapper com scroll horizontal pro grid em telas estreitas */
.grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Click targets pra ocultar */
.grid-mes th.dia-head, .grid-mes td.peca {
  cursor: pointer;
  user-select: none;
}
.grid-mes th.dia-head:hover, .grid-mes td.peca:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
:root[data-theme="dark"] .grid-mes th.dia-head:hover,
:root[data-theme="dark"] .grid-mes td.peca:hover { color: var(--accent-text); }

/* Estados de oculto */
.grid-mes tr.row-hidden { display: none; }
.grid-mes .col-hidden { display: none; }

/* Painel de ocultos */
.hidden-panel {
  font-size: 12px;
  position: relative;
}
.hidden-panel summary {
  cursor: pointer;
  color: var(--muted);
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  list-style: none;
  user-select: none;
}
.hidden-panel summary::-webkit-details-marker { display: none; }
.hidden-panel summary::before { content: "▸ "; color: var(--dim); }
.hidden-panel[open] summary::before { content: "▾ "; }
.hidden-panel.has-items summary {
  color: var(--accent);
  border-color: var(--accent);
}
.hidden-body {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
  z-index: 10;
  min-width: 320px;
  max-width: 480px;
}
.hidden-group { margin-bottom: 8px; }
.hidden-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.hidden-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  min-height: 22px;
}
.hidden-chips:empty::after {
  content: "(nenhum)";
  color: var(--dim);
  font-size: 11px;
  font-style: italic;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.chip:hover { background: var(--accent-soft); border-color: var(--accent); }
.chip .x { color: var(--muted); font-weight: bold; font-size: 13px; line-height: 1; }
.chip:hover .x { color: var(--accent); }
.show-all {
  margin-top: 8px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}
.show-all:hover { background: var(--surface-alt); }

/* Grid de reconciliação (peça × dia, células com ditado/pdf) */
.grid-recon {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  overflow: hidden;
}
.grid-recon th, .grid-recon td {
  padding: 4px 6px;
  text-align: center;
  border-right: 1px solid var(--border-row);
  border-bottom: 1px solid var(--border-row);
}
.grid-recon thead th {
  background: var(--surface-alt);
  color: var(--muted);
  font-weight: 600;
  font-size: 10px;
  position: sticky;
  top: 0;
}
.grid-recon th.peca, .grid-recon td.peca {
  text-align: left;
  font-weight: 500;
  background: var(--surface-alt);
  color: var(--text);
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 130px;
}
.grid-recon thead th.peca { z-index: 2; }
.grid-recon td.cell.ok { color: var(--text); }
.grid-recon td.cell.ok.zero { color: var(--dim); opacity: 0.4; }
.grid-recon td.cell.esp-diverge {
  /* Pousada/Lavanderia batem mas Stays discorda — borda amarela leve */
  box-shadow: inset 0 0 0 2px #facc15;
}
.grid-recon td.cell.diff {
  font-weight: 600;
  padding: 2px 3px;
  line-height: 1.1;
}
.grid-recon td.cell.diff .diff-n {
  display: block;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.grid-recon td.cell.diff .diff-pl {
  display: block;
  font-size: 9px;
  font-weight: 400;
  color: var(--dim);
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
}
.grid-recon td.cell.diff.diff-pos {
  /* Lavanderia declara mais → vermelho (auditar) */
  background: rgba(220, 38, 38, 0.12);
  color: var(--neg);
}
.grid-recon td.cell.diff.diff-neg {
  /* Pousada conta mais → verde (a favor) */
  background: rgba(16, 185, 129, 0.12);
  color: var(--pos);
}
:root[data-theme="dark"] .grid-recon td.cell.diff.diff-pos { background: rgba(191, 97, 106, 0.20); }
:root[data-theme="dark"] .grid-recon td.cell.diff.diff-neg { background: rgba(163, 190, 140, 0.18); }

/* Editor de regras */
.grid-regras {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  overflow: hidden;
}
.grid-regras th, .grid-regras td {
  padding: 6px 8px;
  text-align: center;
  border-right: 1px solid var(--border-row);
  border-bottom: 1px solid var(--border-row);
}
.grid-regras thead th {
  background: var(--surface-alt);
  color: var(--muted);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  position: sticky;
  top: 0;
}
.grid-regras .listing-col,
.grid-regras .listing-name {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface-alt);
  min-width: 150px;
  z-index: 1;
}
.grid-regras thead .listing-col { z-index: 2; }
.grid-regras td.num.n-chk { font-variant-numeric: tabular-nums; color: var(--muted); }
.grid-regras td.qtd { padding: 0; min-width: 50px; }
.grid-regras td.qtd input {
  width: 100%;
  padding: 6px 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: center;
  border-radius: 3px;
  -moz-appearance: textfield;
}
.grid-regras td.qtd input::-webkit-outer-spin-button,
.grid-regras td.qtd input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.grid-regras td.qtd input:hover { background: var(--surface); border-color: var(--border-soft); }
.grid-regras td.qtd input:focus { outline: none; background: var(--surface); border-color: var(--accent); }
.grid-regras td.qtd input.dirty { background: #fef9c3; }
:root[data-theme="dark"] .grid-regras td.qtd input.dirty { background: #4a4530; }
.grid-regras td.qtd input.saved { background: #d1fae5; }
:root[data-theme="dark"] .grid-regras td.qtd input.saved { background: #3a4a3a; }
.grid-regras td.qtd input.error { background: #fee2e2; border-color: var(--danger); }
:root[data-theme="dark"] .grid-regras td.qtd input.error { background: #4a3030; }
.grid-recon td.total {
  background: var(--surface-alt);
  font-weight: 600;
}
.grid-recon td.total.delta.pos { color: var(--pos); }
.grid-recon td.total.delta.neg { color: var(--neg); }

/* Bloco WhatsApp */
.wpp-block {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}
.wpp-block textarea {
  width: 100%;
  min-height: 280px;
  max-height: 600px;
  padding: 12px;
  border: none;
  background: var(--surface-alt);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  border-radius: 6px;
  resize: vertical;
  white-space: pre;
}
.wpp-block textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.btn-copy {
  position: absolute;
  top: 18px;
  right: 18px;
  padding: 6px 12px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  z-index: 1;
}
.btn-copy:hover { opacity: 0.9; }
.btn-copy.copied { background: var(--pos); }

.metric .value.pos { color: var(--pos); }
.metric .value.neg { color: var(--neg); }

/* ============ NFs ============ */

/* Variação card — cores condicionais */
.metric.var-pos .value { color: var(--pos); }
.metric.var-neg .value { color: var(--neg); }
.metric.var-neutral .value { color: var(--muted); }

/* Card destaque (Total IRPF) — full width */
.metric-card-irpf {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin: 12px 0 16px;
  padding: 16px 20px;
}
.metric-card-irpf .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.metric-card-irpf .value-xl {
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--text);
}
.metric-card-irpf .sub {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}

/* Chart cards */
.chart-card { margin-top: 12px; }
.chart-card h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.chart-card h2 .hint-inline {
  font-weight: 400;
  color: var(--dim);
  font-size: 11px;
  margin-left: 8px;
}

/* Grid de 2 charts lado a lado (top fornec + top itens) */
.chart-grid {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
}
.chart-grid > .chart-card { margin-top: 0; }

/* Barras horizontais */
.bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bar-link {
  text-decoration: none;
  color: inherit;
  display: block;
}
.bar-link:hover .bar-fill { filter: brightness(1.1); }
.bar-link:hover .bar-label { color: var(--accent); }
.bar-row {
  display: grid;
  grid-template-columns: minmax(140px, 28%) 1fr 90px;
  gap: 10px;
  align-items: center;
  padding: 2px 0;
  font-size: 12px;
}
.bar-label {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.bar-label .bar-sub {
  color: var(--dim);
  font-size: 11px;
  margin-left: 4px;
}
.bar-track {
  background: var(--surface-alt);
  border-radius: 3px;
  height: 14px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: filter 0.15s, width 0.2s;
}
.bar-value {
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}

/* Barras verticais (timeline) */
.vbars {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  height: 200px;
  padding: 8px 0 0;
  overflow: visible;
}
.vbar-link {
  text-decoration: none;
  color: inherit;
  flex: 1 0 32px;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.vbar-link:hover .vbar-fill { filter: brightness(1.15); }
/* Tooltip CSS imediato — visível só no hover, posicionado acima da barra */
.vbar-link { position: relative; }
.vbar-tt {
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: #2e3440; color: #eceff4;
  padding: 8px 12px; border-radius: 6px;
  font-size: 11px; white-space: nowrap;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 6px 16px rgba(0,0,0,.30);
  opacity: 0; pointer-events: none; transition: opacity .12s;
  z-index: 10;
}
.vbar-tt::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: #2e3440;
}
.vbar-tt-multi .tt-lbl { color: #d8dee9; opacity: .75; }
.vbar-tt-multi .var-pos { color: #a3be8c; }
.vbar-tt-multi .var-neg { color: #bf616a; }

/* Tooltip CSS imediato pras barras horizontais (top categorias / payees) */
.bar-row { position: relative; }
.bar-tt {
  position: absolute; bottom: calc(100% + 4px); left: 16px;
  background: #2e3440; color: #eceff4;
  padding: 6px 10px; border-radius: 6px;
  font-size: 11px; white-space: nowrap;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 6px 16px rgba(0,0,0,.30);
  opacity: 0; pointer-events: none; transition: opacity .12s;
  z-index: 10;
}
.bar-row:hover .bar-tt { opacity: 1; }
.vbar-link:hover .vbar-tt { opacity: 1; }
/* Tooltip multi-linha (usado no timeline mensal: 3 linhas label/valor) */
.vbar-tt.vbar-tt-multi {
  display: flex; flex-direction: column; gap: 4px; align-items: stretch;
  white-space: normal; min-width: 180px; text-align: left;
}
.vbar-tt-multi strong { font-size: 12px; margin-bottom: 2px; }
.vbar-tt-multi .tt-row { display: flex; justify-content: space-between; gap: 12px; }
.vbar-tt-multi .tt-lbl { color: var(--muted); }
/* Paginador de faturas */
.fat-pager {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 10px; font-size: 12px;
}
.fat-pager a { color: var(--accent); text-decoration: none; }
.fat-pager a:hover { text-decoration: underline; }
.fat-pager .pager-disabled { color: var(--muted); opacity: .5; cursor: not-allowed; }
.vbar {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  flex: 1 0 24px;
  position: relative;
}
.vbar:hover .vbar-fill { filter: brightness(1.15); }
.vbar:hover .vbar-tt { opacity: 1; }
.vbar-fill {
  background: var(--accent);
  width: 70%;
  min-height: 1px;
  border-radius: 2px 2px 0 0;
  transition: filter 0.15s, height 0.2s;
}
.vbar-label {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.vbar-label-yr {
  font-size: 9px;
  color: var(--dim);
}

/* Filtros — form principal */
.filters label { display: inline-flex; align-items: center; gap: 6px; }
.filters button.btn-primary {
  padding: 6px 14px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.filters button.btn-primary:hover { filter: brightness(1.08); }

/* Chips de filtro aplicado nos drill-downs (não confundir com .chip do hidden-panel) */
.nfs-chip {
  display: inline-block;
  padding: 3px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 10px;
  font-size: 11px;
  margin-right: 4px;
  font-variant-numeric: tabular-nums;
}
:root[data-theme="dark"] .nfs-chip { color: var(--accent-text); }

/* ============ Heatmap (Financeiro) ============ */
.hm-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table.hm {
  border-collapse: separate;
  border-spacing: 2px;
  font-size: 11px;
  background: transparent;
}
table.hm th.hm-cat {
  text-align: left;
  font-weight: 500;
  color: var(--text);
  padding: 0 10px 0 0;
  min-width: 180px;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.hm th.hm-mes {
  font-weight: 400;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
  padding: 2px;
  min-width: 28px;
  line-height: 1.1;
}
table.hm th.hm-mes .hm-mes-m { display: block; font-weight: 600; color: var(--text); }
table.hm th.hm-mes .hm-mes-y { display: block; color: var(--dim); font-size: 9px; }
table.hm td.hm-cell {
  width: 28px;
  height: 26px;
  border-radius: 3px;
  padding: 0;
  position: relative;
  cursor: pointer;
}
table.hm td.hm-empty {
  background: var(--surface-alt);
  cursor: default;
}
table.hm td.hm-cell:hover { outline: 1.5px solid var(--accent); outline-offset: -1px; }
.hm-link {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
  position: absolute;
  top: 0; left: 0;
}

/* Presence grid — sim/não (✓ no mês que teve) */
table.hm-presence td.hm-present {
  text-align: center;
  vertical-align: middle;
  color: white;
  font-weight: 600;
  font-size: 12px;
}
table.hm-presence td.hm-present .hm-mark {
  position: relative;
  z-index: 1;
  pointer-events: none;
}
table.hm-presence th.hm-cat .hm-cat-sub {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
}

/* Legenda de cores (recorrências por budget) */
.rec-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
  font-size: 11px;
  color: var(--muted);
}
.rec-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.rec-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.rec-legend-label {
  font-weight: 500;
  color: var(--text);
  margin-right: 4px;
}

/* ============ v5 — Paginação ============ */
.pager {
  display: flex;
  gap: 4px;
  justify-content: center;
  align-items: center;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  flex-wrap: wrap;
}
.pager-btn {
  padding: 4px 10px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text);
  border-radius: 4px;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  text-align: center;
}
.pager-btn:hover { background: var(--surface-alt); text-decoration: none; }
.pager-btn.current {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  font-weight: 600;
  cursor: default;
}
.pager-btn.disabled {
  color: var(--dim);
  background: transparent;
  border-color: var(--border-soft);
  cursor: default;
}
.pager-gap { color: var(--dim); padding: 0 4px; }

/* ============ v5 — Edição inline categoria ============ */
.cat-cell {
  white-space: nowrap;
  display: table-cell;
}
.cat-icon {
  font-size: 11px;
  margin-right: 4px;
  cursor: help;
}
.cat-select, .cat-input {
  padding: 2px 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 3px;
  font-size: 11px;
  font-family: inherit;
  width: 160px;
}
.cat-select:hover, .cat-input:hover {
  border-color: var(--border-soft);
  background: var(--surface);
}
.cat-select:focus, .cat-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  width: 220px;
}
.cat-input::placeholder { color: var(--dim); font-style: italic; }
.cat-cell.saved { background: rgba(16, 185, 129, 0.15); }
.cat-cell.error { background: rgba(220, 38, 38, 0.15); }

/* ============ v5 — Conciliação persistente ============ */
.conc-table .conc-row.confirmed {
  background: rgba(16, 185, 129, 0.06);
}
.conc-table .conc-row.confirmed td {
  color: var(--dim);
}
.conc-cell {
  white-space: nowrap;
  text-align: right;
}
.conc-status.confirmed {
  color: var(--pos);
  font-size: 11px;
  font-weight: 600;
  margin-right: 4px;
}
.btn-confirm, .btn-undo {
  padding: 3px 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
}
.btn-confirm { color: var(--pos); border-color: var(--pos); }
.btn-confirm:hover { background: var(--pos); color: var(--accent-text); }
.btn-undo:hover { background: var(--surface-alt); }

/* ============ v6.1 — KPI link + bulk-edit bar ============ */
.metric-link {
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.metric-link:hover {
  background: var(--surface-alt);
  border-color: var(--accent);
}
.metric-link:hover .value { color: var(--accent); }

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 12px;
  flex-wrap: wrap;
}
.bulk-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 110px;
}
.bulk-bar select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  min-width: 200px;
}
.bulk-bar button {
  padding: 4px 12px;
  font-size: 12px;
}
.bulk-bar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.bulk-status { color: var(--muted); font-size: 11px; }

.drill-table input.bulk-tx { cursor: pointer; }
#bulk-select-all { cursor: pointer; }

/* ============ v6.4 — NFs órfãs (candidatos próximos) ============ */
.orphans-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.orphan-nf {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}
.orphan-nf-line {
  display: grid;
  grid-template-columns: 90px 1fr 100px 130px 100px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border-soft);
}
.orphan-date { font-variant-numeric: tabular-nums; font-weight: 600; }
.orphan-emitente { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orphan-ent { font-size: 11px; }
.orphan-valor { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.orphan-valor.neg { color: var(--neg); }
.orphan-chave { text-align: right; font-size: 11px; }

.orphan-cand {
  display: grid;
  grid-template-columns: 16px 90px 100px 1fr 100px 100px auto;
  gap: 10px;
  align-items: center;
  font-size: 11px;
  padding: 5px 0 5px 12px;
  border-bottom: 1px solid var(--border-row);
}
.orphan-cand:last-child { border-bottom: none; }
.orphan-cand.confirmed { background: rgba(16, 185, 129, 0.06); }
.orphan-cand.confirmed > * { color: var(--dim); }
.cand-arrow { color: var(--dim); }
.cand-date { font-variant-numeric: tabular-nums; }
.cand-diff { font-variant-numeric: tabular-nums; font-size: 10px; }
.cand-payee { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cand-budget { font-size: 10px; }
.cand-valor.neg { color: var(--neg); text-align: right; font-variant-numeric: tabular-nums; }
.cand-action { white-space: nowrap; text-align: right; }

.orphan-empty {
  padding: 8px 0 0 16px;
  font-size: 11px;
  color: var(--dim);
  font-style: italic;
}

/* ============ v6.5 — Tag manual editável (NFs) ============ */
.tags-cell {
  display: table-cell;
  white-space: normal;
  min-width: 200px;
  max-width: 280px;
  line-height: 1.6;
}
.nfs-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 3px 1px 6px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 10px;
  font-size: 10px;
  margin: 1px 2px 1px 0;
  font-variant-numeric: tabular-nums;
}
:root[data-theme="dark"] .nfs-tag-chip { color: var(--accent-text); }
.nfs-tag-chip > span:first-child { padding-right: 2px; }
.tag-remove {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 12px;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.6;
  font-family: inherit;
}
.tag-remove:hover { opacity: 1; color: var(--neg); }
.tag-add-input {
  display: inline-block;
  width: 80px;
  padding: 1px 4px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  font-size: 10px;
  font-family: inherit;
  margin-left: 2px;
}
.tag-add-input:focus {
  outline: none;
  border-style: solid;
  border-color: var(--accent);
  background: var(--surface);
  width: 140px;
}
.tag-add-input::placeholder { color: var(--dim); }

/* Toggle de peças adicionais (reconciliação) */
.grid-recon tr.row-extra.hidden-extra { display: none; }
.grid-recon tr.toggle-row td { user-select: none; }
.grid-recon tr.toggle-row td:hover { background: var(--accent-soft); }

/* ─── Pluggy sync page ─── */
.sync-banner { padding: 10px 14px; border-radius: 8px; margin: 10px 0;
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  background: var(--surface-2, #f7f7f8); border: 1px solid var(--border-soft); }
.sync-banner.sync-running { background: rgba(59,130,246,.08); border-color: rgba(59,130,246,.25); }
.sync-banner.sync-ok      { background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.25); }
.sync-banner.sync-err     { background: rgba(220,38,38,.08); border-color: rgba(220,38,38,.25); }
.sync-banner .spinner {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: sync-spin .8s linear infinite;
}
@keyframes sync-spin { to { transform: rotate(360deg); } }
table.data tr.stale td { background: rgba(220,38,38,.06); }
table.data tr.stale strong { color: var(--neg); }
/* Pluggy↔banco com erro (CRÍTICO — reconectar): vermelho mais forte */
table.data tr.row-bank-error td { background: rgba(220,38,38,.14); }
table.data tr.row-bank-error strong { color: var(--neg); }
table.data tr.row-bank-error td:first-child {
  border-left: 3px solid var(--neg);
}
/* Pluggy↔banco apenas stale (>24h) — laranja/aviso */
table.data tr.row-bank-stale td { background: rgba(234,179,8,.10); }
table.data tr.row-bank-stale td:first-child {
  border-left: 3px solid #d97706;
}
button.btn-sync-item,
button.btn-reconnect,
button.btn-delete-item {
  font-size: 11px; padding: 3px 8px; border-radius: 6px;
  border: 1px solid var(--border-soft); background: var(--surface); cursor: pointer;
  margin-left: 4px;
}
button.btn-sync-item:hover:not([disabled]),
button.btn-reconnect:hover:not([disabled]) { background: var(--accent-soft); }
button.btn-delete-item:hover:not([disabled]) { background: rgba(220,38,38,.10); border-color: var(--neg); }
button.btn-sync-item[disabled],
button.btn-reconnect[disabled],
button.btn-delete-item[disabled] { opacity: .5; cursor: wait; }
button.btn-reconnect { background: rgba(59,130,246,.08); border-color: rgba(59,130,246,.30); }
a.btn-pluggy-link {
  display: inline-block; font-size: 11px; padding: 3px 8px; border-radius: 6px;
  border: 1px solid rgba(59,130,246,.30); background: rgba(59,130,246,.08);
  color: inherit; text-decoration: none; margin-left: 4px;
}
a.btn-pluggy-link:hover { background: rgba(59,130,246,.18); }
#btn-sync-all { font-size: 13px; padding: 8px 16px; border-radius: 8px;
  border: none; background: var(--accent); color: #fff; cursor: pointer; font-weight: 500;
  white-space: nowrap; }
#btn-sync-all:hover:not([disabled]) { filter: brightness(1.08); }
#btn-sync-all[disabled] { opacity: .5; cursor: wait; }
.sync-log { display: none; max-height: 300px; overflow: auto; font-size: 11px;
  background: var(--surface-alt, #2e3440); color: #d8dee9; padding: 10px;
  border-radius: 8px; white-space: pre-wrap; margin-top: 12px; }
.sync-log.show { display: block; }
.sync-erro summary { cursor: pointer; color: var(--neg); font-size: 11px; }
.sync-erro pre { font-size: 11px; background: var(--surface-alt); color: #eee;
  padding: 8px; border-radius: 4px; white-space: pre-wrap; margin: 4px 0 0; max-width: 400px; }

/* ─── Reconnect modal (custom MFA flow, sem SDK) ─── */
.reconnect-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
  padding: 20px;
}
.reconnect-modal[hidden] { display: none; }
.reconnect-box {
  background: var(--surface); border-radius: 12px; padding: 24px 28px;
  max-width: 480px; width: 100%; max-height: 90vh; overflow: auto;
  position: relative; box-shadow: 0 12px 40px rgba(0,0,0,.4);
}
.reconnect-close {
  position: absolute; top: 8px; right: 12px; background: none; border: none;
  font-size: 24px; cursor: pointer; color: var(--muted); padding: 4px 8px;
}
.reconnect-close:hover { color: var(--text); }
.reconnect-box h2 { margin: 0 0 16px; font-size: 16px; }
.reconnect-status { font-size: 13px; color: var(--muted); margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px; }
.reconnect-status.rc-progress  { color: #3b82f6; }
.reconnect-status.rc-input     { color: var(--text); font-weight: 500; }
.reconnect-status.rc-success   { color: var(--pos); font-weight: 500; }
.reconnect-status.rc-error-status { color: var(--neg); }
.reconnect-error {
  background: rgba(220,38,38,.10); border: 1px solid rgba(220,38,38,.30);
  color: var(--neg); padding: 10px 12px; border-radius: 6px; font-size: 12px; margin-top: 12px;
}
.rc-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.rc-label { font-size: 12px; font-weight: 600; color: var(--text); }
.rc-assist { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.rc-form input, .rc-form select {
  padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border-soft);
  background: var(--surface); color: var(--text); font-size: 13px;
}
.rc-form input:focus, .rc-form select:focus { outline: 2px solid var(--accent); }
.rc-qr {
  display: block; max-width: 280px; width: 100%; margin: 8px auto;
  background: #fff; padding: 12px; border-radius: 8px;
}
.rc-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.rc-submit {
  background: var(--accent); color: #fff; border: none; padding: 8px 16px;
  border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500;
}
.rc-submit:hover:not([disabled]) { filter: brightness(1.08); }
.rc-submit[disabled] { opacity: .5; cursor: wait; }

/* ─── Saldos por conta ─── */
table.saldos-table { font-size: 12px; }
table.saldos-table td { padding: 6px 10px; }
table.saldos-table tr.saldo-ent-row td {
  background: var(--surface-alt, rgba(0,0,0,.04));
  border-top: 1px solid var(--border-soft);
  font-size: 11px; text-transform: uppercase; letter-spacing: .03em;
}
/* Conta picker no extrato — trigger + popover com bloco saldos */
.conta-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.conta-picker-label {
  font-size: 11px;
  color: var(--muted);
}
.conta-picker-trigger {
  font: inherit;
  font-size: 12px;
  padding: 5px 10px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text);
  border-radius: 5px;
  cursor: pointer;
  min-width: 220px;
  max-width: 320px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  text-align: left;
}
.conta-picker-trigger:hover {
  border-color: var(--border);
  background: var(--surface-alt);
}
.conta-picker-trigger[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--surface-alt);
}
.conta-picker-trigger .conta-current {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.conta-picker-caret {
  color: var(--muted);
  font-size: 10px;
  flex-shrink: 0;
}
.conta-picker-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 100;
  width: min(440px, calc(100vw - 32px));
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
  padding: 12px;
}
.conta-picker-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
}
.conta-picker-all {
  font-size: 12px;
  color: var(--accent);
}
.conta-picker-close {
  font: inherit;
  font-size: 14px;
  padding: 0 6px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.conta-picker-close:hover { color: var(--text); }

/* Pie/donut chart + legend lateral (usado em Top payees) */
.pie-wrap {
  display: grid;
  grid-template-columns: minmax(140px, 200px) 1fr;
  gap: 14px;
  align-items: center;
}
.pie-svg { width: 100%; height: auto; max-width: 200px; }
.pie-svg .pie-slice path,
.pie-svg path {
  transition: opacity 0.12s ease, transform 0.12s ease;
  transform-origin: 100px 100px;
}
.pie-svg .pie-slice:hover path,
.pie-svg path:hover { opacity: 0.85; transform: scale(1.02); }
.pie-total-lbl {
  font-size: 9px;
  fill: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pie-total-val {
  font-size: 13px;
  font-weight: 600;
  fill: var(--text);
  font-variant-numeric: tabular-nums;
}
.pie-legend {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  max-height: 240px;
  overflow-y: auto;
}
.pie-leg-row {
  display: grid;
  grid-template-columns: 8px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 3px 4px;
  border-radius: 4px;
  color: inherit;
  text-decoration: none;
}
.pie-leg-row:hover {
  background: var(--surface-alt);
  text-decoration: none;
}
.pie-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pie-leg-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.pie-leg-pct {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 10px;
  min-width: 36px;
  text-align: right;
}
.pie-leg-val {
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  color: var(--text);
  min-width: 64px;
  text-align: right;
}
@media (max-width: 700px) {
  .pie-wrap { grid-template-columns: 1fr; }
  .pie-svg { max-width: 180px; margin: 0 auto; }
}

/* Header row do bloco saldos (h2 + botão sync à direita) */
.block-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.block-header-row > h2 { margin: 0; flex: 1; min-width: 0; }
.btn-sync-saldos {
  font: inherit;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.btn-sync-saldos:hover:not(:disabled) {
  background: var(--surface-alt);
  border-color: var(--border);
}
.btn-sync-saldos:disabled {
  opacity: 0.65;
  cursor: wait;
}
.btn-sync-saldos.spinning {
  background: var(--accent-soft, rgba(59,130,246,.12));
  border-color: var(--accent);
  color: var(--accent);
}

/* Header colapsável de transações futuras — extrato detalhado */
.futures-block {
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 6px;
  margin-bottom: 14px;
  overflow: hidden;
  background: rgba(99, 102, 241, 0.04);
}
.futures-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: rgba(99, 102, 241, 0.08);
  border: none;
  border-bottom: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  font: inherit;
  text-align: left;
  color: rgb(67, 56, 202);
}
.futures-header:hover { background: rgba(99, 102, 241, 0.14); }
.futures-block[data-futures-state="expanded"] .futures-header {
  background: rgba(99, 102, 241, 0.18);
  border-bottom-color: rgba(99, 102, 241, 0.3);
}
.futures-badge {
  display: inline-block;
  padding: 3px 10px;
  background: rgb(99, 102, 241);
  color: white;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  min-width: 90px;
  text-align: center;
}
.futures-title { font-weight: 600; }
.futures-count {
  display: inline-block;
  padding: 2px 9px;
  background: rgb(99, 102, 241);
  color: white;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.futures-sum {
  font-size: 12px;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}
.futures-body { padding: 0; }
.futures-body table.data { border-radius: 0; border: none; }
.futures-body table.data tbody tr { background: rgba(99, 102, 241, 0.05); }
.futures-body table.data tbody tr:hover { background: rgba(99, 102, 241, 0.12); }
:root[data-theme="dark"] .futures-block { background: rgba(165, 180, 252, 0.06); border-color: rgba(165, 180, 252, 0.3); }
:root[data-theme="dark"] .futures-header { background: rgba(165, 180, 252, 0.12); color: #c7d2fe; }
:root[data-theme="dark"] .futures-block[data-futures-state="expanded"] .futures-header { background: rgba(165, 180, 252, 0.22); }
:root[data-theme="dark"] .futures-body table.data tbody tr { background: rgba(165, 180, 252, 0.06); }

/* Variante âmbar — órfãs (compras sem fatura) na view de Faturas */
.futures-block.orfas-block { border-color: rgba(217, 119, 6, 0.35); background: rgba(217, 119, 6, 0.05); }
.futures-block.orfas-block .futures-header { background: rgba(217, 119, 6, 0.10); color: rgb(146, 64, 14); }
.futures-block.orfas-block .futures-header:hover { background: rgba(217, 119, 6, 0.16); }
.futures-block.orfas-block[data-futures-state="expanded"] .futures-header {
  background: rgba(217, 119, 6, 0.20); border-bottom-color: rgba(217, 119, 6, 0.35);
}
.futures-block.orfas-block .futures-badge,
.futures-block.orfas-block .futures-count { background: rgb(217, 119, 6); }
.futures-block.orfas-block .futures-body table.data tbody tr { background: rgba(217, 119, 6, 0.05); }
.futures-block.orfas-block .futures-body table.data tbody tr:hover { background: rgba(217, 119, 6, 0.12); }
:root[data-theme="dark"] .futures-block.orfas-block { background: rgba(251, 191, 36, 0.06); border-color: rgba(251, 191, 36, 0.3); }
:root[data-theme="dark"] .futures-block.orfas-block .futures-header { background: rgba(251, 191, 36, 0.12); color: #fcd34d; }
:root[data-theme="dark"] .futures-block.orfas-block[data-futures-state="expanded"] .futures-header { background: rgba(251, 191, 36, 0.22); }
:root[data-theme="dark"] .futures-block.orfas-block .futures-body table.data tbody tr { background: rgba(251, 191, 36, 0.06); }

/* Sync indicator (dot colorido antes do nome da conta) */
.sync-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  cursor: help;
  background: var(--sync-gray, #9ca3af);
}
.sync-dot.sync-green  { background: var(--sync-ok,   #16a34a); }
.sync-dot.sync-yellow { background: var(--sync-warn, #d97706); }
.sync-dot.sync-red    { background: var(--sync-err,  #dc2626); }
:root[data-theme="dark"] .sync-dot.sync-green  { background: #4ade80; }
:root[data-theme="dark"] .sync-dot.sync-yellow { background: #fbbf24; }
:root[data-theme="dark"] .sync-dot.sync-red    { background: #f87171; }

.sync-age {
  font-size: 10px;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
  cursor: help;
  color: var(--muted);
}
.sync-age.sync-age-green  { color: var(--sync-ok,   #16a34a); }
.sync-age.sync-age-yellow { color: var(--sync-warn, #d97706); font-weight: 500; }
.sync-age.sync-age-red    { color: var(--sync-err,  #dc2626); font-weight: 600; }
:root[data-theme="dark"] .sync-age.sync-age-green  { color: #4ade80; }
:root[data-theme="dark"] .sync-age.sync-age-yellow { color: #fbbf24; }
:root[data-theme="dark"] .sync-age.sync-age-red    { color: #f87171; }

table.saldos-table .saldo-conta-cell { padding-left: 22px; }
table.saldos-table .saldo-conta-cell a { color: inherit; text-decoration: none; }
table.saldos-table .saldo-conta-cell a:hover { color: var(--accent); }
table.saldos-table tr.saldo-current td {
  background: var(--accent-soft, rgba(59,130,246,.08));
  font-weight: 500;
}
table.saldos-table tr.saldo-total-row td {
  border-top: 2px solid var(--border-soft);
  font-size: 13px; background: var(--surface);
}
/* Coluna 'Pend.' compacta — só conta número ou ✅, não precisa de largura cheia */
table.saldos-table th.pend-col, table.saldos-table td.pend-col {
  width: 48px; padding-left: 4px; padding-right: 8px;
  text-align: right; white-space: nowrap;
}
.saldos-tabs .saldos-tab-nav {
  display: flex; gap: 4px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
}
.saldos-tabs .saldos-tab-btn {
  background: none; border: none; cursor: pointer;
  padding: 8px 12px; font-size: 12px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-family: inherit;
}
.saldos-tabs .saldos-tab-btn:hover { color: var(--text); }
.saldos-tabs .saldos-tab-btn.active {
  color: var(--text); border-bottom-color: var(--accent);
  font-weight: 500;
}
.saldos-tabs .saldos-tab-panel { display: none; }
.saldos-tabs .saldos-tab-panel.active { display: block; }

/* ============================================================
   Layout editor — grid 12-col com blocos reordenáveis
   ============================================================ */
.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.page-header-title { display: flex; flex-direction: column; gap: 2px; }
.page-header-sub {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  flex-wrap: wrap;
}
.page-header-actions .header-link { font-size: 11px; color: var(--muted); }
.page-header-actions .header-link:hover { color: var(--accent); }
.page-header-actions button {
  font: inherit;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.page-header-actions button:hover { background: var(--surface-alt); border-color: var(--border); }
.page-header-actions button[hidden] { display: none; }
.page-header-actions .layout-done-btn {
  background: var(--accent);
  color: var(--accent-text, #fff);
  border-color: var(--accent);
  font-weight: 500;
}
.page-header-actions .layout-done-btn:hover {
  background: var(--accent);
  filter: brightness(1.12);
}
.layout-edit-btn.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* === GridStack customização (12 cols × rows de 60px) === */
.grid-stack {
  margin-top: 12px;
  /* GridStack adiciona suas próprias variáveis CSS — não precisa template-columns */
}
.grid-stack-item > .grid-stack-item-content {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  inset: 0;
  /* GridStack faz height: 100% via absolute positioning */
}
.grid-stack-item-content > .block-inner {
  padding: 16px;
  height: 100%;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  /* Scrollbar fina e discreta — só aparece quando conteúdo realmente overflowa */
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 0.2s ease;
}
.grid-stack-item-content > .block-inner:hover {
  scrollbar-color: var(--border) transparent;
}
.grid-stack-item-content > .block-inner::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.grid-stack-item-content > .block-inner::-webkit-scrollbar-track {
  background: transparent;
}
.grid-stack-item-content > .block-inner::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
  transition: background 0.2s ease;
}
.grid-stack-item-content > .block-inner:hover::-webkit-scrollbar-thumb {
  background: var(--border);
}
.grid-stack-item-content > .block-inner::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}
.grid-stack-item-content > .block-inner > h2 {
  margin: 0 0 12px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.grid-stack-item-content > .block-inner > h2 .hint-inline {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 6px;
}
/* KPI blocks: a .metric interna assume largura total. */
.grid-stack-item-content > .block-inner > .metric,
.grid-stack-item-content > .block-inner > .metric-link {
  display: block;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
  box-shadow: none;
  background: transparent;
}

/* Botão de esconder bloco — visível só em edit mode, canto superior direito */
.block-hide-btn {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--neg);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  line-height: 1;
  z-index: 10;
  padding: 0;
  align-items: center;
  justify-content: center;
}
.grid-stack.edit-mode .block-hide-btn { display: inline-flex; }
.block-hide-btn:hover { background: var(--surface-alt); }

/* Edit mode: outline tracejado em cada bloco */
.grid-stack.edit-mode .grid-stack-item > .grid-stack-item-content {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}
.grid-stack.edit-mode .grid-stack-item:hover > .grid-stack-item-content {
  outline-style: solid;
}
/* Conteúdo interno não captura cliques/drags em edit mode */
.grid-stack.edit-mode .grid-stack-item-content > .block-inner {
  pointer-events: none;
  user-select: none;
}

/* GridStack: customizar visual do handle de resize (canto inferior-direito) */
.grid-stack-item > .ui-resizable-se {
  background: var(--accent);
  border-radius: 0 0 7px 0;
  opacity: 0.7;
  width: 14px;
  height: 14px;
}
.grid-stack-item > .ui-resizable-se::before { display: none; }
.grid-stack-item > .ui-resizable-se:hover { opacity: 1; }

/* Drag placeholder (ghost mostrando alvo) */
.grid-stack-placeholder > .placeholder-content {
  background: var(--accent-soft, rgba(59, 130, 246, 0.15));
  border: 2px dashed var(--accent);
  border-radius: 8px;
}

/* Painel de blocos ocultos */
.hidden-blocks-panel {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--surface-alt);
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.hidden-blocks-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 8px;
}
.hidden-blocks-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.hidden-blocks-list .hidden-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  cursor: pointer;
  color: var(--text);
}
.hidden-blocks-list .hidden-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.hidden-blocks-list .hidden-chip::before {
  content: "+";
  color: var(--muted);
  font-weight: 600;
}
