/* ═══════════════ EMS – System dokumentacji medycznej ═══════════════ */

:root {
  --bg: #f2f5f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f7;
  --border: #e1e7ef;
  --border-strong: #c9d3df;
  --text: #0f1b2d;
  --text-2: #3d4b5f;
  --muted: #66758a;
  --brand: #1d4fa3;
  --brand-hover: #173f84;
  --brand-soft: #e9f0fc;
  --brand-ink: #ffffff;
  --navy: #0c1a33;
  --navy-2: #142748;
  --navy-text: #c9d5e8;
  --red: #c41d3a;
  --red-soft: #fdecef;
  --green: #12804a;
  --green-soft: #e6f6ee;
  --amber: #a85b05;
  --amber-soft: #fff5e3;
  --focus: 0 0 0 3px rgba(29, 79, 163, 0.28);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, 0.06);
  --shadow: 0 1px 2px rgba(15, 27, 45, 0.05), 0 6px 20px rgba(15, 27, 45, 0.06);
  --shadow-lg: 0 24px 60px rgba(8, 18, 36, 0.3);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sidebar-w: 264px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220;
    --surface: #121b2c;
    --surface-2: #162134;
    --surface-3: #1b2840;
    --border: #23324b;
    --border-strong: #31435f;
    --text: #e6edf7;
    --text-2: #b9c6d8;
    --muted: #8a9ab0;
    --brand: #4f86e6;
    --brand-hover: #6a9af0;
    --brand-soft: #172a4b;
    --brand-ink: #071226;
    --navy: #080f1c;
    --navy-2: #101b30;
    --red: #f0566f;
    --red-soft: #3a1620;
    --green: #3ccf87;
    --green-soft: #10301f;
    --amber: #f0aa4c;
    --amber-soft: #33240e;
    --focus: 0 0 0 3px rgba(79, 134, 230, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #121b2c;
  --surface-2: #162134;
  --surface-3: #1b2840;
  --border: #23324b;
  --border-strong: #31435f;
  --text: #e6edf7;
  --text-2: #b9c6d8;
  --muted: #8a9ab0;
  --brand: #4f86e6;
  --brand-hover: #6a9af0;
  --brand-soft: #172a4b;
  --brand-ink: #071226;
  --navy: #080f1c;
  --navy-2: #101b30;
  --red: #f0566f;
  --red-soft: #3a1620;
  --green: #3ccf87;
  --green-soft: #10301f;
  --amber: #f0aa4c;
  --amber-soft: #33240e;
  --focus: 0 0 0 3px rgba(79, 134, 230, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.4em; letter-spacing: -0.01em; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 0.75em; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.strong { font-weight: 600; }
.mono { font-family: var(--mono); letter-spacing: 0.01em; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.pre { white-space: pre-wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; }

.boot, .noscript {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: var(--muted); text-align: center; padding: 16px;
}
.boot .icon { width: 40px; height: 40px; color: var(--red); }

/* ─────────── Przyciski ─────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--surface-3); color: var(--text);
  font: inherit; font-weight: 600; font-size: 0.92rem; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:hover { text-decoration: none; background: var(--border); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); border-color: var(--brand); color: var(--brand); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-ghost-danger { color: var(--red); }
.btn-ghost-danger:hover { background: var(--red-soft); color: var(--red); }
.btn-light { background: rgba(255, 255, 255, 0.12); color: #fff; border-color: rgba(255, 255, 255, 0.35); }
.btn-light:hover { background: rgba(255, 255, 255, 0.22); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #a3162f; }
.btn-danger-outline { background: transparent; color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.btn-danger-outline:hover { background: var(--red-soft); }
.btn-sm { min-height: 32px; padding: 5px 11px; font-size: 0.85rem; }
.btn-lg { min-height: 46px; padding: 11px 22px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm); border: 0;
  background: transparent; color: var(--text-2); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--focus); }
.icon-btn-light { color: var(--navy-text); }
.icon-btn-light:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* ─────────── Karty, nagłówki ─────────── */

/* Logo EMS (kwadratowy znak z tłem) – zaokrąglone rogi jak ikona aplikacji. */
img.logo { border-radius: 22%; flex: none; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
}
.card-flush { padding: 0; overflow: hidden; }
.card-title { font-size: 1.05rem; display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.card-subtitle { font-size: 0.95rem; margin-top: 18px; }
.card-warn { border-color: color-mix(in srgb, var(--amber) 40%, var(--border)); background: var(--amber-soft); }
.card-warn .card-title { color: var(--amber); }

.page-head { margin-bottom: 22px; }
.page-head h1 { display: flex; align-items: center; gap: 10px; }
.page-head h1 .icon { width: 26px; height: 26px; color: var(--brand); }
.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { max-width: 760px; }
.page-narrow { max-width: 820px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 0.88rem; margin-bottom: 8px; color: var(--muted); }
.back-link:hover { color: var(--brand); text-decoration: none; }

.section-block { margin-top: 30px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.block-head h2 { margin: 0; }
.link-more { display: inline-flex; align-items: center; gap: 4px; font-size: 0.9rem; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-2); font-size: 0.8rem; font-weight: 600;
}
.chip .icon { width: 14px; height: 14px; }
.chip-ok { background: var(--green-soft); color: var(--green); }

.badge {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  font-size: 0.76rem; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.badge-lg { font-size: 0.88rem; padding: 5px 13px; }
.badge-active, .badge-zrealizowany { background: var(--green-soft); color: var(--green); }
.badge-annulled, .badge-odrzucony { background: var(--red-soft); color: var(--red); }
.badge-nowy { background: var(--brand-soft); color: var(--brand); }
.badge-w_realizacji { background: var(--amber-soft); color: var(--amber); }
.badge-role-admin { background: var(--red-soft); color: var(--red); }
.badge-role-lekarz { background: var(--brand-soft); color: var(--brand); }
.badge-role-ratownik { background: var(--green-soft); color: var(--green); }

.note-box {
  display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; margin-bottom: 16px; border-radius: var(--radius);
  background: var(--brand-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
}
.note-box > .icon { color: var(--brand); margin-top: 2px; }
.note-box > div { flex: 1 1 260px; }
.note-box p { margin: 4px 0 0; }
.note-ok { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 30%, transparent); align-items: center; }
.note-ok > .icon { color: var(--green); }
.note-quote { margin-top: 8px; padding-left: 10px; border-left: 3px solid var(--border-strong); color: var(--text-2); white-space: pre-wrap; }

.verdict {
  display: flex; gap: 16px; align-items: flex-start; padding: 18px 20px; border-radius: var(--radius);
  margin-bottom: 18px; border: 1px solid;
}
.verdict > .icon { width: 34px; height: 34px; }
.verdict h2 { margin-bottom: 4px; }
.verdict p { margin: 2px 0; }
.verdict-ok { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.verdict-ok > .icon, .verdict-ok h2 { color: var(--green); }
.verdict-bad { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.verdict-bad > .icon, .verdict-bad h2 { color: var(--red); }
.verdict-warn { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 35%, transparent); }
.verdict-warn > .icon, .verdict-warn h2 { color: var(--amber); }

.empty-state { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-state .icon { width: 44px; height: 44px; color: var(--border-strong); }
.empty-state h1 { color: var(--text); margin-top: 12px; }
.empty-inline { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 36px 20px; color: var(--muted); }

.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px 0; justify-content: center; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--brand); animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────── Formularze ─────────── */

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.w-full { grid-column: span 12; }
.w-half { grid-column: span 6; }
.w-third { grid-column: span 4; }
.w-quarter { grid-column: span 3; }

.field { min-width: 0; }
.field[hidden] { display: none; }
.field-label { display: block; font-size: 0.86rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.req { color: var(--red); }
.field-hint { font-size: 0.8rem; color: var(--muted); margin-top: 5px; }
.field-interpret { font-size: 0.84rem; font-weight: 600; color: var(--brand); margin-top: 5px; }
.field-interpret:empty { display: none; }
.field-interpret.alert { color: var(--red); }
.field-error { font-size: 0.82rem; color: var(--red); margin-top: 5px; font-weight: 600; }
.field-error:empty { display: none; }

input[type=text], input[type=search], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=time], input[type=email], input:not([type]), select, textarea {
  width: 100%; min-height: 40px; padding: 8px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.94rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 92px; line-height: 1.5; }
select { cursor: pointer; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.has-error input, .has-error select, .has-error textarea, .has-error .tbl, .has-error .choice-group, .has-error .check-group {
  border-color: var(--red);
}
.has-error .choice-group, .has-error .check-group { border: 1px solid var(--red); border-radius: var(--radius-sm); padding: 6px; }

.input-unit { display: flex; align-items: stretch; }
.input-unit input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-unit span {
  display: flex; align-items: center; padding: 0 11px; border: 1px solid var(--border-strong); border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--surface-2); color: var(--muted);
  font-size: 0.85rem; white-space: nowrap;
}

.readonly-box {
  min-height: 40px; padding: 8px 11px; border-radius: var(--radius-sm); background: var(--surface-2);
  border: 1px dashed var(--border-strong); color: var(--text-2); font-size: 0.94rem;
}

.choice-group { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-stack { flex-direction: column; }
.choice-stack .choice { flex: none; }
.choice {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 13px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
  font-size: 0.92rem; flex: 1 1 200px; transition: border-color 0.15s, background 0.15s;
}
.choice:hover { border-color: var(--brand); }
.choice input { margin: 3px 0 0; accent-color: var(--brand); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); font-weight: 600; }

.check-group { display: grid; gap: 6px; }
.check-inline { display: flex; flex-wrap: wrap; gap: 6px; }
.check-inline .check {
  padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); min-width: 58px; justify-content: center;
}
.check-inline .check:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); font-weight: 700; }
.check-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.check { display: inline-flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 0.92rem; }
.check input { margin: 3px 0 0; width: 16px; height: 16px; accent-color: var(--brand); flex: none; }
.check-single { padding: 10px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); width: 100%; }

.daterange { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.daterange label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.daterange input { width: auto; }
.daterange-days { font-weight: 700; color: var(--brand); }

.tbl { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; background: var(--surface-2); }
.tbl-head, .tbl-row { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)) 36px; gap: 8px; align-items: center; }
.tbl-head { font-size: 0.78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 0 2px 6px; }
.tbl-row + .tbl-row { margin-top: 8px; }
.tbl .btn { margin-top: 10px; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.matrix { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.matrix th, .matrix td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: center; }
.matrix thead th { font-size: 0.78rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.matrix tbody th { text-align: left; font-weight: 500; }
.matrix tbody tr:hover { background: var(--surface-2); }
.matrix-cell { display: inline-flex; padding: 4px; cursor: pointer; }
.matrix-cell input { width: 17px; height: 17px; accent-color: var(--brand); margin: 0; }

.form-section { margin-bottom: 16px; }
.form-section-title {
  display: flex; align-items: center; gap: 10px; font-size: 1.02rem; margin: 0 0 16px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.form-section-title .step {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand); font-size: 0.82rem; font-weight: 800;
}
.form-card .form-section-title:not(:first-child) { margin-top: 24px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.form-actions-sticky {
  position: sticky; bottom: 0; z-index: 5; margin: 0 -4px; padding: 14px 4px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.autosave { margin-right: auto; }
.form-error {
  margin-top: 14px; padding: 10px 13px; border-radius: var(--radius-sm);
  background: var(--red-soft); color: var(--red); font-weight: 600; font-size: 0.9rem;
}
.form-error[hidden] { display: none; }

.search-input { position: relative; display: flex; align-items: center; }
.search-input > .icon { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.search-input input { padding-left: 38px; }
.patient-search { position: relative; margin-bottom: 16px; }
.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); max-height: 320px; overflow-y: auto;
}
.search-result {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%;
  padding: 10px 14px; border: 0; border-bottom: 1px solid var(--border); background: transparent;
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.search-result span { font-size: 0.82rem; color: var(--muted); }
.search-result:hover, .search-result:focus { background: var(--brand-soft); outline: none; }
.search-empty { padding: 12px 14px; color: var(--muted); font-size: 0.88rem; }
.patient-linked {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; padding: 10px 13px;
  border-radius: var(--radius-sm); background: var(--green-soft); font-size: 0.9rem;
}
.patient-linked > .icon { color: var(--green); }
.patient-linked > span { flex: 1 1 240px; }
.patient-notes { flex-basis: 100%; color: var(--amber); font-weight: 600; white-space: pre-wrap; }

.code-input { font-family: var(--mono); font-size: 1.1rem !important; letter-spacing: 0.08em; text-transform: uppercase; }
.verify-row { display: flex; gap: 10px; }
.verify-row input { flex: 1; }
.verify-form { margin-bottom: 20px; }

/* ─────────── Tabele i listy ─────────── */

.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th {
  text-align: left; padding: 11px 16px; background: var(--surface-2); color: var(--muted);
  font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.row-muted td { opacity: 0.6; }
.actions-cell { text-align: right; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px; margin-bottom: 12px; }
.filters select { width: auto; flex: 0 1 220px; }
.filters-search { flex: 1 1 260px; }
.list-meta { font-size: 0.86rem; margin: 0 2px 10px; }

.pagination { display: flex; gap: 6px; justify-content: center; align-items: center; margin-top: 18px; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 10px 14px; color: var(--muted); font-weight: 600; font-size: 0.9rem; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.request-list { display: grid; gap: 10px; }
.request-card { display: flex; gap: 16px; align-items: center; color: var(--text); padding: 16px 20px; transition: border-color 0.15s, box-shadow 0.15s; }
.request-card:hover { text-decoration: none; border-color: var(--brand); box-shadow: var(--shadow); }
.request-card-main { flex: 1; min-width: 0; }
.request-card-main h3 { margin: 6px 0 4px; }
.request-card-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.request-card-side { display: flex; align-items: center; gap: 8px; color: var(--muted); flex-wrap: wrap; justify-content: flex-end; }

.request-status-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.request-status h2 { margin: 4px 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; display: flex; gap: 14px; padding: 0 0 14px 20px; font-size: 0.9rem; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.timeline li::after { content: ""; position: absolute; left: 7px; top: 18px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline-date { color: var(--muted); white-space: nowrap; min-width: 130px; }

.dl { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 8px 18px; margin: 0; font-size: 0.92rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }

.credentials { display: grid; gap: 6px; padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px dashed var(--border-strong); }

/* ─────────── Pulpit ─────────── */

.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, transform 0.15s;
}
.stat:hover { text-decoration: none; border-color: var(--brand); transform: translateY(-1px); }
.stat-icon { color: var(--brand); margin-bottom: 6px; }
.stat-value { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.stat-label { font-size: 0.82rem; color: var(--muted); }
.stat-alert { border-color: color-mix(in srgb, var(--red) 45%, var(--border)); background: var(--red-soft); }
.stat-alert .stat-icon, .stat-alert .stat-value { color: var(--red); }

.type-groups { display: grid; gap: 22px; }
.type-group-title { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 10px; }
.type-group-title .icon { color: var(--brand); }
.type-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.type-groups-compact .type-cards { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.type-card {
  display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  box-shadow: var(--shadow-sm); position: relative; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.type-card strong { font-size: 0.97rem; }
.type-card .muted { font-size: 0.85rem; line-height: 1.45; }
a.type-card::after {
  content: ""; position: absolute; top: 0; left: 16px; right: 16px; height: 3px; border-radius: 0 0 3px 3px;
  background: var(--brand); opacity: 0; transition: opacity 0.15s;
}
a.type-card:hover { text-decoration: none; border-color: var(--brand); box-shadow: var(--shadow); transform: translateY(-1px); }
a.type-card:hover::after { opacity: 1; }
.type-groups-compact .type-card { padding: 12px 14px; }
.type-card.disabled { opacity: 0.55; cursor: not-allowed; background: var(--surface-2); }
.type-lock { display: inline-flex; align-items: center; gap: 4px; font-size: 0.76rem; color: var(--muted); font-weight: 600; }
.type-lock .icon { width: 13px; height: 13px; }

/* ─────────── Panel: układ ─────────── */

.panel-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column; background: var(--navy); color: var(--navy-text);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}
.sidebar::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--red); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.2; }
.brand strong { font-size: 1rem; }
.brand small { font-size: 0.76rem; color: var(--muted); }
.brand-light { color: #fff; padding: 22px 20px 18px; }
.brand-light small { color: var(--navy-text); opacity: 0.8; }
.side-nav { flex: 1; overflow-y: auto; padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.side-heading { margin: 16px 10px 6px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--navy-text); opacity: 0.55; font-weight: 700; }
.side-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--navy-text); font-weight: 500; font-size: 0.93rem;
}
.side-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }
.side-link.active { background: rgba(79, 134, 230, 0.2); color: #fff; box-shadow: inset 3px 0 0 #6d9cf0; }
.side-link span:not(.side-badge) { flex: 1; }
.side-badge { background: var(--red); color: #fff; font-size: 0.72rem; font-weight: 800; padding: 1px 7px; border-radius: 999px; }
.side-badge[hidden] { display: none; }
.side-user { display: flex; align-items: center; gap: 6px; padding: 12px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.side-user-card { flex: 1; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-sm); color: #fff; min-width: 0; }
.side-user-card:hover, .side-user-card.active { background: rgba(255, 255, 255, 0.07); text-decoration: none; }
.side-user-card > span:last-child { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.side-user-card strong { font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-card small { font-size: 0.75rem; color: var(--navy-text); opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 34px; height: 34px;
  border-radius: 50%; background: linear-gradient(135deg, #2f63c4, #1d4fa3); color: #fff; font-weight: 800; font-size: 0.8rem; text-transform: uppercase;
}
.avatar-lg { width: 54px; height: 54px; font-size: 1.1rem; }
.patient-title { display: flex; align-items: center; gap: 14px; }
.patient-title h1 { margin: 0; }
.patient-title p { margin: 2px 0 0; }

.panel-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: none; position: sticky; top: 0; z-index: 30; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-brand { flex: 1; gap: 8px; }
.panel-content { flex: 1; width: 100%; max-width: 1240px; padding: 30px 34px 60px; }
.sidebar-backdrop { display: none; }

/* ─────────── Strona publiczna ─────────── */

.public-shell { min-height: 100vh; display: flex; flex-direction: column; }
.public-header { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.public-header::before { content: ""; display: block; height: 3px; background: var(--red); }
.public-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.public-nav { display: flex; align-items: center; gap: 6px; }
.public-nav > a:not(.btn) { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 600; font-size: 0.92rem; }
.public-nav > a:not(.btn):hover, .public-nav > a.active { background: var(--surface-3); color: var(--text); text-decoration: none; }
.public-main { flex: 1; padding-bottom: 40px; }
.public-main > .container:first-child, .public-main > .page-narrow:first-child { padding-top: 34px; }

.public-footer { background: var(--navy); color: var(--navy-text); padding: 28px 0; font-size: 0.86rem; }
.public-footer .container { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; align-items: center; }
.footer-brand { display: flex; align-items: center; gap: 12px; }
.footer-brand strong { color: #fff; }
.footer-note { max-width: 520px; margin: 0; opacity: 0.8; }

.hero { background: radial-gradient(1200px 500px at 85% -10%, #2a5fc0 0%, transparent 60%), linear-gradient(160deg, #0c1a33 0%, #142c57 100%); color: #fff; }
.hero-inner { display: grid; grid-template-columns: 1.35fr 1fr; gap: 40px; align-items: center; padding-top: 64px; padding-bottom: 64px; }
.eyebrow { display: inline-block; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #ff8fa3; margin-bottom: 14px; }
.hero h1 { font-size: clamp(1.9rem, 4vw, 2.75rem); letter-spacing: -0.02em; margin-bottom: 16px; }
.hero p { color: #c9d5e8; font-size: 1.06rem; max-width: 580px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.hero-verify { color: var(--text); box-shadow: var(--shadow-lg); padding: 26px; }
.hero .hero-verify p { color: var(--muted); font-size: 0.92rem; }
.hero-verify h2 { display: flex; align-items: center; gap: 8px; }
.hero-verify h2 .icon { color: var(--green); }
.hero-verify .btn { margin-top: 14px; }

.section { padding-top: 56px; padding-bottom: 20px; }
.section-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-top: 40px; padding: 50px 0; }
.section-head { text-align: center; max-width: 680px; margin: 0 auto 30px; }
.section-head h2 { font-size: 1.6rem; }
.cat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.cat-card { padding: 24px; }
.cat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--brand-soft); color: var(--brand); margin-bottom: 14px; }
.cat-icon .icon { width: 24px; height: 24px; }
.type-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 7px; font-size: 0.92rem; }
.type-list li { display: flex; gap: 8px; align-items: flex-start; }
.type-list .icon { color: var(--green); width: 16px; height: 16px; margin-top: 3px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; counter-reset: s; }
.steps li { padding: 4px; }
.steps p { color: var(--muted); font-size: 0.92rem; }
.step-num { display: inline-flex; width: 38px; height: 38px; border-radius: 50%; align-items: center; justify-content: center; background: var(--red); color: #fff; font-weight: 800; margin-bottom: 12px; }
.cta-band { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-bottom: 50px; }
.cta-band h2 { font-size: 1.4rem; }

.code-card { text-align: center; padding: 30px; }
.big-code { font-family: var(--mono); font-size: 2.1rem; font-weight: 800; letter-spacing: 0.12em; margin: 8px 0 18px; color: var(--brand); }
.code-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ─────────── Logowanie ─────────── */

.bare-main { min-height: 100vh; background: radial-gradient(900px 500px at 50% -10%, #23498f 0%, transparent 65%), linear-gradient(170deg, #0c1a33, #10203f); }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; padding: 32px; box-shadow: var(--shadow-lg); }
.auth-card-wide { max-width: 640px; }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand img { margin-bottom: 8px; }
.auth-brand h1 { font-size: 1.45rem; margin-bottom: 4px; }
.auth-card form .btn-block { margin-top: 20px; }
.auth-foot { text-align: center; font-size: 0.85rem; margin: 18px 0 0; }
.auth-back { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 0.86rem; margin-top: 10px; color: var(--muted); }

/* ─────────── Dokument: pasek narzędzi ─────────── */

.doc-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; }
.toolbar-spacer { flex: 1; }
.code-pill .mono { font-weight: 700; }
.stamp-preview { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

/* ─────────── Okna dialogowe i powiadomienia ─────────── */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 16px; background: rgba(6, 14, 28, 0.55); overflow-y: auto; animation: fade 0.15s ease;
}
.modal {
  width: 100%; max-width: 520px; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); animation: pop 0.18s ease; margin: auto 0;
}
.modal-wide { max-width: 900px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 1.12rem; }
.modal-body { padding: 20px; }
.modal > .form-error { margin: 0 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 36px); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--navy-2); color: #fff; box-shadow: var(--shadow-lg); font-size: 0.92rem; font-weight: 500;
  animation: pop 0.2s ease; transition: opacity 0.35s, transform 0.35s;
}
.toast-success .icon { color: #4ade80; }
.toast-error .icon { color: #fb7185; }
.toast.leaving { opacity: 0; transform: translateY(6px); }

/* ─────────── Prawo PlayLife ─────────── */

.law-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.law-side {
  position: sticky; top: 16px; display: grid; gap: 12px; grid-template-rows: auto minmax(0, 1fr);
  max-height: calc(100vh - 32px);
}
.law-search { padding: 12px; }
.law-count { font-size: 0.82rem; margin-top: 8px; }
.law-toc { padding: 8px 6px; overflow: auto; }
.law-toc summary { font-weight: 700; font-size: 0.85rem; padding: 6px 10px; cursor: pointer; color: var(--text-2); }
.law-toc ol { list-style: none; margin: 4px 0 0; padding: 0; }
.law-toc a {
  display: flex; gap: 8px; align-items: baseline; padding: 6px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 0.86rem; line-height: 1.35;
}
.law-toc a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.law-toc-num { flex: none; min-width: 20px; font-weight: 700; color: var(--brand); }
.law-toc .badge { margin-left: auto; }
.law-chapter { margin-bottom: 26px; scroll-margin-top: 16px; }
.law-chapter > h2 { font-size: 1.12rem; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--border); }
.law-chapter > h2 .muted { display: block; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.law-art {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 10px; scroll-margin-top: 16px;
}
.law-art-target { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.law-art-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.law-art-head h3 { flex: 1; margin: 0; font-size: 1rem; }
.law-art-num { font-weight: 800; white-space: nowrap; }
.law-cite { flex: none; align-self: center; }
.law-par { margin: 6px 0; line-height: 1.6; color: var(--text-2); }
.law-par-label { font-weight: 700; color: var(--text); margin-right: 4px; }
.law-par-title { color: var(--text); }
.law-par-title + span { display: block; margin-top: 2px; }
.law-items { list-style: none; margin: 6px 0; padding-left: 18px; display: grid; gap: 3px; }
.law-items li { display: flex; gap: 8px; }
.law-item-label { flex: none; min-width: 18px; font-weight: 700; color: var(--text); }
.law-after { margin: 4px 0 0; }
.law-copy { font-size: 0.75rem; margin-top: 18px; }
mark { background: #fde68a; color: inherit; border-radius: 2px; padding: 0 1px; }
:root[data-theme="dark"] mark { background: #7a5a0c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) mark { background: #7a5a0c; } }

/* ─────────── Responsywność ─────────── */

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1023px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg); }
  .sidebar-open .sidebar { transform: none; }
  .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(6, 14, 28, 0.5); }
  .panel-main { margin-left: 0; }
  .topbar { display: flex; }
  .panel-content { padding: 22px 16px 60px; }
  .hero-inner { grid-template-columns: 1fr; padding-top: 44px; padding-bottom: 44px; }
  .cat-grid { grid-template-columns: 1fr; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .law-layout { grid-template-columns: 1fr; }
  .law-side { position: static; max-height: none; }
}

@media (max-width: 720px) {
  body { font-size: 14.5px; }
  h1 { font-size: 1.4rem; }
  .container { padding: 0 16px; }
  .grid { gap: 12px; }
  .w-half, .w-third, .w-quarter { grid-column: span 12; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: 1fr; }
  .check-cols { grid-template-columns: 1fr; }
  .public-nav > a:not(.btn) span { display: none; }
  .public-nav .btn span { display: none; }
  .brand small { display: none; }
  .topbar-cta span { display: none; }
  .tbl-head { display: none; }
  .tbl-row { grid-template-columns: 1fr 36px; padding-bottom: 8px; border-bottom: 1px dashed var(--border-strong); }
  .tbl-row input:not(:first-child) { grid-column: 1; }
  .tbl-row .icon-btn { grid-column: 2; grid-row: 1; }
  .filters select { flex: 1 1 100%; }
  .verify-row { flex-direction: column; }
  .request-card { flex-direction: column; align-items: stretch; }
  .request-card-side { justify-content: flex-start; }
  .request-status-head { flex-direction: column; }
  .timeline li { flex-direction: column; gap: 0; }
  .doc-toolbar .btn { flex: 1 1 auto; }
  .toolbar-spacer { display: none; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
  .table th, .table td { padding: 10px 12px; }
  .auth-card { padding: 24px 20px; }
  .modal-backdrop { padding: 12px; }
  .big-code { font-size: 1.6rem; }
}
