body[data-view="exchange"] .content > .panel > .panel-head { display: none; }
body[data-view="exchange"] .content > .panel { overflow: visible; border: 0; background: transparent; box-shadow: none; }
.exchange-route { --pe-green: #075743; --pe-ink: #173044; --pe-columns: minmax(0, 1.25fr) minmax(0, .95fr) minmax(0, .95fr) minmax(0, .72fr) 94px minmax(0, 1fr); min-width: 0; padding: 8px; color: var(--pe-ink); }
.exchange-route *, .pe-ghost { box-sizing: border-box; }
.pe-notice { margin: 0 0 8px; padding: 8px 12px; color: #854249; background: #fff1f2; border-radius: 7px; }
.pe-notice:empty { display: none; }
.pe-layout { display: grid; grid-template-columns: minmax(0, 1.28fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.pe-fund-panel, .pe-mini-plan { min-width: 0; overflow: visible; scroll-margin-block: 12px 90px; }
.pe-workspace-header { min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 7px 10px; color: #fff; background: var(--pe-green); }
.pe-workspace-header h2 { flex: 1; text-align: center; font-size: 16px; margin: 0; }
.pe-workspace-header > span { min-width: 34px; padding: 6px; border: 1px solid #ffffff47; border-radius: 7px; text-align: center; }
.pe-workspace-header button { color: #fff; border-color: #ffffff47; background: transparent; font-size: 12px; }
.pe-workspace-header [data-pe-mini-jump], .pe-workspace-header [data-pe-return] { min-width: 44px; min-height: 44px; }
.pe-funds-scroll, .pe-plan-scroll { height: auto; max-height: none; overflow: visible; }
.pe-funds-scroll { padding: 8px 0; }
.pe-fund { position: relative; min-width: 0; margin-bottom: 14px; border-top: 1px solid #c7ddc4; border-bottom: 1px solid #c7ddc4; background: #eff9ec; transition: background-color 180ms ease, box-shadow 180ms ease; }
.pe-fund:last-child { margin-bottom: 0; }
.pe-fund[data-pe-fund-id="pending"] { border-color: #eccbd0; background: #fff1f2; }
.pe-fund-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 50px; padding: 8px 12px; border-bottom: 1px solid #c9dec6; background: #dff4d9; }
.pe-fund[data-pe-fund-id="pending"] .pe-fund-header { border-color: #ebc8cd; background: #fbdde0; }
.pe-fund-header h3 { margin: 0; font-size: 14px; }
.pe-tools { display: flex; align-items: center; gap: 6px; }
.pe-tools button { font-size: 11px; font-weight: 600; padding: 5px 8px; }
.pe-count { min-width: 38px; font-size: 12px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.pe-column-head { display: grid; grid-template-columns: var(--pe-columns); gap: 7px; margin-left: 42px; padding: 7px 10px 4px; color: #60756b; font-size: 10px; font-weight: 700; text-align: center; }
.pe-fund-rows { display: grid; gap: 7px; padding: 5px 9px 10px; margin: 0; list-style: none; }
.pe-row { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 5px; align-items: stretch; }
.pe-row-number { display: grid; place-items: center; min-height: 54px; border-radius: 8px; color: #244a3e; background: #07574312; font-size: 12px; font-weight: 700; }
.pe-card { min-width: 0; overflow-wrap: anywhere; border: 1px solid #cadad5; border-radius: 9px; background: #ffffffeb; transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, outline-color 180ms ease; }
.pe-fund-card { display: grid; grid-template-columns: var(--pe-columns); gap: 7px; align-items: center; min-height: 78px; padding: 8px 9px; }
.pe-patient { min-width: 0; text-align: center; }
.pe-patient > strong { display: block; color: #153c31; font-size: 12px; line-height: 1.4; }
.pe-patient-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; margin-top: 5px; color: #587066; font-size: 11px; line-height: 1.35; }
.pe-cell { min-width: 0; color: #28493f; font-size: 12px; line-height: 1.35; text-align: center; }
.pe-note { min-width: 0; align-self: stretch; padding-left: 8px; border-left: 1px solid #d6e2de; color: #51665e; font-size: 11px; line-height: 1.4; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; }
.pe-fund[data-pe-fund-id="pending"] .pe-note { border-color: #ecd1d4; }
.pe-missing { color: #243f36; font-weight: 800; }
.pe-card-actions { display: grid; gap: 4px; }
.pe-card-actions button { min-height: 28px; padding: 3px 5px; font-size: 11px; }
.pe-delete { border-color: #e3b3b6; color: #a43139; }
.pe-empty-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; min-height: 54px; padding: 7px 10px; border: 1px solid #91b3a673; border-radius: 9px; color: #61776b; background: #ffffff78; font-size: 12px; transition: background-color 180ms ease, box-shadow 180ms ease, outline-color 180ms ease; }
.pe-empty-row > span { grid-column: 2; text-align: center; }
.pe-empty-row button { grid-column: 3; justify-self: end; min-height: 30px; padding: 4px 8px; font-size: 11px; }
.pe-week-navigation { display: grid; grid-template-columns: 36px minmax(0, 1fr) 36px; gap: 6px; padding: 7px; border-bottom: 1px solid #cddcd7; }
.pe-week-navigation button { padding: 2px; font-size: 22px; }
.pe-week-navigation select { min-width: 0; width: 100%; min-height: 34px; text-align: center; color: #31584c; background: #eef7f3; font-size: 12px; }
.pe-plan-scroll { padding: 8px; }
.pe-day { overflow: hidden; margin-bottom: var(--day-gap, 8px); border: 1px solid #b7d0c7; border-radius: 8px; background: #f7fbf9; }
.pe-day > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 34px; padding: 6px 8px; color: #fff; background: var(--pe-green); }
.pe-day h3 { margin: 0; font-size: 12px; }
.pe-day h3 span { margin-left: 7px; font-size: 11px; font-weight: 500; color: #c9e2da; }
.pe-day > header > span { font-size: 11px; }
.pe-lock { padding: 3px 5px; border-radius: 7px; color: #6a3237; background: #f7d9dc; font-size: 10px; }
.pe-day-grid-scroll { overflow-x: auto; overscroll-behavior-x: contain; }
.pe-day-grid { width: 100%; min-width: calc(34px + var(--pe-rooms) * 155px); table-layout: fixed; border-collapse: collapse; }
.pe-day-grid th, .pe-day-grid td { border: 1px solid #c7dad3; }
.pe-day-grid thead th { height: 28px; padding: 4px; color: #345a4e; background: #dfeee9; font-size: 11px; text-align: center; }
.pe-day-grid thead th:first-child, .pe-day-grid tbody th { width: 34px; color: #31594c; font-size: 11px; text-align: center; }
.pe-plan-row { position: relative; height: 108px; padding: 3px; vertical-align: top; background: #eaf5ef; outline: 1px dashed #73a995; outline-offset: -5px; transition: background-color 180ms ease, box-shadow 180ms ease, outline-color 180ms ease; }
.pe-plan-row.pe-occupied { outline: none; background: #fff3d5; }
.pe-plan-unavailable { background: #eef1f0; }
.pe-plan-row .pe-empty { display: grid; place-items: center; min-height: 100px; color: #5b8a79; font-size: 12px; }
.pe-mini-card { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px; min-height: 100px; padding: 6px; border-color: #d1ad62; border-radius: 5px; background: #fff9e6f2; text-align: center; }
.pe-mini-name { font-size: 12px; line-height: 1.4; color: #304a41; }
.pe-mini-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; font-size: 10px; color: #66776f; }
.pe-mini-card .pe-procedure, .pe-mini-card .pe-team { font-size: 11px; line-height: 1.35; color: #3f5f54; }
.pe-mini-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 3px; }
.pe-mini-actions button { min-height: 24px; padding: 3px 5px; font-size: 10px; }
.pe-card[data-pe-transfer-source] { cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.pe-row.pe-current-target > .pe-card, .pe-row.pe-current-target > .pe-empty-row,
.pe-plan-row.pe-current-target, .pe-fund-header.pe-current-target {
  outline: 3px solid #b96708; outline-offset: -3px;
  box-shadow: inset 0 0 0 3px #b96708; background-color: #fff4db;
}
.pe-drag-active .pe-card, .pe-drag-active .pe-empty-row, .pe-drag-active .pe-plan-row { transition: none; }
.pe-drag-source { opacity: .35; }
.pe-note-text { line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 7em; overflow: hidden; }
.pe-note-text.is-note-expanded { max-height: none; }
.pe-note [data-pe-note] { min-width: 44px; min-height: 44px; margin-top: 2px; }
.pe-note [data-pe-note][hidden] { display: none; }
.pe-drag-active { user-select: none; -webkit-user-select: none; }
.pe-ghost {
  box-sizing: border-box; position: fixed; z-index: 10020; pointer-events: none;
  width: min(240px, calc(100vw - 16px)); min-height: 0; max-height: 110px;
  display: grid; gap: 4px; padding: 9px 11px; overflow: hidden;
  border: 1px solid #b96708; border-radius: 9px; background: #fff; color: #173044;
  opacity: 1; box-shadow: 0 10px 35px #1c3f3838;
}
.pe-ghost-name, .pe-ghost-procedure {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; overflow-wrap: anywhere; line-height: 1.3; font-size: 13px;
}
.pe-target-status {
  position: fixed; z-index: 10030; left: 8px; right: 8px; max-width: 560px;
  margin-inline: auto; padding: 8px 12px; border: 2px solid #b96708;
  border-radius: 9px; color: #623905; background: #fff6e5;
  box-shadow: 0 5px 18px #30200926; font-size: 13px; line-height: 1.3; pointer-events: none;
}
.pe-target-status[hidden] { display: none; }
.pe-target-status[data-outcome="unavailable"] { border-color: #9b454b; color: #792d34; background: #fff1f2; }
.pe-exchange-field[hidden], body[data-view="exchange"] #editModal button[hidden] { display: none !important; }
@media (max-width: 1050px) {
  .pe-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 980px) {
  .exchange-route button { min-width: 44px; min-height: 44px; }
  body[data-view="exchange"] #editModal .plan-editor-panel button,
  body[data-view="exchange"] #editModal .plan-editor-confirm-actions button { min-width: 44px; min-height: 44px; }
  body[data-view="exchange"] #editModal .plan-editor-close { flex-basis: 44px; }
  body[data-view="exchange"] #editModal .plan-editor-person { grid-template-columns: 26px minmax(0, 1fr) 44px; }
  .pe-week-navigation { grid-template-columns: 44px minmax(0, 1fr) 44px; }
  .pe-week-navigation select { min-height: 44px; }
  .pe-day-grid { min-width: calc(34px + var(--pe-rooms) * 180px); }
  .pe-mini-actions button { font-size: 11px; }
}
@media (max-width: 600px) {
  .exchange-route { padding: 6px; }
  .pe-fund-header { flex-wrap: wrap; padding: 9px; }
  .pe-tools { margin-left: auto; }
  .pe-column-head { display: none; }
  .pe-fund-card { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pe-patient, .pe-note, .pe-card-actions { grid-column: 1 / -1; }
  .pe-cell { font-size: 13px; }
  .pe-note { padding: 8px 0 0; border-left: 0; border-top: 1px solid #d6e2de; font-size: 13px; }
  .pe-card-actions { display: flex; }
  .pe-card-actions button { flex: 1; font-size: 12px; }
  .pe-cell::before, .pe-note::before { display: block; margin-bottom: 4px; color: #60756b; font-size: 11px; font-weight: 600; content: attr(data-pe-caption); }
  .pe-empty-row { grid-template-columns: minmax(0, 1fr) auto; }
  .pe-empty-row > span { grid-column: 1; }
  .pe-empty-row button { grid-column: 2; }
  .pe-day > header { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .exchange-route *, .exchange-route *::after, .pe-ghost { transition: none !important; animation: none !important; }
}
.pe-name-mobile { display: none; }
@media screen and (max-width: 980px) {
  .pe-name-full { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .pe-name-mobile { display: inline; }
  .pe-workspace-header { gap: 6px; padding: 3px 7px; }
  .pe-workspace-header h2 { font-size: 14px; }
}
@media screen and (max-width: 600px) {
  .exchange-route .pe-fund-card {
    grid-template-columns: minmax(0, 1fr) 90px;
    gap: 4px 7px;
    padding: 7px;
  }
  .exchange-route .pe-fund-card .pe-patient { grid-column: 1; grid-row: 1; }
  .exchange-route .pe-fund-card > [data-pe-caption="Диагноз"] { grid-column: 1; grid-row: 3; font-size: 12px; }
  .exchange-route .pe-fund-card > .pe-procedure { grid-column: 1; grid-row: 2; font-size: 14px; }
  .exchange-route .pe-fund-card > .pe-team { grid-column: 1 / -1; grid-row: 4; }
  .exchange-route .pe-fund-card > .pe-note { grid-column: 1 / -1; grid-row: 5; }
  .exchange-route .pe-fund-card > .pe-card-actions {
    grid-column: 2; grid-row: 1 / 4;
    display: grid; align-content: start; gap: 4px;
  }
  .exchange-route .pe-patient > strong { font-size: 13px; line-height: 1.2; }
  .exchange-route .pe-fund-card .pe-cell::before { display: inline; margin: 0 4px 0 0; font-size: 10px; }
  .exchange-route .pe-fund-card .pe-note::before { display: none; }
  .exchange-route .pe-fund-card .pe-note { padding-top: 4px; }
  .exchange-route .pe-patient-meta { margin-top: 2px; gap: 3px 7px; }
  .exchange-route .pe-patient-meta > span:has(.pe-missing) { display: none; }
  .exchange-route .pe-mini-name { line-height: 1.2; }
}

@media screen and (max-width: 600px) {
  .exchange-route .pe-field-hidden,
  .exchange-route .pe-meta-empty { display: none; }
  .exchange-route .pe-hide-diagnosis .pe-fund-card > .pe-team { grid-row: 3; }
  .exchange-route .pe-hide-diagnosis .pe-fund-card > .pe-card-actions { grid-row: 1 / 3; }
  .exchange-route .pe-hide-diagnosis .pe-fund-card > .pe-note,
  .exchange-route .pe-hide-team .pe-fund-card > .pe-note { grid-row: 4; }
  .exchange-route .pe-hide-diagnosis.pe-hide-team .pe-fund-card > .pe-note { grid-row: 3; }
}

/* Shared settings govern complete semantic rows; table siblings share their tallest cell. */
.pe-row:has(.pe-fund-card) { min-height: var(--occupied-slot-height, 80px); }
.pe-row:has(.pe-empty-row) { min-height: var(--empty-slot-height, 52px); }
.pe-plan-row { height: max(108px, var(--empty-slot-height, 52px)); }
.pe-plan-row.pe-occupied { height: max(108px, var(--occupied-slot-height, 80px)); }
[data-pe-clinical="diagnosis"] { --clinical-lines: var(--patient-diagnosis-lines, 1); }
[data-pe-clinical="operation"] { --clinical-lines: var(--patient-operation-lines, 2); }
.pe-card [data-pe-clinical] {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--clinical-lines);
  overflow: hidden; overflow-wrap: anywhere;
}
.pe-card.is-clinical-expanded [data-pe-clinical] { -webkit-line-clamp: unset; }
.pe-card button[data-pe-clinical-toggle] { min-width: 44px; min-height: 44px; }
.pe-card button[data-pe-clinical-toggle][hidden] { display: none; }
