/* SENTINEL (2026-09-27, stage C) — new file, package C4-KARTA-UI of etap-c/PLAN.md (§4.9, §5).
   The Karta: list of people, one editable screen per person, sheets, "Do decyzji", "Zmiany", template editor
   (wzory.js). Everything is scoped under `.kt` (screen), `.kt-sheet*` (bottom sheets), `.kt-bar` (sticky save bar)
   and `.kt-toast`; colours come from the panel variables of styl.css, so light and dark follow the panel.
   Phone first (390 px, one hand): every tap target >= 44 px, primary actions on the RIGHT and at the bottom, the
   top-right corner stays with `.kciuk` (PULAPKI), explanations only under "?". */

.kt { --kt-bar-h: 72px; }
.kt .kt-screen-title { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }

/* ---------- "?" with a real 44 px target (the panel's .pyt is 18 px + a pseudo hit area) ---------- */
.kt button.pyt, .kt-sheet button.pyt {
  width: 44px; height: 44px; margin: -12px -10px -12px -6px; border: 0; background: none;
  font-size: 0; color: var(--slaby); flex: none;
}
.kt button.pyt::after, .kt-sheet button.pyt::after { content: none; }
.kt button.pyt::before, .kt-sheet button.pyt::before {
  content: "?"; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 999px;
  border: 1px solid var(--linia); font-size: 12px; font-weight: 600; line-height: 1;
}
.kt button.pyt[aria-expanded="true"]::before, .kt-sheet button.pyt[aria-expanded="true"]::before { color: var(--tekst); border-color: var(--tekst); }
.kt .pomoc-sekcji { margin: 4px 0 8px; }

/* ---------- list ---------- */
.kt-decide-banner {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; margin: 0 0 12px;
  padding: 10px 14px; border-radius: var(--r); text-align: left; font-weight: 600;
  color: var(--alarm); border: 1px solid color-mix(in srgb, var(--alarm) 45%, var(--linia));
  background: color-mix(in srgb, var(--alarm) 7%, var(--tlo));
}
.kt-person {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 64px; margin: 0 0 8px;
  padding: 12px 14px; text-align: left; font-weight: 400;
  background: var(--tlo2); border: 1px solid var(--linia); border-radius: var(--r); color: var(--tekst);
}
.kt-p-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kt-p-name { font-weight: 700; font-size: 16px; }
.kt-p-sub, .kt-p-counts { font-size: 13px; color: var(--slaby); overflow-wrap: anywhere; }
.kt-p-badge {
  flex: none; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 13px; display: grid; place-items: center;
  background: var(--alarm); color: #fff; font-size: 13px; font-weight: 700;
}
.kt-chev { flex: none; font-size: 22px; color: var(--slaby); }
.kt-state { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--linia); color: var(--slaby); }
.kt-state-warn { color: var(--alarm); border-color: color-mix(in srgb, var(--alarm) 50%, var(--linia)); }
.kt-right { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin: 4px 0 16px; }

/* ---------- buttons ---------- */
.kt button, .kt-sheet button, .kt-bar button, .kt-toast button { min-height: 44px; }
.kt-primary { background: var(--akcent); color: var(--tlo); border-color: var(--akcent); }
.kt-danger { color: var(--alarm); border-color: var(--alarm); }
.kt-danger.kt-primary { background: var(--alarm); color: #fff; border-color: var(--alarm); }
.kt-quiet { border-color: transparent; background: none; color: var(--slaby); font-weight: 600; }
.kt-link { border: 1px solid var(--linia); background: var(--tlo); font-weight: 600; padding: 10px 14px; }

/* ---------- sections (details) ---------- */
.kt-sec { border: 1px solid var(--linia); border-radius: var(--r); background: var(--tlo2); margin: 0 0 10px; }
.kt-sec > summary {
  list-style: none; display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 4px 14px;
  cursor: pointer; font-weight: 700;
}
.kt-sec > summary::-webkit-details-marker { display: none; }
.kt-sec > summary::before { content: "▸"; color: var(--slaby); font-size: 14px; width: 12px; flex: none; }
.kt-sec[open] > summary::before { content: "▾"; }
.kt-sec-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.kt-sec-body { padding: 0 14px 12px; }
.kt-counts { display: inline-flex; align-items: center; gap: 8px; }
.kt-h { display: flex; align-items: center; gap: 4px; }
.kt-count { font-size: 13px; font-weight: 600; color: var(--slaby); }
.kt-diffs { font-size: 13px; font-weight: 700; color: var(--alarm); white-space: nowrap; }
.kt-group { border-top: 1px solid var(--linia); }
.kt-group > summary {
  list-style: none; display: flex; align-items: center; gap: 8px; min-height: 48px; cursor: pointer; font-weight: 600;
}
.kt-group > summary::-webkit-details-marker { display: none; }
.kt-group > summary::before { content: "▸"; color: var(--slaby); font-size: 13px; width: 12px; flex: none; }
.kt-group[open] > summary::before { content: "▾"; }
.kt-note { font-size: 13px; color: var(--slaby); margin: 2px 0 8px; }

/* ---------- one row = one item ---------- */
.kt-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 0 8px 10px; margin-left: -10px;
  border-left: 3px solid transparent; border-top: 1px solid color-mix(in srgb, var(--linia) 60%, transparent);
}
.kt-row:first-child { border-top: 0; }
.kt-row-main { flex: 1 1 96px; min-width: 0; }
.kt-row-extra { flex: 1 1 100%; min-width: 0; margin-top: -2px; }
.kt-label { font-weight: 600; font-size: 14px; display: inline; overflow-wrap: break-word; hyphens: auto; }
.kt-ctl { flex: none; margin-left: auto; display: flex; align-items: center; gap: 6px; }
.kt-seg { display: flex; border: 1px solid var(--linia); border-radius: var(--r); overflow: hidden; background: var(--tlo); }
.kt-seg button {
  border: 0; border-radius: 0; min-width: 48px; min-height: 44px; padding: 8px 10px; font-size: 14px; font-weight: 600;
  background: var(--tlo); color: var(--slaby);
}
.kt-seg button + button { border-left: 1px solid var(--linia); }
.kt-seg button[aria-pressed="true"] { background: var(--akcent); color: var(--tlo); }
.kt-ro { font-size: 14px; font-weight: 600; color: var(--slaby); }
.kt-reset { width: 44px; min-width: 44px; padding: 0; font-size: 20px; line-height: 1; border-radius: var(--r); }
.kt-row.kt-diff { border-left-color: var(--alarm); }
.kt-diffline { font-size: 13px; color: var(--alarm); font-weight: 600; margin-top: 2px; }
.kt-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--alarm); margin-right: 6px; vertical-align: 1px; }
.kt-row.kt-changed:not(.kt-diff) { border-left-color: var(--akcent); }
.kt-changed-mark { font-size: 12px; font-weight: 700; color: var(--tekst); margin-top: 2px; }
.kt-chip { display: inline-block; font-size: 12px; font-weight: 600; margin-top: 3px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--linia); color: var(--slaby); background: var(--tlo); }
.kt-warn { font-size: 13px; color: var(--alarm); margin-top: 2px; }
.kt-sub { font-size: 13px; color: var(--slaby); margin-top: 2px; overflow-wrap: anywhere; }

/* ---------- Karta head ---------- */
.kt-head {
  position: sticky; top: calc(var(--belka-h) + env(safe-area-inset-top)); z-index: 6;
  display: flex; align-items: center; gap: 6px; margin: -16px -16px 12px; padding: 6px 12px;
  background: var(--tlo); border-bottom: 1px solid var(--linia);
}
.kt-back { width: 44px; min-width: 44px; padding: 0; font-size: 26px; line-height: 1; border-color: transparent; background: none; }
.kt-head-main { flex: 1; min-width: 0; }
.kt-name { font-weight: 800; font-size: 18px; overflow-wrap: anywhere; }
.kt-subline { font-size: 13px; color: var(--slaby); overflow-wrap: anywhere; }
.kt-more { width: 44px; min-width: 44px; padding: 0; font-size: 22px; line-height: 1; }
.kt-status { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; margin: 0 0 10px; padding: 8px 12px;
  border-radius: var(--r); border: 1px solid var(--linia); background: var(--tlo); }
.kt-status[hidden] { display: none; }
.kt-status-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--linia)); }
.kt-status-warn { color: var(--alarm); border-color: color-mix(in srgb, var(--alarm) 45%, var(--linia)); }
.kt-banner { font-size: 14px; font-weight: 600; margin: 0 0 10px; padding: 10px 12px; border-radius: var(--r);
  color: var(--alarm); background: color-mix(in srgb, var(--alarm) 8%, var(--tlo)); border: 1px solid color-mix(in srgb, var(--alarm) 45%, var(--linia)); }
.kt-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.kt-chips button { min-height: 44px; padding: 6px 14px; border-radius: 999px; font-weight: 600; }
.kt-risks { margin: 0; padding-left: 20px; font-size: 14px; }
.kt-risks li { margin: 4px 0; }
.kt-agentline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0 10px; border-bottom: 1px solid var(--linia); margin-bottom: 4px; }

/* ---------- "Do decyzji" ---------- */
.kt-decide { padding: 10px 0; border-top: 1px solid color-mix(in srgb, var(--linia) 60%, transparent); }
.kt-decide:first-child { border-top: 0; }
.kt-decide-text { font-size: 14px; overflow-wrap: anywhere; }
.kt-decide-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.kt-decide-actions button { padding: 8px 12px; font-size: 14px; }
.kt-decide-actions button[aria-pressed="true"] { background: var(--akcent); color: var(--tlo); border-color: var(--akcent); }
.kt-decide-group { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--slaby);
  display: flex; align-items: center; gap: 8px; margin: 12px 0 2px; }
.kt-decide-group .kt-link { margin-left: auto; text-transform: none; letter-spacing: 0; font-size: 13px; }
/* SENTINEL (2026-09-27, stage C) review round 3 UI-11 — "Zostaw wszystkie" inherited the grey group-header colour at 13 px
   and looked disabled next to the black "Zostaw" buttons: same colour and size as the other decide buttons */
.kt-decide-group .kt-link { color: var(--tekst); font-size: 14px; }

/* ---------- "Zmiany" ---------- */
.kt-batch { padding: 10px 0; border-top: 1px solid color-mix(in srgb, var(--linia) 60%, transparent); }
.kt-batch:first-child { border-top: 0; }
.kt-batch-head { display: flex; align-items: center; gap: 8px; }
.kt-batch-when { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--slaby); }
.kt-batch ul { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.kt-batch li { margin: 2px 0; overflow-wrap: anywhere; }
.kt-batch-more > summary { list-style: none; min-height: 44px; display: flex; align-items: center; font-size: 13px; color: var(--slaby); cursor: pointer; }
.kt-batch-more > summary::-webkit-details-marker { display: none; }
.kt-batch-note { font-size: 12px; color: var(--slaby); margin-top: 4px; }

/* ---------- sticky save bar (only with a draft) ---------- */
.kt-bar {
  position: fixed; z-index: 60; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--tlo); border-top: 1px solid var(--linia); box-shadow: 0 -6px 18px rgba(0,0,0,.12);
}
.kt-bar[hidden] { display: none; }
.kt-bar-info { flex: 1; min-width: 0; font-size: 13px; color: var(--slaby); }
.kt-bar .kt-primary { min-width: 140px; }
[data-tryb="komputer"][data-studio="obok"] .kt-bar { right: var(--studio-szer); }
/* the lightning (#b-quick) and the phone thumb buttons move above the bar while a draft exists */
[data-karta-draft] #b-quick { bottom: calc(18px + var(--kt-bar-lift, 72px) + env(safe-area-inset-bottom, 0px)); }
/* SENTINEL (2026-09-27, stage C) review round 3 UI-10 — the lightning (60 px at right 18 px) sat over the Karta's right column
   ("Praca", "tak", ↺, ⋯, values in read mode): hidden while the Karta or the template editor is on screen, as the
   drawer/dialogs already hide it (styl.css). Other sections: unchanged. */
html[data-sekcja="ludzie"]:has(.kt) #b-quick { display: none; }
[data-karta-draft] .tresc { padding-bottom: calc(260px + env(safe-area-inset-bottom)); }

/* ---------- bottom sheets (no prompt/alert/confirm anywhere) ---------- */
.kt-sheet-backdrop {
  position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.kt-sheet {
  width: 100%; max-width: 640px; max-height: 88vh; overflow: hidden; display: flex; flex-direction: column;
  background: var(--tlo); color: var(--tekst); border-radius: 18px 18px 0 0; border-top: 1px solid var(--linia);
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 24px rgba(0,0,0,.3);
}
.kt-sheet-grab { width: 40px; height: 4px; border-radius: 2px; background: var(--linia); margin: 0 auto 12px; }
.kt-sheet-title { display: flex; align-items: center; gap: 6px; font-size: 18px; font-weight: 800; margin: 0 0 10px; overflow-wrap: anywhere; }
.kt-sheet-grab, .kt-sheet-title, .kt-sheet > .pomoc-sekcji, .kt-sheet-msg, .kt-sheet-actions { flex: none; }
/* the body scrolls, the buttons stay at the bottom under the thumb (a long list never pushes them off the screen) */
.kt-sheet-body { font-size: 14px; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.kt-sheet > form { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.kt-sheet-body ul { margin: 4px 0 10px; padding-left: 18px; }
.kt-sheet-body li { margin: 3px 0; overflow-wrap: anywhere; }
.kt-sheet-who { font-weight: 700; margin: 10px 0 2px; }
.kt-sheet-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.kt-sheet-actions .kt-primary { min-width: 140px; }
.kt-sheet-actions .kt-spacer { flex: 1; }
.kt-sheet-list { display: flex; flex-direction: column; gap: 6px; }
.kt-sheet-list button { text-align: left; width: 100%; min-height: 52px; font-weight: 600; }
.kt-sheet-list button[aria-pressed="true"] { background: var(--akcent); color: var(--tlo); border-color: var(--akcent); }
.kt-sheet-list button.kt-danger { color: var(--alarm); }
.kt-sheet label { display: block; font-size: 13px; font-weight: 600; color: var(--slaby); margin: 8px 0 4px; }
.kt-sheet input[type="text"], .kt-sheet input[type="password"], .kt-sheet select {
  width: 100%; min-height: 44px; padding: 10px 12px; font-size: 16px; background: var(--tlo); color: var(--tekst);
  border: 1px solid var(--linia); border-radius: var(--r); margin: 0 0 6px;
}
.kt-sheet label.kt-check, .kt-check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; font-weight: 400; color: var(--tekst); margin: 4px 0; }
.kt-check input { width: 22px; height: 22px; }
.kt-secret { font: 700 20px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; padding: 10px 12px;
  border: 1px dashed var(--linia); border-radius: var(--r); overflow-wrap: anywhere; user-select: all; }
.kt-msg { font-size: 14px; margin: 8px 0; padding: 10px 12px; border-radius: var(--r); }
.kt-msg-bad { color: var(--alarm); background: color-mix(in srgb, var(--alarm) 10%, transparent); }
.kt-msg-ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.kt-gain { color: var(--ok); }
.kt-loss { color: var(--alarm); }

/* ---------- toast "Zapisane · Cofnij" ---------- */
.kt-toast {
  position: fixed; z-index: 70; left: 12px; right: 12px; bottom: calc(96px + env(safe-area-inset-bottom));
  max-width: 520px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 16px;
  background: var(--akcent); color: var(--tlo); border-radius: var(--r); box-shadow: 0 8px 24px rgba(0,0,0,.25); font-weight: 600;
}
.kt-toast { pointer-events: none; }   /* only its button takes taps; the row under it stays usable */
.kt-toast span { flex: 1; }
.kt-toast button { pointer-events: auto; }
/* with a draft the bar and the lifted lightning take the bottom: the toast goes above both */
[data-karta-draft] .kt-toast { bottom: calc(var(--kt-bar-lift, 72px) + 96px + env(safe-area-inset-bottom)); }
.kt-toast button { background: none; border: 1px solid color-mix(in srgb, var(--tlo) 50%, transparent); color: var(--tlo); padding: 8px 14px; }
[data-tryb="komputer"][data-studio="obok"] .kt-toast { right: calc(var(--studio-szer) + 12px); }

/* ---------- computer: a little more air, same order ---------- */
[data-tryb="komputer"] .kt-head { top: calc(var(--belka-h) + env(safe-area-inset-top)); }

/* >>> SENTINEL (2026-09-29, stage D) D4-KARTA-UI (etap-d/PLAN.md §4.12): agent ceiling state, OD-D2 hint, "Maszyny — klucze" */
.kt-ceil { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0 8px 10px; margin: 0 0 6px -10px;
  border-left: 3px solid transparent; }
.kt-ceil-owned { border-left-color: var(--akcent); }
.kt-ceil .kt-sub { margin-top: 0; }
.kt-ceil .kt-link { margin-left: auto; }
.kt-card > .kt-ceil { margin: 0 0 10px; padding-left: 12px; } /* the agent's own Karta: same column as the sections */
.kt-after { font-style: italic; }
.kt-mcard { background: var(--tlo2); border: 1px solid var(--linia); border-radius: var(--r); padding: 10px 14px; margin: 0 0 8px; }
.kt-sec-body .kt-mcard { background: var(--tlo); }
.kt-mcard-head { display: flex; align-items: center; gap: 10px; }
.kt-mcard-head .rosnie { flex: 1; min-width: 0; }
.kt-mcard-head .kt-more { flex: none; margin-left: auto; }
.kt-keys { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--slaby); overflow-wrap: anywhere; }
.kt-keys li { margin: 2px 0; }
/* <<< SENTINEL (2026-09-29, stage D) D4-KARTA-UI */
/* SENTINEL (2026-09-30, stage E) E2-KARTA — "Czeka na zgodę administratora" block and its sheet lines */
.kt-approvals { margin: 8px 0 12px; }
.kt-approvals-head { margin-bottom: 6px; }
.kt-approval .kt-sub { margin: 0 6px 0 auto; white-space: nowrap; }
.kt-approval-lines { margin: 0 0 10px; padding-left: 18px; }
.kt-approval-lines li { margin: 4px 0; overflow-wrap: anywhere; }
/* SENTINEL (2026-10-13) ZGODA-ZBIORCZA: the collective card (one tap for many modules) — module heads and their state line */
.kt-collective-state { margin: 0 0 2px; }
.kt-sheet-body [data-collective-module] { margin-top: 14px; }

/* SENTINEL (2026-10-19) KARTA-HEADER — the guard line under the "Moduły" section title („Strażnik zielony od N dni (cel 14)”):
   a second line of the title (wraps on a phone, never pushes the "?" off), normal weight, the panel's quiet colour; accent only for
   "cel osiągnięty", the alarm colour only for a stale / missing summary — the text says it either way. */
.kt-sec-stack { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.kt-gd { font-size: 13px; font-weight: 600; color: var(--slaby); line-height: 1.3; overflow-wrap: anywhere; }
.kt-gd-ok { color: var(--akcent); }
.kt-gd-warn { color: var(--alarm); }
