/* «Стационар»: дополнение к общему стилю «Резерва» (/static/common/style.css);
   цвета — переменные темы /static/shared/theme.css. Статусные цвета листа
   (просрочка — красный, выполнено — зелёный) розовыми не делаются. */

/* Цвета подсветок листа и доски (дополняют тему). */
:root {
  --due: #ea580c;            /* «сделать сейчас» — оранжевый */
  --due-bg: #ffedd5;
  --due-text: #9a3412;
  --norm: #7c3aed;           /* вне нормы — фиолетовый */
  --norm-text: #6d28d9;
  --sev-stable: #16a34a;
  --sev-severe: #eab308;
  --sev-extreme: #ea580c;
  --sev-critical: #7f1d1d;
}

/* Доска */
.board-block { margin: 0 0 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.tile { display: flex; flex-direction: column; gap: 2px; min-height: 120px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card);
  color: var(--text); text-decoration: none; }
.tile.busy { border-left: 4px solid var(--brand); }
.tile.busy:hover { background: var(--row-hover); }
.tile.has-overdue { border-color: var(--danger); border-width: 2px 2px 2px 4px; }
.tile.sev-critical { border-left-color: var(--sev-critical); }
.tile-due { display: flex; gap: 4px; flex-wrap: wrap; }
.due-badge { border-radius: 10px; padding: 0 7px; font-weight: 700; font-size: 12px;
  white-space: nowrap; }
.due-badge.now { background: var(--due-bg); color: var(--due-text); border: 1px solid var(--due); }
.due-badge.late { background: var(--danger); color: #fff; }
.sev-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  vertical-align: middle; flex: none; border: 1px solid rgba(0, 0, 0, 0.2); }
.sev-dot.sev-stable { background: var(--sev-stable); }
.sev-dot.sev-severe { background: var(--sev-severe); }
.sev-dot.sev-extreme { background: var(--sev-extreme); }
.sev-dot.sev-critical { background: var(--sev-critical); }
table.due-list tr.late td:first-child { border-left: 3px solid var(--danger); }
table.due-list tr.due td:first-child { border-left: 3px solid var(--due); }
.tile.free { background: var(--row-alt); justify-content: space-between; }
.tile-head { display: flex; gap: 6px; align-items: center; }
.tile .code { font-weight: 700; font-size: 16px; }
.tile .day { margin-left: auto; color: var(--muted); font-size: 12px; }
.tile .alias { font-weight: 600; font-size: 15px; }
.tile .diag { overflow-wrap: anywhere; }
.overdue-badge { background: var(--danger); color: #fff; border-radius: 10px; padding: 0 7px;
  font-weight: 700; font-size: 12px; }

/* Поступление */
.admit-layout { display: grid; grid-template-columns: minmax(360px, 1.2fr) 1fr; gap: 10px;
  align-items: start; }
.hints .hint-entry { border-top: 1px solid var(--border); padding: 4px 0; }
.hints .text { max-height: 260px; overflow: auto; }

/* Лист назначений */
.sheet-card { overflow: hidden; }
.sheet-card.saving { opacity: 0.7; }
table.sheet-head { border-collapse: collapse; width: 100%; margin: 0 0 8px; }
table.sheet-head th { text-align: left; font-weight: 600; color: var(--muted); padding: 2px 8px 2px 0;
  white-space: nowrap; width: 1%; }
table.sheet-head td { padding: 2px 16px 2px 0; }
.weight-edit { display: inline-flex; gap: 4px; align-items: center; }
.weight-edit input { width: 80px; }
.sheet-section h2 { margin: 10px 0 4px; }
.grid-scroll { overflow-x: auto; }
table.sheet-grid { border-collapse: collapse; background: var(--card); min-width: 100%; }
table.sheet-grid th, table.sheet-grid td { border: 1px solid var(--border); padding: 2px 4px; }
table.sheet-grid th { background: var(--head); font-weight: 600; white-space: nowrap; }
table.sheet-grid .title-col { min-width: 160px; max-width: 260px; text-align: left; }
table.sheet-grid th.hour { width: 30px; text-align: center; font-size: 12px; }
table.sheet-grid td.cell { width: 30px; min-width: 30px; height: 28px; text-align: center;
  cursor: pointer; font-weight: 700; user-select: none; font-size: 15px; }
table.sheet-grid.monitoring td.cell { font-weight: 400; font-size: 12px; min-width: 38px; }
table.sheet-grid td.cell:hover { outline: 2px solid var(--brand); outline-offset: -2px; }
table.sheet-grid .now { background: var(--now); }
table.sheet-grid td.cell.done { background: var(--ok-bg); color: var(--ok); }
table.sheet-grid td.cell.skipped { background: var(--row-alt); color: var(--danger); }
table.sheet-grid td.cell.overdue { background: var(--danger-bg); color: var(--danger);
  box-shadow: inset 0 0 0 2px var(--danger); }
table.sheet-grid td.cell.due-now { background: var(--due-bg); color: var(--due-text);
  box-shadow: inset 0 0 0 3px var(--due); animation: pulse-due 1.6s ease-in-out infinite; }
table.sheet-grid td.cell.overdue-fresh { animation: pulse-late 1.2s ease-in-out infinite; }
table.sheet-grid td.cell.off-norm { box-shadow: inset 0 0 0 2px var(--norm); color: var(--norm-text);
  font-weight: 700; }
table.sheet-grid .unit { color: var(--muted); font-size: 11px; font-weight: 400; }
@keyframes pulse-due {
  50% { box-shadow: inset 0 0 0 1px var(--due); background: var(--card); }
}
@keyframes pulse-late {
  50% { box-shadow: inset 0 0 0 1px var(--danger); background: var(--card); }
}
@media (prefers-reduced-motion: reduce) {
  table.sheet-grid td.cell.due-now, table.sheet-grid td.cell.overdue-fresh { animation: none; }
}
table.sheet-grid td.del button { padding: 0 6px; min-height: 22px; }
.row-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px 8px;
  align-items: end; }
.row-form label { display: flex; flex-direction: column; gap: 2px; }
.row-form .wide { grid-column: span 2; }
.day-jump { width: auto; }
.value-field select, .value-field input { width: auto; min-width: 120px; }

/* Динамика (график под листом) */
.chart-card .seg { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.chart-grid { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.chart { margin: 0; }
.chart figcaption { font-weight: 600; font-size: 13px; margin: 4px 0 2px; }
.chart svg { display: block; max-width: 100%; height: auto; }
.chart-frame { fill: var(--card); stroke: var(--border); }
.chart-band { fill: var(--ok-bg); }
.chart-line { fill: none; stroke: var(--brand-strong); stroke-width: 2; }
.chart-pt { fill: var(--card); stroke: var(--brand-strong); stroke-width: 2; cursor: default; }
.chart-pt.off { fill: var(--norm); stroke: var(--norm); }
.chart-pt:hover, .chart-pt:focus { stroke-width: 4; }
.chart-axis { fill: var(--muted); font-size: 11px; }

/* Параметры мониторинга */
table.params .num-in { width: 70px; }
table.params tr.dead td { color: var(--muted); }

/* Журнал сотрудника */
.ok-text { color: var(--ok); }
.danger-text { color: var(--danger); }
.staff-summary { margin: 4px 0 8px; }
table.staff-journal tr.st-cancelled td { color: var(--muted); }

/* Места */
.place-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.place-row input[name=code] { width: 120px; } .place-row input[name=sort] { width: 70px; }
.place-row label.check input { width: auto; }

/* Заход B: группы, выделение, критичное, инфузия, доза */
:root { --critical: #7f1d1d; --select: #2563eb; }
.sheet-tools { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 0 0 6px; }
.sheet-tools label { display: inline-flex; gap: 4px; align-items: center; }
.sheet-tools select { width: auto; max-width: 260px; }
.section-toggle { background: none; border: 0; padding: 0; font: inherit; color: inherit;
  cursor: pointer; min-height: 0; }
.section-toggle .caret { display: inline-block; transition: transform 0.15s ease; }
.sheet-section.collapsed .grid-scroll { display: none; }
.sheet-section.collapsed .caret { transform: rotate(-90deg); }
table.sheet-grid tr.filtered { display: none; }
table.sheet-grid tr.critical .row-name { font-weight: 700; color: var(--critical); }
.crit-mark { display: inline-block; min-width: 14px; text-align: center; border-radius: 3px;
  background: var(--critical); color: #fff; font-weight: 700; font-size: 11px; }
table.sheet-grid td.del { white-space: nowrap; }
table.sheet-grid td.del .crit-btn { font-weight: 700; }
table.sheet-grid td.del .crit-btn.on { background: var(--critical); color: #fff; }
table.sheet-grid td.cell.selected { outline: 3px solid var(--select); outline-offset: -3px; }
table.sheet-grid tr.total-rate td { background: var(--head); font-weight: 600; text-align: center;
  font-size: 12px; }
table.sheet-grid tr.total-rate td.title-col { text-align: left; }
table.sheet-grid .dose-col { white-space: nowrap; }
table.sheet-grid .computed { color: var(--brand-strong); white-space: nowrap; }
.bulk-bar { position: sticky; bottom: 8px; z-index: 5; display: flex; flex-wrap: wrap; gap: 6px;
  align-items: center; padding: 6px 10px; margin: 6px 0; border: 2px solid var(--select);
  border-radius: var(--radius); background: var(--card); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15); }
.dose-preview { margin: 0; color: var(--brand-strong); font-weight: 600; min-height: 1.2em; }
.row-form label.check { flex-direction: row; align-items: center; }
.row-form .inline { display: flex; gap: 4px; }
.row-form .inline input { flex: 1; min-width: 0; }
.template-item { border-top: 1px solid var(--border); padding: 6px 0; }
.template-item.dead summary { color: var(--muted); }
.template-item summary { cursor: pointer; }
td.critical { font-weight: 700; color: var(--critical); }

/* Понятность листа: «+ Добавить» в заголовке блока, окно добавления, подсказка «?» */
.sheet-section h2.section-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.sheet-section .add-row { min-height: 40px; padding: 4px 14px; font-size: 14px; font-weight: 600; }
.sheet-section .section-hint { font-weight: 400; }
#sheet-body[data-editable="1"] table.sheet-grid.monitoring td.cell[data-kind=""]:hover {
  background: var(--row-hover); }
.help-btn { min-width: 40px; min-height: 40px; border-radius: 50%; padding: 0; font-weight: 700;
  font-size: 18px; }
dialog.row-dialog { width: min(720px, calc(100vw - 32px)); }
dialog.row-dialog h2 { margin: 0 0 8px; }
dialog.row-dialog input, dialog.row-dialog select { min-height: 40px; }
dialog.row-dialog .actions button, dialog.help-dialog .actions button,
#cell-dialog .actions button { min-height: 40px; }
.row-form .wide-all { grid-column: 1 / -1; }
.row-form .actions { display: flex; gap: 8px; }
.help-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.help-key { display: inline-block; padding: 1px 8px; border: 1px solid var(--plus-border);
  border-radius: var(--radius-sm); font-weight: 600; white-space: nowrap; }
.help-more summary { cursor: pointer; }
.help-more p { font-size: 13px; margin: 6px 0; }
.sheet-legend { margin: 4px 0 8px; }
.discharged-notice { background: var(--warn-bg); border: 1px solid var(--warn, #eab308);
  border-radius: var(--radius-sm); padding: 8px 12px; margin: 0 0 8px; }
/* Лист выписанного (или без листа) — только чтение: ячейки не кликаются. */
#sheet-body:not([data-editable="1"]) table.sheet-grid td.cell { cursor: default; }
#sheet-body:not([data-editable="1"]) table.sheet-grid td.cell:hover { outline: none; }

/* Печать листа — альбомная, как бумажный бланк */
.print-landscape main { max-width: none; }
table.sheet-grid.print td.cell { cursor: default; height: 22px; }

@media (max-width: 900px) {
  .admit-layout { grid-template-columns: 1fr; }
  .row-form .wide { grid-column: auto; }
}
@media print {
  .sheet-section .add-row, .sheet-section .section-hint { display: none; }
}
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  .print-landscape body, body.print-landscape { font-size: 9pt; }
  table.sheet-grid th, table.sheet-grid td { padding: 1px 2px; }
  table.sheet-grid .title-col { min-width: 0; }
  table.sheet-grid td.cell { width: auto; min-width: 0; font-size: 10pt; }
  table.sheet-grid td.cell.done, table.sheet-grid td.cell.skipped,
  table.sheet-grid td.cell.overdue, table.sheet-grid td.cell.due-now,
  table.sheet-grid td.cell.off-norm { background: none; color: #000; box-shadow: none;
    animation: none; }
  .chart-card { display: none; }
  .sheet-section.collapsed .grid-scroll { display: block; }
  table.sheet-grid tr.filtered { display: table-row; }
}
