/* Layout: app shell — pasek boczny (Spaces → listy, projekty, zespół) | lista tasków pogrupowana wg statusu; task otwiera się w oknie dwupanelowym (szczegóły | komentarze) */
:root {
  --bg: #F4F6F6;
  --surface: #FFFFFF;
  --sidebar: #EBEFEF;
  --raised: #FFFFFF;
  --line: #E0E5E6;
  --line-strong: #C8D0D2;
  --fg: #172022;
  --muted: #55636A;
  --faint: #7F8C93;
  --hover: #E5EAEB;
  --row-hover: #F3F6F6;
  --accent: #0D7473;
  --accent-strong: #08595A;
  --accent-fg: #FFFFFF;
  --accent-soft: #D7EDEC;
  --on-swatch: #FFFFFF;
  --st-todo: #7D8A92;
  --st-progress: #6D54E8;
  --st-done: #1E9455;
  --p-urgent: #D93A3F;
  --p-high: #E08A00;
  --p-normal: #3C74E3;
  --p-low: #94A0A6;
  --danger: #C9363B;
  --overlay: rgba(15, 24, 27, .42);
  --lightbox: rgba(8, 12, 14, .88);
  --shadow: 0 12px 32px rgba(16, 28, 32, .16), 0 2px 6px rgba(16, 28, 32, .08);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 8px;
  --r-sm: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12181A; --surface: #182023; --sidebar: #0E1315; --raised: #1F282B;
    --line: #273236; --line-strong: #364247; --fg: #E4EAEC; --muted: #A0ADB2; --faint: #75838A;
    --hover: #232D31; --row-hover: #1C2528; --accent: #39BDB8; --accent-strong: #66D6D1; --accent-fg: #052322;
    --accent-soft: #143634; --on-swatch: #FFFFFF; --st-todo: #8C99A1; --st-progress: #9783F5; --st-done: #3DBA75;
    --p-urgent: #F0595D; --p-high: #F2A93B; --p-normal: #6B98F2; --p-low: #7F8C92; --danger: #EF5F63;
    --overlay: rgba(0, 0, 0, .55); --lightbox: rgba(0, 0, 0, .9);
    --shadow: 0 14px 36px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12181A; --surface: #182023; --sidebar: #0E1315; --raised: #1F282B;
  --line: #273236; --line-strong: #364247; --fg: #E4EAEC; --muted: #A0ADB2; --faint: #75838A;
  --hover: #232D31; --row-hover: #1C2528; --accent: #39BDB8; --accent-strong: #66D6D1; --accent-fg: #052322;
  --accent-soft: #143634; --on-swatch: #FFFFFF; --st-todo: #8C99A1; --st-progress: #9783F5; --st-done: #3DBA75;
  --p-urgent: #F0595D; --p-high: #F2A93B; --p-normal: #6B98F2; --p-low: #7F8C92; --danger: #EF5F63;
  --overlay: rgba(0, 0, 0, .55); --lightbox: rgba(0, 0, 0, .9);
  --shadow: 0 14px 36px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

:root { color-scheme: light; }
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
.tm:focus { outline: none; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: inherit; }
.ic { display: inline-flex; width: 16px; height: 16px; flex: none; }
.ic svg { width: 100%; height: 100%; display: block; }
.muted { color: var(--faint); }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid transparent; font-weight: 600; font-size: 13.5px; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn .ic { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--fg); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: var(--danger); color: var(--on-swatch); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 0; background: transparent; border-radius: var(--r-sm); color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--fg); }
.icon-btn .ic { width: 18px; height: 18px; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 4px 6px; border-radius: 4px; font-size: 13px; }
.link-btn:hover { background: var(--accent-soft); }
.input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--fg); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.invalid { border-color: var(--danger); }

/* App shell */
.app { display: grid; grid-template-columns: 268px minmax(0, 1fr); height: 100%; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.sb-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 12px 8px max(16px, env(safe-area-inset-left, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; }
.sb-close { display: none; }
.sb-nav { flex: 1; overflow-y: auto; padding: 4px 12px 20px max(16px, env(safe-area-inset-left, 0px)); }
.sb-sec { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 4px; padding-left: 6px; }
.sb-sec:first-child { margin-top: 6px; }
.sb-sec h2 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.sb-sec .icon-btn { width: 26px; height: 26px; }
.sb-sec .icon-btn .ic { width: 16px; height: 16px; }
.sb-row { display: flex; align-items: center; gap: 2px; border-radius: var(--r-sm); min-height: 32px; }
.sb-row:hover { background: var(--hover); }
.sb-row.active { background: var(--accent-soft); }
.sb-row.active .sb-label { color: var(--accent-strong); font-weight: 600; }
.sb-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 6px; color: var(--fg); text-decoration: none; border: 0; background: none; text-align: left; border-radius: var(--r-sm); font-size: 13.5px; }
.sb-link .ic { color: var(--faint); }
.sb-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.sb-tog { width: 22px; height: 22px; border: 0; background: none; color: var(--faint); display: grid; place-items: center; border-radius: 4px; flex: none; }
.sb-tog:hover { color: var(--fg); background: var(--hover); }
.sb-tog .ic { width: 14px; height: 14px; transition: transform .15s; }
.sb-tog[aria-expanded="true"] .ic { transform: rotate(90deg); }
.sb-more { width: 26px; height: 26px; opacity: 0; }
.sb-more .ic { width: 16px; height: 16px; }
.sb-row:hover .sb-more, .sb-more:focus-visible, .sb-more.pop-open { opacity: 1; }
@media (hover: none) { .sb-more { opacity: .7; } }
.sb-lists { margin: 0 0 6px 11px; padding-left: 10px; border-left: 1px solid var(--line-strong); }
.sb-add { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px; border: 0; background: none; color: var(--muted); font-size: 13px; border-radius: var(--r-sm); text-align: left; }
.sb-add:hover { background: var(--hover); color: var(--fg); }
.sb-add .ic { width: 14px; height: 14px; }
.sb-empty { color: var(--faint); font-size: 13px; padding: 4px 6px 6px; }
.sb-team { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 6px; border: 0; background: none; border-radius: var(--r-sm); text-align: left; color: var(--muted); font-size: 13px; }
.sb-team:hover { background: var(--hover); color: var(--fg); }
.sb-me { border-top: 1px solid var(--line); padding: 12px 12px 12px max(16px, env(safe-area-inset-left, 0px)); display: flex; align-items: center; gap: 10px; }
.sb-me .av { width: 30px; height: 30px; font-size: 11px; }
.me-txt { flex: 1; min-width: 0; }
.me-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-sub { font-size: 12px; color: var(--faint); }
.nav-scrim { position: fixed; inset: 0; z-index: 34; background: var(--overlay); }

.sp-ic { width: 20px; height: 20px; border-radius: 5px; background: var(--c); color: var(--on-swatch); display: inline-grid; place-items: center; font: 700 11px/1 var(--font-display); flex: none; }
.sp-ic.xs { width: 16px; height: 16px; font-size: 9.5px; border-radius: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; --gx-l: 32px; --gx-r: max(28px, env(safe-area-inset-right, 0px)); }
.main-head { display: flex; align-items: center; gap: 12px; padding: 18px var(--gx-r) 8px var(--gx-l); }
.nav-btn { display: none; }
.head-txt { flex: 1; min-width: 0; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; min-height: 20px; }
.crumb { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; border-radius: 4px; padding: 1px 4px; margin-left: -4px; }
a.crumb:hover { background: var(--hover); color: var(--fg); }
.view-title { margin: 2px 0 0; font-family: var(--font-display); font-size: 25px; font-weight: 600; letter-spacing: -.015em; line-height: 1.2; text-wrap: balance; overflow-wrap: anywhere; }
.view-sub { color: var(--faint); font-size: 13px; margin-top: 3px; font-variant-numeric: tabular-nums; min-height: 19px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px var(--gx-r) 12px var(--gx-l); border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); width: min(260px, 100%); color: var(--faint); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; color: var(--fg); height: 100%; }
.fbtn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--muted); font-size: 13px; max-width: 100%; }
.fbtn:hover { border-color: var(--line-strong); color: var(--fg); }
.fbtn .ic { width: 15px; height: 15px; }
.fbtn .fb-val { color: var(--fg); font-weight: 500; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fbtn.on { border-color: var(--accent); background: var(--accent-soft); }
.notice { margin: 12px var(--gx-r) 0 var(--gx-l); padding: 8px 12px; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--fg); font-size: 13px; }
.notice.warn { background: color-mix(in srgb, var(--p-high) 18%, var(--surface)); }
.list-wrap { flex: 1; overflow: auto; padding: 6px var(--gx-r) 72px var(--gx-l); }
.groups { display: flex; flex-direction: column; gap: 18px; max-width: 1400px; }

/* Status groups */
.group-head { display: grid; grid-template-columns: 30px minmax(0, 1fr) var(--cols); align-items: center; min-height: 40px; position: sticky; top: 0; z-index: 3; background: var(--bg); }
.g-tog { width: 24px; height: 24px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; border-radius: 4px; }
.g-tog:hover { background: var(--hover); color: var(--fg); }
.g-tog .ic { width: 14px; height: 14px; transition: transform .15s; }
.g-tog[aria-expanded="false"] .ic { transform: rotate(-90deg); }
.g-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.g-count { color: var(--faint); font-size: 13px; font-variant-numeric: tabular-nums; }
.g-add { width: 26px; height: 26px; opacity: .7; }
.g-add .ic { width: 15px; height: 15px; }
.col-label { font-size: 11.5px; color: var(--faint); font-weight: 500; padding: 0 10px; display: flex; align-items: center; gap: 4px; border: 0; background: none; text-align: left; height: 28px; white-space: nowrap; border-radius: 4px; }
button.col-label:hover { color: var(--fg); background: var(--hover); }
.col-label.sorted { color: var(--accent); }
.col-label .ic { width: 12px; height: 12px; }
.spill { display: inline-flex; align-items: center; gap: 7px; height: 24px; padding: 0 10px 0 8px; border-radius: 5px; font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; background: color-mix(in srgb, var(--c) 17%, transparent); color: var(--fg); white-space: nowrap; }
.spill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.group-body { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.group-body > * + * { border-top: 1px solid var(--line); }
.g-empty { padding: 10px 14px; color: var(--faint); font-size: 13px; }

/* Task rows */
.row { display: grid; grid-template-columns: 30px minmax(0, 1fr) var(--cols); align-items: stretch; min-height: 42px; cursor: pointer; background: var(--surface); }
.row:hover { background: var(--row-hover); }
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sbtn { display: grid; place-items: center; border: 0; background: none; padding: 0; border-radius: 6px; }
button.sbtn:hover .sdot { transform: scale(1.12); }
.sdot { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--c); display: inline-grid; place-items: center; color: var(--surface); flex: none; transition: transform .1s; }
.sdot[data-s="progress"] { background: conic-gradient(var(--c) 0 50%, transparent 0); }
.sdot[data-s="done"] { background: var(--c); }
.sdot .ic { width: 9px; height: 9px; }
.cells { display: contents; }
.cell { display: flex; align-items: center; gap: 6px; padding: 0 10px; min-width: 0; border: 0; background: none; text-align: left; color: var(--fg); font-size: 13px; }
button.cell:hover { background: var(--hover); }
.cell .ph { color: var(--faint); opacity: 0; }
.row:hover .cell .ph, .cell:focus-visible .ph { opacity: 1; }
@media (hover: none) { .cell .ph { opacity: .5; } }
.cell-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-cell { gap: 10px; padding-left: 2px; }
.t-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 13.5px; }
.row.is-done .t-name { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.badge { display: inline-flex; align-items: center; gap: 3px; color: var(--faint); font-size: 12px; flex: none; font-variant-numeric: tabular-nums; }
.badge .ic { width: 14px; height: 14px; }
.ic.flag { color: var(--c); }
.due { white-space: nowrap; font-variant-numeric: tabular-nums; }
.due.over { color: var(--danger); font-weight: 600; }
.due.today { color: var(--p-high); font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px 0 7px; border-radius: 999px; font-size: 12px; font-weight: 500; background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--fg); max-width: 100%; min-width: 0; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.chip-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font: 600 10px/1 var(--font); color: var(--on-swatch); background: var(--c, var(--accent)); flex: none; overflow: hidden; box-shadow: 0 0 0 2px var(--surface); object-fit: cover; }
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av.sm { width: 22px; height: 22px; font-size: 9.5px; }
.av.more { background: var(--hover); color: var(--muted); }
.av-stack { display: inline-flex; align-items: center; }
.av-stack .av + .av { margin-left: -6px; }
/* Compact rows: used whenever the list is too narrow for the columns (set from script) */
.compact .group-head { grid-template-columns: 30px minmax(0, 1fr); }
.compact .group-head .col-label { display: none; }
.compact .row { grid-template-columns: 34px minmax(0, 1fr); padding: 8px 0 6px; }
.compact .row .sbtn { align-self: start; height: 26px; }
.compact .name-cell { padding: 3px 10px 0 0; align-items: flex-start; flex-wrap: wrap; row-gap: 2px; }
.compact .t-name { white-space: normal; overflow-wrap: anywhere; }
.compact .cells { display: flex; flex-wrap: wrap; gap: 6px; grid-column: 2; padding: 6px 10px 2px 0; }
.compact .cell { padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; min-height: 28px; }
.compact .cell.is-empty { display: none; }
.compact .cells:not(:has(> .cell:not(.is-empty))) { display: none; }
.compact .cell.name-cell { border: 0; border-radius: 0; padding: 3px 10px 0 0; min-height: 0; }
.qa-btn { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 38px; padding: 0 10px 0 34px; border: 0; background: none; color: var(--faint); text-align: left; font-size: 13px; }
.qa-btn:hover { color: var(--fg); background: var(--row-hover); }
.qa-btn .ic { width: 14px; height: 14px; }
.qa-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 8px; }
.qa-row .sdot { margin: 0 6px 0 0; }
.qa-input { flex: 1; min-width: 0; height: 32px; border: 1px solid var(--accent); border-radius: var(--r-sm); padding: 0 10px; background: var(--surface); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); color: var(--fg); }

/* Empty / loading */
.empty { max-width: 540px; margin: 40px auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 0 8px; }
.empty h2 { font-family: var(--font-display); font-size: 22px; font-weight: 600; margin: 4px 0 0; text-wrap: balance; }
.empty p { margin: 0; color: var(--muted); max-width: 48ch; }
.eh-art { width: min(300px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 14px; display: flex; flex-direction: column; margin-bottom: 6px; box-shadow: var(--shadow); }
.eh-row { display: flex; align-items: center; gap: 12px; height: 38px; }
.eh-row + .eh-row { border-top: 1px solid var(--line); }
.eh-bar { height: 8px; border-radius: 4px; background: var(--hover); }
.eh-row .ic.flag, .eh-sp { margin-left: auto; width: 14px; height: 14px; }
.steps { display: flex; gap: 14px; list-style: none; padding: 0; margin: 10px 0 0; counter-reset: s; flex-wrap: wrap; justify-content: center; }
.steps li { counter-increment: s; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.steps li::before { content: counter(s); width: 20px; height: 20px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.loading { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; }
.skel { height: 40px; border-radius: var(--r); background: linear-gradient(90deg, var(--hover), var(--row-hover), var(--hover)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Popover & menus */
.pop { position: fixed; z-index: 60; min-width: 210px; max-width: min(320px, calc(100vw - 24px)); max-height: min(380px, 70vh); overflow: auto; background: var(--raised); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; }
.pop-filter { width: 100%; height: 32px; border: 1px solid var(--line); border-radius: 6px; padding: 0 10px; margin-bottom: 4px; background: var(--surface); color: var(--fg); }
.pop-filter:focus { outline: none; border-color: var(--accent); }
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 6px 10px; border-radius: 6px; border: 0; background: none; color: var(--fg); text-align: left; font-size: 13.5px; }
.pop-item:hover, .pop-item:focus-visible { background: var(--hover); outline: none; }
.pop-item .ic { color: var(--muted); }
.pop-item .ic.flag { color: var(--c); }
.pop-item.danger, .pop-item.danger .ic { color: var(--danger); }
.pi-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-item .pi-check { color: var(--accent); width: 15px; height: 15px; }
.pop-head { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); padding: 8px 10px 4px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.pop-note { padding: 6px 10px; color: var(--faint); font-size: 13px; }
.due-pop { display: flex; flex-direction: column; gap: 8px; padding: 4px; width: 250px; max-width: 100%; }
.due-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 12.5px; color: var(--fg); }
.chip-btn:hover { background: var(--hover); }
.chip-btn.danger { color: var(--danger); }

/* Dialogs */
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--overlay); display: flex; align-items: center; justify-content: center; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); animation: fade .12s ease-out; }
.dlg-scrim { z-index: 50; }
.dialog { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); width: min(440px, 100%); max-height: 100%; overflow: auto; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.dialog.wide { width: min(540px, 100%); }
.dlg-form { display: flex; flex-direction: column; gap: 16px; }
.dlg-title { margin: 0; font-family: var(--font-display); font-size: 19px; font-weight: 600; text-wrap: balance; overflow-wrap: anywhere; }
.dlg-text { margin: 0; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--c); }
.sw[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.team-list { display: flex; flex-direction: column; gap: 2px; max-height: min(42vh, 340px); overflow: auto; margin: 0 -6px; }
.team-row { display: flex; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 8px; }
.team-row:hover { background: var(--row-hover); }
.team-name { flex: 1; min-width: 0; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 5px 8px; color: var(--fg); }
.team-name:hover { border-color: var(--line); }
.team-name:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.team-tag { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.team-empty { color: var(--faint); padding: 8px 6px; }
.team-add { display: flex; gap: 8px; }
.team-sugg { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; padding: 4px; margin-top: -8px; }
@keyframes fade { from { opacity: 0; } }

/* Task modal */
.tm-scrim { z-index: 30; padding: max(24px, env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px)); }
.tm { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); width: min(1160px, 100%); height: min(860px, 100%); display: flex; flex-direction: column; overflow: hidden; }
.tm-top { display: flex; align-items: center; gap: 4px; padding: 10px 12px 10px 24px; border-bottom: 1px solid var(--line); min-height: 54px; }
.tm-crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; min-width: 0; overflow: hidden; white-space: nowrap; }
.tm-crumbs > span:not(.ic):not(.sp-ic) { overflow: hidden; text-overflow: ellipsis; }
.crumb-sep { width: 12px; height: 12px; color: var(--faint); }
.grow { flex: 1; }
.tm-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); }
.tm-main { overflow-y: auto; padding: 26px 36px 48px; min-width: 0; }
.tm-title { display: block; width: calc(100% + 12px); border: 0; outline: 0; resize: none; background: transparent; font-family: var(--font-display); font-size: 27px; font-weight: 600; letter-spacing: -.015em; line-height: 1.25; padding: 4px 6px; margin: 0 -6px; border-radius: 6px; color: var(--fg); overflow: hidden; }
.tm-title:not([readonly]):hover { background: var(--row-hover); }
.tm-title:focus { background: var(--row-hover); box-shadow: 0 0 0 2px var(--accent-soft); }
.props { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 28px; margin: 18px 0 28px; }
.prop { display: grid; grid-template-columns: 100px minmax(0, 1fr); align-items: center; min-height: 38px; gap: 8px; }
.prop-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.prop-label .ic { width: 15px; height: 15px; color: var(--faint); }
.prop-val { min-width: 0; }
.pv { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 8px; margin-left: -8px; border: 0; border-radius: 6px; background: none; color: var(--fg); text-align: left; max-width: calc(100% + 8px); min-width: 0; font-size: 13.5px; }
button.pv:hover { background: var(--hover); }
.pv-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sec-label { font-size: 11.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); margin-bottom: 8px; }
.desc { position: relative; min-height: 140px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); white-space: pre-wrap; overflow-wrap: anywhere; outline: none; line-height: 1.6; font-size: 14px; }
.desc[contenteditable="true"]:hover { border-color: var(--line-strong); }
.desc:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.desc.is-empty::before { content: attr(data-ph); position: absolute; left: 15px; top: 12px; color: var(--faint); pointer-events: none; }
.desc.drag { border-color: var(--accent); background: var(--accent-soft); }
.img-block { position: relative; display: block; width: fit-content; max-width: 100%; margin: 8px 0; user-select: none; }
.img-block img { display: block; max-width: 100%; max-height: 460px; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; background: var(--row-hover); }
.img-block.broken img { display: none; }
.img-block.broken::before { content: "Obrazek niedostępny"; display: block; padding: 18px 22px; border: 1px dashed var(--line-strong); border-radius: 6px; color: var(--faint); font-size: 13px; }
.img-x { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 6px; border: 0; background: var(--raised); color: var(--fg); display: grid; place-items: center; box-shadow: var(--shadow); opacity: 0; transition: opacity .12s; }
.img-x .ic { width: 14px; height: 14px; }
.img-block:hover .img-x, .img-x:focus-visible { opacity: 1; }
@media (hover: none) { .img-x { opacity: 1; } }
.img-uploading { display: flex; align-items: center; gap: 8px; margin: 8px 0; padding: 14px 18px; border: 1px dashed var(--accent); border-radius: 6px; color: var(--accent-strong); font-size: 13px; width: fit-content; user-select: none; }
.desc-tools { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.desc-hint { color: var(--faint); font-size: 12.5px; flex: 1; min-width: 0; }
.saved { font-size: 12px; color: var(--faint); opacity: 0; transition: opacity .25s; }
.saved.on { opacity: 1; }
.tm-meta { margin-top: 26px; color: var(--faint); font-size: 12.5px; }
.tm-side { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--bg); }
.tm-side-head { display: flex; align-items: baseline; gap: 8px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.tm-side-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.cm-count { color: var(--faint); font-size: 13px; font-variant-numeric: tabular-nums; }
.cm-list { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 16px; }
.cm { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; }
.cm > .av { width: 28px; height: 28px; font-size: 10.5px; }
.cm-meta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cm-author { font-weight: 600; font-size: 13px; }
.cm-time { color: var(--faint); font-size: 12px; }
.cm-del { margin-left: auto; border: 0; background: none; color: var(--faint); font-size: 12px; padding: 0 4px; border-radius: 4px; opacity: 0; }
.cm-del:hover { color: var(--danger); }
.cm:hover .cm-del, .cm-del:focus-visible { opacity: 1; }
@media (hover: none) { .cm-del { opacity: 1; } }
.cm-text { margin-top: 4px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 2px 10px 10px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.cm-empty { margin: auto; text-align: center; color: var(--faint); font-size: 13px; max-width: 30ch; padding: 24px 0; }
.composer { border-top: 1px solid var(--line); padding: 12px 16px 14px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.composer.ro { color: var(--faint); font-size: 13px; }
.cm-input { width: 100%; min-height: 64px; resize: none; border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; background: var(--surface); color: var(--fg); outline: none; line-height: 1.45; }
.cm-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kbd-hint { font-size: 12px; color: var(--faint); }
.toast { position: fixed; left: 50%; bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 12px)); transform: translateX(-50%); z-index: 90; background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 13.5px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); width: max-content; animation: fade .15s ease-out; }
.lightbox { position: fixed; inset: 0; z-index: 85; background: var(--lightbox); display: flex; align-items: center; justify-content: center; padding: max(24px, env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px)); cursor: zoom-out; animation: fade .12s ease-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }

@media (max-width: 1080px) {
  .tm-main { padding: 22px 24px 40px; }
  .props { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 35; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); transform: translateX(-104%); transition: transform .2s ease; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); box-shadow: var(--shadow); }
  .app.nav-open .sidebar { transform: none; }
  .nav-btn, .sb-close { display: inline-grid; }
  .main { --gx-l: max(16px, env(safe-area-inset-left, 0px)); --gx-r: max(16px, env(safe-area-inset-right, 0px)); }
  .main-head { padding-top: 12px; align-items: flex-start; }
  .view-title { font-size: 21px; }
  .search { width: 100%; }
  .tm-scrim { padding: 0; }
  .tm { border-radius: 0; width: 100%; height: 100%; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .tm-top { padding: 8px max(8px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); }
  .tm-body { display: block; overflow-y: auto; }
  .tm-main { overflow: visible; padding: 18px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
  .tm-title { font-size: 22px; }
  .tm-side { border-left: 0; border-top: 1px solid var(--line); min-height: 280px; }
  .tm-side-head { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .cm-list { overflow: visible; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .composer { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Self-hosted additions: login, accounts, presence */
body { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.login { height: 100%; display: grid; place-items: center; overflow: auto; padding-block: 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.login-title { margin: 6px 0 0; font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.login-err { color: var(--danger); font-size: 13px; }
.login-btn { height: 40px; }
.login-hint { margin: 0; color: var(--faint); font-size: 12.5px; }
.av-wrap { position: relative; display: inline-flex; flex: none; }
.online-dot { position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border-radius: 50%; background: var(--st-done); box-shadow: 0 0 0 2px var(--sidebar); }
.team-row .online-dot { box-shadow: 0 0 0 2px var(--surface); }
.team-who { flex: 1; min-width: 0; }
.team-nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-me .icon-btn { width: 30px; height: 30px; }
.sb-me .icon-btn .ic { width: 17px; height: 17px; }
.acc-sec { border-top: 1px solid var(--line); padding-top: 16px; }
.acc-h { margin: 0; font-size: 15px; font-weight: 600; }
.acc-msg { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; align-self: center; }
.acc-foot { justify-content: space-between; border-top: 1px solid var(--line); padding-top: 16px; }
/* Admin: roles and account management */
.role-badge { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; margin-left: 8px; border-radius: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; background: var(--accent-soft); color: var(--accent-strong); vertical-align: 1px; }
.team-row.is-blocked .av-wrap, .team-row.is-blocked .team-nm { opacity: .5; }
.chk { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; width: fit-content; }
.chk input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.pw-card { display: grid; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--row-hover); }
.pw-card > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pw-box { font: 600 15px/1.35 ui-monospace, "Cascadia Mono", Consolas, "SF Mono", monospace; color: var(--fg); user-select: all; overflow-wrap: anywhere; }
