/* Лечение: карточки приёмов и исследований, файлы, распознавание, показатели и графики.
   Общие карточки — room-card/health-card, таблицы — health-table, здесь только своё. */
.treatment-head-actions { display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
.treatment-head-actions .secondary,.treatment-head-actions .primary { min-height:42px; }

.treatment-date-tile { display:grid; justify-items:center; align-content:center; gap:1px; inline-size:84px; block-size:84px; border-radius:14px; background:color-mix(in srgb,#2d83e5 13%,transparent); color:#1f6ac0; }
.treatment-date-tile b { font-size:27px; line-height:1; font-weight:800; }
.treatment-date-tile span { font-size:13px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; }
.treatment-date-tile small { font-size:12px; color:var(--muted); }
.treatment-date-tile.is-planned { background:color-mix(in srgb,#f5a623 20%,transparent); color:#9a6421; }
.treatment-date-tile.is-cancelled { background:color-mix(in srgb,var(--muted) 14%,transparent); color:var(--muted); }
html[data-theme="dark"] .treatment-date-tile { color:#9cc4ff; }
html[data-theme="dark"] .treatment-date-tile.is-planned { color:#f0c985; }

.treatment-research-icon { display:grid; place-items:center; inline-size:84px; block-size:84px; border-radius:14px; }
.treatment-research-icon.blood { color:#c83447; background:color-mix(in srgb,#e5484d 13%,transparent); }
.treatment-research-icon.urine { color:#9a6421; background:color-mix(in srgb,#f5a623 17%,transparent); }
.treatment-research-icon.other { color:#2d8b63; background:color-mix(in srgb,#2d8b63 14%,transparent); }
html[data-theme="dark"] .treatment-research-icon.blood { color:#ff9fa4; }
html[data-theme="dark"] .treatment-research-icon.urine { color:#f0c985; }
html[data-theme="dark"] .treatment-research-icon.other { color:#9af1c8; }

.treatment-avatar { color:#2d83e5; background:color-mix(in srgb,#2d83e5 13%,transparent); inline-size:64px; block-size:64px; border-radius:16px; }
.treatment-avatar.blood { color:#c83447; background:color-mix(in srgb,#e5484d 13%,transparent); }
.treatment-avatar.urine { color:#9a6421; background:color-mix(in srgb,#f5a623 17%,transparent); }
.treatment-avatar.other { color:#2d8b63; background:color-mix(in srgb,#2d8b63 14%,transparent); }

.treatment-specialists { margin:18px 0; }
.treatment-specialist-row { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:11px 0; border-top:1px solid var(--line); }
.treatment-specialist-row:first-of-type { border-top:0; }
.treatment-specialist-row b { display:block; font-size:16px; }
.treatment-specialist-row span { display:block; margin-top:2px; color:var(--muted); font-size:14px; }
.treatment-specialist-actions { display:flex; align-items:center; gap:8px; }
.treatment-specialist-actions .health-muted { margin:0; }

.treatment-files { display:grid; gap:8px; }
.treatment-file { display:grid; grid-template-columns:44px minmax(0,1fr) auto auto; align-items:center; gap:10px; padding:8px 11px; border:1px solid var(--line); border-radius:11px; background:color-mix(in srgb,var(--muted) 5%,transparent); }
.treatment-file a { color:var(--ink); font-weight:650; text-decoration:none; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.treatment-file a:hover { text-decoration:underline; }
.treatment-file small { color:var(--muted); font-size:12px; white-space:nowrap; }
.treatment-file-icon { display:grid; place-items:center; inline-size:44px; block-size:30px; border-radius:7px; background:color-mix(in srgb,#2d83e5 14%,transparent); color:#1f6ac0; font-size:11px; font-weight:800; letter-spacing:.03em; }
html[data-theme="dark"] .treatment-file-icon { color:#9cc4ff; }
.treatment-upload { display:inline-flex; align-items:center; min-height:38px; padding:0 13px; border-radius:10px; cursor:pointer; font-weight:650; }

.treatment-text { margin:0; line-height:1.5; overflow-wrap:anywhere; }
.treatment-row-actions { display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }

.treatment-results td { vertical-align:middle; }
.treatment-results .health-muted { display:block; margin-top:2px; font-size:12px; }
.treatment-value.low { color:#c83447; font-weight:750; }
.treatment-value.high { color:#b3640a; font-weight:750; }
html[data-theme="dark"] .treatment-value.low { color:#ff9fa4; }
html[data-theme="dark"] .treatment-value.high { color:#ffbf6b; }
.treatment-indicator-link { padding:0; border:0!important; background:none!important; color:var(--ink); font:inherit; font-weight:650; text-decoration:underline; text-decoration-color:color-mix(in srgb,var(--muted) 55%,transparent); cursor:pointer; }
.treatment-indicator-link:hover { color:#1f6ac0; }
.treatment-map { margin-top:5px; max-width:250px; min-height:34px!important; height:34px!important; padding:4px 8px!important; font-size:13px!important; }

.treatment-hint { margin:4px 0 12px; }
.treatment-show-all { margin-top:10px; }
.treatment-indicator-group { margin-top:18px; }
.treatment-indicator-list { display:grid; gap:7px; }
.treatment-indicator-row { display:grid; grid-template-columns:minmax(0,1.6fr) minmax(0,1fr) auto; align-items:center; gap:14px; padding:10px 13px; border:1px solid var(--line); border-radius:12px; background:var(--paper); color:var(--ink); font:inherit; text-align:left; cursor:pointer; transition:border-color .15s ease,background .15s ease; }
.treatment-indicator-row:hover { border-color:color-mix(in srgb,#2d83e5 45%,var(--line)); }
.treatment-indicator-row.is-selected { border-color:#2d83e5; background:color-mix(in srgb,#2d83e5 7%,var(--paper)); }
.treatment-indicator-name b { display:block; font-size:15px; }
.treatment-indicator-name small,.treatment-indicator-last small { display:block; margin-top:2px; color:var(--muted); font-size:12px; }
.treatment-indicator-last { justify-self:end; text-align:right; font-weight:750; font-variant-numeric:tabular-nums; }
.treatment-indicator-last.low { color:#c83447; }
.treatment-indicator-last.high { color:#b3640a; }
html[data-theme="dark"] .treatment-indicator-last.low { color:#ff9fa4; }
html[data-theme="dark"] .treatment-indicator-last.high { color:#ffbf6b; }
.treatment-indicator-count { justify-self:end; display:flex; align-items:center; gap:6px; color:var(--muted); font-size:12px; white-space:nowrap; }
.treatment-flag { display:grid; place-items:center; inline-size:20px; block-size:20px; border-radius:50%; font-size:11px; font-weight:800; }
.treatment-flag.low { color:#c83447; background:color-mix(in srgb,#e5484d 16%,transparent); }
.treatment-flag.high { color:#9a6421; background:color-mix(in srgb,#f5a623 22%,transparent); }
.treatment-flag.normal { color:#2d8b63; background:color-mix(in srgb,#2d8b63 16%,transparent); }

.treatment-chart-panel { margin:18px 0; }
.treatment-chart { position:relative; block-size:330px; }
.treatment-chart-legend { display:flex; flex-wrap:wrap; gap:14px; margin-top:8px; color:var(--muted); font-size:13px; }
.treatment-chart-legend .dot { display:inline-block; inline-size:9px; block-size:9px; margin-right:5px; border-radius:50%; vertical-align:0; }
.treatment-chart-legend .dot.normal { background:#2d8b63; }
.treatment-chart-legend .dot.low { background:#e5484d; }
.treatment-chart-legend .dot.high { background:#f5a623; }
.treatment-chart-legend .band { display:inline-block; inline-size:18px; block-size:9px; margin-right:5px; border-radius:3px; background:rgba(45,131,229,.16); vertical-align:0; }

.treatment-dialog { width:min(1000px,calc(100% - 28px)); }
.treatment-dialog-small { width:min(680px,calc(100% - 28px)); }
.treatment-recognition { width:min(1240px,calc(100% - 24px)); }
.treatment-dialog .modal-head p { margin:4px 0 0; }
.treatment-recognition-table { min-width:900px; }
.treatment-recognition-table input[type="checkbox"] { inline-size:18px; block-size:18px; }
.treatment-recognition-table input:not([type="checkbox"]),.treatment-recognition-table select { min-height:38px; padding:7px 9px; font-size:14px; }
.treatment-recognition-table .recognition-value,.treatment-recognition-table .recognition-min,.treatment-recognition-table .recognition-max { inline-size:100px; }
.treatment-recognition-table .recognition-unit { inline-size:92px; }
.treatment-recognition-hint { margin-right:auto; max-width:520px; text-align:left; }

@media (max-width:640px) {
  .treatment-indicator-row { grid-template-columns:minmax(0,1fr) auto; gap:9px; }
  .treatment-indicator-count { grid-column:1 / -1; justify-self:start; }
  .treatment-file { grid-template-columns:38px minmax(0,1fr) auto; }
  .treatment-file small { display:none; }
  .treatment-file-icon { inline-size:38px; }
  .treatment-chart { block-size:260px; }
  .treatment-head-actions { width:100%; justify-content:stretch; }
  .treatment-head-actions > * { flex:1; }
  .treatment-specialist-row { align-items:flex-start; flex-direction:column; gap:7px; }
}

/* Узкие экраны: фильтры и вкладки не должны растягивать страницу шире окна. */
@media (max-width:860px) {
  .health-panel .health-filter-grid { grid-template-columns:1fr!important; }
  .health-panel .property-head { flex-direction:column; align-items:stretch; gap:10px; }
  .health-panel .property-head .treatment-head-actions { justify-content:flex-start; }
}
@media (max-width:640px) {
  .health-tabs { grid-template-columns:repeat(3,minmax(0,1fr))!important; gap:7px!important; }
  .health-tabs .calendar-filter { min-height:46px!important; padding:8px 5px!important; font-size:13px!important; line-height:1.2; }
  .health-panel .property-summary { grid-template-columns:1fr 1fr; }
  .health-panel .property-summary > div { min-height:0; }
  .treatment-head-actions > * { flex:1 1 auto; }
  .room-card.health-compact { grid-template-columns:64px minmax(0,1fr) 40px!important; }
  .room-card.health-compact .room-card-photo { width:64px; height:64px; }
  .treatment-date-tile,.treatment-research-icon { inline-size:64px; block-size:64px; }
  .treatment-date-tile b { font-size:22px; }
  .treatment-indicator-row { grid-template-columns:minmax(0,1fr) auto; }
  .treatment-file { grid-template-columns:38px minmax(0,1fr) auto; }
}
.treatment-migration { margin:12px 0; padding:14px 16px; border-radius:12px; background:color-mix(in srgb,var(--muted) 10%,transparent); color:var(--ink); font:14px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace; overflow-x:auto; }
/* Внутри .room-card-photo общее правило «span { font-size:46px }» перебивает плитку даты. */
.room-card-photo .treatment-date-tile b { font-size:27px; line-height:1; font-weight:800; }
.room-card-photo .treatment-date-tile span { font-size:13px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; }
.room-card-photo .treatment-date-tile small { font-size:12px; color:var(--muted); }
@media (max-width:640px) {
  .room-card-photo .treatment-date-tile b { font-size:22px; }
}

/* Окна раздела «Лечение»: шире и выше, заголовки на 2 пункта крупнее. */
.treatment-dialog { width:min(1180px,calc(100% - 24px)); max-height:calc(100dvh - 20px); }
.treatment-dialog form,
.treatment-dialog .health-viewer-body { padding:26px 30px; }
.treatment-dialog .treatment-visit-form { min-height:min(600px,calc(100dvh - 44px)); }
.treatment-dialog.treatment-dialog-small { width:min(680px,calc(100% - 28px)); }

.treatment-dialog .modal-head h2 { font-size:26px; line-height:1.2; }
.treatment-dialog .health-section h3 { font-size:20px; }

/* Сетка формы: 12 колонок, чтобы строки шли 4 / 2 / 3 / 2 / 1 / 1. */
.treatment-form-grid { grid-template-columns:repeat(12,minmax(0,1fr)); gap:16px 20px; }
.treatment-form-grid .span-3 { grid-column:span 3; }
.treatment-form-grid .span-4 { grid-column:span 4; }
.treatment-form-grid .span-6 { grid-column:span 6; }
.treatment-form-grid .span-12 { grid-column:1 / -1; }

@media (max-width:900px) {
  .treatment-dialog .treatment-visit-form { min-height:0; }
  .treatment-form-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px 16px; }
  .treatment-form-grid .span-3,
  .treatment-form-grid .span-4,
  .treatment-form-grid .span-6 { grid-column:span 1; }
  .treatment-form-grid .span-12 { grid-column:1 / -1; }
  .treatment-dialog form,
  .treatment-dialog .health-viewer-body { padding:22px 20px; }
}
@media (max-width:640px) {
  .treatment-form-grid { grid-template-columns:1fr; }
  .treatment-form-grid .span-3,
  .treatment-form-grid .span-4,
  .treatment-form-grid .span-6,
  .treatment-form-grid .span-12 { grid-column:1 / -1; }
  .treatment-dialog .modal-head h2 { font-size:24px; }
  .treatment-dialog .health-section h3 { font-size:19px; }
}
/* В окне приёма текстовые поля повыше: заключение и рекомендации пишутся подробно. */
.treatment-visit-form textarea { min-height:112px; }
@media (max-width:640px) { .treatment-visit-form textarea { min-height:90px; } }

/* Подписи полей во всех окнах раздела — на 2 пункта крупнее (13 → 15). */
.treatment-dialog .field label { font-size:15px; }
.treatment-dialog .form-grid .wide { grid-column:1 / -1; }
@media (max-width:640px) { .treatment-dialog .field label { font-size:14px; } }

/* Красивый выбор файла заключения вместо системного «белого» input. */
.treatment-file-picker { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.treatment-file-button { display:inline-flex; align-items:center; gap:8px; min-height:42px; padding:0 16px; border-radius:10px; font-weight:650; }
.treatment-file-button svg { flex:0 0 auto; }
.treatment-file-input { position:absolute; inline-size:1px; block-size:1px; opacity:0; pointer-events:none; }
.treatment-file-name { color:var(--muted); font-size:15px; overflow-wrap:anywhere; }
.treatment-file-name.is-chosen { color:var(--ink); font-weight:650; }
.treatment-file-field .health-muted { display:block; margin-top:7px; }
.treatment-form-recognition { margin-top:4px; }
.treatment-form-results { min-width:0; }
.treatment-form-results td { vertical-align:middle; }
.treatment-form-results .rec-value { inline-size:110px; }
.treatment-form-results .rec-unit { inline-size:100px; }
.treatment-form-results td:nth-child(2) { max-width:260px; overflow-wrap:anywhere; }
.treatment-form-recognition .table-wrap { max-height:min(420px,42dvh); overflow:auto; }

/* Когда в окне исследования появилась таблица распознанных показателей,
   разворачиваем окно почти на весь экран: строк бывает много. */
.treatment-dialog:has(.treatment-form-recognition:not([hidden])) { height:calc(100dvh - 20px); max-height:calc(100dvh - 20px); }
.treatment-dialog:has(.treatment-form-recognition:not([hidden])) .treatment-form-recognition .table-wrap { max-height:min(46dvh,540px); }
.treatment-rec-text { color:var(--muted); font-size:14px; white-space:nowrap; }
/* Окно проверки распознанных показателей тоже на весь экран. */
.treatment-recognition { height:calc(100dvh - 20px); }
.treatment-recognition .table-wrap { max-height:min(62dvh,720px); }
@media (max-width:640px) {
  .treatment-recognition { height:calc(100dvh - 12px); }
  .treatment-recognition .table-wrap { max-height:60dvh; }
}

/* Пока в окне есть таблица распознавания, она занимает всю свободную высоту,
   а прокручивается только сама таблица — окно и поля остаются на месте. */
.treatment-dialog:has(.treatment-form-recognition:not([hidden])) .treatment-research-form {
  display:flex; flex-direction:column; height:100%; min-height:0; overflow:hidden;
}
.treatment-dialog:has(.treatment-form-recognition:not([hidden])) .treatment-form-grid { flex:0 0 auto; }
.treatment-dialog:has(.treatment-form-recognition:not([hidden])) .treatment-form-recognition {
  flex:1 1 auto; min-height:0; display:flex; flex-direction:column; overflow:hidden; margin-top:10px;
}
.treatment-dialog:has(.treatment-form-recognition:not([hidden])) .treatment-form-recognition .table-wrap {
  flex:1 1 auto; min-height:0; height:auto; max-height:none; overflow:auto;
}
.treatment-dialog:has(.treatment-form-recognition:not([hidden])) .treatment-form-recognition .health-table thead th {
  position:sticky; top:0; background:var(--paper); z-index:1;
}
.treatment-dialog:has(.treatment-form-recognition:not([hidden])) .treatment-form-recognition > .health-muted { flex:0 0 auto; }
.treatment-dialog:has(.treatment-form-recognition:not([hidden])) .form-actions { flex:0 0 auto; margin-top:12px; }
/* Скрытый нативный select из select-ui.js — absolute; внутри таблицы он
   растягивал прокрутку всего диалога. Возвращаем его в поток ячейки. */
.health-table .ui-select-native { position:static!important; display:block!important; }
/* Таблица распознавания компактнее: в окне видно больше строк. */
.treatment-form-results td { padding:6px 10px; }
.treatment-form-results .ui-select-trigger.ui-select-trigger { min-height:36px!important; padding:0 9px!important; font-size:14px!important; }
.treatment-form-results input { min-height:36px; height:36px; padding:6px 9px; }
/* Скрытый select не должен занимать место в строке таблицы. */
.health-table .ui-select-native { display:none!important; position:absolute!important; }

/* Окно исследования с таблицей — на весь экран фрейма, не только по высоте. */
.treatment-dialog:has(.treatment-form-recognition:not([hidden])) {
  width:calc(100% - 24px); max-width:none;
}
@media (max-width:640px) { .treatment-dialog:has(.treatment-form-recognition:not([hidden])) { width:calc(100% - 12px); } }

/* Референсные значения и подсветка отклонений в таблице распознавания. */
.treatment-form-results .treatment-ref { color:var(--muted); font-size:13px; white-space:nowrap; }
.treatment-form-results .treatment-rec-value { display:inline-flex; align-items:center; gap:5px; }
.treatment-form-results input.rec-value.is-low,
.treatment-form-results input.rec-value.is-high { color:#c83447!important; border-color:#e5484d!important; background:color-mix(in srgb,#e5484d 9%,transparent); font-weight:750; }
.treatment-form-results .rec-flag { inline-size:12px; font-weight:800; color:#c83447; }
html[data-theme="dark"] .treatment-form-results input.rec-value.is-low,
html[data-theme="dark"] .treatment-form-results input.rec-value.is-high { color:#ff9fa4!important; border-color:#ff7373!important; background:color-mix(in srgb,#e5484d 18%,transparent); }
html[data-theme="dark"] .treatment-form-results .rec-flag { color:#ff9fa4; }

/* Окно исследования с таблицей — как просмотр счёта в «Финансах»:
   ровно область контента справа от бокового меню, без затемнения. */
@media (min-width:861px) {
  .treatment-dialog:has(.treatment-form-recognition:not([hidden])) {
    position:fixed; inset:0 0 0 266px; width:auto; max-width:none;
    height:auto; max-height:none; margin:0; border:0; border-radius:0;
  }
  .treatment-dialog:has(.treatment-form-recognition:not([hidden]))::backdrop { background:transparent; }
}
@media (max-width:860px) {
  .treatment-dialog:has(.treatment-form-recognition:not([hidden])) {
    position:fixed; inset:0; width:auto; max-width:none;
    height:auto; max-height:none; margin:0; border:0; border-radius:0;
  }
}

/* Ровные колонки таблицы распознавания: фиксированные ширины вместо auto. */
.treatment-form-results { table-layout:fixed; width:100%; }
.treatment-form-results .rec-col-check { width:3%; }
.treatment-form-results .rec-col-name { width:22%; }
.treatment-form-results .rec-col-indicator { width:29%; }
.treatment-form-results .rec-col-norm { width:15%; }
.treatment-form-results .rec-col-value { width:16%; }
.treatment-form-results .rec-col-unit { width:15%; }
.treatment-form-results th { font-size:14px; }
.treatment-form-results td { font-size:15px; }
.treatment-form-results input,
.treatment-form-results select,
.treatment-form-results .ui-select-trigger.ui-select-trigger { font-size:15px!important; }
.treatment-form-results .rec-value { inline-size:100%; max-width:130px; text-align:right; }
.treatment-form-results .rec-unit { inline-size:100%; max-width:120px; text-align:left; }
.treatment-form-results .treatment-rec-value { display:flex; align-items:center; justify-content:flex-end; gap:5px; }
.treatment-form-results .rec-flag { flex:0 0 12px; text-align:center; }
.treatment-form-results .treatment-ref { font-size:14px; }
.treatment-form-recognition > .health-muted { margin-top:16px!important; padding-top:4px; }

/* Окно исследования — как tx-drilldown-dialog в «Финансах»: скруглённая
   карточка с отступами от краёв, поверх контента справа от меню. */
@media (min-width:861px) {
  .treatment-dialog:has(.treatment-form-recognition:not([hidden]))[open] {
    position:fixed; inset:18px 16px 18px 282px; width:auto; max-width:none;
    height:auto; max-height:none; margin:0; border:0; border-radius:24px; padding:0;
    display:flex; flex-direction:column; overflow:hidden;
  }
  .treatment-dialog:has(.treatment-form-recognition:not([hidden]))::backdrop { background:transparent; }
  body.sidebar-compact .treatment-dialog:has(.treatment-form-recognition:not([hidden]))[open] { inset:18px 16px 18px 106px; }
}
@media (max-width:860px) {
  .treatment-dialog:has(.treatment-form-recognition:not([hidden]))[open] {
    position:fixed; inset:8px; width:auto; max-width:none;
    height:auto; max-height:none; margin:0; border:0; border-radius:24px; padding:0;
    display:flex; flex-direction:column; overflow:hidden;
  }
}
.treatment-dialog:has(.treatment-form-recognition:not([hidden])) .treatment-research-form {
  flex:1 1 auto; min-height:0; height:auto;
}

/* Один шрифт во всех колонках таблицы — как в «Показателе». */
.treatment-form-results th,
.treatment-form-results td,
.treatment-form-results input,
.treatment-form-results select,
.treatment-form-results .ui-select-trigger.ui-select-trigger,
.treatment-form-results .treatment-rec-text { font-size:16px!important; }

/* Число и качественный текст в «Значении» выровнены по правому краю,
   место под стрелку отклонения зарезервировано в каждой строке. */
.treatment-form-results .treatment-rec-value { display:flex; align-items:center; justify-content:flex-end; gap:5px; width:100%; }
.treatment-form-results .treatment-rec-text { flex:0 1 auto; text-align:right; }
.treatment-form-results .rec-value { inline-size:100%; max-width:130px; text-align:right; }
.treatment-form-results .rec-flag { flex:0 0 12px; text-align:center; }

/* Закрытый диалог не должен оставаться на экране из-за display:flex выше. */
.treatment-dialog:not([open]) { display:none!important; }
