:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --border: #e3e1da;
  --border-strong: #cfccc3;
  --text: #1b1d1f;
  --muted: #6a6e72;
  --faint: #9a9da0;
  --accent: #1e4d3f;
  --accent-hover: #163b30;
  --accent-soft: #e7efeb;
  --pos: #2d6a4f;
  --neg: #a1392a;
  --neg-soft: #f8ebe8;
  --warn: #8a5d0f;
  --warn-soft: #f7f0e1;
  --info: #2c4f73;
  --info-soft: #e9eff5;
  --radius: 6px;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
p { margin: 0; }
.icon { flex-shrink: 0; vertical-align: middle; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Estrutura */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 600; font-size: 15px; text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 5px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font: 600 13px/1 var(--mono);
}
.company-switch { position: relative; }
.company-switch select {
  width: 100%;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 9px 30px 9px 10px;
  font: 500 13px var(--sans);
  color: var(--text);
  cursor: pointer;
}
.company-switch::after {
  content: '';
  position: absolute; right: 12px; top: 50%;
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding: 14px 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-foot .who { min-width: 0; }
.sidebar-foot .who strong { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .who span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { padding: 28px 36px 64px; min-width: 0; }
.container { max-width: 1120px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: 500 13px var(--sans);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--neg); }
.btn-danger:hover { border-color: var(--neg); background: var(--neg-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-icon { width: 32px; padding: 0; height: 32px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
form.inline { display: inline; }

/* Cartões */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head a { font-size: 12px; color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.card-head a:hover { color: var(--text); }
.card-body { padding: 18px; }
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

.stat { padding: 16px 18px; }
.stat-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat-value { font: 500 24px/1.2 var(--sans); letter-spacing: -0.02em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat-foot { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--muted);
  padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2);
  white-space: nowrap;
}
td { padding: 11px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfbf9; }
td.num, th.num { text-align: right; }
.row-link { text-decoration: none; font-weight: 500; }
.row-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 14px; }

/* Selos */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok, .badge-paga, .badge-pago { color: var(--pos); background: var(--accent-soft); border-color: #cfe0d7; }
.badge-atencao, .badge-pendente, .badge-aberta, .badge-a_vencer { color: var(--warn); background: var(--warn-soft); border-color: #eadbb9; }
.badge-critico, .badge-vencida { color: var(--neg); background: var(--neg-soft); border-color: #eccbc5; }
.badge-em_apuracao, .badge-info { color: var(--info); background: var(--info-soft); border-color: #d2dde9; }
.badge-cancelada { text-decoration: line-through; }

/* Alertas */
.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.alert + .alert { margin-top: 10px; }
.alert .icon { margin-top: 1px; }
.alert strong { display: block; font-weight: 600; margin-bottom: 2px; }
.alert p { color: var(--muted); }
.alert-critico { border-color: #eccbc5; background: var(--neg-soft); }
.alert-critico .icon { color: var(--neg); }
.alert-atencao { border-color: #eadbb9; background: var(--warn-soft); }
.alert-atencao .icon { color: var(--warn); }
.alert-info { border-color: #d2dde9; background: var(--info-soft); }
.alert-info .icon { color: var(--info); }
.flash { margin-bottom: 20px; display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--radius); border: 1px solid; font-weight: 500; }
.flash-ok { background: var(--accent-soft); border-color: #cfe0d7; color: var(--accent); }
.flash-erro { background: var(--neg-soft); border-color: #eccbc5; color: var(--neg); }
.flash-info { background: var(--info-soft); border-color: #d2dde9; color: var(--info); }
.errors { margin: 0 0 20px; padding: 12px 16px 12px 34px; border-radius: var(--radius); background: var(--neg-soft); border: 1px solid #eccbc5; color: var(--neg); }

/* Formulários */
.form-section { padding: 20px 22px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 220px 1fr; gap: 24px; }
.form-section:last-of-type { border-bottom: 0; }
.form-section > header p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 14px; }
.field { display: flex; flex-direction: column; gap: 6px; grid-column: span 6; }
.span-1 { grid-column: span 1; } .span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; }
label, .label { font-size: 12px; font-weight: 500; color: var(--muted); }
.hint { font-size: 12px; color: var(--faint); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=month], input[type=search], select, textarea {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 14px var(--sans);
}
textarea { height: auto; min-height: 80px; padding: 9px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input[readonly] { background: var(--surface-2); color: var(--muted); }
input.money { text-align: right; font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; color: var(--text); font-weight: 400; }
.check input { margin: 3px 0 0; width: 16px; height: 16px; accent-color: var(--accent); }
.form-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.segmented { display: inline-flex; align-self: flex-start; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.segmented a, .segmented label { padding: 7px 14px; font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none; cursor: pointer; border-right: 1px solid var(--border); display: inline-flex; align-items: center; gap: 6px; }
.segmented a:last-child, .segmented label:last-of-type { border-right: 0; }
.segmented a.on, .segmented input:checked + label { background: var(--text); color: #fff; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }

.month-nav { display: inline-flex; align-items: center; gap: 4px; }
.month-nav strong { min-width: 150px; text-align: center; font-weight: 500; display: inline-block; }
.month-nav strong::first-letter { text-transform: uppercase; }

/* Listas de definição */
.dl { display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; text-align: right; }
.dl .total { border-top: 1px solid var(--border); padding-top: 10px; font-weight: 600; }

/* Gráfico */
.chart { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; align-items: end; height: 180px; padding: 8px 4px 0; }
.chart-col { display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; }
.chart-bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.chart-bar { width: 14px; border-radius: 2px 2px 0 0; min-height: 2px; }
.chart-bar.in { background: var(--accent); }
.chart-bar.out { background: #c9c5ba; }
.chart-label { font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.progress { height: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); }

/* Pix e boleto */
.pay-box { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: start; }
.qr { width: 180px; height: 180px; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; background: #fff; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { font-family: var(--mono); font-size: 12px; }
.code-block { font-family: var(--mono); font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; word-break: break-all; }

.summary-line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.summary-line:last-child { border-bottom: 0; }
.summary-line.total { font-weight: 600; font-size: 16px; border-top: 1px solid var(--text); border-bottom: 0; margin-top: 4px; padding-top: 12px; }

.diff { width: 100%; font-size: 13px; }
.diff td { padding: 6px 10px; }
.diff .antes { color: var(--neg); text-decoration: line-through; }
.diff .depois { color: var(--pos); }

/* Público */
.public { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 48px 16px; }
.public .brand { margin-bottom: 28px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .card-body { padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { font-size: 20px; }
.auth-foot { text-align: center; color: var(--muted); margin-top: 18px; font-size: 13px; }
.invoice { width: 100%; max-width: 720px; }
.invoice-head { display: flex; justify-content: space-between; gap: 20px; padding: 24px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.invoice-total { font: 500 30px/1.1 var(--sans); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.powered { margin-top: 24px; font-size: 12px; color: var(--faint); }

.cnpj-hero { max-width: 520px; }
.cnpj-hero input { height: 48px; font: 500 20px var(--mono); letter-spacing: 0.02em; }

.tag { font: 12px var(--mono); color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }

dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(20, 22, 24, 0.35); }

/* Barra superior e gaveta do menu: só existem em telas estreitas */
.topbar, .sidebar-fechar, .menu-fundo { display: none; }
.sidebar-topo { display: flex; align-items: center; justify-content: space-between; }

/* Em todas as grades, minmax(0, 1fr): "1fr" sozinho nunca encolhe abaixo do conteúdo mais largo
   e empurra a página para os lados */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: sticky; top: 0; z-index: 30;
    height: 56px; padding: 0 8px 0 16px;
    background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .topbar .brand { padding: 0; min-width: 0; }
  .topbar-titulo { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Menu vira gaveta lateral */
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
    width: min(300px, 86vw); height: 100%;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 0 0 40px rgba(20, 22, 24, 0.18);
    overflow-y: auto; visibility: hidden;
  }
  .menu-aberto .sidebar { transform: none; visibility: visible; }
  .sidebar-fechar { display: inline-flex; }
  .menu-fundo { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(20, 22, 24, 0.35); }
  .menu-fundo[hidden] { display: none; }
  .nav a { padding: 11px 10px; }
  .menu-aberto { overflow: hidden; }

  .main { padding: 20px 16px 48px; }
  .form-section { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .fields .span-1, .fields .span-2, .fields .span-3, .fields .span-4 { grid-column: span 6; }
  .pay-box { grid-template-columns: minmax(0, 1fr); }
  th, td { padding-left: 12px; padding-right: 12px; }
  .page-head { margin-bottom: 18px; }
  .page-head .actions { width: 100%; }

  /* Tabelas marcadas como responsivas viram cartões: cada célula com seu rótulo */
  .tabela-resp thead { display: none; }
  .tabela-resp, .tabela-resp tbody, .tabela-resp td { display: block; }
  .tabela-resp tr { display: flex; flex-direction: column; padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .tabela-resp tr:last-child { border-bottom: 0; }
  .tabela-resp tbody tr:hover td { background: none; }
  .tabela-resp td { padding: 3px 0; border: 0; text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .tabela-resp td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 500; flex-shrink: 0; }
  .tabela-resp td.num { text-align: right; }
  .tabela-resp td.cel-titulo { display: block; order: -1; padding-bottom: 6px; }
  .tabela-resp td:empty:not(.cel-acoes) { display: none; }
  .tabela-resp td.cel-acoes { justify-content: flex-end; padding-top: 8px; }
  .tabela-resp td.cel-acoes:empty { display: none; }
  .tabela-resp tr.destaque { background: var(--accent-soft); }
}
@media (max-width: 520px) {
  /* Cards de resumo compactos, em duas colunas */
  .grid-4 { gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 18px; margin-top: 4px; overflow-wrap: anywhere; }
  .stat-foot { font-size: 11px; margin-top: 4px; }
  .grid-4 > .card:only-child, .grid-4 > .stat-largo { grid-column: 1 / -1; }
  .col-opcional { display: none; }
  .page-head .actions .btn { flex: 1 1 auto; }
}

/* Telas de toque: alvos maiores, sem alterar o visual no computador */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; padding: 0 12px; }
  .btn-icon { width: 42px; min-width: 42px; height: 42px; }
  .segmented a, .segmented label { padding: 11px 14px; }
  .check input { width: 20px; height: 20px; margin-top: 1px; }
  .check { padding: 4px 0; }
  input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], select { height: 44px; font-size: 16px; }
  textarea { font-size: 16px; }
}

@media print {
  .sidebar, .no-print, .actions { display: none !important; }
  .app { display: block; }
  body, .public { background: #fff; padding: 0; }
  .card { border-color: #ddd; }
}

button.badge { font: 500 12px var(--sans); }
button.badge:hover { filter: brightness(0.97); }

/* Resultado da busca de cliente */
.lookup { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 8px 12px; border-radius: var(--radius); border: 1px solid; }
.lookup::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.lookup-ok { color: var(--accent); background: var(--accent-soft); border-color: #cfe0d7; }
.lookup-warn { color: var(--warn); background: var(--warn-soft); border-color: #eadbb9; }
.lookup-loading { color: var(--muted); background: var(--surface-2); border-color: var(--border); }
.lookup-loading::before { animation: pulso 1s ease-in-out infinite; }
@keyframes pulso { 50% { opacity: .25; } }

/* Autocomplete de clientes */
.ac-wrap { position: relative; }
.ac-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
  margin: 4px 0 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(20, 22, 24, 0.08);
  max-height: 300px; overflow-y: auto;
  min-width: 280px;
}
.ac-list li { padding: 8px 10px; border-radius: 4px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.ac-list li strong { font-weight: 500; font-size: 14px; }
.ac-list li span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ac-list li:hover, .ac-list li.on { background: var(--accent-soft); }
.ac-list mark { background: none; color: inherit; font-weight: 600; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* Logo da empresa */
.logo-uploader { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: start; }
.logo-preview {
  width: 200px; height: 110px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2);
  /* flex com altura fixa: o max-height: 100% da imagem passa a ter referência (no grid era ignorado) */
  display: flex; align-items: center; justify-content: center; text-align: center;
  overflow: hidden;
  font-size: 12px; color: var(--faint);
  padding: 12px;
}
.logo-preview.drag { border-color: var(--accent); background: var(--accent-soft); }
.logo-preview img { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.invoice-logo { display: block; max-width: 180px; max-height: 64px; object-fit: contain; margin-bottom: 14px; }
@media (max-width: 860px) { .logo-uploader { grid-template-columns: 1fr; } }

/* Campo com conteúdo sensível exibido como pontos, sem acionar o gerenciador de senhas */
.mascarado { -webkit-text-security: disc; }

/* Confirmação manual de recebimento */
.confirmar-resumo { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.confirmar-resumo strong { font-size: 18px; font-weight: 600; white-space: nowrap; }
.pendente-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.pendente-item:last-child { border-bottom: 0; }
.pendente-item .info { min-width: 0; }
.pendente-item .info strong { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pendente-item .lado { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.card-atencao { border-color: #eadbb9; }
.card-atencao .card-head { background: var(--warn-soft); border-bottom-color: #eadbb9; border-radius: var(--radius) var(--radius) 0 0; }

/* Tabela de lançamentos: descrição ocupa o espaço livre, ações alinhadas à direita */
.tabela-lanc .col-desc { width: 100%; min-width: 220px; }
.tabela-lanc .col-acoes { white-space: nowrap; text-align: right; }
.tabela-lanc .col-acoes > * { vertical-align: middle; }
.tabela-lanc .col-acoes .btn-sm { margin-right: 4px; }
.btn-icon-espaco { display: inline-block; width: 32px; }


/* Celular e tablet: cada lançamento vira um bloco empilhado */
@media (max-width: 860px) {
  .tabela-lanc thead { display: none; }
  .tabela-lanc, .tabela-lanc tbody { display: block; }
  .tabela-lanc tr { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .tabela-lanc tr:last-child { border-bottom: 0; }
  .tabela-lanc td { display: block; padding: 0; border: 0; }
  .tabela-lanc tbody tr:hover td { background: none; }
  .tabela-lanc .col-desc { grid-column: 1 / -1; order: 1; width: auto; min-width: 0; }
  .tabela-lanc td:nth-child(1) { order: 2; font-size: 13px; }
  .tabela-lanc td:nth-child(4) { order: 3; text-align: right; font-weight: 500; }
  .tabela-lanc td:nth-child(3) { order: 4; }
  .tabela-lanc .col-acoes { order: 5; }
}

/* Tooltip do gráfico do painel */
.chart { position: relative; }
.chart-col { cursor: default; border-radius: 4px; outline: none; transition: background-color .12s; }
.chart-col.ativo { background: var(--surface-2); }
.chart-col:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.chart .chart-bar { transition: opacity .12s; }
.chart.com-foco .chart-col:not(.ativo) .chart-bar { opacity: .35; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  min-width: 180px; padding: 10px 12px;
  background: var(--text); color: #fff; border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(20, 22, 24, 0.18);
  font-size: 12px; line-height: 1.4;
}
.chart-tip strong { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.chart-tip strong::first-letter { text-transform: uppercase; }
.chart-tip .linha { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: tabular-nums; }
.chart-tip .linha span:first-child { display: inline-flex; align-items: center; gap: 6px; color: #c9ccce; }
.chart-tip .linha i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.chart-tip .total { border-top: 1px solid rgba(255, 255, 255, 0.18); margin-top: 6px; padding-top: 6px; font-weight: 600; }
.chart-tip .total .pos { color: #8fd1b0; }
.chart-tip .total .neg { color: #f0a597; }
.chart-tip .nota { margin-top: 6px; color: #c9ccce; }

/* Modal de confirmação de ações destrutivas */
.btn-perigo { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn-perigo:hover { background: #86301f; border-color: #86301f; }
.btn-perigo:disabled { opacity: .45; cursor: not-allowed; pointer-events: auto; }
.dlg-confirmacao { width: min(460px, calc(100vw - 32px)); }
.dlg-confirmacao-corpo { display: flex; gap: 14px; padding: 22px 22px 18px; }
.dlg-confirmacao-corpo h2 { font-size: 16px; margin-bottom: 6px; }
.dlg-confirmacao-corpo p { line-height: 1.5; }
.dlg-confirmacao-icone { flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--neg-soft); color: var(--neg); }
.dlg-confirmacao .field { margin-top: 14px; }
.dlg-confirmacao .field strong { color: var(--text); font-weight: 600; }
dialog[open] { animation: aparece .14s ease-out; }
dialog[open]::backdrop { animation: escurece .14s ease-out; }
@keyframes aparece { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes escurece { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { dialog[open], dialog[open]::backdrop { animation: none; } }

/* Painel: itens aguardando confirmação empilham no celular */
@media (max-width: 520px) {
  .pendente-item { flex-direction: column; align-items: stretch; gap: 10px; }
  .pendente-item .info strong { white-space: normal; }
  .pendente-item .lado { justify-content: space-between; }
  .card-head { flex-wrap: wrap; }
}

/* Tabelas de referência que continuam como tabela no celular: mais estreitas */
@media (max-width: 520px) {
  .tabela-compacta th { white-space: normal; line-height: 1.3; }
  .tabela-compacta th, .tabela-compacta td { padding: 9px 8px; font-size: 13px; }
  .tabela-compacta th:first-child, .tabela-compacta td:first-child { padding-left: 14px; }
  .tabela-compacta th:last-child, .tabela-compacta td:last-child { padding-right: 14px; }
  .stat-largo .month-nav strong { min-width: 0; flex: 1; }
  .stat-largo .month-nav { width: 100%; justify-content: space-between; }
}
