/*
 * Сторінка «Адміністрація і структура ТМО».
 * Основа — дизайн-система сторінки центру (center.css, класи tmo-cp-*),
 * тут лише те, чого в ній немає: показники хіроу, дирекція, схема, служби.
 */

.tmo-ad-main {
	--ad-accent: var(--tmo-blue);
	--ad-accent-soft: rgba(115, 156, 210, 0.14);
}

/* ------------------------------------------------- Показники в хіроу */

.tmo-ad-hero .tmo-cp-hero__title,
.tmo-ad-hero .tmo-cp-hero__subtitle {
	max-width: 100%;
}

.tmo-ad-facts {
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
	margin: 44px 0 0;
	padding: 0;
	list-style: none;
}

.tmo-ad-fact__inner {
	display: flex;
	align-items: center;
	gap: 14px;
	min-height: 84px;
	padding: 16px 26px 16px 20px;
	border: 1px solid var(--cp-line);
	border-radius: var(--cp-radius);
	background: rgba(255, 255, 255, 0.75);
	color: inherit;
	text-decoration: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

a.tmo-ad-fact__inner:hover,
a.tmo-ad-fact__inner:focus-visible {
	border-color: rgba(115, 156, 210, 0.7);
	box-shadow: var(--cp-shadow);
	transform: translateY(-2px);
}

.tmo-ad-fact__icon {
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	border-radius: 12px;
	background: var(--ad-accent-soft);
	color: var(--tmo-blue-dark);
}

.tmo-ad-fact__value {
	font-size: 30px;
	font-weight: 700;
	line-height: 1;
	color: var(--tmo-blue-dark);
}

.tmo-ad-fact__label {
	max-width: 140px;
	font-size: 15px;
	line-height: 1.3;
	color: var(--cp-muted);
}

/* ------------------------------------------------------------ Дирекція */

.tmo-ad-board {
	display: grid;
	gap: 20px;
}

/* Директор — картка на всю ширину, фото плиткою з відступом від країв. */
.tmo-ad-director {
	display: grid;
	grid-template-columns: 320px minmax(0, 1fr);
	align-items: stretch;
	border-radius: var(--cp-radius);
	background: var(--cp-tint);
	overflow: hidden;
}

.tmo-ad-director__photo {
	margin: 0;
	min-height: 416px;
	padding: 18px;
}

/* Фото немає — на місці плитки лишається тло картки. */
.tmo-ad-director__photo:not(:has(img)) {
	background: linear-gradient(160deg, rgba(115, 156, 210, 0.3), rgba(115, 156, 210, 0.08));
}

.tmo-ad-director__body {
	align-self: center;
	padding: 32px 36px;
}

.tmo-ad-director__photo img {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: var(--cp-radius-sm);
	object-fit: cover;
	object-position: top center;
}

.tmo-ad-director__label {
	display: inline-block;
	margin: 0 0 10px;
	padding: 6px 12px;
	border-radius: 999px;
	background: rgba(245, 122, 117, 0.14);
	font-size: 13px;
	font-weight: 500;
	color: #c9534e;
}

.tmo-ad-director__name {
	margin: 0;
	font-size: clamp(22px, 1.7vw, 28px);
	font-weight: 700;
	line-height: 1.2;
	color: var(--tmo-blue-dark);
}

.tmo-ad-director__bio {
	margin: 14px 0 0;
	font-size: 15.5px;
	line-height: 1.6;
	color: var(--cp-muted);
}

.tmo-ad-director__contacts {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 22px;
	margin: 18px 0 0;
}

.tmo-ad-director__contacts a {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 15px;
	font-weight: 500;
	color: var(--tmo-blue-dark);
	text-decoration: none;
	word-break: break-word;
}

.tmo-ad-director__contacts a:hover {
	color: var(--tmo-coral);
}

.tmo-ad-director__contacts .tmo-icon {
	width: 18px;
	height: 18px;
	color: var(--tmo-blue);
}

.tmo-ad-people {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 16px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Решта дирекції: фото на всю висоту картки, врівень із її краями. */
.tmo-ad-person {
	display: flex;
	align-items: stretch;
	border: 1px solid var(--cp-line);
	border-radius: var(--cp-radius);
	background: #fff;
	overflow: hidden;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tmo-cp-section--bg-white .tmo-ad-person {
	background: var(--tmo-page, #f8f8f8);
}

.tmo-ad-person:hover {
	border-color: rgba(115, 156, 210, 0.6);
	box-shadow: var(--cp-shadow);
}

.tmo-ad-person__photo {
	display: block;
	flex: none;
	width: 262px;
	min-height: 312px;
	padding: 16px;
}

.tmo-ad-person__photo:not(:has(img)) {
	background: linear-gradient(160deg, rgba(115, 156, 210, 0.28), rgba(115, 156, 210, 0.08));
}

.tmo-ad-person__photo img {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: var(--cp-radius-sm);
	object-fit: cover;
	object-position: top center;
}

.tmo-ad-person__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 4px;
	align-self: center;
	padding: 24px 26px;
}

.tmo-ad-person__name {
	font-size: 18px;
	font-weight: 700;
	line-height: 1.25;
	color: var(--tmo-blue-dark);
}

.tmo-ad-person__role {
	font-size: 14px;
	line-height: 1.4;
	color: var(--cp-muted);
}

.tmo-ad-person__name--empty {
	color: var(--cp-muted);
	font-weight: 600;
}

.tmo-ad-person__bio {
	margin-top: 2px;
	font-size: 15px;
	line-height: 1.5;
	color: #3b4552;
}

.tmo-ad-person__schedule {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	margin: 10px 0 0;
	font-size: 14.5px;
	line-height: 1.45;
	color: #3b4552;
}

.tmo-ad-person__schedule .tmo-icon {
	width: 18px;
	height: 18px;
	margin-top: 1px;
	color: var(--tmo-blue-dark);
}

.tmo-ad-person__schedule-label {
	font-weight: 600;
	color: var(--tmo-blue-dark);
}

.tmo-ad-director .tmo-ad-person__schedule {
	margin-top: 16px;
	font-size: 15.5px;
}

.tmo-ad-person__link {
	margin-top: 8px;
}

.tmo-ad-director .tmo-ad-person__link {
	margin-top: 18px;
}

@media (max-width: 1100px) {
	.tmo-ad-people {
		grid-template-columns: minmax(0, 1fr);
	}

	.tmo-ad-director {
		grid-template-columns: 320px minmax(0, 1fr);
	}

	.tmo-ad-director__photo {
		min-height: 356px;
	}
}

@media (max-width: 700px) {
	.tmo-ad-director {
		grid-template-columns: minmax(0, 1fr);
	}

	.tmo-ad-director__photo {
		min-height: 0;
		aspect-ratio: 4 / 3;
	}

	.tmo-ad-director__body {
		padding: 22px 20px;
	}

	.tmo-ad-person__photo {
		width: 144px;
		min-height: 0;
		padding: 12px;
	}

	.tmo-ad-person__body {
		padding: 18px 18px 18px 20px;
	}
}

/* -------------------------------------------------------------- Схема */

.tmo-ad-chart {
	--ad-line: rgba(115, 156, 210, 0.55);
	--ad-gap: 20px;
	position: relative;
}

.tmo-ad-chart__root {
	position: relative;
	display: flex;
	justify-content: center;
	margin-bottom: 56px;
}

/* Вертикальна лінія від директора до горизонтальної шини. */
.tmo-ad-chart__root::after {
	content: "";
	position: absolute;
	top: 100%;
	left: calc(50% - 1px);
	width: 2px;
	height: 28px;
	background: var(--ad-line);
}

/* Кількість колонок — у style="--ad-cols" з шаблону. */
.tmo-ad-chart__row {
	position: relative;
	display: grid;
	grid-template-columns: repeat(var(--ad-cols, 6), minmax(0, 1fr));
	gap: var(--ad-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

/*
 * Горизонтальна шина — від центру першої колонки до центру останньої:
 * півколонки з кожного боку (колонки рівні, тож рахуємо з ширини й проміжків).
 */
.tmo-ad-chart__row::before {
	content: "";
	position: absolute;
	bottom: calc(100% + 27px);
	left: calc((100% - (var(--ad-cols, 6) - 1) * var(--ad-gap)) / (var(--ad-cols, 6) * 2));
	right: calc((100% - (var(--ad-cols, 6) - 1) * var(--ad-gap)) / (var(--ad-cols, 6) * 2));
	height: 2px;
	background: var(--ad-line);
}

.tmo-ad-chart__cell {
	position: relative;
	display: flex;
}

/* Вертикальні відводи від шини до кожного блоку. */
.tmo-ad-chart__cell::before {
	content: "";
	position: absolute;
	bottom: 100%;
	left: calc(50% - 1px);
	width: 2px;
	height: 28px;
	background: var(--ad-line);
}

/*
 * Другий рівень — заступники медичного директора. Лінія йде з-під вузла
 * «Медичний директор»: його центр рахуємо з номера (--ad-main-index)
 * і кількості колонок верхнього ряду (--ad-top-cols).
 */
.tmo-ad-chart__tier {
	--ad-line: rgba(245, 122, 117, 0.55);
	--ad-top-col: calc((100% - (var(--ad-top-cols) - 1) * var(--ad-gap)) / var(--ad-top-cols));
	position: relative;
	margin-top: 56px;
}

.tmo-ad-chart__tier::before {
	content: "";
	position: absolute;
	top: -56px;
	left: calc((var(--ad-top-col) + var(--ad-gap)) * (var(--ad-main-index) - 1) + var(--ad-top-col) / 2 - 1px);
	width: 2px;
	height: 30px;
	background: var(--ad-line);
}

.tmo-ad-chart__caption {
	display: none;
}

.tmo-ad-node {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 6px;
	width: 100%;
	padding: 20px 22px;
	border: 1.5px solid var(--cp-line);
	border-radius: var(--cp-radius-sm);
	background: #fff;
	text-align: center;
}

.tmo-ad-node__role {
	font-size: 16px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--tmo-blue-dark);
}

.tmo-ad-node__person {
	margin: 0;
	font-size: 14px;
	line-height: 1.35;
	color: var(--cp-muted);
}

/* ПІБ — посилання на сторінку лікаря, якщо вона є. */
.tmo-ad-node__person a {
	color: inherit;
	text-decoration: none;
	border-bottom: 1px solid rgba(115, 156, 210, 0.45);
}

.tmo-ad-node__person a:hover,
.tmo-ad-node__person a:focus-visible {
	color: var(--tmo-coral);
	border-bottom-color: currentColor;
}

.tmo-ad-node--root {
	min-width: 320px;
	padding: 26px 40px;
	border-color: transparent;
	background: linear-gradient(120deg, var(--tmo-blue-dark) 0%, var(--tmo-blue) 100%);
}

.tmo-ad-node--root .tmo-ad-node__role {
	font-size: 26px;
	color: #fff;
}

.tmo-ad-node--root .tmo-ad-node__person {
	font-size: 15px;
	color: rgba(255, 255, 255, 0.85);
}

.tmo-ad-node--main {
	border-color: var(--tmo-coral);
	background: rgba(245, 122, 117, 0.08);
}

.tmo-ad-node--deputy {
	padding: 16px 18px;
}

.tmo-ad-node--deputy .tmo-ad-node__role {
	font-size: 15px;
}

/* ----------------------------------------------- Служби та підрозділи */

.tmo-ad-service {
	--ad-branch: var(--tmo-blue);
	--ad-branch-soft: rgba(115, 156, 210, 0.12);
	padding-block: 36px;
	border-top: 1px solid var(--cp-line);
}

.tmo-ad-service:first-child {
	padding-top: 0;
	border-top: 0;
}

.tmo-ad-service:last-child {
	padding-bottom: 0;
}

.tmo-ad-service--coral {
	--ad-branch: var(--tmo-coral);
	--ad-branch-soft: rgba(245, 122, 117, 0.12);
}

.tmo-ad-service--navy {
	--ad-branch: var(--tmo-blue-dark);
	--ad-branch-soft: rgba(58, 81, 110, 0.1);
}

.tmo-ad-service--muted {
	--ad-branch: var(--tmo-blue-muted);
	--ad-branch-soft: rgba(90, 124, 169, 0.1);
}

.tmo-ad-service__title {
	display: flex;
	align-items: center;
	gap: 14px;
	margin: 0 0 24px;
	font-size: clamp(20px, 1.5vw, 24px);
	font-weight: 700;
	line-height: 1.25;
	color: var(--tmo-blue-dark);
}

.tmo-ad-service__icon {
	display: grid;
	place-items: center;
	flex: none;
	width: 42px;
	height: 42px;
	border-radius: 12px;
	background: var(--ad-branch-soft);
	color: var(--ad-branch);
}

.tmo-ad-service__icon .tmo-icon {
	width: 22px;
	height: 22px;
}

/* Групи — колонками; група не розривається між колонками. */
.tmo-ad-service__groups {
	columns: 3 280px;
	column-gap: 48px;
}

.tmo-ad-group {
	break-inside: avoid;
	margin: 0 0 26px;
}

/* «Безпосередньо керівникові» — на всю ширину, підрозділи в ній теж колонками. */
.tmo-ad-group--lead {
	column-span: all;
	margin-top: 8px;
	padding-top: 24px;
	border-top: 1px dashed var(--cp-line);
}

.tmo-ad-group--lead > .tmo-ad-units {
	display: block;
	columns: 3 280px;
	column-gap: 48px;
}

.tmo-ad-group--lead > .tmo-ad-units > .tmo-ad-unit {
	break-inside: avoid;
	margin-bottom: 16px;
}

.tmo-ad-group__role {
	margin: 0 0 10px;
	font-size: 15.5px;
	font-weight: 700;
	line-height: 1.35;
	color: var(--tmo-blue-dark);
}

.tmo-ad-group__note {
	margin: 0;
	font-size: 15px;
	line-height: 1.5;
	color: var(--cp-muted);
}

/* Перелік підрозділів */

.tmo-ad-units {
	display: grid;
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.tmo-ad-unit {
	position: relative;
	padding-left: 16px;
	font-size: 15px;
	line-height: 1.45;
	color: #3b4552;
}

.tmo-ad-unit::before {
	content: "";
	position: absolute;
	top: 0.6em;
	left: 0;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--ad-branch, var(--tmo-blue));
}

.tmo-ad-unit--has-children > .tmo-ad-unit__name {
	font-weight: 600;
	color: var(--tmo-blue-dark);
}

/* Не inline-flex: інакше при переносі рядків стрілка відлітає до краю. */
a.tmo-ad-unit__name {
	color: var(--tmo-blue-dark);
	text-decoration: none;
	border-bottom: 1px solid transparent;
}

a.tmo-ad-unit__name:hover,
a.tmo-ad-unit__name:focus-visible {
	color: var(--tmo-coral);
	border-bottom-color: currentColor;
}

a.tmo-ad-unit__name .tmo-icon {
	display: inline-block;
	width: 14px;
	height: 14px;
	margin-left: 5px;
	vertical-align: -2px;
	opacity: 0.5;
	transition: transform 0.15s ease, opacity 0.15s ease;
}

a.tmo-ad-unit__name:hover .tmo-icon {
	opacity: 1;
	transform: translateX(2px);
}

.tmo-ad-unit__note {
	display: block;
	font-size: 13.5px;
	color: var(--cp-muted);
}

/* Вкладені відділення — тонка лінія ліворуч замість маркерів. */
.tmo-ad-units--nested {
	gap: 4px;
	margin: 8px 0 2px;
	padding-left: 12px;
	border-left: 1px solid var(--cp-line);
}

.tmo-ad-units--nested .tmo-ad-unit {
	padding-left: 0;
	font-size: 14.5px;
	color: #4a5563;
}

.tmo-ad-units--nested .tmo-ad-unit::before {
	display: none;
}

/* ------------------------------------------------------------- Центри */

.tmo-ad-center__count {
	margin: 0;
	font-size: 14px;
	font-weight: 500;
	color: var(--tmo-coral);
}

/* ---------------------------------------------------------- Адаптація */

/*
 * Вужче ряд у шість колонок не читається: блоки стають стовпчиком,
 * а шина — вертикальною рейкою ліворуч із відводом до кожного блоку.
 */
@media (max-width: 1280px) {
	.tmo-ad-chart__root {
		justify-content: flex-start;
		margin-bottom: 28px;
	}

	.tmo-ad-chart__root::after {
		/* Рейка блоків стоїть на 27 px — лінія директора має збігтися з нею. */
		left: 27px;
		height: 28px;
	}

	.tmo-ad-chart__row {
		grid-template-columns: minmax(0, 1fr);
		gap: 14px;
		padding-left: 56px;
	}

	.tmo-ad-chart__row::before {
		display: none;
	}

	/* Горизонтальний відвід до блоку. */
	.tmo-ad-chart__cell::before {
		top: calc(50% - 1px);
		bottom: auto;
		left: -28px;
		width: 28px;
		height: 2px;
	}

	/* Рейка: шматок на кожен блок — разом виходить суцільна лінія. */
	.tmo-ad-chart__cell::after {
		content: "";
		position: absolute;
		left: -29px;
		top: -7px;
		bottom: -7px;
		width: 2px;
		background: var(--ad-line);
	}

	.tmo-ad-chart__cell:last-child::after {
		bottom: 50%;
	}

	/* Лінію з-під «Медичного директора» у стовпчику не провести — замість неї підпис. */
	.tmo-ad-chart__tier {
		margin-top: 36px;
	}

	.tmo-ad-chart__tier::before {
		display: none;
	}

	.tmo-ad-chart__caption {
		display: block;
		margin: 0 0 14px;
		font-size: 16px;
		font-weight: 700;
		line-height: 1.3;
		color: var(--tmo-blue-dark);
	}

	.tmo-ad-node {
		text-align: left;
	}

	.tmo-ad-node--root {
		text-align: center;
	}
}

@media (max-width: 1100px) {
	.tmo-ad-board {
		grid-template-columns: minmax(0, 1fr);
	}
}

@media (max-width: 900px) {
	.tmo-ad-director {
		grid-template-columns: 160px minmax(0, 1fr);
		gap: 20px;
		padding: 20px;
	}

	/* Відступ тут дає сама картка — плитці фото власний уже не потрібен. */
	.tmo-ad-director__photo {
		padding: 0;
	}

	.tmo-ad-node--root {
		min-width: 0;
		width: 100%;
	}
}

@media (max-width: 640px) {
	.tmo-ad-facts {
		gap: 10px;
	}

	.tmo-ad-fact__inner {
		width: 100%;
		padding: 14px 18px;
	}

	.tmo-ad-fact__label {
		max-width: none;
	}

	.tmo-ad-director {
		grid-template-columns: minmax(0, 1fr);
	}

	.tmo-ad-director__photo {
		max-width: 200px;
		aspect-ratio: 4 / 4.4;
	}

	.tmo-ad-person {
		align-items: flex-start;
	}

	.tmo-ad-service {
		padding-block: 28px;
	}
}
