/* Baza wiedzy Single Origin — style aplikacji
   Jasny, nowoczesny motyw: białe powierzchnie, ciepłe szarości,
   miedziany akcent nawiązujący do logo palarni. */

:root {
    --bg:          #faf9f7;   /* tło aplikacji */
    --surface:     #ffffff;   /* karty, sidebar, topbar */
    --border:      #e9e4dd;
    --border-soft: #f1eee9;

    --ink:    #221c17;        /* nagłówki */
    --text:   #46403b;        /* tekst podstawowy */
    --muted:  #837b73;        /* opisy, metadane */
    --faint:  #aaa29a;        /* najcichsze detale */

    --accent:        #a3612f; /* miedź — linki, akcje */
    --accent-strong: #864d22;
    --accent-soft:   #f6efe7; /* tła hover / aktywne */

    --red:      #b3261e;
    --red-soft: #fdeeed;

    /* Ciemna lewa kolumna */
    --side-bg:     #1b1815;   /* niemal czarny, z ciepłym odcieniem */
    --side-text:   #cfc7bf;
    --side-muted:  #948b82;
    --side-faint:  #6d655e;
    --side-hover:  rgba(255, 255, 255, .06);

    --radius:    12px;
    --radius-sm: 9px;
    --shadow-sm: 0 1px 2px rgba(34, 28, 23, .04);
    --shadow:    0 1px 2px rgba(34, 28, 23, .04), 0 8px 24px rgba(34, 28, 23, .05);
    --ring:      0 0 0 3px rgba(163, 97, 47, .18);

    --sidebar-w: 280px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font: 15px/1.6 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; font-weight: 700; letter-spacing: -.015em; color: var(--ink); }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.inline { display: inline; }
.num { text-align: right; }

::selection { background: #ecdcc9; }

/* ---------- Układ ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--side-bg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: #3b3531; border-radius: 4px; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.content { padding: 28px 36px 56px; max-width: 1180px; width: 100%; }

.footer {
    margin-top: auto; padding: 18px 36px; border-top: 1px solid var(--border-soft);
    display: flex; justify-content: space-between; color: var(--faint); font-size: .8rem;
}

/* ---------- Sidebar: logo ---------- */
.brand { display: block; padding: 26px 26px 8px; text-align: center; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 100%; max-width: 200px; height: auto; display: inline-block; }
.brand-sub {
    display: block; margin-top: 8px; font-size: .68rem; font-weight: 600;
    letter-spacing: .22em; text-transform: uppercase; color: var(--side-muted);
}

/* ---------- Sidebar: szukajka ---------- */
.search { position: relative; padding: 16px 16px 6px; }
/* Wyższa specyficzność niż ogólna reguła input[type=search] niżej w pliku. */
.search input[type=search] {
    width: 100%; padding: 9px 12px 9px 38px; border-radius: var(--radius-sm); font-size: .88rem;
    border: 1px solid transparent; background: rgba(255, 255, 255, .08); color: #f1ece6;
}
.search input::placeholder { color: var(--side-faint); }
.search input:focus { outline: none; background: rgba(255, 255, 255, .12); border-color: var(--accent); box-shadow: none; }
.search-ico {
    position: absolute; left: 28px; top: 50%; transform: translateY(calc(-50% + 5px));
    width: 15px; height: 15px; stroke: var(--side-faint); fill: none; stroke-width: 2;
    stroke-linecap: round; pointer-events: none;
}

/* ---------- Sidebar: nawigacja ---------- */
.nav { padding: 12px 12px 30px; }
.nav-section { margin-bottom: 22px; }
.nav-section-head { padding: 4px 10px 6px; }
.nav-title {
    font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
    color: var(--side-muted);
}
a.nav-title:hover { color: #fff; text-decoration: none; }
.nav-title.muted { color: var(--side-faint); }
.nav-empty { color: var(--side-faint); font-size: .82rem; padding: 2px 12px; }

.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { margin-left: 15px; border-left: 1px solid #2e2925; display: none; padding-left: 2px; }
.tree li.is-open > .tree { display: block; }

.tree-row { display: flex; align-items: center; gap: 2px; border-radius: 8px; padding: 1px 6px; }
.tree-row:hover { background: var(--side-hover); }
.tree-row.is-active { background: var(--accent); }
.tree-row.is-active > a { color: #fff; font-weight: 600; }

.tree-row a {
    color: var(--side-text); flex: 1; min-width: 0; padding: 6px 2px; font-size: .89rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tree-row a:hover { text-decoration: none; color: #fff; }

.tree-toggle {
    background: none; border: 0; color: var(--side-faint); cursor: pointer; padding: 2px 4px;
    transition: transform .15s ease; line-height: 1; font-size: .72rem;
}
.tree-toggle:hover { color: #d3a06c; }
li.is-open > .tree-row > .tree-toggle { transform: rotate(90deg); }
.tree-bullet { color: #453e38; width: 15px; text-align: center; font-size: .8rem; }
.tree-count {
    font-size: .68rem; color: var(--side-muted); background: rgba(255, 255, 255, .08);
    border-radius: 20px; padding: 1px 7px; line-height: 1.5;
}
.tree-row.is-active .tree-count { background: rgba(255, 255, 255, .22); color: #fff; }

/* ---------- Topbar ---------- */
.topbar {
    display: flex; align-items: center; gap: 14px;
    padding: 13px 36px; background: rgba(255, 255, 255, .85); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-soft);
    position: sticky; top: 0; z-index: 30;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.burger { display: none; background: none; border: 0; font-size: 1.25rem; cursor: pointer; color: var(--text); }

/* Menu „Zarządzanie" w górnym pasku */
.topnav { display: flex; gap: 2px; align-items: center; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
    padding: 6px 12px; border-radius: 8px; font-size: .85rem; font-weight: 500;
    color: var(--muted); white-space: nowrap;
}
.topnav a:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.topnav a.is-active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }

.user-menu { position: relative; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
    background: linear-gradient(150deg, #b97a45, #8a5427); color: #fff; font-weight: 700; font-size: .76rem;
}
.avatar:hover { filter: brightness(1.08); }
.dropdown {
    position: absolute; right: 0; top: 44px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); min-width: 230px; padding: 6px; display: none; z-index: 40;
}
.user-menu.is-open .dropdown { display: block; }
.dropdown-head { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); margin-bottom: 6px; }
.dropdown-head strong { color: var(--ink); }
.dropdown-head small { display: block; color: var(--muted); font-size: .78rem; margin-bottom: 7px; }
.dropdown a, .dropdown .linklike {
    display: block; width: 100%; text-align: left; padding: 8px 12px; border-radius: 8px;
    color: var(--text); background: none; border: 0; font: inherit; font-size: .9rem; cursor: pointer;
}
.dropdown a:hover, .dropdown .linklike:hover { background: var(--bg); color: var(--ink); text-decoration: none; }

/* ---------- Elementy ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px 24px; box-shadow: var(--shadow-sm); margin-bottom: 20px;
}
.card-title {
    font-size: .95rem; margin-bottom: 14px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border-soft);
}
.sub-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 10px 0 8px; }

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: 3px; }
.page-head p { margin: 0; font-size: .87rem; }
.page-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-side { grid-template-columns: 1fr 360px; align-items: start; }

.btn {
    display: inline-flex; align-items: center; gap: 6px; justify-content: center;
    padding: 8px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: .87rem;
    font-weight: 500; white-space: nowrap;
    transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn:hover { background: var(--bg); border-color: #d9d2c8; color: var(--ink); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary {
    background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
    box-shadow: 0 1px 2px rgba(134, 77, 34, .3);
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-danger { color: var(--red); border-color: #eedad8; background: var(--surface); }
.btn-danger:hover { background: var(--red-soft); color: var(--red); border-color: #e4bab6; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn-xs { padding: 3px 10px; font-size: .76rem; }
.btn-block { display: flex; width: 100%; margin-bottom: 8px; }

.badge {
    display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: .71rem; font-weight: 500;
    background: var(--bg); color: var(--muted); border: 1px solid var(--border); vertical-align: middle;
}
.badge-draft { background: #fdf6e3; color: #8a6100; border-color: #efdfb0; }
.badge-role  { background: var(--accent-soft); color: var(--accent-strong); border-color: #ead9c5; }
.badge-ok    { background: #edf6ea; color: #2f6420; border-color: #d3e6cc; }

.chip {
    display: inline-block; padding: 4px 11px; border-radius: 20px; font-size: .79rem;
    background: var(--bg); border: 1px solid var(--border); color: var(--text); margin: 0 4px 4px 0;
}
.chip:hover { background: var(--accent-soft); border-color: #ead9c5; color: var(--accent-strong); text-decoration: none; }
.chip-sm { font-size: .73rem; padding: 2px 8px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
    display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 20px;
    background: var(--bg); color: var(--text); font-size: .79rem; border: 1px solid var(--border);
}
.tag:hover { background: var(--accent-soft); color: var(--accent-strong); border-color: #ead9c5; text-decoration: none; }
.tag span { font-size: .7rem; color: var(--faint); }
.tags-sm .tag, .tags-xs .tag { font-size: .73rem; padding: 2px 8px; }
.tags-xs { margin-top: 4px; }

.alert {
    display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-sm);
    margin-bottom: 16px; border: 1px solid; font-size: .89rem;
}
.alert span { flex: 1; }
.alert-success { background: #f0f8ec; border-color: #d5e8cb; color: #2c5a1a; }
.alert-error   { background: var(--red-soft); border-color: #f0d2cf; color: #8f221c; }
.alert-warning { background: #fdf6e3; border-color: #efdfb0; color: #77560a; }
.alert-close { background: none; border: 0; cursor: pointer; font-size: 1.1rem; line-height: 1; color: inherit; opacity: .55; }
.alert-close:hover { opacity: 1; }

.empty { text-align: center; color: var(--muted); padding: 44px 20px; }

/* Ramka informacyjna w formularzach */
.notice {
    margin-top: 14px; padding: 12px 16px; border-radius: var(--radius-sm); font-size: .86rem; line-height: 1.6;
    background: var(--bg); border: 1px solid var(--border-soft); color: var(--muted);
}
.notice strong { color: var(--text); }

/* ---------- Listy ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--border-soft); }
.list li:last-child { border-bottom: 0; }
.list-main { flex: 1; min-width: 0; font-weight: 500; color: var(--ink); }
.list-main:hover { color: var(--accent-strong); text-decoration: none; }
.list-meta { font-size: .77rem; color: var(--faint); white-space: nowrap; }

.subcats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.subcat {
    padding: 8px 15px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border);
    font-size: .87rem; font-weight: 500; color: var(--text); box-shadow: var(--shadow-sm);
}
.subcat:hover { border-color: var(--accent); color: var(--accent-strong); text-decoration: none; }

.article-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.article-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 22px; box-shadow: var(--shadow-sm); transition: border-color .12s;
}
.article-card:hover { border-color: #d9d2c8; }
.article-card h2, .article-card h3 { font-size: 1.05rem; margin-bottom: 5px; }
.article-card h2 a, .article-card h3 a { color: var(--ink); }
.article-card h2 a:hover, .article-card h3 a:hover { color: var(--accent-strong); text-decoration: none; }
.article-card .excerpt { margin: 0 0 10px; color: var(--muted); font-size: .89rem; }
.article-meta { display: flex; flex-wrap: wrap; align-items: baseline; font-size: .77rem; color: var(--faint); }
.article-meta span + span::before { content: "·"; margin: 0 8px; color: var(--border); }
.article-meta + .tags { margin-top: 10px; }

mark { background: #fbe9b7; padding: 0 2px; border-radius: 3px; }

.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin: 20px 0; }
.pagination a, .pagination .current {
    padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface); font-size: .84rem; color: var(--text);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent-strong); text-decoration: none; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

/* ---------- Pliki ---------- */
.fbadge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 42px; padding: 4px 7px; border-radius: 7px;
    font-size: .64rem; font-weight: 700; letter-spacing: .05em;
    background: var(--bg); color: var(--muted); flex: 0 0 auto;
}
.fbadge-pdf { background: #fdecea; color: #b3261e; }
.fbadge-doc { background: #e8f0fc; color: #2b5cb0; }
.fbadge-xls { background: #e8f5e9; color: #1e7a3c; }
.fbadge-ppt { background: #fdefe2; color: #b25e10; }
.fbadge-zip { background: #efeaf8; color: #5b3fa8; }
.fbadge-img { background: #e6f4f6; color: #0f7285; }
.fbadge-vid { background: #fceaf2; color: #a82960; }
.fbadge-aud { background: #f9f0e0; color: #8a6100; }

.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border-soft); }
.file-list li:last-child { border-bottom: 0; }
.file-row { display: flex; align-items: center; gap: 14px; padding: 12px 6px; flex: 1; min-width: 0; color: var(--text); border-radius: var(--radius-sm); }
.file-row:hover { text-decoration: none; background: var(--bg); }
.file-name { flex: 1; min-width: 0; }
.file-name strong { display: block; font-weight: 600; color: var(--ink); }
.file-name small { display: block; color: var(--faint); font-size: .76rem; }
.file-name small.desc { color: var(--muted); font-style: italic; }
.file-dl { font-size: .8rem; color: var(--accent); font-weight: 600; white-space: nowrap; }
.file-row:hover .file-dl { color: var(--accent-strong); }
.file-edit { padding: 6px 10px; font-size: .78rem; color: var(--faint); }
.file-edit:hover { color: var(--accent-strong); text-decoration: none; }

/* ---------- Artykuł: czysty dokument ---------- */
.view-doc, .view-doc .main { background: var(--surface); }
.view-doc .topbar { background: rgba(255, 255, 255, .85); }
.view-doc .content { padding-top: 34px; max-width: 900px; }

.doc { max-width: 780px; }
.doc-title { font-size: 2rem; line-height: 1.2; margin: 0 0 14px; }

.doc-draft {
    margin: 0 0 14px; font-size: .85rem; color: #8a6100;
    border-left: 2px solid #e8c96a; padding-left: 10px;
}

.doc-meta {
    display: flex; flex-wrap: wrap; gap: 2px 26px;
    margin: 0 0 18px; font-size: .82rem; line-height: 1.7; color: var(--faint);
}
.doc-meta a { color: var(--faint); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--border); }
.doc-meta a:hover { color: var(--accent-strong); text-decoration-color: currentColor; }

.doc-actions { display: flex; flex-wrap: wrap; gap: 18px; margin: 0 0 28px; padding-bottom: 20px; border-bottom: 1px solid var(--border-soft); }
.doc-actions a, .doc-actions button {
    padding: 0; border: 0; background: none; font: inherit; font-size: .85rem;
    color: var(--muted); cursor: pointer; text-decoration: none;
}
.doc-actions a:hover, .doc-actions button:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }

.doc-body { font-size: 1rem; }

.doc-section { margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--border-soft); }
.doc-section h2 { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); margin-bottom: 12px; }

.doc-files { list-style: none; margin: 0; padding: 0; }
.doc-files li { padding: 5px 0; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.doc-files li > a { font-size: .95rem; }
.doc-file-info { font-size: .78rem; color: var(--faint); }

.doc-tags { margin-top: 28px; font-size: .82rem; color: var(--faint); }
.doc-tags a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--border); }
.doc-tags a:hover { color: var(--accent-strong); }

/* ---------- Treść (prose) ---------- */
.prose { line-height: 1.75; color: var(--text); }
.prose > *:first-child { margin-top: 0; }
.prose h2 { font-size: 1.3rem; margin: 1.6em 0 .5em; }
.prose h3 { font-size: 1.1rem; margin: 1.4em 0 .4em; }
.prose h4 { font-size: 1rem; margin: 1.2em 0 .4em; }
.prose p { margin: 0 0 1em; }
.prose ul, .prose ol { margin: 0 0 1em; padding-left: 1.5em; }
.prose li { margin-bottom: .3em; }
.prose a { text-decoration: underline; text-underline-offset: 3px; }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius-sm); margin: .5em 0; }
.prose blockquote {
    margin: 1em 0; padding: .6em 1.2em; border-left: 3px solid var(--accent);
    background: var(--bg); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--muted);
}
.prose pre {
    background: #231d18; color: #ece5dd; padding: 14px 18px; border-radius: var(--radius-sm);
    overflow-x: auto; font-size: .85rem;
}
.prose code { background: var(--bg); border: 1px solid var(--border-soft); padding: 1px 6px; border-radius: 5px; font-size: .87em; }
.prose pre code { background: none; border: 0; padding: 0; color: inherit; }
.prose table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: .9rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
.prose th { background: var(--bg); font-weight: 600; color: var(--ink); }
.prose hr { border: 0; border-top: 1px solid var(--border-soft); margin: 1.8em 0; }

/* ---------- Tabele ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th {
    text-align: left; font-size: .69rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
    color: var(--faint); border-bottom: 1px solid var(--border); padding: 8px 10px; white-space: nowrap;
}
.table td { padding: 11px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--bg); }
.table tr.is-muted { opacity: .55; }
.table td a { color: var(--ink); }
.table td a:hover { color: var(--accent-strong); text-decoration: none; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.rev-body { max-height: 320px; overflow: auto; background: var(--bg); padding: 14px 16px; border-radius: var(--radius-sm); }

/* ---------- Formularze ---------- */
.form label, .field { display: block; margin-bottom: 15px; }
.form label > span, .field-label {
    display: block; font-size: .79rem; font-weight: 600; margin-bottom: 6px; color: var(--ink);
}
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=number], input[type=date], input[type=datetime-local], input[type=file], select, textarea {
    width: 100%; padding: 9px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font: inherit; font-size: .91rem; background: var(--surface); color: var(--text);
    transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
textarea { resize: vertical; }
.big-label input { font-size: 1.05rem; padding: 11px 15px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .span-2 { grid-column: span 2; }
.align-end { align-self: end; margin-bottom: 20px; }

.checkbox { display: flex !important; align-items: center; gap: 8px; margin-bottom: 6px; font-size: .9rem; cursor: pointer; }
.checkbox input { width: auto; margin: 0; accent-color: var(--accent); }
.checkbox > span { font-weight: 400 !important; font-size: .89rem !important; margin: 0 !important; color: var(--text); }

.hint { font-size: .78rem; color: var(--muted); margin: 5px 0 0; }
.field .hint { margin-top: 7px; }

.form-columns { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
.form-side { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 16px; }
.side-box {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow-sm);
}
.side-box h3 { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 12px; }
.side-actions { margin-top: 14px; }

.cat-picker {
    max-height: 260px; overflow-y: auto; border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface);
}
.cat-picker.tall { max-height: 340px; }
.access-tools { display: flex; gap: 8px; margin-bottom: 12px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 18px; }
.filters input[type=search] { flex: 1; min-width: 200px; }
.filters select { width: auto; min-width: 180px; }
.inline-form { display: inline-flex; gap: 6px; }
.inline-form select { width: auto; }

.att-list { list-style: none; margin: 0 0 12px; padding: 0; }
.att-list li {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 6px; background: var(--surface);
}
.att-list li input[type=text] { flex: 1; }
.att-list li small { color: var(--faint); font-size: .74rem; white-space: nowrap; }
.att-new { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.att-new input[type=text] { flex: 0 0 40%; }
.att-new input[type=file] { flex: 1; }

.dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 20px; margin: 0; font-size: .9rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; color: var(--ink); }

.stat-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 22px; min-width: 132px; box-shadow: var(--shadow-sm); color: var(--text);
}
a.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat strong { display: block; font-size: 1.55rem; font-weight: 700; line-height: 1.2; color: var(--ink); letter-spacing: -.02em; }
.stat span { font-size: .77rem; color: var(--muted); }

.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tab { padding: 9px 16px; color: var(--muted); font-size: .9rem; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.is-active { color: var(--accent-strong); border-bottom-color: var(--accent); font-weight: 600; }

.search-big { display: flex; gap: 10px; }
.search-big input { flex: 1; font-size: 1rem; padding: 12px 16px; }

/* ---------- Edytor ---------- */
/* Uwaga: bez overflow:hidden na .editor — inaczej sticky toolbar liczy się względem
   samego edytora i przesuwa się o `top` w dół, zasłaniając początek pola edycji. */
.editor { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: text; }
.editor.is-focused { border-color: var(--accent); box-shadow: var(--ring); }
.editor-toolbar {
    display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; background: var(--bg);
    border-bottom: 1px solid var(--border-soft); border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    position: sticky; top: 61px; z-index: 5;
}
.editor-toolbar button {
    min-width: 32px; height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: 7px;
    background: none; cursor: pointer; font-size: .85rem; color: var(--text);
}
.editor-toolbar button:hover { background: var(--surface); border-color: var(--border); }
.editor-toolbar button.is-active { background: var(--accent); color: #fff; }
.editor-toolbar .sep { width: 1px; background: var(--border); margin: 4px 5px; }
.editor-body {
    min-height: 420px; padding: 18px 22px; outline: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm); cursor: text;
}
.editor-body:empty::before { content: "Zacznij pisać treść procedury…"; color: var(--faint); }
.editor.is-dragover { outline: 2px dashed var(--accent); }

.error-card { text-align: center; padding: 52px 20px; }
.error-code { font-size: 3.4rem; font-weight: 800; color: var(--accent); line-height: 1; letter-spacing: -.03em; }

/* ---------- Logowanie ---------- */
.login-page {
    display: grid; place-items: center; min-height: 100vh; padding: 20px;
    background: var(--bg);
    background-image: radial-gradient(60rem 40rem at 85% -10%, #f3e8da 0%, transparent 60%),
                      radial-gradient(50rem 34rem at -10% 110%, #f0e9df 0%, transparent 55%);
}
.login-box {
    width: 100%; max-width: 410px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 18px; padding: 36px 34px 30px; box-shadow: var(--shadow);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-logo { width: 168px; height: auto; margin-bottom: 14px; }
.login-brand h1 { font-size: 1.2rem; margin: 0; }
.login-brand p { color: var(--muted); font-size: .86rem; margin: 4px 0 0; }
.login-form { margin-top: 6px; }
.login-form label { display: block; margin-bottom: 14px; }
.login-form label span { display: block; font-size: .79rem; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.login-links { text-align: center; margin: 16px 0 0; font-size: .85rem; }
.login-foot { text-align: center; font-size: .76rem; color: var(--faint); margin: 20px 0 0; line-height: 1.55; }

/* ---------- Responsywność ---------- */
@media (max-width: 1000px) {
    .grid-side, .form-columns { grid-template-columns: 1fr; }
    .form-side { position: static; }
}
@media (max-width: 860px) {
    .sidebar {
        position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%);
        transition: transform .2s ease; box-shadow: 0 0 48px rgba(34, 28, 23, .25);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open::after {
        content: ""; position: fixed; inset: 0; background: rgba(34, 28, 23, .35); z-index: 50;
    }
    .burger { display: block; }
    .content, .topbar, .footer { padding-left: 18px; padding-right: 18px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .att-new { flex-wrap: wrap; }
    .att-new input[type=text] { flex: 1 1 100%; }
}

/* ---------- Druk ---------- */
@media print {
    .sidebar, .topbar, .footer, .doc-actions, .page-actions, .alert { display: none !important; }
    .content { padding: 0; max-width: none; }
    .card { border: 0; box-shadow: none; padding: 0; }
    body { background: #fff; }
    a { color: #000; }
}

/* ---------- Kadry ---------- */
.nav-links { list-style: none; margin: 0; padding: 0; }
.nav-links a { display: block; padding: 6px 8px; border-radius: 8px; color: var(--side-text); font-size: .89rem; }
.nav-links a:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
.nav-links a.is-active { background: var(--accent); color: #fff; font-weight: 600; }

.badge-danger { background: var(--red-soft); color: var(--red); border-color: #eccac7; }
.text-danger { color: var(--red) !important; }

.scan-row { border-top: 1px solid var(--border-soft); padding-top: 14px; margin-top: 14px; }
.scan-row:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.scan-head { margin-bottom: 10px; font-size: .92rem; }

.vac-form {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
    padding: 14px 16px; margin-bottom: 18px;
    background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
}
.vac-form label { margin: 0; }
.vac-form label > span { display: block; font-size: .75rem; font-weight: 600; margin-bottom: 4px; color: var(--ink); }
.vac-form input[type=date] { width: 190px; font-size: 1rem; padding: 11px 13px; }
.ac-wrap { position: relative; }
.autocomplete {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 40; margin-top: 4px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: 0 10px 28px rgba(34, 28, 23, .13); max-height: 280px; overflow: auto;
}
.autocomplete button {
    display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
    width: 100%; padding: 9px 13px; border: 0; background: none;
    font: inherit; font-size: .91rem; color: var(--text); text-align: left; cursor: pointer;
}
.autocomplete button:hover, .autocomplete button:focus { background: var(--accent-soft); outline: none; }
.autocomplete .ac-price { color: var(--muted); font-size: .84rem; white-space: nowrap; }
.vac-form select { width: auto; min-width: 190px; font-size: 1rem; padding: 11px 13px; }
.vac-form .vac-note { flex: 1; min-width: 180px; }
.vac-days {
    min-width: 130px; padding: 9px 12px; font-size: .88rem; font-weight: 600;
    color: var(--accent-strong); background: var(--accent-soft); border-radius: var(--radius-sm); text-align: center;
}
