:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --text: #1d1f23;
  --muted: #5b616b;
  --border: #dcdad5;
  --accent: #1f5f8b;
  --accent-text: #ffffff;
  --ok: #2f6b3a;
  --warn-bg: #fff4d6;
  --warn-border: #d9a400;
  --danger: #a1261c;
  --danger-bg: #fde8e6;
  --info-bg: #e8f1f8;
  --radius: 8px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1d2024;
    --text: #e8e6e3;
    --muted: #a3a8b0;
    --border: #353a41;
    --accent: #7db7e0;
    --accent-text: #0e1114;
    --ok: #8fd19e;
    --warn-bg: #3a3014;
    --warn-border: #c99a12;
    --danger: #ff9b91;
    --danger-bg: #3d1d1a;
    --info-bg: #1b2a36;
  }
}

* { box-sizing: border-box; }
/* Atrybut hidden ma wygrywać z regułami display (np. .actions { display: flex }). */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }

header.site { border-bottom: 1px solid var(--border); background: var(--surface); }
header.site .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding-top: 12px; padding-bottom: 12px; }
header.site .brand { font-weight: 700; text-decoration: none; color: var(--text); }
header.site nav { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 15px; }
header.site nav a { text-decoration: none; }
header.site nav a[aria-current="page"] { font-weight: 700; text-decoration: underline; }

main { padding: 24px 0 40px; }
h1 { font-size: 1.7rem; line-height: 1.25; margin: 0 0 12px; }
h2 { font-size: 1.25rem; margin: 32px 0 10px; }
h3 { font-size: 1.05rem; margin: 20px 0 8px; }
p, ul, ol { margin: 0 0 12px; }
.lead { color: var(--muted); font-size: 1.05rem; }
.muted { color: var(--muted); }
small, .small { font-size: 0.875rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 16px 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid .card { margin: 0; }

.notice { border-radius: var(--radius); padding: 12px 14px; margin: 16px 0; border: 1px solid var(--border); }
.notice.warn { background: var(--warn-bg); border-color: var(--warn-border); }
.notice.danger { background: var(--danger-bg); border-color: var(--danger); }
.notice.info { background: var(--info-bg); border-color: var(--border); }
.notice > :last-child { margin-bottom: 0; }

form .row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 12px; }
label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; }
label .hint { font-weight: 400; color: var(--muted); }
input, select { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; min-height: 42px; }
input[type="checkbox"] { width: auto; min-height: 0; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 5px; }

button, .button {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  border-radius: 6px; padding: 8px 14px; min-height: 42px;
}
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
/* Ukryte pole pliku dostaje fokus z klawiatury: pokazujemy go na etykiecie-przycisku. */
.button:has(+ .file-input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }

.result { font-size: 1.05rem; }
.big { font-size: 2rem; font-weight: 700; line-height: 1.1; }
meter { width: 100%; height: 22px; margin: 8px 0; }
.status-ok { color: var(--ok); font-weight: 700; }
.status-warn { color: var(--text); font-weight: 700; }
.status-danger { color: var(--danger); font-weight: 700; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

.log { white-space: pre-wrap; font-size: 0.875rem; }
.sources li { margin-bottom: 6px; }
dl.facts dt { font-weight: 700; margin-top: 12px; }
dl.facts dd { margin: 4px 0 0 0; }

footer.site { border-top: 1px solid var(--border); padding: 20px 0 32px; font-size: 0.9rem; color: var(--muted); }
footer.site p { margin: 0 0 6px; }
footer.site a { color: var(--muted); }

.print-only { display: none; }

@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  header.site, footer.site, .no-print, .notice { display: none !important; }
  .print-only { display: block; }
  main { padding: 0; }
  .card, .table-wrap { border: 0; border-radius: 0; padding: 0; background: #fff; overflow: visible; }
  th { background: #eee; }
  th, td { border: 1px solid #999; }
  a { color: #000; text-decoration: none; }
}
