/* Служба записи и очереди: светлая тема по умолчанию, темная по переключателю. Без внешних шрифтов. */
/* Цвета, шрифт, скругления только из theme.css (подключается первой). Здесь короткие имена для своих правил.
   Объявлены на body, чтобы ночь (body.night) переопределяла их вместе с темой. */
body {
  --surface: var(--card); --surface2: var(--grey-soft); --faint: var(--muted);
  --primary: var(--accent); --primary-ink: var(--accent-ink); --primary-soft: var(--accent-soft); --gray-soft: var(--grey-soft);
  --r: var(--radius); --r-s: var(--radius-sm);
}
body.night { color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: var(--fs)/1.45 var(--font); }
body { min-height: 100vh; font-variant-numeric: tabular-nums; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: var(--fs-h1); line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: var(--fs-h2); margin: 0; font-weight: 650; }
h3 { font-size: var(--fs-h3); margin: 0; font-weight: 650; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- шапка */
#top { position: sticky; top: 0; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 24px 0;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 650; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
#lab-name { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.search { position: relative; flex: 1; max-width: 520px; min-width: 220px; }
.search input { width: 100%; height: var(--h-ctl); padding: 0 14px 0 38px; border-radius: var(--radius-btn); border: 1px solid var(--line2);
  background: var(--surface2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238a9a9c' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 4 4'/%3E%3C/svg%3E") 14px 50% no-repeat;
  color: var(--ink); font: inherit; }
.search input:focus { background-color: var(--surface); border-color: var(--primary); outline: 2px solid var(--primary); outline-offset: 1px; }
.dropdown { position: absolute; top: 46px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); max-height: 60vh; overflow: auto; z-index: 40; }
.dropdown a { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; color: var(--ink); border-bottom: 1px solid var(--sep); }
.dropdown a:hover, .dropdown a.on { background: var(--primary-soft); text-decoration: none; }
#nav { display: flex; gap: 4px; flex-basis: 100%; min-width: 0; overflow: visible; margin: 0 -8px; align-items: stretch; }   /* не hidden: иначе список «Еще» обрезается */
.nav-items { display: flex; gap: 4px; flex: 0 1 auto; min-width: 0; overflow: hidden; }
.nav-more { position: relative; flex: none; }
.nav-more-btn { height: 100%; padding: 9px 12px 11px; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; }
.nav-more-btn:hover { color: var(--ink); }
.nav-drop { top: 100%; left: auto; right: 0; min-width: 220px; padding: 6px 0; }
.nav-drop a { display: flex; padding: 9px 16px; border: 0; border-left: 3px solid transparent; }
.nav-drop a.on { border-left-color: var(--primary); }
.pc-more { position: relative; }
.pc-drop { top: calc(100% + 4px); left: auto; right: 0; min-width: 240px; z-index: 30; }
.ev-hl { outline: 3px solid var(--amber); outline-offset: 2px; background: var(--amber-soft) !important; transition: background .6s, outline-color .6s; }
#nav a { padding: 9px 12px 11px; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; }
#nav a:hover { text-decoration: none; color: var(--ink); }
#nav a.on { color: var(--primary); border-bottom-color: var(--primary); }
#nav .cnt { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--red); color: var(--accent-ink);
  font-size: 13px; line-height: 18px; text-align: center; }
.me { margin-left: auto; display: flex; align-items: center; gap: 10px; white-space: nowrap; color: var(--muted); position: relative; }
/* аватар с меню: имя и роль, вид, ночь, войти как, выход (план дизайна: 4 элемента справа вместо 7) */
#me-ava { width: var(--h-ctl); height: var(--h-ctl); border-radius: 50%; border: 1px solid var(--line2); background: var(--violet-soft); color: var(--violet); font: inherit; font-weight: 650; cursor: pointer; }
#me-ava:hover { border-color: var(--accent); }
#me-drop { top: calc(100% + 6px); left: auto; right: 0; min-width: 300px; padding: 10px; display: flex; flex-direction: column; gap: 8px; white-space: normal; }
#me-drop .me-who { padding: 4px 6px 8px; border-bottom: 1px solid var(--line); color: var(--ink); line-height: 1.3; }
#me-drop .me-who small { display: block; color: var(--muted); }
#me-drop .btn, #me-drop select { width: 100%; justify-content: flex-start; height: var(--h-ctl); font-size: inherit; }
#me-drop .me-row { display: flex; gap: 8px; }
#me-drop .me-row .btn { flex: 1; }
#me-drop .me-row .icon { flex: none; width: var(--h-ctl); height: var(--h-ctl); }
#lab-switch, #demo-as { width: auto; max-width: 300px; height: var(--h-sm); border-radius: var(--radius-btn); border: 1px solid var(--line2); background: var(--surface2); color: var(--ink); font: inherit; padding: 0 8px; }
#demo-as { border-color: var(--amber); }   /* демо-сервер: переключатель ролей заметен */

/* ---------- кнопки и поля */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--h-ctl); padding: 0 16px; border-radius: var(--radius-btn);
  border: 1px solid var(--line2); background: var(--surface); color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; transition: transform .16s ease-out; }
.btn:active { transform: scale(.96); }
.btn svg.ic { width: 20px; height: 20px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { height: var(--h-sm); padding: 0 10px; font-size: var(--fs-cap); }
.btn.big { height: 52px; padding: 0 24px; font-size: var(--fs-h3); }
.btn[disabled] { opacity: .5; cursor: default; }
.icon { width: 40px; height: 40px; border-radius: var(--radius-btn); border: 1px solid var(--line2); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 17.5px; display: inline-flex; align-items: center; justify-content: center; }
.icon:hover { border-color: var(--accent); }
svg.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -6px; }
input[type=text], input[type=tel], input[type=password], input[type=number], input[type=search]:not(#q), select, textarea {
  height: var(--h-ctl); padding: 0 10px; border-radius: var(--radius-btn); border: 1px solid var(--line2); background: var(--surface); color: var(--ink); font: inherit; width: 100%; }
textarea { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 2px solid var(--primary); outline-offset: 1px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-cap); color: var(--muted); }
label.f > span { font-weight: 550; }
label.chk { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.sp { flex: 1; }

/* ---------- раскладка экранов */
#app { padding: 22px 24px 60px; max-width: 1480px; margin: 0 auto; }
body.cal-wide #app { max-width: none; padding-left: 12px; padding-right: 12px; }
.boot { padding: 80px; text-align: center; color: var(--muted); }
.page-h { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-h .sub { color: var(--muted); margin-top: 4px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 18px; align-items: start; }
.cols.c3 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.cols > * { min-width: 0; }   /* широкая таблица листается внутри панели, а не раздвигает страницу */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.panel > .ph { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.panel > .ph select { max-width: 100%; }
.panel > .ph .n { color: var(--muted); font-weight: 500; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > .ph { padding: 14px 18px 0; }
.empty { color: var(--faint); padding: 10px 0; }
/* пустое состояние с действием: значок линией, текст, кнопка (план дизайна, шаг 6) */
.empty.act { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 12px; text-align: center; }
.empty.act svg.ic { width: 40px; height: 40px; stroke-width: 1.5; opacity: .7; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--sep); }
.list > li:first-child { border-top: 0; }
.list .main { flex: 1; min-width: 0; }
.list .t { font-weight: 600; }
.list .s { color: var(--muted); font-size: 15px; }
.pname { color: var(--ink); font-weight: 600; }
.pname:hover { color: var(--primary); }

/* ---------- плашки, приоритет, статус */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 11px; font-size: 14px; font-weight: 600; line-height: 20px;
  white-space: nowrap; background: var(--gray-soft); color: var(--muted); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.violet { background: var(--violet-soft); color: var(--violet); }
.prio { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 26px; padding: 0 8px; border-radius: 13px;
  color: var(--accent-ink); font-weight: 700; font-size: 15px; }
.prio.none { background: transparent; border: 1.5px dashed var(--faint); color: var(--faint); }
.st { display: inline-block; padding: 2px 10px; border-radius: 6px; font-size: 14.5px; font-weight: 600; background: var(--gray-soft); color: var(--muted); white-space: nowrap; }
.st.g-intake { background: var(--gray-soft); color: var(--ink); }
.st.g-queue { background: var(--blue-soft); color: var(--blue); }
.st.g-plan { background: var(--primary-soft); color: var(--primary); }
.st.g-hosp { background: var(--green-soft); color: var(--green); }
.st.g-review { background: var(--violet-soft); color: var(--violet); }
.st.g-seeg { background: var(--violet-soft); color: var(--violet); }
.st.g-after { background: var(--amber-soft); color: var(--amber); }
.st.g-closed { background: var(--gray-soft); color: var(--faint); }

/* ---------- таблицы */
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 14.5px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line);
  background: var(--surface2); position: sticky; top: 0; white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--sep); vertical-align: middle; }
table.t.compact th, table.t.compact td { padding: 8px 7px; }   /* узкие таблицы в трехколоночной сетке сводки: без переполнения панели */
table.t.compact th { white-space: normal; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface2); }
table.t td.num, table.t th.num { text-align: right; }
.wrap-t { overflow: auto; max-height: calc(100vh - 230px); }
.wrap-t.wrap-x { max-height: none; overflow-y: visible; max-width: 100%; }
.idx { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.idx .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--sep); overflow: hidden; }
.idx .bar { position: relative; top: auto; padding: 0; box-shadow: none; border: 0; cursor: auto; z-index: auto; }   /* полоса срочности не календарная полоса: остается в ячейке таблицы */
.idx .bar i { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.idx .bar i.over { background: var(--red); }

/* ---------- фильтры и вкладки */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--primary); border-color: var(--primary); }
.tabs button { padding: 10px 14px; color: var(--muted); font: inherit; font-weight: 600; background: none; border: 0; border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; cursor: pointer; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--primary); border-color: var(--primary); }
.tabs a .n { color: var(--faint); font-weight: 500; margin-left: 4px; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 140px; }
.filters input[type=checkbox] { min-width: 0; width: 18px; height: 18px; }

/* ---------- карточка пациента */
.pc-head { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px 20px; }
.pc-head .who { flex: 1; min-width: min(300px, 100%); }
.pc-ava { width: 52px; height: 52px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; font-weight: 650; font-size: var(--fs-h3); flex: none; }
/* следующий шаг под полосой пути: одна залитая кнопка на экране */
.next { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding: 14px 18px; border-radius: 12px; background: var(--accent-soft); flex-wrap: wrap; }
.next > svg.ic { width: 28px; height: 28px; color: var(--accent); }
.next .t { flex: 1; min-width: 220px; display: flex; flex-direction: column; }
.next .t b { font-size: var(--fs-h3); }
.next .t span { color: var(--muted); font-size: var(--fs-sm); }
.pc-head .meta { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; color: var(--muted); }
.pc-head .meta b { color: var(--ink); font-weight: 600; }
.pc-head .kpis { display: flex; gap: 22px; }
.kpi .v { font-size: var(--fs-h1); font-weight: 650; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 14.5px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.badges .chip, .list .chip { white-space: normal; }

/* путь пациента: линия этапов */
.path { margin: 14px 0 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 20px 14px; }
.track { display: flex; align-items: flex-start; overflow-x: auto; padding-bottom: 6px; }
.track .stp { position: relative; flex: 1 0 110px; text-align: center; font-size: var(--fs-cap); color: var(--faint); padding-top: 24px; }
.track .stp::before { content: ""; position: absolute; top: 7px; left: 0; right: 0; height: 3px; background: var(--line); }
.track .stp:first-child::before { left: 50%; }
.track .stp:last-child::before { right: 50%; }
.track .stp::after { content: ""; position: absolute; top: 1px; left: calc(50% - 8px); width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--line); box-sizing: border-box; }
.track .stp.done { color: var(--muted); }
.track .stp.skip { color: var(--faint); opacity: .8; }
.track .stp.done::before, .track .stp.done::after { background: var(--primary); border-color: var(--primary); }
.track .stp.skip::after { background: var(--surface); }
.track .stp.cur { color: var(--ink); font-weight: 700; }
.track .stp.cur::before { background: linear-gradient(90deg, var(--primary) 50%, var(--line) 50%); }
.track .stp.cur::after { width: 22px; height: 22px; top: -2px; left: calc(50% - 11px); background: var(--primary); border-color: var(--primary-soft); border-width: 5px; }
.track .stp .d { display: block; font-weight: 400; color: var(--faint); font-size: var(--fs-cap); }
.moves { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.moves .lbl { color: var(--muted); margin-right: 4px; }

.pc-body { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 18px; align-items: start; }
.kv { display: grid; grid-template-columns: 200px 1fr; gap: 8px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* лента */
.feed { display: flex; flex-direction: column; gap: 10px; max-height: 520px; overflow: auto; padding-right: 4px; }
.msg { padding: 10px 12px; border-radius: 10px; background: var(--surface2); border: 1px solid var(--sep); }
.msg .h { display: flex; gap: 8px; align-items: baseline; font-size: 14.5px; color: var(--muted); margin-bottom: 3px; flex-wrap: wrap; }
.msg .h b { color: var(--ink); }
.msg.question { border-left: 3px solid var(--amber); }
.msg.request { border-left: 3px solid var(--blue); }
.msg.over { border-left-color: var(--red); background: var(--red-soft); }
.msg.reply { margin-left: 26px; }
.msg .txt { white-space: pre-wrap; word-break: break-word; }
.composer { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }

/* ---------- календарь */
.cal-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: var(--radius-btn); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 0 14px; height: calc(var(--h-ctl) - 2px); font: inherit; color: var(--muted); cursor: pointer; font-weight: 550; }
.seg button.on { background: var(--primary-soft); color: var(--primary); }
.cal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; user-select: none; position: relative; }
.cal-grid { display: grid; min-width: 100%; position: relative; }
/* перевод на другую койку: изогнутый пунктир со стрелкой поверх полос, клики проходят насквозь */
svg.mlinks { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 4; overflow: visible; }
svg.mlinks path { fill: none; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 5 4; opacity: .75; }
svg.mlinks path.ah { stroke-dasharray: none; stroke-width: 2.2; }
.bar.mvout { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.bar.mvin { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cal .hd { position: sticky; top: 0; z-index: 3; background: var(--surface2); border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: center;
  font-size: 14px; color: var(--muted); border-left: 1px solid var(--sep); }
.cal .hd b { display: block; color: var(--ink); font-size: 15.5px; }
.cal .hd.today b { color: var(--primary); }
.cal .hd.hol { background: var(--red-soft); color: var(--red); }
.cal .hd.off { background: repeating-linear-gradient(135deg, var(--surface2), var(--surface2) 5px, var(--sep) 5px, var(--sep) 7px); }
.cal .bedh { position: sticky; left: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--sep); border-right: 1px solid var(--line);
  padding: 0 12px; display: flex; flex-direction: column; justify-content: center; font-weight: 600; }
.cal .bedh small { font-weight: 400; }
.cal .corner { position: sticky; left: 0; top: 0; z-index: 4; background: var(--surface2); border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  padding: 6px 12px; font-size: 14px; color: var(--muted); display: flex; align-items: flex-end; }
.cal .lane { position: relative; border-bottom: 1px solid var(--sep); height: 58px; }
.cal .cell { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--sep); }
.cal .cell.hol { background: var(--red-soft); }
.cal .cell.off { background: repeating-linear-gradient(135deg, transparent, transparent 6px, var(--sep) 6px, var(--sep) 7px); opacity: .7; }
.cal .cell.today { background: var(--accent-soft); }
.cal .sel { position: absolute; top: 4px; bottom: 4px; background: var(--primary-soft); border: 2px dashed var(--primary); border-radius: 8px; z-index: 1; }
.bar { position: absolute; top: 6px; height: 46px; border-radius: 8px; padding: 4px 8px; color: var(--accent-ink); font-size: 14px; line-height: 1.3; overflow: hidden;
  cursor: grab; z-index: 2; box-shadow: var(--shadow); border-left: 5px solid var(--card); white-space: nowrap; }
.bar b { display: block; font-size: 15px; text-overflow: ellipsis; overflow: hidden; }
.bar.cat { border: 1px solid transparent; border-left: 5px solid var(--muted); box-shadow: var(--shadow); }
.bar.cat small { color: inherit; opacity: .9; font-weight: 400; }
.bar.cat.admitted { box-shadow: 0 0 0 2px var(--green) inset, var(--shadow); }
.bar.cat.blk { opacity: .9; }
.lane.staff { background: var(--surface2); }
.bar.admitted { box-shadow: 0 0 0 2px var(--green) inset, var(--shadow); }
.bar.discharged { opacity: .55; }
.bar.warn { outline: 2px solid var(--amber); outline-offset: 1px; }
.bar.conflict { outline: 2px solid var(--red); top: 30px; height: 24px; }
.bar.drag { opacity: .8; cursor: grabbing; z-index: 5; box-shadow: var(--shadow); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 14.5px; margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* месяц */
.mcal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.mhead { display: flex; background: var(--surface2); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 14px; font-weight: 600; }
.mhead > div { flex: 1; padding: 6px 8px; border-left: 1px solid var(--sep); }
.mhead > div:first-child { border-left: 0; }
.mwn { flex: none !important; width: 44px; text-align: center; color: var(--faint); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 6px !important; gap: 4px; }
.mw { display: flex; border-bottom: 1px solid var(--line); position: relative; }
.mw:last-child { border-bottom: 0; }
.mdays { flex: 1; position: relative; display: flex; }
.md { flex: 1; position: relative; border-left: 1px solid var(--sep); padding: 4px 6px; min-width: 0; }
.md:first-child { border-left: 0; }
.md.out { background: var(--surface2); }
.md.out .dn { color: var(--faint); }
.md.hol { background: var(--red-soft); }
.md.off:not(.hol) { background: repeating-linear-gradient(135deg, transparent, transparent 8px, var(--sep) 8px, var(--sep) 9px); }
.md .dn { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 4px; border-radius: 13px; font-weight: 600; font-size: 15px; }
.md .dn.today { background: var(--primary); color: var(--primary-ink); }
.md .madd { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; opacity: 0; }
.md:hover .madd, .md:focus-within .madd, .madd:focus-visible { opacity: 1; }
.bar:focus-visible, .mbar:focus-visible, [role=button]:focus-visible { outline: 3px solid var(--ink); outline-offset: 1px; z-index: 5; }
.md .madd:hover { color: var(--primary); border-color: var(--primary); }
.mmore { position: absolute; left: 4px; right: 4px; height: 22px; border: 0; background: transparent; color: var(--primary); font: inherit; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer; padding: 0 4px; }
.mmore:hover { text-decoration: underline; }
.mbar { position: absolute; height: 22px; line-height: 20px; padding: 0 6px; border-radius: 6px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
  border: 1px solid transparent; border-left-width: 4px; color: var(--ink); box-sizing: border-box; }
.mbar.oms { background: var(--blue-soft); border-color: var(--blue-soft); border-left-color: var(--blue); }
.mbar.pmu { background: var(--violet-soft); border-color: var(--violet-soft); border-left-color: var(--violet); }
.mbar.special { background: var(--red-soft); border-color: var(--red-soft); border-left-color: var(--red); }
.mbar.mri { background: var(--amber-soft); border-color: var(--amber-soft); border-left-color: var(--amber); }
.mbar.adm { box-shadow: 0 0 0 2px var(--green) inset; }
/* поступил: не только зеленая рамка, но и галочка (читается и программой чтения с экрана) */
.mbar.adm::before, .bar.admitted > b::before { content: "✓ "; content: "✓ " / "поступил, "; font-weight: 800; }
.prio-help { margin: 0 0 10px; }
.prio-help summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.prio-help ul { margin: 6px 0 0; padding-left: 20px; }
.prio-help li { margin: 3px 0; }
.mbar.done { opacity: .55; }
.mbar.cl { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-width: 1px; }
.mbar.cr { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.mbar:hover { filter: brightness(.96); z-index: 2; }
/* продолжение с прошлой недели или месяца: полоска у края и стрелка в начале заливки */
.bar.cl, .mbar.cl { border-left: 3px solid currentColor !important; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.bar.cr { border-top-right-radius: 0; border-bottom-right-radius: 0; }
i.cont { font-style: normal; font-weight: 800; margin-right: 4px; }
/* выписавшиеся и отлежавшие: штриховка поверх цвета категории, чуть бледнее; без галочки обычная заливка */
.bar.past, .mbar.done { opacity: 1; }
.hatchdone .bar.past, .hatchdone .mbar.done { opacity: .78; }
.hatchdone .bar.past::after, .hatchdone .mbar.done::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: repeating-linear-gradient(135deg, rgba(255,255,255,.42) 0 4px, transparent 4px 10px); }
/* сложности с поступлением: красная рамка */
.bar.iss, .mbar.iss { outline: 2.5px solid var(--red); outline-offset: 1px; }
.legend i.mbar { position: static; display: inline-block; width: 14px; height: 14px; padding: 0; border-left-width: 3px; }
/* шаг 10 дизайна: легенда с фильтром над сеткой, линия «сейчас», полоса занятости коек в клетке месяца */
.cal-legend { margin: 0 0 8px; gap: 6px 10px; }
.cal-legend .leg { display: inline-flex; align-items: center; gap: 6px; height: var(--h-sm); padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); font: inherit; font-size: 14.5px; cursor: pointer; }
.cal-legend .leg:hover { border-color: var(--accent); }
.cal-legend .leg.off { color: var(--muted); background: var(--bg); text-decoration: line-through; }
.cal-legend .leg.off i { opacity: .35; }
.cal-legend .leg.all { border-style: dashed; color: var(--accent); }
.cal-legend .leg i.mbar { margin: 0; }
.bar.hid, .mbar.hid { opacity: .18 !important; filter: grayscale(1); pointer-events: none; }
.bar.hid::after, .mbar.hid::after { display: none; }
.nowline { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--coral); z-index: 2; pointer-events: none; }
.nowline span { position: sticky; top: 0; display: inline-block; transform: translateX(-50%); background: var(--coral); color: var(--coral-ink); font-size: 11px; line-height: 16px; padding: 0 6px; border-radius: 0 0 6px 6px; white-space: nowrap; }
.md .mocc { position: absolute; left: 6px; right: 6px; bottom: 3px; height: 4px; border-radius: 2px; background: var(--grey-soft); overflow: hidden; }
.md .mocc b { display: block; height: 100%; background: var(--seq-3); }
.md .mocc.full b { background: var(--coral); }
.md.out .mocc { display: none; }
.md .mocc { right: 34px; }
.md .mocc-n { position: absolute; right: 6px; bottom: 0; font-size: 11px; line-height: 10px; color: var(--muted); }   /* занято коек числом (31.10.2026) */
.md.out .mocc-n { display: none; }
.legend .mbar-occ { display: inline-block; width: 22px; height: 4px; border-radius: 2px; background: var(--seq-3); vertical-align: middle; margin-right: 4px; }

/* ---------- техник: койки */
.beds { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.bed { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-height: 200px; }
.bed.free { background: var(--surface2); border-style: dashed; }
.bed .bn { display: flex; align-items: baseline; gap: 8px; color: var(--muted); font-weight: 600; }
.bed .pn { font-size: 20px; font-weight: 650; }
.bed .sz { display: flex; align-items: baseline; gap: 8px; }
.bed .sz .v { font-size: 37.5px; font-weight: 700; line-height: 1; }
.bed .btn.sz-btn { height: 56px; font-size: 20px; background: var(--coral); border-color: var(--coral); color: var(--coral-ink); margin-top: auto; font-weight: 700; }
.trace { height: 26px; width: 100%; color: var(--primary); opacity: .55; }

/* ---------- сводка */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.metric .v { font-size: var(--fs-num); font-weight: 700; line-height: 1.1; }
.metric .l { color: var(--muted); font-size: 15px; margin-top: 2px; }
.metric .v small { font-size: 16.5px; font-weight: 500; }
svg.bars text { fill: var(--muted); font-size: 14px; font-family: var(--font); }
svg.bars .val { fill: var(--ink); font-weight: 600; }

/* ---------- мастер и вход */
.center { min-height: calc(100vh - 80px); display: flex; align-items: center; justify-content: center; }
.login { width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 30px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.login .lg { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.login .lg img { width: 46px; height: 46px; border-radius: 10px; }
.login .lg h1.lg-t { font-size: 20px; }
.err { color: var(--red); font-size: 15.5px; min-height: 20px; }
.wiz { max-width: 980px; margin: 0 auto; }
.wiz-steps { display: flex; gap: 4px; margin: 16px 0 18px; flex-wrap: wrap; }
.wiz-steps span { padding: 6px 12px; border-radius: 16px; font-size: 15px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); }
.wiz-steps span.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.wiz-steps span.done { color: var(--primary); border-color: var(--primary); }
.edit-t { width: 100%; border-collapse: collapse; }
.edit-t th { text-align: left; font-size: 14.5px; color: var(--muted); font-weight: 600; padding: 6px; }
.edit-t td { padding: 4px 6px; vertical-align: top; }
.edit-t input[type=color] { width: 44px; height: 36px; border: 1px solid var(--line); border-radius: 6px; background: none; padding: 2px; }
.hint { color: var(--muted); font-size: 15px; margin: 4px 0 12px; }

/* ---------- окно, уведомления */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(680px, 94vw); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
dialog.wide { width: min(1000px, 96vw); }
dialog.full { width: min(1200px, 98vw); height: 94vh; max-height: 94vh; }
dialog.full form { height: 100%; display: flex; flex-direction: column; }
dialog.full .dlg-b { flex: 1; overflow: auto; }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
/* документы при поступлении: весь пакет в одном окне без прокрутки */
.pk-head { display: grid; grid-template-columns: 1fr 260px; gap: 16px; align-items: end; }
.pk-head .muted { margin-top: 2px; }
.pk-grid { display: grid; grid-template-columns: 1fr 1fr; grid-auto-flow: column; gap: 2px 18px; margin-top: 12px; border-top: 1px solid var(--sep); padding-top: 8px; }
.pk-item { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 8px; cursor: pointer; min-height: 44px; }
.pk-item:hover { background: var(--surface2); }
.pk-item input { width: 22px; height: 22px; flex: none; }
.pk-item small { display: block; color: var(--muted); font-size: 13.5px; }
.pk-foot { display: flex; gap: 16px; align-items: end; margin-top: 10px; border-top: 1px solid var(--sep); padding-top: 10px; }
.pk-foot .f { flex: 1; } .pk-foot .pk-copies { flex: 0 0 90px; }
@media (max-width: 700px) { .pk-head, .pk-grid { grid-template-columns: 1fr; grid-auto-flow: row; } .pk-foot { flex-wrap: wrap; } }
.dlg-h { display: flex; align-items: center; gap: 10px; padding: 18px 22px 10px; }
.dlg-b { padding: 6px 22px 16px; max-height: 70vh; overflow: auto; }
.dlg-f { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 22px 18px; border-top: 1px solid var(--sep); }
.warn-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.warn-list li { padding: 8px 12px; border-radius: 8px; background: var(--amber-soft); color: var(--amber); font-weight: 550; }
.warn-list li.error { background: var(--red-soft); color: var(--red); }
#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 550; }
.toast.err { background: var(--red); color: var(--accent-ink); display: flex; align-items: center; gap: 12px; }
.toast .toast-x { flex: none; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; font-size: 17px; cursor: pointer; }
.toast .toast-x:hover { background: rgba(0, 0, 0, .15); }
.dlg-err { margin: 0; padding: 8px 22px 0; font-weight: 550; }
.drop { border: 2px dashed var(--line); border-radius: var(--r); padding: 34px; text-align: center; color: var(--muted); background: var(--surface); }
.drop.over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.dup { border: 1px solid var(--amber); background: var(--amber-soft); border-radius: 10px; padding: 10px 12px; margin-top: 10px; }
.dup a { font-weight: 650; }
.diary-rec { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; padding: 10px 0; border-top: 1px solid var(--sep); align-items: start; }
.diary-rec .ph { color: var(--muted); font-style: italic; }
.diary-rec.unc { background: var(--amber-soft); }
.tl { display: flex; flex-direction: column; gap: 0; }
.tl .d { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 12px; padding: 7px 0; border-top: 1px solid var(--sep); }
pre.copy { white-space: pre-wrap; background: var(--surface2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font: 14px/1.5 var(--font); max-height: 50vh; overflow: auto; }

@media (max-width: 1100px) {
  .pc-body { grid-template-columns: minmax(0, 1fr); }
  #top { flex-wrap: wrap; }
  .search { order: 5; max-width: none; flex-basis: 100%; }
}
@media (max-width: 700px) {
  #app { padding: 14px 16px 40px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .cols, .cols.c3 { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: 1fr; }
  #nav { max-width: 100%; }                                      /* лишние пункты уходят в «Еще», прокрутка обрезала бы его список */
  .me { flex-wrap: wrap; white-space: normal; min-width: 0; }   /* «Выход» не уезжает за край узкого окна */
  #me-name { min-width: 0; overflow-wrap: anywhere; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* корзина PDF: панель справа, список по пациентам, постраничный редактор */
#pdfb-btn .pdfb-cnt { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--primary); color: #fff; font-size: 12px; line-height: 18px; text-align: center; margin-left: 4px; }
.pdfb { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); z-index: 60; background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.pdfb.drop { outline: 3px dashed var(--primary); outline-offset: -8px; }
.pdfb-h { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 17px; }
.pdfb-h .n { color: var(--muted); font-weight: 600; }
.pdfb .sp { flex: 1; }
.pdfb .ib { border: 1px solid transparent; background: transparent; color: var(--ink); border-radius: 6px; padding: 2px 7px; font: inherit; cursor: pointer; }
.pdfb .ib:hover:not([disabled]) { border-color: var(--line); background: var(--primary-soft); }
.pdfb .ib[disabled] { opacity: .3; cursor: default; }
.pdfb-tools { display: flex; flex-wrap: wrap; gap: 5px; padding: 10px 14px; border-bottom: 1px solid var(--sep); }
.pdfb-busy { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--primary-soft); color: var(--ink); font-size: 14px; }
.pdfb-busy i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--primary); border-right-color: transparent; animation: pdfbspin .8s linear infinite; }
@keyframes pdfbspin { to { transform: rotate(360deg); } }
.pdfb-list { flex: 1; overflow: auto; padding: 6px 8px 12px; }
.pdfb-only { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--primary-soft); color: var(--ink); font-size: 15px; font-weight: 600; }
.pdfb-only span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdfb-g { margin: 10px 6px 4px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: none; }
.pdfb-it { display: flex; align-items: center; gap: 6px; padding: 7px 8px; border: 1px solid var(--sep); border-radius: 8px; margin: 4px 0; background: var(--surface); cursor: grab; }
.pdfb-it.on { border-color: var(--primary); background: var(--primary-soft); }
.pdfb-it.drag { opacity: .45; }
.pdfb-it .main { flex: 1; min-width: 0; }
.pdfb-it .main b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.pdfb-it .main small { color: var(--muted); }
.pdfb-foot { border-top: 1px solid var(--line); padding: 10px 14px; display: grid; gap: 6px; }
.pdfe { display: grid; gap: 12px; }
.pdfe-doc { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.pdfe-new { border-style: dashed; }
.pdfe-h { margin-bottom: 6px; } .pdfe-h small { color: var(--muted); margin-left: 6px; }
.pdfe-pages { display: flex; flex-wrap: wrap; gap: 8px; min-height: 120px; align-items: flex-start; }
.pdfe-pg { border: 1px solid var(--sep); border-radius: 6px; padding: 4px; background: var(--surface); cursor: grab; }
.pdfe-pg.drag { opacity: .4; }
.pdfe-c { width: 120px; height: 160px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #fff; }
.pdfe-c canvas { max-width: 120px; max-height: 160px; transition: transform .15s; }
.pdfe-b { display: flex; align-items: center; gap: 4px; margin-top: 3px; font-size: 13px; }
.pdfe-b span { flex: 1; color: var(--muted); }
.pdfe-b button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 5px; padding: 0 6px; cursor: pointer; }/* окно корзины (/pdf/index.html, в FUSER.exe отдельное окно): та же панель во весь экран */
body.pdfb-page { margin: 0; background: var(--bg, var(--surface)); }
.pdfb-page .pdfb { position: static; width: auto; height: 100vh; border-left: 0; box-shadow: none; }
.pdfb-page .pdfb-list { padding: 8px 14px 16px; }
/* история пациента: медицина ярко, общение и деньги спокойнее (заказчик 30.10.2026) */
.list li.ev-med { border-left: 3px solid var(--accent); padding-left: 8px; }
.list li.ev-comm b, .list li.ev-money b, .list li.ev-other b { font-weight: 600; color: var(--muted); }
.btn[data-hf][aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
/* календарь по часам (замечания 30.10.2026): сетка часов, подписи через 2 часа */
.lane.hourly { background-image: repeating-linear-gradient(90deg, transparent 0, transparent calc(var(--hw) - 1px), var(--line) calc(var(--hw) - 1px), var(--line) var(--hw)); }
.lane.hourly .cell { background: transparent; }
.cal .hd .hrs { display: grid; grid-template-columns: repeat(12, 1fr); font-size: 11px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.cal .hd .hrs span { text-align: left; padding-left: 2px; border-left: 1px solid var(--line); }
/* демо: выбор роли после входа (31.10.2026) */
.demo-roles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-top: 10px; }
.demo-role { flex-direction: column; align-items: flex-start; gap: 2px; min-height: 56px; padding: 8px 12px; text-align: left; }
.demo-role small { font-weight: 400; color: var(--muted); }
.demo-role.primary small { color: inherit; opacity: .85; }
