:root {
  --paper: #fafaf7;
  --card: #ffffff;
  --ink: #16201c;
  --ink-soft: #3f4a45;
  --line: #c9d1cd;
  /* Marka Lekowiedza: ciemny #0F5C63 (tekst/przyciski, 7,7:1 na białym), akcent #2A9D8F i jasny #7FD1C7
     tylko na ramki, ikony i duże elementy (za mały kontrast dla zwykłego tekstu), żółty #F2B544 tylko jako tło/akcent. */
  --brand: #0F5C63;
  --brand-accent: #2A9D8F;
  --brand-light: #7FD1C7;
  --brand-yellow: #F2B544;
  --green: var(--brand);
  --green-dark: #0A454B;
  --ok-bg: #e3f4f1;
  --amber-bg: #fff1cc;
  --amber-ink: #6b4a00;
  --amber-bar: var(--brand-yellow);
  --red-bg: #fbe4e1;
  --red-ink: #8e1f17;
  --red-bar: #c0392b;
  --focus: #1d4e89;
  --radius-s: 8px;
  --radius-l: 14px;
  font-size: 20px;
}
html.large { font-size: 24px; }

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Atkinson Hyperlegible', Verdana, Tahoma, sans-serif;
  line-height: 1.55;
}
.wrap { max-width: 44rem; margin: 0 auto; padding: 0 1rem; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; background: #fff; padding: .5rem; z-index: 10; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* Pasek marki z logo (białe tło — logo ma ciemny napis) */
.brand { background: #fff; border-bottom: 4px solid var(--brand-accent); }
.brand-inner { padding: .5rem 1rem; }
.brand-title { margin: 0; line-height: 0; }
.brand-link { display: inline-block; line-height: 0; border-radius: var(--radius-s); }
.brand-logo { display: block; height: 5.5rem; width: auto; max-width: 100%; }  /* podpis w logo ≥ 12 px */

/* Instancja badawcza (STUDY_MODE=1) — pasek wstawiany przez marka.js */
.study-bar {
  background: var(--brand-yellow); color: #16201c; border-bottom: 3px solid #16201c;
  padding: .5rem 1rem; text-align: center; font-weight: 700; font-size: 1.05rem; letter-spacing: .02em;
}
.study-bar span { font-weight: 400; }
@media (max-width: 40rem) { .study-bar { font-size: .85rem; padding: .4rem .8rem; } }

/* Linki w treści: kolor marki (7,7:1 na białym), grube podkreślenie; hover/focus wyraźnie inne */
main a:not(.btn), main a:not(.btn):visited {
  color: var(--brand); font-weight: 700;
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .2em;
}
main a:not(.btn):hover { color: var(--green-dark); text-decoration-thickness: 4px; background: var(--ok-bg); }
main a:not(.btn):focus-visible {
  outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 3px;
  background: var(--brand-yellow); color: #16201c; text-decoration-thickness: 4px;
}

/* Wybór pliku (panel administratora) — przycisk w stylu marki */
input[type="file"] { font: inherit; font-size: .9rem; color: var(--ink-soft); max-width: 100%; }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 700; color: var(--brand); background: #fff; cursor: pointer;
  border: 2px solid var(--brand); border-radius: var(--radius-s); padding: .45rem .9rem; margin-right: .7rem; min-height: 2.6rem;
}
input[type="file"]::file-selector-button:hover { background: var(--ok-bg); }
input[type="file"]:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: var(--radius-s); }

/* Nagłówek */
.top { background: var(--green); color: #fff; padding: 1.4rem 0 1.6rem; }
.top-inner { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 .4rem; }
.lead { margin: 0; font-size: 1.05rem; max-width: 32rem; }
.size-toggle { display: flex; gap: .3rem; flex-shrink: 0; }
.size-toggle button {
  min-width: 2.6rem; min-height: 2.6rem; border-radius: var(--radius-s);
  border: 2px solid rgba(255,255,255,.7); background: transparent; color: #fff;
  font: inherit; font-weight: 700; cursor: pointer;
}
.size-toggle .big-a { font-size: 1.3rem; }
.size-toggle button[aria-pressed="true"] { background: #fff; color: var(--green); }

/* Uwaga */
.notice {
  margin: 1.2rem 0; padding: .9rem 1.1rem; background: var(--amber-bg);
  border-left: 6px solid var(--amber-bar); border-radius: var(--radius-s); color: #3b2a00;
}
.notice p { margin: .2rem 0; }

/* Kroki */
.step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 1.2rem 1.2rem 1.4rem; margin: 1.2rem 0; }
h2 { font-size: 1.3rem; line-height: 1.25; margin: 0 0 .5rem; display: flex; align-items: center; gap: .6rem; }
/* Kółko z numerem tylko w nagłówkach kroków — klasa „num” jest też na komórkach liczbowych tabel */
h2 > .num, h3.rr-step > .num {
  display: inline-grid; place-items: center; width: 2rem; height: 2rem; flex-shrink: 0;
  border-radius: 50%; background: var(--green); color: #fff; font-size: 1.05rem;
}
.hint { color: var(--ink-soft); margin: 0 0 1rem; }
.soft { background: var(--paper); padding: .6rem .8rem; border-radius: var(--radius-s); }

.field-label, label[for] { display: block; font-weight: 700; margin: 1rem 0 .35rem; }
input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 2px solid var(--line); border-radius: var(--radius-s); padding: .6rem .7rem; min-height: 2.8rem;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px rgba(29,78,137,.25); }

/* Przyciski */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 700; min-height: 3rem; padding: .6rem 1.2rem;
  border-radius: var(--radius-s); border: 2px solid var(--green); cursor: pointer;
  background: #fff; color: var(--green); text-decoration: none;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-outline:hover { background: var(--ok-bg); }
.btn-big { background: var(--green); color: #fff; min-height: 4rem; font-size: 1.1rem; flex: 1; }
.btn-big.btn-outline { background: #fff; color: var(--green); }
.btn-wide { width: 100%; margin-top: 1.3rem; min-height: 3.4rem; font-size: 1.1rem; }
.btn[disabled] { opacity: .55; cursor: wait; }
.btn-remove {
  font: inherit; border: none; background: none; color: var(--red-ink); cursor: pointer;
  padding: .4rem .5rem; min-height: 2.6rem; text-decoration: underline;
}
.photo-buttons { display: flex; gap: .7rem; flex-wrap: wrap; }
.photo-buttons label { margin: 0; }
.photo-buttons label:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }

.thumbs { list-style: none; padding: 0; margin: .8rem 0 0; display: flex; gap: .6rem; flex-wrap: wrap; }
.thumbs li { position: relative; }
.thumbs img { width: 6rem; height: 6rem; object-fit: cover; border-radius: var(--radius-s); border: 1px solid var(--line); display: block; }
.btn-docs { flex-basis: 100%; }
.photo-thumb { margin: 0; position: relative; }
.photo-thumb figcaption {
  position: absolute; left: .3rem; bottom: .3rem; min-width: 1.5rem; height: 1.5rem; padding: 0 .3rem;
  display: grid; place-items: center; border-radius: 1rem; background: rgba(22,32,28,.8); color: #fff; font-size: .75rem; font-weight: 700;
}
.pdf-thumb {
  width: 6rem; height: 6rem; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--paper);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem; padding: .3rem; overflow: hidden;
}
.pdf-ico { background: var(--red-bar); color: #fff; font-weight: 700; font-size: .75rem; padding: .1rem .4rem; border-radius: 4px; }
.pdf-name { font-size: .65rem; line-height: 1.2; text-align: center; word-break: break-all; max-height: 3.6em; overflow: hidden; }
.filled-note { border-left: 6px solid var(--green); background: var(--ok-bg); }
.thumbs button {
  position: absolute; top: -.5rem; right: -.5rem; width: 2rem; height: 2rem; border-radius: 50%;
  border: 2px solid #fff; background: var(--red-bar); color: #fff; font-size: 1rem; cursor: pointer; line-height: 1;
}

.error { color: var(--red-ink); background: var(--red-bg); padding: .6rem .8rem; border-radius: var(--radius-s); margin-top: 1rem; font-weight: 700; }

/* Lista leków do poprawy */
.med-list { padding: 0; margin: 0 0 1rem; list-style: none; counter-reset: med; }
.med-list li {
  counter-increment: med; display: grid; grid-template-columns: 2rem 1fr auto; gap: .3rem .6rem;
  align-items: start; padding: .8rem 0; border-bottom: 1px solid var(--line);
}
.med-list li::before { content: counter(med) "."; font-weight: 700; padding-top: .6rem; }
.med-list li.low { background: var(--amber-bg); margin: 0 -.6rem; padding: .8rem .6rem; border-radius: var(--radius-s); }
.med-fields { display: grid; gap: .4rem; }
.med-fields input { min-height: 2.6rem; }
.med-fields .sub { font-size: .85rem; color: var(--ink-soft); margin: 0; }

/* Podpowiedzi leków */
.btn-second { margin-top: .7rem; min-height: 3rem; font-size: 1rem; }
.ac { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
  max-height: min(60vh, 26rem); overflow-y: auto; overscroll-behavior: contain;
  background: #fff; border: 2px solid var(--focus); border-radius: var(--radius-s);
  box-shadow: 0 8px 24px rgba(22,32,28,.18);
}
.ac-group { padding: .55rem .7rem .65rem; border-top: 1px solid var(--line); }
.ac-group:first-child { border-top: none; }
.ac-head strong { display: block; line-height: 1.25; }
.ac-meta { display: block; font-size: .8rem; color: var(--ink-soft); line-height: 1.3; }
.ac-doses { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; }
.ac-opt {
  cursor: pointer; font-size: .9rem; line-height: 1.2; padding: .45rem .7rem; min-height: 2.3rem;
  display: inline-flex; align-items: center; border: 2px solid var(--line); border-radius: 2rem; background: var(--paper);
}
.ac-opt:hover { border-color: var(--green); background: var(--ok-bg); }
.ac-opt.active { border-color: var(--focus); background: var(--focus); color: #fff; }

/* Choroby */
.checks { border: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .5rem; }
.checks label {
  display: flex; gap: .6rem; align-items: center; margin: 0; font-weight: 400;
  border: 2px solid var(--line); border-radius: var(--radius-s); padding: .55rem .7rem; cursor: pointer; min-height: 3rem;
}
.checks input { width: 1.4rem; height: 1.4rem; accent-color: var(--green); flex-shrink: 0; }
.checks label:has(input:checked) { border-color: var(--green); background: var(--ok-bg); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
@media (max-width: 520px) { .grid3 { grid-template-columns: 1fr 1fr; } .grid3 > div:last-child { grid-column: span 2; } }

/* Ładowanie */
.loading { text-align: center; padding: 2rem 1rem; }
.pill-anim { display: flex; justify-content: center; gap: .6rem; margin-bottom: 1rem; }
.pill-anim span { width: 2.4rem; height: 1rem; border-radius: 1rem; background: linear-gradient(90deg, var(--green) 50%, #fff 50%); border: 2px solid var(--green); animation: bob 1.4s ease-in-out infinite; }
.pill-anim span:nth-child(2) { animation-delay: .2s; }
.pill-anim span:nth-child(3) { animation-delay: .4s; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-.5rem) rotate(20deg); } }
@media (prefers-reduced-motion: reduce) { .pill-anim span { animation: none; } }

/* Wynik */
.result { margin: 1.5rem 0; outline: none; }
.result > h2 { font-size: 1.6rem; }
.print-date { color: var(--ink-soft); margin: 0 0 1rem; }
.block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 1.1rem 1.2rem; margin: 1rem 0; }
.block h3 { font-size: 1.15rem; margin: 0 0 .6rem; }
.block ul { margin: 0; padding-left: 1.2rem; }
.block li { margin: .35rem 0; }
.summary { font-size: 1.1rem; border-left: 6px solid var(--green); }
.urgent { background: var(--red-bg); border-color: var(--red-bar); border-left: 6px solid var(--red-bar); color: #4a0f0a; }

.item { border-top: 1px solid var(--line); padding: .8rem 0; }
.item:first-of-type { border-top: none; padding-top: 0; }
.item strong { display: block; }
.item p { margin: .25rem 0; }
.sev { display: inline-block; font-weight: 700; font-size: .85rem; padding: .1rem .55rem; border-radius: 1rem; margin-bottom: .3rem; }
.sev-high { background: var(--red-bg); color: var(--red-ink); }
.sev-moderate { background: var(--amber-bg); color: var(--amber-ink); }
.sev-low { background: var(--ok-bg); color: var(--green); }

/* Karta leku — kolorowy pasek jak naklejka apteczna */
.drug { display: grid; grid-template-columns: .5rem 1fr; gap: .9rem; padding: .9rem 0; border-top: 1px solid var(--line); }
.drug:first-of-type { border-top: none; }
.drug .bar { border-radius: 4px; }
.drug h4 { margin: 0; font-size: 1.1rem; }
.drug .subst { color: var(--ink-soft); margin: 0 0 .3rem; }
.drug .verdict { display: inline-block; font-weight: 700; padding: .15rem .6rem; border-radius: var(--radius-s); margin: .2rem 0 .4rem; }
.drug p { margin: .2rem 0; }
.drug .crit { font-size: .85rem; color: var(--ink-soft); }
.drug .taper { background: var(--amber-bg); padding: .4rem .6rem; border-radius: var(--radius-s); }
.v-keep .bar { background: var(--green); } .v-keep .verdict { background: var(--ok-bg); color: var(--green); }
.v-review .bar { background: var(--amber-bar); } .v-review .verdict { background: var(--amber-bg); color: var(--amber-ink); }
.v-consider_stop .bar, .v-duplicate .bar { background: var(--red-bar); }
.v-consider_stop .verdict, .v-duplicate .verdict { background: var(--red-bg); color: var(--red-ink); }

.sources a { color: var(--focus); word-break: break-word; }
.result-actions { display: flex; gap: .8rem; flex-wrap: wrap; margin: 1.4rem 0 2rem; }
.result-actions .btn { flex: 1; min-width: 12rem; }

.foot { color: var(--ink-soft); font-size: .85rem; padding-bottom: 2rem; }

/* Wydruk */
@media print {
  :root, html.large { font-size: 12pt; }
  body { background: #fff; }
  .top, .notice, .step, .loading, .result-actions, .foot, .skip { display: none !important; }
  .result { display: block !important; margin: 0; }
  .block { break-inside: avoid; border-color: #999; }
  .drug { break-inside: avoid; }
  a { color: #000; }
}

.key-points { border: 2px solid var(--green); border-left-width: 6px; background: var(--ok-bg); }
.key-points li { font-weight: 700; }
.sp-key { border: 1pt solid #000; padding: 2pt 4pt; }
@media print { .key-points { break-inside: avoid; } }

.disclaimer { background: var(--amber-bg); border-left: 6px solid var(--amber-bar); color: #3b2a00; }
@media print { .disclaimer { display: block !important; } }

/* Krótki PDF */
.pdf-panel { background: var(--card); border: 2px solid var(--green); border-radius: var(--radius-l); padding: 1rem 1.2rem 1.2rem; margin: 0 0 2rem; }
.pdf-panel p { margin: 0 0 .7rem; }
.pdf-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.pdf-actions .btn { flex: 1; min-width: 9rem; }
.pdf-frame { width: 100%; height: 80vh; margin-top: 1rem; border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff; }
@media print { .pdf-panel, #err-pdf { display: none !important; } }

/* Krótki wydruk — jedna kartka */
.short-print { display: none; }
.short-print.measure {
  display: block; position: absolute; left: -10000px; top: 0;
  width: calc(210mm - 20mm); font-size: 8.5pt; background: #fff;
}
.short-print { font-size: 8.5pt; line-height: 1.3; color: #000; }
.sp-head { display: flex; justify-content: space-between; gap: 1em; border-bottom: 1.5pt solid #000; padding-bottom: 2pt; margin-bottom: 3pt; font-size: 10.5pt; }
.sp-pat { margin: 0 0 4pt; }
.sp-sec { margin: 0 0 4pt; break-inside: avoid-page; }
.sp-sec h3 { font-size: 9pt; margin: 0 0 1pt; text-transform: uppercase; letter-spacing: .03em; border-bottom: .5pt solid #888; }
.sp-sec p { margin: 0 0 1.5pt; }
.sp-urgent { border: 1pt solid #000; padding: 2pt 4pt; }
.sp-foot { margin: 5pt 0 0; font-size: 7pt; font-style: italic; border-top: .5pt solid #888; padding-top: 2pt; }

@media print {
  html.print-short body > *:not(.short-print) { display: none !important; }
  html.print-short .short-print { display: block !important; }
}
@page { size: A4; margin: 10mm; }

/* Konto użytkownika */
.auth-pending main, .auth-pending .userbar { visibility: hidden; }
.userbar { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; margin-top: .9rem; font-size: .9rem; }
.userbar a, .userbar button { color: #fff; font: inherit; background: none; border: none; padding: .2rem 0; text-decoration: underline; cursor: pointer; min-height: 2rem; }
.pw-dialog { border: none; border-radius: var(--radius-l); padding: 1.3rem; width: min(26rem, calc(100vw - 2rem)); }
.pw-dialog::backdrop { background: rgba(0,0,0,.45); }
.pw-dialog h2 { margin-top: 0; }
.dialog-actions { display: flex; gap: .6rem; margin-top: 1.2rem; }
.dialog-actions .btn { flex: 1; }
@media print { .userbar, .pw-dialog, #saved-note { display: none !important; } }
.login-box { max-width: 26rem; margin: 2rem auto; }
.login-hint { margin: 1rem 0 0; font-size: .9rem; }

/* Panel administratora */
.wrap.wide { max-width: 76rem; }
.admin { font-size: .9rem; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .6rem 1rem; align-items: end; }
.filters label { margin-top: 0; }
.filters .quick { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { font: inherit; font-size: .85rem; padding: .35rem .8rem; border-radius: 2rem; border: 2px solid var(--line); background: #fff; cursor: pointer; min-height: 2.3rem; }
.chip:hover { border-color: var(--green); background: var(--ok-bg); }
input[type="date"] { width: 100%; font: inherit; border: 2px solid var(--line); border-radius: var(--radius-s); padding: .5rem .6rem; min-height: 2.8rem; background: #fff; }
.exports { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.2rem 0 .6rem; }
.exports .btn { flex: 1; min-width: 14rem; }
.small { font-size: .85rem; }
.rev-count { font-weight: 700; margin: 1rem 0 .4rem; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius-s); }
table.data { border-collapse: collapse; width: 100%; font-size: .85rem; }
table.data th, table.data td { padding: .45rem .55rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { background: var(--paper); position: sticky; top: 0; white-space: nowrap; }
table.data td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data td.sum { min-width: 18rem; }
table.data tr.inactive td { color: var(--ink-soft); }
table.data a { color: var(--focus); white-space: nowrap; }
.actions { white-space: nowrap; }
.link-btn { font: inherit; background: none; border: none; color: var(--focus); text-decoration: underline; cursor: pointer; padding: .2rem .3rem; }
.add-user { background: var(--paper); border-radius: var(--radius-s); padding: 1rem; margin-bottom: 1.2rem; }
.add-user h3 { margin: 0 0 .3rem; font-size: 1.05rem; }
.grid-add { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 1rem; }
.pass-row { display: flex; gap: .4rem; }
.pass-row .btn { min-height: 2.8rem; padding: .4rem .8rem; }
.check-inline { display: flex !important; gap: .5rem; align-items: center; font-weight: 400 !important; margin: .9rem 0 !important; }
.check-inline input { width: 1.3rem; height: 1.3rem; accent-color: var(--green); }
.credentials { margin-top: 1rem; padding: .9rem 1rem; border: 2px solid var(--green); background: var(--ok-bg); border-radius: var(--radius-s); }
.credentials pre { background: #fff; padding: .6rem .8rem; border-radius: var(--radius-s); font-size: .95rem; white-space: pre-wrap; margin: .5rem 0; }

/* Edytor przycinania i zamazywania */
.redact {
  width: 100vw; max-width: 60rem; height: 100dvh; max-height: 100dvh; margin: 0 auto; padding: .8rem 1rem 1rem;
  border: none; overflow-y: auto; background: var(--paper); color: var(--ink);
}
.redact::backdrop { background: rgba(0,0,0,.6); }
.rd-status { font-weight: 700; padding: 2rem 0; text-align: center; }
.rd-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; position: sticky; top: -.8rem; background: var(--paper); padding: .4rem 0; z-index: 2; }
.rd-head h2 { margin: 0; font-size: 1.2rem; }
.rd-close { font: inherit; background: none; border: none; color: var(--red-ink); text-decoration: underline; cursor: pointer; min-height: 2.6rem; }
.rd-hint { margin: .4rem 0 .6rem; font-size: .9rem; color: var(--ink-soft); }
.rd-guide { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-s); padding: .5rem .8rem; margin: .3rem 0; font-size: .85rem; }
.rd-guide summary { font-weight: 700; cursor: pointer; min-height: 2rem; }
.rd-guide-cols { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem 1.2rem; margin-top: .3rem; }
@media (max-width: 600px) { .rd-guide-cols { grid-template-columns: 1fr; } }
.rd-guide ul { margin: .2rem 0 0; padding-left: 1.1rem; }
.rd-keep strong { color: var(--green); }
.rd-cut strong { color: var(--red-ink); }
.rd-tools { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.rd-tool, .rd-btn {
  font: inherit; font-size: .9rem; font-weight: 700; min-height: 2.6rem; padding: .3rem .8rem; cursor: pointer;
  border-radius: var(--radius-s); border: 2px solid var(--line); background: #fff; color: var(--ink);
}
.rd-tool.keep[aria-pressed="true"] { border-color: #1f9d55; background: #1f9d55; color: #fff; }
.rd-tool.mask[aria-pressed="true"] { border-color: #000; background: #000; color: #fff; }
.rd-stage { background: #444; border-radius: var(--radius-s); padding: .4rem; }
.rd-canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; border-radius: 4px; }
.rd-nav { display: flex; gap: .6rem; margin-top: .8rem; position: sticky; bottom: -1rem; background: var(--paper); padding: .5rem 0; }
.rd-nav .btn { flex: 1; }
.rd-review { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .8rem; }
.rd-review figure { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-s); padding: .4rem; }
.rd-review img { width: 100%; display: block; border: 1px solid #ddd; }
.rd-review figcaption { font-size: .8rem; color: var(--ink-soft); margin-top: .3rem; word-break: break-word; }
.rd-checks { border: 2px solid var(--amber-bar); background: var(--amber-bg); border-radius: var(--radius-s); margin: 1rem 0 0; padding: .6rem .9rem; }
.rd-checks legend { font-weight: 700; padding: 0 .3rem; }
.rd-checks label { display: flex; gap: .6rem; align-items: flex-start; margin: .5rem 0; font-weight: 400; cursor: pointer; }
.rd-checks input { width: 1.4rem; height: 1.4rem; flex-shrink: 0; accent-color: var(--green); margin-top: .1rem; }

/* Panel: badanie */
.study-imports { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.study-imports > div { background: var(--paper); border-radius: var(--radius-s); padding: .8rem 1rem; }
.study-imports h3, #study > h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
.study-imports h3 { margin-top: 0; }
#st-err, #st-msg { white-space: pre-line; }
#study select { font: inherit; font-size: .85rem; padding: .3rem; border: 2px solid var(--line); border-radius: var(--radius-s); max-width: 18rem; }

.rec-dialog { width: min(52rem, calc(100vw - 2rem)); max-height: 90vh; overflow-y: auto; }
.rec-list { padding-left: 1.1rem; }
.rec-list li { margin: .45rem 0; }
#val-err, #val-msg { white-space: pre-line; }
#validation select { font: inherit; }
.rate-list li { margin: .8rem 0; }
.rate-row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .4rem; }
.rate-row input[type="text"] { flex: 1; min-width: 12rem; min-height: 2.3rem; padding: .3rem .5rem; }
.chip[aria-pressed="true"] { border-color: var(--green); background: var(--green); color: #fff; }
#pn-err, #pn-msg { white-space: pre-line; }
.case-list { list-style: none; padding: 0; margin: 0; }
.case-list li { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.final-table input, .final-table select { min-height: 2.3rem; padding: .3rem .5rem; font-size: .9rem; }

.survey-q { border: 1px solid var(--line); border-radius: var(--radius-s); padding: .7rem 1rem; margin: 0 0 .9rem; }
.survey-q legend { font-weight: 700; padding: 0 .3rem; }
.survey-opt { display: flex !important; gap: .5rem; align-items: center; font-weight: 400 !important; margin: .35rem 0 !important; }
.survey-opt input { width: 1.3rem; height: 1.3rem; accent-color: var(--green); }
.likert { display: grid; gap: .1rem; }
#survey-err { white-space: pre-line; }

@media print { .brand, .study-bar { display: none; } }

/* Planowany lek — reguły (instancja badawcza) */
.study-bar-link { color: inherit; font-weight: 700; text-decoration: underline; margin-left: .4rem; }
.rr-banner { margin: 1.2rem 0; padding: .9rem 1.1rem; background: #fff3cf; border: 2px solid #8a5d00; border-radius: var(--radius-s); color: #3b2a00; }
.rr-banner p { margin: .2rem 0; }
.rr-result-banner { background: #fff3cf; border-left: 6px solid #8a5d00; padding: .5rem .8rem; color: #3b2a00; font-weight: 700; }
.rr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0 1rem; }
#rr-form fieldset { border: 1px solid var(--line); border-radius: var(--radius-s); margin: 1rem 0; padding: .5rem .9rem .8rem; }
#rr-form legend, #dec-form legend { font-weight: 700; padding: 0 .3rem; }
.rr-inline { display: flex; flex-wrap: wrap; gap: .2rem 1.2rem; }
.rr-choice { display: inline-flex; align-items: center; gap: .5rem; min-height: 2.6rem; cursor: pointer; font-weight: 400; margin: 0; }
.rr-choice input { width: 1.3rem; height: 1.3rem; accent-color: var(--green); }
.rr-excl-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .3rem 1rem; padding: .3rem 0; border-bottom: 1px solid var(--line); }
.rr-excl-row:last-child { border-bottom: none; }
.rr-excl-opts { display: inline-flex; gap: 1.2rem; }
.rr-bar { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.2rem; border-radius: var(--radius-l); border: 2px solid; font-size: 1.2rem; margin: .8rem 0; }
.rr-icon { flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 1.3rem; }
.rr-ok { background: #e3f3e6; border-color: #2d7a3e; color: #123d1c; } .rr-ok .rr-icon { background: #2d7a3e; }
.rr-warn { background: #fff3cf; border-color: #b27a00; color: #3b2a00; } .rr-warn .rr-icon { background: #8a5d00; }
.rr-bad { background: var(--red-bg); border-color: var(--red-bar); color: #4a0f0a; } .rr-bad .rr-icon { background: #b3261e; }

/* Bezpieczniejsze opcje (instancja badawcza) */
.bo-meta { overflow-wrap: anywhere; }
#wynik .rr-bar strong, .bo-drug summary, .bo-cite { overflow-wrap: anywhere; hyphens: auto; }
@media (max-width: 40rem) { #wynik .rr-bar { font-size: 1.02rem; padding: .8rem .9rem; gap: .7rem; } }
.bo-none { background: #eef1f0; border-color: #5b6762; color: #16201c; } .bo-none .rr-icon { background: #5b6762; }
.bo-addmed { display: flex; gap: .7rem; align-items: flex-end; flex-wrap: wrap; } .bo-addmed > div { flex: 1 1 14rem; } .bo-addmed .btn { min-height: 2.8rem; }
.bo-meds { list-style: none; padding: 0; margin: .6rem 0; }
.bo-meds li { display: flex; flex-wrap: wrap; gap: .2rem .8rem; align-items: center; padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
.bo-med-status { font-size: .9rem; color: var(--ink-soft); flex: 1 1 12rem; }
.bo-med-unknown { background: var(--amber-bg); border-radius: var(--radius-s); } .bo-med-unknown .bo-med-status { color: var(--amber-ink); font-weight: 700; }
#nasilenie .rr-choice { display: flex; flex-wrap: wrap; align-items: baseline; margin: .3rem 0; }
.bo-def { flex-basis: 100%; margin-left: 1.8rem; color: var(--ink-soft); font-size: .9rem; }
.bo-group { margin: 1rem 0 1.4rem; }
.bo-drug { border: 1px solid var(--line); border-radius: var(--radius-s); padding: .6rem .9rem; margin: .5rem 0; background: var(--card); }
.bo-drug summary { cursor: pointer; min-height: 2.2rem; display: flex; align-items: center; flex-wrap: wrap; gap: .3rem; }
.bo-drug ul { margin: .2rem 0 .6rem; padding-left: 1.2rem; }
.bo-note, .bo-sub { color: var(--ink-soft); } .bo-sub { margin: .5rem 0 .1rem; font-weight: 700; }
.bo-src { border-top: 1px dashed var(--line); margin-top: .6rem; padding-top: .4rem; }
.bo-quote { margin: .4rem 0; padding: .4rem .8rem; border-left: 4px solid var(--brand-accent); background: var(--paper); font-style: italic; }
.bo-cite { font-size: .9rem; margin: .1rem 0 .5rem; }
.bo-consult { font-weight: 700; color: var(--red-ink); }
.bo-drug-flat { display: block; }
.bo-pos { font-weight: 700; min-width: 1.6rem; }
.bo-first { background: var(--brand); color: #fff; font-size: .8rem; font-weight: 700; border-radius: 1rem; padding: .1rem .6rem; margin-left: .3rem; }
.bo-cmp { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--ink-soft); margin-right: .4rem; cursor: pointer; }
.bo-cmp input { width: 1.1rem; height: 1.1rem; accent-color: var(--green); }
.bo-dose { border-top: 1px dashed var(--line); margin-top: .6rem; padding-top: .4rem; }
.bo-dose-none { color: var(--ink-soft); font-style: italic; }
.bo-dose-real { border-left: 4px solid var(--brand-accent); padding-left: .7rem; }
#bo-porownanie td, #bo-porownanie th { vertical-align: top; min-width: 9rem; }
.bo-dose-note { font-size: .85rem; color: var(--ink-soft); font-style: italic; margin: .3rem 0 0; }
.bo-cmp-stack { display: none; }
.bo-cmp-card { border: 1px solid var(--line); border-radius: var(--radius-s); padding: .6rem .8rem; margin: .5rem 0; background: var(--card); }
.bo-cmp-card h4 { margin: 0 0 .4rem; }
@media (max-width: 40rem) { .bo-cmp-table { display: none; } .bo-cmp-stack { display: block; } }
.bo-reason { color: var(--ink); }
.bo-testsrc { border: 2px dashed #8a5d00; background: #fffaf0; border-radius: var(--radius-s); padding: .4rem .7rem; margin: .4rem 0; font-style: normal; }
.bo-testsrc p { margin: .2rem 0; }
.bo-testsrc-tag { font-weight: 700; color: #6b4a00; font-size: .85rem; letter-spacing: .02em; }
.bo-safety { border: 2px solid var(--red-bar); background: var(--red-bg); }
.bo-status { font-size: .85rem; color: var(--ink-soft); font-style: italic; }
.bo-dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; }
.bo-dl dt { font-weight: 700; } .bo-dl dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 40rem) { .bo-dl { grid-template-columns: 1fr; } .bo-dl dd { margin-bottom: .4rem; } }
.bo-dialog { border: 2px solid var(--ink); border-radius: var(--radius-l); padding: 1.2rem 1.4rem; max-width: min(32rem, calc(100vw - 2rem)); }
.bo-dialog::backdrop { background: rgba(0,0,0,.45); }
.bo-dialog h2 { margin-top: 0; }
.bo-dialog-btns { display: flex; gap: .8rem; justify-content: flex-end; flex-wrap: wrap; }
@media print { .bo-dialog, #btn-do-decyzji, #btn-nowy { display: none !important; } .bo-drug { break-inside: avoid; } }

#planned-panel .pass-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
#planned-panel .pass-row select { width: auto; min-width: 12rem; }
#planned-panel .pass-row label { margin: 0; }

/* Dane do doktoratu: dawka, potwierdzanie ostrzeżeń */
.bd-dose { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .3rem 1rem; margin: .6rem 0; }
.bd-sub { font-weight: 700; margin: .8rem 0 .3rem; }
.bd-ack-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .2rem 1rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.bd-ack-text { flex: 1 1 18rem; }
.bd-ack-opts { display: inline-flex; flex-wrap: wrap; gap: .2rem 1rem; }
.bd-card h3 { margin-top: 0; }
.bd-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem 1rem; margin: .5rem 0; }
.bd-row label { flex-basis: 100%; }
.bd-row input { width: auto; }
.bd-follow { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .3rem 1rem; align-items: end; margin-top: .6rem; }
.bd-follow .bd-sub, .bd-follow .btn { grid-column: 1 / -1; justify-self: start; }
.bd-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }

/* Instancja badawcza w internecie: stały baner (wstawiany przez serwer w każdą stronę) */
.pilot-banner { position: sticky; top: 0; z-index: 50; margin: 0; padding: .55rem 1rem; background: #7a1010; color: #fff; font-weight: 700; text-align: center; line-height: 1.35; }
@media print { .pilot-banner { position: static; background: none; color: #000; border: 2px solid #000; } }

/* 0.8.1: menu modułów na stronie głównej instancji badawczej (administrator) */
.bd-start { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0; }
.rr-step { margin: 1.6rem 0 .6rem; display: flex; align-items: center; gap: .5rem; }

/* 0.8.1: odczyt dokumentu w karcie badawczej — dane osobowe, źródła pól, lista leków po odczycie */
.bd-pii { background: #fde8e8; border-color: #9b1c1c; color: #5c0f0f; font-weight: 700; }
.bd-src { margin: .8rem 0; padding: .8rem 1rem; border: 2px solid var(--line); border-radius: var(--radius-s); }
.bd-src-row { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.bd-src-status { font-weight: 700; }
.bd-src-status.ok { color: #1e6b3a; }
.bd-src-status.edit { color: #8a5d00; }
.bo-meds li input.rr-med-input { flex: 1 1 14rem; min-width: 10rem; }
.bo-med-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem 1rem; }
.bo-med-add > div { flex: 1 1 16rem; }
.thumbs li.bd-reczny { display: flex; flex-direction: column; align-items: flex-start; max-width: 14rem; }
.bd-reczny-info { font-size: .85rem; color: #8a5d00; margin: .3rem 0 0; }
.bd-reczny-potw { font-weight: 700; }

/* Lista leków niekompletna (leki nierozpoznane albo brak listy): zastrzeżenie przy wyniku */
.bd-incomplete { background: #fff3cf; border-color: #8a5d00; }
.bd-incomplete p:first-child { font-weight: 700; }
.rr-incomplete-note { font-weight: 700; color: #8a5d00; }

/* Karta badawcza w układzie aplikacji klinicznej: planowany lek w kroku 3, wiersze listy leków */
.planned { margin-top: 2rem; padding-top: 1.2rem; border-top: 2px solid var(--line); }
.planned-title { font-size: 1.2rem; margin: 1.4rem 0 .5rem; }
.rr-med-body { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; min-width: 0; }
.rr-med-body .rr-med-input { flex: 1 1 14rem; }


/* Odczyt dokumentów w badaniu: komunikat „tylko dokumenty fikcyjne” nad przyciskami zdjęć */
.bd-test-only { font-weight: 400; }
.bd-test-only strong { display: block; margin-bottom: .2rem; }
