/* RMG Trenažér – clinical UI. Tokens first; components below. */
:root {
    --brand: #0f5c6e;
    --brand-600: #0c4c5b;
    --brand-50: #e8f3f5;
    --brand-100: #cfe6ea;
    --ink: #0f2530;
    --ink-2: #33495a;
    --muted: #64798a;
    --line: #dde5eb;
    --line-2: #eef2f5;
    --bg: #f3f6f8;
    --card: #ffffff;
    --ai: #5b4bc4;
    --ai-50: #efedfb;
    --ok: #177245;
    --ok-50: #e5f4ec;
    --warn: #9a5b00;
    --warn-50: #fff4e0;
    --err: #b42318;
    --err-50: #fdecea;
    --info: #1d5fa8;
    --info-50: #e8f0fb;
    --pending: #a15c07;
    --completed: #1d5fa8;
    --valid: #177245;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(15, 37, 48, .06), 0 1px 3px rgba(15, 37, 48, .05);
    --shadow-lg: 0 12px 32px rgba(15, 37, 48, .16);
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --serif: "Source Serif 4", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; color: var(--ink); }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14.5px; font-weight: 600; }
h1:focus { outline: none; }
p { margin: 0; }
ul { margin: 0; padding-left: 18px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.spacer { flex: 1; }
.icon { width: 18px; height: 18px; flex: none; }

/* ------------------------------------------------------------------ shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 248px; flex: none; position: sticky; top: 0; height: 100vh;
    background: linear-gradient(180deg, #0d3f4c 0%, #0b3441 100%);
    color: #d6e6ea; display: flex; flex-direction: column; padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; color: #fff; padding: 4px 6px 18px; text-decoration: none !important; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: #1f8a9c; display: grid; place-items: center; color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.brand-mark svg { width: 26px; height: 26px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15.5px; letter-spacing: .01em; }
.brand-text small { color: #9ec2ca; font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #c8dde2; font-weight: 500; text-decoration: none !important; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 3px 0 0 #5cc6d6; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: #9ec2ca; display: flex; flex-direction: column; gap: 8px; padding: 12px 6px 0; border-top: 1px solid rgba(255,255,255,.08); }
.env-badge { display: inline-flex; align-items: center; gap: 8px; color: #fff; font-weight: 600; font-size: 12.5px; }
.env-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #f5b83d; box-shadow: 0 0 0 3px rgba(245,184,61,.2); }
.sidebar-foot .muted { color: #7fa6b0; }

.main { flex: 1; min-width: 0; }
.page, .form-page { max-width: 1320px; margin: 0 auto; padding: 26px 32px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.lead { color: var(--muted); margin-top: 4px; max-width: 760px; }
.privacy-note { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; color: var(--ok); }
.privacy-note .icon { width: 15px; height: 15px; }
.page-actions { display: flex; align-items: center; gap: 8px; }
.crumbs { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.crumbs a { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 500; }
.crumbs a:hover { color: var(--brand); text-decoration: none; }
.crumbs .icon { width: 16px; height: 16px; }
.loading, .empty-state { padding: 60px; text-align: center; color: var(--muted); }
.empty-state { display: flex; flex-direction: column; gap: 14px; align-items: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ------------------------------------------------------------------ buttons */
.btn {
    display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px;
    border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 13.5px;
    cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn .icon { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-600); }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); }
.btn-secondary:hover:not(:disabled) { border-color: #c4d1da; background: #fafcfd; }
.btn-soft { background: var(--brand-50); color: var(--brand); border-color: var(--brand-100); }
.btn-soft:hover:not(:disabled) { background: var(--brand-100); }
.btn-outline { background: #fff; color: var(--brand); border-color: var(--brand); }
.btn-outline:hover:not(:disabled) { background: var(--brand-50); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--line-2); }
.btn-ghost.danger, .danger-text { color: var(--err); }
.btn-danger { background: var(--err); color: #fff; }
.btn-danger:hover { background: #911c13; }
.icon-btn { border: 0; background: transparent; color: var(--muted); width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.link-btn { border: 0; background: none; padding: 0; color: var(--brand); font: inherit; cursor: pointer; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }
.btn-with-help { display: inline-flex; align-items: center; gap: 2px; }

.help-btn {
    width: 22px; height: 22px; flex: none; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
    background: transparent; color: #8aa0ae; display: inline-grid; place-items: center; vertical-align: middle;
    transition: color .12s, background .12s, transform .12s;
}
.help-btn .icon { width: 17px; height: 17px; }
.help-btn:hover { color: var(--ai); background: var(--ai-50); }
.help-btn.active { color: #fff; background: var(--ai); }
.help-btn.lg { width: 28px; height: 28px; }
.help-btn.lg .icon { width: 21px; height: 21px; }
.inline-help { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--ai); color: var(--ai); font-size: 11px; font-weight: 700; }

/* ------------------------------------------------------------------ chips & badges */
.phase-chip { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; background: #e8edf1; color: var(--ink-2); }
.phase-mgus { background: #e6f0fa; color: #1f5f99; }
.phase-smm { background: #f1ebfa; color: #6b3fb0; }
.phase-mm { background: #e3f3f0; color: #0d6b5d; }
.phase-amyl, .phase-al-amyl { background: #fbeee4; color: #9b4a12; }
.phase-wm { background: #eceff2; color: #5b6b78; }
.phase-patient, .phase-pacient { background: #eceff2; color: #3a4d5b; }

.state { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state-new { background: #eef1f4; color: #6a7c89; }
.state-pending { background: var(--warn-50); color: var(--pending); }
.state-completed { background: var(--info-50); color: var(--completed); }
.state-valid { background: var(--ok-50); color: var(--valid); }
.training-tag { font-size: 11.5px; font-weight: 600; color: #8a5a00; background: #fff4dc; border: 1px solid #f3dca8; padding: 1px 8px; border-radius: 999px; }
.line-badge { display: inline-flex; font-size: 13px; font-weight: 600; color: var(--brand); background: var(--brand-50); padding: 2px 10px; border-radius: 999px; vertical-align: middle; margin-left: 6px; }
.page-ref { color: var(--muted); font-size: 12px; }
.page-ref::before { content: "§ "; color: #a9b8c3; }
a.mref { color: var(--info); text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
a.mref:hover { text-decoration-style: solid; }
.dirty { color: var(--warn); font-size: 12px; font-weight: 600; }
.dirty::before { content: "● "; }
.preview-tag { font-size: 11.5px; font-weight: 600; color: var(--ai); background: var(--ai-50); padding: 1px 8px; border-radius: 999px; }
.assume-flag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #8a5a00; background: #fff1d6; border: 1px dashed #e0b35c; padding: 0 6px; border-radius: 4px; cursor: help; }
.assume-flag.dash { color: #6b3fb0; background: #f3eefc; border-color: #b9a2e6; }
.assume-inline { color: #8a5a00; font-style: italic; }
.assume-note { font-size: 12.5px; color: #8a5a00; background: #fff8e8; border-left: 3px solid #e0b35c; padding: 8px 10px; border-radius: 4px; }
.sev { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 4px; background: #eef1f4; color: var(--ink-2); }
.sev-blocker { background: var(--err-50); color: var(--err); }
.sev-major { background: var(--warn-50); color: var(--warn); }

/* ------------------------------------------------------------------ banners */
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid; margin-bottom: 14px; }
.banner > .icon { margin-top: 1px; }
.banner > div { flex: 1; }
.banner.info { background: var(--info-50); border-color: #c8daf2; color: #173f6d; }
.banner.ok { background: var(--ok-50); border-color: #bfe3cf; color: #0f4d2f; }
.banner.warn { background: var(--warn-50); border-color: #f1d29b; color: #6b4000; }
.banner.error { background: var(--err-50); border-color: #f4c7c2; color: #7a1a12; }
.issue-list { margin-top: 6px; font-size: 13px; }
.issue-list li { margin: 2px 0; }
.gaps-inline summary { cursor: pointer; display: flex; gap: 8px; align-items: center; font-weight: 600; }
.gaps-inline ul { margin-top: 8px; }
.gaps-inline li { margin: 4px 0; }

/* ------------------------------------------------------------------ patient list */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.stat-num { font-size: 24px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.stat-num.ok { color: var(--ok); }
.stat-num.warn { color: var(--pending); }
.stat-num.err { color: var(--err); }
.stat-label { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.stat-label .help-btn { margin: -3px 0; }
.table-card { overflow: hidden; }
.table-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; width: 320px; color: var(--muted); }
.search input { border: 0; background: transparent; height: 34px; font: inherit; flex: 1; outline: none; color: var(--ink); }
.filter-pills { display: flex; gap: 6px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 14px; background: #f8fafb; border-bottom: 1px solid var(--line); }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.data-table tbody tr:hover { background: #fafcfd; }
.data-table.compact td { padding: 7px 12px; font-size: 13px; vertical-align: top; }
.data-table.compact th { padding: 8px 12px; }
.empty-row { text-align: center; color: var(--muted); padding: 30px !important; }
.who { display: flex; align-items: center; gap: 10px; }
.who small { display: block; color: var(--muted); font-size: 12px; }
.avatar { width: 52px; height: 52px; border-radius: 12px; background: linear-gradient(135deg, #1f8a9c, #0f5c6e); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 17px; letter-spacing: .03em; flex: none; }
.avatar.sm { width: 34px; height: 34px; border-radius: 9px; font-size: 12.5px; }
.state-bar { display: flex; gap: 4px; flex-wrap: wrap; max-width: 240px; }
.seg-dot { width: 18px; height: 8px; border-radius: 3px; background: #dfe5ea; }
.seg-dot.state-pending { background: #f0b45d; }
.seg-dot.state-completed { background: #6d9fe0; }
.seg-dot.state-valid { background: #3fa373; }
.seg-dot.state-new { background: #d5dde3; }
.last-event span { display: block; font-weight: 500; }
.last-event small { color: var(--muted); }
.hint-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.hint-card { display: flex; gap: 12px; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink-2); font-size: 13px; }
.hint-card > .icon { color: var(--brand); margin-top: 2px; }

/* ------------------------------------------------------------------ pills / toggles */
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-wrap { display: inline-flex; align-items: center; gap: 1px; }
.pill { height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.pill:hover:not(:disabled) { border-color: #b8c7d2; }
.pill.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pill:disabled { opacity: .45; cursor: not-allowed; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg { height: 32px; min-width: 64px; padding: 0 14px; border: 0; background: transparent; font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.seg + .seg { border-left: 1px solid var(--line); }
.seg.on { background: var(--brand); color: #fff; font-weight: 600; }
.seg:disabled { cursor: not-allowed; opacity: .55; }
.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none; }
.toggle input { appearance: none; width: 30px; height: 18px; border-radius: 999px; background: #cfd9e0; position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input:checked { background: var(--brand); }
.toggle input:checked::after { transform: translateX(12px); }

/* ------------------------------------------------------------------ patient detail */
.patient-header { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 20px; padding: 18px 20px; margin-bottom: 18px; }
.patient-id h1 { display: flex; align-items: baseline; gap: 10px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 21px; }
.patient-id .initials { font-family: var(--font); font-size: 15px; color: var(--muted); font-weight: 600; }
.patient-facts { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; color: var(--ink-2); margin-top: 4px; font-size: 13.5px; }
.patient-dx { border-left: 1px solid var(--line); padding-left: 20px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.dx-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 4px; }
.dx-long { font-size: 12.5px; color: var(--ink-2); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.phase-tabs { display: flex; gap: 6px; align-items: center; margin-bottom: 12px; }
.phase-tab { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff; cursor: pointer; font: inherit; min-width: 96px; }
.phase-tab .tab-code { font-weight: 700; font-size: 14px; color: var(--ink); }
.phase-tab .tab-count { font-size: 11.5px; color: var(--muted); }
.phase-tab.on { border-color: var(--brand); box-shadow: inset 0 -3px 0 var(--brand); background: var(--brand-50); }
.phase-tab.oos { opacity: .6; border-style: dashed; }
.phase-panel-head { margin-bottom: 12px; }
.phase-panel-head h2 { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.form-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.form-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); }
.form-card.inactive { background: #fbfcfd; border-style: dashed; }
.form-card-head { display: flex; gap: 12px; align-items: flex-start; }
.form-card-head > .icon { color: var(--brand); background: var(--brand-50); border-radius: 8px; padding: 7px; width: 34px; height: 34px; }
.form-card-head > div { flex: 1; }
.form-card-head p { color: var(--muted); font-size: 12.5px; }
.form-card-foot { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-top: auto; }
.mini-stats { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.mini-stats strong { color: var(--ink); }
.line-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.line-list a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; color: var(--ink); text-decoration: none; }
.line-list a:hover { border-color: var(--brand-100); background: #fafdfd; }
.line-no { width: 26px; height: 26px; border-radius: 7px; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 12.5px; flex: none; }
.line-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.line-main small { color: var(--muted); font-size: 12px; }
.group-heading { margin: 22px 0 10px; }

.timeline { padding: 16px 18px; position: sticky; top: 16px; }
.timeline h2 { display: flex; align-items: center; gap: 4px; margin-bottom: 12px; }
.timeline ol { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline ol::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 14px 24px; }
.tl-dot { position: absolute; left: 0; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid #9fb3c0; }
.tl-diagnosis .tl-dot { border-color: var(--brand); }
.tl-treatment .tl-dot { border-color: #6d9fe0; }
.tl-progression .tl-dot, .tl-transfer .tl-dot { border-color: #c2410c; background: #fff1e6; }
.tl-death .tl-dot { border-color: #334155; background: #334155; }
.tl-response .tl-dot { border-color: var(--ok); }
.tl-date { font-size: 11.5px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.tl-title { font-weight: 600; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tl-title a { color: var(--ink); }
.tl-title .phase-chip { height: 18px; font-size: 10px; padding: 0 6px; }
.tl-detail { font-size: 12.5px; color: var(--ink-2); }

/* ------------------------------------------------------------------ form page */
.form-header { position: sticky; top: 0; z-index: 20; background: rgba(243,246,248,.94); backdrop-filter: blur(6px); margin: -26px -32px 16px; padding: 18px 32px 14px; border-bottom: 1px solid var(--line); }
.form-title-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.form-title-row h1 { display: flex; align-items: center; gap: 8px; }
.form-subtitle { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 13px; margin-top: 4px; flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar-sep { width: 1px; height: 26px; background: var(--line); }
.form-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; }
.section-nav { position: sticky; top: 130px; max-height: calc(100vh - 150px); overflow: auto; display: flex; flex-direction: column; gap: 1px; padding-right: 4px; }
.section-nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 0 10px 6px; }
.section-link { display: flex; align-items: center; justify-content: space-between; gap: 6px; text-align: left; border: 0; background: transparent; padding: 6px 10px; border-radius: 7px; font: inherit; font-size: 12.5px; color: var(--ink-2); cursor: pointer; line-height: 1.3; }
.section-link:hover { background: #e7eef2; color: var(--ink); }
.section-link.hidden-sec { color: #a3b3bf; }
.section-link.oos { color: #a3b3bf; font-style: italic; }
.sl-title { overflow: hidden; text-overflow: ellipsis; }
.sl-meta { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.sl-meta .icon { width: 13px; height: 13px; }
.sl-meta.ok { color: var(--ok); font-weight: 600; }
.sl-meta.err { background: var(--err); color: #fff; border-radius: 999px; padding: 0 6px; font-weight: 700; }
.form-body { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.form-section { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); scroll-margin-top: 140px; }
.form-section.out-of-scope { background: #fafbfc; border-style: dashed; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 18px 12px; border-bottom: 1px solid var(--line-2); }
.section-head h2 { font-size: 13.5px; letter-spacing: .04em; color: var(--brand); font-weight: 700; }
.section-sub { display: flex; gap: 12px; color: var(--muted); font-size: 12.5px; margin-top: 2px; flex-wrap: wrap; align-items: center; }
.section-notes { margin: 12px 18px 0; padding: 10px 14px 10px 30px; background: #f6f9fb; border-radius: 8px; color: var(--ink-2); font-size: 13px; }
.section-notes li { margin: 2px 0; }
.scope-banner { display: flex; gap: 10px; align-items: center; margin: 14px 18px; color: var(--muted); font-size: 13px; }
.fields { padding: 6px 0 8px; }

.field { display: grid; grid-template-columns: minmax(200px, 34%) minmax(0, 1fr) auto; gap: 8px 18px; padding: 10px 18px; border-bottom: 1px solid var(--line-2); align-items: start; scroll-margin-top: 150px; }
.fields > .field:last-child, .repeat-body > .field:last-child { border-bottom: 0; }
.field-label label { font-weight: 550; color: var(--ink); font-size: 13.5px; line-height: 1.35; display: block; padding-top: 6px; }
.field-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 3px; }
.label-cs { font-size: 12px; color: var(--muted); }
.req { color: var(--err); font-weight: 700; margin-left: 2px; }
.req.assumed { color: #c48a18; }
.field-control { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.field-control > .input, .field-control > .select-row, .field-control > .option-list { align-self: stretch; }
.field-actions { display: flex; align-items: center; gap: 6px; padding-top: 6px; }
.field.has-error { background: #fff8f7; box-shadow: inset 3px 0 0 var(--err); }
.field.has-warning { background: #fffbf2; box-shadow: inset 3px 0 0 #e0a030; }
.field.unconfirmed .field-label label { text-decoration: underline dotted #d49a2a; text-underline-offset: 3px; }
.field.not-evaluated .field-label label, .field.disabled .field-label label { color: #8193a0; }

.input { width: 100%; max-width: 420px; height: 34px; padding: 0 10px; border: 1px solid #cfd9e1; border-radius: 7px; font: inherit; font-size: 13.5px; background: #fff; color: var(--ink); transition: border-color .12s, box-shadow .12s; }
textarea.input { height: auto; padding: 8px 10px; max-width: 640px; resize: vertical; }
select.input { padding-right: 28px; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,92,110,.14); }
.input:disabled { background: #f3f6f8; color: #7d8f9b; cursor: not-allowed; }
.has-error .input { border-color: #e7a19a; }
.number-input, .date-input { display: flex; align-items: center; gap: 8px; }
.number-input .input { max-width: 170px; text-align: right; font-variant-numeric: tabular-nums; }
.unit { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.date-input .input { max-width: 140px; font-variant-numeric: tabular-nums; }
.date-pick { position: relative; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 7px; color: var(--muted); cursor: pointer; }
.date-pick:hover { background: var(--line-2); color: var(--brand); }
.date-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.date-pick input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.select-row { display: flex; align-items: center; gap: 10px; }
.option-list { list-style: none; padding: 8px 10px; background: #f8fafb; border: 1px solid var(--line-2); border-radius: 8px; display: flex; flex-direction: column; gap: 4px; max-width: 640px; }
.option-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: baseline; font-size: 13px; }
.option-list small { color: var(--muted); }
.checks { display: flex; flex-direction: column; gap: 4px; }
.checks.cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }
.check.single { padding-top: 6px; }
.computed { display: inline-flex; align-items: center; gap: 10px; min-height: 34px; padding: 0 12px; border-radius: 7px; background: #f4f7f9; border: 1px dashed #cfd9e1; max-width: 420px; }
.computed-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.computed-empty { color: #97a8b4; font-size: 12.5px; }
.computed-undoc { color: #8a5a00; font-size: 12.5px; font-style: italic; }
.computed-tag { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #8aa0ae; font-weight: 700; }
.ne-box { display: inline-flex; align-items: center; height: 34px; padding: 0 12px; border-radius: 7px; background: repeating-linear-gradient(135deg, #f4f7f9 0 6px, #eef2f5 6px 12px); color: #7a8d9a; font-size: 12.5px; font-weight: 600; max-width: 240px; }
.hint { font-size: 12.5px; line-height: 1.4; }
.hint.error { color: var(--err); }
.hint.warn { color: var(--warn); }
.hint.auto-filled { color: var(--ink-2); background: var(--info-50); padding: 3px 8px; border-radius: 6px; display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; }
.hint.drug-hint { color: var(--info); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.button-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.button-msg { font-size: 12.5px; color: var(--ink-2); background: var(--info-50); padding: 4px 10px; border-radius: 6px; }

.slider { width: 38px; height: 22px; border-radius: 999px; border: 2px solid #1c3f8c; background: #1c3f8c; position: relative; cursor: pointer; padding: 0; flex: none; }
.slider .knob { position: absolute; top: 2px; right: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: right .15s; }
.slider.off { background: #fff; }
.slider.off .knob { right: 18px; background: #1c3f8c; }
.slider:disabled { opacity: .5; cursor: not-allowed; }

.subheading { display: flex; align-items: center; gap: 6px; padding: 14px 18px 6px; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); border-bottom: 1px solid var(--line-2); background: linear-gradient(180deg, #fbfcfd, #fff); }
.info-note { display: flex; gap: 10px; align-items: flex-start; margin: 8px 18px; padding: 10px 12px; border-radius: 8px; background: #f2f7fb; border: 1px solid #dbe7f1; color: #24435c; font-size: 13px; }
.info-note > .icon { color: var(--info); margin-top: 1px; }
.info-note > div { flex: 1; }
.info-note strong { display: block; margin-bottom: 2px; }

.repeat { padding: 12px 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.repeat-empty { color: var(--muted); font-size: 13px; font-style: italic; }
.repeat-generated { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--ink-2); background: var(--brand-50); border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 8px; }
.repeat-generated .icon { flex: none; color: var(--brand); margin-top: 1px; }
.repeat-item { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.repeat-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #f6f9fb; border-bottom: 1px solid var(--line-2); }
.repeat-no { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 11.5px; font-weight: 700; }
.repeat-title { flex: 1; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.repeat-body .field { padding-left: 14px; padding-right: 14px; }
.repeat-add { display: flex; align-items: center; gap: 6px; }
.group { margin: 6px 18px 10px; border: 1px solid var(--line-2); border-radius: 9px; background: #fcfdfe; }
.group-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px 0; }
.group-title { font-weight: 600; }
.group .repeat { padding: 10px 14px 14px; }

.fully-filled { display: flex; align-items: center; gap: 8px; justify-content: space-between; margin: 16px 0 0 250px; padding: 12px 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.form-footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin: 18px 0 0 250px; padding-top: 14px; border-top: 1px solid var(--line); }
.queries { background: #fff; border: 1px solid #f1d29b; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; }
.queries-head { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--warn); margin-bottom: 6px; }
.queries ul { margin: 6px 0; }
.queries p { font-size: 12.5px; }

/* ------------------------------------------------------------------ assistant panel */
.assistant-backdrop { position: fixed; inset: 0; background: rgba(15,37,48,.18); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; }
.assistant-backdrop.open { opacity: 1; pointer-events: auto; }
.assistant { position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 100vw; background: #fff; box-shadow: var(--shadow-lg); z-index: 70; display: flex; flex-direction: column; transform: translateX(105%); transition: transform .22s ease; border-left: 1px solid var(--line); }
.assistant.open { transform: translateX(0); }
.assistant-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #f7f6fe, #fff); }
.assistant-title { display: flex; align-items: center; gap: 8px; }
.ai-badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ai); }
.kind-chip { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--line-2); padding: 2px 8px; border-radius: 999px; }
.assistant-body { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.context-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.context-eyebrow { display: flex; gap: 10px; font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.context-card h3 { font-size: 16px; }
.context-sub { color: var(--muted); font-size: 13px; margin-top: -6px; }
.guidance { background: #f5f9fa; border-left: 3px solid var(--brand); border-radius: 0 8px 8px 0; padding: 10px 12px; font-size: 13px; color: var(--ink-2); display: flex; flex-direction: column; gap: 6px; }
.guidance-label { display: flex; align-items: center; gap: 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); font-weight: 700; }
.guidance-label .icon { width: 14px; height: 14px; }
.pitfalls { background: #fff8f0; border-left: 3px solid #e08a30; border-radius: 0 8px 8px 0; padding: 10px 12px; font-size: 13px; }
.pitfalls .guidance-label { color: #b35c00; }
.assumptions { font-size: 12.5px; color: #6b4a00; }
.assumptions summary { cursor: pointer; font-weight: 600; }
.assumptions ul { margin-top: 6px; }
.context-kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 12.5px; }
.context-kv dt { color: var(--muted); }
.context-kv dd { margin: 0; font-weight: 500; }
.chat { display: flex; flex-direction: column; gap: 10px; }
.chat-empty { color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid #d7d1f5; background: var(--ai-50); color: var(--ai); border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 12.5px; cursor: pointer; font-weight: 500; }
.chip:hover { background: #e3dffa; }
.msg { display: flex; gap: 8px; align-items: flex-end; }
.msg.user { justify-content: flex-end; }
.msg-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--ai); color: #fff; display: grid; place-items: center; flex: none; }
.msg-avatar .icon { width: 15px; height: 15px; }
.msg-bubble { max-width: 82%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user .msg-bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot .msg-bubble { background: var(--ai-50); color: #2d2466; border-bottom-left-radius: 4px; }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ai); opacity: .4; animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: 1; } }
.assistant-input { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.assistant-input input { flex: 1; height: 38px; border: 1px solid #cfd9e1; border-radius: 9px; padding: 0 12px; font: inherit; }
.assistant-input input:focus { outline: none; border-color: var(--ai); box-shadow: 0 0 0 3px rgba(91,75,196,.14); }
.send-btn { width: 38px; height: 38px; border-radius: 9px; border: 0; background: var(--ai); color: #fff; display: grid; place-items: center; cursor: pointer; }
.send-btn:disabled { opacity: .45; cursor: not-allowed; }
.assistant-foot { font-size: 11.5px; color: var(--muted); padding: 0 16px 12px; }

/* ------------------------------------------------------------------ modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,37,48,.4); z-index: 80; }
.modal { position: fixed; z-index: 81; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(560px, 94vw); background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 8px; }
.modal-head h3 { flex: 1; font-size: 17px; }
.modal-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.modal-icon.brand, .modal-icon.info { background: var(--brand-50); color: var(--brand); }
.modal-icon.warn { background: var(--warn-50); color: var(--warn); }
.modal-body { padding: 6px 20px 16px; display: flex; flex-direction: column; gap: 10px; color: var(--ink-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line-2); background: #fafbfc; border-radius: 0 0 14px 14px; }
.transfer-visual { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.transfer-visual .phase-chip { height: 30px; font-size: 14px; padding: 0 14px; }

/* ------------------------------------------------------------------ reference & gaps */
.toc { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.toc-link { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 12.5px; color: var(--ink-2); }
.ref-table, .gap-group { margin-bottom: 16px; overflow: hidden; }
.ref-table .banner { margin: 12px 18px 0; }
.ref-table .section-notes { margin-bottom: 14px; }
.table-scroll { overflow-x: auto; padding: 12px 18px 16px; }
.gap-group h2 { display: flex; gap: 10px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }

/* ------------------------------------------------------------------ misc */
#blazor-error-ui { background: #fff4e5; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem .7rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "Došlo k chybě."; }

/* ------------------------------------------------------------------ narrow screens */
.mobile-bar, .sidebar-backdrop, .section-jump { display: none; }
.form-extra { display: flex; justify-content: flex-end; margin: 10px 0 0 250px; }

@media (max-width: 1100px) {
    .detail-grid { grid-template-columns: minmax(0, 1fr); }
    .timeline { position: static; }
    .form-layout { grid-template-columns: minmax(0, 1fr); }
    .section-nav { display: none; }
    .section-jump { display: block; margin-bottom: 12px; }
    .section-jump select { width: 100%; height: 40px; border: 1px solid #cfd9e1; border-radius: 8px; padding: 0 10px; font: inherit; background: #fff; color: var(--ink); }
    .fully-filled, .form-footer, .form-extra { margin-left: 0; }
    .stats { grid-template-columns: repeat(3, 1fr); }
    .hint-cards { grid-template-columns: 1fr; }
    .form-cards { grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
}

@media (max-width: 800px) {
    body { font-size: 15px; }
    .shell { display: block; }
    .mobile-bar { display: flex; position: sticky; top: 0; z-index: 50; height: 52px; align-items: center; gap: 8px; padding: 0 8px; background: #0d3f4c; color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
    .mobile-bar .icon-btn { color: #fff; width: 40px; height: 40px; }
    .mobile-bar .icon-btn .icon { width: 22px; height: 22px; }
    .brand-mini { color: #fff; font-weight: 700; font-size: 16px; text-decoration: none !important; }
    .env-dot { width: 9px; height: 9px; border-radius: 50%; background: #f5b83d; margin-left: auto; margin-right: 8px; box-shadow: 0 0 0 3px rgba(245,184,61,.25); }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; height: 100%; z-index: 90; transform: translateX(-105%); transition: transform .2s ease; width: 270px; }
    .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(15,37,48,.4); z-index: 85; }
    .sidebar-backdrop.open { display: block; }

    .page, .form-page { padding: 16px 14px 90px; }
    .page-head { flex-wrap: wrap; align-items: flex-start; }
    .page-actions { flex-wrap: wrap; }
    h1 { font-size: 21px; }
    .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat { padding: 10px 12px; }
    .stat-num { font-size: 20px; }
    .table-card { overflow-x: auto; }
    .table-tools { flex-wrap: wrap; }
    .search { width: 100%; }
    .gap-group, .ref-table { overflow-x: auto; }

    .patient-header { grid-template-columns: auto minmax(0, 1fr); gap: 12px 14px; padding: 14px; }
    .patient-header .avatar { width: 44px; height: 44px; border-radius: 10px; font-size: 15px; }
    .patient-id h1 { font-size: 18px; flex-wrap: wrap; row-gap: 0; }
    .patient-facts { gap: 4px 12px; font-size: 13px; }
    .patient-dx { grid-column: 1 / -1; border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 10px; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
    .patient-actions { grid-column: 1 / -1; }
    .patient-actions .btn { width: 100%; justify-content: center; }
    .phase-tabs { overflow-x: auto; padding-bottom: 4px; }
    .phase-tab { flex: none; min-width: 74px; padding: 7px 12px; }
    .form-card-foot { flex-wrap: wrap; }

    .form-header { position: static; margin: -16px -14px 12px; padding: 12px 14px; backdrop-filter: none; }
    .form-title-row h1 { font-size: 20px; flex-wrap: wrap; }
    .toolbar .btn-with-help, .toolbar-sep { display: none; }
    .form-section { scroll-margin-top: 64px; }
    .field { scroll-margin-top: 70px; grid-template-columns: minmax(0, 1fr) auto; padding: 10px 14px; }
    .field-control { grid-column: 1 / -1; grid-row: 2; }
    .section-head { padding: 12px 14px 10px; }
    .section-notes { margin: 10px 14px 0; }
    .info-note, .group { margin-left: 14px; margin-right: 14px; }
    .repeat { padding: 10px 14px 14px; }
    .form-footer { position: sticky; bottom: 0; z-index: 30; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px -14px 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: rgba(243,246,248,.97); border-top: 1px solid var(--line); box-shadow: 0 -4px 12px rgba(15,37,48,.08); }
    .form-footer .btn { justify-content: center; white-space: normal; height: auto; min-height: 42px; line-height: 1.2; padding: 6px 10px; text-align: center; }
    .fully-filled { flex-wrap: wrap; }
    .modal-foot { flex-wrap: wrap; }
    .modal-foot .btn { flex: 1 1 auto; justify-content: center; }
}

@media (max-width: 640px) {
    .col-opt { display: none; }
    .data-table td, .data-table th { padding: 10px; }
}

/* Czech labels: section headings keep the capitalised clinical look; RMG reference line in help */
.section-head h2 { text-transform: uppercase; }
.rmg-label { font-size: 12.5px; color: var(--muted); margin-top: -4px; }
.rmg-label span { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--ink-2); }

/* ---------- checks catalogue ---------- */
.rules-area { font-size: 15px; margin: 0; padding: 14px 18px 8px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: baseline; }
.rules-area:first-of-type { border-top: 0; }
.rule-list { padding: 0 12px 12px; display: grid; gap: 6px; }
.rule { border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; scroll-margin-top: 80px; }
.rule[open] { border-color: var(--brand-100); box-shadow: var(--shadow); }
.rule > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 9px 12px; flex-wrap: wrap; }
.rule > summary::-webkit-details-marker { display: none; }
.rule-id { font-size: 12px; font-weight: 700; color: var(--brand); min-width: 78px; }
.rule-title { flex: 1; min-width: 200px; font-weight: 600; }
.rule-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 4px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.tag-logic { background: var(--brand-50); color: var(--brand); }
.tag-criteria { background: var(--info-50); color: var(--info); }
.tag-medium { background: var(--warn-50); color: var(--warn); }
.rule-body { padding: 4px 14px 14px 100px; color: var(--ink-2); }
.rule-body p { margin: 8px 0; }
.rule-forms { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.rule-msg { display: flex; gap: 8px; align-items: flex-start; background: var(--warn-50); color: var(--warn); border-radius: 6px; padding: 8px 10px; }
.rule-msg .icon { flex: none; margin-top: 2px; }
.rule-sources ul, .rule-tests ul { margin: 4px 0 8px; padding-left: 18px; }
.rule-sources li { margin: 3px 0; }
.rule-sources q { font-style: italic; color: var(--ink); }
.src-kind { font-weight: 600; margin-right: 4px; }
.rule-tests li.hit::marker { color: var(--warn); }
.rule-tests li.pass::marker { color: var(--ok); }
.rule-ref { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-weight: 600; margin-left: 6px; padding: 1px 6px; border-radius: 4px; background: rgba(255,255,255,.7); border: 1px solid currentColor; color: inherit; text-decoration: none; white-space: nowrap; }
.rule-ref:hover { background: #fff; }
.pad { padding: 0 18px; }
@media (max-width: 640px) {
    .rule-body { padding-left: 14px; }
    .rule-id { min-width: 0; }
}

/* ---------- help discoverability ---------- */
.help-btn { color: var(--ai); opacity: .72; }
.help-btn:hover, .help-btn.active { opacity: 1; }
@keyframes help-pulse {
    0% { box-shadow: 0 0 0 0 rgba(91, 75, 196, .55); }
    70% { box-shadow: 0 0 0 9px rgba(91, 75, 196, 0); }
    100% { box-shadow: 0 0 0 0 rgba(91, 75, 196, 0); }
}
.help-unseen h1 .help-btn,
.help-unseen .section-head .help-btn,
.help-unseen .help-intro-icon { animation: help-pulse 1.8s ease-out infinite; opacity: 1; background: var(--ai-50); }
.help-intro {
    display: flex; gap: 14px; align-items: center; margin-bottom: 14px; padding: 14px 16px;
    border: 1px solid #d7d1f5; background: linear-gradient(90deg, var(--ai-50), #fff 70%); border-radius: var(--radius);
}
.help-intro-icon { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--ai-50); color: var(--ai); }
.help-intro-icon .icon { width: 24px; height: 24px; }
.help-intro-text { flex: 1; min-width: 0; }
.help-intro-text strong { color: var(--ai); font-size: 15px; }
.help-intro-text p { margin: 3px 0 0; color: var(--ink-2); }
.help-intro-actions { display: flex; gap: 6px; flex: none; }
.btn-ai { background: var(--ai); border-color: var(--ai); color: #fff; }
.btn-ai:hover:not(:disabled) { background: #4a3cae; }
@keyframes field-flash { 0%, 60% { background: var(--ai-50); box-shadow: inset 3px 0 0 var(--ai); } 100% { background: transparent; } }
.field.flash { animation: field-flash 2.2s ease-out; }
@media (max-width: 800px) {
    .help-intro { flex-wrap: wrap; }
    .help-intro-actions { width: 100%; justify-content: flex-end; }
}
@media (max-width: 640px) {
    .help-intro-icon { display: none; }
}

/* ---------- language switch & terms ---------- */
.lang-switch { display: flex; gap: 4px; margin: 0 14px 10px; padding: 4px; background: rgba(255,255,255,.06); border-radius: 8px; }
.lang-switch button { flex: 1; text-align: center; padding: 5px 0; border: 0; border-radius: 6px; background: none; font: inherit; font-size: 12px; font-weight: 700; letter-spacing: .05em; color: rgba(255,255,255,.7); cursor: pointer; }
.lang-switch button:hover { background: rgba(255,255,255,.1); color: #fff; }
.lang-switch button.on { background: rgba(255,255,255,.18); color: #fff; }
.terms-backdrop { z-index: 90; }
.terms-modal { z-index: 91; width: min(640px, 94vw); max-height: 92vh; overflow-y: auto; padding: 22px 24px 0; }
.terms-modal h2 { display: flex; align-items: center; gap: 10px; font-size: 19px; margin: 6px 0 12px; color: var(--brand); }
.terms-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--ink-2); line-height: 1.5; }
.terms-lang { display: flex; justify-content: flex-end; gap: 4px; }
.terms-lang button { font: inherit; font-size: 12px; padding: 3px 8px; border-radius: 6px; color: var(--muted); background: none; border: 1px solid transparent; cursor: pointer; }
.terms-lang button.on { border-color: var(--line); color: var(--ink); font-weight: 600; }
.terms-modal .modal-actions { position: sticky; bottom: 0; background: #fff; display: flex; justify-content: flex-end; padding: 14px 0 18px; margin-top: 14px; border-top: 1px solid var(--line-2); }
.context-kv-caption { margin-top: 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* ------------------------------------------------------------------ clinical manual
   Each .m-sheet is one page of the printed manual (A4, measurements in pt taken from the v3.0 PDF), so page
   numbers, running headers and footers match the original and the PDF download. */
@font-face { font-family: "Carlito"; src: url("manual/fonts/Carlito-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Carlito"; src: url("manual/fonts/Carlito-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Carlito"; src: url("manual/fonts/Carlito-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Carlito"; src: url("manual/fonts/Carlito-BoldItalic.ttf") format("truetype"); font-weight: 700; font-style: italic; font-display: swap; }
@font-face { font-family: "DejaVu Sans"; src: url("manual/fonts/DejaVuSans.ttf") format("truetype"); font-display: swap; }

.version-chip { font-size: 12px; font-weight: 600; color: var(--muted); background: #e7eef2; border-radius: 999px; padding: 2px 9px; vertical-align: middle; margin-left: 6px; }
.manual-search { width: 260px; }
.manual-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; align-items: start; }
.manual-toc { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; display: flex; flex-direction: column; gap: 1px; padding-right: 4px; }
.manual-toc .toc-link { display: flex; justify-content: space-between; gap: 8px; background: transparent; border: 0; border-radius: 7px; padding: 6px 10px; font-size: 12.5px; line-height: 1.3; color: var(--ink-2); }
.manual-toc .toc-link:hover { background: #e7eef2; color: var(--ink); }
.manual-toc .toc-link.on { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.manual-toc .toc-link .pg { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.manual-main { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.manual-results { width: 100%; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.manual-results h2 { font-size: 16px; margin-bottom: 6px; display: flex; gap: 8px; align-items: baseline; }
.manual-results .result { display: grid; grid-template-columns: 70px 180px minmax(0, 1fr); gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--ink-2); font-size: 13px; }
.manual-results .result:hover { background: #f0f4f7; }
.manual-results .result .pg { font-weight: 700; color: var(--brand); }
.manual-results .result .ch { color: var(--muted); }
.manual-results .result mark { background: #fff1a8; color: inherit; padding: 0 1px; }
.manual-pager { width: 100%; max-width: 595.32pt; display: flex; justify-content: space-between; gap: 10px; }

.m-sheet { position: relative; width: 595.32pt; max-width: 100%; min-height: 841.92pt; background: #fff; box-shadow: 0 1px 3px rgba(15,37,48,.14), 0 6px 18px rgba(15,37,48,.08);
    padding: 112pt 43pt 68pt 50pt; font-family: "Carlito", Calibri, sans-serif; font-size: 11pt; line-height: 16.1pt; color: #000; scroll-margin-top: 16px; text-rendering: geometricPrecision; font-kerning: none; }
.m-head { position: absolute; left: 0; right: 0; top: 0; height: 72pt; }
.m-head::after { content: ""; position: absolute; left: 15.6pt; right: 41.3pt; top: 71pt; border-top: .75pt solid #4A7EBB; }
.m-running { position: absolute; left: 50pt; top: 55.5pt; font-size: 12pt; line-height: 14.6pt; color: #454545; white-space: nowrap; }
.m-head img { position: absolute; left: 236pt; top: 14pt; width: 326pt; height: 48pt; }
.m-foot { position: absolute; left: 0; right: 0; bottom: 0; height: 60pt; color: #454545; }
.m-no { position: absolute; left: 0; right: 0; top: 5pt; text-align: center; font-size: 12pt; }
.m-ver { position: absolute; left: 50pt; top: 19pt; font-size: 11pt; line-height: 14pt; }

.m-body > :first-child { margin-top: 0 !important; }
.m-body > h1:first-child { margin-top: 4pt !important; }
/* vertical rhythm calibrated on the PDF: body line pitch 16.1pt, paragraph spacing 6pt, heading spacing below */
.m-body p { margin: 0 0 6pt; text-align: justify; hyphens: manual; }
.m-body h1, .m-body h2, .m-body h4 { color: #000; letter-spacing: 0; font-family: inherit; }
.m-body h1 { font-size: 24pt; line-height: 29pt; font-weight: 700; margin: 8pt 0 6pt; display: flex; }
.m-body h1 .no { flex: none; width: 35pt; }
.m-body h1:not(.plain) { padding-left: 28pt; }
.m-body h1:has(.no) { padding-left: 0; }
.m-body h1.plain { font-size: 26pt; line-height: 31pt; font-weight: 400; margin: 4pt 0 18pt; }
.m-body h2 { font-size: 16pt; line-height: 20pt; font-weight: 700; margin: 21pt 0 7pt; }
.m-body h4 { font-size: 14pt; line-height: 18pt; font-weight: 700; margin: 17pt 0 6pt; }
.m-body h3.m-field { position: relative; font-size: 14pt; line-height: 18pt; font-weight: 400; color: #0066CC; margin: 17pt 0 3pt; padding-left: 36pt; scroll-margin-top: 90px; }
.m-body h3.m-field::before { content: "▶"; position: absolute; left: 17pt; top: 0; font-size: 13pt; font-family: "DejaVu Sans", sans-serif; }
.m-body strong { font-weight: 700; }
.m-body mark { background: none; color: #FF0000; }
.m-body a { color: #0563C1; text-decoration: underline; }
.m-body ul { list-style: none; margin: 0 0 6pt; padding: 0; }
.m-body li > ul { margin: 6pt 0 6pt; }
.m-body h2 + h3.m-field { margin-top: 19pt; }
.m-body h3.m-field + p { margin-top: 6pt; }
.m-body li, .m-body li > p, .m-body p.left { position: relative; margin: 0; text-align: left; }
.m-body ul.l-check > li { margin-bottom: 6pt; }
.m-body ul.l-check > li { padding-left: 18pt; }
.m-body ul.l-check > li::before { content: "✓"; position: absolute; left: 0; font-family: "DejaVu Sans", sans-serif; font-size: 11pt; font-weight: 700; }
.m-body ul.l-square { margin-left: 18pt; }
.m-body ul.l-square > li { padding-left: 18pt; }
.m-body ul.l-square > li::before { content: "▪"; position: absolute; left: 0; top: -1pt; font-family: "DejaVu Sans", sans-serif; font-size: 8pt; }
.m-body ul.l-dash { margin-left: 54pt; }
.m-body li ul.l-dash { margin-left: 18pt; }
.m-body ul.l-dash > li { padding-left: 18pt; }
.m-body ul.l-dash > li::before { content: "-"; position: absolute; left: 0; }
.m-body li > ul.l-square { margin-left: 0; }
.m-body ol { list-style: none; margin: 0 0 6pt; padding: 0 0 0 36pt; }
.m-body ol > li { margin-bottom: 6pt; }
.m-body ol > li::before { content: counter(list-item) "."; position: absolute; left: -36pt; }
.m-body img { max-width: 100%; height: auto; display: block; margin: 6pt 0 10pt; }
.m-body p.update { margin: 0 0 6pt; padding: 2pt 6pt; border-left: 2.5pt solid #b45309; background: #fef3c7; font-size: 9pt; line-height: 11.5pt; text-align: left; font-style: italic; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.m-body p.sign { margin: 22pt 0 0 290pt; text-align: left; white-space: nowrap; }
.m-body img.icon { display: inline; vertical-align: -3pt; margin: 0 1pt; }
.m-body p.caption { font-style: italic; font-size: 10pt; line-height: 13pt; margin: 4pt 0 12pt; text-align: left; scroll-margin-top: 90px; }
.m-body table.m-table { border-collapse: collapse; margin: 0 auto 6pt 0; font-size: 11pt; line-height: 16.1pt; table-layout: fixed; }
.m-body table.m-table td { border: .5pt solid #000; padding: .2pt 5pt; vertical-align: top; text-align: left; overflow-wrap: anywhere; }
.m-body table.m-table td p { margin: 0; text-align: left; }
.m-body table.m-table.middle td { vertical-align: middle; }
.m-body table.m-table.has-header tr.head td { background: var(--head, #C9E4FF); }
.m-body .m-box { border: .5pt solid #000; padding: 6pt 8pt 0; margin: 6pt 0 8pt; }
.m-body p:has(> a.m-toc) { margin: 0; }
.m-body a.m-toc { display: flex; align-items: baseline; gap: 0; color: #000; text-decoration: none; margin: 0; line-height: 17.9pt; }
.m-body a.m-toc .no { flex: none; width: 22pt; }
.m-body a.m-toc .t { flex: none; max-width: calc(100% - 50pt); }
.m-body a.m-toc .dots { flex: 1; border-bottom: 1.2pt dotted #000; margin: 0 2pt; transform: translateY(-3pt); }
.m-body a.m-toc .n { flex: none; }
.m-body a.m-toc:hover .t { color: #0066CC; text-decoration: underline; }
.m-body h2#obsah, .m-body h2.h2:first-child { font-size: 20pt; font-weight: 400; padding-top: 30pt; margin-bottom: 8pt; }

.m-sheet.cover { padding: 0; }
.m-cover-logos { position: absolute; left: 30pt; top: 36pt; width: 536pt; height: 68pt; }
.m-cover-rule { position: absolute; left: 28pt; right: 28pt; top: 114pt; border-top: 3pt solid #4A7EBB; }
.m-cover-text { color: #548DD4; }
.m-cover-text > div { position: absolute; left: 0; right: 0; text-align: center; line-height: 1; }
.m-cover-text .c0 { top: 353pt; font-size: 48pt; font-weight: 700; }
.m-cover-text .c1 { top: 410pt; font-size: 22pt; }
.m-cover-text .c2 { top: 480pt; font-size: 48pt; }
.m-cover-text .c3 { top: 539pt; font-size: 48pt; }
.m-cover-text .c4 { top: 600pt; font-size: 16pt; }

@keyframes manual-flash { 0%, 60% { background: #fff1a8; box-shadow: 0 0 0 4pt #fff1a8; } 100% { background: transparent; box-shadow: 0 0 0 4pt transparent; } }
.m-sheet .flash { animation: manual-flash 2.4s ease-out; }
.m-sheet.flash { animation: none; }

@media (max-width: 1100px) {
    .manual-layout { grid-template-columns: minmax(0, 1fr); }
    .manual-toc { position: static; max-height: 220px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 8px; }
}
@media (max-width: 700px) {
    .manual-search { width: 100%; }
    .manual-results .result { grid-template-columns: 60px minmax(0, 1fr); }
    .manual-results .result .snip { grid-column: 1 / -1; }
    /* phone: the sheet reflows (page boundaries and numbers stay visible) */
    .m-sheet { width: 100%; min-height: 0; padding: 58px 16px 70px; font-size: 15px; line-height: 1.45; }
    .m-head { height: 44px; }
    .m-head::after { left: 0; right: 0; top: 44px; }
    .m-running { left: 16px; top: 14px; font-size: 13px; max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
    .m-head img { left: auto; right: 10px; top: 6px; width: 200px; height: auto; }
    .m-foot { height: 56px; }
    .m-ver { left: 16px; top: 22px; font-size: 12px; }
    .m-no { font-size: 13px; }
    .m-body h1 { font-size: 24px; } .m-body h1.plain { font-size: 26px; }
    .m-body h2 { font-size: 18px; } .m-body h3.m-field, .m-body h4 { font-size: 16px; }
    .m-body p, .m-body li { text-align: left; }
    .m-body table.m-table { width: 100% !important; font-size: 13px; line-height: 1.3; }
    .m-body ul.l-dash { margin-left: 18pt; }
    .m-sheet.cover { min-height: 70vh; }
    .m-cover-logos { left: 4%; width: 92%; height: auto; top: 20px; }
    .m-cover-rule { left: 4%; right: 4%; top: 80px; }
    .m-cover-text { position: relative; padding: 140px 12px 40px; display: flex; flex-direction: column; gap: 14px; }
    .m-cover-text > div { position: static; }
    .m-cover-text .c0, .m-cover-text .c2, .m-cover-text .c3 { font-size: 32px; }
    .m-cover-text .c1 { font-size: 16px; }
}

/* manual print view (/manual/print → PDF): exactly one A4 sheet per PDF page */
.manual-print { background: #fff; }
.manual-print .m-sheet { box-shadow: none; width: 595.32pt; height: 841.92pt; min-height: 0; max-width: none; overflow: hidden; break-after: page; }
@page { size: A4; margin: 0; }
@media print {
    html, body { background: #fff !important; margin: 0; }
    .manual-print .m-sheet { margin: 0; }
    #blazor-error-ui { display: none !important; }
}

/* ------------------------------------------------------------------ start-up (wwwroot/index.html, before the app runs) */
.app-loading { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--ink); }
.app-loading strong { font-size: 18px; }
.app-loading small { color: var(--muted); }
.app-loading-bar { width: min(240px, 60vw); height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.app-loading-bar i { display: block; height: 100%; width: var(--blazor-load-percentage, 8%); background: var(--brand); transition: width .2s ease; }
.app-start-failed { max-width: 560px; margin: 18vh auto 0; padding: 20px 22px; background: var(--err-50); border: 1px solid var(--err); border-radius: var(--radius); color: var(--ink); display: grid; gap: 8px; }
.app-start-failed[hidden], .app-loading[hidden] { display: none; }
