/* Painel — Caixa, Relatórios e Histórico (classes rp-). Complementa painel.css. */

/* ---------- Estrutura ---------- */
.rp-stack { display: grid; gap: 16px; min-width: 0; }
.rp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; align-items: start; }
.rp-grid > * { min-width: 0; }
.rp-grow { flex: 1 1 0; }
.rp-m0 { margin: 0; }
.rp-center { justify-content: center; }
.rp-err { margin: 0; min-height: 1.2em; color: var(--red); }

/* ---------- Barra do dia / período ---------- */
.rp-daybar, .rp-periodbar .toolbar { row-gap: 10px; }
.rp-periodbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.rp-periodbar .seg { flex-wrap: wrap; max-width: 100%; }
.rp-daybar .btn-icon span, .rp-periodbar .btn-icon span { font-size: 24px; line-height: 1; margin-top: -2px; }
.rp-daylabel { display: grid; line-height: 1.2; min-width: 0; padding: 0 4px; }
.rp-daylabel b { font-family: var(--font-cond); font-weight: 700; font-size: 20px; letter-spacing: .01em; }
.rp-daylabel small { color: var(--muted); font-size: 12px; }
.rp-date { width: auto; min-width: 0; max-width: 11.5rem; color-scheme: dark; }
.rp-range { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.rp-range .field { flex: 1 1 140px; }
.rp-export { justify-content: flex-end; }
.rp-print-head { display: none; }

/* ---------- Textos e números ---------- */
.rp-muted { color: var(--muted); }
.rp-strong { font-weight: 700; }
.rp-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; font-family: var(--font-body); letter-spacing: 0; }
.rp-wrap { white-space: normal; min-width: 14ch; overflow-wrap: anywhere; }
.rp-time { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-money { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-empty-icon { width: 34px; height: 34px; color: var(--gold); opacity: .85; }

/* Botão/link discreto (token, dia) */
.rp-linkbtn, .rp-link { display: inline-block; padding: 4px 0; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: rgba(232, 169, 58, .6); text-underline-offset: 3px; }
.rp-linkbtn.token { font-family: var(--font-mono); font-size: 13px; }
.rp-linkbtn:hover, .rp-link:hover { text-decoration-color: var(--gold); text-decoration-thickness: 2px; }

/* Totais em rodapé de tabela */
.rp-stack .table tfoot th, .rp-stack .table tfoot td { position: static; background: var(--surface-2); color: var(--text); font-size: 14px; font-weight: 700; text-transform: none; letter-spacing: 0; border-top: 1px solid var(--line-strong); border-bottom: 0; white-space: nowrap; }

/* Conta: lista "rótulo ........ valor" */
.rp-calc { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; margin: 0; font-size: 14px; }
.rp-calc dt { color: var(--muted); min-width: 0; }
.rp-calc dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-calc .rp-total { border-top: 1px solid var(--line-strong); padding-top: 8px; margin-top: 2px; font-weight: 700; }
.rp-calc dt.rp-total { color: var(--text); }
.rp-calc-wide { max-width: 620px; }

details.rp-details > summary, details.rp-log > summary { width: fit-content; padding: 6px 0; color: var(--muted); font-size: 13.5px; cursor: pointer; }
details.rp-details > summary:hover, details.rp-log > summary:hover { color: var(--text); }
details.rp-details[open] > summary { margin-bottom: 8px; }

/* ---------- Caixa ---------- */
.rp-cash.is-closed { border-color: rgba(61, 220, 132, .35); }
.rp-badge-open { color: var(--bulb); }
.rp-badge-closed { color: var(--green); }
.rp-movs { display: grid; gap: 8px; }
.rp-movs-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.rp-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.rp-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.rp-list li:last-child { border-bottom: 0; }
.rp-list-main { display: grid; min-width: 0; line-height: 1.3; }
.rp-list-main small { color: var(--muted); overflow-wrap: anywhere; }

.rp-diff { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 2px 12px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--bg); }
.rp-diff > span { grid-column: 1 / -1; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; }
.rp-diff b { font-family: var(--font-cond); font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-diff small { font-size: 13.5px; }
.rp-diff.rp-ok { border-color: rgba(61, 220, 132, .45); }
.rp-diff.rp-sobra { border-color: rgba(108, 180, 255, .45); }
.rp-diff.rp-falta { border-color: rgba(255, 90, 78, .5); background: rgba(255, 90, 78, .06); }

details.rp-log ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; max-height: 220px; overflow-y: auto; font-size: 13px; }

/* ---------- Gráficos ---------- */
.rp-chart { display: grid; gap: 8px; min-width: 0; }
.rp-chart-host { width: 100%; min-width: 0; }
.rp-svg { display: block; }
.rp-svg .rp-axis { stroke: var(--line-strong); }
.rp-svg .rp-val { fill: var(--text); font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rp-hbars .rp-svg .rp-val { font-size: 12px; fill: var(--muted); font-weight: 500; }
.rp-svg .rp-hlabel { fill: var(--text); font-size: 12.5px; }
.rp-svg .rp-track { fill: var(--surface-2); }
.rp-svg .rp-empty-text { fill: var(--muted); font-size: 13px; }
.rp-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: 13px; }
.rp-legend li { display: inline-flex; align-items: center; gap: 6px; }
.rp-sw { width: 12px; height: 12px; border-radius: 3px; background: var(--gold); }
.rp-sw.alt { background: var(--orange); }

/* ---------- Relatórios ---------- */
.rp-extra { display: none; }
.rp-expanded .rp-extra { display: table-row; }
.rp-costs { border-color: rgba(232, 169, 58, .3); }
.rp-est { display: inline-block; vertical-align: middle; margin-left: 4px; padding: 1px 8px; border: 1px solid rgba(232, 169, 58, .6); border-radius: 4px; font-family: var(--font-body); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text); }
.rp-coverage { display: grid; gap: 6px; }
.rp-coverage-text { font-size: 14px; color: var(--muted); }
.rp-coverage-text b { font-family: var(--font-cond); font-size: 22px; color: var(--text); font-variant-numeric: tabular-nums; }
.rp-meter { height: 10px; overflow: hidden; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); }
.rp-meter span { display: block; height: 100%; border-radius: inherit; background: var(--gold); }
.rp-missing { display: grid; gap: 8px; }
.rp-missing ul { margin: 0; padding-left: 18px; columns: 2 260px; column-gap: 28px; color: var(--muted); font-size: 13.5px; }
.rp-missing li { break-inside: avoid; margin-bottom: 2px; }
.rp-missing .btn { justify-self: start; }

/* ---------- Histórico ---------- */
.rp-month { padding: 0; gap: 0; scroll-margin-top: 76px; } /* ?mes= não esconde o mês sob a barra do topo */
.rp-month-sum { list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; padding: 14px 16px; border-radius: var(--radius-lg); cursor: pointer; }
.rp-month-sum::-webkit-details-marker { display: none; }
.rp-month-sum:hover { background: var(--surface-2); }
.rp-month-details[open] > .rp-month-sum { border-bottom: 1px solid var(--line); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.rp-month-name { display: inline-flex; align-items: center; gap: 12px; font-family: var(--font-cond); font-weight: 700; font-size: 20px; letter-spacing: .01em; }
.rp-month-name::before { content: ""; flex: none; width: 8px; height: 8px; border-right: 2px solid var(--gold); border-bottom: 2px solid var(--gold); transform: rotate(-45deg); transition: transform .15s ease; }
.rp-month-details[open] .rp-month-name::before { transform: rotate(45deg); }
.rp-month-meta { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; color: var(--muted); font-size: 13.5px; }
.rp-month-meta b { color: var(--text); font-family: var(--font-cond); font-size: 19px; font-variant-numeric: tabular-nums; }
.rp-month-body { display: grid; gap: 14px; padding: 16px; min-width: 0; }
.rp-month-body > .toolbar { justify-content: flex-end; }

/* Primeira coluna (dia) fixa ao rolar a tabela para o lado no celular */
.rp-days thead th:first-child, .rp-days tbody th, .rp-stack .rp-days tfoot th { position: sticky; left: 0; z-index: 1; }
.rp-days thead th:first-child { z-index: 2; }
.rp-days tbody th { top: auto; background: var(--surface); color: var(--text); font-size: 14px; font-weight: 600; text-transform: none; letter-spacing: 0; white-space: nowrap; }
.rp-days tbody tr.clickable:hover th { background: var(--surface-2); }
.rp-today { margin-left: 6px; color: var(--bulb); border-color: rgba(255, 211, 107, .4); }
.rp-cx { display: inline-grid; padding: 4px 0; line-height: 1.25; color: var(--muted); text-decoration: none; white-space: nowrap; }
.rp-cx span { font-size: 13px; font-weight: 600; }
.rp-cx small { font-size: 11.5px; color: var(--muted); }
.rp-cx:hover span { text-decoration: underline; text-underline-offset: 3px; }
.rp-cx-fechado span, .rp-cx-falta span { color: var(--green); }
.rp-cx-falta small { color: var(--red); }
.rp-cx-aberto span, .rp-cx-pendente span { color: var(--bulb); }
.rp-cx-sem span { font-weight: 500; }

/* ---------- Cores de resultado (por último para prevalecer) ---------- */
.rp-ok { color: var(--green); }
.rp-sobra { color: var(--blue); }
.rp-falta { color: var(--red); }

/* ---------- Celular ---------- */
@media (max-width: 480px) {
  .rp-daylabel b { font-size: 18px; }
  .rp-date { max-width: 10.5rem; }
  .rp-export .hint { width: 100%; }
  .rp-export { justify-content: flex-start; }
  .rp-month-sum { padding: 12px 14px; }
  .rp-month-body { padding: 12px; }
}

/* ---------- Impressão / PDF ---------- */
@media print {
  @page { margin: 12mm; }
  /* Paleta clara só nestas telas: todo var() passa a ter contraste no papel */
  .view[data-view="relatorios"], .view[data-view="caixa"], .view[data-view="historico"] {
    --text: #111; --muted: #4a4a4a; --bg: #fff; --surface: #fff; --surface-2: #f1f1f1;
    --line: #d6d6d6; --line-strong: #9a9a9a; --bulb: #7a5600; --green: #17703f; --red: #b3261e; --blue: #1d5aa0;
    padding: 0; gap: 10px; color: #111;
  }
  .rp-print-head { display: grid; gap: 2px; padding-bottom: 8px; border-bottom: 2px solid #111; }
  .rp-print-head b { font-family: var(--font-display); font-weight: 400; font-size: 22px; text-transform: uppercase; letter-spacing: .01em; }
  .rp-print-head span { font-family: var(--font-cond); font-weight: 700; font-size: 18px; }
  .rp-print-head small { color: #4a4a4a; }
  .rp-stack, .rp-month-body { gap: 10px; }
  .rp-stack .kpi .k-value { color: #111 !important; }
  .rp-report .card, .rp-report .table-wrap, .rp-month .table-wrap { break-inside: auto; }
  .rp-report .card-head { break-after: avoid; }
  .rp-report tr, .kpi, .rp-chart { break-inside: avoid; }
  .table-wrap { overflow: visible; }
  .rp-extra { display: table-row; }
  .notice { background: #fff; border-color: #9a9a9a; color: #111; }
  .notice svg { color: #111; }
  .rp-linkbtn, .rp-link { text-decoration: none; }
  .rp-days tbody th, .rp-stack .rp-days tfoot th { position: static; }
  .rp-meter span, .rp-sw, .rp-svg { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
