/* Zwroty — panel biura: Raport finansowy (Gotówka / Przelew) oraz wykresy SVG (raportFinansowy.css).
 * Dokłada się do styles.css i biuro.css; używa zmiennych Foodie Point (--bg, --surface, --surface-2,
 * --text, --muted, --primary, --line, --line-strong, --fill, --on-fill, --display, --font).
 * Kolory serii wykresów: Gotówka #15803d, Przelew #1d4ed8, Inne #6b7280, Zwroty #d62626. */

:root {
  --rf-cash: #15803d;
  --rf-cash-bg: #e2f2e7;
  --rf-cash-ink: #14532d;
  --rf-bank: #1d4ed8;
  --rf-bank-bg: #dbeafe;
  --rf-bank-ink: #1e3a8a;
  --rf-other: #6b7280;
  --rf-other-bg: var(--surface-2);
  --rf-other-ink: var(--muted);
  --rf-ret: #d62626;
  --rf-ret-bg: #fde5e4;
  --rf-ret-ink: #9f1419;
}

@media (prefers-color-scheme: dark) {
  :root {
    --rf-cash-bg: #112e1d;
    --rf-cash-ink: #6ee7a0;
    --rf-bank-bg: #13254a;
    --rf-bank-ink: #93c5fd;
    --rf-other-bg: #262624;
    --rf-other-ink: #c7c7c0;
    --rf-ret-bg: #3a1213;
    --rf-ret-ink: #ff8a83;
  }
}

.rf-root { min-width: 0; }

/* ---------- siatka 4 kart KPI ---------- */
.rf-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.rf-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.rf-kpi.is-main {
  background: var(--surface-2);
  border-color: var(--line-strong);
  box-shadow: inset 0 -4px 0 var(--fill);
}

.rf-kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rf-kpi-label {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.rf-kpi-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: none;
}

.rf-kpi-dot.is-cash { background: var(--rf-cash); }
.rf-kpi-dot.is-bank { background: var(--rf-bank); }
.rf-kpi-dot.is-ret { background: var(--rf-ret); }

.rf-kpi-val {
  font: 850 1.48rem/1.15 var(--display);
  letter-spacing: -.015em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  overflow-wrap: anywhere;
}

.rf-kpi-sub {
  font-size: .84rem;
  font-weight: 650;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.rf-kpi-meta {
  font-size: .8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

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

@media (max-width: 519px) {
  .rf-kpi-grid { grid-template-columns: 1fr; gap: 8px; }
  .rf-kpi { padding: 11px 13px; }
  .rf-kpi-val { font-size: 1.35rem; }
}

/* ---------- pigułki form płatności i zwrotów ---------- */
.rf-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 750;
  line-height: 1.35;
  white-space: nowrap;
}

.rf-pill.is-cash { background: var(--rf-cash-bg); color: var(--rf-cash-ink); }
.rf-pill.is-bank { background: var(--rf-bank-bg); color: var(--rf-bank-ink); }
.rf-pill.is-other { background: var(--rf-other-bg); color: var(--rf-other-ink); box-shadow: inset 0 0 0 1px var(--line); }
.rf-pill.is-ret { background: var(--rf-ret-bg); color: var(--rf-ret-ink); }
.rf-pill.is-disc { background: var(--warn-bg); color: var(--warn); }

.rf-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex: none;
}

.rf-dot.is-cash { background: var(--rf-cash); }
.rf-dot.is-bank { background: var(--rf-bank); }
.rf-dot.is-other { background: var(--rf-other); }
.rf-dot.is-ret { background: var(--rf-ret); }

/* ---------- wykresy SVG ---------- */
.rf-charts-2col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
  align-items: stretch;
}

.rf-chart-panel {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}

.rf-charts-2col > .rf-chart-panel {
  margin-bottom: 0;
}

.rf-chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  margin-bottom: 10px;
}

.rf-chart-head .bz-h2,
.rf-chart-head .bz-h3 {
  margin: 0;
}

.rf-mini-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  font-size: .8rem;
  font-weight: 650;
  color: var(--muted);
}

.rf-mini-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.rf-svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: var(--font);
  overflow: visible;
}

/* Donut: koło po lewej, legenda po prawej */
.rf-donut-wrap {
  display: grid;
  grid-template-columns: minmax(150px, 200px) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  flex: 1 1 auto;
}

.rf-donut-svg {
  max-width: 200px;
  margin: 0 auto;
}

.rf-donut-center-lbl {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.rf-donut-center-val {
  fill: var(--text);
  font-family: var(--display);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.rf-donut-center-sub {
  fill: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
}

.rf-donut-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.rf-legend-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: center;
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.rf-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.rf-legend-name {
  font-weight: 750;
  font-size: .92rem;
  color: var(--text);
}

.rf-legend-pct {
  font-weight: 800;
  font-size: .88rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.rf-legend-meta {
  grid-column: 2 / 4;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 10px;
  font-size: .84rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.rf-legend-meta strong {
  color: var(--text);
  font-weight: 800;
}

/* Wykres słupkowy dzienny */
.rf-bar-wrap {
  width: 100%;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
}

.rf-bar-svg {
  min-height: 210px;
}

.rf-axis-lbl {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.rf-bar-val-lbl {
  fill: var(--text);
  font-size: 10px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.rf-gridline {
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.rf-axis-base {
  stroke: var(--line-strong);
  stroke-width: 1.2;
}

/* Ranking TOP 8 */
.rf-rank-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rf-rank-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rf-rank-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 10px;
  font-size: .9rem;
}

.rf-rank-left {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 7px;
  min-width: 0;
}

.rf-rank-num {
  color: var(--muted);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.rf-rank-name {
  font-weight: 750;
  color: var(--text);
  overflow-wrap: anywhere;
}

.rf-rank-right {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rf-rank-sub {
  font-size: .8rem;
  color: var(--muted);
  font-weight: 600;
}

.rf-rank-val {
  font-weight: 850;
  color: var(--text);
}

.rf-rank-svg {
  display: block;
  width: 100%;
  height: 10px;
}

@media (max-width: 1023px) {
  .rf-charts-2col { grid-template-columns: 1fr; }
}

@media (max-width: 559px) {
  .rf-donut-wrap {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .rf-donut-svg {
    max-width: 176px;
  }
}

/* ---------- tabele rozliczeniowe wg formy płatności ---------- */
.rf-pay-section {
  margin-bottom: 14px;
}

.rf-pay-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  margin-bottom: 10px;
}

.rf-pay-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1.08rem;
}

.rf-pay-summary {
  font-size: .88rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.rf-pay-summary strong {
  color: var(--text);
  font-weight: 850;
}

.rf-shop-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-top: 2px;
  font-size: .78rem;
  color: var(--muted);
  font-weight: 500;
}

.rf-table th, .rf-table td {
  padding: 9px 8px;
}

.rf-table td.is-brutto {
  font-weight: 850;
}

.rf-grand-total {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
  padding: 14px 16px;
  background: var(--fill);
  color: var(--on-fill);
  border-radius: 14px;
  font-variant-numeric: tabular-nums;
}

.rf-grand-title {
  font: 850 1.05rem/1.2 var(--display);
  letter-spacing: .02em;
  text-transform: uppercase;
}

.rf-grand-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 20px;
  font-size: .92rem;
}

.rf-grand-metric {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.rf-grand-metric span {
  opacity: .78;
  font-size: .82rem;
}

.rf-grand-metric strong {
  font-weight: 850;
}

.rf-grand-metric.is-main strong {
  font-size: 1.2rem;
}

.rf-stats-section {
  margin-top: 14px;
}

.rf-stats-heading {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

/* stopka widoczna tylko na wydruku */
.rf-print-only {
  display: none;
}

@media (max-width: 899px) {
  .rf-table.is-stack tfoot,
  .rf-table.is-stack tfoot tr {
    display: block;
    width: 100%;
  }
  .rf-table.is-stack tfoot tr.bz-total {
    margin-top: 6px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1.5px solid var(--line-strong);
    border-radius: 12px;
  }
  .rf-table.is-stack tfoot th {
    display: block;
    width: 100%;
    padding: 0 0 6px;
    margin-bottom: 4px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    font-size: .95rem;
  }
  .rf-table.is-stack tfoot td {
    background: transparent;
    border: 0;
  }
  .rf-grand-total {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---------- wydruk ---------- */
@media print {
  .rf-sheet,
  .rf-chart-panel,
  .rf-kpi,
  .rf-pill,
  .rf-dot,
  .rf-svg,
  .rf-rank-svg,
  .rf-grand-total,
  .rf-legend-swatch {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .rf-sheet {
    border: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }

  .rf-kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 8pt !important;
    margin-bottom: 10pt !important;
  }

  .rf-kpi {
    padding: 8pt 10pt !important;
    border: 1px solid #999 !important;
    border-radius: 6pt !important;
    break-inside: avoid;
  }

  .rf-kpi-val {
    font-size: 13pt !important;
  }

  .rf-charts-2col {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10pt !important;
    margin-bottom: 10pt !important;
    break-inside: avoid;
  }

  .rf-chart-panel {
    padding: 10pt !important;
    border: 1px solid #bbb !important;
    border-radius: 6pt !important;
    break-inside: avoid;
    margin-bottom: 10pt !important;
  }

  .rf-pay-section {
    padding: 10pt !important;
    border: 1px solid #bbb !important;
    border-radius: 6pt !important;
    break-inside: avoid-page;
    margin-bottom: 10pt !important;
  }

  .rf-pay-section > .bz-tablewrap {
    margin: 0 !important;
    width: 100% !important;
  }

  .rf-table {
    width: 100% !important;
    table-layout: auto !important;
    font-size: 9pt !important;
  }

  .rf-table th, .rf-table td {
    padding: 4pt 5pt !important;
    border: 1px solid #666 !important;
  }

  .rf-grand-total {
    background: #111111 !important;
    color: #ffffff !important;
    padding: 9pt 12pt !important;
    border-radius: 6pt !important;
    break-inside: avoid;
  }

  .rf-print-only {
    display: flex !important;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24pt;
    margin-top: 22pt;
    padding-top: 10pt;
    border-top: 1px solid #999;
    font-size: 9pt;
    color: #333;
    break-inside: avoid;
  }

  .rf-print-sig {
    min-width: 190pt;
    text-align: center;
  }

  .rf-print-sig-line {
    height: 22pt;
    border-bottom: 1px solid #000;
    margin-bottom: 4pt;
  }
}
