/* ===== Tokeny ===== */
:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f8f9f6;
  --border: #e2e4dd;
  --border-strong: #cdd1c7;
  --text: #1d231f;
  --text-2: #56605a;
  --muted: #7b847e;
  --brand: #2f5d50;
  --brand-ink: #ffffff;
  --brand-soft: #e3eee9;
  --accent: #c2410c;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #18794e;
  --warn: #a15c07;
  --focus: #2f5d50;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 2px 8px rgba(20, 30, 25, .04);
  --shadow-lg: 0 8px 28px rgba(20, 30, 25, .12);
  --radius: 10px;
  --radius-sm: 7px;

  --st-prio-bg: #fde8df; --st-prio-fg: #a3360a;
  --st-start-bg: #e3edfb; --st-start-fg: #1f4f99;
  --st-prog-bg: #fbf0d6; --st-prog-fg: #8a5a00;
  --st-own-bg: #eee8fb; --st-own-fg: #5b3aa8;
  --st-done-bg: #dff3e7; --st-done-fg: #16683f;
  --st-arch-bg: #ebecea; --st-arch-fg: #5f6662;

  --sidebar-w: 236px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #121614;
  --surface: #1a1f1c;
  --surface-2: #202622;
  --border: #2c3430;
  --border-strong: #3a443f;
  --text: #e6ebe7;
  --text-2: #b0bab4;
  --muted: #8a948e;
  --brand: #6fb39d;
  --brand-ink: #0d1411;
  --brand-soft: #1f342d;
  --accent: #f08a4b;
  --danger: #f26b5b;
  --danger-soft: #3a1f1c;
  --ok: #4fc28a;
  --warn: #e0a640;
  --focus: #6fb39d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .45);

  --st-prio-bg: #44241a; --st-prio-fg: #ffad85;
  --st-start-bg: #1d2c44; --st-start-fg: #9cc0f5;
  --st-prog-bg: #3d3018; --st-prog-fg: #f0c766;
  --st-own-bg: #2e2545; --st-own-fg: #c6b1f5;
  --st-done-bg: #17362a; --st-done-fg: #7fd9a8;
  --st-arch-bg: #2a2f2c; --st-arch-fg: #a7afaa;
  color-scheme: dark;
}

/* Strony bez logowania podążają za ustawieniem systemu */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --bg: #121614; --surface: #1a1f1c; --surface-2: #202622; --border: #2c3430; --border-strong: #3a443f;
    --text: #e6ebe7; --text-2: #b0bab4; --muted: #8a948e; --brand: #6fb39d; --brand-ink: #0d1411; --brand-soft: #1f342d;
    --danger: #f26b5b; --danger-soft: #3a1f1c; --focus: #6fb39d; color-scheme: dark;
  }
}

/* ===== Podstawy ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
code { font: .86em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border); padding: .1em .4em; border-radius: 5px; word-break: break-all; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.inline { display: inline; margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.ic { width: 18px; height: 18px; flex: none; }

/* ===== Układ ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 14px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--text); padding: 6px 8px 18px; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); }
.brand-mark .ic { width: 18px; height: 18px; stroke-width: 2.6; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: var(--text-2); font-weight: 550; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--brand-soft); color: var(--brand); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 12px 6px 4px; border-top: 1px solid var(--border); }
.side-user-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.side-user-txt b { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-txt small { color: var(--muted); font-size: .78rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 32px 64px; }

.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin-right: auto; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: .9rem; margin-bottom: 12px; }
.back:hover { color: var(--text); text-decoration: none; }
.back .ic { width: 16px; height: 16px; }

/* ===== Przyciski ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; font-size: .92rem; line-height: 1; padding: 10px 15px; min-height: 40px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; transition: background .12s, border-color .12s, transform .05s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger-outline { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.danger-outline:hover { background: var(--danger-soft); }
.btn.block { width: 100%; }
.btn-sm { min-height: 32px; padding: 6px 11px; font-size: .85rem; }
.btn .ic { width: 17px; height: 17px; }

/* "Ładny" przycisk zakończenia */
.btn.complete {
  background: linear-gradient(135deg, #1f8a5b, #18794e); border-color: #16683f; color: #fff;
  box-shadow: 0 2px 10px rgba(24, 121, 78, .28); padding-inline: 18px;
}
.btn.complete:hover { filter: brightness(1.08); box-shadow: 0 4px 16px rgba(24, 121, 78, .36); }
.btn.complete .ic { stroke-width: 2.8; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.active { color: var(--danger); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm .ic { width: 15px; height: 15px; }

/* ===== Karty, panele ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.panel > h2, .panel-head h2 { margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.count { font-size: .78rem; font-weight: 600; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); padding: 1px 8px; border-radius: 99px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; }
.two-col > .panel { margin-bottom: 18px; }
.prose { overflow-wrap: anywhere; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--text); margin-bottom: 16px; }
.note .ic { color: var(--brand); margin-top: 2px; }

/* ===== Komunikaty ===== */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash { padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid; font-weight: 500; margin-bottom: 10px; }
.flashes .flash { margin: 0; }
.flash-ok { background: var(--st-done-bg); color: var(--st-done-fg); border-color: color-mix(in srgb, var(--st-done-fg) 25%, transparent); }
.flash-err { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }

/* ===== Statusy ===== */
.badge { display: inline-flex; align-items: center; font-size: .76rem; font-weight: 650; padding: 3px 9px; border-radius: 99px; background: var(--st-arch-bg); color: var(--st-arch-fg); white-space: nowrap; }
.st-priorytetowy { background: var(--st-prio-bg); color: var(--st-prio-fg); }
.st-rozpoczety { background: var(--st-start-bg); color: var(--st-start-fg); }
.st-w_trakcie { background: var(--st-prog-bg); color: var(--st-prog-fg); }
.st-wlasny { background: var(--st-own-bg); color: var(--st-own-fg); }
.st-zakonczony { background: var(--st-done-bg); color: var(--st-done-fg); }
.st-zarchiwizowany { background: var(--st-arch-bg); color: var(--st-arch-fg); }
.st-blocked { background: var(--danger-soft); color: var(--danger); }
.st-pending { background: var(--st-prog-bg); color: var(--st-prog-fg); }

.deadline { display: inline-flex; align-items: center; gap: 5px; font-size: .84rem; color: var(--text-2); white-space: nowrap; }
.deadline .ic { width: 15px; height: 15px; }
.deadline.dl-soon, .deadline.dl-today { color: var(--warn); font-weight: 600; }
.deadline.dl-late { color: var(--danger); font-weight: 600; }
.deadline.dl-done { color: var(--muted); }
.deadline.big { font-size: .92rem; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); font-size: .84rem; color: var(--text-2); }
.pill .ic { width: 15px; height: 15px; }
a.pill:hover { color: var(--text); text-decoration: none; border-color: var(--border-strong); }
.chip { padding: 2px 10px; border-radius: 6px; }

/* ===== Pasek narzędzi listy ===== */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar-spacer { flex: 1; }
.sort-form label { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--text-2); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; color: var(--text-2); font-size: .88rem; font-weight: 550; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border-strong); }
.seg-btn:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.seg-btn.on { background: var(--brand-soft); color: var(--brand); }
.list-foot { display: flex; justify-content: flex-end; margin-top: 10px; }
.archive-link { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.archive-link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.archive-link .ic { width: 15px; height: 15px; }
.empty-list { padding: 36px 20px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }

/* ===== Lista (wiersze) ===== */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 14px; padding: 10px 12px; }
.row-main { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; color: var(--text); }
.row-main:hover { text-decoration: none; }
.row-main:hover .row-name { text-decoration: underline; }
.row-thumb { width: 44px; height: 44px; border-radius: 8px; overflow: hidden; flex: none; background: var(--surface-2); }
.row-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-ph { display: grid; place-items: center; font-weight: 700; color: var(--muted); background: var(--surface-2); }
.row-name { font-weight: 650; padding: 3px 9px; margin-left: -9px; border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.row-actions { display: flex; min-width: 34px; justify-content: flex-end; }
.subrows { list-style: none; margin: 0; padding: 4px 12px 10px 68px; display: flex; flex-direction: column; border-top: 1px dashed var(--border); }
.subrow { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: .87rem; flex-wrap: wrap; }
.subrow + .subrow { border-top: 1px solid var(--border); }
.subrow a { flex: 1; min-width: 140px; color: var(--text-2); display: inline-flex; align-items: center; gap: 8px; }
.subrow a:hover { color: var(--text); }
.subrow .badge { font-size: .7rem; padding: 2px 7px; }
.subrow .deadline { font-size: .78rem; }
.sub-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex: none; }
.is-done .row-name, .subrow.is-done a { opacity: .65; }

/* Priorytet: inna ramka */
.row-block.is-priority, .tile.is-priority, .detail-head.is-priority {
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent), var(--shadow);
}
.subrow.is-priority a { color: var(--accent); font-weight: 600; }

/* ===== Miniatury (siatka) ===== */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.tile { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.tile-link { display: flex; flex-direction: column; color: var(--text); height: 100%; }
.tile-link:hover { text-decoration: none; }
.tile-thumb { aspect-ratio: 1 / 1; background: var(--surface-2); overflow: hidden; }
.tile-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-thumb.thumb-ph span { font-size: 3rem; opacity: .55; }
.tile-name { font-weight: 650; padding: 9px 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-top: 1px solid var(--border); }
.tile-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 12px 12px; flex-wrap: wrap; }
.tile-meta .deadline { font-size: .78rem; }
.card-del { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity .12s; }
.card-del .icon-btn { background: var(--surface); box-shadow: var(--shadow); }
.tile:hover .card-del, .tile:focus-within .card-del { opacity: 1; }
@media (hover: none) { .card-del { opacity: 1; } }

/* ===== Szczegóły ===== */
.detail-head { display: flex; gap: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.detail-cover { flex: none; width: 150px; height: 150px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.detail-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.detail-title { display: inline-block; align-self: flex-start; padding: 2px 10px; margin-left: -10px; border-radius: 8px; overflow-wrap: anywhere; }
.detail-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.progress-wrap { display: inline-flex; align-items: center; gap: 10px; font-size: .88rem; color: var(--text-2); }
.progress { width: 130px; height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--ok); border-radius: 99px; }

.members { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.members li { display: flex; align-items: center; gap: 10px; }
.m-txt { display: flex; flex-direction: column; min-width: 0; }
.m-txt b { font-weight: 600; font-size: .92rem; display: inline-flex; align-items: center; gap: 6px; }
.m-txt small { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; }
.owner { color: #c08a00; display: inline-flex; }
.owner .ic { width: 15px; height: 15px; fill: currentColor; }

/* Awatary */
.avatar { --h: 160; display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; font-size: .78rem; font-weight: 700;
  background: hsl(var(--h) 45% 88%); color: hsl(var(--h) 45% 28%); }
[data-theme="dark"] .avatar { background: hsl(var(--h) 30% 26%); color: hsl(var(--h) 55% 82%); }
.avatar.sm { width: 28px; height: 28px; font-size: .6rem; letter-spacing: -.02em; }
.avatar.xl { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar.more { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.avatars { display: inline-flex; }
.avatars .avatar { border: 2px solid var(--surface); margin-left: -6px; }
.avatars .avatar:first-child { margin-left: 0; }

/* ===== Komentarze ===== */
.comments { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.comment { display: flex; gap: 12px; }
.comment-body { flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 0 var(--radius) var(--radius) var(--radius); padding: 10px 14px; }
.comment-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.comment-head time { color: var(--muted); font-size: .8rem; margin-right: auto; }
.comment-text { overflow-wrap: anywhere; }
.comment:target .comment-body { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.comment-form textarea { margin-bottom: 10px; }
.comment-form-row, .upload-form { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.upload-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); justify-content: flex-start; }
.file-pick { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); color: var(--text-2); cursor: pointer; font-size: .9rem; max-width: 100%; }
.file-pick:hover { border-color: var(--brand); color: var(--brand); }
.file-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

/* ===== Pliki ===== */
.att-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.att { display: flex; align-items: center; gap: 12px; padding: 9px 4px; }
.att + .att { border-top: 1px solid var(--border); }
.att-link { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; color: var(--text); }
.att-link:hover { text-decoration: none; }
.att-link:hover b { text-decoration: underline; }
.att > .att-link:first-child:not(:has(.att-txt)) { flex: none; }
.att-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.att-txt b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.att-txt a:hover { text-decoration: none; }
.att-txt small { color: var(--muted); font-size: .8rem; }
.fctx a { color: var(--text-2); }
.att-list.compact { margin-top: 8px; }
.att-list.compact .att { padding: 5px 0; border: 0; }
.att-list.compact .ficon { width: 38px; height: 38px; }
.att-list.compact .ficon svg { width: 18px; height: 18px; margin-top: -9px; }
.ficon { position: relative; flex: none; width: 44px; height: 44px; border-radius: 8px; display: inline-grid; place-items: center; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); }
.ficon svg { width: 22px; height: 22px; margin-top: -10px; }
.ficon b { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-size: .55rem; font-weight: 800; letter-spacing: .02em; }
.ficon-img { object-fit: cover; padding: 0; background: var(--surface-2); }
.fk-pdf { color: #c2352b; } .fk-doc { color: #2b63c2; } .fk-sheet { color: #1f8a4c; } .fk-slides { color: #d0620f; }
.fk-archive { color: #8a6d1f; } .fk-audio { color: #8a3fc2; } .fk-video { color: #c23f86; } .fk-model { color: #148a8a; } .fk-image { color: #6a7f2b; }
.file-group h2 a { color: var(--text); }

/* ===== Formularze ===== */
input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]), select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 9px 11px; min-height: 40px;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
input[disabled], select[disabled] { opacity: .55; }
input[type=file] { font: inherit; font-size: .88rem; color: var(--text-2); max-width: 100%; }
input[type=color] { width: 48px; height: 36px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 17px; height: 17px; }
.sort-form select, .cal-pick select, td select { width: auto; min-height: 34px; padding: 5px 30px 5px 10px; }
.form-card { padding: 22px; margin-bottom: 18px; }
.form-card > h2 { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; align-items: start; }
.span2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: .86rem; font-weight: 600; color: var(--text-2); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: .92rem; }
.field-check { align-self: end; min-height: 40px; }
.big-check { display: flex; align-items: flex-start; gap: 12px; margin-top: 18px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.big-check span { display: flex; flex-direction: column; }
.big-check small { color: var(--muted); }
.big-check input { margin-top: 3px; }
.color-row { display: flex; align-items: center; gap: 14px; min-height: 40px; }
.img-current { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.img-current img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; align-items: center; }
.form-actions.left { margin-top: 0; }
.form-row { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 200px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.assignees { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; margin: 20px 0 0; }
.assignees legend { font-weight: 650; padding: 0 6px; }
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; max-height: 340px; overflow: auto; }
.pick { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.pick:hover { background: var(--surface-2); }
.pick:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.pick > span { display: flex; flex-direction: column; min-width: 0; font-size: .9rem; font-weight: 550; }
.pick small { color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-filter { margin-bottom: 8px; }
.search-row { display: flex; gap: 8px; margin-bottom: 14px; max-width: 520px; }
.add-user { padding: 0; }
.add-user > summary { list-style: none; margin: 16px; display: inline-flex; }
.add-user > summary::-webkit-details-marker { display: none; }
.add-user[open] > summary { margin-bottom: 0; }
.add-user form { padding: 18px 22px 22px; }
.theme-pick { display: flex; gap: 10px; }
.theme-opt { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.theme-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.swatch { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border-strong); }
.sw-light { background: linear-gradient(135deg, #fff 50%, #f4f5f2 50%); }
.sw-dark { background: linear-gradient(135deg, #1a1f1c 50%, #121614 50%); }
.profile-head { display: flex; align-items: center; gap: 16px; padding: 20px; margin-bottom: 18px; }
.profile-head h2 { font-size: 1.25rem; margin-bottom: 2px; }
.profile-head p { margin: 0 0 6px; }
pre.notes { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); padding: 12px; border-radius: var(--radius-sm); font-size: .85rem; max-height: 260px; overflow: auto; }

/* ===== Tabele ===== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th.center, .table td.center { text-align: center; }
.table th.right, .table td.right { text-align: right; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell > span { display: flex; flex-direction: column; font-weight: 600; }
.user-cell small { color: var(--muted); font-weight: 400; }
.user-cell .badge { margin-left: 4px; }
tr.is-blocked td { opacity: .6; }

/* ===== Kalendarz ===== */
.cal-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-title { font-size: 1.25rem; min-width: 190px; text-align: center; }
.cal-pick { display: flex; gap: 6px; margin-left: auto; }
.cal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; }
.cal-row, .cal-body { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div { padding: 8px 10px; font-size: .78rem; font-weight: 650; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-cell { min-height: 112px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.out { background: var(--surface-2); }
.cal-cell.weekend:not(.out) { background: color-mix(in srgb, var(--surface-2) 50%, var(--surface)); }
.cal-day { font-size: .82rem; font-weight: 650; color: var(--text-2); width: 26px; height: 26px; display: inline-grid; place-items: center; border-radius: 50%; }
.cal-cell.today .cal-day { background: var(--brand); color: var(--brand-ink); }
.cal-item { --c: var(--brand); display: flex; align-items: center; gap: 5px; font-size: .76rem; line-height: 1.25; padding: 3px 6px; border-radius: 5px; color: var(--text);
  background: color-mix(in srgb, var(--c) 16%, var(--surface)); min-width: 0; }
.cal-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item:hover { text-decoration: none; filter: brightness(.96); }
.cal-item .ic { width: 12px; height: 12px; flex: none; color: var(--c); }
.cal-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c); flex: none; }
.cal-project { font-weight: 650; }
.cal-item.st-zakonczony span { text-decoration: line-through; opacity: .7; }
.cal-item.st-priorytetowy:not(.has-color) { --c: var(--accent); }
.cal-agenda { display: none; }
.agenda-day { display: flex; gap: 14px; padding: 8px 0; border-top: 1px solid var(--border); }
.agenda-day:first-of-type { border-top: 0; }
.agenda-day > b { width: 90px; flex: none; font-size: .88rem; }
.agenda-day > div { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.agenda-day .cal-item { font-size: .86rem; padding: 5px 8px; }

/* ===== Logowanie / instalator ===== */
body.bare { display: grid; place-items: center; min-height: 100vh; padding: 20px;
  background: radial-gradient(1200px 600px at 20% -10%, var(--brand-soft), transparent 60%), var(--bg); }
.bare-wrap { width: 100%; max-width: 420px; }
.bare-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; font-size: 1.2rem; margin-bottom: 18px; }
.bare-card { padding: 28px; }
.bare-card h1 { font-size: 1.4rem; margin-bottom: 18px; }
.bare-card .center { margin: 16px 0 0; font-size: .9rem; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .85rem; margin: 18px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.google-btn { gap: 10px; }
.steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 16px; font-size: .78rem; }
.steps li { flex: 1; padding: 6px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); text-align: center; }
.steps li.on { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.checks { list-style: none; padding: 0; margin: 0 0 18px; font-size: .9rem; }
.checks li { display: flex; align-items: center; gap: 8px; padding: 4px 0; flex-wrap: wrap; }
.checks li > span { width: 20px; height: 20px; display: inline-grid; place-items: center; border-radius: 50%; font-size: .75rem; font-weight: 800; }
.checks .ok > span { background: var(--st-done-bg); color: var(--st-done-fg); }
.checks .bad > span { background: var(--danger-soft); color: var(--danger); }
.checks .warn > span { background: var(--st-prog-bg); color: var(--st-prog-fg); }
.empty { text-align: center; padding: 60px 20px; }
.empty h2 { font-size: 1.4rem; margin-bottom: 8px; }


/* ===== Zarządzenia ===== */
.nav-badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--accent); color: #fff; font-size: .74rem; font-weight: 750; display: inline-grid; place-items: center; }
.note-warn { background: var(--st-prio-bg); color: var(--st-prio-fg); font-weight: 550; }
.note-warn .ic { color: var(--accent); }
.directives { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.directive-row a { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.directive-row a:hover { text-decoration: none; border-color: var(--border-strong); }
.directive-row a:hover b { text-decoration: underline; }
.dir-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--muted); }
.dir-ic .ic { width: 21px; height: 21px; }
.dir-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.dir-main b { font-size: 1.02rem; font-weight: 650; overflow-wrap: anywhere; }
.dir-main small { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: .82rem; }
.dir-main small span { display: inline-flex; align-items: center; gap: 4px; }
.dir-main small .ic { width: 14px; height: 14px; }
.dir-status { display: inline-flex; align-items: center; gap: 5px; font-size: .82rem; font-weight: 650; white-space: nowrap; padding: 4px 10px; border-radius: 99px; }
.dir-status .ic { width: 15px; height: 15px; stroke-width: 2.4; }
.dir-status.todo { background: var(--accent); color: #fff; }
.dir-status.done { background: var(--st-arch-bg); color: var(--st-arch-fg); }
/* Niezaakceptowane: kontrastowe */
.directive-row.is-pending a { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.directive-row.is-pending .dir-ic { background: var(--st-prio-bg); color: var(--accent); }
/* Zaakceptowane: wyszarzone, ale klikalne */
.directive-row.is-acked a { background: var(--surface-2); box-shadow: none; color: var(--muted); }
.directive-row.is-acked .dir-main b { font-weight: 550; color: var(--text-2); }
.directive-row.is-acked a:hover { color: var(--text); }

.directive-doc { padding: 28px 32px; }
.directive-head { padding-bottom: 16px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.directive-head h1 { margin-bottom: 6px; overflow-wrap: anywhere; }
.directive-head .detail-actions { margin-top: 12px; }
.rich { max-width: 72ch; line-height: 1.65; overflow-wrap: anywhere; }
.rich > :first-child { margin-top: 0; }
.rich p { margin: 0 0 .9em; }
.rich h2 { font-size: 1.2rem; margin: 1.4em 0 .5em; }
.rich h3 { font-size: 1.05rem; margin: 1.2em 0 .4em; }
.rich ul, .rich ol { margin: 0 0 .9em; padding-left: 1.5em; }
.rich li { margin: .2em 0; }
.rich blockquote { margin: 0 0 .9em; padding: 10px 16px; background: var(--surface-2); border-radius: var(--radius-sm); color: var(--text-2); font-style: italic; }
.rich hr { border: 0; border-top: 1px solid var(--border); margin: 1.5em 0; }
.dir-att-h { margin: 24px 0 8px; }
.ack-box { margin-top: 28px; padding: 20px; border-radius: var(--radius); background: var(--surface-2); border: 1px dashed var(--border-strong); display: flex; justify-content: center; }
.ack-box.done { border-style: solid; background: var(--st-done-bg); color: var(--st-done-fg); border-color: transparent; }
.ack-done { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; text-align: center; }
.ack-done .ic { stroke-width: 2.6; }
.btn.complete.big { font-size: 1rem; padding: 14px 26px; min-height: 50px; }
.ack-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.ack-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.ack-list .m-txt { flex: 1; }
.ack-list li.no .dir-status.todo { background: var(--st-prio-bg); color: var(--st-prio-fg); }

/* Edytor */
.rte { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.rte:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.rte-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; }
.rte-btn { min-width: 34px; height: 32px; padding: 0 7px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); cursor: pointer; display: inline-grid; place-items: center; font: inherit; }
.rte-btn:hover { background: var(--surface); color: var(--text); }
.rte-btn.on { background: var(--brand-soft); color: var(--brand); }
.rte-txt { font-weight: 750; font-size: .82rem; }
.rte-sep { width: 1px; margin: 5px 4px; background: var(--border-strong); }
.rte-area { position: relative; min-height: 320px; max-height: 70vh; overflow: auto; padding: 14px 16px; outline: none; max-width: none; }
.rte-area.is-empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; position: absolute; }
@media (max-width: 640px) {
  .directive-doc { padding: 18px 16px; }
  .directive-row a { flex-wrap: wrap; }
  .dir-status { margin-left: 54px; }
}

/* ===== Mobile ===== */
.sidebar-backdrop { display: none; }
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .content { padding: 18px 16px 48px; }
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; }
  .topbar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 10; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .topbar-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cal-cell { min-height: 64px; padding: 3px; }
  .cal-item span { display: none; }
  .cal-item { padding: 0; height: 6px; background: var(--c); }
  .cal-item .ic, .cal-item .dot { display: none; }
  .cal-agenda { display: block; }
  .cal-pick { margin-left: 0; }
  .cal-title { min-width: 0; flex: 1; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .form-grid { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; gap: 8px; }
  .row-main { flex-basis: calc(100% - 46px); }
  .row-meta { justify-content: flex-start; padding-left: 56px; order: 3; flex-basis: 100%; }
  .row-actions { order: 2; }
  .subrows { padding-left: 16px; }
  .detail-head { flex-direction: column; padding: 16px; }
  .detail-cover { width: 100%; height: 180px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .seg-btn span { display: none; }
  .panel { padding: 14px; }
  .form-card { padding: 16px; }
  .comment .avatar { display: none; }
  .comment-body { border-radius: var(--radius); }
  .users-table th:nth-child(3), .users-table td:nth-child(3) { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.form-card > .field + .field { margin-top: 16px; }

.help { margin-top: 14px; font-size: .9rem; }
.help summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.help ol { margin: 10px 0 0; padding-left: 1.3em; color: var(--text-2); }
.help li { margin: 5px 0; }
