/* Phonebook: site directory. */
.pb-directory {
	--pb-dept-bg: #eef1f4;
	--pb-dept-fg: #1f2d3d;
	--pb-border: #d6dbe0;
	--pb-accent: #2a69b8;
}

.pb-description {
	position: relative;
	margin-bottom: 1rem;
}
.pb-description-edit {
	margin-top: .5rem;
}

.pb-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .5rem 1rem;
	margin-bottom: .75rem;
}
.pb-search {
	position: relative;
	flex: 1 1 18rem;
	max-width: 32rem;
}
.pb-search .form-control {
	padding-left: 2.1rem;
}
.pb-search-icon {
	position: absolute;
	left: .75rem;
	top: 50%;
	transform: translateY(-50%);
	opacity: .55;
	pointer-events: none;
}
.pb-count {
	color: #6c757d;
	font-size: .9rem;
}
.pb-buttons {
	display: flex;
	flex-wrap: wrap;
	gap: .5rem;
	margin-left: auto;
}

.pb-table {
	border-color: var(--pb-border);
	margin-bottom: 0;
}
.pb-table thead th {
	white-space: nowrap;
	vertical-align: middle;
}
.pb-table td {
	vertical-align: middle;
}
.pb-table .pb-col-phone_internal,
.pb-table .pb-col-phone_external {
	white-space: nowrap;
}

.pb-dept-row > th,
.pb-dept-row > td {
	background-color: var(--pb-dept-bg) !important;
	color: var(--pb-dept-fg) !important;
	font-size: 1.05rem;
	font-weight: 700;
	box-shadow: none !important;
}
.pb-dept-phone {
	white-space: nowrap;
}
.pb-dept-count {
	margin-left: .5rem;
	font-size: .8rem;
	font-weight: 400;
	opacity: .75;
}
.pb-dept-count.pb-understaffed {
	color: #b02a37;
	opacity: 1;
}
.pb-dept-add {
	margin-left: .5rem;
	font-size: .85rem;
	text-decoration: none;
	opacity: .6;
}
.pb-dept-add:hover,
.pb-dept-add:focus {
	opacity: 1;
}

/* Head of department: gold star and bold name. */
.pb-head-star {
	color: #f0ad4e;
}
.pb-row.pb-head .pb-col-fio .pb-value {
	font-weight: 700;
}

/* The colour fills the whole row, every cell included. */
.pb-row.pb-colored > td {
	background-color: var(--pb-row-bg) !important;
	color: var(--pb-row-fg) !important;
	box-shadow: none !important;
}
.pb-row.pb-colored a {
	color: inherit;
	text-decoration: underline;
}

/* Inline editing. */
.pb-editable-mode .pb-cell {
	cursor: text;
}
.pb-editable-mode .pb-cell:hover,
.pb-editable-mode .pb-cell:focus {
	outline: 2px dashed var(--pb-accent);
	outline-offset: -3px;
}
.pb-cell.pb-editing {
	padding: .2rem;
	outline: none !important;
}
.pb-cell .pb-input {
	width: 100%;
	min-width: 6rem;
	padding: .25rem .4rem;
	font: inherit;
	font-weight: 400;
	color: #212529;
	background: #fff;
	border: 1px solid var(--pb-accent);
	border-radius: .25rem;
}
.pb-cell.pb-saving {
	opacity: .55;
}
.pb-row.pb-flash > td,
.pb-dept-row.pb-flash > td,
.pb-dept-row.pb-flash > th {
	animation: pb-flash 1s ease-out;
}
@keyframes pb-flash {
	from { box-shadow: inset 0 0 0 9999px rgba(25, 135, 84, .25); }
	to   { box-shadow: inset 0 0 0 9999px rgba(25, 135, 84, 0); }
}

.pb-actions {
	width: 1%;
	white-space: nowrap;
	text-align: right;
}
.pb-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 1px solid transparent;
	border-radius: .25rem;
	background: transparent;
	color: inherit;
	text-decoration: none !important;
	cursor: pointer;
}
.pb-btn:hover,
.pb-btn:focus {
	border-color: currentColor;
}
.pb-btn-danger:hover,
.pb-btn-danger:focus {
	color: #b02a37;
}

/* Colour picker popover. */
.pb-palette {
	position: absolute;
	z-index: 1050;
	width: 15rem;
	padding: .6rem;
	background: #fff;
	color: #212529;
	border: 1px solid var(--pb-border);
	border-radius: .375rem;
	box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);
}
.pb-palette-title {
	margin-bottom: .4rem;
	font-size: .85rem;
	font-weight: 600;
}
.pb-swatches {
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	gap: .35rem;
	margin-bottom: .5rem;
}
.pb-swatch {
	width: 100%;
	aspect-ratio: 1;
	padding: 0;
	border: 1px solid rgba(0, 0, 0, .2);
	border-radius: .25rem;
	cursor: pointer;
}
.pb-swatch.is-active {
	outline: 2px solid var(--pb-accent);
	outline-offset: 1px;
}
.pb-palette-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .5rem;
	font-size: .85rem;
}
.pb-palette-row input[type="color"] {
	width: 2.5rem;
	height: 1.8rem;
	padding: 0;
	border: 1px solid var(--pb-border);
	background: none;
}

.pb-edit-buttons {
	display: flex;
	flex-wrap: wrap;
	gap: .5rem;
	margin-top: 1rem;
}

/* Print: only the directory, with colours, as currently filtered. */
@media print {
	body * {
		visibility: hidden;
	}
	.pb-directory,
	.pb-directory * {
		visibility: visible;
	}
	.pb-directory {
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
	}
	.pb-directory .d-print-none,
	.pb-directory [hidden] {
		display: none !important;
	}
	.pb-table-wrap {
		overflow: visible !important;
	}
	.pb-table,
	.pb-table * {
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}
	.pb-table a {
		text-decoration: none !important;
		color: inherit !important;
	}
	.pb-group {
		break-inside: avoid;
	}
	.pb-editable-mode .pb-cell {
		outline: none !important;
	}
}

/* Drag & drop ordering: rows move only by the grip handle, inside one department */
.pb-col-grip,
.pb-grip,
.pb-dept-grip {
	width: 1%;
}
.pb-dept-grip {
	padding: 0;
	border: 0;
}
.pb-grip {
	cursor: grab;
	text-align: center;
	color: var(--body-color, #212529);
	opacity: .45;
	touch-action: none;
	user-select: none;
}
.pb-grip:hover {
	opacity: 1;
}
.pb-grip-icon {
	fill: currentColor;
}
.pb-row.pb-dragging,
.pb-dept-row.pb-dragging {
	opacity: .4;
	cursor: grabbing;
}
.pb-row.pb-drop-before td,
.pb-row.pb-drop-before th,
.pb-dept-row.pb-drop-before td,
.pb-dept-row.pb-drop-before th {
	box-shadow: inset 0 3px 0 0 var(--link-color, #0d6efd);
}
.pb-row.pb-drop-after td,
.pb-row.pb-drop-after th,
.pb-dept-row.pb-drop-after td,
.pb-dept-row.pb-drop-after th {
	box-shadow: inset 0 -3px 0 0 var(--link-color, #0d6efd);
}
.pb-grip-dept {
	display: inline-block;
	padding: 2px 4px;
}

@media print {
	.pb-grip {
		cursor: default;
	}
}

/* Small screens: the search field takes the full toolbar row */
@media (max-width: 575.98px) {
	.pb-search {
		flex-basis: 100%;
	}
}

/* Touch devices: larger tap targets for the row action buttons */
@media (pointer: coarse) {
	.pb-btn {
		width: 2.75rem;
		height: 2.75rem;
	}
}

/* Responsive: full-width search on small screens; ≥44px touch targets on coarse pointers. */
@media (max-width: 575.98px) {
	.pb-search {
		flex-basis: 100%;
	}
}

@media (pointer: coarse) {
	.pb-btn {
		width: 2.75rem;
		height: 2.75rem;
	}
}
