:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #667085;
  --line: #d8dee9;
  --line2: #edf0f5;
  --accent: #14634e;
  --action-primary: #14634e;
  --accent-soft: #edf6f1;
  --day-base: #173f78;
  --room-base: #245f9f;
  --color-strength: 75%;
  --danger: #a42424;
  --warn: #9b5a00;
  --ok: #207245;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  --board-font-size: 13px;
  --card-scale: 1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

input[type="checkbox"] { accent-color: var(--action-primary); }

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 12px;
  cursor: pointer;
}

button.primary {
  background: var(--action-primary);
  border-color: var(--action-primary);
  color: #fff;
}

button.danger {
  color: var(--danger);
  border-color: #e4b4b4;
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.hidden {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.authbar,
.tabs,
.panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid #bddbf4;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.layout {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 14px;
  display: grid;
  grid-template-columns: 285px minmax(0, 1fr);
  gap: 14px;
}

.layout.filters-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.layout.filters-collapsed .sidebar {
  display: none;
}

.sidebar {
  position: sticky;
  top: 78px;
  align-self: start;
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sidebar-head,
.content-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.content-tools {
  margin-bottom: 10px;
}

.sidebar-head button,
.content-tools button {
  padding: 5px 9px;
  font-size: 12px;
}

.section-title {
  margin: 4px 0 0;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.mt {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.content {
  min-width: 0;
}

.tabs {
  margin-bottom: 14px;
}

.tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metrics div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metrics b {
  display: block;
  font-size: 25px;
}

.metrics span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.week-board {
  padding: 14px;
  overflow-x: auto;
}

.board-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.board-toolbar select {
  max-width: 190px;
}

.ops-board {
  display: grid;
  grid-template-columns: repeat(var(--day-count), minmax(250px, 1fr));
  gap: 8px;
  padding: 10px;
  overflow-x: auto;
  min-height: 560px;
  font-size: var(--board-font-size);
}

.board-day {
  min-width: 250px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
}

.board-day-head,
.vertical-day-head {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 9px;
  background: var(--accent-soft);
  border-bottom: 1px solid #c7d9eb;
  cursor: pointer;
}

.board-day-head b,
.vertical-day-head b {
  font-size: 14px;
}

.board-day-head span,
.vertical-day-head span {
  color: var(--accent);
  font-weight: 800;
}

.board-day-head button,
.board-room-head button {
  padding: 2px 7px;
  min-width: 28px;
}

.day-toggle {
  padding: 2px 6px;
  min-width: 26px;
  font-weight: 900;
}

.collapsed-day-summary {
  padding: 10px;
  border-top: 1px solid var(--line);
  background: #edf4fc;
  background: color-mix(in srgb, var(--day-base, #173f78) 12%, #ffffff);
  color: #344054;
  font-size: 13px;
  font-weight: 850;
}

.board-day-rooms {
  display: grid;
  gap: 8px;
  padding: 8px;
}

.board-room {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.board-room-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  background: #f1f5f9;
  border-bottom: 1px solid var(--line);
  color: #344054;
}

.board-room-head b {
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-room-head button {
  font-size: 12px;
  white-space: nowrap;
}

.room-toggle {
  padding: 2px 6px;
  min-width: 26px;
  font-weight: 800;
}

.room-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.room-actions button {
  padding: 2px 7px;
  min-width: 26px;
}

.collapsed-room-summary {
  padding: 8px 10px;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
  background: #fff;
}

.board-room-body {
  display: block;
}

.room-slots {
  min-width: 0;
}

.slot-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  min-height: calc(112px * var(--card-scale));
  border-bottom: 1px solid var(--line2);
}

.slot-row:last-child {
  border-bottom: 0;
}

.slot-row.empty {
  background: #fbfcfe;
}

.slot-row.drag-over {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.slot-number {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--line2);
  background: #f8fafc;
  color: #475467;
  font-weight: 800;
}

.slot-content {
  min-width: 0;
  padding: 5px;
}

.slot-add {
  width: 100%;
  height: 100%;
  min-height: 84px;
  border-style: dashed;
  color: var(--accent);
  background: #fff;
}

.board-card {
  height: 100%;
  display: grid;
  gap: 3px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: grab;
  overflow: hidden;
}

.board-card.warn {
  border-color: #ead18a;
  background: #fffdf5;
}

.board-card.conflict {
  border-color: #e4b4b4;
  background: #fff7f7;
}

.board-card-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  align-items: start;
}

.board-card-head b {
  min-width: 0;
  font-size: calc(var(--board-font-size) + 1px);
  line-height: 1.15;
}

.board-card-head button {
  padding: 1px 5px;
  line-height: 1.2;
}

.board-meta,
.board-diagnosis,
.board-operation,
.board-preparation,
.board-team,
.board-tags {
  min-width: 0;
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}

.board-meta,
.board-team {
  color: var(--muted);
  font-size: calc(var(--board-font-size) - 2px);
  -webkit-line-clamp: 1;
}

.board-diagnosis {
  color: #344054;
  font-size: calc(var(--board-font-size) - 1px);
  -webkit-line-clamp: 2;
}

.board-operation {
  font-size: calc(var(--board-font-size) - 1px);
  font-weight: 750;
  -webkit-line-clamp: 2;
}

.board-preparation {
  padding: 3px 5px;
  border: 1px solid #e5bfd6;
  border-radius: 6px;
  background: #fff2f8;
  color: #7b2857;
  font-size: calc(var(--board-font-size) - 2px);
  font-weight: 800;
  -webkit-line-clamp: 2;
}

.board-team {
  justify-self: center;
  width: 100%;
  padding: 3px 6px;
  border: 1px solid color-mix(in srgb, var(--room-accent, #ffb45c) 55%, #ffffff);
  border-radius: 6px;
  background: color-mix(in srgb, var(--room-accent, #ffb45c) 24%, #ffffff);
  color: #253347;
  font-weight: 850;
  text-align: center;
}

.board-tags {
  color: var(--warn);
  font-size: calc(var(--board-font-size) - 2px);
  -webkit-line-clamp: 1;
}

.overflow-note {
  padding: 5px 7px;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
  border-top: 1px solid var(--line2);
}

.overflow-card {
  padding: 5px;
  border-top: 1px solid var(--line2);
}

.add-room-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
  background: #fbfcfe;
}

.add-room-row.top {
  margin-top: 0;
  border-top: 0;
  border-bottom: 1px solid var(--line);
}

.day-tone-1 .board-day-head,
.day-tone-1 .vertical-day-head {
  background: #dbe8f8;
  background: color-mix(in srgb, var(--day-base, #173f78) 35%, #ffffff);
  border-bottom-color: color-mix(in srgb, var(--day-base, #173f78) 52%, #ffffff);
}
.day-tone-2 .board-day-head,
.day-tone-2 .vertical-day-head {
  background: #c9dcf4;
  background: color-mix(in srgb, var(--day-base, #173f78) 43%, #ffffff);
  border-bottom-color: color-mix(in srgb, var(--day-base, #173f78) 58%, #ffffff);
}
.day-tone-3 .board-day-head,
.day-tone-3 .vertical-day-head {
  background: #b7d0ee;
  background: color-mix(in srgb, var(--day-base, #173f78) 51%, #ffffff);
  border-bottom-color: color-mix(in srgb, var(--day-base, #173f78) 64%, #ffffff);
}
.day-tone-4 .board-day-head,
.day-tone-4 .vertical-day-head {
  background: #8eb0dc;
  background: color-mix(in srgb, var(--day-base, #173f78) 60%, #ffffff);
  border-bottom-color: color-mix(in srgb, var(--day-base, #173f78) 72%, #ffffff);
}
.day-tone-5 .board-day-head,
.day-tone-5 .vertical-day-head {
  background: #6f96ca;
  background: color-mix(in srgb, var(--day-base, #173f78) 68%, #ffffff);
  border-bottom-color: color-mix(in srgb, var(--day-base, #173f78) 80%, #ffffff);
}
.day-tone-6 .board-day-head,
.day-tone-6 .vertical-day-head {
  background: #4e7bb9;
  background: color-mix(in srgb, var(--day-base, #173f78) var(--color-strength, 75%), #ffffff);
  border-bottom-color: color-mix(in srgb, var(--day-base, #173f78) 88%, #ffffff);
}

.day-tone-4 .board-day-head,
.day-tone-4 .vertical-day-head,
.day-tone-5 .board-day-head,
.day-tone-5 .vertical-day-head,
.day-tone-6 .board-day-head,
.day-tone-6 .vertical-day-head {
  color: #fff;
}

.day-tone-4 .board-day-head span,
.day-tone-4 .vertical-day-head span,
.day-tone-5 .board-day-head span,
.day-tone-5 .vertical-day-head span,
.day-tone-6 .board-day-head span,
.day-tone-6 .vertical-day-head span {
  color: #edf6ff;
}

.day-tone-4 .day-toggle,
.day-tone-5 .day-toggle,
.day-tone-6 .day-toggle {
  border-color: rgba(255, 255, 255, .45);
  background: rgba(255, 255, 255, .16);
  color: #fff;
}

.room-tone-1 { --room-accent: color-mix(in srgb, var(--room-base, #245f9f) 88%, #1f7fd1); border-color: color-mix(in srgb, var(--room-accent) 58%, #ffffff); }
.room-tone-2 { --room-accent: color-mix(in srgb, var(--room-base, #245f9f) 86%, #00a2d8); border-color: color-mix(in srgb, var(--room-accent) 58%, #ffffff); }
.room-tone-3 { --room-accent: color-mix(in srgb, var(--room-base, #245f9f) 84%, #536dfe); border-color: color-mix(in srgb, var(--room-accent) 58%, #ffffff); }
.room-tone-4 { --room-accent: color-mix(in srgb, var(--room-base, #245f9f) 82%, #008fb5); border-color: color-mix(in srgb, var(--room-accent) 58%, #ffffff); }
.room-tone-5 { --room-accent: color-mix(in srgb, var(--room-base, #245f9f) 86%, #6b8cff); border-color: color-mix(in srgb, var(--room-accent) 58%, #ffffff); }
.room-tone-6 { --room-accent: color-mix(in srgb, var(--room-base, #245f9f) 82%, #0076bd); border-color: color-mix(in srgb, var(--room-accent) 58%, #ffffff); }
.room-tone-7 { --room-accent: color-mix(in srgb, var(--room-base, #245f9f) 84%, #2c9abf); border-color: color-mix(in srgb, var(--room-accent) 58%, #ffffff); }
.room-tone-8 { --room-accent: color-mix(in srgb, var(--room-base, #245f9f) 80%, #4d73d9); border-color: color-mix(in srgb, var(--room-accent) 58%, #ffffff); }
.room-tone-9 { --room-accent: color-mix(in srgb, var(--room-base, #245f9f) 86%, #0088cc); border-color: color-mix(in srgb, var(--room-accent) 58%, #ffffff); }

.room-tone-1 .board-room-head,
.room-tone-1 h4,
.room-tone-2 .board-room-head,
.room-tone-2 h4,
.room-tone-3 .board-room-head,
.room-tone-3 h4,
.room-tone-4 .board-room-head,
.room-tone-4 h4,
.room-tone-5 .board-room-head,
.room-tone-5 h4,
.room-tone-6 .board-room-head,
.room-tone-6 h4,
.room-tone-7 .board-room-head,
.room-tone-7 h4,
.room-tone-8 .board-room-head,
.room-tone-8 h4,
.room-tone-9 .board-room-head,
.room-tone-9 h4 {
  background: #dbeafe;
  background: color-mix(in srgb, var(--room-accent, #245f9f) 36%, #ffffff);
}

.week-vertical {
  display: grid;
  gap: 12px;
  padding: 10px;
}

.vertical-day {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.vertical-rooms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 8px;
  padding: 8px;
}

.day-modal-card {
  width: min(1180px, 100%);
}

.day-detail {
  display: grid;
  gap: 12px;
}

.day-detail-room {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.day-detail-room h4 {
  margin: 0;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.day-detail-room h4 small {
  display: block;
  margin-top: 3px;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.day-slot-list {
  display: grid;
}

.day-slot-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  border-bottom: 1px solid var(--line2);
  background: #fff;
}

.day-slot-row:last-child {
  border-bottom: 0;
}

.day-slot-row.empty {
  background: #fbfcfe;
}

.day-slot-number {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--line2);
  color: #7b2857;
  font-weight: 900;
}

.day-slot-main {
  min-width: 0;
  display: grid;
  gap: 5px;
  padding: 9px;
}

.day-patient {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}

.day-patient b {
  font-size: 14px;
}

.day-patient span,
.day-diagnosis {
  color: var(--muted);
  font-size: 12px;
}

.day-operation {
  color: #253347;
  font-size: 12px;
  font-weight: 800;
}

.day-preparation {
  width: fit-content;
  max-width: 100%;
  padding: 3px 7px;
  border: 1px solid #e5bfd6;
  border-radius: 999px;
  background: #fff2f8;
  color: #7b2857;
  font-size: 12px;
  font-weight: 800;
}

.day-team {
  justify-self: start;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--room-accent, #d9579c) 50%, #fff);
  border-radius: 7px;
  background: color-mix(in srgb, var(--room-accent, #d9579c) 22%, #fff);
  color: #253347;
  font-size: 12px;
  font-weight: 850;
}

.slot-add.line {
  min-height: 34px;
  padding: 5px 8px;
}

body[data-density="dense"] .slot-row {
  min-height: calc(88px * var(--card-scale));
}

body[data-density="dense"] .board-diagnosis {
  -webkit-line-clamp: 1;
}

body[data-density="normal"] .slot-row {
  min-height: calc(136px * var(--card-scale));
}

.week-columns {
  min-width: 1180px;
  display: grid;
  grid-template-columns: repeat(5, minmax(235px, 1fr));
  gap: 12px;
}

.day {
  min-height: 520px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  overflow: hidden;
}

.day-head {
  padding: 10px 11px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  background: var(--accent-soft);
  border-bottom: 1px solid #c7d9eb;
}

.day-head b {
  font-size: 15px;
}

.day-head span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.room {
  padding: 10px;
  border-bottom: 1px solid var(--line2);
}

.room-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.mini-list {
  display: grid;
  gap: 7px;
}

.mini-card {
  display: grid;
  gap: 5px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.mini-card.warn {
  border-color: #ead18a;
  background: #fffdf5;
}

.mini-card.conflict {
  border-color: #e4b4b4;
  background: #fff7f7;
}

.mini-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 8px;
}

.patient {
  font-weight: 800;
  line-height: 1.25;
}

.small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tagline {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #344054;
  font-size: 12px;
}

.tag.robot {
  background: #eef7ff;
  border-color: #bddbf4;
  color: #175284;
}

.tag.lap {
  background: #effaf3;
  border-color: #bfe3cc;
  color: var(--ok);
}

.tag.open {
  background: #fff4e6;
  border-color: #f1d0a6;
  color: #8a4b00;
}

.tag.warn {
  background: #fff8e5;
  border-color: #ead18a;
  color: var(--warn);
}

.tag.conflict {
  background: #fff1f1;
  border-color: #e4b4b4;
  color: var(--danger);
}

.slot-box {
  margin-top: auto;
  display: grid;
  gap: 7px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: #f7f9fc;
}

.empty-slot {
  min-height: 38px;
  padding: 9px 10px;
  border: 1px dashed #aeb8c8;
  border-radius: 7px;
  background: #fff;
  color: #475467;
  text-align: left;
}

.empty-slot.admin {
  border-color: #7aa9d4;
  color: var(--accent);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 260px);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line2);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9fc;
  color: #344054;
  font-size: 12px;
}

tr:hover td {
  background: #fbfcff;
}

.analytics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 14px;
}

.audit-list {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.bar-row {
  margin: 9px 0;
}

.bar-row div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.track {
  height: 8px;
  margin-top: 4px;
  border-radius: 999px;
  background: #edf0f5;
  overflow: hidden;
}

.fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.empty {
  padding: 34px 16px;
  color: var(--muted);
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, .46);
}

.modal.open {
  display: flex;
}

.modal-card {
  width: min(520px, 100%);
  max-height: 92vh;
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

.modal-card.wide {
  width: min(960px, 100%);
}

.modal-head,
.modal-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  justify-content: flex-end;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-foot > button {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.modal-head h3 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 14px;
}

.compact-form {
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  align-items: end;
  padding: 12px 0 0;
}

.span-all {
  grid-column: 1 / -1;
}

.checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 9px 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.checklist .sidebar-head,
.content-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.content-tools {
  margin-bottom: 10px;
}

.sidebar-head button,
.content-tools button {
  padding: 5px 9px;
  font-size: 12px;
}

.section-title {
  grid-column: 1 / -1;
}

.check-item {
  display: flex;
  align-items: center;
  min-width: 0;
  overflow-wrap: anywhere;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
}

.check-item input {
  width: auto;
  flex-shrink: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.note {
  margin: 0;
  padding: 8px 0;
  color: #456357;
  font-size: 13px;
}

.note[role="alert"],
.note[data-kind="rejected"] {
  padding: 10px 12px;
  border: 1px solid #d6a5a5;
  border-radius: 8px;
  background: #fff1f1;
  color: #842323;
}

.note[data-kind="unknown"],
.note[data-kind="warning"],
.warning {
  margin: 0;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff9e8;
  color: #6f4200;
  border: 1px solid #ead18a;
  font-size: 13px;
}

.warning {
  margin: 0 14px 14px;
}



/* v018: рабочее табло */
.board-card {
  position: relative;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.board-card-head {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-right: 26px;
}

.board-card-head button {
  position: absolute;
  top: 4px;
  right: 4px;
}

.board-meta,
.board-diagnosis,
.board-operation,
.board-preparation,
.board-team,
.board-tags {
  text-align: center;
  justify-content: center;
}

.board-card.emias-submitted,
.board-card.emias-submitted.warn,
.board-card.emias-submitted.conflict,
.day-slot-main.emias-submitted,
.patient-table-slot.emias-submitted {
  border-color: #80c77a;
  background: #e6f8e2;
}

.emias-badge {
  width: fit-content;
  max-width: 100%;
  padding: 2px 7px;
  border: 1px solid #7bc47d;
  border-radius: 999px;
  background: #d8f3d2;
  color: #1c6b2f;
  font-size: calc(var(--board-font-size) - 2px);
  font-weight: 900;
}

.board-team {
  justify-self: center;
  align-self: center;
  margin-top: 2px;
}

.metrics.hidden {
  display: none;
}

.form-check {
  align-self: end;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfe;
}

.patient-table-board {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.table-toolbar div {
  display: grid;
  gap: 2px;
}

.table-toolbar span {
  color: var(--muted);
  font-size: 12px;
}

.patient-zone {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.patient-zone.ready {
  border-color: #b5e6a4;
  background: #f2fee8;
}

.patient-zone.pending {
  border-color: #f0b5b9;
  background: #fff3f4;
}

.patient-zone-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  border-bottom: 1px solid rgba(0,0,0,.07);
  color: #253347;
}

.patient-zone.ready .patient-zone-head {
  background: #dcfacf;
}

.patient-zone.pending .patient-zone-head {
  background: #ffe1e4;
}

.patient-zone-body {
  display: grid;
}

.patient-table-slot {
  display: grid;
  grid-template-columns: 44px minmax(150px, 1.1fr) 110px minmax(150px, .9fr) minmax(230px, 1.4fr) minmax(150px, .9fr) 150px;
  gap: 8px;
  align-items: center;
  min-height: 58px;
  padding: 7px 9px;
  border-bottom: 1px solid rgba(0,0,0,.06);
}

.patient-table-slot:last-child {
  border-bottom: 0;
}

.patient-table-slot.ready {
  background: #f6ffef;
}

.patient-table-slot.pending {
  background: #fff8f8;
}

.patient-table-slot.empty {
  color: #667085;
}

.patient-slot-no {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border-radius: 8px;
  background: rgba(255,255,255,.75);
  font-weight: 900;
}

.patient-slot-person,
.patient-slot-card,
.patient-slot-wait,
.patient-slot-operation,
.patient-slot-team,
.patient-slot-empty {
  display: grid;
  gap: 2px;
  min-width: 0;
  text-align: center;
  justify-items: center;
  align-items: center;
}

.patient-slot-person b,
.patient-slot-operation b,
.patient-slot-card b,
.patient-slot-wait b,
.patient-slot-team b {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.patient-slot-person span,
.patient-slot-operation span,
.patient-slot-card span,
.patient-slot-wait span,
.patient-slot-team span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.patient-slot-actions {
  display: flex;
  gap: 5px;
  justify-content: center;
  flex-wrap: wrap;
}

.patient-slot-actions button {
  padding: 5px 7px;
  font-size: 12px;
}

.overflow-zone .patient-zone-head {
  background: #f1f5f9;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .week-columns {
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .ops-board {
    grid-template-columns: 1fr;
    min-height: auto;
    overflow-x: visible;
  }

  .board-day {
    min-width: 0;
  }

  .day {
    min-height: auto;
  }

  .analytics {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    padding: 12px;
    gap: 12px;
  }

  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .panel-head {
    flex-direction: column;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .checklist {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .vertical-rooms {
    grid-template-columns: 1fr;
  }

  .board-room-head {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .room-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .patient-table-slot {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .patient-slot-card,
  .patient-slot-wait,
  .patient-slot-operation,
  .patient-slot-team,
  .patient-slot-actions {
    grid-column: 2;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .sidebar,
  .tabs,
  .metrics,
  .panel-head,
  .slot-box,
  .mini-actions,
  .board-toolbar,
  .add-room-row,
  .board-card-head button,
  .board-room-head button,
  .board-day-head button {
    display: none !important;
  }

  .layout {
    display: block;
    max-width: none;
    padding: 0;
  }

  .panel {
    border: 0;
    box-shadow: none;
  }

  .week-board {
    padding: 0;
    overflow: visible;
  }

  .week-columns {
    min-width: 0;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }

  .day {
    min-height: auto;
    break-inside: avoid;
  }

  .ops-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    padding: 0;
    overflow: visible;
  }

  .board-day,
  .board-room,
  .slot-row,
  .board-card {
    break-inside: avoid;
  }
}

/* Alternative operations day board host bridge. Component styles remain scoped
   to [data-owb-root] in operations-day-board.css. */
.day-board-plan-switcher {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 0 0 10px;
  padding: 3px;
  border: 1px solid #cdd8d3;
  border-radius: 10px;
  background: #edf2ef;
}

.day-board-plan-switcher button {
  min-height: 34px;
  padding: 6px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #395047;
  font-weight: 700;
}

.day-board-plan-switcher button.is-active {
  background: #185b47;
  color: #fff;
  box-shadow: 0 2px 8px rgb(20 72 56 / 20%);
}

body[data-view="day_board"] #appLayout {
  grid-template-columns: minmax(0, 1fr);
}

body[data-view="day_board"] #sidebar,
body[data-view="day_board"] .content-tools,
body[data-view="day_board"] .tabs,
body[data-view="day_board"] .panel-head {
  display: none !important;
}

body[data-view="day_board"] .content,
body[data-view="day_board"] .panel,
body[data-view="day_board"] #content {
  min-width: 0;
  width: 100%;
  max-width: none;
}

body[data-view="day_board"] .panel {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

/* v019: stabilization, full-width workboard, touch actions */
.layout {
  padding: 8px;
  gap: 8px;
}

.panel {
  border-radius: 7px;
}

.panel-head {
  padding: 10px 12px;
}

.week-vertical {
  padding: 8px;
  gap: 8px;
}

.vertical-rooms {
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 7px;
  padding: 7px;
}

.board-card {
  min-height: 94px;
}

.action-modal-card {
  width: min(560px, 100%);
}

.card-menu-summary {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  text-align: center;
}

.card-menu-summary b {
  font-size: 18px;
}

.card-menu-summary span {
  color: var(--muted);
  font-size: 13px;
}

.card-menu-summary strong {
  justify-self: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: #d8f3d2;
  color: #1c6b2f;
  font-size: 12px;
}

.card-menu-summary.emias-submitted {
  background: #e6f8e2;
  border-color: #80c77a;
}

.card-menu-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.card-menu-actions button {
  min-height: 42px;
}

.day-modal-card {
  width: min(1280px, calc(100vw - 20px));
}

.day-detail {
  gap: 10px;
}

.day-slot-main {
  min-height: 74px;
}

.day-patient {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.day-patient b,
.day-patient span {
  min-width: 0;
}

.day-patient button {
  padding: 4px 8px;
  font-size: 12px;
}

.metrics:not(.hidden) {
  margin: 14px;
}

.content-tools {
  margin-bottom: 6px;
}

body[data-density="dense"] .vertical-rooms {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

body[data-density="normal"] .vertical-rooms {
  grid-template-columns: repeat(auto-fit, minmax(390px, 1fr));
}

@media (max-width: 680px) {
  .card-menu-actions {
    grid-template-columns: 1fr;
  }

  .day-patient {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

/* =========================
   v1.0 clinical board design
   ========================= */
:root {
  --v1-ink: #172033;
  --v1-muted: #667085;
  --v1-panel: rgba(255,255,255,0.92);
  --v1-line: rgba(19,44,77,0.14);
  --v1-blue: #17324f;
  --v1-blue-2: #254f7e;
  --v1-ready: #d8f2cd;
  --v1-ready-border: #70b969;
  --v1-pending: #f9dada;
  --v1-pending-border: #e07f7f;
  --v1-cream: #fbf8f3;
}

body {
  color: var(--v1-ink);
  background:
    radial-gradient(circle at 16% 8%, rgba(80, 114, 159, .16), transparent 34%),
    linear-gradient(135deg, #f8f3ef 0%, #eef4fa 42%, #edf1f7 100%);
}

.topbar {
  background: linear-gradient(135deg, rgba(16, 40, 68, .96), rgba(44, 74, 112, .92));
  border-bottom: 1px solid rgba(255,255,255,.16);
}

.layout {
  max-width: none;
  width: min(100%, 1920px);
  grid-template-columns: 252px minmax(0, 1fr);
}

.layout.filters-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.content {
  max-width: none;
}

.panel,
.sidebar,
.modal-card,
.box {
  border-color: var(--v1-line);
  box-shadow: 0 18px 46px rgba(25, 50, 84, .08);
}

.tabs {
  gap: 8px;
}

.tabs button {
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(21, 49, 83, .14);
}

.tabs button.active {
  background: linear-gradient(135deg, #17324f, #315e8f);
  color: #fff;
  box-shadow: 0 8px 24px rgba(30, 63, 100, .22);
}

.v1-toolbar {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--v1-line);
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(12px);
  border-radius: 18px;
  margin-bottom: 12px;
}

.week-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #eef3f8;
  border: 1px solid rgba(23,50,79,.12);
}

.week-state span {
  color: var(--v1-muted);
  font-size: 12px;
}

.week-state b {
  font-size: 13px;
}

.v1-week-vertical {
  gap: 14px;
}

.vertical-day {
  border-radius: 24px;
  border: 1px solid rgba(20, 44, 76, .16);
  overflow: hidden;
  background: rgba(255,255,255,.76);
}

.vertical-day-head,
.board-day-head {
  min-height: 46px;
  padding: 10px 14px;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,.18);
}

.day-tone-1 .vertical-day-head,
.day-tone-1 .board-day-head { background: linear-gradient(135deg, #344b7f, #49689e); }
.day-tone-2 .vertical-day-head,
.day-tone-2 .board-day-head { background: linear-gradient(135deg, #3c4f86, #665d9e); }
.day-tone-3 .vertical-day-head,
.day-tone-3 .board-day-head { background: linear-gradient(135deg, #4a4d85, #795b9b); }
.day-tone-4 .vertical-day-head,
.day-tone-4 .board-day-head { background: linear-gradient(135deg, #59477e, #87558d); }
.day-tone-5 .vertical-day-head,
.day-tone-5 .board-day-head { background: linear-gradient(135deg, #623f72, #954d80); }
.day-tone-6 .vertical-day-head,
.day-tone-6 .board-day-head { background: linear-gradient(135deg, #6c3a67, #a24776); }

.vertical-rooms,
.board-day-rooms {
  padding: 10px;
  gap: 10px;
}

.board-room {
  border-radius: 18px;
  border: 1px solid rgba(23,50,79,.18);
  background: rgba(255,255,255,.90);
  overflow: hidden;
}

.board-room-head {
  min-height: 40px;
  background: linear-gradient(135deg, rgba(52,94,142,.94), rgba(83,112,160,.92));
  color: #fff;
}

.room-tone-1 .board-room-head,
.room-tone-1 h4 { background: linear-gradient(135deg, #2d6f9f, #5c8eba); }
.room-tone-2 .board-room-head,
.room-tone-2 h4 { background: linear-gradient(135deg, #4e6dad, #7d8ac5); }
.room-tone-3 .board-room-head,
.room-tone-3 h4 { background: linear-gradient(135deg, #6b64a8, #9885c4); }
.room-tone-4 .board-room-head,
.room-tone-4 h4 { background: linear-gradient(135deg, #805f9e, #b184bc); }
.room-tone-5 .board-room-head,
.room-tone-5 h4 { background: linear-gradient(135deg, #98598f, #c884ad); }
.room-tone-6 .board-room-head,
.room-tone-6 h4 { background: linear-gradient(135deg, #a75880, #d1879c); }
.room-tone-7 .board-room-head,
.room-tone-7 h4 { background: linear-gradient(135deg, #466f99, #78a2bf); }
.room-tone-8 .board-room-head,
.room-tone-8 h4 { background: linear-gradient(135deg, #3d7e8d, #75aeb4); }
.room-tone-9 .board-room-head,
.room-tone-9 h4 { background: linear-gradient(135deg, #606f9e, #8d9bc0); }

.slot-row {
  min-height: calc(112px * var(--card-scale));
  border-bottom: 1px solid rgba(23,50,79,.10);
}

.slot-number,
.day-slot-number,
.patient-slot-no {
  background: rgba(23,50,79,.08);
  color: #17324f;
  font-weight: 800;
}

.board-card {
  min-height: calc(96px * var(--card-scale));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 3px;
  border-radius: 16px;
  border: 1px solid rgba(23,50,79,.12);
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(250,252,255,.92));
}

.board-card.ready-ready {
  background: linear-gradient(180deg, #f2fbec, #dff4d2);
  border-color: var(--v1-ready-border);
}

.board-card.ready-pending {
  background: linear-gradient(180deg, #fff6f6, #f8dede);
  border-color: var(--v1-pending-border);
}

.board-card.emias-submitted {
  background: linear-gradient(180deg, #e6f9dd, #c1edb8) !important;
  border-color: #58a853;
}

.board-card-head {
  width: 100%;
  justify-content: center;
  position: relative;
}

.board-meta,
.board-diagnosis,
.board-operation,
.board-preparation,
.board-team,
.board-tags {
  text-align: center;
}

.board-diagnosis {
  font-size: calc(var(--board-font-size) * .89);
  color: #354258;
}

.board-operation {
  font-size: calc(var(--board-font-size) * .82);
  line-height: 1.18;
  font-weight: 800;
  color: #12233a;
}

.board-team,
.day-team,
.patient-slot-team {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(23,50,79,.10);
  color: #17324f;
  font-weight: 800;
}

.emias-badge {
  border-radius: 999px;
  padding: 2px 8px;
  background: #45a34f;
  color: #fff;
  font-weight: 800;
}

.v1-day-detail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 12px;
}

.day-detail-room {
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(23,50,79,.18);
  background: #fff;
}

.day-detail-room h4 {
  color: #fff;
  margin: 0;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
}

.day-slot-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  min-height: 96px;
  border-bottom: 1px solid rgba(23,50,79,.10);
}

.day-slot-main {
  padding: 9px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  gap: 4px;
}

.day-patient {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.patient-table-board {
  display: grid;
  gap: 16px;
}

.patient-zone {
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(23,50,79,.14);
}

.patient-zone.ready {
  background: linear-gradient(180deg, #effbe9, #dff5d3);
}

.patient-zone.pending {
  background: linear-gradient(180deg, #fff4f4, #f8dada);
}

.patient-zone-head {
  padding: 12px 16px;
  background: rgba(255,255,255,.72);
  border-bottom: 1px solid rgba(23,50,79,.10);
}

.patient-zone-body,
.patient-zone-overflow {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.patient-table-slot {
  min-height: 86px;
  display: grid;
  grid-template-columns: 46px minmax(160px, 1.2fr) minmax(160px, 1fr) minmax(220px, 1.4fr) minmax(160px, 1fr) auto;
  gap: 8px;
  align-items: center;
  border-radius: 16px;
  padding: 8px;
  background: rgba(255,255,255,.88);
  border: 1px solid rgba(23,50,79,.12);
}

.patient-table-slot.ready,
.patient-table-slot.ready-ready {
  background: #edfbe7;
}

.patient-table-slot.pending,
.patient-table-slot.ready-pending {
  background: #fff0f0;
}

.patient-slot-person,
.patient-slot-card,
.patient-slot-wait,
.patient-slot-operation,
.patient-slot-team,
.patient-slot-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 3px;
}

.metric-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.metric-strip div {
  border: 1px solid rgba(23,50,79,.12);
  border-radius: 18px;
  background: rgba(255,255,255,.88);
  padding: 14px;
  text-align: center;
}

.metric-strip b {
  display: block;
  font-size: 26px;
  color: #17324f;
}

.training-grid,
.security-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.print-plan {
  background: white;
  color: #111827;
  padding: 22px;
  border-radius: 18px;
}

.print-plan-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin: -4px 0 12px;
  color: #475569;
  font-size: 11px;
}

.print-plan-meta span {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 18px;
  font-size: 12px;
}

.print-table th,
.print-table td {
  border: 1px solid #cbd5e1;
  padding: 5px 7px;
  vertical-align: top;
}

.print-table th {
  background: #eef2f7;
}

.prep-checklist-v1 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.prep-checklist-v1 .section-title,
.prep-checklist-v1 .legacy-checks {
  grid-column: 1 / -1;
}

.legacy-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
  padding-top: 8px;
}

@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .layout.filters-collapsed .sidebar { display: none; }
  .patient-table-slot { grid-template-columns: 38px minmax(0, 1fr); }
  .patient-slot-card,
  .patient-slot-wait,
  .patient-slot-operation,
  .patient-slot-team,
  .patient-slot-actions { grid-column: 2; }
}

@media print {
  body.print-only { background: white; }
  body.print-only .print-plan { padding: 0; border-radius: 0; }
  .topbar, .layout > .sidebar, .tabs, .content-tools, .panel-head, .v1-toolbar, button { display: none !important; }
  .layout, .content, .panel { display: block !important; width: 100% !important; max-width: none !important; box-shadow: none !important; border: 0 !important; padding: 0 !important; margin: 0 !important; }
}

/* v1.1 operational resilience */
.standby-board {
  display: grid;
  gap: 14px;
}
.standby-strip div {
  min-width: 130px;
}
.standby-section {
  background: rgba(255,255,255,0.86);
  border: 1px solid rgba(31, 48, 78, 0.12);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 18px 40px rgba(31, 48, 78, 0.08);
}
.standby-section h3 {
  margin: 0 0 10px;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: #172947;
}
.reserve-card,
.reserve-slot {
  border: 1px solid rgba(32, 47, 78, 0.16);
  border-radius: 14px;
  padding: 10px;
  margin: 8px 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.96), rgba(245,248,255,0.92));
  display: grid;
  gap: 5px;
}
.reserve-slot {
  background: linear-gradient(135deg, rgba(239,247,255,0.92), rgba(250,252,255,0.98));
}
.reserve-main,
.reserve-slot b {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #13253f;
}
.reserve-meta,
.reserve-team,
.reserve-reasons,
.reserve-op,
.reserve-slot span {
  font-size: 12px;
  color: #455672;
}
.reserve-op {
  font-weight: 700;
  color: #243451;
}
.reserve-reasons {
  color: #7c3248;
}
.reserve-actions,
.reserve-slot-candidates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.readiness-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  line-height: 1.1;
  font-weight: 800;
  border: 1px solid rgba(32, 47, 78, 0.12);
  white-space: nowrap;
}
.readiness-готов {
  background: #d9f6de;
  color: #185228;
}
.readiness-контроль {
  background: #fff1c7;
  color: #77540b;
}
.readiness-не\ готов {
  background: #ffe0e5;
  color: #842a3d;
}
.board-readiness {
  display: flex;
  justify-content: center;
  margin: 2px 0 4px;
}
.interop-board {
  display: grid;
  gap: 12px;
}
.json-preview {
  max-height: 520px;
  overflow: auto;
  border: 1px solid rgba(31, 48, 78, 0.16);
  border-radius: 14px;
  padding: 12px;
  background: #111827;
  color: #e5eefc;
  font-size: 11px;
  line-height: 1.35;
}
.small-empty {
  padding: 12px;
  min-height: auto;
}
@media (min-width: 1200px) {
  .standby-board {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .standby-strip,
  .standby-section:first-of-type {
    grid-column: 1 / -1;
  }
}


/* v1.2 patient bank */
.patient-bank-v12 { display: grid; gap: 14px; }
.bank-actions-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.bank-v12-layout { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr) minmax(240px, .7fr); gap: 14px; align-items: start; }
.bank-v12-layout section { background: rgba(255,255,255,.74); border: 1px solid rgba(58,72,109,.18); border-radius: 18px; padding: 12px; }
.bank-v12-layout h3 { margin: 0 0 10px; font-size: 15px; }
.reason-counts { display: grid; gap: 8px; }
.reason-counts div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 12px; background: rgba(70, 92, 150, .10); }
.reason-counts b { font-size: 12px; }
.reason-counts span { font-weight: 800; }
@media (max-width: 980px) { .bank-v12-layout { grid-template-columns: 1fr; } }


/* v1.3 quality control */
.quality-board { display: grid; gap: 14px; }
.quality-layout { display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr)); gap: 14px; align-items: start; }
.qc-section { border-radius: 18px; padding: 12px; border: 1px solid rgba(40, 50, 80, .16); background: rgba(255,255,255,.78); }
.qc-section h3 { margin: 0 0 10px; font-size: 15px; }
.qc-issue { display: grid; gap: 6px; padding: 10px; border-radius: 14px; margin-bottom: 8px; border: 1px solid rgba(38, 50, 83, .16); background: rgba(245, 247, 255, .82); }
.qc-issue.hard { background: rgba(255, 231, 231, .86); }
.qc-issue.warning { background: rgba(255, 246, 218, .88); }
.qc-issue.info { background: rgba(229, 242, 255, .86); }
.qc-issue b { font-size: 12px; }
.qc-issue span { font-size: 11px; color: #41506e; }
.quality-mini-badges { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.quality-mini-badges span { border-radius: 999px; padding: 3px 7px; font-size: 10px; font-weight: 800; }
.quality-mini-badges .hard { background: rgba(197, 50, 73, .16); color: #742035; }
.quality-mini-badges .warning { background: rgba(201, 142, 35, .18); color: #68400f; }
@media (max-width: 1100px) { .quality-layout { grid-template-columns: 1fr; } }


/* v1.4 schedule templates and suggestions */
.templates-board { display: grid; grid-template-columns: minmax(260px,.8fr) minmax(260px,.8fr) minmax(320px,1fr); gap: 14px; align-items: start; }
.templates-list { display: grid; gap: 10px; }
.template-card { display: grid; gap: 6px; padding: 12px; border-radius: 16px; background: rgba(255,255,255,.78); border: 1px solid rgba(56,67,104,.16); }
.template-card b { font-size: 13px; }
.template-card span { font-size: 12px; color: #45546f; }
.suggestion-board { display: grid; gap: 14px; }
.suggestion-list { display: grid; gap: 10px; }
.suggestion-card { display: grid; gap: 6px; grid-template-columns: 1fr auto; align-items: center; padding: 12px; border-radius: 16px; background: rgba(255,255,255,.80); border: 1px solid rgba(48,64,104,.16); }
.suggestion-card.high { background: rgba(255, 238, 238, .88); }
.suggestion-card b { font-size: 13px; }
.suggestion-card span { color: #4b5872; font-size: 11px; }
@media (max-width: 1100px) { .templates-board { grid-template-columns: 1fr; } .suggestion-card { grid-template-columns: 1fr; } }


/* v1.5 week lifecycle */
.lifecycle-board { display: grid; gap: 14px; }
.lifecycle-hero { display: grid; grid-template-columns: minmax(260px,1fr) auto auto; gap: 14px; align-items: center; padding: 16px; border-radius: 20px; color: #f8fbff; background: linear-gradient(135deg, #23466d, #102844); box-shadow: 0 14px 34px rgba(18, 35, 62, .14); }
.lifecycle-hero span { display: block; font-size: 11px; opacity: .78; text-transform: uppercase; letter-spacing: .08em; }
.lifecycle-hero h3 { margin: 2px 0 0; font-size: 20px; }
.lifecycle-hero b { font-size: 14px; }
.lifecycle-hero.draft { background: linear-gradient(135deg, #4b6078, #203247); }
.lifecycle-hero.review { background: linear-gradient(135deg, #5c4f86, #26315d); }
.lifecycle-hero.published { background: linear-gradient(135deg, #236476, #102844); }
.lifecycle-hero.archived { background: linear-gradient(135deg, #4a4f5a, #1f2430); }
.lifecycle-strip { grid-template-columns: repeat(6, minmax(100px,1fr)); }
.lifecycle-quality { display: grid; gap: 4px; padding: 12px 14px; border-radius: 16px; border: 1px solid rgba(30, 49, 80, .16); }
.lifecycle-quality.ok { background: rgba(221, 247, 238, .9); }
.lifecycle-quality.blocked { background: rgba(255, 239, 231, .92); }
.lifecycle-quality b { font-size: 14px; }
.lifecycle-quality span { color: #40516c; font-size: 12px; }
.lifecycle-actions { display: grid; gap: 10px; }
.lifecycle-grid { display: grid; grid-template-columns: minmax(240px,.55fr) minmax(320px,1fr); gap: 14px; }
.lifecycle-kpi { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid rgba(34, 50, 78, .10); }
.lifecycle-kpi:last-child { border-bottom: 0; }
.lifecycle-kpi span { color: #465672; }
.lifecycle-events { display: grid; gap: 8px; margin-top: 10px; }
.lifecycle-event { display: grid; gap: 4px; padding: 10px 12px; border-radius: 14px; background: rgba(247, 249, 255, .86); border: 1px solid rgba(42, 55, 91, .14); }
.lifecycle-event.post_publication_change { background: rgba(255, 246, 226, .92); }
.lifecycle-event.week_published { background: rgba(223, 247, 240, .92); }
.lifecycle-event.week_archived { background: rgba(235, 238, 244, .92); }
.lifecycle-event b { font-size: 12px; }
.lifecycle-event span, .lifecycle-event p { margin: 0; color: #4d5b74; font-size: 11px; }
.week-force, .week-lock { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; padding: 6px 9px; border-radius: 999px; background: rgba(255,255,255,.72); color: #28364f; }
.week-lock { background: rgba(86, 92, 105, .14); font-weight: 800; }
@media (max-width: 900px) {
  .lifecycle-hero, .lifecycle-grid { grid-template-columns: 1fr; }
  .lifecycle-strip { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
}

/* v1.6 plan stability */
.stability-board { display: grid; gap: 14px; }
.stability-hero { display: grid; grid-template-columns: minmax(260px,1fr) repeat(3, auto); gap: 14px; align-items: center; padding: 16px; border-radius: 20px; color: #f8fbff; background: linear-gradient(135deg, #263c66, #102844); box-shadow: 0 14px 34px rgba(18,35,62,.14); }
.stability-hero.good { background: linear-gradient(135deg, #1f6b71, #102844); }
.stability-hero.watch { background: linear-gradient(135deg, #80603c, #26315d); }
.stability-hero.bad { background: linear-gradient(135deg, #743f5c, #1f2a44); }
.stability-hero span { display: block; font-size: 11px; opacity: .78; text-transform: uppercase; letter-spacing: .08em; }
.stability-hero h3 { margin: 2px 0 0; font-size: 20px; }
.stability-hero b { font-size: 18px; }
.stability-strip { grid-template-columns: repeat(8, minmax(96px,1fr)); }
.stability-warning { display: grid; gap: 8px; background: rgba(255, 246, 226, .92); }
.stability-grid { display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr)); gap: 14px; align-items: start; }
.stability-grid.two { grid-template-columns: repeat(2, minmax(280px, 1fr)); }
.stability-bars { display: grid; gap: 8px; margin-top: 10px; }
.stability-bar-row { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; min-height: 30px; padding: 7px 10px; overflow: hidden; border-radius: 12px; background: rgba(55, 76, 118, .08); }
.stability-bar-row i { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(55, 97, 159, .18); z-index: 0; }
.stability-bar-row span, .stability-bar-row b { position: relative; z-index: 1; font-size: 12px; }
.stability-list { display: grid; gap: 8px; }
.stability-list article { display: grid; gap: 4px; padding: 10px; border-radius: 14px; background: rgba(247,249,255,.86); border: 1px solid rgba(42,55,91,.14); }
.stability-list article span { font-weight: 800; font-size: 12px; }
.stability-list article small { color: #4d5b74; font-size: 11px; }
.stability-events { display: grid; gap: 8px; margin-top: 10px; }
.stability-events article { display: grid; grid-template-columns: 180px minmax(180px, 1fr) minmax(220px, 1fr); gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; background: rgba(247,249,255,.86); border: 1px solid rgba(42,55,91,.14); }
.stability-events b { font-size: 12px; }
.stability-events span, .stability-events p { margin: 0; color: #4d5b74; font-size: 11px; }
@media (max-width: 1100px) { .stability-hero, .stability-grid, .stability-grid.two { grid-template-columns: 1fr; } .stability-strip { grid-template-columns: repeat(2, minmax(120px, 1fr)); } .stability-events article { grid-template-columns: 1fr; } }

/* v1.7 interface sizing and filter-only collapse */
:root{--sidebar-width:252px;--day-min-width:250px;--room-min-width:360px;--slot-height:112px;--vertical-slot-height:96px}
.layout,.layout.filters-collapsed{grid-template-columns:minmax(190px,var(--sidebar-width)) minmax(0,1fr)}.layout.filters-collapsed .sidebar{display:grid}.filter-controls{display:grid;gap:10px}.layout.filters-collapsed .filter-controls{display:none}.layout.filters-collapsed .sidebar-head{margin-bottom:0}.content-tools{display:none}
.ops-board{grid-template-columns:repeat(var(--day-count),minmax(var(--day-min-width),1fr))}.board-day{min-width:var(--day-min-width)}.vertical-rooms{grid-template-columns:repeat(auto-fit,minmax(var(--room-min-width),1fr))}.slot-row{min-height:calc(var(--slot-height)*var(--card-scale))}.day-slot-row{min-height:var(--vertical-slot-height)}.board-card{padding:clamp(4px,calc(var(--board-font-size)*.45),8px)}
body[data-density="dense"] .slot-row{min-height:calc(var(--slot-height)*.78*var(--card-scale))}body[data-density="normal"] .slot-row{min-height:calc(var(--slot-height)*1.15*var(--card-scale))}body[data-density="dense"] .day-slot-row{min-height:calc(var(--vertical-slot-height)*.82)}body[data-density="normal"] .day-slot-row{min-height:calc(var(--vertical-slot-height)*1.15)}
body[data-fit-week="1"] .layout{gap:8px;padding:8px}body[data-fit-week="1"] .sidebar{padding:10px;gap:8px}body[data-fit-week="1"] .ops-board{grid-template-columns:repeat(var(--day-count),minmax(min(180px,var(--day-min-width)),1fr));gap:6px;padding:6px;overflow-x:visible}body[data-fit-week="1"] .board-day{min-width:0}body[data-fit-week="1"] .board-day-head,body[data-fit-week="1"] .vertical-day-head,body[data-fit-week="1"] .board-room-head{padding:5px 7px}body[data-fit-week="1"] .board-day-rooms,body[data-fit-week="1"] .vertical-rooms{gap:6px;padding:6px}body[data-fit-week="1"] .slot-row{grid-template-columns:24px minmax(0,1fr);min-height:calc(var(--slot-height)*.68*var(--card-scale))}body[data-fit-week="1"] .day-slot-row{grid-template-columns:34px minmax(0,1fr);min-height:calc(var(--vertical-slot-height)*.72)}body[data-fit-week="1"] .board-meta,body[data-fit-week="1"] .board-diagnosis,body[data-fit-week="1"] .board-operation,body[data-fit-week="1"] .board-preparation,body[data-fit-week="1"] .board-team,body[data-fit-week="1"] .board-tags{-webkit-line-clamp:1}body[data-fit-week="1"] .board-card{gap:2px}body[data-fit-week="1"] .day-slot-main{gap:3px;padding:6px}
@media(max-width:1100px){.layout,.layout.filters-collapsed{grid-template-columns:1fr}.sidebar{position:static}.layout.filters-collapsed .sidebar{display:grid}}

/* v1.7.1c safe repair */
.v171c-hidden-role-hint,
#modeHint {
  display: none !important;
}

/* Keep only useful Week horizontal scrolling */
body.v171c-week-board #content,
body.v171c-week-board .content,
body.v171c-week-board .main-panel,
body.v171c-week-board .week-panel,
body[data-view="week"] #content,
body[data-view="week"] .content,
body[data-view="week"] .main-panel,
body[data-view="week"] .week-panel {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

body.v171c-week-board .ops-board,
body.v171c-week-board .ops-board.v1-board,
body[data-view="week"] .ops-board,
body[data-view="week"] .ops-board.v1-board {
  min-width: max-content !important;
  overflow: visible !important;
}

/* Restore neutral empty slots */
.slot-row.empty {
  min-height: var(--slot-height, 112px);
}

.slot-row.empty .slot-content {
  padding: 4px;
}

/* Hide failed slot deletion remnants from cached DOM */
.slot-remove-empty {
  display: none !important;
}

/* v1.7.1d empty slot deletion */
.empty-slot-v171d {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 6px;
  align-items: stretch;
  width: 100%;
}

.empty-slot-v171d .slot-add {
  min-height: 36px !important;
  height: 36px !important;
  border-radius: 8px !important;
}

.slot-delete-empty-v171d {
  min-width: 40px !important;
  width: 40px !important;
  min-height: 36px !important;
  height: 36px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: #eef2f7 !important;
  color: #334155 !important;
  font-size: 18px !important;
  line-height: 1 !important;
}

.slot-delete-empty-v171d:active {
  background: #dbe3ef !important;
}

.slot-row.empty .slot-content {
  padding: 4px !important;
}

/* v1.7.1e day edit protection */
.day-lock-button-v171e {
  min-width: 36px !important;
  min-height: 32px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: rgba(255,255,255,.82) !important;
  color: #334155 !important;
  font-size: 15px !important;
  line-height: 1 !important;
}

.day-locked-v171e .vertical-day-head,
.day-locked-v171e .board-day-head {
  background: linear-gradient(90deg, #475569, #64748b) !important;
}

.day-locked-v171e .vertical-day-head::after,
.day-locked-v171e .board-day-head::after {
  content: "день защищён";
  margin-left: auto;
  margin-right: 8px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,.86);
}

.day-locked-v171e .slot-add,
.day-locked-v171e .slot-delete-empty-v171d,
.day-locked-v171e .add-room-row button,
.day-locked-v171e button[onclick*="addSlot"],
.day-locked-v171e button[onclick*="openEditor(null"] {
  opacity: .45 !important;
  pointer-events: none !important;
}

.day-locked-note-v171e {
  display: inline-block;
  margin: 4px 0 0 0;
  padding: 3px 6px;
  border-radius: 999px;
  background: #eef2f7;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
}

/* Stable patient-card presentation */
.board-card.patient-card {
  display: flex !important;
  flex-direction: column !important;
  gap: 2px !important;
  position: relative !important;
  min-height: 0 !important;
  padding: 6px 8px !important;
  border-width: 0 !important;
  border-radius: 12px !important;
  box-shadow: none !important;
  cursor: pointer !important;
  touch-action: manipulation !important;
  -webkit-tap-highlight-color: rgba(15, 94, 114, 0.10);
}

.patient-card .board-card-head {
  display: block !important;
  min-height: 22px !important;
  padding: 0 !important;
  margin: 0 !important;
  text-align: center !important;
}

.patient-card .board-card-head b {
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  text-align: center !important;
  font-size: 13.5px !important;
  font-weight: 800 !important;
  line-height: 1.08 !important;
  color: #102033 !important;
}

.patient-card .board-diagnosis {
  margin: 1px 0 0 0 !important;
  text-align: center !important;
  font-size: 11px !important;
  line-height: 1.12 !important;
  font-weight: 500 !important;
  color: #5b6b7d !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 1 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
}

.patient-card .board-operation {
  margin: 0 !important;
  text-align: center !important;
  font-size: 12.5px !important;
  font-weight: 800 !important;
  line-height: 1.12 !important;
  color: #102033 !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
}

.patient-card-meta {
  display: flex !important;
  flex-wrap: nowrap !important;
  justify-content: center !important;
  gap: 4px !important;
  margin: 2px 0 0 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  white-space: nowrap !important;
}

.patient-card-finance,
.patient-card-number {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  max-width: 100% !important;
  min-height: 20px !important;
  padding: 2px 7px !important;
  border-radius: 999px !important;
  font-size: 10.5px !important;
  line-height: 1 !important;
  font-weight: 800 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.patient-card-finance {
  background: rgba(15,94,114,.12) !important;
  color: #0f5e72 !important;
}

.patient-card-number {
  background: rgba(226,232,240,.92) !important;
  color: #405166 !important;
}

.patient-card .emias-badge {
  align-self: center;
}

.patient-card .board-preparation {
  margin: 2px 0 0 0 !important;
  padding: 2px 7px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: rgba(255,255,255,.68) !important;
  color: #5b6b7d !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  line-height: 1.08 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  text-align: center !important;
}

.patient-card .board-team {
  margin: 2px 0 0 0 !important;
  padding: 2px 7px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: rgba(15,94,114,.10) !important;
  color: #405166 !important;
  font-size: 10.5px !important;
  font-weight: 800 !important;
  line-height: 1.08 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  text-align: center !important;
}

.patient-card .board-tags {
  margin: 2px 0 0 0 !important;
  display: flex !important;
  justify-content: center !important;
  gap: 4px !important;
  overflow: hidden !important;
}

.patient-card .board-tags span,
.patient-card .tag,
.patient-card .badge,
.patient-card .chip {
  border: 0 !important;
  border-radius: 999px !important;
  padding: 2px 7px !important;
  font-size: 10px !important;
  line-height: 1 !important;
  font-weight: 800 !important;
  white-space: nowrap !important;
}

.patient-card.ready-ready {
  background: #eaf7ef !important;
}

.patient-card.ready-pending,
.patient-card.warn {
  background: #fff8e8 !important;
}

.patient-card.conflict {
  background: #fdecec !important;
}

.patient-card:active {
  filter: brightness(0.985);
}

body[data-density="dense"] .patient-card {
  gap: 1px !important;
  padding-top: 5px !important;
  padding-bottom: 5px !important;
}

body[data-density="dense"] .patient-card .board-diagnosis,
body[data-density="dense"] .patient-card .board-operation {
  -webkit-line-clamp: 1 !important;
}

body[data-fit-week="1"] .patient-card {
  padding: 4px 6px !important;
  gap: 1px !important;
  border-radius: 8px !important;
}

body[data-fit-week="1"] .patient-card .board-card-head b {
  text-align: left !important;
  font-size: 11px !important;
  -webkit-line-clamp: 1 !important;
}

body[data-fit-week="1"] .patient-card-meta,
body[data-fit-week="1"] .patient-card .board-preparation,
body[data-fit-week="1"] .patient-card .board-tags {
  display: none !important;
}

body[data-fit-week="1"] .patient-card .board-diagnosis,
body[data-fit-week="1"] .patient-card .board-operation,
body[data-fit-week="1"] .patient-card .board-team {
  text-align: left !important;
  font-size: 10px !important;
  line-height: 1.05 !important;
  -webkit-line-clamp: 1 !important;
}

/* v1.8 clinical workspace shell. The desktop interface remains the fallback. */
:root {
  --workspace-surface: #ffffff;
  --workspace-ink: #102844;
  --workspace-muted: #526477;
  --workspace-accent: #0f5e72;
  --workspace-border: #d6e0e8;
  --workspace-shadow: 0 -12px 32px rgba(16, 40, 68, .18);
  --workspace-radius: 14px;
  --workspace-space: 12px;
  --workspace-tap-size: 44px;
}

.workspace-mobile-header,
.workspace-command-strip,
.workspace-sheet-root {
  display: none;
}

.workspace-sheet-root.is-open {
  display: block;
}

.workspace-sheet-root {
  position: fixed;
  z-index: 1000;
  inset: 0;
}

.workspace-sheet-overlay {
  position: absolute;
  inset: 0;
  background: rgba(16, 40, 68, .42);
}

.workspace-sheet {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  max-height: min(78dvh, 680px);
  overflow: auto;
  border-radius: var(--workspace-radius) var(--workspace-radius) 0 0;
  background: var(--workspace-surface);
  box-shadow: var(--workspace-shadow);
}

.workspace-sheet-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--workspace-space);
  min-height: 56px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--workspace-border);
  background: var(--workspace-surface);
}

.workspace-sheet-head h2 {
  margin: 0;
  color: var(--workspace-ink);
  font-size: 16px;
}

.workspace-sheet-head button,
.workspace-sheet-content button,
.workspace-sheet-content select,
.workspace-sheet-content input {
  min-height: var(--workspace-tap-size);
  font-size: max(11px, .875rem);
}

.workspace-sheet-content {
  display: grid;
  gap: 10px;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
}

.workspace-sheet-menu {
  display: grid;
  gap: 8px;
}

.workspace-sheet-menu button {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--workspace-border);
  border-radius: 10px;
  background: #fff;
  color: var(--workspace-ink);
  font-weight: 700;
  text-align: left;
}

.workspace-sheet-menu button:focus-visible,
.workspace-bottom-nav button:focus-visible,
.workspace-command-strip button:focus-visible,
.workspace-profile-button:focus-visible {
  outline: 3px solid #4f9cc3;
  outline-offset: 2px;
}

.workspace-filter-form {
  display: grid;
  gap: 10px;
}

.workspace-filter-form label {
  display: grid;
  gap: 4px;
  color: var(--workspace-ink);
  font-size: 12px;
  font-weight: 700;
}

.workspace-filter-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.workspace-filter-actions .primary {
  grid-column: span 2;
}

@media (max-width: 980px) {
  body {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  body.workspace-sheet-open {
    overflow: hidden;
  }

  .topbar {
    min-height: 0;
    padding: 0;
    background: var(--workspace-surface);
  }

  .topbar > div:first-child,
  .topbar .authbar {
    display: none;
  }

  .workspace-mobile-header {
    display: grid;
    gap: 6px;
    width: 100%;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
    border-bottom: 1px solid var(--workspace-border);
  }

  .workspace-mobile-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .workspace-mobile-title-row h1 {
    margin: 0;
    color: var(--workspace-ink);
    font-size: 18px;
    line-height: 1.15;
  }

  .workspace-mobile-title-row p {
    margin: 2px 0 0;
    color: var(--workspace-muted);
    font-size: 12px;
    line-height: 1.2;
  }

  .workspace-profile-button {
    min-width: var(--workspace-tap-size);
    min-height: var(--workspace-tap-size);
    padding: 6px 10px;
    border: 1px solid var(--workspace-border);
    border-radius: 10px;
    background: #fff;
    color: var(--workspace-ink);
    font-size: 12px;
    font-weight: 700;
  }

  .workspace-mobile-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
  }

  .workspace-mobile-summary span,
  .workspace-filter-chips span {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #eaf2f5;
    color: #24465d;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.1;
  }

  .layout,
  .layout.filters-collapsed {
    display: block;
    padding: 8px;
  }

  .sidebar,
  .layout.filters-collapsed .sidebar {
    display: none;
  }

  .content-tools,
  .tabs {
    display: none !important;
  }

  .workspace-command-strip {
    display: grid;
    gap: 7px;
    margin: 0 0 8px;
    padding: 8px;
    border: 1px solid var(--workspace-border);
    border-radius: 12px;
    background: var(--workspace-surface);
  }

  .workspace-week-controls,
  .workspace-command-actions {
    display: grid;
    grid-template-columns: var(--workspace-tap-size) minmax(0, 1fr) var(--workspace-tap-size);
    gap: 6px;
  }

  .workspace-command-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace-command-strip button {
    min-height: var(--workspace-tap-size);
    padding: 6px 8px;
    border: 1px solid var(--workspace-border);
    border-radius: 9px;
    background: #fff;
    color: var(--workspace-ink);
    font-size: 12px;
    font-weight: 700;
  }

  .workspace-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
  }

  .workspace-bottom-nav {
    position: fixed;
    z-index: 900;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px;
    min-height: calc(64px + env(safe-area-inset-bottom));
    padding: 5px 5px calc(5px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--workspace-border);
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 -4px 14px rgba(16, 40, 68, .08);
  }

  .workspace-bottom-nav button {
    min-height: var(--workspace-tap-size);
    padding: 4px 2px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--workspace-muted);
    font-size: 11px;
    font-weight: 800;
  }

  .workspace-bottom-nav button.is-active {
    background: #deeff4;
    color: #0b5064;
  }

  .workspace-sheet-root.is-open {
    display: block;
  }
}

@media print {
  .workspace-mobile-header,
  .workspace-command-strip,
  .workspace-bottom-nav,
  .workspace-sheet-root {
    display: none !important;
  }
}
/* Optional text presets share the ordinary note editor and its native history. */
.plan-editor-notes > label { margin: 0; }
.note-presets > summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: #285d50; }
.note-presets > summary::before { content: "+"; margin-right: 8px; }
.note-presets[open] > summary::before { content: "−"; }
.note-preset-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.note-preset-buttons button { min-height: 44px; min-width: 44px; padding: 7px 10px; border: 1px solid #c7d7d1; border-radius: 8px; color: #264d41; background: #fff; font-size: 13px; }
.note-preset-buttons button[aria-pressed="true"] { border-color: #246f58; box-shadow: inset 0 0 0 1px #246f58; background: #edf5f1; }
.note-preset-status { margin: 0; font-size: 12px; line-height: 1.4; color: #40594f; }

#placementModal .placement-panel {
  display:flex; flex-direction:column; width:min(500px,calc(100vw - 32px));
  height:auto; max-height:min(88dvh,820px); min-height:0; overflow:hidden;
}
#placementModal .placement-head, #placementModal .placement-footer { flex:0 0 auto; }
#placementModal .placement-fields { min-height:0; overflow-y:auto; overflow-wrap:anywhere; }
#placementModal .placement-summary { display:grid; grid-template-columns:auto minmax(0,1fr); gap:6px 12px; }
#placementModal .placement-summary dd { margin:0; }
#placementModal .placement-footer { display:flex; flex-wrap:wrap; gap:8px; }
@media screen and (max-width:980px) {
  #placementModal {
    top:var(--placement-viewport-top,0px); bottom:auto; left:0; right:0;
    height:var(--placement-viewport-height,100dvh); box-sizing:border-box;
    align-items:flex-end; justify-content:center; padding:8px;
  }
  #placementModal .placement-panel {
    width:100%; margin:0; box-sizing:border-box;
    max-height:min(var(--placement-visible-cap,80dvh),calc(var(--placement-viewport-height,100dvh) - 16px));
  }
  #placementModal button, #placementModal select { min-width:44px; min-height:44px; }
  #placementModal .placement-footer { display:grid; grid-template-columns:1fr 1fr; }
  #placementModal #placementConfirm { grid-column:1 / -1; }
}

#placementModal { opacity:0; transition:opacity 240ms ease; }
#placementModal.is-open { opacity:1; }
#placementModal.is-closing { opacity:0; transition-duration:180ms; pointer-events:none; }
#placementModal .placement-panel { transform:translateY(20px); transition:transform 240ms ease; border:1px solid #b8cdc1; border-radius:14px; }
#placementModal.is-open .placement-panel { transform:translateY(0); }
#placementModal.is-closing .placement-panel { transform:translateY(20px); transition-duration:180ms; }
#placementModal .placement-fields p { margin:0; }
#placementModal .placement-summary { margin:0; }
#placementModal select { max-width:100%; width:100%; min-width:0; }
#placementModal .placement-head button { min-width:44px; min-height:44px; }
@media screen and (max-width:980px) {
 #placementModal .placement-panel { transform:translateY(36px); }
 #placementModal.is-open .placement-panel { transform:translateY(0); }
 #placementModal.is-closing .placement-panel { transform:translateY(36px); }
 #placementModal select { font-size:16px; }
}
@media (prefers-reduced-motion:reduce) {
 #placementModal, #placementModal .placement-panel { transition:none; }
}

#appHeader .unified-header-session {
  grid-template-columns: minmax(0, auto) 44px auto auto;
  grid-template-rows: 1fr;
  align-items: center;
}
#appHeader #operationsClockPanel { grid-column: 1; grid-row: 1; }
#appHeader #appSaveStatus {
  display: grid;
  grid-column: 2;
  grid-row: 1;
  place-items: center;
  align-self: center;
  justify-self: center;
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  padding: 0;
  margin: 0;
  transform: none;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #a2e4bf;
  line-height: 1;
  overflow: visible;
}
#appHeader #appSaveStatus::before { content: none; }
#appHeader #appSaveStatus > svg { width: 18px; height: 18px; pointer-events: none; }
#appHeader #appSaveStatus:focus-visible { outline: 2px solid #fff; outline-offset: -3px; }
#appHeader #appHeaderAccount { grid-column: 3; grid-row: 1; }
#appHeader #appHeaderMenu { grid-column: 4; grid-row: 1; }
@media screen and (max-width: 980px) {
  #appHeader .unified-header-session {
    grid-template-columns: 72px repeat(3, 44px);
    grid-template-rows: 72px;
    gap: 0 6px;
  }
  #appHeader .unified-brand-identity > div { min-width: 0; }
  #appHeader .unified-header-account,
  #appHeader .unified-header-menu {
    width: 44px;
    max-width: 44px;
    height: 44px;
    max-height: 44px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media screen and (max-width: 420px) {
  #appHeader .unified-header-brand {
    gap: 3px;
    padding-right: max(4px, env(safe-area-inset-right));
    padding-left: max(4px, env(safe-area-inset-left));
  }
  #appHeader .unified-header-session { column-gap: 4px; }
  #appHeader .unified-brand-identity { gap: 3px; }
}

#appHeader #appSaveStatus[hidden] { display: none; }
#appHeader #appSaveStatus[data-state="busy"] { color: #f3edc7; }
#appHeader #appSaveStatus:is([data-state="unknown"], [data-state="saved_view_stale"]) { color: #ffd780; }
#appHeader #appSaveStatus:is([data-state="rejected"], [data-state="error"]) { color: #ffc2bd; }
#appHeader #appSaveStatus[data-state="offline"] { color: #d3ddda; }
#quietImportantLive { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
#realtimeSyncStatus { display: none; }
#quietDetails { display: grid; gap: 12px; overflow-wrap: anywhere; }
#quietDetails p { margin: 0; line-height: 1.45; }
#quietDetailEvents { display: grid; gap: 12px; }
#quietDetailEvents section { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; border-top: 1px solid #dce7e3; }
#quietDetailEvents p { flex: 0 0 100%; }
#quietDetailEvents button { min-width: 44px; min-height: 44px; }
#quietDetailEvents [hidden] { display: none; }
#quietDetailRead { font-size: 12px; color: #5d6e67; }

/* Activity journal: details wrap on narrow screens, without a horizontal table. */
.activity-journal { display: grid; gap: 12px; }
.activity-filters, .activity-pages { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.activity-filters label { display: grid; gap: 4px; flex: 1 1 150px; min-width: 0; }
.activity-filters input { width: 100%; min-width: 0; box-sizing: border-box; }
.activity-event { border: 1px solid var(--border, #cbd5e1); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.activity-event summary { cursor: pointer; display: grid; grid-template-columns: minmax(140px, 1fr) minmax(80px, .6fr) minmax(150px, 1fr) minmax(130px, 1fr); gap: 8px; overflow-wrap: anywhere; }
.activity-event summary:focus-visible { outline: 2px solid #17659b; outline-offset: 3px; }
.activity-details, .activity-object { display: grid; gap: 8px; margin-top: 10px; min-width: 0; overflow-wrap: anywhere; }
.activity-object > button { justify-self: start; }
.activity-change { display: grid; grid-template-columns: minmax(100px, .6fr) minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding: 8px 0; border-top: 1px solid var(--border, #cbd5e1); white-space: pre-wrap; }
@media (max-width: 640px) {
  .activity-event summary, .activity-change { grid-template-columns: minmax(0, 1fr); }
  .activity-filters button, .activity-pages button { min-height: 44px; }
}
