/* ResonoApp Energy Balance – system wizualny „Edytorski”: papier, atrament i granat.
   Liczby i tytuły serifem Fraunces, interfejs w Inter (obie czcionki lokalnie – vendor/fonts.css).
   Nazwy tokenów = design system „Energy Balance” (tokens.json). Linie zamiast kart, kolor tylko dla danych. */
:root {
  color-scheme: light;
  --surface-0: #f6f4ee;
  --surface-1: #fdfcfa;
  --surface-2: #efece4;
  --rule: #e3dfd5;
  --rule-strong: #8f887a;
  --ink: #1c1b18;
  --ink-2: #5e594f;
  --ink-3: #6f6a60;
  --navy: #1e2a3d;
  --navy-hover: #141d2c;
  --on-navy: #ffffff;
  --on-navy-2: #aab4c8;
  --navy-soft: #e6eaf1;
  --focus: #1e2a3d;
  --sun: #f2b632;
  --series-prod: #b07d24;
  --series-import: #3f5f8f;
  --series-export: #3d7a5c;
  --series-self: #8c5b7e;
  --status-good: #2f6b4d;
  --status-warning: #8a5a0c;
  --status-critical: #9e3427;
  --status-good-soft: #e5efe8;
  --status-warning-soft: #f6ecd8;
  --status-critical-soft: #f7e4e0;
  --shadow-lg: 0 24px 60px -24px rgba(28, 27, 24, .35);
  --shimmer: rgba(255, 255, 255, .45);
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font: var(--font-sans); --serif: var(--font-serif); --mono: var(--font-mono);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #161511; --surface-1: #1e1c18; --surface-2: #26241f;
    --rule: #33302a; --rule-strong: #6d675c;
    --ink: #f0ede6; --ink-2: #b3ada0; --ink-3: #948e81;
    --navy: #e6ebf5; --navy-hover: #ffffff; --on-navy: #161511; --on-navy-2: #3c4658; --navy-soft: #242b3a; --focus: #e6ebf5;
    --series-prod: #e0b25a; --series-import: #8aa8d6; --series-export: #6fbf95; --series-self: #c799b8;
    --status-good: #7cc79f; --status-warning: #e2b35c; --status-critical: #f08c7e;
    --status-good-soft: #1c2a22; --status-warning-soft: #302617; --status-critical-soft: #33201d;
    --shadow-lg: 0 30px 80px -30px rgba(0, 0, 0, .8);
    --shimmer: rgba(255, 255, 255, .06);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #161511; --surface-1: #1e1c18; --surface-2: #26241f;
  --rule: #33302a; --rule-strong: #6d675c;
  --ink: #f0ede6; --ink-2: #b3ada0; --ink-3: #948e81;
  --navy: #e6ebf5; --navy-hover: #ffffff; --on-navy: #161511; --on-navy-2: #3c4658; --navy-soft: #242b3a; --focus: #e6ebf5;
  --series-prod: #e0b25a; --series-import: #8aa8d6; --series-export: #6fbf95; --series-self: #c799b8;
  --status-good: #7cc79f; --status-warning: #e2b35c; --status-critical: #f08c7e;
  --status-good-soft: #1c2a22; --status-warning-soft: #302617; --status-critical-soft: #33201d;
  --shadow-lg: 0 30px 80px -30px rgba(0, 0, 0, .8);
  --shimmer: rgba(255, 255, 255, .06);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11';
}
h1, h2, h3 { margin: 0; font-weight: 400; color: var(--ink); text-wrap: balance; }
h1, h2, .serif { font-family: var(--serif); font-variation-settings: 'opsz' 96, 'SOFT' 30; letter-spacing: -.015em; }
a { color: var(--navy); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--navy) 35%, transparent); }
a:hover { text-decoration-color: currentColor; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--navy-soft); color: var(--ink); }
.num, .tnum { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

/* ---- pasek wersji demo: jedna cicha linia ---- */
.demo-ribbon { display: flex; align-items: center; justify-content: center; gap: 8px 14px; flex-wrap: wrap; padding: 7px 24px; font-size: 12.5px; color: var(--ink-3); border-bottom: 1px solid var(--rule); background: var(--surface-0); }
.demo-ribbon b { font-weight: 500; color: var(--ink-2); }
.demo-ribbon .pill { color: var(--ink-3); }
.demo-ribbon .pill::before { content: '·'; margin-right: 10px; }

/* ---- pasek górny ---- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 40px; padding: 0 48px; height: 64px; background: color-mix(in srgb, var(--surface-0) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--rule); }
.brand { display: flex; align-items: center; gap: 12px; font-family: var(--serif); font-size: 20px; font-weight: 400; letter-spacing: -.01em; line-height: 1.15; color: var(--ink); }
.brand small { display: block; font-family: var(--font); font-size: 12px; color: var(--ink-3); margin-top: 2px; letter-spacing: 0; white-space: nowrap; }
.brand .logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--navy); flex: none; }
.brand .logo svg { width: 30px; height: 30px; display: block; }
.brand .logo svg path { fill: var(--on-navy); }
.brand .logo svg circle { fill: var(--sun); }
.nav { display: flex; gap: 28px; height: 100%; }
.nav a { display: inline-flex; align-items: center; height: 64px; color: var(--ink-2); font-weight: 500; font-size: 14.5px; text-decoration: none; border-bottom: 1.5px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color .15s, border-color .15s; }
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--ink); border-bottom-color: var(--ink); }
.spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 14px; font-size: 13.5px; color: var(--ink-2); }
.userbox .email { white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--on-navy); background: var(--navy); flex: none; letter-spacing: .02em; }
.topbar .btn.small { height: 32px; }

/* ---- strona ---- */
.container { max-width: 1280px; margin: 0 auto; padding: 44px 48px 72px; }
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 32px; flex-wrap: wrap; margin: 0 0 36px; }
.page-heading { min-width: 0; }
.page-heading .sub { display: block; }
.page-title h1 { font-size: 40px; line-height: 1.05; font-weight: 300; letter-spacing: -.02em; }
.page-title h1 em { font-style: italic; font-weight: 400; }
.page-title .sub { display: block; width: 100%; color: var(--ink-2); font-size: 14.5px; margin-top: 12px; }
.page-title .spacer { display: none; }
.page-title .badge { align-self: flex-end; }
.page-status { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; text-align: right; font-size: 13.5px; color: var(--ink-2); line-height: 1.5; padding-bottom: 4px; margin-left: auto; }
.page-status:empty { display: none; }
.page-status .controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.page-title select { max-width: 380px; }

.grid { display: grid; gap: 24px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 56px; }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 40px; }
.grid.flow-row, .flowrow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 56px; }
.section { margin-top: 44px; padding-top: 32px; border-top: 1px solid var(--rule); }

/* ---- sekcja zamiast karty ---- */
.card { min-width: 0; background: transparent; }
.card h2, .card h3 { font-size: 22px; line-height: 1.2; margin: 0 0 4px; }
.card h3 { font-family: var(--font); font-size: 15px; font-weight: 600; }
.hint, .card .hint { color: var(--ink-3); font-size: 13px; line-height: 1.5; }
.card-head { display: flex; align-items: flex-end; gap: 6px 24px; flex-wrap: wrap; margin-bottom: 22px; }
.card-head h2 { margin: 0; }
.card-head .hint { flex-basis: 100%; order: 2; margin-top: 4px; }
.card-head .controls { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; order: 1; align-self: flex-end; }
.card ul { padding-left: 18px; margin: 8px 0; }
.card.boxed { padding: 24px 28px; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface-1); }
.flow-card .flow { margin: 4px 0 0; }

/* ---- kafelki KPI: pasek z liniami ---- */
.grid.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0; border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule-strong); }
.tile { display: flex; flex-direction: column; gap: 0; position: relative; padding: 22px 24px 20px 0; margin-right: 24px; border-right: 1px solid var(--rule); }
.grid.kpi > .tile:last-child { border-right: 0; margin-right: 0; }
.tile .label { color: var(--ink-2); font-size: 13px; display: flex; align-items: center; gap: 8px; font-weight: 500; }
.tile .value { font-family: var(--serif); font-variation-settings: 'opsz' 144, 'SOFT' 30; font-size: 44px; font-weight: 300; letter-spacing: -.025em; font-variant-numeric: tabular-nums; line-height: 1; margin: 16px 0 8px; }
.tile .value small { font-family: var(--font); font-size: 13px; font-weight: 500; color: var(--ink-2); margin-left: 6px; letter-spacing: 0; }
.tile .delta { color: var(--ink-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tile .spark { position: relative; height: 40px; margin: 16px 0 -6px; }
.tile .spark canvas { width: 100% !important; height: 100% !important; display: block; }
.swatch { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.swatch.prod { background: var(--series-prod); }
.swatch.import { background: var(--series-import); }
.swatch.export { background: var(--series-export); }
.swatch.self { background: var(--series-self); }

/* ---- szkielety ---- */
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 3px; color: transparent !important; }
.skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--shimmer), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.tile.skeleton-tile .label, .tile.skeleton-tile .value, .tile.skeleton-tile .delta { color: transparent; }

/* ---- odznaki / status: tekst z kropką, bez tła ---- */
.badge { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.badge.ok { color: var(--status-good); }
.badge.warning { color: var(--status-warning); }
.badge.error { color: var(--status-critical); }
.dot { display: inline-block; vertical-align: middle; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: none; }
td > .dot { margin-right: 10px; }
.dot.ok, .badge.ok .dot { background: var(--status-good); }
.dot.stale, .badge.warning .dot { background: var(--status-warning); border-radius: 1px; transform: rotate(45deg) scale(.9); }
.dot.error, .badge.error .dot { background: var(--status-critical); border-radius: 1px; }
.badge.live .dot { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---- przyciski i kontrolki ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 4px; border: 1px solid var(--rule-strong); background: transparent; cursor: pointer; font-size: 14px; font-weight: 500; line-height: 1; color: var(--ink); text-decoration: none; transition: background .15s, border-color .15s, color .15s; white-space: nowrap; }
.btn:hover { background: var(--surface-1); border-color: var(--ink-2); text-decoration: none; }
.btn.primary { background: var(--navy); color: var(--on-navy); border-color: var(--navy); }
.btn.primary:hover { background: var(--navy-hover); border-color: var(--navy-hover); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.icon { width: 32px; padding: 0; }
.btn.danger { color: var(--status-critical); border-color: var(--status-critical); }
.btn.danger:hover { background: var(--status-critical-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; gap: 0; border: 1px solid var(--rule-strong); border-radius: 4px; overflow: hidden; }
.seg button { height: 32px; padding: 0 14px; border: 0; border-right: 1px solid var(--rule); background: transparent; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--ink-2); transition: background .15s, color .15s; }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--ink); background: var(--surface-1); }
.seg button.active { background: var(--ink); color: var(--surface-0); }
input[type="date"], input[type="month"], input[type="text"], input[type="number"], input[type="email"], input[type="password"], input[type="file"], select, textarea {
  height: 38px; padding: 0 12px; border: 1px solid var(--rule-strong); border-radius: 4px; background: var(--surface-1); color: var(--ink); min-width: 0; font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
input[type="file"] { padding: 6px 8px; }
textarea { height: auto; padding: 10px 12px; }
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 1; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-soft); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--navy); vertical-align: -2px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
label.field > input, label.field > select, label.field > textarea { font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px 24px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; align-items: center; }

/* ---- panel Serwis ---- */
label.field > .hint { font-weight: 400; }
label.field .check, label.field .inline { display: flex; align-items: center; gap: 8px; min-height: 38px; font-weight: 400; color: var(--ink); }
label.field .inline > input { flex: 1; }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin: 4px 0 8px; }
.progress-bar { height: 100%; background: var(--status-good); transition: width .3s; }
.onb-item { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, 1fr); gap: 16px 40px; padding: 20px 0; border-bottom: 1px solid var(--rule); }
.onb-item:last-child { border-bottom: 0; }
.onb-item.dirty { background: linear-gradient(90deg, var(--status-warning-soft), transparent 40%); margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
.onb-title { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.onb-title .badge { gap: 0; }
.onb-q { margin: 8px 0 10px; color: var(--ink); line-height: 1.55; }
.kv.compact-meta { font-size: 13px; gap: 4px 14px; }
.kv.compact-meta dt { color: var(--ink-3); }
.onb-side { display: grid; gap: 12px; align-content: start; }
.onb-side textarea { min-height: 72px; font-family: var(--font); }
.result { margin-top: 16px; }
.result:empty { display: none; }
table.fields th, table.fields td { white-space: normal; }
table.fields select, table.fields input { height: 34px; font-size: 13px; width: 100%; }
table.fields td:first-child select { min-width: 200px; }
table.fields td:nth-child(2) input, table.fields td:nth-child(4) input { min-width: 84px; }
table.fields td:nth-child(3) select { min-width: 100px; }
table.fields td:nth-child(5) input { min-width: 64px; }
table.fields td:nth-child(6) { width: 100%; }
table.fields td:nth-child(6) input { min-width: 140px; }
[hidden] { display: none !important; }
.mono-table td, .mono-table th { font-variant-numeric: tabular-nums; }
.log-view { max-height: 460px; overflow: auto; background: var(--surface-2); border-radius: 4px; padding: 10px 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; }
.log-view:empty::before { content: 'Wybierz usługę i kliknij „Pokaż”.'; color: var(--ink-3); font-family: var(--font); }
.log-line { display: grid; grid-template-columns: 130px 52px minmax(0, 1fr); gap: 0 12px; padding: 2px 0; border-bottom: 1px dotted var(--rule); }
.log-line .log-ts { color: var(--ink-3); white-space: nowrap; }
.log-line .log-level { text-transform: uppercase; font-size: 11px; letter-spacing: .04em; color: var(--ink-3); padding-top: 2px; }
.log-line.warn .log-level { color: var(--status-warning); }
.log-line.error .log-level { color: var(--status-critical); }
.log-line .log-msg { white-space: pre-wrap; word-break: break-word; }
@media (max-width: 860px) { .onb-item { grid-template-columns: 1fr; } .log-line { grid-template-columns: 1fr; } }

/* ---- wykresy ---- */
.chart-wrap { position: relative; height: 300px; }
.chart-wrap.tall { height: 380px; }
.chart-wrap.short { height: 240px; }
.legend { display: flex; gap: 8px 22px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin: 4px 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }

/* ---- diagram przepływu energii (api.js: flowSvg) – rysunek liniowy ---- */
.flow { margin: 0; }
.flow svg { width: 100%; height: auto; display: block; overflow: visible; }
.flow text { font-family: var(--font); fill: var(--ink); }
.flow .node { fill: var(--surface-0); stroke: var(--ink); stroke-width: 1; }
.flow .icon path, .flow .icon circle { fill: none; stroke: var(--ink); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.flow .sun { fill: var(--ink); stroke: none; }
.flow .node-label { font-size: 13px; font-weight: 600; }
.flow .node-sub { font-size: 12px; fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.flow .val { font-family: var(--serif); font-variation-settings: 'opsz' 96, 'SOFT' 30; font-size: 20px; font-weight: 400; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.flow .val-sub { font-size: 11.5px; fill: var(--ink-2); font-weight: 500; letter-spacing: .02em; }
.flow .rail { fill: none; stroke: var(--rule-strong); stroke-width: 1; }
.flow .beam { fill: none; stroke-width: 2; stroke-linecap: round; stroke-dasharray: 1 9; animation: beam var(--dur, 1s) linear infinite; }
.flow .beam.self { stroke: var(--series-self); }
.flow .beam.export { stroke: var(--series-export); }
.flow .beam.import { stroke: var(--series-import); }
.flow .beam.idle { animation: none; opacity: 0; }
@keyframes beam { to { stroke-dashoffset: -20; } }

/* ---- tabele ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; vertical-align: middle; }
th { color: var(--ink); font-weight: 600; font-size: 12.5px; border-bottom: 1px solid var(--ink); background: var(--surface-0); }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { white-space: nowrap; }
#split table { min-width: 880px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-1); }
tr.clickable td:first-child { font-weight: 500; }
table tr.total td { border-top: 1px solid var(--ink); border-bottom: 0; font-weight: 600; }
td.strong { font-weight: 600; color: var(--ink); }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: -.01em; }
.empty { color: var(--ink-3); padding: 28px 0; text-align: center; }

/* tabela okresów (EB.periodTable) */
table.period th { border-bottom: 1px solid var(--ink); padding: 0 0 10px 12px; font-size: 13px; text-align: right; }
table.period th:first-child { text-align: left; padding-left: 0; }
table.period th small { display: block; font-weight: 400; font-size: 12px; color: var(--ink-3); margin-top: 1px; }
table.period td { padding: 11px 0 11px 12px; }
table.period td:first-child { padding-left: 0; color: var(--ink-2); }
table.period td:first-child .swatch { margin-right: 10px; vertical-align: 1px; }
table.period td.num { color: var(--ink); }
table.period tr.total td { font-weight: 600; color: var(--ink); border-top: 0; border-bottom: 1px solid var(--rule); }
table.period tr:last-child td { border-bottom: 0; }
.kv-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; }
.kv-cols h3 { font-size: 15px; margin: 0 0 10px; display: flex; gap: 8px; align-items: baseline; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: 14px; margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.kv.compact { grid-template-columns: minmax(0, 1fr) auto; }
.kv.compact dd { text-align: right; }
.kv.model { grid-template-columns: max-content 1fr; gap: 10px 24px; }
.kv.model dd { font-weight: 500; }
.kv dd.strong, .kv dd b { font-weight: 600; }

/* ---- komunikaty ---- */
.alert { padding: 12px 16px; border-radius: 4px; border: 1px solid var(--rule-strong); background: var(--surface-1); font-size: 14px; color: var(--ink); }
.alert.error { border-color: var(--status-critical); background: var(--status-critical-soft); }
.alert.ok { border-color: var(--status-good); background: var(--status-good-soft); }
.alert.warning { border-color: var(--status-warning); background: var(--status-warning-soft); }
.toast { position: fixed; bottom: 24px; right: 24px; z-index: 50; max-width: min(400px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 8px; }
.toast .alert { animation: toastin .2s ease-out; box-shadow: var(--shadow-lg); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

/* ---- modal ---- */
.modal-bg { position: fixed; inset: 0; background: rgba(28, 27, 24, .45); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; animation: fadein .15s; }
@keyframes fadein { from { opacity: 0; } }
.modal { background: var(--surface-0); border: 1px solid var(--rule); border-radius: 6px; padding: 32px; width: 100%; max-width: 680px; max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal h3 { font-family: var(--serif); font-size: 24px; font-weight: 400; margin: 0 0 22px; }

/* ---- zakładki ---- */
.tabs { display: flex; gap: 28px; flex-wrap: wrap; border-bottom: 1px solid var(--rule); margin-bottom: 32px; }
.tabs button { height: 44px; padding: 0; border: 0; background: transparent; cursor: pointer; color: var(--ink-2); border-bottom: 1.5px solid transparent; margin-bottom: -1px; font-weight: 500; font-size: 14.5px; transition: color .15s, border-color .15s; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--ink); }

pre.json { background: var(--surface-2); padding: 12px 16px; border-radius: 4px; overflow: auto; font-size: 12.5px; max-height: 320px; font-family: var(--mono); white-space: pre-wrap; }
code { font-family: var(--mono); font-size: 12.5px; }

/* ---- logowanie: okładka + formularz ---- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--surface-0); }
.demo-ribbon + .auth { min-height: calc(100vh - 34px); }
.auth-hero { --navy: #1e2a3d; --navy-hover: #141d2c; --on-navy: #ffffff; --on-navy-2: #aab4c8; position: relative; overflow: hidden; padding: 44px 56px 40px; display: flex; flex-direction: column; color: var(--on-navy); background: var(--navy); }
.auth-hero .brand { color: var(--on-navy); }
.auth-hero .brand small { color: var(--on-navy-2); }
.auth-hero .brand .logo { background: var(--on-navy); }
.auth-hero .brand .logo svg path { fill: var(--navy); }
.auth-hero .brand .logo svg circle { fill: var(--sun); }
.auth-hero-body { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 32px 0 24px; max-width: 560px; }
.eyebrow { font-family: var(--font); font-size: 12.5px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.auth-hero .eyebrow { margin: 0 0 20px; color: var(--on-navy-2); }
.auth-hero h1 { font-size: clamp(38px, 3.6vw, 54px); line-height: 1.02; font-weight: 300; letter-spacing: -.025em; margin: 0 0 24px; color: var(--on-navy); max-width: 13ch; }
.auth-hero h1 em { font-style: italic; font-weight: 400; }
.auth-hero p.lead { font-size: 16px; line-height: 1.6; color: var(--on-navy-2); max-width: 46ch; margin: 0 0 32px; }
.hero-flow-wrap { max-width: 520px; }
.hero-flow-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; font-size: 12.5px; }
.hero-flow-head .badge { color: #9ed6b9; font-size: 12.5px; }
.hero-flow-head .badge .dot { background: #9ed6b9; }
.hero-flow-note { color: var(--on-navy-2); }
.auth-hero .hero-flow { max-width: 520px; }
.auth-hero .flow text { fill: var(--on-navy); }
.auth-hero .flow .node { fill: var(--navy); stroke: var(--on-navy); }
.auth-hero .flow .icon path, .auth-hero .flow .icon circle { stroke: var(--on-navy); }
.auth-hero .flow .sun { fill: var(--sun); }
.auth-hero .flow .node-sub, .auth-hero .flow .val-sub { fill: var(--on-navy-2); }
.auth-hero .flow .rail { stroke: color-mix(in srgb, var(--on-navy) 30%, transparent); }
.auth-hero .flow .beam.self { stroke: #d9b8cf; }
.auth-hero .flow .beam.export { stroke: #9ed6b9; }
.auth-hero .flow .beam.import { stroke: #b4c8ea; }
.hero-stats { display: grid; grid-template-columns: repeat(4, auto); justify-content: start; gap: 28px; margin: 24px 0 0; padding: 24px 0 0; list-style: none; border-top: 1px solid color-mix(in srgb, var(--on-navy) 18%, transparent); }
.hero-stats li { display: flex; flex-direction: column; gap: 2px; }
.hero-stats b { font-family: var(--serif); font-size: 24px; font-weight: 300; letter-spacing: -.01em; color: var(--on-navy); line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero-stats span { font-size: 12.5px; color: var(--on-navy-2); }
.auth-hero .foot { font-size: 12.5px; color: var(--on-navy-2); margin: 0; }
.auth-form { display: grid; place-items: center; padding: 48px 40px; }
.login-col { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 28px; }
.brand-mobile { display: none; }
.login-card h1 { font-size: 36px; line-height: 1.1; font-weight: 300; letter-spacing: -.02em; margin: 0 0 10px; }
.login-card .sub { color: var(--ink-2); margin: 0 0 32px; font-size: 15px; }
.login-card form { display: flex; flex-direction: column; gap: 18px; }
.login-card label.field { font-size: 13.5px; color: var(--ink); }
.login-card input[type="email"], .login-card input[type="password"], .login-card input[type="text"] { height: 46px; font-size: 15px; width: 100%; }
.login-card .btn.primary { height: 46px; font-size: 15px; margin-top: 6px; }
.login-card #crmlink { width: 100%; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 76px; }
.pw-wrap button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); height: 32px; padding: 0 10px; border: 0; background: transparent; color: var(--ink-2); font-size: 13px; font-weight: 500; cursor: pointer; border-radius: 3px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule-strong); }
.pw-wrap button:hover { color: var(--ink); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 12.5px; margin: 32px 0 14px; letter-spacing: .04em; text-transform: uppercase; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--rule); }
.demo-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.demo-list li { border-bottom: 1px solid var(--rule); }
.demo-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 4px; border: 0; background: transparent; text-align: left; cursor: pointer; transition: background .15s; }
.demo-row:hover { background: var(--surface-1); }
.demo-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.demo-text b { font-weight: 500; font-size: 14px; color: var(--ink); }
.demo-text small { font-size: 12.5px; color: var(--ink-3); }
.demo-go { font-size: 18px; line-height: 1; color: var(--ink-3); transition: transform .15s, color .15s; }
.demo-row:hover .demo-go { color: var(--ink); transform: translateX(2px); }
.demo-note { margin: 12px 0 0; font-size: 13px; color: var(--ink-3); }
.demo-note code { font-family: var(--mono); color: var(--ink-2); }
.login-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); }
.login-foot p { margin: 0; flex: 1; min-width: 200px; }

/* ---- objaśnienia w trybie pokazowym (guide.js) ---- */
.guide-tip { position: fixed; z-index: 60; max-width: 320px; padding: 12px 14px 13px; background: var(--surface-1); color: var(--ink); border: 1px solid var(--rule-strong); border-radius: 6px; box-shadow: var(--shadow-lg); pointer-events: none; opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; }
.guide-tip.on { opacity: 1; transform: none; }
.guide-tip h4 { margin: 0 0 4px; font-family: var(--serif); font-variation-settings: 'opsz' 96, 'SOFT' 30; font-size: 16px; font-weight: 400; letter-spacing: -.01em; color: var(--ink); }
.guide-tip p { margin: 0; font-family: var(--font); font-size: 13px; line-height: 1.5; color: var(--ink-2); }
.guide-target { outline: 1px dashed var(--rule-strong) !important; outline-offset: 4px; border-radius: 3px; }
.guide-toggle { position: fixed; left: 16px; bottom: 16px; z-index: 55; height: 30px; padding: 0 12px 0 10px; border-radius: 999px; border: 1px solid var(--rule-strong); background: var(--surface-1); color: var(--ink-2); font: 500 12.5px/1 var(--font); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 6px 20px -12px rgba(0,0,0,.4); }
.guide-toggle::before { content: '?'; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--navy); color: var(--on-navy); font-size: 11px; font-weight: 600; }
.guide-toggle.off::before { background: var(--rule-strong); }
.guide-toggle:hover { color: var(--ink); border-color: var(--ink-2); }
@media print { .guide-tip, .guide-toggle { display: none !important; } .guide-target { outline: none !important; } }
@media (max-width: 720px) { .guide-toggle { bottom: 12px; left: 12px; } .guide-tip { max-width: calc(100vw - 24px); } }

/* ---- raport do druku (raport.html) ---- */
.report-body { background: var(--surface-2); }
.report-bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 10px 24px; background: color-mix(in srgb, var(--surface-0) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--rule); }
.report { width: 210mm; min-height: 297mm; margin: 32px auto 64px; padding: 20mm 18mm 16mm; background: var(--surface-0); box-shadow: var(--shadow-lg); border: 1px solid var(--rule); }
.report-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--ink); }
.report-head .brand { font-size: 18px; }
.report-head .brand small em { font-style: italic; }
.report-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; color: var(--ink-3); }
.report-meta .eyebrow { margin: 0; font-size: 11.5px; }
.report-title { font-size: 34px; font-weight: 300; line-height: 1.1; margin: 28px 0 6px; letter-spacing: -.02em; }
.report-title em { font-style: italic; font-weight: 400; color: var(--ink-2); }
.report-sub { margin: 0 0 8px; font-size: 13.5px; color: var(--ink-2); }
.report-section { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--rule); break-inside: avoid; }
.report-section h2 { font-size: 20px; margin: 0 0 14px; }
.report-section .card-head { margin-bottom: 10px; }
.report-section.two { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 36px; }
.report-section.two > div { min-width: 0; }
.report .grid.kpi { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.report-kpi .tile { padding: 14px 12px 12px 0; margin-right: 12px; }
.report-kpi .tile .value { font-size: 30px; margin: 8px 0 4px; }
.report-kpi .tile .label { font-size: 11.5px; white-space: nowrap; }
.report-kpi .tile .delta { font-size: 12px; }
.report .chart-wrap.short { height: 200px; }
.report .kv { font-size: 13.5px; gap: 9px 18px; grid-template-columns: minmax(0, 1fr) auto; }
.report .kv dd { text-align: right; white-space: nowrap; }
.report table { font-size: 12.5px; }
.report th, .report td { padding: 8px 10px; }
.report th:first-child, .report td:first-child { white-space: normal; }
.report .table-wrap table td:first-child { min-width: 170px; }
.report .table-wrap th, .report .table-wrap td { padding: 7px 6px; }
.report .mono { font-size: 11px; }
.report table.period th, .report table.period td { padding-left: 8px; }
.report .table-wrap { overflow: visible; }
.report-note { font-size: 12px; color: var(--ink-3); margin: 10px 0 0; }
.report-foot { display: flex; justify-content: space-between; gap: 16px; margin-top: 36px; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 11px; color: var(--ink-3); }
@media screen and (max-width: 860px) { .report { width: auto; margin: 0; padding: 20px 16px; border: 0; box-shadow: none; } .report-section.two { grid-template-columns: 1fr; gap: 24px; } }

/* ---- responsywność ---- */
@media (max-width: 1400px) {
  .topbar { gap: 28px; padding: 0 32px; }
  .nav { gap: 22px; }
  .userbox .email { max-width: 200px; }
}
/* Nagłówek nigdy nie wychodzi poza ekran: przy węższym oknie zawija się do drugiego wiersza (Wyloguj / Hasło zawsze widoczne). */
@media (max-width: 1360px) {
  .topbar { height: auto; min-height: 64px; flex-wrap: wrap; row-gap: 6px; padding-top: 10px; padding-bottom: 10px; }
  .topbar .userbox { margin-left: auto; }
}
@media (max-width: 1100px) {
  .grid.flow-row, .flowrow { grid-template-columns: 1fr; gap: 44px; }
  .grid.two { gap: 44px; }
  .topbar .brand small, .userbox .email { display: none; }
}
@media (max-width: 980px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .brand-mobile { display: flex; }
  .topbar { padding: 0 24px; gap: 24px; }
  .container { padding: 32px 24px 56px; }
}
@media (max-width: 720px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 8px 16px; }
  .topbar .brand small, .topbar .userbox .email { display: none; }
  .topbar .spacer { display: none; }
  .topbar .userbox { margin-left: auto; }
  .nav { order: 3; width: 100%; gap: 0; height: auto; border-top: 1px solid var(--rule); margin-top: 6px; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: 1 0 auto; justify-content: center; height: 44px; font-size: 14px; padding: 0 12px; }
  .container { padding: 24px 16px 48px; }
  .page-title h1 { font-size: 30px; }
  .page-title { margin-bottom: 28px; }
  .page-status { align-items: flex-start; text-align: left; }
  .page-status .controls { justify-content: flex-start; }
  .grid.kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { padding: 16px 12px 14px 0; margin-right: 12px; }
  .grid.kpi > .tile:nth-child(2n) { border-right: 0; margin-right: 0; }
  .tile .value { font-size: 32px; }
  .chart-wrap { height: 250px; }
  .chart-wrap.tall { height: 300px; }
  .card-head .controls { margin-left: 0; width: 100%; }
  .section { margin-top: 32px; padding-top: 24px; }
  .auth-form { padding: 28px 16px; }
  .login-card h1 { font-size: 30px; }
  .demo-ribbon > span { display: none; }
  th, td { padding: 10px 8px; }
}

/* ---- wydruk ---- */
@media print {
  :root, :root[data-theme="dark"] {
    color-scheme: light;
    --surface-0: #fff; --surface-1: #fff; --surface-2: #f4f4f4; --rule: #ddd; --rule-strong: #999;
    --ink: #111; --ink-2: #444; --ink-3: #666; --navy: #1e2a3d; --on-navy: #fff;
    --series-prod: #b07d24; --series-import: #3f5f8f; --series-export: #3d7a5c; --series-self: #8c5b7e;
    --status-good: #2f6b4d; --status-warning: #8a5a0c; --status-critical: #9e3427;
  }
  @page { size: A4 portrait; margin: 14mm 12mm; }
  body, .report-body { background: #fff; }
  .topbar, .controls, .seg, .toast, .demo-ribbon, .report-bar, .page-status .controls, .btn { display: none !important; }
  .card, .section, .report-section { break-inside: avoid; }
  .report { width: auto; min-height: 0; margin: 0; padding: 0; border: 0; box-shadow: none; background: #fff; }
  .report .chart-wrap.short { height: 150px; }
  .report-section { margin-top: 14px; padding-top: 10px; }
  .report-section h2 { font-size: 18px; margin-bottom: 8px; }
  .report-title { margin-top: 14px; font-size: 30px; }
  .report .kv { font-size: 12.5px; gap: 6px 16px; }
  .report table { font-size: 12px; } .report th, .report td { padding: 6px 8px; }
  .report-kpi .tile { padding: 10px 12px 8px 0; } .report-kpi .tile .value { font-size: 26px; margin: 4px 0 2px; }
  .report-foot { margin-top: 12px; padding-top: 8px; }
  a { text-decoration: none; color: inherit; }
}

/* przeglądarki bez color-mix() (starsze Chrome/Safari/Firefox na firmowych laptopach) */
@supports not (color: color-mix(in srgb, #000, #fff)) {
  a { text-decoration-color: var(--rule-strong); }
  .topbar, .report-bar { background: var(--surface-0); }
  .auth-hero .flow .rail { stroke: #55637c; }
  .hero-stats { border-top-color: #3b4759; }
}

/* ---- ankieta wdrożeniowa (Serwis → Wdrożenie → druk) ---- */
.report.ankieta { max-width: 900px; margin: 0 auto; }
.ankieta .report-head { display: flex; justify-content: space-between; gap: 32px; align-items: flex-start; border-bottom: 1px solid var(--ink); padding-bottom: 20px; margin-bottom: 8px; }
.ankieta .kicker { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 8px; }
.ankieta h1 { font-family: var(--serif); font-weight: 300; font-size: 30px; letter-spacing: -.02em; margin: 0 0 10px; }
.ankieta h1 em { font-style: italic; font-weight: 400; }
.ankieta .lead { font-size: 14px; color: var(--ink-2); max-width: 560px; margin: 0; }
.ankieta .report-meta { font-size: 13px; color: var(--ink-2); flex: none; display: grid; gap: 4px; padding-top: 30px; }
.ankieta h2 { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 28px 0 8px; display: flex; align-items: baseline; gap: 12px; }
.ankieta h2 small { font-family: var(--font); font-size: 12.5px; color: var(--ink-3); font-weight: 500; }
.ank-item { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 16px 24px; padding: 14px 0; border-top: 1px solid var(--rule); break-inside: avoid; }
.ank-q { display: grid; grid-template-columns: 28px 1fr; gap: 12px; font-size: 14px; }
.ank-q p { margin: 6px 0 0; line-height: 1.5; }
.ank-num { font-family: var(--serif); font-size: 20px; color: var(--sun, #b8860b); line-height: 1; padding-top: 2px; }
.ank-meta { font-size: 12.5px; color: var(--ink-2); display: flex; flex-direction: column; gap: 2px; }
.ank-answer { border: 1px solid var(--rule-strong); border-radius: 4px; min-height: 96px; padding: 6px 8px; font-size: 11px; color: var(--ink-3); background: var(--surface-1); }
.ank-foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--ink); font-size: 13px; color: var(--ink-2); }
.ank-item.wide { grid-template-columns: 1fr; }
.ank-table-wrap { overflow-x: auto; }
table.ank-table { font-size: 11.5px; border: 1px solid var(--rule-strong); }
table.ank-table th, table.ank-table td { border: 1px solid var(--rule-strong); padding: 6px 8px; white-space: normal; height: 26px; }
table.ank-table th { font-size: 11px; background: var(--surface-1); border-bottom: 1px solid var(--ink); }
table.ank-table td.pre { color: var(--ink-2); font-size: 11.5px; }
table.ank-table th:first-child, table.ank-table td:first-child { padding-left: 8px; }
table.ank-table th:last-child, table.ank-table td:last-child { padding-right: 8px; }
.ank-choices { display: grid; gap: 8px; margin-top: 4px; }
.ank-choice { display: grid; grid-template-columns: 16px 1fr; gap: 10px; align-items: start; font-size: 13px; line-height: 1.45; }
.ank-choice .box { width: 13px; height: 13px; border: 1.3px solid var(--ink); border-radius: 2px; margin-top: 3px; }
.ank-answer.small { min-height: 60px; margin-top: 4px; }
.ank-attachments .ank-choice { font-size: 13px; }
@media (max-width: 720px) { .ank-item { grid-template-columns: 1fr; } .ankieta .report-head { flex-direction: column; } .ankieta .report-meta { padding-top: 0; } }
@media print {
  body.print-doc { background: #fff; }
  .print-doc .topbar, .print-doc .report-bar { display: none !important; }
  .print-doc .container { padding: 0; max-width: none; }
  .report.ankieta { max-width: none; }
  .ank-answer { background: #fff; min-height: 88px; }
  .ank-item { page-break-inside: avoid; }
  table.ank-table th { background: #fff; }
  .ank-choices, .ank-table-wrap { break-inside: avoid; }
  .ankieta h2 { break-after: avoid; page-break-after: avoid; }
  .ank-area > h2 + .ank-item { break-before: avoid; page-break-before: avoid; }
}

.onb-options { margin: 4px 0 8px; padding-left: 18px; }
.onb-options li { margin: 2px 0; }

/* =====================================================================================
   Układ „pytanie → odpowiedź” (2.10.2026): ekran Miesiąc, Mój miesiąc, Serwis → Stan.
   Każdy ekran zaczyna się zdaniem i kilkoma liczbami; szczegóły są niżej, zwinięte.
   ===================================================================================== */
body { font-size: 16px; }
.hint { font-size: 13.5px; }
a.brand { text-decoration: none; }
.page-title h1 em { color: var(--ink-2); }

/* odpowiedź zdaniem */
.answer { margin: 0 0 32px; max-width: 62ch; }
.answer .lead { font-family: var(--serif); font-variation-settings: 'opsz' 60, 'SOFT' 30; font-size: 27px; line-height: 1.3; font-weight: 300; letter-spacing: -.012em; margin: 0; color: var(--ink); text-wrap: pretty; }
.answer .lead + .lead { margin-top: 10px; }
.answer .lead.second { font-size: 21px; color: var(--ink-2); }
.answer .lead b { font-weight: 500; color: var(--ink); white-space: nowrap; }
#banner .alert, #mBanner .alert, #liveBanner .alert { margin: 0 0 28px; font-size: 15px; line-height: 1.5; }

/* wybór miesiąca: duże strzałki, jedno pole */
.monthnav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.monthnav .btn { width: 44px; height: 44px; padding: 0; font-size: 22px; line-height: 1; }
.monthnav input[type="month"], .monthnav select { height: 44px; padding: 0 12px; font-size: 16px; border: 1px solid var(--rule-strong); border-radius: 4px; background: var(--surface-1); min-width: 190px; }

.good { color: var(--status-good); }
.bad { color: var(--status-critical); }
.tag { display: inline-block; margin-left: 8px; padding: 1px 7px; border: 1px solid var(--rule-strong); border-radius: 10px; font-size: 11.5px; font-weight: 500; color: var(--ink-2); vertical-align: 1px; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

/* kto ma niedobór */
.rank { list-style: none; margin: 0; padding: 0; max-width: 620px; }
.rank li { display: flex; align-items: baseline; gap: 8px; padding: 11px 0; border-bottom: 1px solid var(--rule); font-size: 16px; }
.rank li.more { border-bottom: 0; }
.rank .rank-val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--status-critical); white-space: nowrap; }

/* tabela spółdzielców: wiersz rozwijany, nazwa zawsze widoczna */
table.people td { padding-top: 13px; padding-bottom: 13px; font-size: 15px; }
table.people tr.clickable { cursor: pointer; }
table.people tr.clickable:hover td { background: var(--surface-1); }
table.people tr.open td { border-bottom-color: transparent; background: var(--surface-1); }
table.people tr.detail-row td { white-space: normal; padding: 4px 0 28px; background: var(--surface-1); }
.detail { padding: 0 16px; max-width: 980px; }
.detail .kv { grid-template-columns: minmax(0, max-content) 1fr; }
.detail .history { margin-top: 20px; }
.detail .history table { font-size: 13.5px; }
.detail details.adjust { margin-top: 18px; border-top: 1px solid var(--rule); padding-top: 14px; }
.detail details.adjust summary { cursor: pointer; font-weight: 500; }
.detail details.adjust .form-grid { margin-top: 12px; }
.stick-first th:first-child, .stick-first td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface-0); }
.stick-first tr.open td:first-child, .stick-first tr.clickable:hover td:first-child { background: var(--surface-1); }

/* zwijane sekcje */
details.fold, details.explain { border-top: 1px solid var(--rule); }
details.fold > summary, details.explain > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 12px; font-family: var(--serif); font-size: 22px; padding: 4px 0; }
details.fold > summary::-webkit-details-marker, details.explain > summary::-webkit-details-marker { display: none; }
details.fold > summary::before, details.explain > summary::before { content: '+'; display: inline-grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--rule-strong); border-radius: 50%; font-family: var(--font); font-size: 18px; line-height: 1; flex: none; }
details.fold[open] > summary::before, details.explain[open] > summary::before { content: '−'; }
details.fold[open] > summary, details.explain[open] > summary { margin-bottom: 24px; }
details.fold > .section:first-of-type, details.fold > section:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.card-plain { border-top: 1px solid var(--rule); }
.glossary { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 12px 28px; margin: 0 0 20px; font-size: 15px; max-width: 900px; }
.glossary dt { font-weight: 600; }
.glossary dd { margin: 0; color: var(--ink-2); }

/* Serwis → Stan */
.checks { list-style: none; margin: 0 0 12px; padding: 0; max-width: 900px; }
.checks li { display: grid; grid-template-columns: 84px 1fr; gap: 16px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.checks li b { display: block; font-size: 16px; font-weight: 600; }
.checks li .hint { display: block; margin-top: 2px; }
.checks li.error b { color: var(--status-critical); }
.tabs a.tab-link { display: inline-flex; align-items: center; height: 44px; margin-left: auto; font-size: 14px; color: var(--ink-2); }

/* pola wyłączone mają wyglądać na wyłączone */
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--ink-3); cursor: not-allowed; }

/* raport: wykres nie może wyjść poza swoje pole (na wydruku najeżdżał na sekcje poniżej) */
.report .chart-wrap { overflow: hidden; }
@media print {
  .report .chart-wrap.short { height: 190px !important; }
  .report .chart-wrap canvas { max-width: 100% !important; max-height: 100% !important; }
  .report-section { break-inside: avoid; }
}

@media (max-width: 980px) {
  .topbar .nav { gap: 18px; }
  .answer .lead { font-size: 23px; }
  .answer .lead.second { font-size: 18px; }
}

/* telefon: jedna kolumna, karty zamiast szerokich tabel, przyciski pod palec */
@media (max-width: 720px) {
  body { font-size: 16px; }
  .btn, .btn.small, .seg button { min-height: 44px; font-size: 15px; }
  .monthnav { width: 100%; }
  .monthnav input[type="month"], .monthnav select { flex: 1; min-width: 0; }
  .answer .lead { font-size: 21px; }
  .answer .lead.second { font-size: 17px; }
  .grid.kpi { grid-template-columns: 1fr 1fr; }
  .grid.kpi .tile { padding: 16px 12px 14px 0; margin-right: 12px; }
  .grid.kpi .tile:nth-child(2n) { border-right: 0; margin-right: 0; }
  .grid.kpi .tile .value { font-size: 30px; margin: 10px 0 6px; }
  .glossary { grid-template-columns: 1fr; gap: 4px; }
  .glossary dd { margin-bottom: 12px; }
  .checks li { grid-template-columns: 1fr; gap: 6px; }
  .tabs a.tab-link { margin-left: 0; }

  table.people thead { display: none; }
  table.people, table.people tbody, table.people tr, table.people td { display: block; width: 100%; }
  table.people tr { padding: 12px 0; border-bottom: 1px solid var(--rule-strong); }
  table.people td { border: 0; padding: 3px 0; white-space: normal; text-align: left; position: static; }
  table.people td[data-label].num { display: flex; justify-content: space-between; gap: 16px; }
  table.people td[data-label].num::before { content: attr(data-label); color: var(--ink-2); font-weight: 400; }
  table.people tr.total td { border-top: 0; }
  table.people tr.detail-row { padding: 0 0 16px; }
  .detail { padding: 0; }
  .detail .kv { grid-template-columns: 1fr; gap: 2px; }
  .detail .kv dd { margin-bottom: 8px; font-weight: 600; }

  /* raport: pasek narzędzi w dwóch wierszach, miesiąc na pełną szerokość */
  .report-bar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .report-bar .bar-hint, .report-bar .spacer { display: none; }
  .report-bar #month { order: 3; flex: 1 0 100%; height: 44px; font-size: 16px; }
  .report-bar #printBtn { margin-left: auto; }
  .report-head { flex-direction: column; gap: 8px; }
  .report-meta { align-items: flex-start; }
  .report .kv { grid-template-columns: 1fr; gap: 2px; }
  .report .kv dd { text-align: left; white-space: normal; font-weight: 600; margin-bottom: 8px; }
  .report-title { font-size: 26px; }
}

/* =====================================================================================
   Runda 2 (2.10.2026, po obejrzeniu w przeglądarce 390 px i 1366 px): telefon i drobne usterki wyglądu.
   ===================================================================================== */
.rank-who { min-width: 0; }
.answer .why { margin: 12px 0 0; font-size: 14.5px; line-height: 1.5; max-width: 60ch; }
table.ledger td:first-child b { font-weight: 500; }

.adjust-target { margin: 12px 0 0; font-size: 15px; }
.adjust-target b { font-weight: 600; }
.detail details.adjust .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* raport spółdzielni: tabela punktów mieści się w szerokości kartki A4 (wychodziła poza prawy margines) */
.report #ppeTable table { width: 100%; }
.report #ppeTable th { white-space: normal; vertical-align: bottom; line-height: 1.25; }
.report #ppeTable th, .report #ppeTable td { padding-left: 6px; padding-right: 6px; }
.report #ppeTable td.mono { font-size: 10px; white-space: nowrap; letter-spacing: -.02em; }
.report #ppeTable td:first-child { min-width: 130px; }

@media (max-width: 720px) {
  .only-wide, table.people td.only-wide-cell { display: none !important; }

  /* pasek górny: wszystkie pozycje menu widoczne (było przewijanie w bok bez żadnego znaku, „Administracja” ucięta) */
  .topbar { padding: 8px 14px 0; gap: 6px 10px; }
  .topbar .brand { font-size: 17px; }
  .topbar .userbox { gap: 6px; }
  .topbar .btn.small { min-height: 36px; height: 36px; font-size: 14px; padding: 0 10px; }
  .nav { overflow: visible; flex-wrap: wrap; justify-content: flex-start; margin-top: 4px; }
  .nav a { flex: 0 0 auto; height: 42px; padding: 0 2px; margin-right: 18px; font-size: 15px; }
  .nav a:last-child { margin-right: 0; }

  /* nagłówek strony i sekcji w jednej kolumnie */
  .page-title { gap: 14px; }
  .page-title h1 { font-size: 30px; line-height: 1.15; }
  .card-head { flex-wrap: wrap; row-gap: 8px; }
  .card-head .controls { width: 100%; margin-left: 0; flex-wrap: wrap; }

  /* przełączniki: pełna szerokość, równe pola, nic nie ucieka poza ekran */
  .seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); width: 100%; }
  #filterSeg { grid-template-columns: 1fr 1fr; }
  .nav a:only-child { display: none; }
  .nav:has(a:only-child) { border-top: 0; margin-top: 0; }
  .page-status, .page-status .controls { width: 100%; }
  .seg button { height: auto; padding: 6px 8px; white-space: normal; line-height: 1.25; border-bottom: 1px solid var(--rule); margin-bottom: -1px; }

  /* kto ma niedobór: nazwa i numer pod sobą, liczba po prawej w jednej linii z nazwą */
  .rank li { align-items: flex-start; gap: 12px; }
  .rank-who { display: flex; flex-direction: column; gap: 2px; }
  .rank-who .muted { font-size: 13.5px; }

  /* karty spółdzielców i historii magazynu */
  table.people tr.total { border-bottom: 0; background: var(--surface-1); padding: 14px 12px; margin-top: 8px; }
  table.people tr.total td { font-weight: 600; }
  table.ledger tr td:first-child { font-size: 16px; padding-bottom: 6px; }
  table.people td.num { text-align: right; }

  /* rozwinięcie wiersza: etykieta po lewej, wartość po prawej (było jedno pod drugim – dwa ekrany przewijania) */
  .detail { padding: 4px 12px 0; }
  .detail .kv { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; align-items: baseline; }
  .detail .kv dt { color: var(--ink-2); }
  .detail .kv dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }
  .detail .actions-row .btn { flex: 1 1 100%; justify-content: center; }
  .actions-row .btn { flex: 1 1 100%; justify-content: center; text-align: center; }
  .detail .history { overflow-x: auto; }

  /* raport: dwa kafle w wierszu, podpisy się nie nakładają */
  .report .grid.kpi { grid-template-columns: 1fr 1fr; column-gap: 16px; }
  .report .grid.kpi .tile { min-width: 0; border-right: 0; margin-right: 0; padding-right: 0; }
  .report .grid.kpi .tile .sub, .grid.kpi .tile .sub { overflow-wrap: anywhere; }
  .report-meta { text-align: left; }

  /* zakładki (Administracja, Serwis): zawijane ciasno, bez pustych wierszy */
  .tabs { flex-wrap: wrap; gap: 0 18px; }
  .tabs a, .tabs button { height: 40px; }

  /* formularze: jedno pole w wierszu */
  .form-grid { grid-template-columns: 1fr !important; }
  .modal { width: calc(100vw - 24px); max-height: calc(100vh - 24px); overflow: auto; padding: 18px 16px; }

  /* nic nie wychodzi poza ekran: etykiety stanu, formularze Serwisu, tabela raportu spółdzielni */
  .badge { max-width: 100%; white-space: normal; text-align: left; }
  .field, .field input, .field select, .field textarea { max-width: 100%; min-width: 0; }
  .field select { width: 100%; }
  .inline { flex-wrap: wrap; }
  .kv dd, .kv dd.mono { overflow-wrap: anywhere; min-width: 0; }
  .report-section { overflow-x: auto; }
}

/* =====================================================================================
   Runda 3 (2.10.2026, po przeglądzie wizualnym na 1150 px / 394 px): rozwinięty wiersz, raport na telefonie, menu.
   ===================================================================================== */
/* Miesiąc: tabela mieści się na laptopie – nazwa może się zawijać, węższe odstępy, przycisk nie jest ucinany */
table.people tr:not(.detail-row) td:first-child { white-space: normal; min-width: 180px; max-width: 320px; }
table.people th, table.people td { padding-left: 10px; padding-right: 10px; }
table.people tr:not(.detail-row):not(.total) td:last-child { white-space: nowrap; width: 1%; }
/* panel szczegółów nie przewija się razem z tabelą (znikały pierwsze litery etykiet) */
table.people tr.detail-row td { position: static; }
.detail { position: sticky; left: 0; box-sizing: border-box; width: min(980px, calc(100vw - 96px)); }
.detail .actions .push { flex: 1 1 auto; }
.detail .history table td, .detail .history table th { padding: 8px 14px 8px 0; }
table.adjust-table td { white-space: normal; }
/* raport: tabela punktów przewija się w swoim polu także na telefonie */
#ppeTable { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 720px) {
  /* rozwinięty wiersz: etykieta nad wartością (kolumna etykiet zapadała się do zera i tekst łamał się po słowie) */
  .detail { width: auto; position: static; }
  .detail .kv { display: block; }
  .detail .kv dt { color: var(--ink-2); font-size: 13.5px; margin-top: 10px; }
  .detail .kv dd { margin: 2px 0 0; text-align: left; font-weight: 600; }
  table.people tr:not(.detail-row) td:first-child { max-width: none; min-width: 0; }
  table.people tr:not(.detail-row):not(.total) td:last-child { width: 100%; white-space: normal; }
  table.people tr.detail-row td { width: 100%; box-sizing: border-box; }
  /* menu: cztery pozycje zarządu w jednym rzędzie */
  .nav a { margin-right: 14px; font-size: 14.5px; }
  /* schemat przepływu: podpisy nie mniejsze niż ok. 12 px – schemat można przewinąć w bok */
  .flow, .flow-wrap, #flow { overflow-x: auto; }
  .flow svg, .flow-wrap svg, #flow svg { min-width: 520px; }
}

/* Runda 4 (2.10.2026): puste wykresy, szerokie tabele Administracji i Serwisu */
.chart-wrap { position: relative; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); font-size: 15px; text-align: center; padding: 12px; }
.chart-empty[hidden] { display: none; }
/* kolumna z przyciskami zawsze widoczna przy prawej krawędzi przewijanej tabeli (były ucinane „Edytuj”, „Test odczytu”) */
.table-wrap table tr > td:last-child:has(> .btn), .table-wrap table tr > td:last-child:has(> button) { position: sticky; right: 0; background: var(--surface-0); box-shadow: -10px 0 10px -10px rgba(0,0,0,.18); }
/* długie opisy w tabelach uprawnień i dziennika zawijają się zamiast wypychać kolumny poza ekran */
.table-wrap td.wrap, .perm-table td, .perm-table th { white-space: normal; }
.table-wrap table td .hint { white-space: normal; }
@media print { .chart-empty { position: static; padding: 24px 0; } .table-wrap table tr > td:last-child { position: static; box-shadow: none; } }
