/* Lekarz: motyw probówek laboratoryjnych. Kolor grupy = kolor korka probówki dla danego badania. */
@font-face { font-family: "Atkinson Next"; src: url("fonts/atkinson-next-latin-ext.woff2") format("woff2"); font-weight: 200 800; font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Atkinson Next"; src: url("fonts/atkinson-next-latin.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  --paper: #f3f6f8;        /* chłodna biel laboratorium */
  --sheet: #ffffff;
  --ink: #18304a;          /* granat atramentu wydruku */
  --ink-soft: #4d6277;
  --rule: #d5dee6;
  --alarm: #a4161a;        /* tylko czerwone flagi */
  --alarm-bg: #fdecec;
  --amber: #7a4d00;
  --amber-bg: #fff3d6;
  --ok: #2d6a5f;
  --focus: #1f6feb;
  --tube-grey: #8b939b;    /* fluorek: glukoza */
  --tube-lavender: #8a76c4;/* EDTA: morfologia */
  --tube-gold: #c79a1e;    /* żel: biochemia */
  --tube-blue: #5f9fd6;    /* cytrynian: krzepnięcie */
  --radius-s: 4px;
  --radius-l: 14px;
  --measure: 72ch;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 1.0625rem/1.55 "Atkinson Next", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 4.5vw, 3rem); font-weight: 800; max-width: 20ch; }
h2 { font-size: 1.5rem; font-weight: 800; }
h3 { font-size: 1.125rem; font-weight: 600; }
p { margin: 0 0 .6em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 1rem; top: 1rem; background: var(--sheet); padding: .5rem 1rem; z-index: 10; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem clamp(1rem, 4vw, 3rem); border-bottom: 1px solid var(--rule); background: var(--sheet); }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.25rem; text-decoration: none; }
.brand-mark { width: 16px; height: 28px; } .brand-mark .cap { fill: var(--tube-lavender); } .brand-mark .tube { fill: none; stroke: var(--ink); stroke-width: 1.5; } .brand-mark .fill { fill: #b3262b; }
.local-note { margin: 0; color: var(--ink-soft); font-size: .9rem; }
.page { max-width: 1080px; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 3rem) 4rem; }
.footer { max-width: 1080px; margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 3rem) 3rem; color: var(--ink-soft); font-size: .9rem; border-top: 1px solid var(--rule); }

.intro { margin-bottom: 2rem; }
.lede { font-size: 1.2rem; color: var(--ink-soft); max-width: var(--measure); }
.crumbs { color: var(--ink-soft); font-size: .95rem; }
.hint, .privacy, .opt, .muted, .why, .ref-src { color: var(--ink-soft); }
.opt { font-size: .85rem; font-weight: 400; display: block; }
.privacy { font-size: .95rem; max-width: var(--measure); margin-top: .75rem; }

.notice { background: var(--sheet); border-left: 4px solid var(--ink-soft); padding: .8rem 1rem; border-radius: var(--radius-s); max-width: var(--measure); }
.notice-error { border-color: var(--alarm); background: var(--alarm-bg); }
.notice-warn { border-color: var(--amber); background: var(--amber-bg); }
.notice ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* Formularz startowy: dwa kroki, faktyczna sekwencja */
.upload { display: grid; gap: 1.5rem; }
.step { border: 1px solid var(--rule); border-radius: var(--radius-l); background: var(--sheet); padding: 1.5rem; margin: 0; }
.step legend { font-weight: 800; font-size: 1.25rem; padding: 0 .4rem; display: flex; align-items: center; gap: .6rem; }
.step-no { display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--ink); color: var(--sheet); font-size: 1rem; }
.dropzone { display: grid; gap: .3rem; padding: 2rem 1.5rem; border: 2px dashed var(--rule); border-radius: var(--radius-l); cursor: pointer; text-align: left; background: linear-gradient(var(--sheet), var(--sheet)) padding-box; }
.dropzone:hover, .dropzone.is-over { border-color: var(--ink); }
.dropzone input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.dropzone-title { font-weight: 600; font-size: 1.15rem; }
.dropzone-hint { color: var(--ink-soft); font-size: .95rem; }
.file-list { list-style: none; padding: 0; margin: .5rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.file-list li { background: var(--paper); border: 1px solid var(--rule); border-radius: 999px; padding: .2rem .8rem; font-size: .9rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.2rem 1.5rem; align-items: end; }
.field { display: grid; gap: .3rem; font-weight: 600; }
.field input, .field select, .field textarea, .review-table input { font: inherit; color: inherit; border: 1px solid #b9c6d2; border-radius: var(--radius-s); padding: .55rem .7rem; background: var(--sheet); width: 100%; }
.check { display: flex; gap: .6rem; align-items: center; }
.check input { width: 1.2rem; height: 1.2rem; accent-color: var(--ink); }
.submit-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; margin-top: 1rem; }
.btn { font: inherit; font-weight: 600; border: 1px solid var(--ink); background: var(--sheet); color: var(--ink); border-radius: 999px; padding: .65rem 1.3rem; cursor: pointer; text-decoration: none; display: inline-block; }
.btn-primary { background: var(--ink); color: var(--sheet); }
.btn-primary:hover { background: #0f2236; }
.btn-quiet { border-color: transparent; color: var(--ink-soft); }
.btn-icon { border: 0; background: none; font-size: 1rem; cursor: pointer; color: var(--ink-soft); padding: .4rem; }

.history { margin-top: 3rem; }
.history-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
.history-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.history-meta { color: var(--ink-soft); display: flex; gap: .6rem; align-items: center; }
.tag { border-radius: 999px; padding: .05rem .6rem; font-size: .85rem; }
.tag-critical { background: var(--alarm); color: #fff; }
.empty { color: var(--ink-soft); }

/* Weryfikacja */
.table-wrap { overflow-x: auto; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-l); }
.review-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.review-table th { text-align: left; font-size: .9rem; color: var(--ink-soft); font-weight: 600; padding: .8rem .6rem; border-bottom: 1px solid var(--rule); }
.review-table td { padding: .4rem .6rem; border-bottom: 1px solid var(--rule); }
.row-unknown td { background: var(--amber-bg); }
.unknown-note { display: block; font-size: .8rem; color: var(--amber); margin-top: .2rem; }
.review-table input.num { text-align: right; max-width: 8rem; }
.review-table input.unit { max-width: 8rem; }
.review-table input.date { max-width: 9rem; }

/* Postęp */
.steps { list-style: none; padding: 0; margin: 1.5rem 0; display: grid; gap: .7rem; max-width: 34rem; }
.steps li { display: flex; align-items: center; gap: .8rem; font-size: 1.1rem; }
.step-mark { width: 1.2rem; height: 1.2rem; border-radius: 50%; border: 2px solid var(--rule); flex: none; }
.step-running .step-mark { border-color: var(--ink); border-top-color: transparent; animation: spin 0.9s linear infinite; }
.step-done .step-mark { background: var(--ok); border-color: var(--ok); }
.step-error .step-mark { background: var(--amber); border-color: var(--amber); }
.spinner { width: 2rem; height: 2rem; border: 3px solid var(--rule); border-top-color: var(--ink); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Wynik */
.alarm { position: sticky; top: 0; z-index: 5; background: var(--alarm); color: #fff; border-radius: var(--radius-l); padding: 1.2rem 1.5rem; margin-bottom: 2rem; box-shadow: 0 6px 24px rgba(164, 22, 26, .25); }
.alarm h2 { font-size: 1.25rem; margin-bottom: .6rem; }
.alarm-item + .alarm-item { border-top: 1px solid rgba(255,255,255,.35); margin-top: .8rem; padding-top: .8rem; }
.alarm-value { font-weight: 800; font-size: 1.15rem; }
.alarm a, .alarm .source { color: #fff; font-size: .9rem; }
.summary { display: flex; flex-wrap: wrap; gap: 0; margin: 1.5rem 0 1rem; border: 1px solid var(--rule); border-radius: var(--radius-l); background: var(--sheet); }
.summary > div { padding: 1rem 1.4rem; border-right: 1px solid var(--rule); min-width: 9rem; }
.summary > div:last-child { border-right: 0; }
.summary .wide { flex: 1 1 18rem; }
.summary dt { color: var(--ink-soft); font-size: .9rem; }
.summary dd { margin: .1rem 0 0; font-size: 2rem; font-weight: 800; line-height: 1.1; }
.summary dd.dd-text { font-size: 1.1rem; font-weight: 600; line-height: 1.3; }
.summary dd.is-critical { color: var(--alarm); }
.profile-line { color: var(--ink-soft); }
.warnings, .todo, .results, .glucose, .tests, .opinions, .meta { margin-top: 2.5rem; }
.warnings ul { margin: 0; padding: 0; list-style: none; display: grid; gap: .5rem; max-width: var(--measure); }
.warnings li { background: var(--amber-bg); border-left: 4px solid var(--amber); padding: .7rem 1rem; border-radius: var(--radius-s); }
.todo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
.consults, .actions { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; }
.consult { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-l); padding: 1rem 1.2rem; }
.consult-pilna { border-color: var(--alarm); border-width: 2px; }
.consult-head { font-weight: 600; font-size: 1.1rem; }
.urgency { display: inline-block; font-size: .85rem; font-weight: 600; border-radius: 999px; padding: .05rem .6rem; margin-right: .3rem; background: var(--paper); }
.consult-pilna .urgency { background: var(--alarm); color: #fff; }
.origin { font-size: .8rem; color: var(--ink-soft); border: 1px solid var(--rule); border-radius: 999px; padding: 0 .5rem; }
.find { font-size: .95rem; }
.actions li { background: var(--sheet); border-left: 4px solid var(--ink); padding: .7rem 1rem; border-radius: var(--radius-s); }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .9rem; }

.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-l); margin-top: 1rem; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.2rem .9rem 1rem; border-bottom: 1px solid var(--rule); }
.panel-head h3 { margin: 0; display: flex; align-items: center; gap: .6rem; }
.panel-head h3::before { content: ""; width: .7rem; height: 1.4rem; border-radius: 3px 3px 6px 6px; background: var(--tube, var(--rule)); }
.tube-grey { --tube: var(--tube-grey); } .tube-lavender { --tube: var(--tube-lavender); } .tube-gold { --tube: var(--tube-gold); } .tube-blue { --tube: var(--tube-blue); }
.panel-count { font-size: .9rem; color: var(--ink-soft); }
.row { padding: .9rem 1.2rem; border-bottom: 1px solid var(--rule); }
.row:last-child { border-bottom: 0; }
.row-main { display: grid; grid-template-columns: minmax(10rem, 1.3fr) minmax(7rem, .8fr) minmax(8rem, .9fr) minmax(12rem, 1.6fr); gap: .3rem 1rem; align-items: center; }
.row-main p { margin: 0; }
.row-name { font-weight: 600; }
.row-value .num { font-size: 1.35rem; font-weight: 800; }
.row-value .unit { color: var(--ink-soft); font-size: .9rem; }
.st { white-space: nowrap; }
.st-normal { color: var(--ok); } .st-high, .st-low { color: var(--amber); } .st-critical { color: var(--alarm); font-weight: 800; } .st-unknown { color: var(--ink-soft); }
.row-critical { background: var(--alarm-bg); }
.row-ref { font-size: .9rem; color: var(--ink-soft); }

/* Linijka wyniku: jedyny wyrazisty element strony */
.ruler { position: relative; height: 14px; background: repeating-linear-gradient(90deg, var(--rule) 0 1px, transparent 1px 10%); border-bottom: 2px solid var(--rule); margin-bottom: .25rem; }
.ruler-band { position: absolute; top: 3px; bottom: 0; left: var(--a, 0%); width: calc(var(--b, 0%) - var(--a, 0%)); background: color-mix(in srgb, var(--ok) 28%, transparent); border-left: 2px solid var(--ok); border-right: 2px solid var(--ok); }
.ruler-mark { position: absolute; bottom: -6px; left: var(--x, 0%); width: 4px; height: 22px; margin-left: -2px; background: var(--ink); border-radius: 2px; }
.row-high .ruler-mark, .row-low .ruler-mark { background: var(--amber); }
.row-critical .ruler-mark { background: var(--alarm); width: 6px; margin-left: -3px; }
.row-comments { margin-top: .6rem; max-width: var(--measure); }
.row-comments summary { cursor: pointer; color: var(--ink-soft); font-size: .95rem; }
.row-comments p { margin: .4rem 0 0; }
.who { font-weight: 600; }

.glucose { background: var(--sheet); border: 1px solid var(--rule); border-left: 8px solid var(--tube-grey); border-radius: var(--radius-l); padding: 1.4rem 1.6rem; }
.glucose-class { font-size: 1.3rem; font-weight: 800; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--ink); display: grid; gap: 1.1rem; }
.timeline li { padding-left: 1.2rem; position: relative; max-width: var(--measure); }
.timeline li::before { content: ""; position: absolute; left: -7px; top: .45rem; width: 12px; height: 12px; border-radius: 50%; background: var(--sheet); border: 2px solid var(--ink); }
.timeline .when { font-weight: 600; color: var(--ink-soft); margin: 0; }
.timeline .what { font-weight: 800; font-size: 1.1rem; margin: 0; }
.tabs [role="tablist"] { display: flex; gap: .5rem; border-bottom: 1px solid var(--rule); margin-bottom: 1rem; }
.tabs [role="tab"] { font: inherit; font-weight: 600; background: none; border: 0; border-bottom: 3px solid transparent; padding: .6rem .4rem; cursor: pointer; color: var(--ink-soft); }
.tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-color: var(--ink); }
.tabs [role="tabpanel"] { max-width: var(--measure); }
.confidence { color: var(--ink-soft); }
.sources { padding-left: 1.2rem; word-break: break-all; }
.actions-row { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; margin-top: 1rem; }
.actions-row form { margin: 0; }
.plain { padding-left: 1.2rem; }

@media (max-width: 720px) {
  .row-main { grid-template-columns: 1fr auto; }
  .row-ruler { grid-column: 1 / -1; }
  .summary > div { border-right: 0; border-bottom: 1px solid var(--rule); flex: 1 1 45%; }
  .alarm { position: static; }
}
@media (prefers-reduced-motion: reduce) { .spinner, .step-running .step-mark { animation: none; } }
@media print {
  body { background: #fff; font-size: 11pt; }
  .topbar .local-note, .actions-row, .skip, .btn { display: none; }
  .alarm { position: static; box-shadow: none; }
  .panel, .glucose, .consult { break-inside: avoid; }
  details { display: block; } details > * { display: block; }
}

.logout { display: flex; gap: .6rem; align-items: center; margin: 0; }
.login-form { display: grid; gap: 1rem; max-width: 24rem; margin-top: 1.5rem; }
