:root {
  --bg: #f4f5f7; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --primary: #1f4e8c; --primary-2: #173c6c;
  --ok: #1d7a46; --ok-bg: #e5f4ea; --warn: #9a5b00; --warn-bg: #fff3dc;
  --bad: #b42318; --bad-bg: #fde8e6; --info-bg: #e8effa;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .75rem; }
.card h2 { margin-top: 0; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 20px; padding-bottom: 60px; }
.muted { color: var(--muted); }
.mt { margin-top: 1rem; }
.nowrap { white-space: nowrap; }
code { background: #eef0f3; padding: 1px 5px; border-radius: 4px; }

.top { background: var(--primary); color: #fff; }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 600; text-decoration: none; }
.top nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.top nav a, .top nav .link { color: #dfe8f5; text-decoration: none; }
.top nav a:hover, .top nav .link:hover { color: #fff; }
.top nav .btn { background: #fff; color: var(--primary); }
.inline { display: inline; }
button.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.narrow { max-width: 680px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--info-bg); }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--bad-bg); color: var(--bad); }

label { display: block; margin-bottom: 12px; font-weight: 500; }
input, textarea, select { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit;
  border: 1px solid #cfd4dc; border-radius: 8px; background: #fff; color: inherit; }
input[type=file] { border: 1px dashed #cfd4dc; padding: 8px; font-size: .9rem; }
input:focus, textarea:focus, select:focus { outline: 2px solid #9db8e0; border-color: var(--primary); }
textarea { resize: vertical; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
label.check input { width: auto; margin-top: 4px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 14px; padding: 10px 14px 2px; }
legend { padding: 0 6px; font-weight: 500; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

.btn { display: inline-block; background: var(--primary); color: #fff; border: 1px solid transparent; border-radius: 8px;
  padding: 9px 16px; font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; text-align: center; }
.btn:hover { background: var(--primary-2); }
.btn-sm { padding: 5px 11px; font-size: .9rem; }
.btn.full { width: 100%; margin-top: 4px; }
.btn.ghost { background: #fff; color: var(--primary); border-color: #cfd4dc; }
.btn.ghost:hover { background: #f1f4f9; }
.btn.ok { background: var(--ok); } .btn.ok:hover { background: #155c35; }
.btn.danger { background: var(--bad); } .btn.danger:hover { background: #8f1c13; }
.btn.danger.ghost { background: #fff; color: var(--bad); border-color: #f0c5c0; }
.actions { margin-top: 8px; display: flex; gap: 10px; align-items: center; }
.actions.spread { justify-content: space-between; }
.actions.spread input[type=file] { width: auto; flex: 1; margin: 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid2.top { align-items: start; gap: 16px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }

.login { max-width: 380px; margin: 10vh auto 0; }
.login h1 { font-size: 1.25rem; }

.head-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.head-row h1 { margin: 0; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.tabs a span { color: var(--muted); font-size: .85rem; margin-left: 2px; }
.tabs a.active { background: var(--card); border: 1px solid var(--line); font-weight: 600; }
.search { display: flex; gap: 6px; }
.search input { margin: 0; min-width: 240px; padding: 6px 10px; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; justify-content: space-between; gap: 16px; text-decoration: none; color: inherit;
  border-left: 4px solid transparent; padding: 14px 18px; }
.item:hover { border-color: #c5d3e8; border-left-color: inherit; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.item.overdue { border-left-color: var(--bad); }
.item.today, .item.soon { border-left-color: #e0a100; }
.item-title { font-weight: 600; font-size: 1.02rem; }
.item-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: .88rem; margin-top: 2px; }
.item-side { text-align: right; min-width: 170px; font-size: .9rem; }
.deadline { margin-top: 4px; }
.done-at { color: var(--ok); }
@media (max-width: 640px) { .item { flex-direction: column; gap: 6px; } .item-side { text-align: left; } }

.status { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.s-nowe { background: #eef0f3; color: #3c4453; }
.s-w_toku { background: var(--info-bg); color: var(--primary); }
.s-zrobione { background: var(--warn-bg); color: var(--warn); }
.s-zaakceptowane { background: var(--ok-bg); color: var(--ok); }
.dl-note { font-size: .85rem; color: var(--muted); }
.dl-note.overdue, .dl-note.late { color: var(--bad); font-weight: 600; }
.dl-note.today, .dl-note.soon { color: var(--warn); font-weight: 600; }
.pill { padding: 3px 10px; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.pill.overdue { background: var(--bad-bg); color: var(--bad); }
.tag { display: inline-block; font-size: .78rem; background: #eef0f3; color: #3c4453; border-radius: 6px; padding: 1px 7px; }

.task-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.task-layout aside { position: sticky; top: 16px; }
@media (max-width: 860px) { .task-layout { grid-template-columns: 1fr; } .task-layout aside { position: static; order: -1; } }
.task-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 32px; margin: 16px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line); }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 2px 0 0; }
.desc { white-space: pre-wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.action-card form { margin-bottom: 10px; }
.action-card p { margin-top: 0; }
details.return summary { cursor: pointer; color: var(--bad); margin: 6px 0 10px; }

.timeline { list-style: none; padding: 0; margin: 0 0 16px; }
.entry { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px; }
.entry.r-urzednik { border-left: 4px solid var(--primary); }
.entry.r-wykonawca { border-left: 4px solid #8a6fd1; }
.entry.k-done { background: #f6fbf8; }
.entry.k-accept { background: var(--ok-bg); }
.entry.k-return { background: #fff7f6; }
.entry:not(.k-comment):not(.k-done):not(.k-return):not(.k-accept) { background: #fafbfc; }
.entry-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: .92rem; }
.entry-extra { margin-top: 6px; font-size: .92rem; }
.entry-body { white-space: pre-wrap; margin-top: 6px; }
.files { list-style: none; padding: 0; margin: 8px 0 0; }
.files li { margin: 2px 0; }
.files a { text-decoration: none; }

.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tr.inactive td { color: var(--muted); }
.ok-text { color: var(--ok); } .err-text { color: var(--bad); }

/* --- Zdjęcia i załączniki --- */
.label { font-weight: 500; margin-bottom: 4px; }
.upload { margin-bottom: 12px; flex: 1; }
.upload-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.upload-btn { position: relative; overflow: hidden; font-weight: 500; margin: 0; }
.upload-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; width: 100%; font-size: 0; }
.upload-btn:focus-within { outline: 2px solid #9db8e0; }
.upload-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.upload-preview:empty { display: none; }
.up-item { position: relative; display: flex; flex-direction: column; width: 96px; font-size: .75rem; color: var(--muted); }
.up-item img, .up-icon { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #f7f8fa; }
.up-icon { display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.up-del { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 24px; cursor: pointer; padding: 0; }
form.is-busy { opacity: .7; }
.actions.spread { align-items: flex-start; }
.actions.spread .upload { margin-bottom: 0; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.gallery figure { margin: 0; }
.gallery img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #f0f2f5; }
.gallery img:hover { filter: brightness(.95); }
.gallery figcaption { display: flex; justify-content: space-between; font-size: .8rem; margin-top: 3px; }
.gallery figcaption a { text-decoration: none; color: var(--muted); }
button.del { color: var(--bad); font-size: .8rem; }
