:root {
  color-scheme: light;
  --surface-0: #f3f8f4;
  --surface-1: #ffffff;
  --surface-2: #e7f1e9;
  --border: #dbe7dd;
  --border-strong: #bcd3c1;
  --text-primary: #1c1c1c;
  --text-secondary: #62687a;
  --text-muted: #9296ab;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(28,28,40,.07), 0 1px 2px rgba(28,28,40,.05);

  /* Paleta marki Zielona Przychodnia: #53C063 (zieleń znaku) i #085440 (ciemna zieleń).
     Odcienie pomocnicze przyciemnione tak, by tekst spełniał kontrast AA na białym tle. */
  --c-violet: #0f7a52;  /* marka ZP — ciemna zieleń #085440 rozjaśniona do AA na białym */
  --c-indigo: #0b6b6b;  /* morska zieleń — druga barwa serii */
  --c-blue:   #2f74c4;  /* Snow "Secondary/Blue" #b1e3ff family */
  --c-teal:   #1d8a6a;
  --c-green:  #2f8f3f;  /* #53C063 przyciemnione do AA */
  --c-amber:  #a67a1e;
  --c-orange: #c1642f;
  --c-pink:   #b85a92;
  --c-red:    #c94f4f;

  --accent: var(--c-violet);
  --good: var(--c-green);
  --bad: var(--c-red);
  --series-1: var(--c-blue);   /* przychody */
  --series-2: var(--c-orange); /* koszty */
  --series-3: var(--c-teal);   /* dochód */
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #101613;
  --surface-1: #18211c;
  --surface-2: #202b24;
  --border: #2a3a30;
  --border-strong: #3b5044;
  --text-primary: #f5f5f7;
  --text-secondary: #b7b9c6;
  --text-muted: #83858f;
  --shadow: 0 4px 22px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);

  --c-violet: #6fd189;  /* jaśniejszy wariant #53C063 na ciemnym tle */
  --c-indigo: #6fd1c4;
  --c-blue:   #7ec1f2;  /* Snow "Secondary/Blue" #b1e3ff */
  --c-teal:   #5cd6be;
  --c-green:  #7ee38f;
  --c-amber:  #e0b95c;
  --c-orange: #f0966a;
  --c-pink:   #ef9dc9;
  --c-red:    #f08a8a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--surface-0);
  color: var(--text-primary);
  font: 14px/1.5 "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- tone system (kpi icons, pills, swatches) ---------- */
.tone-violet  { --tone: var(--c-violet); }
.tone-indigo  { --tone: var(--c-indigo); }
.tone-blue    { --tone: var(--c-blue); }
.tone-teal    { --tone: var(--c-teal); }
.tone-green   { --tone: var(--c-green); }
.tone-amber   { --tone: var(--c-amber); }
.tone-orange  { --tone: var(--c-orange); }
.tone-pink    { --tone: var(--c-pink); }
.tone-red     { --tone: var(--c-red); }
.tone-neutral { --tone: var(--text-secondary); }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 24px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
  box-shadow: 0 1px 0 rgba(23,25,33,.03);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--accent); color: #fff; border-radius: 11px;
  box-shadow: 0 3px 10px color-mix(in oklab, var(--accent) 45%, transparent);
}
.brand-mark svg { width: 20px; height: 20px; }
.topbar h1 { font-size: 15px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.sub { margin: 0; font-size: 11.5px; color: var(--text-muted); }
.tabs { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.tabs button {
  display: flex; align-items: center; gap: 7px;
  border: 0; background: transparent; color: var(--text-secondary);
  padding: 8px 15px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600;
  transition: background .12s ease, color .12s ease;
}
.tabs button svg { width: 15px; height: 15px; flex: none; }
.tabs button:hover { color: var(--text-primary); }
.tabs button.active { background: var(--surface-1); color: var(--accent); box-shadow: var(--shadow); }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary);
  width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 15px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text-primary); }

/* ---------- layout ---------- */
.view { padding: 24px; max-width: 1560px; margin: 0 auto; }
.loading { color: var(--text-muted); padding: 40px; text-align: center; }
.section-head {
  display: flex; align-items: center; gap: 12px; margin: 0 0 16px;
}
.section-head h2 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.section-head h3 { font-size: 15px; margin: 0; font-weight: 700; letter-spacing: -.01em; color: var(--text-primary); }
.section-head .spacer { margin-left: auto; }
.hint { color: var(--text-muted); font-size: 12.5px; margin: -8px 0 16px; }

.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card > h3 { margin: 0 0 12px; font-size: 12.5px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.card.flush { padding: 0; }

/* skala pomocniczego tekstu ustalona w widoku Dokumentów — używana wszędzie konsekwentnie,
   zamiast punktowych inline style="font-size:11px" rozrzuconych po app.js */
.subtext { display: block; font-size: 11px; margin-top: 1px; }
.h-note { text-transform: none; font-weight: 500; letter-spacing: 0; }
.empty-row { padding: 16px !important; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
/* karty KPI: płaska, pastelowo podbarwiona plytka (Snow Dashboard — Views/Visits/... na ciemnym tle) */
.kpi {
  background: color-mix(in oklab, var(--tone, var(--c-violet)) 7%, var(--surface-1));
  border: 1px solid color-mix(in oklab, var(--tone, var(--c-violet)) 20%, var(--border));
  border-radius: var(--radius); padding: 16px 18px; position: relative; overflow: hidden;
}
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.kpi .label { font-size: 12px; color: var(--text-secondary); font-weight: 600; line-height: 1.35; }
.icon-badge {
  flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  color: var(--tone, var(--c-violet)); background: color-mix(in oklab, var(--tone, var(--c-violet)) 20%, var(--surface-1));
}
.icon-badge svg.ico { width: 18px; height: 18px; }
.kpi .value { font-size: 23px; font-weight: 700; margin-top: 10px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .foot { font-size: 12px; color: var(--text-secondary); margin-top: 5px; }
.kpi.pos .value { color: var(--good); }
.kpi.neg .value { color: var(--bad); }

/* ---------- tabele ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
  font-weight: 600; background: var(--surface-2); position: sticky; top: 0;
}
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 220px; }
tfoot td { font-weight: 600; background: var(--surface-2); border-top: 2px solid var(--border-strong); }
/* dane liczbowe w tabelach: 400 w wierszach, 600 tylko w podsumowaniu (tfoot/RAZEM) —
   poza tabelami (.hint/.notice) emfaza <b> zostaje pełna (700) */
table b, table strong { font-weight: 400; }
tfoot b, tfoot strong { font-weight: 600; }
.neg { color: var(--bad); }
.pos { color: var(--good); }
.muted { color: var(--text-muted); }

/* status/kategorie jako plakietka z obramowaniem — bez kropki */
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  letter-spacing: .01em; color: var(--tone, var(--text-secondary)); background: transparent;
  border: 1px solid color-mix(in oklab, var(--tone, var(--text-secondary)) 45%, transparent);
}
.pill.new    { --tone: var(--c-indigo); }
.pill.maint  { --tone: var(--c-blue); }
.pill.payout { --tone: var(--c-pink); }
.pill.warn   { --tone: var(--c-amber); }
.pill.paid   { --tone: var(--c-green); margin-left: 4px; }
.pill.link   { --tone: var(--c-blue); }
.pill.direct { --tone: var(--c-orange); }

/* ---------- formularze / przyciski ---------- */
.btn {
  border: 1px solid var(--border-strong); background: var(--surface-1); color: var(--text-primary);
  padding: 8px 16px; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 600;
  transition: background .12s ease, border-color .12s ease, filter .12s ease;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 8px color-mix(in oklab, var(--accent) 35%, transparent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: color-mix(in oklab, var(--bad) 40%, var(--border-strong)); }
.btn.danger:hover { background: color-mix(in oklab, var(--bad) 10%, var(--surface-1)); }
.btn.sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.row-actions { display: flex; gap: 6px; }

label.field { display: block; margin-bottom: 12px; font-size: 12px; color: var(--text-secondary); }
label.field > span { display: block; margin-bottom: 5px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface-1); color: var(--text-primary); font: inherit; font-size: 13px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.inline-check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 13px; }
.inline-check input { width: auto; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(10,12,16,.5); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 18px;
  width: min(720px, 100%); max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ---------- toast / tooltip ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--text-primary); color: var(--surface-1); padding: 10px 18px; border-radius: 10px;
  font-size: 13px; z-index: 80; box-shadow: var(--shadow);
}
.tip {
  position: fixed; z-index: 90; pointer-events: none;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: 11px;
  padding: 10px 12px; font-size: 12.5px; box-shadow: var(--shadow); min-width: 170px;
}
.tip .tip-title { font-weight: 700; margin-bottom: 6px; }
.tip .tip-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tip .tip-row .k { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.tip .swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.tip .v { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- wykres ---------- */
.chart-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-left: auto; }
.legend .item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid line { stroke: var(--border); stroke-width: 1; }
svg.chart .axis text { fill: var(--text-muted); font-size: 11px; }
svg.chart .bar-hit { fill: transparent; cursor: pointer; }
svg.chart .bar-hit:hover + .bar-group, svg.chart .bar-group.hl { opacity: .82; }

.filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px;
  background: var(--surface-2); border-radius: 12px; padding: 8px;
}
.filters input, .filters select { width: auto; min-width: 130px; background: var(--surface-1); }
.search-field { position: relative; flex: 1 1 220px; min-width: 180px; }
.search-field svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text-muted); pointer-events: none;
}
.search-field input { width: 100%; padding-left: 32px; }
.notice {
  border-left: 3px solid var(--accent); background: color-mix(in oklab, var(--accent) 6%, var(--surface-1));
  padding: 11px 15px; border-radius: 0 10px 10px 0; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 14px;
}
.notice b { color: var(--text-primary); }
.notice code, .hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em;
  background: var(--surface-2); border-radius: 5px; padding: 1px 5px; color: var(--text-primary);
}
@media (max-width: 720px) {
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ---------- pasek alokacji faktury ---------- */
svg.alloc { display: block; }
svg.alloc rect { cursor: pointer; }
svg.alloc rect:hover { opacity: .8; }
tr.br-row, tr.clickable { cursor: pointer; }
tr.br-row.open { background: var(--surface-2); }
tr.br-row td:first-child::before { content: '▸'; color: var(--text-muted); margin-right: 6px; font-size: 11px; }
tr.br-row.open td:first-child::before { content: '▾'; }
tr.detail > td { background: var(--surface-2); padding: 0; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; padding: 16px 20px; }
.detail-grid h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.detail-grid .kv { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 12.5px; border-bottom: 1px dashed var(--border); }
.detail-grid .kv:last-child { border-bottom: 0; }
.detail-grid .kv b { font-variant-numeric: tabular-nums; }

/* ---------- podwójne kwoty: saldo / cash ---------- */
.dual { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.dual b { font-weight: 400; }
tfoot .dual b { font-weight: 600; }
.dual i { font-style: normal; font-size: 11px; color: var(--text-muted); }
.kpi .cash { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }
/* suwak toggle zamiast checkboxa dla statusu "zapłacone" */
.paid-box {
  -webkit-appearance: none; appearance: none; width: 38px; height: 22px; border-radius: 999px;
  position: relative; cursor: pointer; background: var(--border-strong); border: 1px solid var(--border-strong);
  transition: background .15s ease, border-color .15s ease; vertical-align: middle;
}
.paid-box::before {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s ease;
}
.paid-box:checked { background: var(--good); border-color: var(--good); }
.paid-box:checked::before { transform: translateX(16px); }
.detail-grid .kv b.neg { color: var(--bad); }
.detail-grid .kv b.pos { color: var(--good); }

/* ---------- Dokumenty: nawigacja miesięcy + tabele wpływy/koszty jedna pod drugą ---------- */
.doc-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.doc-nav select { width: auto; min-width: 190px; font-weight: 700; }
.doc-nav .muted { margin-left: auto; font-size: 12.5px; }
.doc-columns { display: flex; flex-direction: column; gap: 18px; }
.doc-col h3 span { text-transform: none; }
@media (max-width: 900px) {
  .doc-nav .muted { margin-left: 0; width: 100%; }
}

/* ---------- przełącznik segmentowy (Rozliczenie) — underline tabs ---------- */
.segmented { display: inline-flex; gap: 18px; border-bottom: 1px solid var(--border); padding: 0; margin-bottom: 18px; }
.segmented button {
  border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text-secondary);
  padding: 9px 2px; cursor: pointer; font-size: 13.5px; font-weight: 600; margin-bottom: -1px;
  transition: color .12s ease, border-color .12s ease;
}
.segmented button:hover { color: var(--text-primary); }
.segmented button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- dostępność: tekst tylko dla czytników ekranu ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- widoczny focus (klawiatura) ---------- */
.btn:focus-visible, .icon-btn:focus-visible, .act-btn:focus-visible,
.tabs button:focus-visible, .segmented button:focus-visible, .paid-box:focus-visible,
tr.br-row:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
tr.br-row:focus-visible { outline-offset: -2px; }

/* ---------- ikonowe akcje w wierszach tabel ---------- */
/* zastępują tekstowe „Edytuj / Klonuj / Usuń”: 32×32 px obszaru klikalnego (z zapasem ponad
   minimum WCAG 2.2 „Target Size (Minimum)” 24×24), tooltip + aria-label z tej samej etykiety */
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
th.actions, td.actions { text-align: right; width: 1%; white-space: nowrap; }
.act-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 1px solid transparent; border-radius: 9px; background: transparent;
  color: var(--text-secondary); cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.act-btn svg { width: 17px; height: 17px; }
.act-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--text-primary); }
.act-btn.on { color: var(--accent); }
.act-btn.danger:hover {
  color: var(--bad);
  background: color-mix(in oklab, var(--bad) 12%, var(--surface-1));
  border-color: color-mix(in oklab, var(--bad) 40%, var(--border));
}
.act-btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn[disabled] { opacity: .55; cursor: not-allowed; filter: none; }

/* ---------- wykres pierścieniowy (struktura kosztów / podziału faktury) ---------- */
.donut { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut svg { flex: none; }
.donut .donut-seg { transition: opacity .12s ease; }
.donut svg:hover .donut-seg { opacity: .55; }
.donut svg .donut-seg:hover { opacity: 1; }
.donut .donut-total { fill: var(--text-primary); font-size: 15px; font-weight: 700; }
.donut .donut-cap { fill: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.donut-legend { list-style: none; margin: 0; padding: 0; flex: 1 1 240px; min-width: 220px; }
.donut-legend li {
  display: grid; grid-template-columns: 12px 1fr auto auto; align-items: center; gap: 10px;
  padding: 5px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px;
}
.donut-legend li:last-child { border-bottom: 0; }
.donut-legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
.donut-legend b { font-variant-numeric: tabular-nums; font-weight: 600; }
.donut-legend .pctv { min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; }
.donut-empty { padding: 18px 4px; }
.donut-empty p { margin: 0; font-size: 12.5px; }

/* ---------- modal podziału faktury na części ---------- */
.split-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px;
  background: var(--surface-2); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px;
}
.split-summary .sm-item { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.split-summary .sm-item span { color: var(--text-secondary); font-weight: 600; }
.split-summary .sm-item b { font-size: 15px; font-variant-numeric: tabular-nums; }
.split-summary .sm-item.status.ok b { color: var(--good); }
.split-summary .sm-item.status.bad b { color: var(--bad); }
.split-table td, .split-table th { padding: 7px 8px; vertical-align: middle; }
.split-table input, .split-table select { min-width: 96px; padding: 7px 9px; }
.split-table td:nth-child(2) { min-width: 170px; }
.split-table .sp-net { width: 116px; text-align: right; }
.split-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.split-errors:empty { display: none; }
.split-errors ul {
  margin: 0 0 14px; padding: 10px 14px 10px 30px; list-style: disc;
  border-left: 3px solid var(--bad); border-radius: 0 10px 10px 0;
  background: color-mix(in oklab, var(--bad) 8%, var(--surface-1));
  color: var(--text-primary); font-size: 12.5px;
}
.split-errors li { margin: 2px 0; }
.modal-card:has(.split-table) { width: min(1040px, 100%); }

/* ---------- panel szczegółów kosztu (podział + wpływ na rentowność) ---------- */
.detail-grid .detail-wide { grid-column: 1 / -1; }
.detail-grid .detail-wide table { font-size: 12.5px; }
.detail-grid .detail-wide th { background: transparent; }

/* ---------- czytelność tabel po usunięciu kolumn ---------- */
/* zwolnione miejsce oddajemy kolumnie opisowej, zamiast rozciągać kolumny liczbowe */
.tbl-invoices, .tbl-costs { table-layout: auto; }
.tbl-invoices td.wrap, .tbl-costs td.wrap { min-width: 240px; width: 40%; }
@media (max-width: 1100px) {
  .tbl-invoices td.wrap, .tbl-costs td.wrap { min-width: 180px; width: auto; }
  .row-actions { gap: 0; }
  .act-btn { width: 30px; height: 30px; }
}
@media (max-width: 720px) {
  .view { padding: 16px 12px; }
  .split-summary { grid-template-columns: repeat(2, 1fr); }
  .donut { justify-content: center; }
  .kpi .value { font-size: 20px; }
}

/* ---------- karta salda wspólnika (Podsumowanie + Rozliczenia → Wspólnicy) ---------- */
.kpis.partner-cards { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.partner-kpi { display: flex; align-items: stretch; gap: 18px; padding: 18px 20px; }
.partner-kpi .pk-main { flex: 1 1 auto; min-width: 0; }
.pk-id { display: flex; align-items: center; gap: 11px; }
.pk-code {
  flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px;
  background: var(--tone, var(--c-violet)); color: var(--surface-1);
  font-size: 18px; font-weight: 700; letter-spacing: -.01em;
}
.pk-title { display: flex; flex-direction: column; min-width: 0; }
.pk-name {
  font-size: 15px; font-weight: 700; letter-spacing: -.01em; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pk-sub {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted);
}
.pk-value {
  font-size: 30px; font-weight: 700; margin-top: 12px; letter-spacing: -.025em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.partner-kpi.pos .pk-value { color: var(--good); }
.partner-kpi.neg .pk-value { color: var(--bad); }
.pk-cash { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; font-variant-numeric: tabular-nums; }

/* „Należne / Wypłacone” — po prawej, jedno pod drugim, wyraźnie odcięte od salda */
.pk-side {
  flex: none; margin: 0; padding-left: 18px; display: flex; flex-direction: column; justify-content: center;
  gap: 12px; text-align: right;
  border-left: 1px solid color-mix(in oklab, var(--tone, var(--c-violet)) 28%, var(--border));
}
.pk-item dt {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-secondary);
}
.pk-item dd {
  margin: 2px 0 0; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--text-primary); white-space: nowrap;
}
.pk-item.paid dd { color: var(--text-secondary); }

@media (max-width: 520px) {
  .partner-kpi { flex-direction: column; gap: 14px; }
  .pk-side {
    flex-direction: row; justify-content: space-between; text-align: left;
    border-left: 0; padding-left: 0; padding-top: 12px;
    border-top: 1px solid color-mix(in oklab, var(--tone, var(--c-violet)) 28%, var(--border));
  }
}

/* ---------- układ dwukolumnowy (wykresy obok siebie) ---------- */
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.two-col > .card { margin-bottom: 0; }

/* ---------- panel gabinetu w widoku Miesiąc ---------- */
.office-panel .sub-head {
  margin: 18px 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); font-weight: 700;
}
.office-panel .sub-head:first-of-type { margin-top: 4px; }
.mini-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px;
  background: var(--surface-2); border-radius: 12px; padding: 10px 14px; margin-bottom: 4px;
}
.mini-kpis > div { display: flex; flex-direction: column; gap: 1px; }
.mini-kpis span { font-size: 11px; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.mini-kpis b { font-size: 15px; font-variant-numeric: tabular-nums; }
.panel-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- ostrzeżenie (np. udziały ≠ 100%) ---------- */
.notice.warn {
  border-left-color: var(--c-amber);
  background: color-mix(in oklab, var(--c-amber) 10%, var(--surface-1));
}

/* ---------- plakietka z wynikiem ---------- */
.pill.pos { --tone: var(--c-green); }
.pill.neg { --tone: var(--c-red); }

/* ---------- podsumowanie w formularzu raportu ---------- */
.split-summary .sm-item small { font-size: 10.5px; font-weight: 500; }

/* ---------- pola dodatkowe w modalu (zwijane) ---------- */
.more-fields {
  border: 1px solid var(--border); border-radius: 12px; padding: 0 14px; margin-top: 6px;
  background: color-mix(in oklab, var(--surface-2) 55%, var(--surface-1));
}
.more-fields summary {
  cursor: pointer; padding: 12px 0; font-weight: 700; font-size: 12.5px; color: var(--text-secondary);
  list-style: none;
}
.more-fields summary::-webkit-details-marker { display: none; }
.more-fields summary::before { content: '▸ '; color: var(--text-muted); }
.more-fields[open] summary::before { content: '▾ '; }
.more-fields[open] { padding-bottom: 6px; }
.more-fields summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- nagłówki dwupoziomowe w tabeli podsumowania ---------- */
thead th[rowspan] { vertical-align: bottom; }

/* ---------- pasek stanu bazy (praca na kopii lokalnej / nieświeża kopia) ---------- */
.db-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 24px; font-size: 13px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 19;
}
.db-banner .dbb-ico { font-size: 15px; line-height: 1; flex: none; }
.db-banner > span:nth-child(2) { flex: 1 1 320px; min-width: 240px; }
.db-banner button { flex: none; }
.db-banner.warn {
  background: color-mix(in oklab, var(--c-amber) 22%, var(--surface-1));
  color: var(--text-primary);
  border-bottom-color: color-mix(in oklab, var(--c-amber) 45%, var(--border));
}
.db-banner.info {
  background: color-mix(in oklab, var(--accent) 12%, var(--surface-1));
  border-bottom-color: color-mix(in oklab, var(--accent) 35%, var(--border));
}

/* ---------- ekran logowania ---------- */
.topbar-actions { display: flex; align-items: center; gap: 8px; }
body.logged-out .tabs { display: none; }
body.logged-out #accountBtn { display: none; }
.login-wrap { display: grid; place-items: center; min-height: 62vh; padding: 24px 0; }
.login-card {
  width: min(400px, 100%); background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow); padding: 30px 28px;
}
.login-card h2 { margin: 14px 0 4px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.login-mark {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px;
  background: var(--accent); color: #fff;
  box-shadow: 0 3px 12px color-mix(in oklab, var(--accent) 40%, transparent);
}
.login-card .field { margin-bottom: 14px; }
.login-card .split-errors ul { margin-bottom: 12px; }
