:root {
  --bg: #fbfaf7;
  --fg: #1d1d1f;
  --muted: #5f6368;
  --line: #e3e0d8;
  --panel: #ffffff;
  --accent: #1f4e8c;
  --warn-bg: #fff4d6;
  --warn-line: #e0b84a;
  --ok: #1e7b45;
  --bad: #b3261e;
  --unk: #8a6d00;
  --row-hover: #f2efe7;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141517;
    --fg: #e8e6e1;
    --muted: #a3a6ab;
    --line: #2e3034;
    --panel: #1c1d20;
    --accent: #8ab4f8;
    --warn-bg: #3a2f10;
    --warn-line: #8c6d1f;
    --ok: #6fcf97;
    --bad: #f28b82;
    --unk: #e6c15a;
    --row-hover: #23252a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
/* Pełna szerokość okna na desktopie; boczne marginesy zależne od szerokości */
.wrap { max-width: none; margin: 0; padding: 0 clamp(16px, 2vw, 32px); }

.top { border-bottom: 1px solid var(--line); background: var(--panel); padding: 20px 0 16px; }
.top h1 { margin: 0; font-size: 26px; letter-spacing: .02em; }
.top h1 a { color: inherit; text-decoration: none; }
.tagline { margin: 4px 0 12px; color: var(--muted); }
.warning { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: 10px 12px; font-size: 14px; }

.filters {
  display: grid; gap: 10px 12px; margin: 16px 0 8px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  align-items: end;
}
.filters label, .filters fieldset { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); min-width: 0; }
.filters .f-search { grid-column: 1 / -1; }
.filters fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px 6px; margin: 0; grid-column: span 2; }
.filters fieldset label { flex-direction: row; align-items: center; gap: 6px; color: var(--fg); }
.filters legend { padding: 0 4px; }
input, select, button {
  font: inherit; color: var(--fg); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0; width: 100%;
}
input[type=checkbox] { width: auto; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
.f-actions { display: flex; }

.summary { color: var(--muted); margin: 8px 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: var(--panel); cursor: pointer; user-select: none; white-space: nowrap; font-weight: 600; }
th[aria-sort=ascending]::after { content: " ▲"; font-size: 10px; }
th[aria-sort=descending]::after { content: " ▼"; font-size: 10px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--row-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.c, th.c { text-align: center; }
td.nowrap { white-space: nowrap; }
td .eli { display: block; color: var(--muted); font-size: 12px; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 12px; border: 1px solid currentColor; white-space: nowrap; }
.k-zgodny { color: var(--ok); }
.k-rozbiezny { color: var(--bad); }
.k-niezweryfikowany { color: var(--unk); }
.k-brak { color: var(--muted); border-style: dashed; }
.more { text-align: center; padding: 12px; }

.kontrole { margin: 24px 0; }
.kontrole h2 { font-size: 17px; }

dialog { width: min(860px, calc(100vw - 24px)); max-height: calc(100vh - 40px); border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--fg); padding: 0 20px 20px; }
dialog::backdrop { background: rgba(0,0,0,.45); }
.close-row { display: flex; justify-content: flex-end; position: sticky; top: 0; background: var(--panel); padding-top: 10px; }
.close-row button { width: auto; }
dialog h2 { margin: 0 0 4px; font-size: 19px; }
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 12px 0; font-size: 14px; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; overflow-wrap: anywhere; }
.links { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 8px 0 16px; }
.znal { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 8px 0; }
.znal blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }
.mini { width: 100%; font-size: 13px; }
.mini td, .mini th { padding: 4px 6px; cursor: default; position: static; }

.foot { color: var(--muted); font-size: 13px; padding-top: 16px; padding-bottom: 32px; border-top: 1px solid var(--line); margin-top: 24px; }

@media (max-width: 640px) {
  .filters fieldset { grid-column: 1 / -1; }
  th, td { padding: 6px; }
  .hide-sm { display: none; }
}

/* Wyszukiwanie podstawowe i zaawansowane */
.basic { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: end; margin: 16px 0 8px; }
.basic .f-search { flex: 1 1 320px; display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.toggle { display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer; }
.toggle input { width: 18px; height: 18px; }
.cnt { color: var(--muted); font-variant-numeric: tabular-nums; }
details.adv { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 0 12px; margin: 8px 0; }
details.adv > summary { cursor: pointer; padding: 10px 0; font-weight: 600; }
details.adv[open] > summary { border-bottom: 1px solid var(--line); }
.adv-active { font-weight: 400; color: var(--accent); }
details.adv .filters { margin: 12px 0 4px; }
.f-help small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 10px; }

/* Podlista znalezisk pod wierszem ustawy */
.znal-btn { width: auto; padding: 2px 8px; border-radius: 12px; font-weight: 600; border-color: var(--accent); color: var(--accent); }
tr.znal-row { cursor: default; }
tr.znal-row:hover { background: transparent; }
tr.znal-row > td { background: var(--row-hover); padding: 8px 12px 12px; }
.zn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.zn { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.zn-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.zn-kat { color: var(--accent); }
.zn-meta { color: var(--muted); font-size: 12px; }
.zn p { margin: 6px 0; }
.zn blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); font-size: 13px; }
.zn details summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.zn-nr { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2.2em; }

/* Responsywność tabeli: przy mniejszej szerokości chowamy kolejne kolumny (od najmniej istotnych).
   Zawsze widoczne: Ustawa, Data, Br., Znal. Pełne dane są w oknie szczegółów. */
@media (max-width: 1180px) { .c-tu { display: none; } }
@media (max-width: 1020px) { .c-wer { display: none; } }
@media (max-width: 860px)  { .c-potj, .c-tj { display: none; } }
@media (max-width: 600px)  { .c-zm { display: none; } td .eli { font-size: 11px; } }
