.tz-pie-donut-chart {
	--tz-chart-size: 320px;
	--tz-legend-marker-size: 12px;
	--tz-legend-gap: 14px;
	--tz-legend-offset-x: 0px;
	--tz-legend-offset-y: 0px;
	--tz-body-justify: center;
	--tz-active-scale: 1.08;
	--tz-active-brightness: 1.08;
	--tz-active-outline-width: 2px;
	--tz-active-outline-color: #111111;
	--tz-inactive-opacity: 0.45;
	--tz-inactive-saturate: 0.45;
	--tz-segment-gap: 2px;
	--tz-active-legend-bg: rgba(17, 17, 17, 0.08);
	--tz-active-legend-text: #111111;
	--tz-active-legend-border: #111111;
	--tz-active-legend-marker: #111111;
	--tz-tooltip-bg: #111111;
	--tz-tooltip-text: #ffffff;
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 18px;
	width: 100%;
	border-radius: 16px;
	box-sizing: border-box;
	overflow: visible;
}

.tz-pie-donut-chart__body {
	display: flex;
	align-items: center;
	justify-content: var(--tz-body-justify);
	gap: 24px;
	width: 100%;
}

.tz-pie-donut-chart--legend-left .tz-pie-donut-chart__body,
.tz-pie-donut-chart--legend-right .tz-pie-donut-chart__body {
	flex-direction: row;
}

.tz-pie-donut-chart--legend-top .tz-pie-donut-chart__body,
.tz-pie-donut-chart--legend-bottom .tz-pie-donut-chart__body,
.tz-pie-donut-chart--fallback .tz-pie-donut-chart__body {
	flex-direction: column;
}

.tz-pie-donut-chart__figure {
	position: relative;
	width: min(100%, var(--tz-chart-size));
	flex: 0 0 auto;
}

.tz-pie-donut-chart__svg {
	display: block;
	width: 100%;
	height: auto;
	overflow: visible;
}

.tz-pie-donut-chart__segment {
	cursor: pointer;
	transform-box: fill-box;
	transform-origin: center;
	transition: transform 180ms ease, opacity 180ms ease, filter 180ms ease, stroke 180ms ease, stroke-width 180ms ease;
}

.tz-pie-donut-chart__segment:focus-visible {
	stroke: var(--tz-active-outline-color);
	stroke-width: calc(var(--tz-segment-gap) + 2px);
}

.tz-pie-donut-chart[data-active-segment-style="scale"] .tz-pie-donut-chart__segment.is-active {
	transform: scale(var(--tz-active-scale));
}

.tz-pie-donut-chart[data-active-segment-style="brighten"] .tz-pie-donut-chart__segment.is-active {
	filter: brightness(var(--tz-active-brightness)) saturate(var(--tz-active-brightness));
}

.tz-pie-donut-chart[data-active-segment-style="outline"] .tz-pie-donut-chart__segment.is-active {
	stroke: var(--tz-active-outline-color);
	stroke-width: calc(var(--tz-segment-gap) + var(--tz-active-outline-width));
}

.tz-pie-donut-chart[data-active-segment-style="combined"] .tz-pie-donut-chart__segment.is-active {
	transform: scale(var(--tz-active-scale));
	filter: brightness(var(--tz-active-brightness)) saturate(var(--tz-active-brightness));
}

.tz-pie-donut-chart[data-dim-inactive="yes"][data-inactive-segment-style="opacity"] .tz-pie-donut-chart__segment.is-inactive {
	opacity: var(--tz-inactive-opacity);
}

.tz-pie-donut-chart[data-dim-inactive="yes"][data-inactive-segment-style="desaturate"] .tz-pie-donut-chart__segment.is-inactive {
	filter: saturate(var(--tz-inactive-saturate));
}

.tz-pie-donut-chart[data-dim-inactive="yes"][data-inactive-segment-style="opacity-desaturate"] .tz-pie-donut-chart__segment.is-inactive {
	opacity: var(--tz-inactive-opacity);
	filter: saturate(var(--tz-inactive-saturate));
}

.tz-pie-donut-chart__legend {
	display: grid;
	gap: var(--tz-legend-gap);
	width: 100%;
	max-width: 340px;
	transform: translate(var(--tz-legend-offset-x), var(--tz-legend-offset-y));
}

.tz-pie-donut-chart--legend-align-left .tz-pie-donut-chart__legend {
	justify-items: start;
	text-align: left;
}

.tz-pie-donut-chart--legend-align-center .tz-pie-donut-chart__legend {
	justify-items: center;
	text-align: center;
}

.tz-pie-donut-chart--legend-align-right .tz-pie-donut-chart__legend {
	justify-items: end;
	text-align: right;
}

.tz-pie-donut-chart__legend-item {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	gap: 12px;
	align-items: start;
	width: min(100%, 340px);
	padding: 10px 12px;
	border: 1px solid transparent;
	border-radius: 14px;
	background: transparent;
	color: inherit;
	font: inherit;
	text-align: inherit;
	cursor: pointer;
	transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, opacity 180ms ease, transform 180ms ease;
}

.tz-pie-donut-chart__legend-item:focus-visible {
	outline: 2px solid var(--tz-active-legend-border);
	outline-offset: 2px;
}

.tz-pie-donut-chart__legend-marker {
	width: var(--tz-legend-marker-size);
	height: var(--tz-legend-marker-size);
	border-radius: 999px;
	background: var(--tz-legend-color, currentColor);
	margin-top: 0.35em;
	transition: transform 180ms ease, background-color 180ms ease;
}

.tz-pie-donut-chart__legend-content {
	display: block;
	min-width: 0;
}

.tz-pie-donut-chart__legend-main {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 12px;
	align-items: baseline;
}

.tz-pie-donut-chart--legend-align-center .tz-pie-donut-chart__legend-main {
	justify-content: center;
}

.tz-pie-donut-chart--legend-align-right .tz-pie-donut-chart__legend-main {
	justify-content: flex-end;
}

.tz-pie-donut-chart__legend-label {
	font-weight: 600;
	min-width: 0;
	max-width: 100%;
	/* Intentionally no ellipsis truncation: segment names must stay fully
	   readable in the legend (same source text as the tooltip), so long
	   labels wrap onto multiple lines instead of being cut off. */
	white-space: normal;
	overflow-wrap: break-word;
	word-break: break-word;
}

.tz-pie-donut-chart__legend-value,
.tz-pie-donut-chart__legend-description {
	opacity: 0.8;
}

.tz-pie-donut-chart__legend-description {
	display: block;
	margin-top: 4px;
	line-height: 1.45;
}

.tz-pie-donut-chart[data-highlight-legend="yes"][data-active-legend-style="background"] .tz-pie-donut-chart__legend-item.is-active {
	background: var(--tz-active-legend-bg);
	color: var(--tz-active-legend-text);
}

.tz-pie-donut-chart[data-highlight-legend="yes"][data-active-legend-style="border"] .tz-pie-donut-chart__legend-item.is-active {
	border-color: var(--tz-active-legend-border);
	color: var(--tz-active-legend-text);
}

.tz-pie-donut-chart[data-highlight-legend="yes"][data-active-legend-style="underline"] .tz-pie-donut-chart__legend-item.is-active {
	border-bottom-color: var(--tz-active-legend-border);
	color: var(--tz-active-legend-text);
}

.tz-pie-donut-chart[data-highlight-legend="yes"][data-active-legend-style="marker"] .tz-pie-donut-chart__legend-item.is-active .tz-pie-donut-chart__legend-marker {
	background: var(--tz-active-legend-marker);
	transform: scale(1.15);
}

.tz-pie-donut-chart[data-highlight-legend="yes"][data-active-legend-style="combined"] .tz-pie-donut-chart__legend-item.is-active {
	background: var(--tz-active-legend-bg);
	border-color: var(--tz-active-legend-border);
	color: var(--tz-active-legend-text);
}

.tz-pie-donut-chart[data-highlight-legend="yes"][data-active-legend-style="combined"] .tz-pie-donut-chart__legend-item.is-active .tz-pie-donut-chart__legend-marker {
	background: var(--tz-active-legend-marker);
	transform: scale(1.15);
}

.tz-pie-donut-chart[data-highlight-legend="yes"] .tz-pie-donut-chart__legend-item.is-inactive {
	opacity: 0.7;
}

.tz-pie-donut-chart__tooltip {
	position: absolute;
	left: 0;
	top: 0;
	z-index: 3;
	min-width: 160px;
	max-width: 240px;
	padding: 10px 12px;
	border-radius: 12px;
	background: var(--tz-tooltip-bg);
	color: var(--tz-tooltip-text);
	box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
	line-height: 1.45;
	pointer-events: none;
	transform: translate(12px, 12px);
}

.tz-pie-donut-chart__tooltip[hidden] {
	display: none;
}

.tz-pie-donut-chart__tooltip-label {
	display: block;
	font-weight: 700;
}

.tz-pie-donut-chart__tooltip-value,
.tz-pie-donut-chart__tooltip-description {
	display: block;
	margin-top: 2px;
	opacity: 0.9;
}

.tz-pie-donut-chart__messages,
.pie-chart-error {
	display: grid;
	gap: 10px;
}

.tz-pie-donut-chart__message {
	padding: 12px 14px;
	border-radius: 12px;
	line-height: 1.45;
	font-size: 14px;
}

.tz-pie-donut-chart__message--warning {
	background: rgba(255, 181, 71, 0.14);
	color: #6f4500;
}

.tz-pie-donut-chart__message--error {
	background: rgba(255, 107, 107, 0.14);
	color: #8b1f1f;
}

@media (max-width: 767px) {
	/*
	 * Force chart-above-legend regardless of the saved desktop
	 * `legend_position` (top/bottom/left/right) and regardless of where
	 * that position renders the legend in the DOM (before/after
	 * .tz-pie-donut-chart__body for top/bottom, inside it for left/right).
	 * The saved `legend_position` value itself is not changed — this is a
	 * presentation-only override.
	 *
	 * This selector list deliberately repeats the desktop
	 * `--legend-left`/`--legend-right` selectors (rather than a bare
	 * `.tz-pie-donut-chart__body`) to match their specificity (two
	 * classes). A bare single-class override here would silently lose
	 * the cascade to the desktop `flex-direction: row` rule above for
	 * left/right — same specificity + later source order is what
	 * actually wins the tie, not just being inside this media query.
	 */
	.tz-pie-donut-chart--legend-left .tz-pie-donut-chart__body,
	.tz-pie-donut-chart--legend-right .tz-pie-donut-chart__body,
	.tz-pie-donut-chart--legend-top .tz-pie-donut-chart__body,
	.tz-pie-donut-chart--legend-bottom .tz-pie-donut-chart__body {
		flex-direction: column;
		/* align-items: center already comes from the base .tz-pie-donut-chart__body
		   rule above and keeps the figure horizontally centered here too. */
	}

	/*
	 * `order` only compares within the element's own flex container, so
	 * these two rules correctly cover both structures: figure vs. legend
	 * as body's children (left/right) and body vs. legend as
	 * .tz-pie-donut-chart's own children (top/bottom) — .tz-pie-donut-chart
	 * itself is always flex-direction: column (see base rule above), and
	 * .tz-pie-donut-chart__body defaults to order 0 like any other item.
	 * There is no competing `order` declaration anywhere else in this
	 * file, so plain single-class selectors are safe here (unlike
	 * flex-direction above).
	 */

	.tz-pie-donut-chart__figure {
		order: 0;
		/* Width itself is left to the existing
		   width: min(100%, var(--tz-chart-size)) base rule, so the
		   figure keeps respecting the chart_size responsive control's
		   own Mobile value instead of being forced to 100% here. */
	}

	.tz-pie-donut-chart__legend {
		order: 1;
		max-width: 100%;
		width: 100%;
		/* Mobile-specific legend_offset_x/y values stay in effect here —
		   only the desktop 340px width cap is removed. Defaults are 0px,
		   so this is a no-op unless the user explicitly set a mobile
		   offset (see legend_offset_x/legend_offset_y `selectors` in
		   widget.php). */
	}

	.tz-pie-donut-chart__legend-item {
		width: 100%;
	}
}
