/* Шрифт Inter (лицензия SIL OFL — fonts/Inter-LICENSE.txt), лежит в проекте, без внешних сайтов */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/Inter-Regular.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/Inter-Medium.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/Inter-SemiBold.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/Inter-Bold.woff2') format('woff2'); }
/* Модуль экспертизы — оформление в цветах логотипа (тёмно-синий + бирюза) */
:root {
  --navy: #12263A; --navy-2: #1B3349; --navy-3: #24425C;
  --teal: #2FB4C4; --teal-dark: #1C8C9A; --teal-ink: #0B4E57; --teal-soft: #E4F6F8;
  --bg: #F4F7FB; --card: #FFFFFF; --ink: #10233A; --muted: #5A7084; --faint: #8DA1B0;
  --line: #E1E8EF; --line-soft: #EDF2F6;
  --red: #C2412D; --red-bg: #FCE8E4; --red-ink: #8E2B1C;
  --amber: #B7791F; --amber-bg: #FDF0D8; --amber-ink: #7A4A06;
  --green: #1B8A5A; --green-bg: #E0F3EA; --green-ink: #145C3C;
  --primary: #1A97A6; --primary-hover: #157F8C; --ring: rgba(47, 180, 196, .28);
  --shadow-sm: 0 1px 2px rgba(16, 35, 58, .05), 0 1px 3px rgba(16, 35, 58, .06);
  --shadow-md: 0 6px 18px rgba(16, 35, 58, .09), 0 1px 3px rgba(16, 35, 58, .05);
  --radius: 12px;
  --x-bd-9AAAB7: #9AAAB7; --x-bd-9FB4C2: #9FB4C2; --x-bd-A9DCE3: #A9DCE3; --x-bd-AFC2D0: #AFC2D0; --x-bd-B9CBD6: #B9CBD6; --x-bd-B9E2CC: #B9E2CC; --x-bd-C9D6DF: #C9D6DF; --x-bd-CBD7E1: #CBD7E1; --x-bd-D0DBE4: #D0DBE4; --x-bd-E3F5EA: #E3F5EA; --x-bd-E7C47A: #E7C47A; --x-bd-F0D49A: #F0D49A; --x-bd-F3C9C9: #F3C9C9; --x-bd-F5C2C2: #F5C2C2; --x-bg-BFE6EC: #BFE6EC; --x-bg-C9D3DB: #C9D3DB; --x-bg-C9D4DC: #C9D4DC; --x-bg-D5DDE4: #D5DDE4; --x-bg-DCE5EC: #DCE5EC; --x-bg-DDEAF0: #DDEAF0; --x-bg-E3F5EA: #E3F5EA; --x-bg-E6F4F6: #E6F4F6; --x-bg-E8EEF3: #E8EEF3; --x-bg-E9EEF2: #E9EEF2; --x-bg-E9F1F5: #E9F1F5; --x-bg-EEF3F7: #EEF3F7; --x-bg-F1F4F7: #F1F4F7; --x-bg-F1F6F9: #F1F6F9; --x-bg-F2FAFB: #F2FAFB; --x-bg-F2FBFC: #F2FBFC; --x-bg-F3C7A6: #F3C7A6; --x-bg-F3F7FA: #F3F7FA; --x-bg-F3FAFB: #F3FAFB; --x-bg-F6F9FB: #F6F9FB; --x-bg-F7FAFC: #F7FAFC; --x-bg-FAFBFC: #FAFBFC; --x-bg-FAFCFD: #FAFCFD; --x-bg-FDECEC: #FDECEC; --x-bg-FDF3F1: #FDF3F1; --x-bg-FFF8E6: #FFF8E6; --x-bg-FFFBFB: #FFFBFB; --x-tx-1E7A45: #1E7A45; --x-tx-1F3242: #1F3242; --x-tx-5F778A: #5F778A; --x-tx-9B2C2C: #9B2C2C; --x-tx-B23A2E: #B23A2E; --x-tx-B4641E: #B4641E; --x-tx-B53A32: #B53A32; --x-tx-B7791F: #B7791F; --x-tx-B83232: #B83232; --x-tx-C46A12: #C46A12;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Arial, sans-serif; background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; }
a { color: var(--teal-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 23px; font-weight: 650; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; margin: 24px 0 10px; }
.muted { color: var(--muted); font-size: 13px; }
.errors { color: var(--red); }
.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; }

/* --- каркас: меню слева + содержимое --- */
/* масштаб интерфейса: --z выбирает пользователь (внизу меню), по умолчанию 90% — компактно */
:root { --z: .9; }
html { zoom: var(--z); }
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: calc(100vh / var(--z)); }
.layout > :not(.sidebar) { min-width: 0; }   /* широкая таблица не растягивает страницу — прокручивается в своём окне */
.sidebar { background: linear-gradient(180deg, #0F2234 0%, #14304A 100%); color: #C9E1E8; padding: 18px 12px; position: sticky; top: 0; height: calc(100vh / var(--z)); overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; font-size: 15px; padding: 0 8px 18px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand img { width: 38px; height: 38px; border-radius: 10px; background: #fff; padding: 2px; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.brand small { display: block; color: #8FB6C2; font-weight: 400; font-size: 11px; }
.nav-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #6C8DA0; padding: 16px 12px 6px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: #BBD3DD; margin-bottom: 2px; text-decoration: none;
  transition: background .15s, color .15s; }
.nav a .icon { color: #7FA3B4; transition: color .15s; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a:hover .icon { color: #CFE6EE; }
.nav a.on { background: rgba(47, 180, 196, .16); color: #fff; font-weight: 600; box-shadow: inset 0 0 0 1px rgba(47, 180, 196, .28); }
.nav a.on .icon { color: var(--teal); }
.nav .badge { margin-left: auto; background: var(--teal); color: var(--navy); border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 600; }
.sidebar .bottom { margin-top: auto; border-top: 1px solid var(--navy-3); padding-top: 12px; font-size: 13px; }
.sidebar .who { padding: 0 10px 8px; color: #fff; }
.sidebar .who small { display: block; color: #8FB6C2; }
.sidebar button.link, .sidebar .pw-link { color: #C9E1E8; padding: 6px 10px; display: flex; align-items: center; gap: 6px; font-weight: 400; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap;
  box-shadow: 0 1px 2px rgba(16, 35, 58, .03); }
.topbar .where { font-weight: 600; }
/* название страницы — в шапке (pagetitle.js переносит сюда первый заголовок страницы) */
.tb-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-title[hidden] { display: none; }
.tb-title h1 { font-size: 17px; margin: 0 !important; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tb-title h1 .chip { font-size: 11px; vertical-align: middle; }
.tb-title .howto { flex: none; }
.tb-title .tb-link { flex: none; font-size: 13px; white-space: nowrap; }
.tb-title + form select { font-size: 13px; }
.topbar.has-title .where { display: none; }
.topbar .spacer { flex: 1; }
.content { padding: 24px 28px 48px; max-width: 1680px; margin: 0 auto; }   /* широкий экран: по центру, строки не растягиваются на 2000 px */

/* --- элементы --- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.card > strong:first-child { display: block; margin-bottom: 6px; }
.msg { background: var(--green-bg); border-color: var(--x-bd-B9E2CC); color: var(--green-ink); }
.warn { background: var(--amber-bg); border: 1px solid var(--x-bd-F0D49A); border-left: 4px solid var(--amber); color: var(--amber-ink); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.cols-2 { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; }

button, .btn, select, input, textarea { font: inherit; }
button, .btn { background: var(--primary); color: #fff; border: 1px solid transparent; border-radius: 10px; padding: 8px 16px; cursor: pointer; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; box-shadow: 0 1px 2px rgba(16, 35, 58, .12);
  transition: background .15s, box-shadow .15s, border-color .15s; }
button:hover, .btn:hover { background: var(--primary-hover); text-decoration: none; box-shadow: 0 3px 10px rgba(26, 151, 166, .25); }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn-secondary { background: var(--card); color: var(--ink); border: 1px solid var(--x-bd-CBD7E1); font-weight: 500; box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--x-bg-F2FAFB); border-color: var(--teal); box-shadow: var(--shadow-sm); }
.btn-gray { background: var(--x-bg-E8EEF3); color: var(--ink); box-shadow: none; }
.btn-gray:hover { background: var(--x-bg-DCE5EC); box-shadow: none; }
button.link { background: none; color: var(--teal-dark); padding: 0; font-weight: 500; border: 0; box-shadow: none; }
button.link:hover { background: none; box-shadow: none; }
select, input:not([type=checkbox]):not([type=file]), textarea { border: 1px solid var(--x-bd-D0DBE4); border-radius: 10px; padding: 7px 11px; background: var(--card); color: var(--ink);
  transition: border-color .15s, box-shadow .15s; }
select:hover, input:not([type=checkbox]):not([type=file]):hover, textarea:hover { border-color: var(--x-bd-AFC2D0); }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--ring); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); }

table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: clip; box-shadow: var(--shadow-sm); }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; line-height: 1.4; vertical-align: middle; }
th { background: var(--x-bg-F6F9FB); color: var(--x-tx-5F778A); font-weight: 600; font-size: 12.5px; border-bottom-color: var(--line); }
/* заголовки таблиц не уезжают при прокрутке вниз */
main table thead th, main table > tbody > tr:first-child > th { position: sticky; top: 0; z-index: 2; }
main table.an-kpn thead th { position: static; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, table tr:hover td { background: var(--x-bg-F3FAFB); }
.card table { border: 0; border-radius: 0; box-shadow: none; }

.counts, .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.count, .kpi { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; color: var(--ink); text-decoration: none;
  box-shadow: var(--shadow-sm); transition: box-shadow .15s, border-color .15s, transform .15s; }
a.count:hover, a.kpi:hover { border-color: var(--x-bd-A9DCE3); text-decoration: none; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.count b, .kpi .v { display: block; font-size: 25px; font-weight: 650; line-height: 1.2; letter-spacing: -.01em; }
.kpi .l, .kpi .s { display: block; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .s, .count .muted { color: var(--muted); font-size: 12px; }
.count.alert b, .kpi.alert .v { color: var(--red); }
.kpi.ok .v { color: var(--green); }
.count.on { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.page-head { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .grow { flex: 1; }
.pager { margin: 14px 0; display: flex; gap: 14px; align-items: center; }
dl.props { display: grid; grid-template-columns: 220px 1fr; gap: 8px 14px; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 10px; font-size: 13px; }

/* --- статусы и метки --- */
.chip { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px; white-space: nowrap; font-weight: 600; }
.chip-new { background: var(--red-bg); color: var(--red-ink); }
.chip-open { background: var(--amber-bg); color: var(--amber-ink); }
.chip-fixed { background: var(--green-bg); color: var(--green-ink); }
.chip-waived, .chip-info { background: var(--teal-soft); color: var(--teal-ink); }
.chip-warn { background: var(--amber-bg); color: var(--amber-ink); }
.chip-gray { background: var(--x-bg-E9EEF2); color: var(--muted); }

/* --- загрузка файла и чек-лист --- */
.dropzone { display: block; border: 2px dashed var(--teal); background: var(--x-bg-F2FBFC); border-radius: 12px; text-align: center; padding: 30px 20px; cursor: pointer; transition: background .15s; }
.dropzone:hover, .dropzone.over { background: var(--teal-soft); }
.dropzone .big { font-size: 16px; font-weight: 600; margin: 8px 0 4px; }
.dropzone input[type=file] { display: none; }
.dropzone .icon { width: 36px; height: 36px; color: var(--teal-dark); }
.checklist .item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.checklist .item:last-child { border-bottom: 0; }
.checklist .item .text { flex: 1; }
.checklist .ok { color: var(--green); } .checklist .bad { color: var(--red); } .checklist .old { color: var(--amber); } .checklist .info { color: var(--teal-dark); }

.barrow { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; color: var(--ink); text-decoration: none; }
a.barrow:hover { text-decoration: none; background: var(--x-bg-FAFCFD); }
.barrow:last-child { border-bottom: 0; }
.barrow .name { width: 150px; flex: none; }
.barrow .track { flex: 1; min-width: 80px; background: var(--line-soft); border-radius: 4px; height: 9px; }
.barrow .muted { flex: none; }
.barrow .fill { background: var(--teal); height: 9px; border-radius: 4px; min-width: 3px; }
.barrow .num { min-width: 60px; flex: none; text-align: right; font-weight: 600; white-space: nowrap; }

/* --- вход --- */
.login-wrap { min-height: calc(100vh / var(--z)); display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1100px 600px at 20% 10%, #1D4E63 0%, transparent 60%), linear-gradient(160deg, #0F2234, #14304A); }
.login-card { background: var(--card); border-radius: 18px; padding: 34px 36px; width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.login-card img { width: 72px; height: 72px; display: block; margin: 0 auto 12px; }
.login-card h1 { text-align: center; font-size: 20px; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 20px; }
.login-card input { width: 100%; }
.login-card button { width: 100%; justify-content: center; padding: 10px; margin-top: 6px; }

@media (max-width: 1200px) {
  .cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}

/* Освоение финансирования */
.fin-filters select { max-width: 260px; }
.fin-fresh { margin-left: auto; }
.fin-table { width: 100%; table-layout: fixed; }
.fin-table td, .fin-table th { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-table td:first-child { white-space: normal; }
.r { text-align: right; }
.fin-src td { background: var(--line-soft); font-weight: 600; }
.fin-lot td:first-child { padding-left: 22px; }
.fin-lot.on td { background: var(--teal-soft); }
.fin-side td { color: var(--muted); font-size: 13px; }
.fin-side td:first-child { padding-left: 42px; }
.fin-bar { display: inline-block; width: 54px; height: 7px; border-radius: 4px; background: var(--line-soft); vertical-align: middle; margin-right: 8px; overflow: hidden; }
.fin-bar.small { width: 12px; }
.fin-bar i { display: block; height: 100%; }
.fin-bar .lo { background: #E0A43A; } .fin-bar .ok { background: var(--green); } .fin-bar .hi { background: var(--teal); }
.fin-legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin: 8px 0 0; }
.fin-legend .grow { flex: 1; }
.fin-tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; }
.fin-tabs a:hover { text-decoration: none; }
#fin-live { transition: opacity .15s; }
#fin-live.loading { pointer-events: none; }
#fin-live.loading table { opacity: .6; transition: opacity .2s .25s; }   /* только если ответ задержался */
.fin-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 12px; }
.fin-chips a.chip:hover { text-decoration: none; filter: brightness(.95); }
.fin-pick tr.on td { background: var(--teal-soft); font-weight: 600; }
.fin-pick td:first-child a, .fin-lot a { color: var(--ink); }
.fin-pick tr.on td:first-child a, .fin-lot.on a { color: var(--teal-ink); }

/* Освоение: плотная раскладка как в Power BI */
.content:has(#fin-live) { max-width: none; padding: 14px 18px 24px; }
.fin-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 8px; }
.fin-head h1 { font-size: 18px; margin: 0; }
.fin-head .muted { cursor: help; }
.fin-head a { margin-left: auto; }
.fin-bar-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.fin-bar-top select { padding: 4px 8px; font-size: 13px; max-width: 220px; }
.fin-bar-top .chip { font-size: 12px; }
.fin-bar-top .fin-fresh { margin-left: auto; font-size: 12px; }
.fin-reset { font-size: 12px; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.fin-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 12px; align-items: start; }
.fin-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.fin-parts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
@media (min-width: 1500px) { .fin-parts { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); } }
@media (max-width: 1100px) { .fin-grid { grid-template-columns: minmax(0, 1fr); } }
.fin-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.fin-kpis div { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; }
.fin-kpis span { display: block; font-size: 11px; color: var(--muted); }
.fin-kpis b { font-size: 17px; font-weight: 600; white-space: nowrap; }
.fin-kpis .ok b { color: var(--green); } .fin-kpis .alert b { color: var(--red); }
.fin-note { font-size: 12px; background: var(--amber-bg); color: var(--amber-ink); border-radius: 6px; padding: 4px 10px; }
.fin-box { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.fin-scroll { max-height: calc(50vh - 60px); overflow: auto; }
.fin-tall { max-height: calc(100vh / var(--z) - 235px); }
.fin-parts > .fin-box:first-child { max-height: calc(100vh / var(--z) - 140px); }
.fin-parts .fin-box .fin-scroll { max-height: calc(100vh / var(--z) - 175px); }
table.fin { border: 0; border-radius: 0; overflow: visible; table-layout: fixed; width: 100%; }
table.fin th, table.fin td { padding: 3px 8px; font-size: 12.5px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.fin thead th { position: sticky; top: 0; z-index: 1; background: var(--x-bg-F7FAFC); border-bottom: 1px solid var(--line); }
table.fin tfoot td { position: sticky; bottom: 0; background: var(--x-bg-EEF3F7); border-top: 1px solid var(--line); }
table.fin td:first-child { white-space: nowrap; }
.fin-table .fin-lot td:first-child { padding-left: 18px; }
.fin-table .fin-side td { font-size: 12px; }
.fin-table .fin-side td:first-child { padding-left: 34px; }
.fin-bar { width: 38px; height: 6px; margin-right: 6px; }
.fin-tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--x-bg-F7FAFC); }
.fin-tabs a { white-space: nowrap; padding: 5px 9px; font-size: 12.5px; color: var(--muted); border-bottom: 2px solid transparent; }
.fin-tabs a.on { color: var(--teal-ink); border-bottom-color: var(--teal); font-weight: 600; }
.fin-tabs a:hover { text-decoration: none; color: var(--ink); }
@media (max-width: 1499px) {
  .fin-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
  .fin-parts > .fin-box:first-child { max-height: calc(42vh - 40px); }
  .fin-parts .fin-box .fin-scroll { max-height: calc(58vh - 110px); }
  .fin-table col:nth-child(3), .fin-table col:nth-child(4) { width: 86px; }
  .fin-table col:nth-child(5) { width: 92px; }
  .fin-bar { width: 26px; }
}
.fin-side a { color: var(--muted); }
.fin-side.on td { background: var(--teal-soft); }
.fin-side.on a { color: var(--teal-ink); font-weight: 600; }

/* Освоение: справа от лотов четыре окна 2×2, каждое со своей прокруткой */
.fin-parts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-auto-rows: calc((100vh / var(--z) - 170px) / 2); gap: 8px; }
.fin-parts > .fin-box { max-height: none; display: flex; flex-direction: column; min-height: 0; }
.fin-parts > .fin-box.fin-scroll { overflow: auto; }
.fin-parts > .fin-box .fin-scroll { max-height: none; flex: 1; min-height: 0; overflow: auto; }
@media (max-width: 1499px) {
  .fin-parts > .fin-box:first-child { max-height: none; }
  .fin-parts .fin-box .fin-scroll { max-height: none; }
}
@media (max-width: 1100px) { .fin-parts { grid-template-columns: minmax(0, 1fr); grid-auto-rows: 320px; } }
th.fin-sort { cursor: pointer; user-select: none; }
th.fin-sort:hover { color: var(--ink); }
th.fin-sort.asc::after { content: ' ▲'; font-size: 9px; }
th.fin-sort.desc::after { content: ' ▼'; font-size: 9px; }
/* Фин. план: ввод по месяцам */
.content:has(#plan-form) { max-width: none; padding: 14px 18px 24px; }
.fin-tools { margin: 0 0 10px; }
.fin-tools summary { cursor: pointer; color: var(--teal-dark); font-size: 13px; margin-bottom: 6px; }
.plan-wrap { overflow: auto; max-height: calc(100vh / var(--z) - 230px); }
table.plan { }
table.plan th, table.plan td { padding: 2px 4px; }
table.plan .plan-lot { position: sticky; left: 0; background: var(--card); z-index: 2; width: 270px; min-width: 270px; white-space: normal; }
table.plan thead .plan-lot, table.plan .fin-src .plan-lot { background: var(--x-bg-F7FAFC); }
table.plan input { width: 92px; padding: 2px 4px; font-size: 12px; text-align: right; border: 1px solid var(--line); border-radius: 4px; background: var(--card); }
table.plan input.plan-y { width: 104px; font-weight: 600; }
table.plan input.ch { background: var(--amber-bg); border-color: var(--x-bd-E7C47A); }
table.plan input:disabled { background: transparent; border-color: transparent; color: var(--faint); }
table.plan tr.off td { color: var(--faint); }
.plan-c { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; white-space: nowrap; }
.plan-reset { font-size: 14px; }
table.fin.plan { table-layout: auto; width: auto; }
table.fin.plan th, table.fin.plan td { overflow: visible; text-overflow: clip; }
table.plan td:nth-child(2) { min-width: 78px; }
.plan-excel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 0 0 10px; display: flex; flex-direction: column; gap: 6px; }
.plan-step { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.plan-excel .fin-tools { margin: 0; }
/* Рычажок «Деньги / Количество» */
.measure-switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; user-select: none; }
.measure-switch > button, .measure-switch > a { width: 42px; height: 24px; border-radius: 12px; padding: 0; border: 0; background: var(--teal); position: relative; cursor: pointer; display: inline-block; transition: background .15s; }
.measure-switch > button i, .measure-switch > a i { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: left .15s; }
.measure-switch [aria-checked="true"] { background: var(--navy-3); }
.measure-switch [aria-checked="true"] i { left: 21px; }
.measure-switch .ms-amount, .measure-switch .ms-count { color: var(--faint); }
.measure-switch:has([aria-checked="false"]) .ms-amount, .measure-switch:has([aria-checked="true"]) .ms-count { color: var(--ink); }
#plan-form[data-measure="amount"] [data-m="count"], #plan-form[data-measure="count"] [data-m="amount"] { display: none; }
#plan-form[data-measure="amount"] [data-hint="count"], #plan-form[data-measure="count"] [data-hint="amount"] { display: none; }
#fin-live[data-measure="amount"] [data-m="count"], #fin-live[data-measure="count"] [data-m="amount"] { display: none; }
.fin-kpis .ok { color: var(--green); } .fin-kpis .alert { color: var(--red); }
/* Таблица лотов: узкий столбец названий с переносом, цифры не обрезаются, свой горизонтальный скролл */
table.fin.fin-table { table-layout: fixed; width: max-content; min-width: 100%; }
.fin-table col.c-lot { width: 170px; } .fin-table col.c-pct { width: 88px; }
.fin-table col.c-num { width: 104px; } .fin-table col.c-oth { width: 96px; } .fin-table col.c-ppl { width: 64px; }
table.fin.fin-table td:first-child { white-space: normal; overflow-wrap: anywhere; line-height: 1.25; }
table.fin.fin-table td.r { overflow: visible; text-overflow: clip; }
.fin-table .fin-bar { width: 28px; margin-right: 5px; }
.fin-table .fin-other { color: var(--muted); }
.fin-table .neg { color: var(--red); } .fin-table .pos { color: var(--green); }
#fin-live:not([data-dev="1"]) .fin-dev { display: none; }
.dev-switch > button { background: var(--x-bg-C9D3DB); }
.dev-switch > button[aria-checked="true"] { background: var(--teal); }
.dev-switch span { color: var(--ink); }
.fin-tall { overflow: auto; }
/* Дефекты: «взят в работу» — строка тусклее; комментарий в строке */
table.defects tr.taken td { opacity: .45; }
table.defects tr.taken td.c, table.defects tr.taken td.comment { opacity: 1; }
table.defects td.c { text-align: center; }
table.defects td.comment { min-width: 180px; max-width: 260px; }
table.defects .comment-text { white-space: pre-wrap; display: block; }
table.defects .comment-by { display: block; font-size: 11px; }
table.defects .comment-form textarea { width: 100%; font-size: 12px; }
/* «Подробности» (правильные поводы по приказу 37 и т. п.) — широкий столбец, чтобы строки не вытягивались в высоту */
table.defects .details { min-width: 520px; }
.content:has(#defects) { max-width: none; }
table.defects .svc { min-width: 240px; }
table.defects .reason { min-width: 190px; }
.defects-wrap { overflow: auto; max-width: 100%; max-height: calc(100vh / var(--z) - 150px); }
.defects-wrap table.defects { width: 100%; }
/* ID услуги: нажал — скопировалось */
table.defects .copy-id { background: none; border: 1px dashed transparent; padding: 1px 4px; font: inherit; font-family: Consolas, monospace; color: var(--teal-ink); cursor: copy; border-radius: 4px; font-weight: 400; }
table.defects .copy-id:hover { border-color: var(--teal); background: var(--teal-soft); }
table.defects .copy-id.copied, .copy-all.copied { background: var(--green-bg); color: var(--green-ink); border-color: transparent; }
table.defects td.sid { white-space: nowrap; }

/* --- правила в сумме дефектов --- */
.card-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.card-head .sum-hint { font-size: 12px; margin-left: auto; }
.barrow .name { color: var(--ink); text-decoration: none; }
.barrow .name:hover { color: var(--teal-dark); text-decoration: underline; }
.barrow .sum { width: 110px; text-align: right; }
.barrow.off-sum .name, .barrow.off-sum .num { color: var(--muted); }
.barrow.off-sum .fill { background: #B9C7D2; }
.barrow.off-sum .sum s { text-decoration-color: var(--x-bd-9AAAB7); }
.sum-toggle { flex: none; margin: 0; }
.sum-chip { background: var(--line-soft); color: var(--muted); font-size: 11px; }
.switch { position: relative; display: inline-block; width: 34px; height: 20px; cursor: pointer; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--x-bg-C9D4DC); border-radius: 20px; transition: background .15s; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: var(--card); border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--teal); }
.switch input:checked + span::before { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--teal-dark); outline-offset: 2px; }

/* --- сортировка в списке дефектов --- */
table.defects th a.sort { color: inherit; text-decoration: none; display: inline-block; }
table.defects th a.sort:hover { color: var(--teal-dark); text-decoration: underline; }
table.defects th a.sort.on { color: var(--teal-ink); }
table.defects th .arrow { font-size: 10px; color: var(--teal-dark); }

/* --- фильтры с несколькими пунктами --- */
.msel { position: relative; }
.msel-btn { display: flex; align-items: center; gap: 10px; min-width: 190px; max-width: 320px; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font: inherit; font-weight: 400; cursor: pointer; text-align: left; }
.msel-btn:hover { border-color: var(--teal); background: var(--card); }
.msel.open .msel-btn { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.msel-btn.picked { border-color: var(--teal); background: var(--teal-soft); color: var(--teal-ink); }
.msel-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msel-caret { font-size: 11px; color: var(--muted); }
.msel-pop { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 100%; max-width: 380px; max-height: 340px; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(18, 38, 58, .14); padding: 6px; }
.msel-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap; font-size: 13px; }
.msel-opt:hover { background: var(--teal-soft); }
.msel-opt input { margin: 0; accent-color: var(--teal-dark); }
.msel-all { border-top: 1px solid var(--line-soft); margin-top: 4px; padding-top: 8px; font-weight: 600; }

/* ссылка на карточку пациента */
a.patient-link { color: var(--ink); text-decoration: none; border-bottom: 1px dashed var(--teal); }
a.patient-link:hover { color: var(--teal-dark); border-bottom-style: solid; text-decoration: none; }

/* --- сортировка в справочнике пациентов --- */
table.patients th a.sort { color: inherit; text-decoration: none; }
table.patients th a.sort:hover { color: var(--teal-dark); text-decoration: underline; }
table.patients th a.sort.on { color: var(--teal-ink); }
table.patients th .arrow { font-size: 10px; color: var(--teal-dark); }

/* письменный диагноз в карточке пациента: мелко, до 3 строк, полностью — при наведении */
td.dx-cell { min-width: 200px; max-width: 280px; }
.dx { font-size: 12px; line-height: 1.35; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: help; }

/* --- страница загрузки: окна по видам файлов --- */
h2.slot-section { display: flex; align-items: center; gap: 8px; font-size: 16px; margin: 22px 0 10px; }
h2.slot-section .icon { width: 18px; height: 18px; color: var(--teal-dark); }
.slot-groups { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 14px; }
.slot-group { grid-column: span 4; min-width: 0; }
.slot-group.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .slot-group.span-2 { grid-column: span 4; } }
.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.slots.slots-1 { grid-template-columns: 1fr; }
.slots.slots-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.slots.slots-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .slots.slots-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .slots.slots-3 { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .slots.slots-2 { grid-template-columns: 1fr; } }
.slot { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; margin: 0; }
.slot .chip { align-self: flex-start; }
.slot-export { font-size: 12px; }
.slot-months { display: flex; flex-wrap: wrap; gap: 4px; }
.slot-months .m { font-size: 11px; min-width: 28px; text-align: center; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); }
.slot-months .m.closed { background: var(--x-bg-E3F5EA); border-color: var(--x-bd-E3F5EA); color: var(--x-tx-1E7A45); font-weight: 600; }
.slot-months .m.future { border-style: dashed; color: var(--faint); }
.slot-error { background: var(--x-bg-FDECEC); color: var(--x-tx-9B2C2C); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.slot-drop { display: flex; align-items: center; justify-content: center; gap: 8px; border: 2px dashed var(--teal); background: var(--x-bg-F2FBFC); border-radius: 10px; padding: 12px; cursor: pointer; font-size: 13px; color: var(--teal-ink); margin-top: auto; transition: background .15s; }
.slot-drop:hover, .slot-drop.over { background: var(--teal-soft); }
.slot-drop .icon { width: 18px; height: 18px; color: var(--teal-dark); }
.slot-drop input[type=file] { display: none; }
.upload-mode { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.upload-mode button { background: var(--card); color: var(--muted); border: 0; border-radius: 0; padding: 7px 14px; font-weight: 600; font-size: 13px; cursor: pointer; }
.upload-mode button.on { background: var(--teal); color: #fff; }
.upload-mode button:not(.on):hover { background: var(--teal-soft); color: var(--teal-ink); }
.slot-auto { margin-top: 6px; }
.slot-auto .slot-drop { padding: 34px 20px; font-size: 15px; }
.card.msg.error { background: var(--x-bg-FDECEC); color: var(--x-tx-9B2C2C); border-color: var(--x-bd-F5C2C2); }

/* --- загрузка со шкалой (core/static/core/upload.js): карточки файлов --- */
.upq { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin: 12px 0 18px; }
.upq-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.upq-head strong { font-size: 15px; }
.upq-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.upq-pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.upq-pill.ok { background: var(--x-bg-E3F5EA); color: var(--x-tx-1E7A45); }
.upq-pill.skip { background: var(--line-soft); color: var(--muted); }
.upq-pill.run, .upq-pill.wait { background: var(--teal-soft); color: var(--teal-ink); }
.upq-pill.bad { background: var(--x-bg-FDECEC); color: var(--x-tx-9B2C2C); }
.upq-total { height: 4px; background: var(--line-soft); border-radius: 4px; overflow: hidden; margin: 12px 0 14px; }
.upq-total i { display: block; height: 100%; width: 0; background: #2E9E5B; transition: width .3s ease; }
.upq-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, max(280px, calc((100% - 24px) / 3))), 1fr)); gap: 12px; }   /* до 3 столбцов */
.upq-card { display: flex; gap: 12px; align-items: flex-start; min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--card); transition: border-color .2s, background .2s; }
.upq-card.run { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.upq-card.bad { border-color: var(--x-bd-F3C9C9); background: var(--x-bg-FFFBFB); }
.upq-card.skip { background: var(--x-bg-FAFCFD); }
.upq-icon { width: 30px; height: 30px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; position: relative; }
.upq-card.wait .upq-icon { background: var(--line-soft); }
.upq-card.wait .upq-icon::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #B9C7D2; }
.upq-card.run .upq-icon { background: var(--teal-soft); }
.upq-card.run .upq-icon::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; border: 2.5px solid var(--teal); border-right-color: transparent; animation: upq-spin .8s linear infinite; }
.upq-card.ok .upq-icon { background: var(--x-bg-E3F5EA); color: var(--x-tx-1E7A45); }
.upq-card.ok .upq-icon::after { content: '✓'; }
.upq-card.skip .upq-icon { background: var(--line-soft); color: var(--muted); }
.upq-card.skip .upq-icon::after { content: '='; }
.upq-card.bad .upq-icon { background: var(--x-bg-FDECEC); color: var(--x-tx-B83232); }
.upq-card.bad .upq-icon::after { content: '✕'; }
.upq-body { min-width: 0; flex: 1; }
.upq-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upq-meta { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.upq-card.run .upq-meta { color: var(--teal-ink); font-weight: 600; }
.upq-bar { height: 4px; background: var(--line-soft); border-radius: 4px; overflow: hidden; margin-top: 8px; display: none; }
.upq-card.run .upq-bar { display: block; }
.upq-bar i { display: block; height: 100%; width: 0; background: var(--teal); border-radius: 4px; transition: width .25s ease; }
.upq-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.upq-tags:empty { display: none; }
.upq-tag { font-size: 11.5px; padding: 2px 8px; border-radius: 6px; background: var(--line-soft); color: var(--ink); white-space: nowrap; }
.upq-card.ok .upq-tag:first-child { background: var(--x-bg-E3F5EA); color: var(--x-tx-1E7A45); font-weight: 600; }
.upq-note { font-size: 12px; line-height: 1.45; margin-top: 5px; overflow-wrap: anywhere; color: var(--ink); }
.upq-note:empty { display: none; }
.upq-card.bad .upq-note { color: var(--x-tx-9B2C2C); }
.upq-link { margin-top: 6px; }
.upq-foot { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-size: 13px; }
.upq-foot button { margin-left: auto; }
@keyframes upq-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .upq-card.run .upq-icon::after { animation: none; } }
.upq-foot button[hidden] { display: none; }

/* Клин. протоколы */
.kp-tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 0 0 16px; }
.kp-tabs a { padding: 8px 14px; border-radius: 8px 8px 0 0; color: var(--muted); text-decoration: none; font-weight: 500; border: 1px solid transparent; border-bottom: 0; margin-bottom: -1px; }
.kp-tabs a.on { background: var(--card); color: var(--ink); border-color: var(--line); }
.kp-search { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.kp-search .card { margin-bottom: 12px; }
.kp-search h3 { margin: 0 0 4px; }
.kp-search input { flex: 1; min-width: 0; }
.kp-row { display: flex; gap: 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line-soft); color: var(--ink); text-decoration: none; }
.kp-row:hover { background: var(--x-bg-F2FBFC); }
.kp-row .chip { margin-left: auto; }
.kp-protos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.kp-proto { display: inline-flex; flex-direction: column; gap: 1px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; text-decoration: none; color: var(--ink); font-weight: 600; }
.kp-proto small { color: var(--muted); font-weight: 400; }
.kp-proto:hover { border-color: var(--teal); background: var(--x-bg-F2FBFC); }
.kp-proto.old { opacity: .7; }
.kp-table-card { overflow-x: auto; }
.kp-table-card h3 { margin: 0 0 8px; }
.kp-table { width: 100%; }
.kp-table td { vertical-align: middle; }
.kp-svc { font-size: 13px; padding: 2px 0; }
.kp-svc code, .kp-table code { font-size: 12px; color: var(--muted); }
.kp-svc.kp-mark { background: var(--amber-bg); border-radius: 4px; padding: 2px 4px; font-weight: 600; }
.kp-quote { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kp-quote summary { cursor: pointer; }
.kp-quote p { margin: 4px 0; }
.kp-codes .chip { margin: 0 2px 4px 0; text-decoration: none; }
.kp-old { opacity: .6; }
.kp-add { border-top: 1px solid var(--line-soft); padding: 8px 0; }
.kp-add summary { cursor: pointer; }
.kp-level { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); margin: 0 0 12px; }
.kp-level a { padding: 7px 14px; color: var(--ink); text-decoration: none; font-size: 13px; }
.kp-level a.on { background: var(--teal); color: #fff; }
.kp-lv { font-size: 11px; color: var(--muted); white-space: nowrap; }
.kp-list td:nth-child(2) { white-space: nowrap; }
.kp-dx { font-size: 13px; }
.kp-o27 { overflow-x: auto; }
.kp-o27 > summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.kp-o27-h { margin: 14px 0 6px; font-size: 14px; }
.kp-o27-head td { background: var(--x-bg-F2FBFC); }
.pdl-fit { margin-top: 4px; font-size: 12px; color: var(--ink); }
.pdl-fit summary { cursor: pointer; color: var(--teal-ink); font-weight: 500; }
.pdl-fit-group { margin: 6px 0 0; max-height: 260px; overflow-y: auto; }
.pdl-fit-group div { padding: 1px 0; }
.pdl-fit code { font-size: 11px; color: var(--muted); }
.dx-link { color: var(--ink); text-decoration: none; } .dx-link:hover { color: var(--teal-ink); text-decoration: underline; }
.chip-dropped { background: var(--x-bg-E9EEF2); color: var(--muted); }
.kp-fix { display: inline; margin: 0; }
.kp-fix button.link { font-size: 11px; color: var(--muted); padding: 0 4px; }
.kp-fix button.link:hover { color: var(--red); }
.kp-fix .kp-code { width: 150px; font-size: 12px; padding: 3px 6px; margin-top: 4px; }
.defect-kind + .defect-kind { margin-top: 6px; }
.defect-kind a { color: var(--ink); }
/* изменяемая ширина столбцов списка дефектов */
table.defects th { position: sticky; top: 0; z-index: 2; }
/* лёгкие границы столбцов, чтобы было видно, где тянуть */
table.defects th, table.defects td { border-right: 1px solid var(--line-soft); }
table.defects th { border-right-color: var(--line); }
table.defects th:last-child, table.defects td:last-child { border-right: 0; }
/* «ручка» на правом краю заголовка: широкая зона захвата, видимая полоска посередине */
table.defects th .col-resize { position: absolute; top: 0; right: -6px; width: 12px; height: 100%; cursor: col-resize; z-index: 2; }
table.defects th .col-resize::after { content: ''; position: absolute; left: 5px; top: 25%; height: 50%; width: 2px; border-radius: 1px; background: var(--faint); opacity: .55; }
table.defects th:hover .col-resize::after { opacity: 1; }
table.defects th .col-resize:hover::after, table.defects th.resizing .col-resize::after { top: 0; height: 100%; background: var(--teal); opacity: 1; }
table.defects th.resizing { background: var(--teal-soft); }
.col-resizing, .col-resizing * { cursor: col-resize !important; user-select: none; }
.defects-wrap table.defects.fixed-cols { table-layout: fixed; max-width: none; }
table.defects.fixed-cols td, table.defects.fixed-cols th { min-width: 0; max-width: none; overflow: hidden; overflow-wrap: anywhere; }
/* страницы «Внешние услуги» и «Нагрузка сотрудников» */
.an-filters select { max-width: 220px; }
.an-picks { margin: -4px 0 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.an-picks a.chip { text-decoration: none; }
.an-grid { display: grid; gap: 14px; margin-bottom: 14px; }
.an-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.an-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .an-top, .an-three { grid-template-columns: minmax(0, 1fr); } }
.an-card { margin-bottom: 0; }
.an-card + .an-card { margin-top: 14px; }
.an-scroll { max-height: 360px; overflow: auto; margin-top: 8px; }
table.fin.an-kpn { margin-top: 8px; }
table.fin.an-kpn th.c { text-align: center; }
table.fin .r, table.an-load .r { text-align: right; }
tr.an-total td { font-weight: 600; border-top: 1px solid var(--line); }
table.fin.an-pat td { white-space: nowrap; }
.an-wide { overflow-x: auto; margin-top: 8px; }
table.an-load { border-collapse: collapse; font-size: 12px; }
table.an-load th, table.an-load td { padding: 3px 6px; border-bottom: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); white-space: nowrap; }
table.an-load .who { position: sticky; left: 0; background: var(--card); min-width: 220px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; z-index: 1; }
table.an-load thead th { background: var(--x-bg-F7FAFC); }
table.an-load thead th.who { background: var(--x-bg-F7FAFC); }
table.an-load .we { background: var(--x-bg-F1F4F7); color: var(--muted); }
table.an-load .pat { color: var(--muted); font-size: 11px; }
table.an-load .tot, table.an-load tfoot td { font-weight: 600; }
table.an-load tfoot td { background: var(--x-bg-EEF3F7); }
.an-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .an-two { grid-template-columns: minmax(0, 1fr); } }
.an-two .an-card + .an-card { margin-top: 0; }
.an-row3 { grid-template-columns: minmax(0, .8fr) repeat(2, minmax(0, 1fr)); }   /* МО уже, направители и исполнители рядом */
@media (max-width: 1100px) { .an-row3 { grid-template-columns: minmax(0, 1fr); } }
table.an-kpn a { color: inherit; display: block; }
table.an-kpn a:hover { color: var(--teal-dark); text-decoration: underline; }
table.an-kpn tr.on td, table.an-kpn th.on { background: var(--teal-soft); }
table.an-kpn th.on a { color: var(--teal-ink); }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--ink); }
th[data-sort].asc::after { content: ' ▲'; font-size: 9px; }
th[data-sort].desc::after { content: ' ▼'; font-size: 9px; }
.slot-months .y { font-size: 11px; font-weight: 600; color: var(--muted); width: 34px; padding: 2px 0; }
.slot-months .m.loaded { background: var(--teal-soft); border-color: var(--teal-soft); color: var(--teal-ink); font-weight: 600; }
.slot-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 11px; }
.slot-legend > span { white-space: nowrap; }
.slot-soon { opacity: .75; }
.slot-soon .chip { align-self: flex-start; }
.slot-legend .m { font-size: 10px; padding: 0 4px; border-radius: 5px; border: 1px solid var(--line); }
.slot-legend .m.closed { background: var(--x-bg-E3F5EA); border-color: var(--x-bd-E3F5EA); color: var(--x-tx-1E7A45); }
.slot-legend .m.loaded { background: var(--teal-soft); border-color: var(--teal-soft); color: var(--teal-ink); }
a.an-card-link { display: inline-flex; align-items: center; gap: 5px; color: var(--teal-ink); }
a.an-card-link .icon { width: 14px; height: 14px; color: var(--teal-dark); flex: none; }
a.an-card-link:hover { color: var(--teal-dark); text-decoration: underline; }
.an-scroll-tall { max-height: 560px; }
table.an-wide-table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 12.5px; }
table.an-wide-table th, table.an-wide-table td { padding: 4px 8px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; text-align: left; vertical-align: middle; }
table.an-wide-table th { position: sticky; top: 0; z-index: 1; background: var(--x-bg-F7FAFC); color: var(--muted); font-weight: 600; }
table.an-wide-table td.w { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
table.an-wide-table td.r, table.an-wide-table th.r { text-align: right; }
table.an-wide-table tr.on td { background: var(--teal-soft); }
table.an-wide-table td:first-child a { color: var(--ink); }
table.an-wide-table .chip { font-size: 11px; padding: 1px 8px; }
/* заголовки столбцов на страницах аналитики — по центру */
.an-card table thead th, .an-card table thead th.r, table.an-load thead th { text-align: center; }
.an-hint { margin: -4px 0 8px; font-size: 12px; }
/* аналитика: выбранные строки наверху, остальные тусклые; шрифт компактнее */
.an-card table tr.dim td, .an-card table td.dim, .an-card table th.dim { opacity: .45; }
.an-card table tr.dim:hover td { opacity: .8; }
.an-card table.fin th, .an-card table.fin td { font-size: 11.5px; padding: 2px 7px; }
table.an-wide-table { font-size: 11.5px; }
table.an-wide-table th, table.an-wide-table td { padding: 3px 7px; }
table.an-load { font-size: 11px; }
.an-hint-inline { font-size: 11px; color: var(--faint); font-weight: 400; margin-left: 8px; }
/* клик принят — страница тускнеет до ответа сервера */
body.an-loading main { opacity: .55; transition: opacity .15s .05s; pointer-events: none; }
body.an-loading { cursor: progress; }
/* большая таблица и нагрузка — тот же компактный шрифт (у ячеек свой размер, поэтому задаём им) */
table.an-wide-table th, table.an-wide-table td, table.an-load th, table.an-load td { font-size: 11.5px; }
/* изменяемая ширина столбцов во всех таблицах (core/static/core/resize.js) */
th.has-grip { position: sticky; top: 0; }
.col-grip { position: absolute; top: 0; right: -5px; width: 10px; height: 100%; cursor: col-resize; z-index: 3; }
.col-grip::after { content: ''; position: absolute; left: 4px; top: 25%; height: 50%; width: 2px; border-radius: 1px; background: var(--faint); opacity: .35; }
th:hover > .col-grip::after { opacity: .9; }
.col-grip:hover::after, th.resizing > .col-grip::after { top: 0; height: 100%; background: var(--teal); opacity: 1; }
th.resizing { background: var(--teal-soft) !important; }
table.cols-fixed { table-layout: fixed; max-width: none; }
table.cols-fixed td, table.cols-fixed th { overflow: hidden; text-overflow: ellipsis; }
/* сортировка и столбцы во всех таблицах (core/static/core/tablekit.js) */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable.asc::after { content: ' ▲'; font-size: 9px; }
th.sortable.desc::after { content: ' ▼'; font-size: 9px; }
.col-hidden { display: none !important; }
.cols-bar { position: relative; display: flex; justify-content: flex-end; margin: 6px 0 4px; }
.cols-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(18, 38, 58, .14); padding: 8px; min-width: 260px; max-height: 420px; overflow-y: auto; }
.cols-menu ul { list-style: none; margin: 4px 0; padding: 0; }
.cols-menu li { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; font-size: 12.5px; }
.cols-menu li:hover { background: var(--teal-soft); }
.cols-menu li.dragging { opacity: .4; }
.cols-menu label { flex: 1; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.cols-drag { cursor: grab; color: var(--faint); letter-spacing: -2px; }
.cols-hint { font-size: 11px; padding: 0 6px; }
th[draggable="true"] { cursor: grab; }
th.dragging { opacity: .4; }
th.drop-left { box-shadow: inset 3px 0 0 var(--teal); }
th.drop-right { box-shadow: inset -3px 0 0 var(--teal); }
/* карточка пациента: фильтр месяцев и два окна сводки */
.card-filter { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-sum { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
@media (max-width: 1100px) { .card-sum { grid-template-columns: minmax(0, 1fr); } }
.card-sum .an-scroll { max-height: 260px; }
.card-top { display: flex; gap: 14px; align-items: stretch; }
.card-top .card-filter { flex-direction: row; align-items: center; justify-content: center; margin: 0 0 14px; min-width: 200px; }
.card-top .kpis { flex: 1; }
.card-hint { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -4px 0 8px; }
.card-hint .an-hint-inline { margin-left: 0; }
.card-hint .an-picks { margin: 0; }
@media (max-width: 900px) { .card-top { flex-direction: column; } }
/* окна рядом в сетке — одной высоты и без сдвига: отступ «карточка за карточкой» здесь не нужен */
.an-grid > .card { margin: 0; }
.an-grid { align-items: stretch; }

.zoom-ctl { display: flex; align-items: center; gap: 6px; padding: 4px 10px 6px; color: #C9E1E8; }
.zoom-ctl > span:first-child { flex: 1; }
.zoom-btn { background: rgba(255, 255, 255, .06); color: #fff; border: 1px solid rgba(255, 255, 255, .14); border-radius: 8px; padding: 1px 8px; font-size: 12px; font-weight: 600; cursor: pointer; box-shadow: none; }
.zoom-btn:hover { background: rgba(255, 255, 255, .14); box-shadow: none; }
.zoom-val { min-width: 34px; text-align: center; font-size: 12px; }
/* названия столбцов во всех таблицах — по центру */
main table th, main table thead th.r, main table th.r { text-align: center; }
main table th a.sort { display: inline-block; }

/* Скрининги */
.sc-warn { background: var(--amber-bg); color: var(--amber-ink); }
.sc-bad { color: var(--red-ink); }
.sc-good { color: var(--green-ink); }   /* выполнено, сделано, прошёл — зелёным, как «не было» красным */
.sc-sum td a { color: inherit; }
table.fin.sc-sum th { white-space: normal; overflow: visible; vertical-align: bottom; }
.sc-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 14px 0 8px; }
.sc-tabs a { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--x-bd-C9D6DF); color: var(--ink); text-decoration: none; background: var(--card); }
.sc-tabs a.on { background: var(--teal-soft); border-color: var(--teal); font-weight: 600; }
/* Список скрининга: на всю высоту окна, строки в одну линию (полный текст — в подсказке) */
.content:has(.sc-list), .content:has(.sc-tabs) { max-width: none; padding: 14px 18px 24px; }   /* скрининги — на всю ширину */
.sc-list-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.sc-list-head .grow { flex: 1; }
[data-cols-slot] .cols-bar { margin: 0; }
.an-scroll.sc-scroll { max-height: calc(100vh / var(--z, 1) - 110px); }
table.an-wide-table.sc-table td { max-width: 320px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }

/* Прокрутка широкой таблицы вбок: копия полосы внизу экрана (core/static/core/hscroll.js) */
.hscroll-bar { position: fixed; bottom: 0; height: 16px; overflow-x: scroll; overflow-y: hidden; z-index: 50;
  background: rgba(247, 250, 252, .95); border-top: 1px solid var(--line); }
.hscroll-bar > div { height: 1px; }
/* Широкая таблица без своей прокрутки — обёртка от hscroll.js: прокрутка вбок, шапка липнет внутри */
.tbl-x { overflow: auto; max-width: 100%; max-height: calc(100vh / var(--z, 1) - 120px); }
/* Диспансеризация: свод по группам заболеваний — своё окно, чтобы 100+ групп не растягивали страницу */
.dp-groups { max-height: calc(40vh / var(--z, 1)); }
.dp-list.dp-with-pv { display: grid; grid-template-columns: minmax(320px, 470px) minmax(0, 1fr); gap: 12px; align-items: start; }
.dp-pv { min-width: 0; }
.dp-pv-head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.dp-pv-head .msel { flex: 1; min-width: 0; }
.dp-pv-x { text-decoration: none; padding: 2px 6px; }
table.fin.dp-pv-table { width: 100%; }
table.fin.dp-pv-table { table-layout: auto; }
table.fin.dp-pv-table td.r, table.fin.dp-pv-table th.r { width: 1%; overflow: visible; }
table.fin.dp-pv-table th { white-space: normal; overflow: visible; }
table.fin.dp-pv-table td:first-child { white-space: normal; overflow: visible; min-width: 120px; }
@media (max-width: 1100px) { .dp-list.dp-with-pv { grid-template-columns: minmax(0, 1fr); } }
.dp-top { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 8px; }
.dp-top .an-card { flex: 0 1 auto; min-width: 0; }
table.fin.dp-sum { width: auto; table-layout: auto; }
table.fin.dp-sum td:first-child { max-width: 420px; }
.dp-tabs { flex-direction: column; margin: 0; flex: 0 0 auto; }
@media (max-width: 1100px) { .dp-top { flex-direction: column; } .dp-tabs { flex-direction: row; } }
/* Администрирование */
.adm-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.adm-table th, .adm-table td { padding: 5px 8px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
.adm-table th.r, .adm-table td.r { text-align: right; }
.adm-table td.c { text-align: center; color: var(--green); font-weight: 600; }
.adm-matrix th { white-space: nowrap; }
.adm-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; align-items: start; }
.adm-inline { display: inline-flex; gap: 6px; align-items: center; margin: 2px 6px 2px 0; }
.adm-action { margin: 0 0 10px; }
.adm-districts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 12px; max-height: 320px; overflow: auto; margin-bottom: 10px; }
.adm-mono { font-family: Consolas, monospace; font-size: 15px; letter-spacing: .5px; }
.adm-item { margin: 0 0 8px; }
.adm-h { margin: 0; }
/* Кадры */
.hr-schedule tr.hr-unit td, .adm-table tr.hr-unit td { background: var(--x-bg-F3F7FA); }
.hr-over { color: var(--x-tx-B4641E); }
.hr-grp { padding: 8px 14px; margin-bottom: 8px; }
.hr-grp > summary { cursor: pointer; padding: 4px 0; }
.hr-grp[open] > summary { margin-bottom: 6px; border-bottom: 1px solid var(--line-soft); }
.hr-grp:target { box-shadow: 0 0 0 2px var(--teal-soft); border-color: var(--teal); }
tr.hr-mark td { background: var(--amber-bg); }
.hr-view .btn.on { background: var(--teal-soft); color: var(--teal-ink); border-color: var(--teal); }
.hr-link-edit { margin-left: 6px; color: var(--faint); }
.hr-plus { color: var(--green); }
.kp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin: 0 0 14px; align-items: start; }
.kp-tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.kp-tile.off { background: var(--x-bg-FAFBFC); color: var(--muted); }
.kp-tile-h { font-weight: 600; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; color: var(--ink); }
.kp-tile-row { padding: 3px 0; border-top: 1px solid var(--line-soft); }
.kp-tile details summary { cursor: pointer; }
.kp-tile.kp-goto { cursor: pointer; }
.kp-tile.kp-goto:hover { border-color: var(--teal); }
.kp-tile.kp-goto.on { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal-soft); }
details.kp-sec > summary { cursor: pointer; list-style: none; }
details.kp-sec > summary h3 { display: inline; }
details.kp-sec > summary::before { content: "▾ "; color: var(--muted); }
details.kp-sec:not([open]) > summary::before { content: "▸ "; }
a.ref { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--teal); }
a.ref:hover { color: var(--teal-ink); }
/* tablekit: «Исходный порядок» — видна, только когда таблица отсортирована */
.tk-reset { display: block; margin: 0 0 4px auto; font-size: 12px; }
.tk-reset[hidden] { display: none; }
/* кадры: свободная ставка — слегка красным */
tr.hr-vac td { background: var(--x-bg-FDF3F1); }
tr.hr-vac td:first-child { color: var(--red-ink); }
tr.hr-auto td { background: var(--x-bg-FFF8E6); }
/* дефекты: переключатель «Детально / Свод» и свод (Парето) */
.dv-switch { display: inline-flex; gap: 0; }
.dv-switch .btn { border-radius: 0; }
.dv-switch .btn:first-child { border-radius: 8px 0 0 8px; }
.dv-switch .btn:last-child { border-radius: 0 8px 8px 0; }
.dv-by { flex-wrap: wrap; gap: 6px; }
.dv-sum tr.dv-top td:nth-child(3) b { color: var(--red); }
.dv-bar { display: inline-block; width: 60px; height: 6px; margin-right: 6px; vertical-align: middle; border-radius: 3px;
  background: linear-gradient(90deg, var(--teal) var(--w), var(--line-soft) var(--w)); }
.nowrap { white-space: nowrap; }
/* пациенты: фильтры как в РПН */
.rpn-f { flex-basis: 100%; padding: 10px 14px; margin: 4px 0 0; }
.rpn-f > summary { cursor: pointer; }
.rpn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 12px; margin-top: 10px; }
.rpn-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.rpn-grid select, .rpn-grid input { width: 100%; }
.rpn-age { display: flex; align-items: center; gap: 6px; color: var(--ink); }
.rpn-age input { width: 80px; }
.pyr .pyr-bar { display: block; height: 8px; border-radius: 4px; width: min(100%, var(--w)); background: var(--teal); }
/* главная «Обзор МО» */
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
@media (max-width: 1100px) { .cols-3 { grid-template-columns: minmax(0, 1fr); } }
.ov-card .ov-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; gap: 8px; }
.ov-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin: 8px 0 4px; }
.ov-bar { height: 8px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.ov-bar i { display: block; height: 100%; border-radius: 4px; background: var(--teal); }
.ov-bar i.ok { background: var(--green); }
/* «Мой день»: охват по каждому участку сотрудника — отстающие сверху */
.md-by { margin: 8px 0 14px; display: grid; gap: 6px; }
.md-by-row { display: grid; grid-template-columns: 92px 1fr 44px; align-items: center; gap: 10px; font-size: .92em; }
.md-by-row .ov-bar { height: 6px; }
.md-by-row b { text-align: right; }
.ov-bar i.blue { background: #378ADD; }
.ov-bar i.lv-good { background: var(--green); } .ov-bar i.lv-mid { background: #E8891E; }
.ov-bar i.lv-low { background: #E5675A; } .ov-bar i.lv-bad { background: #8E1B2E; }
.ov-ok { color: var(--green); } .ov-bad { color: var(--red); }
.ov-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 10px 0 6px; }
.ov-tiles a { background: var(--x-bg-F6F9FB); border-radius: 8px; padding: 8px 10px; color: var(--ink); display: flex; flex-direction: column; gap: 2px; }
.ov-tiles a:hover { background: var(--teal-soft); }
.ov-tiles span { font-size: 12px; color: var(--muted); }
.ov-trend { position: relative; display: flex; align-items: flex-end; gap: 6px; height: 90px; padding-bottom: 16px; }
.ov-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; color: var(--muted); }
.ov-colbar { width: 100%; max-width: 26px; background: var(--x-bg-BFE6EC); border-radius: 3px 3px 0 0; min-height: 2px; }
.ov-colbar.ok { background: #8FD3B4; } .ov-colbar.on { outline: 2px solid var(--teal); }
.ov-col small { position: absolute; bottom: 0; font-size: 11px; }
.ov-col { position: relative; }
.ov-line { position: absolute; left: 0; right: 0; bottom: calc(16px + (100% - 16px) * 100 / 150); border-top: 1px dashed var(--red); opacity: .7; z-index: 1; pointer-events: none; }
/* освоение: перевыполнение, которое не оплатят (finance/overrun.py) */
.fin-bar .cap-warn { background: #E8892B; } .fin-bar .cap-over { background: var(--red); }
.fin-p-cap-warn, .fin-p-warn { color: var(--x-tx-C46A12); font-weight: 600; } .fin-p-cap-over, .fin-p-over { color: var(--red); font-weight: 600; }
.ov-lots { margin-top: 12px; border-top: 1px solid var(--line-soft); padding-top: 6px; }
.ov-sub { font-size: 13px; font-weight: 600; margin: 10px 0 2px; }
.ov-lots .ov-row { margin: 3px 0; }
.ov-paid { font-size: 12px; }
.fin-p-lo { color: var(--x-tx-B7791F); } .fin-p-ok, .fin-p-hi, .fin-p-paid { color: inherit; }
.fin-src a { color: inherit; } .fin-src a:hover { color: var(--teal-dark); }
.fin-src.on td { background: var(--teal-soft); } .fin-src.on a { color: var(--teal-ink); }
/* уникальные люди под числом услуг / случаев (фильтр ppl) */
.ppl { display: inline; margin-left: 6px; font-size: 11.5px; line-height: 1.2; color: var(--muted, #6b7785); font-weight: normal; white-space: nowrap; }
/* главная: освоение по дням — будний день против плана дня */
.ov-days { gap: 2px; }
.ov-days .ov-colbar.low { background: var(--x-bg-F3C7A6); } .ov-days .ov-colbar.off { background: var(--x-bg-D5DDE4); }
.ov-days .ov-colbar.future { background: transparent; }
.ov-days small { font-size: 10px; bottom: -15px; } .ov-days small.ov-we { color: var(--faint); }
.ov-legend { font-size: 12px; margin-top: 4px; }
.ov-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: -1px; background: #8FD3B4; }
.ov-legend i:first-child { margin-left: 0; } .ov-legend i.low { background: var(--x-bg-F3C7A6); } .ov-legend i.off { background: var(--x-bg-D5DDE4); }
/* «Освоение»: календарик выбора дней (С — По) */
.fin-cal { position: relative; display: inline-block; }
.fin-cal > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.fin-cal > summary::-webkit-details-marker { display: none; }
.fin-cal-pop { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: 290px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(18, 38, 58, .15); padding: 10px 12px; }
.fin-cal-hint { font-size: 12px; margin-bottom: 6px; white-space: normal; }
.fin-cal-grid { width: 100%; border-collapse: collapse; }
.fin-cal-grid th { background: none; text-align: center; padding: 2px 0; font-size: 11px; }
.fin-cal-grid td { padding: 1px; text-align: center; border: 0; }
.fin-cal-grid td a { display: block; padding: 4px 0; border-radius: 4px; color: var(--ink); text-decoration: none; font-size: 13px; }
.fin-cal-grid td a:hover { background: var(--x-bg-E6F4F6); }
.fin-cal-grid td a.off { color: var(--faint); }
.fin-cal-grid td a.on { background: var(--teal); color: #fff; }
.fin-cal-grid a.fin-cal-week { font-size: 11px; color: var(--muted); }
.fin-cal-grid a.fin-cal-week.on { background: none; color: var(--teal); font-weight: 600; }
.fin-cal-all { display: inline-block; margin-top: 6px; font-size: 13px; }
a.ov-col { text-decoration: none; }
a.ov-col:hover .ov-colbar { outline: 2px solid var(--teal); }
/* «Освоение», окно «Услуги»: название в две строки, всё по середине строки */
table.fin.fin-wrap2 td { vertical-align: middle; }
table.fin.fin-wrap2 td:first-child { white-space: normal; }
table.fin.fin-wrap2 td:first-child a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-head .rb-more { margin-left: auto; font-size: 13px; } .card-head .sum-hint + .rb-more { margin-left: 0; }
/* главная: лоты полосками заполнения плана */
.ov-lotbar { padding: 5px 0; }
.ov-lotbar .name { width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--teal-dark); }
.ov-lotbar .pct { width: 56px; flex: none; text-align: right; white-space: nowrap; }
.ov-lotbar .sum { width: 112px; text-align: right; white-space: nowrap; }
/* шкала до 200% на главной: черта — 100% плана */
.ov-scale { position: relative; overflow: visible; }
.ov-scale .ov-base { position: absolute; left: 0; top: 0; bottom: 0; background: #3AA675; border-radius: 4px 0 0 4px; }
.ov-scale .ov-base.lv-lo { background: #E0B04A; }
.ov-scale .ov-tail { position: absolute; left: 50%; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: #3AA675; }
.ov-scale .ov-tail.lv-warn { background: #E8892B; } .ov-scale .ov-tail.lv-over { background: var(--red); }
.ov-scale .ov-tail.lv-paid { background: #1F7A52; }
.ov-scale .ov-tick { position: absolute; left: calc(50% - 1px); top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .55; }
/* «Сверка с ЕПС» (соисполнение) */
.cx-tiles .kpi.on { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.cx-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr); gap: 16px; align-items: start; }
.cx-grid > .card { margin: 0; }
@media (max-width: 1100px) { .cx-grid { grid-template-columns: minmax(0, 1fr); } }
/* фильтр с поиском (registry/_msel.html, data-search): строка поиска прилипает к верху списка */
.msel[data-search] .msel-pop { min-width: 380px; max-width: 520px; }
.msel-search { position: sticky; top: -6px; z-index: 1; width: 100%; margin: -6px 0 6px; padding: 7px 10px; border: 0; border-bottom: 1px solid var(--line); border-radius: 10px 10px 0 0; background: var(--card); font-size: 13px; }
.msel-opt[hidden] { display: none; }
/* «ЕПС → Отклонения»: два свода в ряд сверху, общая таблица снизу на всю ширину */
.cx-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-bottom: 16px; }
.cx-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cx-head .grow { flex: 1; }
/* своды — небольшие окна со своей прокруткой: пока мышь над таблицей, колесо крутит только её
   (страница не уезжает, когда таблица докручена до конца); шапка столбцов стоит на месте */
.cx-grid .an-scroll { max-height: 320px; overflow: auto; overscroll-behavior: contain; }
.cx-grid table.fin thead th { top: 0; z-index: 3; box-shadow: 0 1px 0 var(--line); }
.cx-main > .card { margin: 0; }
/* «Аналитика услуг»: таблица КПН слева (компактно), фильтры справа */
.an-top { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.an-top > .card { margin: 0; }
.an-kpn-card table.fin.an-kpn th, .an-kpn-card table.fin.an-kpn td { padding: 3px 6px; }
.an-filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.an-filter-grid select, .an-filter-grid .msel, .an-filter-grid .msel-btn { width: 100%; max-width: none; }
.an-filter-grid .an-q { grid-column: 1 / -1; width: 100%; }
.an-filter-actions { grid-column: 1 / -1; display: flex; gap: 12px; align-items: center; }
.an-filter-card .an-picks { margin: 10px 0 0; }
@media (max-width: 1100px) { .an-top { grid-template-columns: minmax(0, 1fr); } }
/* таблица КПН / вне КПН: лёгкая сетка — каждую цифру видно в своей клетке */
.an-kpn-card table.fin.an-kpn th, .an-kpn-card table.fin.an-kpn td { border: 1px solid var(--line-soft); }
.an-kpn-card table.fin.an-kpn { border-collapse: collapse; }
.an-kpn-card table.fin.an-kpn tr.an-total td { border-top: 1px solid var(--line); }

/* «Как считается» — справка у заголовка страницы */
.howto { position: relative; font-size: 13px; }
.howto > summary { list-style: none; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); user-select: none; }
.howto > summary::-webkit-details-marker { display: none; }
.howto > summary .icon { width: 14px; height: 14px; }
.howto > summary:hover, .howto[open] > summary { color: var(--teal-dark); border-color: var(--teal); }
.howto-body { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: min(560px, 86vw); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(15, 35, 60, .14); padding: 12px 16px;
  color: var(--text, #1d2b3a); line-height: 1.5; }
.howto-body p { margin: 0 0 6px; }
.howto-body ul { margin: 0 0 6px; padding-left: 18px; }
.howto-body li { margin: 2px 0; }
.howto-body b { font-weight: 600; }
.howto-body :last-child { margin-bottom: 0; }

/* Карточка сотрудника: профиль и «чем занимается» */
.pc-head { display: grid; grid-template-columns: minmax(320px, 1.2fr) minmax(240px, 1fr) minmax(240px, 1fr); gap: 12px; margin-bottom: 14px; align-items: start; }
@media (max-width: 1100px) { .pc-head { grid-template-columns: 1fr; } }
.pc-head .card { margin: 0; }
.pc-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.pc-job-more { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 10px; }
.pc-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.pc-facts dt { color: var(--muted); }
.pc-facts dd { margin: 0; }
.pc-eps { margin-top: 10px; font-size: 12px; }
.pc-top h3 { margin: 0 0 8px; font-size: 14px; }
.pc-svc { display: flex; gap: 10px; justify-content: space-between; align-items: baseline; font-size: 13px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.pc-svc:last-child { border-bottom: 0; }
.pc-svc a { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pc-svc b { white-space: nowrap; }

.pc-link { margin-left: 6px; opacity: .55; }
.pc-link:hover { opacity: 1; }
.pc-link .icon { width: 14px; height: 14px; vertical-align: -2px; }
.an-load td.who a { color: inherit; }
.an-load td.who a:hover { color: var(--teal-dark); text-decoration: underline; }

/* Карточка пациента: блок «По руководству ВОП» */
/* карточки разной высоты — колонками без пустот под короткими */
.guide-grid { columns: 2 440px; column-gap: 12px; }
/* один блок — на всю ширину, пустой колонки справа нет */
.guide-grid:has(> :only-child) { columns: auto; }
.guide-grid > :only-child .guide-table td:first-child { width: 30%; }
.guide-card { margin: 0 0 12px; padding: 12px 14px; break-inside: avoid; display: block; }
h2 .h2-note { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 8px; }
h2 .g-law { font-size: 13px; font-weight: 400; margin-left: 8px; }
table.tight { width: auto; min-width: 50%; }
table.sched.tight td:nth-child(n+3) { white-space: nowrap; }
table.tight + table.tight { margin-top: 10px; }
table.sched tr.sched-year td { border-top: 2px solid var(--line, #D5DEE5); }
.guide-card .g-law { display: block; font-size: 12px; font-weight: 400; margin-top: 2px; }
.pd-top { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.pd-top .card { margin: 0; }
.pd-top dl.props { grid-template-columns: 150px minmax(0, 1fr); gap: 3px 10px; margin-top: 8px; }
.pd-top dl.props dt { font-size: 13px; }
/* Отметки по пациенту в списках: кнопка в строке и меню (pactions.js) */
.pa-btn { display: inline-block; min-width: 26px; padding: 1px 7px; border: 1px dashed var(--line); border-radius: 999px; background: none;
  color: var(--muted); font: inherit; font-size: 11.5px; line-height: 16px; white-space: nowrap; cursor: default; box-shadow: none; }
button.pa-btn { cursor: pointer; }
button.pa-btn:hover { border-style: solid; color: var(--ink); }
.pa-btn.pa-called, .pa-opt.pa-called.on { border: 1px solid var(--teal-dark); color: var(--teal-ink); background: var(--teal-soft); }
.pa-btn.pa-booked, .pa-btn.pa-done, .pa-opt.pa-booked.on, .pa-opt.pa-done.on { border: 1px solid var(--green); color: var(--green-ink); background: var(--green-bg); }
.pa-btn.pa-refused, .pa-opt.pa-refused.on { border: 1px solid var(--red); color: var(--red-ink); background: var(--red-bg); }
.pa-btn.pa-no_contact, .pa-opt.pa-no_contact.on { border: 1px solid var(--amber); color: var(--amber-ink); background: var(--amber-bg); }
.pa-btn.pa-left, .pa-opt.pa-left.on { border: 1px solid var(--line); color: var(--muted); background: var(--line-soft); }
.pa-opt.pa-none { border-style: dashed; color: var(--muted); }
.pa-opt.pa-none.on { border-style: solid; }
.pa-btn.pa-flash { transform: scale(1.08); transition: transform .3s; }
.pa-menu { position: fixed; z-index: 60; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px;
  box-shadow: 0 8px 24px rgba(18, 38, 58, .18); width: 230px; display: grid; gap: 6px; animation: mo-pop .15s var(--ease); }
.pa-list { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.pa-opt { padding: 4px 6px; border: 1px solid var(--line); border-radius: 8px; background: none; color: var(--ink); font: inherit; font-size: 12.5px;
  box-shadow: none; cursor: pointer; min-height: 0; }
.pa-opt:hover { background: var(--teal-soft); }
.pa-note { width: 100%; box-sizing: border-box; font-size: 12.5px; padding: 4px 6px; }
.pa-day { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin: 6px 0; }
.pa-date { flex: 1; font-size: 12.5px; padding: 3px 6px; min-height: 0; }
.pa-bulk .pa-date { flex: none; width: 140px; }
td[data-ci="act"] { white-space: nowrap; }
.pa-ck, .pa-ck-all { vertical-align: middle; margin: 0 2px 0 0; }
th[data-ci="act"] .pa-ck-all { margin-right: 4px; }
.pa-bulk { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 55; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  max-width: calc(100vw - 40px); padding: 10px 14px; background: var(--card); border: 2px solid var(--teal-dark); border-radius: 12px;
  box-shadow: 0 0 0 4px var(--teal-soft), 0 14px 40px rgba(0, 0, 0, .45); animation: mo-pop .15s var(--ease); }
.pa-bulk .pa-bulk-n { color: var(--teal-ink); margin-right: 4px; }
.pa-same { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.pa-bulk .pa-note { width: 180px; }
.pa-bulk .pa-opt { padding: 4px 9px; }

/* Дозаполнение прямо в «Сведениях о пациенте»: ИИН, ФИО, телефон */
.pd-edit { display: grid; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.pd-edit label { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; color: var(--muted); }
.pd-edit label.pd-check { flex-direction: row; align-items: center; gap: 6px; }
.pd-edit input, .pd-edit textarea { width: 100%; box-sizing: border-box; color: var(--ink); }
.pd-edit textarea { min-height: 42px; }
.pd-edit button { justify-self: start; }
/* РПН — пары «поле: значение» в две колонки, длинный адрес не растягивает соседей */
dl.props-2 { columns: 2 320px; column-gap: 24px; margin: 8px 0 0; }
dl.props-2 > div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 0 10px; padding: 3px 0; break-inside: avoid; }
dl.props-2 dt { color: var(--muted); font-size: 13px; }
dl.props-2 dd { margin: 0; }
@media (max-width: 1100px) { .pd-top { grid-template-columns: 1fr; } }
.guide-table { width: 100%; margin-top: 6px; border-collapse: collapse; font-size: 13px; }
.guide-table td { white-space: pre-line; padding: 4px 6px; border-top: 1px solid var(--line, #E3E9EE); vertical-align: middle; }
.guide-table td:first-child { width: 48%; }
.guide-table .muted { font-size: 12px; }
.guide-table .g-plan { font-size: 12px; font-weight: 600; color: var(--ink-2, #44525E); }
.g-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #9AA8B3; }
.g-ok .g-dot { background: #2E9D6B; }
.g-wait .g-dot { background: #E0A12B; }
.g-bad .g-dot { background: #D2483F; }
.g-bad td:last-child { color: var(--x-tx-B53A32); font-weight: 600; }


/* Свод по участкам: ячейка — % с цветом уровня, «n из N» — в подсказке */
.dt-card { margin-top: 16px; }
.dt-wrap { overflow-x: auto; }
.dt-table { width: 100%; border-collapse: collapse; }
.dt-table th { white-space: normal; vertical-align: bottom; line-height: 1.2; }
.dt-table th:first-child { white-space: nowrap; }
.dt-table td.dt-name { white-space: nowrap; }
.dt-pct { display: inline-block; min-width: 40px; padding: 1px 4px; border-radius: 6px; font-weight: 600; text-align: center; color: #fff; }
.dt-pct.lv-good { background: var(--green); } .dt-pct.lv-mid { background: #E8891E; }
.dp-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 12px; margin-bottom: 12px; }
.dp-group { padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.dp-group strong { margin-bottom: 6px; }
.dp-group .dp-row, .dp-group a.dp-row { display: grid; align-items: baseline; grid-template-columns: 1fr auto; column-gap: 10px; padding: 5px 6px; margin: 0 -6px; border-radius: 8px;
  text-decoration: none; color: var(--ink); }
a.dp-row[href]:hover { background: var(--line-soft); }
.dp-name { font-weight: 500; }
.dp-pct { text-align: right; }
.dp-pct.lv-good { color: var(--green); } .dp-pct.lv-mid { color: #E8891E; } .dp-pct.lv-low { color: #E5675A; } .dp-pct.lv-bad { color: #C2364A; }
.dp-nt { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.dt-nt { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.dt-pct.lv-low { background: #E5675A; } .dt-pct.lv-bad { background: #8E1B2E; }
.dt-table th, .dt-table td { padding: 5px 6px; }
.dt-table th.num { text-align: center; font-size: 12px; }
.dt-table td.num { text-align: center; }
/* «Участки»: калькулятор весов и карточка */
.dt-calc summary { cursor: pointer; }
.dt-weights { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px 14px; margin-top: 10px; align-items: end; }
.dt-weights label { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.dt-weights input { width: 64px; text-align: right; }
.dt-weights input.dt-changed { border-color: var(--primary); }
.dt-actions { display: flex; gap: 10px; align-items: center; }
.dt-table td.dt-staff { font-size: 12.5px; max-width: 220px; }
.dt-cardgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.dt-score { display: inline-block; padding: 0 10px; border-radius: 8px; color: #fff; }
.dt-score.lv-good { background: var(--green); } .dt-score.lv-mid { background: #E8891E; }
.dt-score.lv-low { background: #E5675A; } .dt-score.lv-bad { background: #8E1B2E; }
.dt-w { display: inline-block; min-width: 22px; text-align: right; font-size: 11.5px; }
table.fin.dt-table { table-layout: auto; }
table.fin.dt-table th, table.fin.dt-table td { overflow: visible; text-overflow: clip; font-size: 13px; }
table.fin.dt-table th { white-space: normal; }
table.fin.dt-table td.dt-staff { white-space: normal; }
table.fin.dt-table th { hyphens: auto; -webkit-hyphens: auto; font-size: 12px; }
table.fin.dt-table td { padding: 3px 5px; }
.dt-inds { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px 28px; }
.dt-people { margin-bottom: 16px; }
.dt-people-list { display: flex; flex-wrap: wrap; gap: 6px 28px; align-items: baseline; }
/* Итоги в таблицах: строка «Итого/Всего», подвал и столбец «Всего» — жирнее и с фоном (метки ставит totals.js) */
tfoot td, tr.is-total td, tr.an-total td { font-weight: 700; color: var(--x-tx-1F3242); background: var(--x-bg-E9F1F5); }
tfoot tr:first-child td, tr.is-total td { border-top: 2px solid var(--x-bd-B9CBD6); }
td.is-total-col { font-weight: 700; color: var(--x-tx-1F3242); background: var(--x-bg-F1F6F9); }
th.is-total-col { color: var(--x-tx-1F3242); }
tfoot td.is-total-col, tr.is-total td.is-total-col { background: var(--x-bg-DDEAF0); }
table.fin tfoot td, table.an-load tfoot td { background: var(--x-bg-E9F1F5); font-weight: 700; }
tfoot td.muted { font-weight: 400; color: var(--muted); }
/* Подсказки в поиске (suggest.js) */
.sg-box { position: absolute; z-index: 60; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-md); padding: 4px; max-width: 560px; max-height: 340px; overflow-y: auto; }
.sg-item { display: flex; gap: 10px; align-items: baseline; padding: 6px 10px; border-radius: 7px; cursor: pointer; font-size: 13.5px; }
.sg-item b { font-weight: 600; white-space: nowrap; }
.sg-item span { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-item:hover, .sg-item.on { background: rgba(26, 151, 166, .10); }
/* Карточка участка: своды разделов */
.dt-secs { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 16px; margin-top: 16px; align-items: start; }
.dt-sec .ov-head a { color: inherit; }
.dt-mini { box-shadow: none; border: 0; border-radius: 0; }
.dt-mini th, .dt-mini td { padding: 4px 8px; font-size: 13px; }
.dt-mini td:first-child { width: 100%; }
.dt-mini td.r, .dt-mini th.r { text-align: right; white-space: nowrap; }
.dt-secs { display: block; columns: 460px; column-gap: 16px; }
.dt-secs .dt-sec { break-inside: avoid; margin-bottom: 16px; display: block; }
.dt-mini a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--x-bd-9FB4C2); }
.dt-mini a:hover { color: var(--primary); border-bottom-color: var(--primary); }
.dt-mini a.dt-left { color: var(--x-tx-B23A2E); font-weight: 600; }
a.dt-pct { text-decoration: none; }
a.dt-pct:hover { filter: brightness(1.12); box-shadow: 0 0 0 2px rgba(26, 151, 166, .35); }
a.dt-plain { color: inherit; text-decoration: none; }
a.dt-plain:hover { color: var(--primary); text-decoration: underline; }
a.dt-left { color: var(--x-tx-B23A2E); font-weight: 600; text-decoration: none; }
a.dt-left:hover { text-decoration: underline; }
/* Карточка сотрудника: своды таблицами — слева дефекты и диагнозы, справа услуги */
.pc-sums { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 16px; align-items: start; margin-bottom: 16px; }
.pc-sums-col { display: grid; gap: 16px; }
.pc-sums .card { margin: 0; }
.pc-sums .card h3 { margin-top: 0; }
.pc-sums .dt-mini td:first-child { width: auto; }
.pc-sums .dt-mini td.w { width: 100%; }
/* Услуги — высотой с левый столбец (дефекты + диагнозы), длинный список прокручивается внутри */
.pc-sums { align-items: stretch; }
.pc-sums-col { align-content: start; }
.pc-svc-card { display: flex; flex-direction: column; }
.pc-scroll { flex: 1 1 0; min-height: 360px; overflow: auto; }
.pc-scroll thead th { position: sticky; top: 0; z-index: 1; }
.pc-scroll tfoot td { position: sticky; bottom: 0; }
.pc-flt{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin:0 0 8px}


/* ===== Тёмная тема: переключатель в шапке (☾/☀), запоминается в браузере; по умолчанию — как в системе ===== */
:root { --text: var(--ink); --ink-2: var(--muted); --thead: #F5F8FB; --row-hover: #F2FAFB; --tile-hi: rgba(47, 180, 196, .10); color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0D1823; --card: #142230; --ink: #E2EBF2; --muted: #93A8B9; --faint: #6D8396;
  --line: #243748; --line-soft: #1C2D3C;
  --teal-dark: #5CCBD8; --teal-ink: #A5E6EC; --teal-soft: #12363D;
  --red: #EE7663; --red-bg: #3A1F1B; --red-ink: #F6B2A6;
  --amber: #E3A740; --amber-bg: #372A12; --amber-ink: #F2CD86;
  --green: #3DB37E; --green-bg: #11332A; --green-ink: #93DEB8;
  --primary: #1A97A6; --primary-hover: #22AEBF; --ring: rgba(47, 180, 196, .35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35); --shadow-md: 0 8px 22px rgba(0, 0, 0, .45);
  --thead: #18293A; --row-hover: #193040; --tile-hi: rgba(47, 180, 196, .14);
  --x-bd-9AAAB7: #616970; --x-bd-9FB4C2: #5A666F; --x-bd-A9DCE3: #4A666A; --x-bd-AFC2D0: #525F68; --x-bd-B9CBD6: #4E5B63; --x-bd-B9E2CC: #466555; --x-bd-C9D6DF: #49545C; --x-bd-CBD7E1: #48535C; --x-bd-D0DBE4: #465159; --x-bd-E3F5EA: #3A5344; --x-bd-E7C47A: #776B52; --x-bd-F0D49A: #6A604A; --x-bd-F3C9C9: #5C4040; --x-bd-F5C2C2: #5D4141; --x-bg-BFE6EC: #33585E; --x-bg-C9D3DB: #434D54; --x-bg-C9D4DC: #424C54; --x-bg-D5DDE4: #394249; --x-bg-DCE5EC: #303B43; --x-bg-DDEAF0: #2B3B43; --x-bg-E3F5EA: #253F2F; --x-bg-E6F4F6: #23393C; --x-bg-E8EEF3: #283138; --x-bg-E9EEF2: #293137; --x-bg-E9F1F5: #253238; --x-bg-EEF3F7: #232C34; --x-bg-F1F4F7: #232A30; --x-bg-F1F6F9: #202B32; --x-bg-F2FAFB: #1C3032; --x-bg-F2FBFC: #1A3133; --x-bg-F3C7A6: #6C4D36; --x-bg-F3F7FA: #1E2830; --x-bg-F3FAFB: #1C2F31; --x-bg-F6F9FB: #1D272D; --x-bg-F7FAFC: #1B262D; --x-bg-FAFBFC: #1E2327; --x-bg-FAFCFD: #1A252A; --x-bg-FDECEC: #371C1C; --x-bg-FDF3F1: #331E1A; --x-bg-FFF8E6: #39311D; --x-bg-FFFBFB: #2B1616; --x-tx-1E7A45: #A7E5C1; --x-tx-1F3242: #CFDCE6; --x-tx-5F778A: #99A9B6; --x-tx-9B2C2C: #DA8F8F; --x-tx-B23A2E: #D8877E; --x-tx-B4641E: #E3AD7E; --x-tx-B53A32: #D5827C; --x-tx-B7791F: #E2B87B; --x-tx-B83232: #D47A7A; --x-tx-C46A12: #EBAE73;
}
:root[data-theme="dark"] .brand img, :root[data-theme="dark"] .login-card img { background: #fff; border-radius: 16px; padding: 4px; }
:root[data-theme="dark"] .login-card { border: 1px solid var(--line); }
:root[data-theme="dark"] img:not(.brand img):not(.login-card img) { opacity: .92; }
.theme-btn { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; box-shadow: none; }
.theme-btn:hover { background: var(--row-hover); color: var(--ink); box-shadow: none; }
.theme-btn .icon { width: 18px; height: 18px; }
.theme-btn .t-sun { display: none; }
:root[data-theme="dark"] .theme-btn .t-sun { display: inline; }
:root[data-theme="dark"] .theme-btn .t-moon { display: none; }

/* ===== Современный вид плиток и таблиц ===== */
:root { --radius: 14px; }
.card { border-color: var(--line); box-shadow: var(--shadow-sm); }
.card h3 { letter-spacing: -.005em; }
/* плитки-показатели: крупное число, тонкая подпись, акцент сверху при наведении */
.count, .kpi { position: relative; overflow: hidden; padding: 16px 18px 14px; border-radius: var(--radius);
  background: linear-gradient(180deg, var(--tile-hi), transparent 46px) var(--card); }
.count::before, .kpi::before { content: ''; position: absolute; left: 0; top: 0; right: 0; height: 3px; background: var(--teal); opacity: .55; }
.count.alert::before, .kpi.alert::before { background: var(--red); }
.kpi.ok::before { background: var(--green); }
.count b, .kpi .v { font-size: 27px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-bottom: 2px; }
a.count:hover, a.kpi:hover { border-color: var(--teal); transform: translateY(-2px); }
a.count:hover::before, a.kpi:hover::before { opacity: 1; }
.ov-tiles a, .kp-tile { border: 1px solid var(--line); border-radius: 10px; transition: border-color .15s, transform .15s, box-shadow .15s; }
.ov-tiles a { background: var(--card); }
.ov-tiles a:hover { border-color: var(--teal); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
/* таблицы: лёгкая шапка, воздух в строках, ровные цифры, мягкое выделение строки */
th, td { padding: 7px 10px; border-bottom-color: var(--line-soft); }
th { background: var(--thead); color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .01em; border-bottom: 1px solid var(--line); }
td { font-variant-numeric: tabular-nums; }
tbody tr { transition: background .1s; }
tbody tr:hover td, table tr:hover td { background: var(--row-hover); }
tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--teal); }
.dt-mini th, .dt-mini td { padding: 6px 10px; }

/* ===== Шапка справа: шрифт, тема, пользователь (меню: сменить пароль, выйти) ===== */
.tb-right { display: flex; align-items: center; gap: 10px; }
.topbar .zoom-ctl { padding: 0; color: var(--muted); gap: 4px; border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.topbar .zoom-btn { background: transparent; color: var(--muted); border: 0; border-radius: 8px; padding: 4px 8px; box-shadow: none; }
.topbar .zoom-btn:hover { background: var(--row-hover); color: var(--ink); }
.topbar .zoom-val { color: var(--ink); min-width: 38px; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 12px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover, .user-menu[open] summary { background: var(--row-hover); }
.um-ava { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--teal); color: #fff; font-weight: 700; font-size: 13px; flex: none; }
.um-who { font-size: 13px; font-weight: 600; line-height: 1.2; color: var(--ink); white-space: nowrap; }
.um-who small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; }
.um-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 200px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-md); padding: 6px; }
.um-pop a, .um-pop button.link { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: 8px; color: var(--ink); font-weight: 500; text-align: left; }
.um-pop a:hover, .um-pop button.link:hover { background: var(--row-hover); text-decoration: none; }
.um-pop form { margin: 0; }
@media (max-width: 900px) { .um-who { display: none; } }
.login-wrap { position: relative; }
.login-theme { position: absolute; top: 16px; right: 16px; color: #C9E1E8; border-color: rgba(255, 255, 255, .2); }
.login-theme:hover { background: rgba(255, 255, 255, .1); color: #fff; }

/* ===== Светлая тема в стиле iOS: серый фон, белые карточки без рамок, системные цвета Apple ===== */
:root:not([data-theme="dark"]) {
  --bg: #F2F2F7; --card: #FFFFFF; --ink: #1C1C1E; --muted: #8A8A8E; --faint: #AEAEB2;
  --line: #E5E5EA; --line-soft: #EFEFF4;
  --teal: #007AFF; --teal-dark: #007AFF; --teal-ink: #0A58CA; --teal-soft: #E8F1FF;
  --primary: #007AFF; --primary-hover: #0062D1; --ring: rgba(0, 122, 255, .22);
  --red: #FF3B30; --red-bg: #FFECEB; --red-ink: #C4241A;
  --amber: #FF9500; --amber-bg: #FFF4E5; --amber-ink: #B36200;
  --green: #34C759; --green-bg: #E8F8EC; --green-ink: #1E8E3E;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04), 0 2px 8px rgba(0, 0, 0, .04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .08), 0 2px 6px rgba(0, 0, 0, .04);
  --radius: 18px; --thead: #FFFFFF; --row-hover: #F2F2F7; --tile-hi: transparent;
  --navy-3: #8E8E93;
  --x-bg-E9F1F5: #F2F2F7; --x-bg-EEF3F7: #F2F2F7; --x-bg-F1F6F9: #F7F7FA; --x-bg-DDEAF0: #EAEAEF;
  --x-tx-1F3242: #1C1C1E; --x-bd-B9CBD6: #D1D1D6;
  --x-bg-F2FBFC: #F2F7FF; --x-bg-F3FAFB: #F2F2F7; --x-bg-F6F9FB: #F7F7FA; --x-bg-F7FAFC: #F7F7FA;
  --x-bg-E9EEF2: #EFEFF4; --x-bg-E8EEF3: #EFEFF4; --x-bg-DCE5EC: #E5E5EA; --x-bg-C9D4DC: #E5E5EA;
}
html:not([data-theme="dark"]) body { font-family: -apple-system, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif; }
/* меню слева — светлое, как боковая панель iPad */
html:not([data-theme="dark"]) .sidebar { background: rgba(249, 249, 251, .92); color: var(--ink); border-right: 1px solid var(--line); }
html:not([data-theme="dark"]) .brand { color: var(--ink); }
html:not([data-theme="dark"]) .brand img { box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
html:not([data-theme="dark"]) .brand small, html:not([data-theme="dark"]) .nav-title { color: var(--muted); }
html:not([data-theme="dark"]) .nav a { color: var(--ink); border-radius: 10px; }
html:not([data-theme="dark"]) .nav a .icon { color: #007AFF; }
html:not([data-theme="dark"]) .nav a:hover { background: rgba(0, 0, 0, .045); color: var(--ink); }
html:not([data-theme="dark"]) .nav a:hover .icon { color: #007AFF; }
html:not([data-theme="dark"]) .nav a.on { background: #007AFF; color: #fff; box-shadow: none; }
html:not([data-theme="dark"]) .nav a.on .icon { color: #fff; }
html:not([data-theme="dark"]) .nav .badge { background: #FF3B30; color: #fff; }
html:not([data-theme="dark"]) .sidebar::-webkit-scrollbar-thumb { background: #C7C7CC; }
/* шапка — полупрозрачная, с размытием */
html:not([data-theme="dark"]) .topbar { background: rgba(255, 255, 255, .78); backdrop-filter: saturate(180%) blur(20px); position: sticky; top: 0; z-index: 30;
  border-bottom: 1px solid rgba(60, 60, 67, .12); box-shadow: none; }
html:not([data-theme="dark"]) .topbar .zoom-ctl, html:not([data-theme="dark"]) .theme-btn, html:not([data-theme="dark"]) .user-menu summary { border-color: transparent; background: #EFEFF4; }
html:not([data-theme="dark"]) .user-menu summary:hover, html:not([data-theme="dark"]) .theme-btn:hover { background: #E5E5EA; }
html:not([data-theme="dark"]) .um-ava { background: linear-gradient(180deg, #5AC8FA, #007AFF); }
/* карточки и плитки — белые, без рамок, мягкая тень */
html:not([data-theme="dark"]) .card, html:not([data-theme="dark"]) .count, html:not([data-theme="dark"]) .kpi,
html:not([data-theme="dark"]) table, html:not([data-theme="dark"]) .upq, html:not([data-theme="dark"]) .slot { border-color: transparent; }
html:not([data-theme="dark"]) .count, html:not([data-theme="dark"]) .kpi { background: var(--card); }
html:not([data-theme="dark"]) .count::before, html:not([data-theme="dark"]) .kpi::before { display: none; }
html:not([data-theme="dark"]) .count b, html:not([data-theme="dark"]) .kpi .v { font-weight: 700; letter-spacing: -.025em; }
html:not([data-theme="dark"]) a.count:hover, html:not([data-theme="dark"]) a.kpi:hover { border-color: transparent; box-shadow: var(--shadow-md); }
html:not([data-theme="dark"]) .count.on { box-shadow: inset 0 0 0 2px #007AFF; }
html:not([data-theme="dark"]) .ov-tiles a, html:not([data-theme="dark"]) .kp-tile { border-color: transparent; background: #F2F2F7; }
html:not([data-theme="dark"]) .ov-tiles a:hover { background: #E8F1FF; box-shadow: none; }
/* таблицы — как списки iOS: серые заголовки, тонкие разделители */
html:not([data-theme="dark"]) th { color: var(--muted); font-weight: 500; border-bottom-color: var(--line); }
html:not([data-theme="dark"]) tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 #007AFF; }
html:not([data-theme="dark"]) tfoot td, html:not([data-theme="dark"]) tr.is-total td { background: #F7F7FA; color: var(--ink); }
html:not([data-theme="dark"]) tfoot tr:first-child td, html:not([data-theme="dark"]) tr.is-total td { border-top: 1px solid #D1D1D6; }
/* кнопки, поля, вкладки, переключатели */
html:not([data-theme="dark"]) button, html:not([data-theme="dark"]) .btn { border-radius: 12px; box-shadow: none; }
html:not([data-theme="dark"]) button:hover, html:not([data-theme="dark"]) .btn:hover { box-shadow: none; }
html:not([data-theme="dark"]) .btn-secondary { background: #EFEFF4; border-color: transparent; color: #007AFF; }
html:not([data-theme="dark"]) .btn-secondary:hover { background: #E5E5EA; border-color: transparent; }
html:not([data-theme="dark"]) select, html:not([data-theme="dark"]) input:not([type=checkbox]):not([type=file]):not([type=radio]), html:not([data-theme="dark"]) textarea {
  background: #F2F2F7; border-color: transparent; border-radius: 10px; }
html:not([data-theme="dark"]) .card select, html:not([data-theme="dark"]) .card input:not([type=checkbox]):not([type=file]):not([type=radio]) { background: #F2F2F7; }
html:not([data-theme="dark"]) select:focus, html:not([data-theme="dark"]) input:focus, html:not([data-theme="dark"]) textarea:focus { background: #fff; border-color: #007AFF; }
html:not([data-theme="dark"]) .switch input:checked + span, html:not([data-theme="dark"]) .measure-switch > button, html:not([data-theme="dark"]) .measure-switch > a { background: #34C759; }
html:not([data-theme="dark"]) .measure-switch [aria-checked="true"] { background: #8E8E93; }
html:not([data-theme="dark"]) .switch span::before, html:not([data-theme="dark"]) .measure-switch i { box-shadow: 0 2px 4px rgba(0, 0, 0, .2); }
html:not([data-theme="dark"]) .sc-tabs a { border-color: transparent; background: #E5E5EA; border-radius: 9px; }
html:not([data-theme="dark"]) .kp-level, html:not([data-theme="dark"]) .upload-mode { background: #E5E5EA; border-color: transparent; padding: 2px; border-radius: 10px; }
html:not([data-theme="dark"]) .kp-level a.on, html:not([data-theme="dark"]) .upload-mode button.on { background: #fff; color: var(--ink); border-radius: 8px; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
html:not([data-theme="dark"]) .upload-mode button { background: transparent; }
html:not([data-theme="dark"]) .chip { font-weight: 600; }
html:not([data-theme="dark"]) .dropzone { border-color: #007AFF; background: #F2F7FF; }
html:not([data-theme="dark"]) .login-wrap { background: radial-gradient(900px 500px at 20% 10%, #DCEBFF 0%, transparent 60%), #F2F2F7; }
html:not([data-theme="dark"]) .login-card { box-shadow: 0 20px 50px rgba(0, 0, 0, .08); }
html:not([data-theme="dark"]) .login-theme { color: var(--muted); border-color: transparent; background: #E5E5EA; }
html:not([data-theme="dark"]) .sc-tabs a.on { background: #007AFF; color: #fff; }

/* ===== Светлая тема: сдержанные цвета, полоски сверху у плиток, карточки «над фоном» ===== */
:root:not([data-theme="dark"]) {
  --bg: #EEEFF3; --ink: #1D1D1F; --muted: #68686D;   /* серый текст читается: контраст ≥ 4,5 на фоне и карточке */
  --teal: #3B74D9; --teal-dark: #2F66C6; --teal-ink: #24569F; --teal-soft: #EAF0FA;
  --primary: #3B74D9; --primary-hover: #2F62BC; --ring: rgba(59, 116, 217, .2);
  --red: #CF4B43; --red-bg: #F9ECEB; --red-ink: #A13A33;
  --amber: #D08A2E; --amber-bg: #FAF2E6; --amber-ink: #8C5A14;
  --green: #3E9B6A; --green-bg: #E8F3ED; --green-ink: #2C7350;
  --shadow-sm: 0 0 0 .5px rgba(0, 0, 0, .04), 0 1px 2px rgba(0, 0, 0, .04), 0 4px 14px rgba(20, 30, 50, .06), 0 14px 36px -12px rgba(20, 30, 50, .10);
  --shadow-md: 0 0 0 .5px rgba(0, 0, 0, .05), 0 2px 4px rgba(0, 0, 0, .05), 0 10px 28px rgba(20, 30, 50, .10), 0 24px 48px -16px rgba(20, 30, 50, .16);
}
html:not([data-theme="dark"]) .nav a .icon, html:not([data-theme="dark"]) .nav a:hover .icon { color: #5E7290; }
html:not([data-theme="dark"]) .nav a.on { background: #E3EBF8; color: #24569F; font-weight: 600; }
html:not([data-theme="dark"]) .nav a.on .icon { color: #3B74D9; }
html:not([data-theme="dark"]) .um-ava { background: linear-gradient(180deg, #6E9BE6, #3B74D9); }
/* плитки: тонкая цветная полоска сверху, лёгкий отсвет, тень — будто над фоном */
html:not([data-theme="dark"]) .count, html:not([data-theme="dark"]) .kpi {
  background: linear-gradient(180deg, rgba(59, 116, 217, .05), transparent 52px) var(--card); }
html:not([data-theme="dark"]) .count::before, html:not([data-theme="dark"]) .kpi::before { display: block; height: 3px; opacity: .75;
  background: linear-gradient(90deg, #3B74D9, #6E9BE6); }
html:not([data-theme="dark"]) .count.alert::before, html:not([data-theme="dark"]) .kpi.alert::before { background: linear-gradient(90deg, #CF4B43, #E2847D); }
html:not([data-theme="dark"]) .kpi.ok::before { background: linear-gradient(90deg, #3E9B6A, #7BC29C); }
html:not([data-theme="dark"]) .count.alert, html:not([data-theme="dark"]) .kpi.alert { background: linear-gradient(180deg, rgba(207, 75, 67, .05), transparent 52px) var(--card); }
html:not([data-theme="dark"]) .card, html:not([data-theme="dark"]) .count, html:not([data-theme="dark"]) .kpi { box-shadow: var(--shadow-sm); transition: box-shadow .2s, transform .2s; }
html:not([data-theme="dark"]) a.count:hover, html:not([data-theme="dark"]) a.kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
/* полосы и бары — приглушённые тона */
html:not([data-theme="dark"]) .ov-bar i.lv-mid, html:not([data-theme="dark"]) .dt-pct.lv-mid, html:not([data-theme="dark"]) .dt-score.lv-mid { background: #D9963F; }
html:not([data-theme="dark"]) .ov-bar i.lv-low, html:not([data-theme="dark"]) .dt-pct.lv-low, html:not([data-theme="dark"]) .dt-score.lv-low { background: #D6766C; }
html:not([data-theme="dark"]) .ov-bar i.lv-bad, html:not([data-theme="dark"]) .dt-pct.lv-bad, html:not([data-theme="dark"]) .dt-score.lv-bad { background: #A9505E; }
html:not([data-theme="dark"]) .ov-bar i.blue { background: #5B8BDB; }
html:not([data-theme="dark"]) .fin-bar .lo, html:not([data-theme="dark"]) .ov-scale .ov-base.lv-lo { background: #DDA457; }
html:not([data-theme="dark"]) .ov-scale .ov-base, html:not([data-theme="dark"]) .ov-scale .ov-tail { background: #4FA77A; }
html:not([data-theme="dark"]) .switch input:checked + span, html:not([data-theme="dark"]) .measure-switch > button, html:not([data-theme="dark"]) .measure-switch > a { background: #4BA877; }

/* ===== Анимации в стиле Apple (motion.js); при «Уменьшить движение» в системе выключены ===== */
:root { --ease: cubic-bezier(.22, 1, .36, 1); --spring: cubic-bezier(.34, 1.4, .64, 1); }
@keyframes mo-rise { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes mo-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes mo-growy { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes mo-pop { from { opacity: 0; transform: translateY(-6px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes mo-fade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.mo-on main .mo-in { animation: mo-rise .6s var(--ease) both; }
.mo-on main .mo-grow { transform-origin: left center; animation: mo-grow .9s var(--ease) both; }
.mo-on main .ov-colbar.mo-grow { transform-origin: center bottom; animation-name: mo-growy; }
.um-pop { transform-origin: top right; animation: mo-pop .22s var(--spring); }
.msel-pop, .cols-menu, .howto-body { animation: mo-pop .2s var(--ease); transform-origin: top left; }
details.kp-sec[open] > :not(summary), details.card[open] > :not(summary) { animation: mo-fade .32s var(--ease); }
/* нажатие — кнопка чуть «вдавливается», как в iOS */
button, .btn, .count, .kpi, .nav a, .theme-btn, .user-menu summary { transition: transform .18s var(--ease), background .2s, color .2s, box-shadow .25s var(--ease), border-color .2s; }
button:active, .btn:active, .theme-btn:active, .user-menu summary:active { transform: scale(.96); }
a.count:active, a.kpi:active { transform: scale(.985); }
.nav a:active { transform: scale(.98); }
.theme-btn .icon { transition: transform .5s var(--spring); }
.theme-btn:hover .icon { transform: rotate(-20deg); }
:root[data-theme="dark"] .theme-btn:hover .icon { transform: rotate(45deg); }
/* смена темы — цвета перетекают */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .5s; animation-timing-function: cubic-bezier(.4, 0, .2, 1); }
@media (prefers-reduced-motion: reduce) {
  .mo-on main .mo-in, .mo-on main .mo-grow, .um-pop, .msel-pop, .cols-menu, .howto-body, details[open] > :not(summary) { animation: none; }
  button:active, .btn:active { transform: none; }
}

/* ===== Шрифт Inter: современный, ровные цифры в таблицах ===== */
html body, html:not([data-theme="dark"]) body { font-family: 'Inter', "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-feature-settings: 'cv11', 'ss03', 'calt'; letter-spacing: -.006em; }
button, .btn, select, input, textarea { font-family: inherit; font-feature-settings: inherit; }
h1 { font-weight: 700; letter-spacing: -.022em; }
h2, h3, .card h3 { font-weight: 600; letter-spacing: -.014em; }
/* цифры одной ширины — столбцы чисел стоят ровно */
td, th, .count b, .kpi .v, .num, .r, .dt-pct, .dt-score, .ov-bar + *, .barrow .num, .zoom-val { font-variant-numeric: tabular-nums; }
.count b, .kpi .v { font-weight: 700; letter-spacing: -.03em; }
th { font-weight: 500; letter-spacing: 0; }
.muted, small { letter-spacing: 0; }
.chip { font-weight: 600; letter-spacing: 0; }
.nav a { letter-spacing: -.004em; }

/* ===== Липкая шапка страницы и шапки таблиц под ней (sticky.js задаёт --st) ===== */
.topbar { position: sticky; top: 0; z-index: 30; }
main table thead th, main table > tbody > tr:first-child > th, table.defects th, th.has-grip { top: var(--st, 0px); }
.dt-wrap { overflow: visible; }   /* иначе шапка «По участкам» не едет; широкую таблицу hscroll.js обернёт в своё окно */
.dt-table thead th { background: var(--thead); }

/* ===== Ссылки: вместо подчёркивания — линия плавно вырастает слева направо ===== */
main a { text-decoration: none; background-image: linear-gradient(currentColor, currentColor); background-repeat: no-repeat;
  background-position: 0 100%; background-size: 0 1.5px; transition: background-size .35s var(--ease, ease), color .2s, transform .2s; }
main a:hover { text-decoration: none; background-size: 100% 1.5px; }
main a.btn, main a.count, main a.kpi, main .ov-tiles a, main .sc-tabs a, main .kp-level a, main .fin-tabs a, main a.barrow, main a.chip,
main .dt-pct, main .dt-score, main a.dt-plain, main .dp-tabs a { background-image: none; }
/* «пилюли» с процентами и метки — приподнимаются, как плитки */
main a.dt-pct, main a.dt-score, main a.chip { display: inline-block; transition: transform .2s var(--ease, ease), box-shadow .2s; }
main a.dt-pct:hover, main a.dt-score:hover, main a.chip:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(20, 30, 50, .18); }
/* стрелка в ссылках «подробно →» чуть подаётся вперёд */
main a.arrow-link:hover, .ov-card-head a:hover { letter-spacing: .01em; }

/* ===== Спокойные таблицы: больше воздуха, без вертикальных линий, ссылки в ячейках — цветом текста ===== */
main td { padding-top: 9px; padding-bottom: 9px; }
table.defects th, table.defects td { border-right: 0; }
.col-grip::after, table.defects th .col-resize::after { opacity: 0; transition: opacity .2s; }
thead:hover .col-grip::after, thead:hover .col-resize::after { opacity: .5; }
main td a:not([class]) { color: var(--ink); font-weight: 500; }
main td a:not([class]):hover { color: var(--teal-dark); }
main td .muted, main td small { color: var(--faint); font-size: 12px; }
a.ref { border-bottom: 0; }
main td .chip { white-space: nowrap; }

/* ===== Страницы в формате главной: заголовок, плитки итогов, карточки ===== */
.page-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-top h1 { margin: 0; }
.page-top .grow { flex: 1; }
/* переключатель-сегменты, как в iOS */
.seg { display: inline-flex; background: var(--line-soft); border-radius: 10px; padding: 3px; gap: 2px; }
.seg a { padding: 6px 14px; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: 13px; background-image: none !important; transition: background .2s, color .2s, box-shadow .2s; }
.seg a:hover { color: var(--ink); }
.seg a.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
:root:not([data-theme="dark"]) .seg { background: #E3E4E9; }
/* фильтры — в своей карточке */
.filter-card { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 16px; }
.filter-card .filter-q { min-width: 240px; flex: 1; max-width: 360px; }
/* таблица-список в карточке: без своей рамки, карточка даёт фон и тень */
.list-card { padding: 6px 8px; }
.list-card .defects-wrap { max-height: calc(100vh / var(--z) - 150px); }
.list-card table { box-shadow: none; border: 0; border-radius: 0; }

/* Врачи */
.doc-table td { vertical-align: middle; }
.doc-name a { font-weight: 600; }
.doc-sub { font-size: 12px; color: var(--faint); margin-top: 2px; font-weight: 400; }
.doc-sub a { color: var(--muted) !important; font-weight: 400 !important; }
.doc-top { max-width: 300px; }
.doc-top span { display: inline-block; font-size: 12px; color: var(--muted); background: var(--line-soft); border-radius: 6px; padding: 1px 7px; margin: 1px 4px 1px 0; }
.doc-top b { color: var(--ink); font-weight: 600; }
.doc-table .dt-pct { min-width: 54px; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 30px; width: 120px; }
.spark i { flex: 1; min-height: 2px; border-radius: 3px 3px 1px 1px; background: var(--x-bd-B9CBD6, #C9D3DB); transition: transform .2s var(--ease, ease); transform-origin: bottom; }
.spark i.now { background: var(--teal); }
.spark i:hover { transform: scaleY(1.08); filter: brightness(.9); }
.mo-on main .spark i { animation: mo-growy .8s var(--ease) both; }

/* Освоение: плитки сверху, лоты + исполнители, ниже три карточки */
#fin-live .fin-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 0 0 16px; }
#fin-live .fin-kpis > div { position: relative; overflow: hidden; background: var(--card); border: 0; border-radius: var(--radius); padding: 16px 18px 14px; box-shadow: var(--shadow-sm); }
#fin-live .fin-kpis > div::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, var(--teal), transparent 140%); opacity: .7; }
#fin-live .fin-kpis span { font-size: 12.5px; }
#fin-live .fin-kpis b { display: block; font-size: 26px; font-weight: 700; letter-spacing: -.03em; margin-top: 2px; }
#fin-live .fin-kpis b span { font-size: inherit; color: inherit; }
#fin-live .fin-kpis .ok, #fin-live .fin-kpis b .ok { color: var(--green); } #fin-live .fin-kpis b .alert { color: var(--red); }
#fin-live .fin-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
#fin-live .fin-box { border: 0; border-radius: var(--radius); box-shadow: var(--shadow-sm); background: var(--card); }
#fin-live .fin-tall, #fin-live .fin-people .fin-scroll { max-height: calc(100vh / var(--z) - 300px); }
#fin-live .fin-people { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
#fin-live .fin-people .fin-scroll { flex: 1; overflow: auto; }
#fin-live .fin-row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: auto; gap: 16px; margin-top: 16px; }
#fin-live .fin-row3 > .fin-box { max-height: 420px; overflow: auto; }
@media (max-width: 1100px) { #fin-live .fin-grid, #fin-live .fin-row3 { grid-template-columns: minmax(0, 1fr); } #fin-live .fin-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
#fin-live table.fin th, #fin-live table.fin td { padding: 7px 10px; font-size: 13px; }
#fin-live table.fin thead th { background: var(--card); color: var(--muted); font-weight: 500; }
#fin-live table.fin tfoot td { background: var(--line-soft); }
#fin-live .fin-tabs { background: transparent; padding: 6px 8px 0; gap: 4px; }
#fin-live .fin-tabs a { border-radius: 8px 8px 0 0; padding: 7px 12px; font-size: 13px; background-image: none; }
#fin-live .fin-bar-top { margin-bottom: 16px; }
.fin-head { margin-bottom: 14px; }
#fin-live .fin-kpis > div > span span { display: inline; }
#fin-live .fin-table .fin-lot td:first-child { padding-left: 22px; }
#fin-live .fin-table .fin-side td:first-child { padding-left: 40px; }
#fin-live .fin-table .fin-side td { color: var(--muted); font-size: 12.5px; }

/* ===== Узкие строки во всех таблицах: шрифт чуть меньше, длинный текст — максимум в 2 строки (полностью — в подсказке) ===== */
main th, main td { font-size: 12.5px; line-height: 1.38; }
main th { font-size: 11.5px; }
main td { padding-top: 7px; padding-bottom: 7px; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
table.defects .svc { min-width: 200px; max-width: 280px; }
table.defects .reason { min-width: 160px; max-width: 220px; }
table.defects .dx-cell { max-width: 220px; }
table.defects .details { min-width: 360px; }
table.defects td.who { white-space: nowrap; }
table.defects td.code-cell { white-space: nowrap; font-family: Consolas, monospace; font-size: 12px; }
table.defects td.code-cell a { color: var(--muted); font-weight: 400; }
table.defects .copy-id { font-size: 12px; }
/* ФИО в таблицах — одной строкой, полное — при наведении */
main td a[href*="/person/"], main td .patient-link { white-space: nowrap; }
/* Главная: две колонки-стопки — без пустот под короткой колонкой */
.ov-main { align-items: start; }
.ov-stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ov-stack > .card { margin-bottom: 0; }

/* ===== Фоновые загрузки: компактный уголок справа снизу, штрих на каждый файл (updock.js) ===== */
.updock { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  animation: mo-pop .25s var(--ease, ease); }
.updock[hidden] { display: none; }
.updock-pill { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 12px; border-radius: 17px; border: 0;
  background: var(--card); color: var(--ink); font-size: 12.5px; font-weight: 500; cursor: pointer;
  box-shadow: 0 6px 20px rgba(16, 35, 58, .16), 0 1px 3px rgba(16, 35, 58, .1); font-variant-numeric: tabular-nums; }
.updock-dash { display: flex; gap: 3px; width: 140px; }
.updock-dash i { flex: 1; min-width: 2px; height: 5px; border-radius: 3px; background: var(--line-soft); overflow: hidden; position: relative; }
:root:not([data-theme="dark"]) .updock-dash i { background: #E1E3E8; }
.updock-dash i b { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 3px; background: var(--teal);
  transition: width .3s linear, background .3s; }
.updock-dash i.send b, .updock-dash i.run b { background: var(--teal); }
.updock-dash i.ok b { background: var(--green); }
.updock-dash i.skip b { background: var(--faint); opacity: .55; }
.updock-dash i.bad b { background: var(--red); }
.updock-dash i.run { animation: updock-pulse 1.4s ease-in-out infinite; }
@keyframes updock-pulse { 50% { opacity: .65; } }
.updock-txt { white-space: nowrap; color: var(--muted); }
.updock.done .updock-txt { color: var(--green); }
.updock.has-bad .updock-txt { color: var(--red); }
.updock-x { margin-left: -2px; font-size: 16px; line-height: 1; color: var(--faint); padding: 2px 0 2px 4px; }
.updock-x:hover { color: var(--ink); }
.updock-x[hidden] { display: none; }
.updock-pop { width: 340px; max-height: min(60vh, 420px); display: flex; flex-direction: column; background: var(--card);
  border-radius: 14px; box-shadow: 0 12px 34px rgba(16, 35, 58, .2), 0 1px 3px rgba(16, 35, 58, .1); overflow: hidden;
  animation: mo-pop .2s var(--ease, ease); transform-origin: bottom right; }
.updock-pop[hidden] { display: none; }
.updock-head { padding: 10px 14px 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.updock-list { overflow: auto; padding: 0 6px; }
.updock-row { display: flex; gap: 9px; padding: 7px 8px; border-radius: 8px; }
.updock-row + .updock-row { border-top: 1px solid var(--line-soft); }
.updock-dot { flex: none; width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: var(--line); }
.updock-row.send .updock-dot, .updock-row.run .updock-dot { background: var(--teal); animation: updock-pulse 1.4s infinite; }
.updock-row.ok .updock-dot { background: var(--green); }
.updock-row.skip .updock-dot { background: var(--faint); }
.updock-row.bad .updock-dot { background: var(--red); }
.updock-body { min-width: 0; flex: 1; }
.updock-name { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.updock-note { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.updock-row.bad .updock-note { color: var(--red); }
.updock-link { margin-top: 5px; }
.updock-foot { padding: 8px 14px 10px; font-size: 11.5px; display: flex; justify-content: flex-end; }
.updock-foot .muted { margin-right: auto; }
@media (prefers-reduced-motion: reduce) { .updock, .updock-pop, .updock-dash i.run { animation: none; } }

/* Месяц и год — двумя короткими списками вместо длинного (ym.js) */
.ym { display: inline-flex; gap: 6px; align-items: center; }
.ym select[hidden] { display: none !important; }
.ym .ym-year { width: auto; min-width: 84px; }
.ym .ym-month { width: auto; min-width: 120px; }
/* Врачи: оказанные и направленные услуги */
.doc-month select { min-width: 150px; }
.doc-top span { max-width: 260px; display: inline-flex; gap: 4px; vertical-align: top; }
.clamp1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.kpi .doc-go { color: var(--teal-dark); }

/* Нагрузка по дням: ФИО и «Итого» закреплены слева, шапка едет за прокруткой в своём окне */
.an-wide { max-height: calc(100vh / var(--z, 1) - 150px); overflow: auto; overscroll-behavior: contain; }
table.an-load .who { width: 250px; min-width: 250px; max-width: 250px; }
table.an-load .tot { position: sticky; left: 250px; z-index: 1; background: var(--card); min-width: 78px;
  box-shadow: inset -1px 0 0 var(--line), 6px 0 8px -6px rgba(0, 0, 0, .25); }
table.an-load thead th { position: sticky; top: 0; z-index: 2; }
table.an-load thead th.who, table.an-load thead th.tot { z-index: 3; }
table.an-load thead th.tot { background: var(--x-bg-F7FAFC); }
table.an-load tfoot td { position: sticky; bottom: 0; z-index: 2; }
table.an-load tfoot td.who, table.an-load tfoot td.tot { z-index: 3; }
table.an-load tbody tr:hover td.who, table.an-load tbody tr:hover td.tot { background: var(--x-bg-F1F4F7); }

/* «Врачи»: мини-график услуг по месяцам с подписями месяцев */
.spark.spark-m { height: 44px; width: 168px; gap: 4px; }
.spark-m span { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 0; }
.spark-m span b { flex: 1; display: flex; align-items: flex-end; min-height: 0; }
.spark-m span i { display: block; width: 100%; }
.spark-m small { font-size: 9.5px; line-height: 12px; color: var(--faint); text-align: center; margin-top: 2px; }
.spark-m span:last-child small { color: var(--teal-dark); font-weight: 600; }

/* Окна с прокруткой у больших таблиц: браузер пересчитывает и перерисовывает только само окно,
   а не всю страницу — прокрутка без рывков даже при тысячах строк */
.an-scroll, .an-wide, .tbl-x, .defects-wrap, .fin-scroll, .fin-tall { contain: layout paint; }

/* Нагрузка: промежуток дат */
.ld-range { display: inline-flex; align-items: center; gap: 6px; position: relative; }
.ld-range > span { display: inline-flex; align-items: center; gap: 6px; }
details.ld-range > span { position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; background: var(--card); padding: 10px 12px;
  border-radius: 12px; box-shadow: 0 10px 30px rgba(16, 35, 58, .18); white-space: nowrap; }
.ld-range input[type=date] { width: 140px; }

/* ===== Название и шапка таблицы под верхней полосой (heads.js) ===== */
.fhead { position: sticky; top: 0; z-index: 20; height: 0; overflow: visible; pointer-events: none; width: 0; min-width: 100%; }
.fhead-in { pointer-events: auto; }
/* Копия выглядит как верх самой карточки: те же края и скругления. За углами — цвет страницы, строки там не видны */
.fhead-in { display: none; position: relative; box-sizing: border-box; background: var(--card); border: 0 solid var(--line); border-bottom: 0; }
/* Верх спущенной копии — как верх настоящей карточки: под ней (z-index: -1) фон страницы закрывает уходящие строки
   и боковую тень карточки над скруглением (иначе по бокам видны две полоски до верхней полосы), а поверх фона —
   своя тень карточки, только у верхнего края и скруглённых углов */
.fhead-in::after { content: ''; position: absolute; z-index: -1; pointer-events: none; top: calc(-1 * var(--fh-b, 0px));
  left: calc(-1 * var(--fh-b, 0px)); right: calc(-1 * var(--fh-b, 0px)); height: calc(2 * var(--fh-r, 12px));
  border-radius: var(--fh-r, 12px) var(--fh-r, 12px) 0 0; box-shadow: var(--fh-shadow, none);
  clip-path: inset(calc(-1 * var(--fh-x, 0px)) calc(-1 * var(--fh-x, 0px)) calc(100% - var(--fh-r, 12px)) calc(-1 * var(--fh-x, 0px))); }
.fhead.fhead-fix { position: fixed; min-width: 0; }
.fhead.on .fhead-in { display: block; }
.fhead-flush th::before { display: none; }
.fhead-x { overflow: hidden; }
.fhead-table { margin: 0 !important; border: 0; border-radius: 0; box-shadow: none; background: none; min-width: 0; max-width: none; table-layout: fixed; }
.fhead-table th { cursor: pointer; }
.sc-list-head .list-filters { max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Сдержанный «светофор»: без плашки, цветное жирное число (проценты, рейтинг, баллы) ===== */
main .dt-pct, main .dt-score { background: none !important; color: var(--soft-mid); font-weight: 700; padding: 0; min-width: 0; border-radius: 0; box-shadow: none; }
main .dt-pct.lv-good, main .dt-score.lv-good { color: var(--soft-good); } main .dt-pct.lv-mid, main .dt-score.lv-mid { color: var(--soft-mid); }
main .dt-pct.lv-low, main .dt-score.lv-low { color: var(--soft-low); } main .dt-pct.lv-bad, main .dt-score.lv-bad { color: var(--soft-bad); }
main a.dt-pct:hover, main a.dt-score:hover { box-shadow: none; filter: none; }
:root { --soft-good: #1B7F52; --soft-mid: #B86E12; --soft-low: #CC4F3F; --soft-bad: #9B1C31; }
html[data-theme="dark"] { --soft-good: #5CCB95; --soft-mid: #F0A64A; --soft-low: #F2857A; --soft-bad: #FF6B7F; }

/* ===== Ссылки в таблицах — плавно приподнимаются при наведении, как плитки и проценты ===== */
main td a:not(.btn) { display: inline-block; max-width: 100%; background-image: none;
  transition: transform .2s var(--ease, ease), color .2s; }
main td a:not(.btn):hover { transform: translateY(-2px); }

/* ===== «Загрузить» в шапке ===== */
.tb-upload { margin: 0; }
.tb-up-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 10px; cursor: pointer;
  background: var(--teal); color: #fff; font-weight: 600; font-size: 13.5px; transition: transform .2s var(--ease, ease), box-shadow .2s, filter .2s; }
.tb-up-btn svg { width: 16px; height: 16px; }
.tb-up-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26, 151, 166, .35); }
.tb-up-btn.over { filter: brightness(1.1); box-shadow: 0 0 0 3px rgba(26, 151, 166, .35); }
.updock-txt { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Иконка пациента в больших списках — одна на всю страницу (маска), а не SVG в каждой строке */
.ico-pat { display: inline-block; width: 14px; height: 14px; flex: none; background: var(--teal-dark);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='7.5' r='3.5'/%3E%3Cpath d='M5 21c.7-4 3.6-6.5 7-6.5s6.3 2.5 7 6.5'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='7.5' r='3.5'/%3E%3Cpath d='M5 21c.7-4 3.6-6.5 7-6.5s6.3 2.5 7 6.5'/%3E%3C/svg%3E") center / contain no-repeat; }

/* ===== Прогресс загрузок — в шапке, рядом с «Загрузить»; список выпадает вниз ===== */
.tb-dock-slot { display: contents; }
.updock.in-bar { position: relative; right: auto; bottom: auto; z-index: 40; flex-direction: row; }
.updock.in-bar .updock-pill { box-shadow: none; border: 1px solid var(--line); height: 34px; border-radius: 10px; }
.updock.in-bar .updock-pop { position: absolute; top: calc(100% + 8px); right: 0; transform-origin: top right; }

/* ===== «Нагрузка»: окошко с услугами за числом (loadcell.js) ===== */
table.an-load[data-cell-url] tbody td:not(.who), table.an-load[data-cell-url] tfoot td:not(.who) { cursor: pointer; }
table.an-load td.lc-on { box-shadow: inset 0 0 0 2px var(--teal); border-radius: 4px; }
.lc-pop { position: fixed; z-index: 70; width: 520px; max-width: calc(100vw / var(--z, 1) - 24px); max-height: 60vh; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 14px 40px rgba(16, 35, 58, .25);
  animation: mo-pop .18s var(--ease, ease); }
.lc-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 8px 14px; border-bottom: 1px solid var(--line-soft); }
.lc-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.lc-x { border: 0; background: none; font-size: 20px; line-height: 1; color: var(--faint); cursor: pointer; padding: 0 4px; }
.lc-x:hover { color: var(--ink); }
.lc-body { overflow: auto; padding: 0 6px 8px; font-size: 12.5px; }
.lc-body.muted { padding: 14px; }
.lc-table { width: 100%; border: 0; box-shadow: none; border-radius: 0; border-collapse: collapse; }
.lc-table th { position: sticky; top: 0; z-index: 2; background: var(--card); box-shadow: 0 1px 0 var(--line); color: var(--muted); font-weight: 600; font-size: 11.5px; padding: 6px 8px; text-align: left; }
.lc-table th.r, .lc-table td.r { text-align: right; white-space: nowrap; }
.lc-table td { padding: 5px 8px !important; border-top: 1px solid var(--line-soft); }
.lc-table .lc-name { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-table tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--card); font-weight: 600; border-top: 1px solid var(--line); }

/* ===================================================================================================
   МОБИЛЬНАЯ ВЕРСИЯ (телефон до 760 px: iPhone 390–440 px). Меню слева — выезжающая панель (☰),
   внизу — быстрые разделы, всё в одну колонку, широкие таблицы листаются вбок в своём окне,
   всплывающие списки — снизу экрана. «Полная версия» в меню пользователя отключает всё это.
   =================================================================================================== */
.m-burger, .mnav, .m-backdrop { display: none; }
@media (max-width: 760px) {
  :root { --z: 1; }
  html.m-locked { overflow: hidden; }
  .sidebar { overscroll-behavior: contain; }
  body { -webkit-text-size-adjust: 100%; }

  /* каркас: одна колонка, меню — панель слева */
  .layout { display: block; min-height: 100dvh; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 90; width: min(84vw, 300px); height: 100dvh;
    padding: calc(14px + env(safe-area-inset-top)) 12px calc(14px + env(safe-area-inset-bottom));
    transform: translateX(-104%); transition: transform .28s var(--ease, ease); box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  .sidebar.open { transform: none; }
  .nav a { padding: 12px 12px; font-size: 15px; }
  .m-backdrop { display: block; position: fixed; inset: 0; z-index: 85; background: rgba(8, 18, 30, .45); backdrop-filter: blur(2px);
    animation: mo-fade .2s ease; }
  .m-backdrop[hidden] { display: none; }

  /* шапка: ☰, МО, загрузка, тема, пользователь */
  .topbar { position: sticky; top: 0; z-index: 30; flex-wrap: nowrap; gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px; }
  .m-burger { display: inline-flex; flex-direction: column; justify-content: center; gap: 4px; width: 38px; height: 38px; flex: none;
    padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); box-shadow: none; }
  .m-burger i { display: block; align-self: stretch; width: 100%; height: 2px; border-radius: 1px; background: var(--ink); }
  .topbar .where { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
  .tb-title h1 { font-size: 15px; }
  .tb-title .howto { display: none; }
  .topbar select { max-width: 130px; font-size: 14px; }
  .topbar .spacer { flex: 1; min-width: 4px; }
  .tb-right { gap: 6px; }
  .topbar .zoom-ctl { display: none; }
  .tb-up-btn { padding: 0 10px; height: 38px; }
  .tb-up-btn span { display: none; }
  .theme-btn { width: 38px; height: 38px; }
  .user-menu summary { padding: 3px; border-radius: 50%; }
  .um-who { display: none; }
  .updock.in-bar .updock-dash { width: 44px; }
  .updock.in-bar .updock-txt, .updock.in-bar .updock-x { display: none; }
  .updock.in-bar .updock-pill { padding: 0 10px; height: 38px; }
  .updock.in-bar .updock-pop { position: fixed; top: calc(60px + env(safe-area-inset-top)); left: 8px; right: 8px; width: auto; max-height: 70dvh; }
  .um-pop { min-width: 230px; }

  /* содержимое */
  .content, .content:has(.sc-list), .content:has(.sc-tabs), .content:has(#fin-live), .content:has(#plan-form), .content:has(#defects) {
    max-width: none; padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); }
  h1 { font-size: 20px; }
  h2 { font-size: 17px; }
  h3 { font-size: 15.5px; }
  .card { padding: 14px; border-radius: 14px; margin-bottom: 12px; }
  .page-top, .fin-head, .toolbar, .sc-list-head, .card-top { flex-wrap: wrap; gap: 8px; }
  .page-top .grow, .fin-head .grow { flex-basis: 100%; height: 0; }
  .fin-head .adm-inline { max-width: 100%; }
  .adm-inline select { min-width: 0; max-width: 100%; }   /* длинное название версии не шире экрана телефона */

  /* плитки — по две в ряд */
  .counts, .kpis, .fin-kpis, #fin-live .fin-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px; }
  .kpi, .count { padding: 12px; min-width: 0; }
  .kpi .v, .count > b { font-size: 21px; }
  .kpi .s { font-size: 11.5px; }

  /* все сетки — в одну колонку */
  .grid, .cols-2, .cols-3, .fin-grid, .fin-parts, .an-top, .an-three, .an-two, .card-sum, .cx-grid, .pc-head, .pd-top,
  .dt-cardgrid, .dt-secs, .pc-sums, .adm-cols, .kp-search, .kp-grid, .slots, .slots.slots-2, .slots.slots-3, .an-filter-grid,
  .dt-inds, .rpn-grid, .upq-list, #fin-live .fin-grid, #fin-live .fin-row3, .slot-groups {
    grid-template-columns: minmax(0, 1fr) !important; }
  .fin-parts { grid-auto-rows: auto !important; }
  .slot-group.span-2 { grid-column: auto; }
  dl.props, .pd-top dl.props, dl.props-2 > div { grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); }
  dl.props-2 { columns: 1; }
  .dp-top { flex-direction: column; align-items: stretch; }
  .dp-top > * { max-width: 100%; }
  .dp-tabs, .sc-tabs, .fin-tabs, .seg { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; max-width: 100%; }
  .dp-tabs { flex-direction: row; }
  .sc-tabs a, .dp-tabs a, .seg a { white-space: nowrap; }

  /* фильтры: по две в ряд, поля во всю ширину; шрифт 16 px — iPhone не увеличивает страницу при вводе */
  input, select, textarea, button { font-size: 16px; }
  .toolbar > *, .an-filters > * { flex: 1 1 calc(50% - 8px); min-width: 0 !important; }
  .an-filters input[name=q], .toolbar input[name=q], .toolbar > h1 { flex-basis: 100%; }
  .an-filters > button, .an-filters > a { flex: 0 0 auto; }
  .msel, .msel-btn { width: 100%; }
  .msel-pop { position: fixed !important; left: 8px !important; right: 8px !important; top: auto !important;
    bottom: calc(8px + env(safe-area-inset-bottom)) !important; width: auto !important; max-height: 62dvh; z-index: 95;
    border-radius: 16px; box-shadow: 0 -10px 40px rgba(0, 0, 0, .3); }
  .msel-opt { padding: 10px 8px; }
  .ym { display: flex; gap: 6px; width: 100%; }
  .ym select { flex: 1; }

  /* таблицы: мельче, листаются вбок в своём окне; окна не выше экрана */
  main table { font-size: 12.5px; }
  main td, main th { padding-left: 8px; padding-right: 8px; }
  main td { padding-top: 7px; padding-bottom: 7px; }
  .an-scroll, .fin-scroll, .sc-scroll, .an-scroll.sc-scroll, .defects-wrap, .tbl-x { max-height: 72dvh; }
  .fin-tall { max-height: 72dvh; }
  table.an-load .who { min-width: 150px; max-width: 170px; }
  table.an-load .tot { left: 170px; }
  .sc-list-head .list-filters { max-width: 100%; flex-basis: 100%; order: 3; }
  .doc-table .doc-top { display: none; }
  .hscroll-bar { bottom: calc(62px + env(safe-area-inset-bottom)); }

  /* строки-полосы (лоты, виды дефектов): название — строкой выше */
  .barrow { flex-wrap: wrap; gap: 4px 10px; }
  .barrow .name { width: auto; flex: 1 1 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .barrow .track { min-width: 60px; }
  .content { overflow-x: clip; }   /* что-то шире экрана не раздвигает страницу (таблицы листаются в своих окнах) */

  /* всплывающие окна — снизу */
  .lc-pop { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: 100%; max-width: none; max-height: 72dvh;
    border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .lc-table .lc-name { max-width: 190px; }

  /* нижняя панель быстрых разделов */
  .mnav { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line);
    box-shadow: 0 -6px 20px rgba(16, 35, 58, .08); }
  .mnav a, .mnav button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 2px; border: 0; background: none;
    color: var(--muted); font-size: 10.5px; font-weight: 500; text-decoration: none; box-shadow: none; min-height: 46px; justify-content: center; }
  .mnav .icon { width: 22px; height: 22px; }
  .mnav a.on { color: var(--teal); font-weight: 650; }
  .mnav a:hover, .mnav button:hover { background: none; transform: none; }
  html[data-theme="dark"] .mnav { background: #0F2234; }

  /* вход */
  .login-wrap { padding: 16px; min-height: 100dvh; }
  .login-card { padding: 26px 20px; border-radius: 16px; }
}
.login-view { text-align: center; margin: 8px 0 0; }
.login-view .link { color: var(--muted); font-size: 13px; }

/* ===== Меню слева — пункт чуть приподнимается при наведении, как ссылки в таблицах ===== */
.nav a:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(16, 24, 40, .08); }
.nav a:active { transform: translateY(0) scale(.98); }

/* ===== Кадры: отделения ровно по левому краю, вложенность — отступом названия ===== */
.hr-grp > summary { padding-left: calc(var(--d, 0) * 20px); }
.hr-sub { margin-right: 6px; }

/* ===== Под шапкой таблицы: название и текущая группа (отдел) ===== */
.fhead-grp td { box-shadow: inset 0 -1px 0 var(--line); }

/* ===== Календарик промежутка дат ===== */
.rcal { position: relative; display: inline-flex; }
.rcal-btn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.rcal-btn.on { color: var(--teal-ink); border-color: var(--teal); background: var(--teal-soft); }
.rcal-pop { position: absolute; z-index: 40; top: calc(100% + 8px); left: 0; width: 292px; padding: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 18px 44px rgba(16, 24, 40, .16), 0 2px 6px rgba(16, 24, 40, .06);
  opacity: 0; transform: translateY(-6px) scale(.97); transform-origin: top left;
  transition: opacity .18s var(--ease, ease), transform .22s var(--ease, ease); }
.rcal-pop.on { opacity: 1; transform: none; }
.rcal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.rcal-title { font-size: 14px; }
.rcal-nav { width: 30px; height: 30px; border-radius: 50%; border: 0; background: none; color: var(--ink); font-size: 18px; line-height: 1; cursor: pointer; }
.rcal-nav:hover:not(:disabled) { background: var(--teal-soft); }
.rcal-nav:disabled { opacity: .25; cursor: default; }
.rcal-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 3px; }
.rcal-grid.go-l { animation: rc-l .24s var(--ease, ease); }
.rcal-grid.go-r { animation: rc-r .24s var(--ease, ease); }
@keyframes rc-l { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes rc-r { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
.rcal-h { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0 4px; }
.rcal-h.we { color: var(--faint); }
.rcal-grid button { position: relative; height: 34px; border: 0; background: none; padding: 0; font: inherit; font-size: 13px;
  color: var(--ink); cursor: pointer; border-radius: 0; transition: background .15s, color .15s; }
.rcal-grid button::after { content: ''; position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; z-index: -1; transition: background .15s, transform .2s var(--spring, ease); transform: scale(.6); }
.rcal-grid button { z-index: 0; display: flex; align-items: center; justify-content: center; margin: 0; min-width: 0; min-height: 0;
  width: auto; box-shadow: none; text-align: center; transform: none !important; }
.rcal-grid button:not(.in) { border-radius: 0 !important; }
.rcal-grid button.in:not(.s):not(.e) { border-radius: 0 !important; }
.rcal-grid button:hover::after { background: var(--teal-soft); transform: scale(1); }
.rcal-grid button.we { color: var(--faint); }
.rcal-grid button.today { font-weight: 700; }
.rcal-grid button.in { background: color-mix(in srgb, var(--teal) 16%, transparent); color: var(--teal-ink); }
.rcal-grid button.s { border-radius: 17px 0 0 17px !important; }
.rcal-grid button.e { border-radius: 0 17px 17px 0 !important; }
.rcal-grid button.s.e { border-radius: 17px !important; }
.rcal-grid button.s, .rcal-grid button.e, .rcal-grid button.pick { color: #fff; font-weight: 600; }
.rcal-grid button.s::after, .rcal-grid button.e::after, .rcal-grid button.pick::after { background: var(--teal); transform: scale(1); }
.rcal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-size: 12.5px; }
@media (max-width: 760px) {
  .rcal { position: static; }
  .rcal-pop { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; border-radius: 20px 20px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); z-index: 120; transform: translateY(20px); }
  .rcal-grid button { height: 44px; font-size: 15px; }
  .rcal-grid button::after { width: 40px; height: 40px; margin: -20px 0 0 -20px; }
  .rcal-grid button.s { border-radius: 22px 0 0 22px !important; } .rcal-grid button.e { border-radius: 0 22px 22px 0 !important; } .rcal-grid button.s.e { border-radius: 22px !important; }
}

/* ===== Тёмная тема: приглушённые цвета (без «ядовитых» тонов) ===== */
html[data-theme="dark"] {
  --red: #D58A7E; --red-ink: #E9B4AB; --amber: #CFA25E; --amber-ink: #E6C892; --green: #5DAE88; --green-ink: #A3D6BC;
  --teal-dark: #74C0C9; --teal-ink: #A9DCE1;
  --soft-good: #7DC3A0; --soft-mid: #D6AC6C; --soft-low: #DB9A90; --soft-bad: #D9838F;
}
html[data-theme="dark"] .ov-bar i.lv-good, html[data-theme="dark"] .dt-pct.lv-good, html[data-theme="dark"] .dt-score.lv-good { background: #4C9A77; }
html[data-theme="dark"] .ov-bar i.lv-mid, html[data-theme="dark"] .dt-pct.lv-mid, html[data-theme="dark"] .dt-score.lv-mid { background: #B98A47; }
html[data-theme="dark"] .ov-bar i.lv-low, html[data-theme="dark"] .dt-pct.lv-low, html[data-theme="dark"] .dt-score.lv-low { background: #B4706A; }
html[data-theme="dark"] .ov-bar i.lv-bad, html[data-theme="dark"] .dt-pct.lv-bad, html[data-theme="dark"] .dt-score.lv-bad { background: #8F4E5A; }
html[data-theme="dark"] .fin-bar .lo, html[data-theme="dark"] .ov-scale .ov-base.lv-lo { background: #B98A47; }
html[data-theme="dark"] .fin-bar .cap-warn, html[data-theme="dark"] .ov-scale .ov-tail.lv-warn { background: #B98A47; }
html[data-theme="dark"] .ov-scale .ov-tail.lv-paid { background: #3F8566; }
html[data-theme="dark"] .fin-bar .hi { background: #3B9BA7; }

/* ===== Разделы таблиц: свернуть / развернуть, «прилипание» в окне таблицы (tree.js) ===== */
.tree-tog { float: left; display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin: -1px 4px -2px -4px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted); box-shadow: none; cursor: pointer; vertical-align: middle;
  transition: background .15s, color .15s, transform .15s; }
.tree-tog::before { content: ''; width: 0; height: 0; border-left: 4.5px solid transparent; border-right: 4.5px solid transparent; border-top: 6px solid currentColor;
  transition: transform .2s ease; }
.tree-tog:hover { background: var(--row-hover); color: var(--teal-dark); transform: none; box-shadow: none; }
tr.tree-shut .tree-tog::before { transform: rotate(-90deg); }
tr.tree-hid { display: none; }
table.tree-in tr[data-lvl] > * { position: sticky; z-index: 1; }
table.tree-in tr[data-lvl="0"] > * { top: calc(var(--t0) + var(--sh, 0px)); z-index: 1; }
table.tree-in tr[data-lvl="1"] > * { top: calc(var(--t1) + var(--sh, 0px)); }
table.tree-in tr[data-lvl="2"] > * { top: calc(var(--t2) + var(--sh, 0px)); }
table.tree-in tr[data-lvl="3"] > * { top: calc(var(--t3) + var(--sh, 0px)); }
table.tree-in tr[data-lvl]:not(.fin-src):not(.hr-unit):not(.on) > * { background: var(--card); }
@media (max-width: 760px) { .m-view-btn { display: none; } }
.fin-table tr.tree-has > td:first-child > a { display: block; overflow: hidden; }
.tree-bar { display: flex; gap: 14px; justify-content: flex-end; margin: 0 2px 6px; font-size: 13px; }
.tree-bar .link { color: var(--teal-dark); }
.kp-q { min-width: 300px; }
.kp-found { font-size: 12px; color: var(--teal-dark); margin-top: 2px; }
.kp-q { min-width: 300px; }
.kp-found { font-size: 12px; color: var(--teal-dark); margin-top: 2px; }
a.code-link { color: inherit; text-decoration: none; border-bottom: 1px dotted color-mix(in srgb, var(--teal) 70%, transparent); }
a.code-link:hover { color: var(--teal-dark); border-bottom-style: solid; text-decoration: none; }
/* «Найти в таблице» (tablefind.js) */
.tf-bar { justify-content: flex-start; align-items: center; }
.tf-bar .link:first-of-type { margin-left: auto; }
.tf-input { width: 220px; height: 30px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.tf-count { font-size: 12px; }
tr.tf-hide { display: none !important; }
table.tf-on tr.tree-hid:not(.tf-hide) { display: table-row; }
/* Фильтры (формы GET): компактно, в одну строку, спокойная кнопка вместо яркой синей */
@media (min-width: 761px) {
  main form:not([method=post]) select,
  main form:not([method=post]) input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]),
  main form:not([method=post]) .msel-btn { padding: 4px 9px; font-size: 13px; border-radius: 8px; min-height: 30px; }
  main form:not([method=post]) .msel-btn { min-width: 0; max-width: 230px; gap: 6px; }
  main form:not([method=post]) > button:not(.link), main form:not([method=post]) > .btn,
  .an-filter-actions > button:not(.link) { padding: 4px 12px; font-size: 13px; min-height: 30px; border-radius: 8px;
    background: var(--x-bg-E8EEF3); color: var(--teal-dark); font-weight: 600; box-shadow: none; }
  main form:not([method=post]) > button:not(.link):hover, main form:not([method=post]) > .btn:hover,
  .an-filter-actions > button:not(.link):hover { background: var(--x-bg-DCE5EC); box-shadow: none; }
  html:not([data-theme="dark"]) main form:not([method=post]) > button:not(.link),
  html:not([data-theme="dark"]) .an-filter-actions > button:not(.link) { background: #EFEFF4; color: #007AFF; }
  html:not([data-theme="dark"]) main form:not([method=post]) > button:not(.link):hover,
  html:not([data-theme="dark"]) .an-filter-actions > button:not(.link):hover { background: #E5E5EA; }
  main form:not([method=post]) > a, main form:not([method=post]) > button.link { font-size: 13px; }
  .filter-card { gap: 6px; padding: 8px 10px; }
  .filter-card .filter-q { min-width: 170px; max-width: 280px; }
  main form.toolbar:not([method=post]), main form.an-filters { gap: 6px; }
}
@media (min-width: 761px) {
  .fin-bar-top select { max-width: 170px; }
  .fin-bar-top .fin-fresh { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
/* свод дефектов: название сверху, код снизу; числа — ссылки на список */
.dv-sum .dv-name { display: block; }
.dv-sum .dv-code { display: block; font-size: 12px; color: var(--muted); }
.dv-sum a:hover .dv-code { color: inherit; }
.dv-sum a.dv-n { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
.dv-sum a.dv-n:hover { color: var(--teal-dark); }
/* карточки клинпротоколов: разделы сворачиваются, в таблице приказа 27 узкие «+» и срок */
.kp-secbar { gap: 16px; margin: 0 0 8px; }
.kp-o27 > summary h3 { margin: 0; }
.kp-o27-t .kp-pm { width: 120px; text-align: center; font-size: 13px; }
.kp-o27-t .kp-term { width: 1%; white-space: nowrap; }
/* «Исправления»: слева дни месяца, справа врачи в окне той же высоты, внизу список услуг */
.cr-top { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: stretch; margin-bottom: 16px; }
.cr-top > .card, .cr-list { margin: 0; }
.cr-top h2, .cr-list h2 { margin: 0; font-size: 16px; }
.cr-days h2 { margin-bottom: 8px; }
.cr-days table.fin td, .cr-days table.fin th, .cr-people table.fin td, .cr-people table.fin th { padding: 3px 8px; }
.cr-days tr.cr-empty td { color: var(--faint); }
.cr-days tfoot td { font-weight: 600; border-top: 2px solid var(--line); }
.cr-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.cr-people { display: flex; flex-direction: column; min-height: 0; }
.cr-scroll { position: relative; flex: 1 1 0; min-height: 300px; overflow-y: auto; }
.cr-scroll table { position: absolute; inset: 0 0 auto 0; width: 100%; }
.cr-top table.fin, table.fin.cr-svc { table-layout: auto; }
.cr-top table.fin th, table.fin.cr-svc th { white-space: normal; vertical-align: bottom; }
.cr-svc th:nth-child(3) { width: 26%; } .cr-svc th:nth-child(6) { width: 28%; }
.cr-people tbody td:first-child { white-space: normal; overflow: visible; width: 45%; }
.cr-scroll thead th { position: sticky; top: 0; z-index: 1; background: var(--card); }
.cr-list { margin-top: 16px; }
.cr-svc .dv-name { display: block; }
.cr-svc .dv-code { display: block; font-size: 12px; color: var(--muted); }
.cr-change div + div { margin-top: 2px; }
@media (max-width: 1100px) {
  .cr-top { grid-template-columns: minmax(0, 1fr); }
  .cr-scroll { flex: none; height: 480px; }
}
main table.fin.cr-svc td { white-space: normal; overflow: visible; }
.cr-top tr.cr-row { cursor: pointer; }
.cr-top tr.cr-row:hover td { background: var(--teal-soft); }
.cr-top tr.cr-row.on td { background: var(--teal-soft); font-weight: 600; }
.cr-top tr.cr-row td a { color: inherit; text-decoration: none; }
.cr-top tr.cr-row:hover td a { color: var(--teal-dark); text-decoration: underline; }
/* ===== Телефон: таблицы карточками, своды шкалами, фильтры по кнопке (core/static/core/mobile.js) ===== */
.m-more, .m-filter-btn { display: none; }
@media (max-width: 760px) {
  table.m-cards, table.m-cards > tbody, table.m-cards > tfoot { display: block; width: 100% !important; min-width: 0 !important;
    border: 0; border-radius: 0; background: none; box-shadow: none; }
  table.m-cards > thead, table.m-cards > colgroup { display: none; }
  table.m-cards tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 12px; padding: 10px 4px;
    border-bottom: 1px solid var(--line-soft); background: none; }
  table.m-cards tr > td, table.m-cards tr > th { display: inline; padding: 0 !important; border: 0 !important; background: none !important;
    width: auto !important; min-width: 0 !important; max-width: none !important; position: static !important;
    white-space: normal !important; overflow: visible !important; text-overflow: clip !important; text-align: left !important;
    font-size: 12.5px; line-height: 1.4; box-shadow: none !important; }
  table.m-cards tr > *::before { content: attr(data-label) " "; color: var(--muted); font-size: 11.5px; font-weight: 400; }
  table.m-cards tr > *:empty, table.m-cards tr > .m-hide, table.m-cards tr > .col-hidden { display: none; }
  table.m-cards tr > .m-title { flex: 1 1 60%; min-width: 0; order: -3; font-size: 14px; font-weight: 600; color: var(--ink); }
  table.m-cards tr > .m-title::before, table.m-cards tr > .m-main::before, table.m-cards tr > .m-pct::before { content: none; }
  table.m-cards tr > .m-main, table.m-cards tr > .m-pct { order: -2; margin-left: auto; font-size: 15px; font-weight: 700; white-space: nowrap !important; }
  table.m-cards tr.m-bar::after { content: ''; order: -1; flex: 1 1 100%; height: 6px; border-radius: 3px; margin: 2px 0 2px;
    background: linear-gradient(90deg, var(--teal) var(--p), var(--line-soft) var(--p)); }
  table.m-cards tr.m-sec { padding: 12px 4px 4px; border-bottom: 0; }
  table.m-cards tr.m-sec > * { font-size: 13px; font-weight: 700; color: var(--ink); }
  table.m-cards tr.m-sec > *::before { content: none; }
  table.m-cards tr.m-total { background: var(--x-bg-F3F7FA); border-radius: 10px; margin-top: 6px; }
  table.m-cards tr.m-total > * { font-weight: 600; }
  table.m-cards tr.m-more-hid { display: none; }
  table.m-cards tr.on, table.m-cards tr.cr-row.on { background: var(--teal-soft); border-radius: 10px; }
  table.m-cards tr > * a { overflow-wrap: anywhere; }
  table.m-cards input[type=checkbox] { width: 20px; height: 20px; }
  .m-more { display: block; width: 100%; margin: 8px 0 0; background: var(--x-bg-E8EEF3); color: var(--teal-dark); box-shadow: none;
    justify-content: center; font-size: 14px; }
  .m-more:hover { background: var(--x-bg-DCE5EC); }
  /* окна с таблицами: карточкам высота не ограничена — листается сама страница */
  .tbl-x:has(> table.m-cards), .an-scroll:has(table.m-cards), .sc-scroll:has(table.m-cards), .fin-scroll:has(table.m-cards),
  .defects-wrap:has(table.m-cards) { max-height: none; overflow: visible; }
  .cr-scroll:has(table.m-cards) { height: auto !important; flex: none; overflow: visible; }
  .cr-scroll table.m-cards { position: static; }
  .cr-top { grid-template-columns: minmax(0, 1fr) !important; }

  /* фильтры: видны «Фильтры · N», поиск и «Показать»; остальное — по нажатию */
  form.m-filters > .m-filter-btn { display: inline-flex; flex: 0 0 auto !important; order: -2; background: var(--x-bg-E8EEF3);
    color: var(--ink); box-shadow: none; font-weight: 600; }
  form.m-filters > .m-filter-btn.on { background: var(--teal-soft); color: var(--teal-ink); }
  form.m-filters > .m-filter-btn::before { content: '☰'; font-size: 13px; }
  form.m-filters > .m-filter-btn[aria-expanded="true"]::before { content: '✕'; }
  form.m-filters:not(.m-open) > .m-f { display: none !important; }
  form.m-filters input[name=q] { order: -1; flex: 1 1 calc(100% - 140px) !important; }
}
@media (max-width: 760px) { .cr-days tr.cr-empty { display: none; } .cr-days { padding-bottom: 6px; } }
@media (max-width: 760px) { table.m-cards tr.m-hrow { display: none; } }
@media (max-width: 760px) { table.m-cards tr > .m-pct-sign::after { content: "%"; } }
@media (max-width: 760px) {
  .cols-bar, .cols-menu, .reset-widths, .copy-all { display: none !important; }
  form.m-filters input[name=q] { flex: 1 1 150px !important; min-width: 0 !important; }
  form.m-filters > button:not(.m-filter-btn):not(.link) { flex: 0 0 auto !important; }
}
@media (max-width: 760px) { table.m-cards .fin-bar { display: none; } }
/* телефон: свёрнутые подразделы (tree.js) остаются скрытыми и в карточках; лоты Освоения — без своего окна */
@media (max-width: 760px) {
  table.m-cards tr.tree-hid { display: none; }
  table.m-cards.tf-on tr.tree-hid:not(.tf-hide) { display: flex; }
  .fin-tall:has(table.m-cards), #fin-live .fin-tall:has(table.m-cards) { max-height: none; overflow: visible; contain: none; }
  table.m-cards tr.tree-has > .m-title { cursor: pointer; }
}

/* Телефон: свод — строка «название · число · %» и шкала; остальные цифры — по нажатию. Детальные списки скрыты. */
@media (max-width: 760px) {
  table.m-compact tr { padding: 8px 4px; gap: 2px 10px; cursor: pointer; }
  table.m-compact tr:not(.m-full) > *:not(.m-title):not(.m-pct):not(.m-main):not(.m-sub) { display: none; }
  table.m-compact tr > .m-main { font-size: 14px; font-weight: 600; }
  table.m-compact tr > .m-main::before { content: attr(data-label) " "; color: var(--muted); font-size: 11.5px; font-weight: 400; }
  table.m-compact tr.m-full { background: var(--x-bg-F3F7FA); border-radius: 10px; }
  table.m-compact tr.m-full > *:not(.m-title):not(.m-pct):not(.m-main):not(.m-sub) { flex: 1 1 40%; order: 1; font-size: 13px; }
  .m-detail, .tf-bar, .tree-bar, .dv-by > .muted:last-child { display: none !important; }
}
@media (max-width: 760px) { .cr-top tr.cr-row a { pointer-events: none; color: inherit; } }
@media (max-width: 760px) {
  table.m-compact tr { flex-wrap: wrap; align-items: baseline; }
  table.m-compact tr > .m-title { flex: 1 1 0; }
  table.m-compact tr > .m-main { margin-left: 0; }
  table.m-compact tr > .m-pct { margin-left: 0; min-width: 44px; text-align: right; }
}
@media (max-width: 760px) {
  table.m-compact tr > .m-title { order: -4; }
  table.m-compact tr > .m-main { order: -3; }
  table.m-compact tr > .m-pct { order: -2; }
}
@media (max-width: 760px) {
  .dv-by { flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding-bottom: 4px; scrollbar-width: none; }
  .dv-by > * { flex: none; }
  .dv-by > .muted:first-child { display: none; }
}
@media (max-width: 760px) {
  table.m-compact tr.m-bar::after { order: 0; }
  table.m-compact tr:not(.m-full) > .m-sub { display: block; }
  table.m-compact tr > .m-sub { order: -1; flex: 1 1 100%; font-size: 12.5px; color: var(--muted); }
  table.m-compact tr > .m-sub::before { content: none; }
  table.m-compact tr > .m-sub .dv-name, table.m-compact tr > .m-sub .dv-code { display: inline; margin-right: 6px; }
}
@media (max-width: 760px) {
  table.m-compact tr > .m-sub, table.m-compact tr > .m-sub * { font-weight: 400; color: var(--muted); }
  table.m-compact .dv-bar { display: none; }
}
/* свод на телефоне: название во всю ширину, ниже — шкала, число и % в одну линию */
@media (max-width: 760px) {
  table.m-compact tr { align-items: center; }
  table.m-compact tr > .m-title { flex: 1 1 100%; }
  table.m-compact tr > .m-sub { order: -4; }
  table.m-compact tr.m-bar::after { order: -3; flex: 1 1 40px; margin: 0; align-self: center; }
  table.m-compact tr > .m-main { order: -2; }
  table.m-compact tr > .m-pct { order: -1; }
  table.m-compact tr.m-full > *:not(.m-title):not(.m-pct):not(.m-main):not(.m-sub) { order: 1; }
}
@media (max-width: 760px) { table.m-compact tr > .m-main { margin-left: auto; } }
.an-filter-grid .an-qs { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 760px) { .an-filter-grid .an-qs { grid-template-columns: 1fr; } }
/* телефон: разделы и подразделы в дереве — раздел на подложке, подраздел с отступом и линией слева */
@media (max-width: 760px) {
  table.m-cards.tree tr[data-lvl="0"] { background: var(--x-bg-F3F7FA); border-radius: 10px; border-bottom: 0; margin-top: 8px; padding: 10px 8px; }
  table.m-cards.tree tr[data-lvl="0"] > .m-title { font-size: 15px; font-weight: 700; }
  table.m-cards.tree tr[data-lvl="1"] { margin-left: 14px; padding-left: 10px; border-left: 3px solid var(--teal-soft); }
  table.m-cards.tree tr[data-lvl="1"] > .m-title { font-size: 13.5px; font-weight: 600; }
  table.m-cards.tree tbody tr:not([data-lvl]) { margin-left: 30px; padding-left: 10px; border-left: 3px solid var(--line); }
  table.m-cards.tree tbody tr:not([data-lvl]) > .m-title { font-size: 13px; font-weight: 400; color: var(--muted); }
  .mnav a span, .mnav button span { white-space: nowrap; font-size: 10px; letter-spacing: -.1px; }
}
@media (max-width: 760px) {
  table.m-cards.tree tbody tr:not([data-lvl]) > .m-title, table.m-cards.tree tbody tr:not([data-lvl]) > .m-title a { font-weight: 400; color: var(--muted); }
}
/* итог таблицы поверх «прилипших» разделов — не пропадает при прокрутке */
table.fin tfoot td { z-index: 3; }
/* Освоение на ноутбуке: таблица лотов почти во весь экран, правая таблица — той же высоты */
@media (min-width: 1101px) {
  #fin-live .fin-tall { max-height: calc(100vh / var(--z) - 110px); }
  #fin-live .fin-people { height: 0; min-height: 100%; }
  #fin-live .fin-people .fin-scroll { max-height: none; min-height: 0; }
}
/* Освоение: лот (подраздел) — своя подложка светлее раздела и жирное название; внешние/внутренние — простые строки под ним */
#fin-live table.fin-table tr.fin-lot:not(.on) > td,
table.tree-in tr.fin-lot[data-lvl]:not(.on) > td { background: color-mix(in srgb, var(--line-soft) 45%, var(--card)); }
#fin-live table.fin-table tr.fin-lot > td { font-weight: 600; border-top: 1px solid var(--line); }
#fin-live table.fin-table tr.fin-lot > td:first-child a { font-weight: 600; }
#fin-live table.fin-table tr.fin-side > td:first-child, #fin-live table.fin-table tr.fin-side > td:first-child a { font-weight: 400; color: var(--muted); }
/* Освоение на компьютере: таблица лотов в своём окне высотой с экран ноутбука 15" (не выше 720 px) — своя прокрутка,
   шапка столбцов и «Всего» прилипают к краям окна */
@media (min-width: 1101px) {
  #fin-live .fin-tall { max-height: min(calc(100vh / var(--z) - 180px), 720px); overflow: auto; contain: layout paint; }
  /* нижние таблицы (участки, услуги, МО внешние) — той же высоты */
  #fin-live .fin-row3 > .fin-box { max-height: min(calc(100vh / var(--z) - 180px), 720px); }
}
/* порядок пунктов меню слева */
.nav-order { display: flex; gap: 10px; padding: 8px 12px 4px; }
.nav-order button { background: none; border: 0; box-shadow: none; padding: 0; min-height: 0; font-size: 12px; font-weight: 500;
  color: var(--muted); cursor: pointer; }
.nav-order button:hover { color: var(--teal); background: none; transform: none; }
.nav-edit a[data-k] { cursor: grab; outline: 1px dashed var(--line); outline-offset: -1px; }
.nav-edit a[data-k]::after { content: "⋮⋮"; margin-left: auto; color: var(--muted); letter-spacing: -2px; }
.nav-edit a.nav-drag { opacity: .45; }
@media (max-width: 760px) { .nav-order { display: none; } }
.nav-order button { white-space: nowrap; }
.nav-order button[hidden] { display: none; }
/* ===== Ссылки вне таблиц — так же приподнимаются при наведении (названия в полосах, «→ подробнее» и т. п.) ===== */
main a:not([class]), main a.name, main a.muted, main a.dv-n, main .ov-row a, main .ov-sub a {
  display: inline-block; max-width: 100%; transition: transform .2s var(--ease, ease), color .2s; }
main a:not([class]):hover, main a.name:hover, main a.muted:hover, main a.dv-n:hover, main .ov-row a:hover, main .ov-sub a:hover {
  transform: translateY(-2px); }
main p a:not([class]), main li a:not([class]) { display: inline; }
@media (prefers-reduced-motion: reduce) { main a:hover { transform: none !important; } }
/* группы меню слева: название-кнопка со стрелкой, свернуть / развернуть */
.nav-group { margin-top: 6px; }
/* пункты без группы сразу после группы — линия: они к ней не относятся */
.nav-group:has(+ a[data-k]) { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid rgba(255, 255, 255, .14); }
html:not([data-theme="dark"]) .nav-group:has(+ a[data-k]) { border-bottom-color: var(--line); }
.nav-gh { display: flex; align-items: center; width: 100%; gap: 6px; padding: 8px 12px 4px; background: none; border: 0; box-shadow: none;
  min-height: 0; border-radius: 8px; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #6C8DA0; cursor: pointer; }
html:not([data-theme="dark"]) .nav-gh { color: var(--muted); }
.nav-gh:hover { background: none; transform: none; color: var(--teal); }
.nav-gh i { margin-left: auto; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg); transition: transform .2s; margin-right: 4px; }
.nav-group.shut .nav-gh i { transform: rotate(-45deg); }
.nav-group.shut .nav-gi { display: none; }
.nav-edit .nav-group.shut .nav-gi { display: block; }
.nav-edit .nav-group { outline: 1px dashed var(--line); outline-offset: 2px; border-radius: 10px; }
.nav-edit .nav-gh { cursor: grab; }
.nav-edit .nav-group.nav-drag { opacity: .45; }
/* вкладки раздела (Сотрудники: Кадры · Врачи · Нагрузка; Загрузить файл · История) — над страницей */
.sec-tabs { margin-bottom: 14px; }
.bk-mirror { margin: 10px 0; gap: 8px; }
.bk-mirror input { flex: 1; min-width: 220px; max-width: 420px; }

/* Скрининги, свод: «N чел.» под числом — в строке «Итого» не обрезается */
.sc-sum .ppl { display: block; margin-left: 0; }
/* Ноутбук: большие списки без своей прокрутки — листается вся страница, как в «Освоении»: шапка столбцов
   прилипает под верхней полосой (heads.js), полоса прокрутки вбок — внизу экрана (hscroll.js).
   Небольшие таблицы рядом друг с другом (свод, лоты, панели «Аналитики услуг») — со своей прокруткой.
   contain остаётся: без него на каждом кадре плавной прокрутки браузер пересчитывает всю большую таблицу — рывки. */
@media (min-width: 1101px) {
  .an-scroll.sc-scroll, .defects-wrap, .list-card .defects-wrap, .an-wide, main .tbl-x, .an-scroll-tall {
    max-height: none; overflow-y: visible; contain: layout paint; overscroll-behavior: auto;
  }
}

/* Главная, «Освоение за месяц»: крупно — сумма, под ней «из плана», ниже — процент (цвет — по выполнению) */
.kpi.kpi-sum .v { color: inherit; }
.kpi.kpi-sum .pct { display: block; margin-top: 4px; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi.kpi-sum.alert .pct { color: var(--red); }
.kpi.kpi-sum.ok .pct { color: var(--green); }

/* «Деньги | Количество» — выбор одного из двух (а не рычажок «вкл/выкл») */
.seg.ms-seg button { padding: 6px 14px; min-height: 0; border: 0; border-radius: 8px; background: none; box-shadow: none;
  color: var(--muted); font-weight: 500; font-size: 13px; cursor: pointer; transform: none; transition: background .2s, color .2s, box-shadow .2s; }
.seg.ms-seg button:hover { color: var(--ink); background: none; transform: none; }
.seg.ms-seg button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg.ms-seg button.on { background: var(--pick); color: #fff; }
/* «Отклонение» — обычный рычажок: выключен — серый, включён — зелёный (правило выше для «Деньги / Количество» было наоборот) */
html .measure-switch.dev-switch > button { background: #C7C7CC; }
html .measure-switch.dev-switch > button[aria-checked="true"] { background: #4BA877; }
html[data-theme="dark"] .measure-switch.dev-switch > button { background: #48484A; }

/* ===== Выбор «один из нескольких» — основной цвет темы: синий в светлой, бирюзовый в тёмной (зелёный — только «выполнено»
   и рычажки вкл/выкл); подложка плавно переезжает (seg.js) ===== */
:root { --pick: var(--primary); }
:root:root .seg a.on, :root:root .seg button.on, :root:root .sc-tabs a.on, :root:root .kp-level a.on,
:root:root .upload-mode button.on, :root:root .kp-tabs a.on, :root:root .hr-view .btn.on {
  background: var(--pick); color: #fff; border-color: var(--pick); }
:root:root .fin-tabs a.on { color: var(--pick); border-bottom-color: var(--pick); }
.seg a, .seg button, .sc-tabs a, .kp-level a, .upload-mode button, .fin-tabs a { position: relative; z-index: 1; transition: color .25s, background-color .25s; }
.seg, .sc-tabs, .kp-level, .upload-mode, .fin-tabs { position: relative; isolation: isolate; }
.seg-pill { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; background: var(--pick); opacity: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .15); transition: transform .3s cubic-bezier(.3, .7, .2, 1), width .3s cubic-bezier(.3, .7, .2, 1), opacity .15s; }
.fin-tabs > .seg-pill { box-shadow: none; }
/* подложка рисует выбранный пункт — у самого пункта фона и рамки нет */
:root:root:root .pill-on > .on { background: transparent; box-shadow: none; border-color: transparent; }
:root:root:root .fin-tabs.pill-on > .on { border-bottom-color: transparent; }
@media (prefers-reduced-motion: reduce) { .seg-pill { transition: none; } }
/* Вкладки «Скринингов», «Диспансеризации»: в одну строку — серая полоса, как у сегментов; подложка едет по ней */
.sc-tabs.pill-on { width: fit-content; max-width: 100%; gap: 2px; padding: 3px; border-radius: 10px; background: var(--line-soft); }
:root:not([data-theme="dark"]) .sc-tabs.pill-on { background: #E3E4E9; }
:root:root:root .sc-tabs.pill-on > a:not(.on) { background: transparent; border-color: transparent; color: var(--muted); }
:root:root:root .sc-tabs.pill-on > a:not(.on):hover { color: var(--ink); }
:root:root:root .kp-level.pill-on > a:not(.on), :root:root:root .upload-mode.pill-on > button:not(.on) { background: transparent; }

/* Еле видимые линии между столбцами во всех таблицах — числа соседних столбцов не сливаются */
main table:not(.fin-cal-grid) :is(th, td):not(:last-child) { border-right: 1px solid var(--line); }

/* Карточка участка: разделы — ровная сетка плиток одной высоты, таблица листается внутри плитки */
@media (min-width: 761px) {
  .dt-secs { display: grid; grid-template-columns: repeat(auto-fill, minmax(470px, 1fr)); gap: 16px; columns: auto; align-items: stretch; }
  .dt-secs .dt-sec { margin: 0; height: 500px; display: flex; flex-direction: column; min-height: 0; }
  .dt-sec .dt-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
  .dt-sec .dt-scroll thead th { position: sticky; top: 0; z-index: 2; }
  .dt-sec .dt-mini th, .dt-sec .dt-mini td { padding: 6px 8px; }
  .dt-sec .dt-mini td:first-child { overflow-wrap: anywhere; hyphens: auto; }
  .dt-sec .dt-scroll tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--x-bg-EEF3F7); }
}

/* Кнопка «Режим демонстрации» в шапке */
.demo-form { display: inline-flex; margin: 0; }
.demo-btn { display: inline-flex; align-items: center; gap: 5px; }
:root:root .demo-btn.on, :root:root .demo-btn.on:hover { background: var(--pick); border-color: var(--pick); color: #fff; font-weight: 600; font-size: 13px; }

/* Переход режима демонстрации (demofx.js): размытие экрана, щит и название режима */
:root[data-fx]::before { content: ''; position: fixed; inset: 0; z-index: 9998; background: color-mix(in srgb, var(--bg) 58%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(.75); backdrop-filter: blur(18px) saturate(.75); }
:root[data-fx]::after { content: 'Режим демонстрации'; position: fixed; left: 0; right: 0; top: calc(50% - 56px); z-index: 9999; padding-top: 74px;
  text-align: center; font: 600 18px/1.3 "Segoe UI", system-ui, sans-serif; color: var(--ink); pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234BA877' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3l7.5 2.8v5.6c0 4.6-3.1 8-7.5 9.6-4.4-1.6-7.5-5-7.5-9.6V5.8z' fill='%234BA877' fill-opacity='.16'/%3E%3Cpath d='M8.8 12.2l2.2 2.2 4.2-4.4'/%3E%3C/svg%3E") center top / 60px 60px no-repeat; }
:root[data-fx="off"]::after { content: 'Обычный режим';
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238DA1B0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3l7.5 2.8v5.6c0 4.6-3.1 8-7.5 9.6-4.4-1.6-7.5-5-7.5-9.6V5.8z'/%3E%3C/svg%3E"); }
:root.fx-in::before { animation: fx-veil-in .32s ease-out both; }
:root.fx-in::after { animation: fx-mark-in .32s cubic-bezier(.2, .9, .3, 1.15) both; }
:root.fx-out::before { animation: fx-veil-out .6s ease-in-out both; }
:root.fx-out::after { animation: fx-mark-out .28s ease-in both; }
@keyframes fx-veil-in { from { opacity: 0; -webkit-backdrop-filter: blur(0); backdrop-filter: blur(0); } }
@keyframes fx-veil-out { to { opacity: 0; -webkit-backdrop-filter: blur(0); backdrop-filter: blur(0); } }
@keyframes fx-mark-in { from { opacity: 0; transform: scale(.86); } }
@keyframes fx-mark-out { to { opacity: 0; transform: scale(1.05); } }

/* Верх окна таблицы ушёл под верхнюю полосу — шапка держится под полосой (sticky.js) */
/* сдвиг, а не top: top на каждом кадре пересчитывал раскладку всей таблицы и прокрутка дёргалась */
main table thead[style*="--st"] th { top: 0 !important; transform: translateY(var(--st)); z-index: 3; }

/* Замок в шапке: страница стоит (колесо, клавиши, полоса), таблицы в своих окнах листаются. Место полосы сохраняем: ширина таблиц не прыгает */
.lock-btn .l-on { display: none; }
:root[data-lock] .lock-btn .l-on { display: inline; }
:root[data-lock] .lock-btn .l-off { display: none; }
:root:root[data-lock] .lock-btn, :root:root[data-lock] .lock-btn:hover { background: var(--pick); border-color: var(--pick); color: #fff; }
@media (max-width: 760px) { .lock-btn { display: none; } }
@media (min-width: 761px) { :root[data-lock] { overflow-y: hidden; scrollbar-gutter: stable; } }

/* Аналитика услуг: обновление на месте (anlive.js). Страница не тускнеет; долгий ответ — тонкая полоса под шапкой */
.an-lv td, .an-lv th { transition: opacity .1s ease, background-color .1s ease; }
body.an-wait { cursor: progress; }
body.an-wait .topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--pick); transform-origin: left; opacity: 0; animation: an-wait 1.1s ease-out .25s infinite; pointer-events: none; }
@keyframes an-wait { 0% { transform: scaleX(0); opacity: 1; } 80% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }

/* Главные фильтры в верхней полосе (barfilters.js): появляются, когда настоящие ушли вверх */
.tb-filters { display: none; align-items: center; gap: 8px; margin: 0; min-width: 0; }
.tb-filters.on { display: flex; animation: mo-fade .24s var(--ease); }
.tb-filters.on.out { animation: tb-filters-out .16s ease-in forwards; }
.tb-filters.tb-none { display: none; }
.tb-filters [hidden] { display: none !important; }
.tb-filters select, .tb-filters input { width: auto; max-width: 150px; min-width: 0; margin: 0; padding: 5px 8px; font-size: 13px; }
.tb-filters input { width: 160px; }
html.ks-hold body { visibility: hidden; }
.tb-filters .ym { gap: 4px; }
.tb-filters .ym select { min-width: 0; }
.tb-filters .tb-more { padding: 5px 10px; font-size: 13px; white-space: nowrap; }
.tb-filters .tb-more[aria-expanded] { background: var(--pick); border-color: var(--pick); color: #fff; }
@keyframes tb-filters { from { opacity: 0; } to { opacity: 1; } }
@keyframes tb-filters-out { to { opacity: 0; transform: translateY(-4px); } }
form.bar-panel { position: fixed !important; right: 28px; z-index: 29; width: min(1100px, calc(100vw / var(--z, 1) - 340px)); max-height: calc(100vh / var(--z, 1) - 90px); overflow: auto; margin: 0; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-md); animation: mo-pop .22s var(--ease); transform-origin: top right; }

/* Браузер сам подстраивает прокрутку при изменениях страницы: панель «Ещё» и обновление таблиц уводили экран в сторону */
html, body { overflow-anchor: none; }

/* Плитки главной: подпись сверху, число снизу. Общее правило main a:not([class]) иначе ставит их в одну строку */
main .ov-tiles a { display: flex; flex-direction: column; justify-content: space-between; gap: 4px; }

/* Плавность: всплывающие окна, полоса прокрутки вбок и переходы между страницами без резкой смены */
.fin-cal-pop, .lc-pop, details.ld-range > span { animation: mo-pop .2s var(--ease); transform-origin: top left; }
.hscroll-bar:not([hidden]) { animation: tb-filters .2s ease-out; }
@media (prefers-reduced-motion: no-preference) {
  /* Вкладка или раздел: шапка и строка вкладок стоят, старое содержимое растворяется в новое, новое чуть приподнимается.
     plus-lighter и одинаковое время: сумма яркостей постоянна, затемнения нет. Класс vt-page — base.html */
  @view-transition { navigation: auto; types: page; }
  :root.vt-page::view-transition-old(root), :root.vt-page::view-transition-new(root) { animation-duration: .24s; }
  :root.vt-page .topbar { view-transition-name: page-top; }
  :root.vt-page main.content { view-transition-name: page-main; }
  :root.vt-page .vt-tabs { view-transition-name: page-tabs; }
  ::view-transition-group(page-top), ::view-transition-group(page-tabs), ::view-transition-group(page-main) { animation-duration: .24s; animation-timing-function: var(--ease); }
  ::view-transition-old(page-top), ::view-transition-new(page-top), ::view-transition-old(page-tabs), ::view-transition-new(page-tabs) { animation-duration: .12s; }
  ::view-transition-old(page-main), ::view-transition-new(page-main) { animation-duration: .24s; animation-timing-function: var(--ease); mix-blend-mode: plus-lighter; }
  ::view-transition-old(page-main) { animation-name: page-out; }
  ::view-transition-new(page-main) { animation-name: page-in; }
  @keyframes page-out { to { opacity: 0; } }
  @keyframes page-in { from { opacity: 0; transform: translateY(6px); } }
}
@media (prefers-reduced-motion: reduce) {
  .tb-filters.on, form.bar-panel, .fin-cal-pop, .lc-pop, details.ld-range > span, .hscroll-bar:not([hidden]) { animation: none; }
}

/* Большие таблицы в своём окне (vrows.js): строки вне окна скрыты, их место держат отступы */
.vr-off { display: none !important; }
table.vr > tbody::before, table.vr > tbody::after { content: ''; display: table-row; }
table.vr > tbody::before { height: var(--vt, 0px); }
table.vr > tbody::after { height: var(--vb, 0px); }

/* Замок, «Аналитика услуг»: два ряда таблиц делят экран поровну, итоги обоих рядов видны при любом масштабе.
   222px — верхняя полоса, заголовки карточек и отступы */
@media (min-width: 1101px) {
  :root[data-lock] .an-two .an-scroll, :root[data-lock] .an-row3 .an-scroll {
    max-height: max(140px, min(360px, calc((100vh / var(--z, 1) - 222px) / 2)));
  }
}

/* Панель «Ещё»: открытый список фильтра не обрезается панелью */
form.bar-panel:has(.msel.open) { overflow: visible; }

/* Ссылки: без линий; значения в таблицах при наведении приподнимаются и меняют цвет.
   top, а не transform: длинное название в ячейке продолжает обрезаться многоточием */
main a, main a:hover { background-image: none; text-decoration: none !important; }
main td a:not(.btn, .count, .chip, .dt-pct, .dt-score) { position: relative; top: 0; transition: top .2s var(--ease, ease), color .2s; }
main td a:not(.btn, .count, .chip, .dt-pct, .dt-score):hover { top: -2px; color: var(--teal-ink); }
main td a:not(.btn, .count, .chip, .dt-pct, .dt-score):hover { transform: none; }
@media (prefers-reduced-motion: reduce) { main td a:not(.btn, .count, .chip, .dt-pct, .dt-score):hover { top: 0; } }

/* Замок, все страницы: длинные списки листаются в своём окне (без замка — вместе со страницей), окно не выше экрана.
   Низ окна подтягивает к краю экрана sticky.js fitAll */
@media (min-width: 1101px) {
  :root[data-lock] .an-scroll.sc-scroll, :root[data-lock] .defects-wrap, :root[data-lock] .list-card .defects-wrap,
  :root[data-lock] .an-wide, :root[data-lock] main .tbl-x, :root[data-lock] .an-scroll-tall {
    max-height: calc(100vh / var(--z, 1) - 110px); overflow-y: auto;
  }
  /* «Освоение»: таблицы встают под верхнюю полосу (sticky.js finAlign), ряды делят экран под ней 60 на 40 */
  :root[data-lock] #fin-live .fin-tall { max-height: max(120px, calc(calc(100vh / var(--z, 1) - 100px) * .6)); }
  :root[data-lock] #fin-live .fin-people .fin-scroll { max-height: none; }
  :root[data-lock] #fin-live .fin-row3 > .fin-box { max-height: max(120px, calc(calc(100vh / var(--z, 1) - 100px) * .4)); }
}

/* Столбцы по содержимому: таблица шире окна — листается вбок (много месяцев) */
table.fin.fin-auto { table-layout: auto; width: max-content; min-width: 100%; }
/* Развернуть и свернуть все разделы: плюс и минус в шапке первого столбца */
main th:has(> .tree-all) { text-align: left; }
.tree-all { display: inline-flex; gap: 3px; margin-right: 8px; vertical-align: middle; }
.tree-all button { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; min-height: 0; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: transparent;
  color: var(--teal-ink); font-size: 13px; font-weight: 600; line-height: 1; cursor: pointer; box-shadow: none; }
.tree-all button:hover { background: var(--teal-soft); border-color: var(--teal); transform: none; }
@media (max-width: 760px) { .tree-all { display: none; } }

/* Меню пользователя: «Полная версия» есть только на телефоне; на компьютере не оставляет пустую строку */
.um-pop [hidden] { display: none !important; }
/* «Всего» прижат к низу окна; строка «Показаны N из M» — под ним, в конце списка */
table.fin tfoot tr.fin-more td { position: static; }
/* Ширина задана вручную: таблица ровно по сумме столбцов, не растягивается на всё окно */
table.cols-fixed { min-width: 0 !important; }
/* Обновлённая без перезагрузки таблица проявляется */
tbody.tb-fresh { animation: tb-filters .24s ease-out; }
@media (prefers-reduced-motion: reduce) { tbody.tb-fresh { animation: none; } }
/* Замок: размер окон не зависит от числа строк — при выборе строки ничего не поднимается */
@media (min-width: 1101px) {
  :root[data-lock] .an-two .an-scroll, :root[data-lock] .an-row3 .an-scroll { height: max(140px, min(360px, calc((100vh / var(--z, 1) - 222px) / 2))); }
  :root[data-lock] #fin-live .fin-tall { height: max(120px, calc(calc(100vh / var(--z, 1) - 100px) * .6)); }
  :root[data-lock] #fin-live .fin-row3 > .fin-box { height: max(120px, calc(calc(100vh / var(--z, 1) - 100px) * .4)); }
  :root[data-lock] #fin-live .fin-bar-top { flex-wrap: nowrap; overflow: hidden; }
  :root[data-lock] #fin-live .fin-bar-top .chip { min-width: 40px; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Шапка таблицы со скруглёнными верхними углами: строки при прокрутке уходят под неё.
   Угол рисуется поверх ячейки цветом карточки — сквозь него не видно проезжающих строк */
main table:not(.an-kpn) thead tr:first-child > th:first-child::before, main table:not(.an-kpn) thead tr:first-child > th:last-child::before {
  content: ''; position: absolute; top: 0; width: 10px; height: 10px; pointer-events: none; z-index: 1; }
main table:not(.an-kpn) thead tr:first-child > th:first-child::before { left: 0; background: radial-gradient(circle at 100% 100%, transparent 9.5px, var(--card) 10px); }
main table:not(.an-kpn) thead tr:first-child > th:last-child::before { right: 0; background: radial-gradient(circle at 0 100%, transparent 9.5px, var(--card) 10px); }

/* Сводные таблицы с короткими числами: ширина по содержимому, а не на весь экран. Заголовки столбцов — в несколько строк */
@media (min-width: 761px) {
  table.fit-w:not(.cols-fixed), table.fin.fit-w:not(.cols-fixed), table.fin.fin-table.fit-w:not(.cols-fixed), table.dt-table.fit-w:not(.cols-fixed) { table-layout: auto; width: auto; min-width: 0; }
  table.fin.fit-w thead th:not(:first-child), table.adm-table.fit-w thead th:not(:first-child) { white-space: normal; max-width: 104px; overflow-wrap: normal; hyphens: none; }
  table.fin.fit-w td { overflow: visible; text-overflow: clip; }
  .card:has(table.fit-w) { width: fit-content; max-width: 100%; }
  /* Узкие карточки встают рядом */
  .fit-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; margin-top: 14px; }
  .fit-row > .card { margin: 0; min-width: 0; }
  .fit-row > .ov-card { flex: 1 1 100%; }
}

/* «Столбцы» и Excel в закреплённой шапке таблицы */

/* Названия столбцов — по центру в обе стороны, во всех таблицах. Исключение: столбец с кнопками «+ −» слева */
main table th { vertical-align: middle !important; }
main table th:not(:has(> .tree-all)):not(.th-left) { text-align: center !important; }
/* Числа — по правому краю */
main table td.r { text-align: right; }
/* Выпадающие списки не длиннее половины экрана; прокрутка в списке не двигает страницу */
@media (min-width: 761px) {
  .msel-pop { max-height: min(340px, calc(48vh / var(--z, 1))); }
  .cols-menu { max-height: min(420px, calc(60vh / var(--z, 1))); }
}
.msel-pop, .cols-menu { overscroll-behavior: contain; }

/* Окна «Освоения»: обычная полоса прокрутки не подчиняется скруглению и даёт квадратный угол справа. Прозрачная дорожка — угол скруглён */
#fin-live .fin-box::-webkit-scrollbar, #fin-live .fin-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
#fin-live .fin-box::-webkit-scrollbar-track, #fin-live .fin-scroll::-webkit-scrollbar-track, #fin-live .fin-box::-webkit-scrollbar-corner, #fin-live .fin-scroll::-webkit-scrollbar-corner { background: transparent; }
#fin-live .fin-box::-webkit-scrollbar-thumb, #fin-live .fin-scroll::-webkit-scrollbar-thumb { background: var(--faint); border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }

/* Строка над таблицей (tablebar.js): название, поиск и фильтры, справа значки. Кнопки появляются в готовой строке — таблица не сдвигается */
.tb-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; margin: 0 0 6px; min-height: 28px; }
.tb-row:not(.fhead-title):not(:has(.tb-title)):not(:has([data-ph])):not(:has(.tb-acts > :not([hidden]))) { display: none; }
.tb-row > .tb-title { margin: 0 !important; min-width: 0; }
.tb-row > .sc-list-head.tb-title { flex: 0 1 auto; }
.tb-acts { display: flex; align-items: center; flex: 1 1 auto; flex-wrap: wrap; gap: 4px 8px; min-width: 0; }
.tb-acts::before { content: ''; order: 3; flex: 1 1 0; }
.tb-acts > .tree-bar { order: 1; margin: 0; }
.tb-acts > .tbl-filters { order: 2; }
.tb-acts > .tk-reset { order: 4; margin: 0; white-space: nowrap; }
.tb-acts > .cols-bar { order: 6; margin: 0; }
.tb-acts > a, .tb-acts > button:not(.tk-reset) { order: 5; }
.tb-acts > a.btn-icon { order: 7; }
.tbl-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tbl-filters .msel-btn { min-height: 30px; }
tr.cf-hide { display: none; }
/* Только значок скачивания */
.btn-icon, main .btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; min-height: 0; padding: 0; border: 0; border-radius: 6px; background: none; box-shadow: none; color: var(--muted); cursor: pointer; text-decoration: none; background-image: none; }
.btn-icon:hover, main .btn-icon:hover { background: var(--teal-soft); color: var(--teal-ink); transform: none; box-shadow: none; text-decoration: none; }
.btn-icon .icon { width: 17px; height: 17px; vertical-align: 0; }
/* Значки в заголовке столбца: окна «Освоения» */
main th:has(> .th-tools) { padding-right: 62px; }
.th-tools { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; gap: 2px; font-weight: 400; }
.th-tools .btn-icon { width: 22px; height: 22px; }
.th-tools .tk-reset { padding: 0 4px; line-height: 1; font-size: 14px; }
.th-tools .tk-reset-t { display: none; }
.th-seg { display: inline-flex; gap: 10px; vertical-align: middle; }
.th-seg a { color: var(--muted); font-weight: 500; text-decoration: none; background-image: none; }
.th-seg a:hover { color: var(--ink); }
.th-seg a.on { color: var(--teal-ink); font-weight: 700; }
.th-sortbtn { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; min-height: 0; margin-left: 8px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: var(--card); color: var(--muted); font-size: 11px; line-height: 1; cursor: pointer; box-shadow: none; vertical-align: middle; }
.th-sortbtn:hover { background: var(--teal-soft); border-color: var(--teal); transform: none; }
th.sort-btn-only { cursor: default; }
th.sort-btn-only:hover { color: inherit; }
@media (max-width: 760px) { .tb-row:not(:has(.tb-title)) { display: none; } }

/* «Участки»: длинные ФИО переносятся внутри ячейки, а не наезжают на соседнюю */
table.fin.dt-table td.dt-staff { overflow-wrap: break-word; min-width: 150px; }   /* anywhere сжимал столбец до одной буквы */
table.fin.dt-table td.dt-staff a { display: inline; white-space: normal; }
table.fin.dt-table th:first-child { white-space: nowrap; hyphens: none; }
/* Ширину столбца задал пользователь: она главнее содержимого */
table.cols-fixed { table-layout: fixed !important; }
table.cols-fixed th, table.cols-fixed td { max-width: none !important; min-width: 0 !important; overflow: hidden; text-overflow: ellipsis; }

/* Зазор между верхней полосой и спущенным верхом таблицы: 6px, как GAP в heads.js */
.fhead-gap { position: absolute; z-index: -1; left: calc(-1 * var(--fh-b, 0px) - var(--fh-x, 0px)); right: calc(-1 * var(--fh-b, 0px) - var(--fh-x, 0px));
  top: calc(-6px - var(--fh-b, 0px)); height: calc(6px + var(--fh-b, 0px) + var(--fh-r, 0px)); background: var(--fh-bg, var(--bg)); pointer-events: none; }

/* Сброс — рядом с названием; скачивание — в меню по щелчку на названии таблицы (tablebar.js) */
.tb-acts > .tk-reset { order: 0; }
[data-tb-menu] { cursor: pointer; }
[data-tb-menu]::after { content: '▾'; margin-left: 5px; font-size: 11px; font-weight: 400; color: var(--faint); }
[data-tb-menu]:hover::after { color: var(--teal); }
.tb-menu { position: fixed; z-index: 60; padding: 4px; background: var(--card, #fff); border: 1px solid var(--line, #E3E9EE); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .14); }
.tb-menu[hidden] { display: none; }
.tb-menu button { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border: 0; border-radius: 6px; background: none; color: inherit; font-size: 13px; white-space: nowrap; cursor: pointer; }
.tb-menu button:hover { background: var(--bg); }
.tb-menu .icon { width: 15px; height: 15px; }
@media (max-width: 760px) { [data-tb-menu] { cursor: default; pointer-events: none; } [data-tb-menu]::after { content: none; } }

/* Таблица без названия и других кнопок: строка нулевой высоты, сброс — значком над шапкой, таблица не прыгает и столбцы не закрыты */
.tb-row:not(:has(.tb-title)):not(:has(.tb-acts > :not(.tk-reset):not([hidden]))) { position: relative; height: 0; min-height: 0; margin: 0; z-index: 6; }
.tb-row:not(:has(.tb-title)):not(:has(.tb-acts > :not(.tk-reset):not([hidden]))) .tk-reset { position: absolute; right: 4px; bottom: 0; padding: 0 5px; line-height: 16px; }
.tb-row:not(:has(.tb-title)):not(:has(.tb-acts > :not(.tk-reset):not([hidden]))) .tk-reset-t { display: none; }
/* В раскрывающемся блоке (details) то, что выше содержимого, обрезается: сброс — обычной строкой над таблицей */
.hr-grp .tb-row { height: auto !important; min-height: 20px !important; }
.hr-grp .tb-row .tk-reset { position: static !important; margin-left: auto; }
/* Ручка целиком внутри своего столбца: половину снаружи закрывал соседний заголовок, а у последнего столбца она давала лишнюю полосу вбок */
th > .col-grip { right: 0; width: 8px; }

/* Карточки в ряд: одной высоты, вместе во всю ширину страницы. Широкий столбец не выталкивает соседа: листается окно */
@media (min-width: 761px) {
  .fit-row { align-items: stretch; }
  .fit-row > .card { display: flex; flex-direction: column; }
  .fit-row > .card:not(.ov-card):not(.fit-side) { flex: 1 1 0; width: auto; }
  .fit-row > .fit-side { flex: 0 1 auto; max-width: 50%; }
  .fit-row > .fit-side:has(table.cols-fixed) { flex: 0 0 34%; }
  .fit-row .tb-row { flex-wrap: nowrap; }
  .fit-row .tb-row .tk-reset-t { display: none; }
  .fit-row .tb-acts { flex: 0 0 auto; }
  .fit-row .fin-scroll { flex: 1 1 auto; min-height: 0; }
  .fit-row table.fin.fit-w:not(.cols-fixed) { width: 100%; }
  /* Шапки и строки соседних таблиц идут вровень */
  .fit-row table.fin.dt-table th, .fit-row table.fin.dt-table td { padding: 2px 7px; font-size: 11.5px; }
  .fit-row .fin-scroll table.fin thead th { height: 52px; }
}

/* Значок-кнопка, пока идёт работа: крутится */
.btn-icon.is-busy { pointer-events: none; color: var(--teal-ink); }
.btn-icon.is-busy .icon { animation: upq-spin 1.1s linear infinite; }

/* Карточка пациента: группы риска каждая с новой строки; карточки наблюдения — после таблиц */
.g-lines { white-space: pre-line; }
.pd-guides { margin-top: 24px; }
.adm-districts label { display: flex; align-items: center; gap: 6px; }
.adm-health { grid-template-columns: 300px 1fr; }
.adm-health dd.adm-warn { color: var(--amber-ink); }
.adm-note { white-space: pre-wrap; font-size: 12px; background: var(--line-soft); padding: 8px; border-radius: 8px; max-height: 200px; overflow: auto; }
.adm-mass { margin-bottom: 8px; }
.view-as, .site-notice { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 18px; font-size: 13.5px; }
.view-as { background: var(--amber-bg); color: var(--amber-ink); border-bottom: 1px solid var(--amber); }
.view-as form { margin: 0 0 0 auto; }
.site-notice { background: var(--teal-soft); color: var(--teal-ink); border-bottom: 1px solid var(--teal-dark); }
.adm-matrix td.adm-over { background: rgba(245, 166, 35, .14); }
.adm-matrix input[type=checkbox] { width: 16px; height: 16px; margin: 0; }
.role-pick { display: inline-flex; align-items: center; gap: 8px; margin: 4px 0 10px; font-weight: 600; }
.role-pick select { min-width: 220px; }
.adm-matrix.one-role { width: auto; min-width: 520px; }
.adm-matrix.one-role td.c, .adm-matrix.one-role th + th { width: 140px; text-align: center; }

/* Меню слева свёрнуто до иконок (sidebar.js): html[data-side] — только иконки, разворачивается кнопкой «›».
   Название раздела — плашка .side-tip рядом с иконкой при наведении; меню не анимируется. */
.side-ctl { margin-top: auto; padding-top: 12px; display: flex; gap: 6px; justify-content: flex-end; }
.side-ctl button { background: rgba(255, 255, 255, .06); border: 0; box-shadow: none; color: #BBD3DD; width: 32px; height: 32px; min-height: 0; padding: 0; border-radius: 9px; display: grid; place-items: center; }
.side-ctl button:hover { color: #fff; background: rgba(255, 255, 255, .12); transform: none; }
html:not([data-theme="dark"]) .side-ctl button { background: rgba(0, 0, 0, .05); color: var(--ink); }
html:not([data-theme="dark"]) .side-ctl button:hover { background: rgba(0, 0, 0, .09); }
.side-ctl .s-open { display: none; }
html[data-side] .side-ctl .s-shut { display: none; }
html[data-side] .side-ctl .s-open { display: grid; }
.side-tip { position: fixed; z-index: 1000; left: 0; top: 0; transform: translateY(-50%); pointer-events: none; opacity: 0; visibility: hidden;
  background: #0F2234; color: #fff; font-size: 13.5px; font-weight: 500; line-height: 1.2; white-space: nowrap; padding: 8px 12px; border-radius: 9px;
  border: 1px solid rgba(47, 180, 196, .45); box-shadow: 0 8px 24px rgba(0, 0, 0, .3); }
.side-tip::before { content: ""; position: absolute; left: -5px; top: 50%; width: 8px; height: 8px; margin-top: -4px; background: inherit;
  border-left: 1px solid rgba(47, 180, 196, .45); border-bottom: 1px solid rgba(47, 180, 196, .45); transform: rotate(45deg); }
.side-tip.on { opacity: 1; visibility: visible; }
@media (max-width: 900px) { .side-ctl, .side-tip { display: none; } }
@media (min-width: 901px) {
  html[data-side] .layout { grid-template-columns: 68px minmax(0, 1fr); }
  html[data-side] .sidebar { width: 68px; padding-left: 8px; padding-right: 8px; scrollbar-width: none; }
  html[data-side] .sidebar::-webkit-scrollbar { display: none; }
  html[data-side] .sidebar .brand { padding: 0 0 14px; justify-content: center; }
  html[data-side] .sidebar .brand span, html[data-side] .sidebar .nav-order { display: none; }
  html[data-side] .sidebar .nav-title { height: 0; padding: 0; margin: 8px 8px 6px; border-top: 1px solid rgba(255, 255, 255, .16); font-size: 0; }
  html[data-side] .sidebar .nav a { justify-content: center; padding: 10px 0; gap: 0; font-size: 0; }
  html[data-side] .sidebar .nav a .icon { width: 20px; height: 20px; }
  html[data-side] .sidebar .nav a .badge { position: absolute; margin: -18px 0 0 18px; font-size: 10px; }
  html[data-side] .sidebar .nav-gh { height: 0; padding: 0; margin: 8px 8px 6px; border-top: 1px solid rgba(255, 255, 255, .16); font-size: 0; }
  html[data-side] .sidebar .nav-gh i { display: none; }
  html[data-side] .sidebar .nav-group { margin-top: 0; }
  html[data-side] .sidebar .nav-group.shut .nav-gi { display: block; }
  html[data-side] .sidebar .side-ctl { flex-direction: column; align-items: center; }
  html:not([data-theme="dark"])[data-side] .sidebar .nav-title, html:not([data-theme="dark"])[data-side] .sidebar .nav-gh { border-top-color: var(--line); }
}

/* Мой профиль */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.profile-grid .props dt { color: var(--muted); }
.profile-mods { display: flex; flex-wrap: wrap; gap: 6px; }

/* Администрирование: единый вид страниц раздела */
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.crumbs a { color: var(--muted); }
.page-head .sub { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.adm-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.adm-grid2 > .card { margin: 0; min-width: 0; }
@media (max-width: 1100px) { .adm-grid2 { grid-template-columns: 1fr; } }
.adm-sub { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 1px; }
.adm-table td .adm-sub { line-height: 1.25; }
.adm-table tbody tr:hover td { background: var(--row-hover); }
.adm-table td.r.num { font-variant-numeric: tabular-nums; }
.adm-table .num { font-variant-numeric: tabular-nums; }
.adm-filters { align-items: center; }
.adm-filters .found { color: var(--muted); font-size: 13px; margin-left: auto; }
.adm-card-h { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.adm-card-h h3 { margin: 0; }
.adm-card-h .grow { flex: 1; }
.adm-ok { color: var(--muted); }
.adm-danger { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line-soft); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.adm-empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.adm-health dd { font-variant-numeric: tabular-nums; }

/* Освоение: фильтр по должности над списком исполнителей; карточка пациента: блоки диспансерного учёта */
.fin-pos { padding: 6px 8px 0; }
.fin-pos select { max-width: 100%; font-size: 12.5px; }
.pd-block { margin: 0 0 12px; }
.pd-block table.tight { margin: 0; }
#fs-btn .fs-on, #fs-btn[aria-pressed="true"] .fs-off { display: none; }
#fs-btn[aria-pressed="true"] .fs-on { display: inline; }
.std-cols ul { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.std-cols label { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.std-cols label:hover { background: var(--row-hover); }
.std-list { display: grid; grid-template-columns: 18px 1fr; gap: 0 8px; align-items: start; }
.std-list .muted { grid-column: 2; display: block; font-size: 12.5px; }
.profile-rights { margin-top: 10px; } .profile-rights summary { cursor: pointer; } .profile-rights ul { margin: 6px 0 0; padding-left: 18px; columns: 2; font-size: 13px; color: var(--muted); }

/* Карточка пользователя (administration/user_form.html, userform.js, distpick.js) */
.uf-layout { display: grid; grid-template-columns: minmax(0, 1060px); gap: 16px; align-items: start; }
.uf-layout.uf-has-side { grid-template-columns: minmax(0, 1fr) 340px; }
.uf-layout > .card, .uf-side > .card { margin: 0; }
.uf-side { display: grid; gap: 16px; }
@media (max-width: 1100px) { .uf-layout.uf-has-side { grid-template-columns: 1fr; } }
.uf { padding: 0; }
.uf-sec { padding: 20px 24px; border-bottom: 1px solid var(--line); }
.uf-sec h3 { margin: 0 0 14px; display: flex; align-items: baseline; gap: 12px; }
.uf-more { font-size: 12.5px; font-weight: 400; margin-left: auto; }
.uf-field { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin: 0 0 14px; }
.uf-field .muted { font-weight: 400; }
.uf-field > input, .uf-field > select, .uf-field > .dp, .uf-field > .uf-dist-text { display: block; width: 100%; margin-top: 6px; font-weight: 400; }
.uf-two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.uf-two .uf-field, .uf-sec > .uf-field:last-child { margin-bottom: 0; }
.uf-group { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin: 14px 0 8px; }
.uf-group:first-of-type { margin-top: 0; }
.uf-roles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 1500px) { .uf-has-side .uf-roles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .uf-roles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .uf-roles { grid-template-columns: 1fr; } }
.uf-role { position: relative; display: grid; grid-template-columns: 34px 1fr 18px; gap: 10px; align-items: center; padding: 10px 12px; margin: 0;
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: border-color .12s, background .12s; }
.uf-role:hover { border-color: var(--teal); }
.uf-role input { position: absolute; opacity: 0; pointer-events: none; }
.uf-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--line-soft); color: var(--muted); }
.uf-ic .icon { width: 18px; height: 18px; }
.uf-rt b { display: block; font-size: 14px; line-height: 1.25; }
.uf-rt small { display: block; color: var(--muted); font-size: 12px; line-height: 1.3; margin-top: 2px; }
.uf-tick { color: var(--teal); visibility: hidden; }
.uf-tick .icon { width: 18px; height: 18px; }
.uf-role:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); box-shadow: inset 0 0 0 1px var(--teal); }
.uf-role:has(input:checked) .uf-ic { background: var(--teal); color: #fff; }
.uf-role:has(input:checked) .uf-tick { visibility: visible; }
.uf-role:has(input:focus-visible) { outline: 2px solid var(--teal); outline-offset: 2px; }
.uf-wgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 16px; align-items: start; }
.uf-wgrid > .uf-field { margin-bottom: 0; }
.uf-wgrid > [hidden], .uf-field > .uf-dist-text[hidden] { display: none; }
.uf-where-wide .uf-wgrid { grid-template-columns: minmax(0, 1fr); }
.uf-mo-all { margin: 0; }
.uf-foot { display: flex; align-items: center; gap: 10px; padding: 16px 24px; flex-wrap: wrap; }
.uf-foot .muted { font-size: 12.5px; max-width: 420px; }
.uf-acts { display: grid; gap: 8px; margin-top: 12px; }
.uf-acts form { display: grid; gap: 2px; margin: 0; }
.uf-acts form button { width: 100%; justify-content: center; white-space: nowrap; }
.uf-acts small { font-size: 12px; text-align: center; }
.uf-side .props dd { white-space: nowrap; }
@media (max-width: 760px) { .uf-two, .uf-wgrid { grid-template-columns: 1fr; } .uf-two .uf-field { margin-bottom: 14px; } .uf-sec { padding: 16px; } }

/* Выбор участков: поле с плашками и выпадающий список с поиском */
.dp { position: relative; }
.dp[hidden] { display: none !important; }
.dp-field { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 42px; padding: 6px 36px 6px 10px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--card); cursor: pointer; position: relative; font-size: 14px; }
.dp-field:hover, .dp.open .dp-field { border-color: var(--teal); }
.dp-field:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.dp-ph { color: var(--faint); padding: 0 2px; }
.dp-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 9px; border-radius: 999px; background: var(--teal-soft); color: var(--teal-ink); font-weight: 600; font-size: 13px; }
.dp-chip i { font-style: normal; width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; line-height: 1; cursor: pointer; opacity: .7; }
.dp-chip i:hover { opacity: 1; background: rgba(0, 0, 0, .1); }
.dp-chev { position: absolute; right: 12px; top: 50%; width: 8px; height: 8px; margin-top: -6px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); }
.dp.open .dp-chev { transform: rotate(-135deg); margin-top: -2px; }
.dp-pop { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px); background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18); padding: 10px; }
.dp-find { width: 100%; margin: 0 0 8px; }
.dp-pop .dp-list { max-height: 260px; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px 8px; }
.dp-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 13.5px; margin: 0; }
.dp-row:hover { background: var(--row-hover, var(--line-soft)); }
.dp-row[hidden] { display: none; }
.dp-row input { margin: 0; flex: none; }
.dp-row:has(input:checked) { color: var(--teal-ink); font-weight: 600; }
.dp-empty { margin: 6px 8px; }
.dp-foot { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
html[data-theme="dark"] .dp-chip, html[data-theme="dark"] .dp-row:has(input:checked) { color: var(--teal); }
html[data-theme="dark"] .uf-role:has(input:checked) { background: rgba(47, 180, 196, .12); }

/* Участки сотрудников: таблица участок × роль (districtboard.js) */
.db-card { padding: 0; }
.db-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; background: var(--card); border-radius: 14px 14px 0 0; }
.db-filter { width: 240px; }
.db-state { min-width: 0; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.db-act { display: flex; align-items: center; gap: 10px; margin-left: auto; min-width: 0; }
.db-act > button { flex: none; }
.db-issue { margin-top: 14px; }
.db-issue summary { cursor: pointer; }
.db-issue details[open] summary { margin-bottom: 10px; }
.db-issue td, .db-issue th { vertical-align: middle; }
.db-issue th:first-child, .db-issue td:first-child { width: 36px; }
.db-issue-bar { display: flex; justify-content: flex-end; margin-top: 10px; }
.db-only { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin: 0; }
.db-wrap { overflow-x: auto; }
.db-table { margin: 0; table-layout: fixed; min-width: 980px; }
.db-table th:first-child { width: 160px; }
.db-table th:last-child { width: 300px; }
.db-table td { vertical-align: middle; }
.db-d b { font-size: 14px; }
.db-cell { cursor: pointer; }
.db-cell:hover { background: var(--row-hover, var(--line-soft)); }
.db-cell.db-open { box-shadow: inset 0 0 0 2px var(--teal); }
.db-cell.db-miss { background: rgba(229, 72, 77, .045); }
.db-reset[hidden], .db-guess[hidden] { display: none; }
.db-cell.db-changed { box-shadow: inset 3px 0 0 var(--teal); }
.db-cell.db-open.db-changed { box-shadow: inset 0 0 0 2px var(--teal); }
.db-chip { display: inline-flex; align-items: center; gap: 2px; margin: 2px 4px 2px 0; padding: 2px 3px 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--teal-soft); color: var(--teal-ink); white-space: nowrap; cursor: default; }
.db-chip.db-new { background: rgba(245, 166, 35, .16); color: #9A5B00; }
.db-chip i { font-style: normal; width: 17px; height: 17px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; opacity: .65; }
.db-chip i:hover { opacity: 1; background: rgba(0, 0, 0, .1); }
.db-add { width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 50%; border: 1px dashed var(--faint); background: transparent; color: var(--muted);
  box-shadow: none; font-size: 15px; line-height: 1; vertical-align: middle; opacity: 0;
  display: inline-grid; place-items: center; gap: 0; }
.db-add svg { width: 12px; height: 12px; display: block; }
.db-cell:hover .db-add, .db-cell.db-miss .db-add, .db-cell.db-open .db-add { opacity: 1; border-color: var(--teal); color: var(--teal); }
.db-add:hover { transform: none; background: var(--teal-soft); }
.db-eps { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-pop { position: absolute; z-index: 60; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 36px rgba(0, 0, 0, .22); padding: 10px; }
.db-find { width: 100%; margin: 0 0 8px; }
.db-list { max-height: 300px; overflow: auto; display: grid; gap: 2px; }
.db-opt { display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; align-items: center; text-align: left; width: 100%; padding: 7px 8px; min-height: 0;
  background: transparent; border: 0; box-shadow: none; color: var(--ink); border-radius: 8px; font-weight: 400; }
.db-opt:hover { background: var(--row-hover, var(--line-soft)); transform: none; }
.db-opt.on { background: var(--teal-soft); }
.db-tick { color: var(--teal); font-weight: 700; }
.db-ob b { display: block; font-size: 13.5px; font-weight: 600; }
.db-ob small { display: block; font-size: 11.5px; color: var(--muted); }
.db-tag { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: rgba(47, 180, 196, .14); color: var(--teal-ink); white-space: nowrap; }
.db-hint { margin: 6px 4px 0; font-size: 12px; }
.db-hint:empty { display: none; }
.db-excel { margin-top: 14px; }
.db-excel summary { cursor: pointer; font-weight: 600; }
.db-excel[open] summary { margin-bottom: 10px; }
html[data-theme="dark"] .db-chip, html[data-theme="dark"] .db-tag { color: var(--teal); }
html[data-theme="dark"] .db-chip.db-new { color: #F5B547; }
html[data-theme="dark"] .db-opt.on { background: rgba(47, 180, 196, .14); }
/* «По сотрудникам»: люди слева, участки галочками справа */
.db-mode { flex: none; }
.db-filter[hidden], .db-only[hidden], .db-wrap[hidden], .db-pp[hidden], .db-pp-body[hidden], .db-pp-empty[hidden], .db-pp-d[hidden] { display: none; }
.db-pp { display: grid; grid-template-columns: minmax(260px, 330px) 1fr; min-height: 420px; }
.db-pp-left { border-right: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.db-pp-find { width: 100%; margin: 0; }
.db-pp-list { overflow: auto; max-height: 68vh; display: block; }
.db-pp-h { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 10px 6px 3px; }
.db-pp-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; text-align: left; width: 100%; padding: 7px 9px; min-height: 0;
  height: auto; margin: 0 0 2px; white-space: normal; line-height: 1.3;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink); box-shadow: none; font-weight: 400; }
.db-pp-item:hover { background: var(--row-hover, var(--line-soft)); transform: none; }
.db-pp-item.on { background: var(--teal-soft); }
.db-pp-n { font-size: 12px; font-weight: 700; color: var(--teal); min-width: 20px; text-align: right; }
.db-pp-n.zero { color: var(--faint); font-weight: 400; }
.db-pp-right { padding: 14px 18px; min-width: 0; }
.db-pp-empty { margin: 40px 0; text-align: center; }
.db-pp-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.db-pp-name b { display: block; font-size: 16px; }
.db-pp-name small { display: block; font-size: 12px; }
.db-pp-role { width: auto; margin: 0; }
.db-pp-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.db-pp-dfind { width: 160px; margin: 0; }
.db-pp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.db-pp-d { display: flex; gap: 8px; align-items: flex-start; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; margin: 0;
  font-size: 13px; font-weight: 600; }
.db-pp-d:hover { border-color: var(--teal); }
.db-pp-d.on { background: var(--teal-soft); border-color: var(--teal); }
.db-pp-d input { margin: 2px 0 0; flex: none; }
.db-pp-dt small { display: block; font-size: 11.5px; font-weight: 400; }
.db-pp-free { color: #C2410C; }
html[data-theme="dark"] .db-pp-item.on, html[data-theme="dark"] .db-pp-d.on { background: rgba(47, 180, 196, .14); }
@media (max-width: 760px) { .db-pp { grid-template-columns: 1fr; } .db-pp-left { border-right: 0; border-bottom: 1px solid var(--line); } }

/* Свод дефектов: группировка и меню «Столбцы» (sections.js) */
.dv-by { align-items: center; gap: 10px; }
.dv-lbl { font-size: 13px; }
.dv-path { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.dv-pill { padding: 4px 12px; border-radius: 999px; background: var(--teal-soft); color: var(--teal-ink); font-weight: 600; font-size: 13px; }
.dv-sep { color: var(--faint); }
.dv-cfg { position: relative; }
.dv-cfg > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.dv-cfg > summary::-webkit-details-marker { display: none; }
.dv-cfg > summary .icon { width: 15px; height: 15px; }
.dv-pop { position: absolute; z-index: 40; left: 0; top: calc(100% + 8px); width: 360px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 16px 40px rgba(0, 0, 0, .22); padding: 14px; }
.dv-pop-h { display: grid; gap: 2px; margin-bottom: 10px; }
.dv-pop-h small { font-size: 12px; }
.dv-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.dv-item { display: grid; grid-template-columns: 14px 20px 1fr auto; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--card); }
.dv-item.on { border-color: var(--teal); background: var(--teal-soft); }
.dv-item.drag { opacity: .45; }
.dv-item label { display: flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; font-size: 13.5px; font-weight: 600; }
.dv-item input { margin: 0; }
.dv-grip { color: var(--faint); cursor: grab; font-size: 12px; letter-spacing: -2px; user-select: none; }
.dv-mv { display: inline-flex; gap: 2px; }
.dv-mv button { width: 26px; height: 26px; min-height: 0; padding: 0; border-radius: 7px; background: transparent; border: 1px solid var(--line);
  box-shadow: none; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.dv-mv button .icon { width: 14px; height: 14px; }
.dv-mv .dv-up .icon { transform: rotate(-90deg); }
.dv-mv .dv-down .icon { transform: rotate(90deg); }
.dv-mv button:hover:not(:disabled) { color: var(--teal); border-color: var(--teal); transform: none; }
.dv-mv button:disabled { opacity: .3; cursor: default; }
.dv-no { width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; color: #fff; background: var(--teal); }
.dv-no:empty { background: transparent; }
.dv-presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12.5px; }
.dv-presets .chip { background: var(--line-soft); color: var(--ink); font-weight: 500; text-decoration: none; }
.dv-presets .chip:hover, .dv-presets .chip.on { background: var(--teal-soft); color: var(--teal-ink); }
.dv-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.dv-def { font-size: 12.5px; }
html[data-theme="dark"] .dv-pill, html[data-theme="dark"] .dv-presets .chip.on, html[data-theme="dark"] .dv-presets .chip:hover { color: var(--teal); }
html[data-theme="dark"] .dv-item.on { background: rgba(47, 180, 196, .12); }
@media (max-width: 760px) {
  .dv-by { overflow: visible; flex-wrap: wrap; }
  .dv-pop { position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; }
}

/* Полный экран вышел при переходе: подсказка внизу (base.html, ui-fs) */
.fs-tip { position: fixed; z-index: 900; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 16px; border-radius: 12px; background: #0F2234; color: #E6F3F6; border: 1px solid rgba(47, 180, 196, .45);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3); font-size: 13px; max-width: calc(100vw - 32px); }
@media print { .fs-tip { display: none; } }

/* ===== Шапка и меню отделены от страницы: свой оттенок, граница и тень (содержимое не сливается с подписями шапки) ===== */
.topbar { box-shadow: 0 1px 0 var(--line), 0 6px 16px -10px rgba(16, 35, 58, .35); }
.tb-title h1 { color: var(--ink); letter-spacing: -.01em; }
.tb-title h1::before { content: ''; display: inline-block; width: 4px; height: 18px; margin-right: 10px; border-radius: 2px; background: var(--teal); vertical-align: -3px; }
:root[data-theme="dark"] .topbar { background: linear-gradient(180deg, #1A3044 0%, #16293B 100%); border-bottom: 1px solid rgba(92, 203, 216, .22);
  box-shadow: 0 8px 22px -8px rgba(0, 0, 0, .65); }
:root[data-theme="dark"] .sidebar { background: linear-gradient(180deg, #0A1622 0%, #0C1C2B 100%); border-right: 1px solid rgba(92, 203, 216, .18);
  box-shadow: 6px 0 20px -12px rgba(0, 0, 0, .7); }
:root[data-theme="dark"] .sidebar .nav a.on { box-shadow: inset 3px 0 0 var(--teal-dark), inset 0 0 0 1px rgba(47, 180, 196, .28); }
:root[data-theme="dark"] .topbar select, :root[data-theme="dark"] .topbar .zoom-ctl, :root[data-theme="dark"] .topbar .theme-btn,
:root[data-theme="dark"] .topbar .user-menu summary { background-color: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .12); }
/* раскрытый список рисуется по фону самого поля — у полупрозрачного выходил белый с белым текстом */
:root[data-theme="dark"] select option, :root[data-theme="dark"] select optgroup { background-color: var(--card); color: var(--ink); }

/* «Освоение»: факт — главное число (жирный, светлый), план — справочный (серый, обычный). Без подложки: строки разных уровней
   красятся по-разному, и подложка столбца выходила шахматной */
table.fin-table[data-tree="lots"] > tbody > tr > td:nth-child(3), table.fin-table[data-tree="lots"] > tbody > tr > td:nth-child(3) *,
table.fin-table[data-tree="lots"] > tfoot > tr > td:nth-child(3), table.fin-table[data-tree="lots"] > tfoot > tr > td:nth-child(3) * { color: var(--ink); font-weight: 700; }
table.fin-table[data-tree="lots"] > tbody > tr.fin-side > td:nth-child(3), table.fin-table[data-tree="lots"] > tbody > tr.fin-side > td:nth-child(3) * { font-weight: 600; }
table.fin-table[data-tree="lots"] > thead > tr > th:nth-child(3), table.fin-table[data-tree="lots"] > thead > tr > th:nth-child(3) * { color: var(--teal-dark); font-weight: 700; }
table.fin-table[data-tree="lots"] > tbody > tr > td:nth-child(4), table.fin-table[data-tree="lots"] > tbody > tr > td:nth-child(4) *,
table.fin-table[data-tree="lots"] > tfoot > tr > td:nth-child(4), table.fin-table[data-tree="lots"] > tfoot > tr > td:nth-child(4) * { color: var(--faint); font-weight: 400; }

/* ===== Соисполнители (finance/coexecutors.html, coexecutor.html) ===== */
.cx-bar { padding: 10px 14px; margin-bottom: 14px; }
.cx-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cx-filters .cx-q { min-width: 180px; flex: 1 1 180px; max-width: 320px; }
.cx-counts { margin-bottom: 14px; }
.cx-table { width: 100%; }
.cx-table td:first-child a { color: var(--ink); font-weight: 600; }
.cx-table td:first-child a:hover { color: var(--teal-dark); }
.cx-share { white-space: nowrap; }
.cx-bar-i { display: inline-block; width: 60px; height: 6px; margin-right: 8px; border-radius: 3px; background: var(--line-soft); vertical-align: middle; overflow: hidden; }
.cx-bar-i i { display: block; height: 100%; background: var(--teal); border-radius: 3px; }
.cx-top { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr); gap: 14px; margin-bottom: 14px; align-items: start; }
.cx-top .card, .cx-top .counts { margin: 0; }
.cx-top .counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cx-rename label { display: block; font-weight: 600; margin-bottom: 6px; }
.cx-rename-row { display: flex; gap: 8px; }
.cx-rename-row input { flex: 1; font-size: 15px; font-weight: 600; }
.cx-rename small { display: block; margin-top: 6px; }
.cx-raw-h { margin: 14px 0 6px; font-weight: 600; font-size: 13px; color: var(--muted); }
.cx-raw { list-style: none; margin: 0; padding: 0; }
.cx-raw li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line-soft); font-size: 13px; }
.cx-raw li > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-raw li .muted { white-space: nowrap; font-size: 12px; }
.cx-raw form { margin: 0; }
.cx-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.cx-side .an-card + .an-card { margin-top: 0; }
@media (max-width: 900px) { .cx-top { grid-template-columns: 1fr; } }

/* «Освоение»: выбор должности над таблицей направителей — по размеру текста, а не во всю ширину */
.fin-people .fin-pos { padding: 8px 10px 4px; }
.fin-people .fin-pos select { width: auto; min-width: 200px; max-width: min(320px, 100%); padding-top: 4px; padding-bottom: 4px; }
/* строка над таблицей: фильтры-списки и «Найти в таблице» одной высоты и одного шрифта */
.tb-acts .tbl-filters .msel-btn { height: 30px; min-height: 30px; padding: 4px 10px; font-size: 13px; box-sizing: border-box; }
.tb-acts .tf-input { height: 30px; box-sizing: border-box; }

/* «Диспансеризация»: «Не охвачены» — красноватая, «Охвачены» — зеленоватая; точка цвета, число строк справа.
   Выбранная — сплошным своим цветом (вместо общего зелёного выбора) */
.dp-tabs a { display: flex; align-items: center; gap: 10px; }
.dp-tabs a > span { flex: 1; }
.dp-tabs a.dp-t-missing { --t: var(--red); --t-bg: var(--red-bg); --t-ink: var(--red-ink); }
.dp-tabs a.dp-t-waiting { --t: var(--green); --t-bg: var(--green-bg); --t-ink: var(--green-ink); }
.dp-tabs a:is(.dp-t-missing, .dp-t-waiting)::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--t); flex: none; }
/* невыбранная — серая, как остальные вкладки: цвет только у точки и числа; выбранная — рамка и мягкий фон своего цвета */
:root:root:root .dp-tabs a:is(.dp-t-missing, .dp-t-waiting):not(.on):hover { border-color: color-mix(in srgb, var(--t) 50%, transparent); }
:root:root:root .dp-tabs a:is(.dp-t-missing, .dp-t-waiting).on { background: color-mix(in srgb, var(--t) 13%, var(--card));
  border-color: var(--t); color: var(--t-ink); font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--t), 0 4px 12px -6px color-mix(in srgb, var(--t) 60%, transparent); }
.dp-n { font-variant-numeric: tabular-nums; font-size: 12.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--t) 16%, transparent); color: var(--t); }
.dp-tabs a.on .dp-n { background: color-mix(in srgb, var(--t) 22%, transparent); }

/* Заголовок таблицы цветом вкладки: красный — не охвачены / вызвать, зелёный — охвачены (видно при прокрутке) */
.tt-bad, .tt-good { display: inline-flex; align-items: center; gap: 8px; }
.tt-bad { color: var(--red); } .tt-good { color: var(--green); }
.tt-bad::before, .tt-good::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

/* ===== «Мой день» (главная врача и медсестёр) ===== */
.md-top { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
@media (max-width: 1000px) { .md-top { grid-template-columns: 1fr; } }
.md-cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.md-cal-head b { font-size: 15px; min-width: 120px; text-align: center; }
.md-cal-head .grow { flex: 1; }
.md-now { font-size: 12.5px; }
.md-legend { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.md-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-left: 6px; }
.md-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.md-wd { font-size: 11.5px; color: var(--muted); text-align: center; padding: 2px 0 4px; }
.md-day { display: flex; flex-direction: column; align-items: stretch; gap: 3px; min-height: 58px; padding: 5px 6px; border-radius: 10px;
  border: 1px solid var(--line-soft); background: none; color: var(--ink); cursor: pointer; text-align: left; font: inherit; transform: none; box-shadow: none; }
.md-day:hover { border-color: var(--line); background: var(--x-bg-F4F7FA, rgba(127, 127, 127, .06)); transform: none; }
.md-day.out { opacity: .35; cursor: default; }
.md-day.now .md-n { background: var(--pick); color: #fff; border-radius: 999px; padding: 0 7px; }
.md-day.on { border-color: var(--pick); box-shadow: inset 0 0 0 1px var(--pick); }
.md-n { font-size: 12.5px; font-weight: 600; align-self: flex-start; line-height: 20px; }
.md-ind { display: flex; flex-wrap: wrap; gap: 3px; }
.md-ind i { font-style: normal; font-size: 11px; font-weight: 700; line-height: 16px; padding: 0 5px; border-radius: 999px; font-variant-numeric: tabular-nums; }
i.md-b { background: color-mix(in srgb, var(--pick) 16%, transparent); color: var(--pick); }
i.md-d { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
i.md-s { background: color-mix(in srgb, var(--teal) 22%, transparent); color: var(--teal); font-weight: 700; }
.md-legend i.md-s { background: var(--teal); }
.md-ev-seen { background: color-mix(in srgb, var(--teal) 18%, transparent); color: var(--teal); }
i.md-m { background: var(--line-soft); color: var(--muted); }
.md-legend i.md-b { background: var(--pick); } .md-legend i.md-d { background: var(--green); } .md-legend i.md-m { background: var(--muted); }
.md-sub { font-size: 12px; margin-top: 1px; }
.md-act { text-align: right; white-space: nowrap; width: 1%; }
.md-rem { margin-top: 10px; font-size: 13px; }
.md-rem-h { font-weight: 600; }
.md-rem ul { margin: 4px 0 0; padding-left: 18px; max-height: 220px; overflow: auto; }
.md-side { display: flex; flex-direction: column; gap: 16px; }
.md-side .card { margin: 0; }
.md-day-card, .md-calls { margin-bottom: 16px; }
.md-list { margin: 0; border: 0; padding: 0; }
.md-scroll { margin-top: 10px; max-height: 420px; }
:root .md-tbl { table-layout: auto; width: 100%; }
:root .md-tbl td { vertical-align: middle; white-space: normal; overflow: visible; text-overflow: clip; max-width: 360px; }
:root .md-tbl td:nth-child(2), :root .md-day-card .md-tbl td:nth-child(5), :root .md-calls .md-tbl td:is(:nth-child(4), :nth-child(8)) { white-space: nowrap; }
:root .md-tbl td:first-child { min-width: 180px; } :root .md-calls .md-tbl td:nth-child(3) { min-width: 120px; }
.md-ev { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.md-ev-booked { background: color-mix(in srgb, var(--pick) 16%, transparent); color: var(--pick); }
.md-ev-done { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.md-calls .md-scroll { max-height: none; }

/* Клин. протоколы → «Внутренний контроль» */
.kc-head h2 { margin: 0 0 12px; }
.kc-code { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--teal); margin-bottom: 2px; }
.kc-props { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 24px; margin: 0 0 4px;
  padding: 12px 14px; border-radius: 10px; background: var(--line-soft); }
.kc-props .wide { grid-column: 1 / -1; }
.kc-props dt { font-size: 12px; color: var(--muted); margin: 0; }
.kc-props dd { margin: 2px 0 0; font-weight: 600; }
.kc-sec { font-size: 17px; margin: 18px 0 8px; }
.kc-goal { font-size: 13px; margin-top: 2px; }
.kc-head h3 { margin: 16px 0 6px; font-size: 15px; }
.kc-what { font-size: 15px; font-weight: 600; margin: 0; }
.kc-how { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.kc-laws { margin: 0; padding-left: 18px; }
.kc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.kc-chips .chip { text-decoration: none; background: var(--line-soft); color: var(--ink); font-weight: 500; }
.kc-chips .chip:hover, .kc-chips .chip.on { background: var(--teal-soft); color: var(--teal-ink); }
html[data-theme="dark"] .kc-chips .chip:hover, html[data-theme="dark"] .kc-chips .chip.on { color: var(--teal); }
.kc-filter { width: 100%; max-width: 360px; margin: 0 0 10px; }
.kc-search input, .kc-head + .card .toolbar input { flex: 1; max-width: 520px; }
.kc-table td:first-child { white-space: nowrap; }
.sc-table td[data-ci="why"] { white-space: normal; min-width: 340px; max-width: 460px; line-height: 1.3; }   /* реабилитация: причина словами */
.rh-o116 td.rh-dc { white-space: nowrap; }
.rh-o116 th small { font-weight: 400; }
/* Карточка диагноза: шапка без плиток — протоколы строками, «Входит в» — только то, что относится */
.kp-dx-row { display: flex; gap: 14px; padding: 8px 0 0; align-items: baseline; }
.kp-dx-l { flex: 0 0 96px; color: var(--muted); font-size: 13px; }
.kp-dx-v { flex: 1; min-width: 0; }
.kp-pline { padding: 2px 0; }
.kp-pline a { font-weight: 600; text-decoration: none; }
.kp-pline.old { opacity: .7; }
.kp-dx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.kp-in { border: 1px solid var(--line); border-radius: 8px; padding: 3px 9px; font-size: 13px; }
.kp-in.kp-goto { cursor: pointer; }
.kp-in.kp-goto:hover, .kp-in.kp-goto.on { border-color: var(--teal); }
.kp-in-no { color: var(--muted); border-style: dashed; }
.kp-dx-more { margin: 0; font-size: 13px; }
.kp-dx-more summary { cursor: pointer; color: var(--muted); }
@media (max-width: 700px) { .kp-dx-row { flex-direction: column; gap: 2px; } .kp-dx-l { flex: none; } .kp-dx-more { margin-left: 0; } }
.kp-dx-chips:not(:has(.kp-in))::before { content: "—"; color: var(--muted); }
/* Шапка карточек диагноза и услуги — таблицами: протоколы и стандарты рядом */
.kp-dx-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-top: 10px; align-items: start; }
@media (max-width: 1200px) { .kp-dx-grid { grid-template-columns: minmax(0, 1fr); } }
.kp-dx-t { width: 100%; font-size: 13.5px; }
.kp-dx-t td, .kp-dx-t th { vertical-align: top; }
.kp-dx-t .kp-n { width: 1%; white-space: nowrap; }
.kp-dx-t .kp-d { width: 1%; white-space: nowrap; }
.kp-dx-t .kp-yes { width: 1%; white-space: nowrap; font-weight: 600; }
.kp-dx-t td:first-child { min-width: 180px; }
.kp-dx-t tr.kp-no td { color: var(--muted); }
.kp-dx-t tr.kp-no .kp-yes { font-weight: 400; }
.kp-dx-t tr.kp-old td { opacity: .7; }
.kp-dx-t tr.kp-goto { cursor: pointer; }
.kp-dx-t tr.kp-goto:hover td, .kp-dx-t tr.kp-goto.on td { background: var(--row-hover, var(--line-soft)); }
.kp-dx-t tr.kp-goto td:first-child::after { content: " ↓"; color: var(--teal); }
/* Верх карточек: куда входит — карточками (✓), куда нет — одной серой строкой; протоколы — свёрнутым списком */
.kp-where { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin: 12px 0 6px; }
.kp-w { border: 1px solid var(--line); border-left: 3px solid var(--teal); border-radius: 12px; padding: 10px 12px; background: var(--card); }
.kp-w.kp-goto { cursor: pointer; }
.kp-w.kp-goto:hover, .kp-w.kp-goto.on { box-shadow: 0 0 0 2px var(--teal-soft); }
.kp-w-t { font-size: 12.5px; color: var(--muted); display: flex; align-items: baseline; gap: 5px; }
.kp-w-t small { font-size: 11.5px; opacity: .8; }
.kp-w-ok { color: var(--teal); font-weight: 700; }
.kp-w-v { font-weight: 600; font-size: 15px; margin: 3px 0 2px; color: var(--ink); }
.kp-w-d { margin: 4px 0 0; padding: 0 0 0 16px; font-size: 12.5px; color: var(--muted); }
.kp-w-go { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--teal); }
.kp-w-off { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.kp-w-off span { font-weight: 600; }
.kp-sub { margin: 4px 0 0; }
.kp-plist { margin-top: 12px; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.kp-plist summary { cursor: pointer; font-weight: 600; }
.kp-pl { padding: 4px 0; display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.kp-pl a { text-decoration: none; }
.kp-pl.old { opacity: .7; }
/* Услуги протокола в карточке диагноза: столбцы вместо цветных плашек в каждой строке */
.kp-svc-t td { vertical-align: top; }
.kp-svc-t tr.kp-first td { border-top: 1px solid var(--line); }
.kp-svc-t td.kp-concept { width: 22%; }
.kp-svc-t .kp-code-c, .kp-svc-t .kp-lv-c { white-space: nowrap; width: 1%; }
.kp-svc-t .kp-lv-c { color: var(--muted); font-size: 12.5px; }
.kp-svc-t .kp-c { text-align: center; width: 1%; white-space: nowrap; }
.kp-yes-m { color: var(--teal); font-weight: 700; }
.kp-no-m { color: var(--red, #d64545); font-size: 12.5px; }
.kp-svc-t .kp-fix { display: inline; }
.kp-where { align-items: start; }
.kp-w-t { flex-wrap: wrap; }
/* Клинический протокол — один сворачиваемый блок, разделы внутри */
.kp-subsec { margin-top: 10px; }
.kp-subsec > summary { cursor: pointer; list-style: revert; }
.kp-subsec > summary h4 { display: inline; margin: 0; font-size: 15px; }
.kp-sec > .kp-level { margin-top: 8px; }
/* Карточка диагноза, верх: небольшие таблицы по темам, по пункту в строке */
.kp-mini { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 12px; margin-top: 10px; align-items: start; }
.kp-mt { width: 100%; font-size: 13.5px; }
.kp-mt th { text-align: left; }
.kp-mt td { vertical-align: top; }
.kp-mt .kp-mt-r { text-align: right; white-space: nowrap; width: 1%; }
.kp-mt tr.kp-no td { color: var(--muted); }
.kp-mt tr.kp-old td { opacity: .7; }
.kp-mt tr.kp-goto { cursor: pointer; }
.kp-mt tr.kp-goto td:first-child::after { content: " ↓"; color: var(--teal); }
.kp-mt tr.kp-goto:hover td, .kp-mt tr.kp-goto.on td { background: var(--row-hover, var(--line-soft)); }
/* Карточка диагноза: квадраты одного размера — стандарт, короткий ответ, пояснение; клик раскрывает раздел ниже */
.kp-sq-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
@media (max-width: 1100px) { .kp-sq-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kp-sq { border: 1px solid var(--line); border-top: 3px solid var(--teal); border-radius: 12px; padding: 10px 12px; min-height: 88px; background: var(--card); }
.kp-sq.off { border-top-color: var(--line); background: transparent; }
.kp-sq.off .kp-sq-v { color: var(--muted); font-weight: 500; }
.kp-sq-l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.kp-sq-v { font-size: 18px; font-weight: 700; margin: 4px 0 2px; color: var(--ink); }
.kp-sq-s { font-size: 12.5px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.kp-sq.kp-goto { cursor: pointer; }
.kp-sq.kp-goto:hover, .kp-sq.kp-goto.on { box-shadow: 0 0 0 2px var(--teal-soft); }
.kp-sq.kp-goto .kp-sq-l::after { content: " ↓"; color: var(--teal); }
.kp-plist-t .kp-nw { white-space: nowrap; width: 1%; }
/* Карточка диагноза/услуги в духе Apple: заголовок прямо на странице, активные плитки — белые с мягкой тенью,
   цвет только в подписи; неактивные — без рамки и тени, отходят на второй план */
.card.kp-dx { background: transparent; border: 0; box-shadow: none; padding: 0; overflow: visible; }
.kp-dx > .card-head { display: flex; align-items: center; gap: 12px; padding: 4px 2px 0; margin: 0; background: none; border: 0; }
.kp-dx > .card-head h2 { font-size: 13px !important; font-weight: 600; color: var(--teal-dark); background: var(--teal-soft);
  padding: 4px 10px; border-radius: 999px; letter-spacing: .02em; }
.kp-dx > .card-head > span { font-size: 22px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
.kp-dx > .kp-sq-grid { margin: 0; padding: 16px 0 4px; gap: 12px; }
.kp-dx > :not(.card-head):not(.kp-sq-grid) { margin-left: 2px; margin-right: 2px; }
.kp-sq { display: flex; flex-direction: column; border: 0; border-radius: 16px; padding: 14px 16px; min-height: 96px; position: relative; }
.kp-sq:not(.off) { background: var(--card); box-shadow: 0 1px 2px rgba(16,35,58,.06), 0 6px 18px rgba(16,35,58,.07); }
.kp-sq.off { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.kp-sq-l { font-size: 13px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.kp-sq:not(.off) .kp-sq-l { color: var(--teal-dark); }
.kp-sq.off .kp-sq-l { color: var(--faint); font-weight: 500; }
.kp-sq-v { font-size: 22px; font-weight: 600; letter-spacing: -.01em; margin: 6px 0 2px; }
.kp-sq:not(.off) .kp-sq-v { color: var(--ink); }
.kp-sq.off .kp-sq-v { font-size: 17px; color: var(--faint); font-weight: 500; }
.kp-sq-s { color: var(--muted); }
.kp-sq.kp-goto .kp-sq-l::after { content: ""; }
.kp-sq.kp-goto:not(.off)::after { content: "›"; position: absolute; top: 10px; right: 14px; font-size: 22px; line-height: 1; color: var(--faint); }
.kp-sq.kp-goto:not(.off) { transition: transform .15s ease, box-shadow .15s ease; }
.kp-sq.kp-goto:not(.off):hover, .kp-sq.kp-goto.on:not(.off) { transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(16,35,58,.06), 0 12px 28px rgba(16,35,58,.12); }
.kp-sq.kp-goto.on:not(.off) { box-shadow: 0 0 0 2px var(--teal), 0 12px 28px rgba(16,35,58,.12); }
/* Кнопка «Наверх» */
.to-top { position: fixed; right: 24px; bottom: 24px; z-index: 50; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: var(--card); color: var(--teal-dark); font-size: 20px; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 6px rgba(16,35,58,.12), 0 8px 24px rgba(16,35,58,.14);
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s; }
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { background: var(--teal-soft); }
@media print { .to-top { display: none; } }
/* Ширины столбцов в таблицах карточек — в CSS, а не в style="": таблица с настройкой ширины (tablekit)
   сбрасывает style у заголовков. Своя ширина пользователя (перетаскиванием) по-прежнему важнее. */
.kp-149 { table-layout: fixed; min-width: 960px; }
.kp-149 th:nth-child(1) { width: 13%; }
.kp-149 th:nth-child(2) { width: 11%; }
.kp-149 th:nth-child(3) { width: 25%; }
.kp-149 th:nth-child(5) { width: 9%; }
.kp-o27-t th.kp-col-item { width: 30%; }
.kp-table th.kp-col-proto { width: 30%; }
/* Карточка пациента: социальный статус — отметки участкового */
.pd-soc { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.pd-soc summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }
.pd-soc[open] summary { margin-bottom: 6px; }
.pd-soc-g { display: grid; gap: 2px; margin-bottom: 8px; }
.pd-soc-g b { font-size: 12px; color: var(--ink); }
.pd-soc-g label.pd-check { color: var(--ink); font-size: 13px; }
.pd-soc input[type=checkbox] { width: auto; margin: 0; }
/* «Стандарты → Шаблоны осмотров» */
.vt-group { margin: 18px 0 8px; font-size: 15px; color: var(--muted); font-weight: 600; }
.vt summary { display: flex; align-items: center; gap: 10px; }
.vt summary h3 { margin: 0; }
.vt-copy { margin-left: auto; }
.vt-copy.done { background: var(--teal-soft); color: var(--teal-ink); }
.vt-text { width: 100%; box-sizing: border-box; margin-top: 10px; font: 13.5px/1.5 inherit; font-family: inherit; resize: vertical; }
.vt-actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.kp-subbar { justify-content: flex-start; margin: 8px 0 2px; }
/* «Участки → Паспорт участка» */
.pp-bar { display: flex; gap: 12px; align-items: center; }
.pp-card { max-width: 900px; }
.pp-t td { padding: 6px 10px; }
.pp-t .pp-n { width: 40px; color: var(--muted); text-align: center; }
.pp-t .pp-v { width: 120px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.pp-t tr.pp-main td { border-top: 1px solid var(--line); }
.pp-t tr.pp-sub td:nth-child(2) { padding-left: 28px; color: var(--muted); }
.pp-t tr.pp-sub .pp-v { font-weight: 500; }
.pp-staff { margin: 14px 0 4px; }
.pp-note { margin: 4px 0 0; font-size: 12.5px; }

/* «Аналитика услуг» → «Услуги пациентов»: список или свод */
.pv-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pv-sum { max-height: 480px; }   /* около 15 строк, дальше — прокрутка */
.pv-by { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0; }
.pv-by .chip { text-decoration: none; }
.pv-tools { margin-left: auto; display: flex; gap: 12px; }
.pv-num { display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; margin-right: 2px; border-radius: 8px;
  background: var(--teal, #1aa3a3); color: #fff; font-size: 11px; line-height: 1; }
/* матрица свода: вложенные строки с отступом, свёрнутые скрыты */
table.mx .mx-pad { display: inline-block; width: calc(var(--lv, 0) * 18px); }
table.mx .mx-tg, table.mx .mx-tg-sp { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 6px;
  vertical-align: middle; }
table.mx .mx-tg { border: 1px solid var(--line, #3a4a5a); border-radius: 4px; background: transparent; color: inherit;
  font-size: 12px; line-height: 1; cursor: pointer; padding: 0; }
table.mx tr.mx-l0 td { font-weight: 600; }
table.mx tr:not(.mx-l0) td:first-child a { opacity: .92; }
table.mx td:first-child { text-overflow: ellipsis; }
table.mx td:first-child a { color: var(--ink); }
/* заголовки свода — обычный текст заголовка (и в закреплённой при прокрутке копии), стрелка у выбранного */
.mx-sort { cursor: pointer; user-select: none; white-space: nowrap; border-radius: 4px; }
.mx-sort:hover { color: var(--teal-dark); }
.mx-sort:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ring); }
.mx-sort.on { color: var(--teal-dark); }
.mx-sort[data-arrow]:not([data-arrow=""])::after { content: " " attr(data-arrow); font-size: .8em; }
table.mx .mx-tg:disabled { opacity: .6; cursor: progress; }
table.mx tr.mx-more td { font-size: 11.5px; }
.an-picks-row { grid-column: 1 / -1; }
.an-picks-row .an-picks { margin: 0; }
/* выбранные строки — и в верхней полосе, рядом с фильтрами */
.tb-picks { display: flex; gap: 6px; align-items: center; min-width: 0; overflow: hidden; }
.tb-picks .chip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; flex: 0 1 auto; }
.tb-picks { max-width: 38vw; }
/* «Какие фильтры показывать»: пользователь сам убирает и возвращает поля фильтров (запоминается в браузере) */
.flt-cfg { grid-column: 1 / -1; position: relative; justify-self: end; }
.flt-cfg-btn { font-size: 12.5px; }
.flt-cfg-pop[hidden] { display: none; }
.flt-cfg-pop { max-height: min(70vh, 520px); overflow: auto; }
.flt-cfg-pop label[hidden] { display: none; }
.flt-cfg-find { width: 100%; margin-bottom: 4px; }
.flt-cfg-h { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 6px; }
.flt-cfg-pop { position: absolute; right: 0; bottom: calc(100% + 4px); z-index: 30; min-width: 240px; padding: 8px 10px; border-radius: 10px;
  background: var(--card, #fff); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); display: grid; gap: 4px; }
.flt-cfg-pop label { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; white-space: nowrap; }
.flt-cfg-pop .muted { font-size: 11.5px; margin-top: 4px; }

/* «Жалобы пациентов» */
.cp-upload { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cp-table td { vertical-align: top; }
.cp-table .cp-text { min-width: 260px; max-width: 420px; }
.clamp3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cp-ok { color: var(--ok, #2e9d5b); font-weight: 700; }
.cp-bad { color: var(--danger, #d9534f); font-weight: 600; }
.cp-check { min-width: 190px; }
.cp-edit summary { cursor: pointer; color: var(--teal-dark); font-size: 12.5px; margin-top: 4px; }
.cp-edit form { display: grid; gap: 6px; margin-top: 6px; }
.cp-edit textarea { width: 100%; resize: vertical; }
.cp-tail { color: var(--ink); background: var(--teal-soft); border-radius: 3px; padding: 0 1px; }
.pv-mf { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0 8px; }
.pv-mf input[type=search] { flex: 1 1 200px; max-width: 320px; }
table.mx tr.on td { background: var(--teal-soft); }
table.mx tr.on td:first-child a { color: var(--teal-ink); }
table.mx tr.on td:first-child { box-shadow: inset 3px 0 0 var(--teal); }
table.mx tr.on td:first-child a { font-weight: 700; }

/* Приказ 27, прил. 5: узкие «+» и срок, широкие услуги; ячейки по верху */
.kp-o27-wide { table-layout: fixed; width: 100%; }
.kp-o27-wide td { vertical-align: top; }
.kp-o27-wide td:nth-child(3), .kp-o27-wide td:nth-child(4) { text-align: center; }
/* Свёрнутые разделы-списки — тонкой строкой, не давят */
details.card.kp-sec:not([open]) { padding-top: 10px; padding-bottom: 10px; margin-bottom: 8px; }
details.card.kp-sec > summary h3 { font-size: 15px; }
details.card.kp-sec > summary .chip { font-size: 12px; padding: 1px 8px; }

/* История загрузок реестра: файл и сравнение с прошлой выгрузкой месяца */
.up-hist .up-file { max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-hist .up-file .chip { font-size: 11.5px; padding: 1px 8px; }
.up-hist .up-fname { font-size: 12px; color: var(--muted); }

/* Карточка участка: шапка с кнопками, полоса «кто ведёт», список «Охват» с раскрытием разделов */
.dc-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.dc-head h1 { font-size: 20px; margin: 0; }
.dc-go { display: flex; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.dc-go a.dc-btn { display: inline-flex; align-items: center; padding: 9px 18px; border-radius: 10px; font-weight: 600; font-size: 14px;
  background: var(--card); color: var(--primary); border: 1px solid var(--primary); text-decoration: none; box-shadow: none; }
.dc-go a.dc-btn.dc-main { background: var(--primary); color: #fff; }
.dc-go a.dc-btn:hover { filter: brightness(1.06); text-decoration: none; }
.dc-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.dc-tile { display: flex; flex-direction: column; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; min-width: 0; }
.dc-tile > .muted { font-size: 12.5px; }
.dc-tile b { font-size: 22px; }
.dc-tile b.dc-name, .dc-tile a { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.dc-cov { padding-bottom: 8px; }
.dc-item { border-top: 1px solid var(--line-soft); }
.dc-item:first-of-type { border-top: 0; }
.dc-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(120px, 220px) 150px 150px; gap: 14px; align-items: center; padding: 9px 4px; font-size: 14px; list-style: none; }
.dc-row::-webkit-details-marker { display: none; }
summary.dc-row { cursor: pointer; }
summary.dc-row:hover { background: var(--x-bg-F2FAFB); }
.dc-t { display: flex; align-items: center; gap: 6px; min-width: 0; }
.dc-t a { color: inherit; text-decoration: none; }
.dc-t a:hover { color: var(--primary); text-decoration: underline; }
.dc-car { display: inline-block; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); margin: 0 6px 0 2px; transition: transform .15s; flex: none; }
details[open] > summary .dc-car { transform: rotate(45deg); }
.dc-item:not(details) .dc-t { padding-left: 21px; }
.dc-row .ov-bar { height: 8px; }
.dc-n { white-space: nowrap; }
.dc-l { text-align: right; white-space: nowrap; }
.dc-nodata { grid-column: 2 / -1; }
.dc-detail { padding: 2px 4px 12px 25px; }
.dc-note { font-size: 12px; margin-top: 4px; }
@media (max-width: 760px) {
  .dc-row { grid-template-columns: 1fr auto; gap: 6px 12px; }
  .dc-row .ov-bar { grid-column: 1 / -1; grid-row: 2; }
  .dc-l { grid-column: 1 / -1; text-align: left; }
  .dc-go { margin-left: 0; }
}

/* Освоение: источники (ГОБМП, ОСМС, договор) — главные строки: своя заливка, крупнее, линия-разделитель сверху */
table.fin-table[data-tree="lots"] tr.fin-src > td { background: color-mix(in srgb, var(--teal) 16%, var(--card)); font-size: 15px; font-weight: 700; padding-top: 11px; padding-bottom: 11px; }
table.fin-table[data-tree="lots"] tbody tr.fin-src > td { border-top: 2px solid var(--teal); }
table.fin-table[data-tree="lots"] tbody tr.fin-src:first-child > td { border-top: 0; }
table.fin-table[data-tree="lots"] tr.fin-src > td:first-child, table.fin-table[data-tree="lots"] tr.fin-src > td:first-child a { color: var(--ink); letter-spacing: .02em; }
table.fin-table[data-tree="lots"] tr.fin-src.on > td { background: color-mix(in srgb, var(--teal) 28%, var(--card)); }
table.fin-table[data-tree="lots"] tfoot tr.fin-src > td { border-top: 2px solid var(--teal); }

/* Карточка участка: анкета «Об участке» и карточки сотрудников */
.dc-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; margin-bottom: 16px; align-items: start; }
.dc-top > .card { margin-bottom: 0; }
.dc-facts { margin: 0; }
.dc-facts > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line-soft); font-size: 14px; }
.dc-facts > div:first-child { border-top: 0; }
.dc-facts dt { color: var(--muted); }
.dc-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.dc-facts dd b { font-size: 18px; }
.dc-facts dd a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--x-bd-9FB4C2); }
.dc-staff { display: flex; flex-direction: column; gap: 10px; }
.dc-person { display: flex; align-items: center; gap: 14px; padding: 12px 16px; margin: 0; }
.dc-ava { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 15px;
  background: var(--teal-soft); color: var(--teal-ink); }
.dc-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dc-who > .muted { font-size: 12.5px; }
.dc-pname { font-size: 15.5px; font-weight: 600; color: var(--ink); text-decoration: none; }
a.dc-pname:hover { color: var(--primary); text-decoration: underline; }
.dc-job { font-size: 12.5px; }
.dc-person .chip { flex: none; }
.dc-more { font-size: 12.5px; padding: 0 4px; }
@media (max-width: 860px) { .dc-top { grid-template-columns: 1fr; } }

/* Профилактика → Флюорография: свод журнала ФГ */
.fg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.fg-d { margin-top: 12px; } .fg-d summary { cursor: pointer; color: var(--primary); }

/* Регистры: карточки по ширине содержимого, рядом друг с другом — без растянутых пустых столбцов */
.rg-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px 0 10px; }
.rg-bar .toolbar { margin: 0; }
.rg-meta { font-size: 12.5px; margin-left: auto; }
.rg-grid { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; margin-top: 14px; }
.rg-grid .card { margin: 0; width: fit-content; max-width: 100%; }
.rg-grid h3 { margin: 0 0 10px; font-size: 15px; }
.rg-grid h3 .muted { font-weight: 400; }
.rg-side { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; flex: 1 1 360px; min-width: 0; }
.rg-scroll { max-height: calc(100vh - 330px); overflow: auto; }
.rg-scroll.rg-short { max-height: 320px; }
table.rg-table { width: auto; }
table.rg-table th, table.rg-table td { padding: 3px 10px; }
table.rg-table th { white-space: nowrap; }
table.rg-table td.r { min-width: 56px; }
table.rg-table td:first-child { max-width: 340px; }
@media (max-width: 1000px) { .rg-meta { margin-left: 0; } }

/* Карточка пациента: регистры КМИС, прививки, ФГ — карточки в ряд по ширине содержимого */
.pd-more { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.pd-more > .card { margin: 0; width: fit-content; max-width: 100%; overflow-x: auto; }
.pd-more > .card > strong { display: block; margin-bottom: 6px; }

/* Сводка и Дефекты: контроли рецептов ИСЛО по приказу 75 */
.alo-h { margin: 22px 0 8px; font-size: 15px; }
.alo-h .muted { font-weight: 400; }
.alo-strip { flex-wrap: wrap; gap: 6px; }
table.alo-defects td.muted { white-space: normal; min-width: 320px; max-width: 560px; }
table.alo-defects td:first-child { white-space: nowrap; }

/* Сводка и Исправления: месяц и год рядом с заголовком */
.reg-months { margin: 0 0 0 12px; }

/* Своды: выбранная строка фильтрует список ниже */
.an-card table.fin tr.on td { background: var(--teal-soft); font-weight: 600; }
.an-card table.fin td a:not(.ref) { color: inherit; }
.an-card table.fin td a:not(.ref):hover { color: var(--teal-ink); text-decoration: underline; }

/* Лаб. показатели: значение выше / ниже нормы; разбор результата в карточке пациента */
.lv-high { color: var(--danger, #e5534b); }
.lv-low { color: var(--warn, #d29922); }
td.lab-parts { white-space: normal; min-width: 340px; }
.lab-parts .lp { line-height: 1.5; }
.lab-parts .lp-n { color: var(--muted); }
.lab-parts .lp .chip { font-size: 11px; padding: 0 6px; }
table.lab-refs input, table.lab-refs select { padding: 3px 6px; }
table.lab-refs tr.lr-first td { border-top: 1px solid var(--line); }

/* «Лаб. результаты»: показатели результата — каждый строкой, столбцы выровнены */
td.lab-col div { line-height: 1.5; white-space: nowrap; }

/* Карточка: результат анализа рядом с услугой, динамика анализов */
td.lab-res { white-space: normal; min-width: 140px; }
td.lab-res .lv { line-height: 1.4; }
td.lab-res .lab-one + .lab-one { margin-top: 4px; }
td.lab-res .lab-one > .muted { display: block; font-size: 12px; }
td.lab-hist { white-space: normal; }
.lab-pt { display: inline-block; margin-right: 12px; }
