/*
 * CharterGroup ROI calculator.
 * Everything is scoped under .cgroi. Brand values come from chartergroup.co.uk
 * (Flash theme + WPBakery): teal #00687a, lime #95c11f, pale teal #e0f2f5;
 * Open Sans body text inherited from the theme.
 */
.cgroi {
	--cgroi-brand: #00687a;
	--cgroi-brand-dark: #00687a;  /* 6.6:1 on white: safe for text and links */
	--cgroi-on-brand: #ffffff;    /* text on teal buttons, 6.6:1 */
	--cgroi-brand-tint: #e0f2f5;
	--cgroi-accent: #95c11f;
	--cgroi-accent-tint: #f2f8e4;
	--cgroi-ink: #313131;
	--cgroi-muted: #5f6368;       /* 6.0:1 on white */
	--cgroi-line: #d3dfe1;
	--cgroi-bg: #ffffff;
	--cgroi-error: #b3261e;
	--cgroi-success: #1e6b52;
	--cgroi-focus: #1d4ed8;
	--cgroi-radius: 8px;
	--cgroi-heading-font: inherit;

	container: cgroi / inline-size;
	box-sizing: border-box;
	max-width: 1100px;
	margin: 0 auto 2.5rem;
	color: var(--cgroi-ink);
	font-size: 1rem;
	line-height: 1.55;
	text-align: left;
}

.cgroi *,
.cgroi *::before,
.cgroi *::after {
	box-sizing: inherit;
}

.cgroi [hidden] {
	display: none !important;
}

/* Headings: keep the theme's typeface, tame its very large sizes. */
.cgroi .cgroi__title {
	margin: 0 0 0.5rem;
	font-family: var(--cgroi-heading-font);
	font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem);
	font-weight: 400;
	line-height: 1.2;
	color: var(--cgroi-ink);
}

.cgroi .cgroi__section-title {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	margin: 0 0 0.35rem;
	font-family: var(--cgroi-heading-font);
	font-size: clamp(1.2rem, 1rem + 0.8vw, 1.5rem);
	font-weight: 500;
	line-height: 1.3;
	color: var(--cgroi-ink);
}

.cgroi .cgroi__section-title:focus {
	outline: none;
}

.cgroi .cgroi__section-title:focus-visible {
	outline: 3px solid var(--cgroi-focus);
	outline-offset: 4px;
}

.cgroi .cgroi__step {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	border-radius: 50%;
	background: var(--cgroi-brand);
	color: var(--cgroi-on-brand);
	font-size: 1rem;
	font-weight: 700;
}

.cgroi p {
	margin: 0 0 0.75rem;
}

.cgroi .cgroi__intro {
	font-size: 1.1rem;
}

.cgroi .cgroi__fees,
.cgroi .cgroi__hint {
	color: var(--cgroi-muted);
	font-size: 0.95rem;
}

.cgroi .cgroi__header {
	margin-bottom: 1.5rem;
}

.cgroi .cgroi__section {
	margin: 0 0 1.5rem;
	padding: 1.5rem;
	border: 1px solid var(--cgroi-line);
	border-radius: var(--cgroi-radius);
	background: var(--cgroi-bg);
}

/* Tables */
.cgroi .cgroi-table {
	width: 100%;
	margin: 0.75rem 0 0;
	border: 0;
	border-collapse: collapse;
	font-size: 0.95rem;
	table-layout: auto;
}

.cgroi .cgroi-table th,
.cgroi .cgroi-table td {
	padding: 0.7rem 0.75rem;
	border: 0;
	border-bottom: 1px solid var(--cgroi-line);
	background: transparent;
	color: var(--cgroi-ink);
	text-align: left;
	vertical-align: middle;
}

.cgroi .cgroi-table thead th {
	border-bottom: 2px solid var(--cgroi-brand);
	font-size: 0.85rem;
	font-weight: 700;
	letter-spacing: 0.01em;
	white-space: nowrap;
}

.cgroi .cgroi-table tbody th {
	font-weight: 600;
}

.cgroi .cgroi-table tbody tr:hover {
	background: var(--cgroi-brand-tint);
}

.cgroi .cgroi-col-input,
.cgroi .cgroi-col-result {
	text-align: right;
	white-space: nowrap;
}

.cgroi .cgroi-table thead th.cgroi-col-input,
.cgroi .cgroi-table thead th.cgroi-col-result {
	text-align: right;
}

.cgroi .cgroi-col-result {
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.cgroi .cgroi-partner,
.cgroi .cgroi-note {
	display: block;
	margin-top: 0.15rem;
	color: var(--cgroi-muted);
	font-size: 0.85rem;
	font-weight: 400;
}

/* Yes/No switch */
.cgroi .cgroi-switch {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0;
	cursor: pointer;
	font-weight: 600;
}

/*
 * Extra specificity beats theme-wide checkbox rules such as Kubio's
 * "[data-kubio] input[type=checkbox] { position: relative; bottom: .15rem; ... }",
 * which would otherwise pull the hidden input back into the layout.
 */
.cgroi .cgroi-switch input.cgroi-switch__input[type="checkbox"] {
	position: absolute;
	inset: 0;
	bottom: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	font-size: inherit;
	vertical-align: baseline;
	opacity: 0;
	cursor: pointer;
}

.cgroi .cgroi-switch .cgroi-switch__track {
	position: relative;
	display: inline-block;
	flex: 0 0 auto;
	width: 2.9rem;
	min-width: 2.9rem;
	height: 1.6rem;
	border: 2px solid var(--cgroi-muted);
	border-radius: 999px;
	background: #fff;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.cgroi .cgroi-switch__track::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: calc(1.6rem - 8px);
	height: calc(1.6rem - 8px);
	border-radius: 50%;
	background: var(--cgroi-muted);
	transition: transform 0.15s ease, background-color 0.15s ease;
}

.cgroi .cgroi-switch__input:checked + .cgroi-switch__track {
	border-color: var(--cgroi-brand-dark);
	background: var(--cgroi-brand);
}

.cgroi .cgroi-switch__input:checked + .cgroi-switch__track::after {
	background: var(--cgroi-on-brand);
	transform: translateX(1.3rem);
}

.cgroi .cgroi-switch__input:focus-visible + .cgroi-switch__track {
	outline: 3px solid var(--cgroi-focus);
	outline-offset: 2px;
}

.cgroi .cgroi-switch__input:disabled ~ * {
	opacity: 0.65;
	cursor: default;
}

.cgroi .cgroi-switch__state {
	min-width: 2em;
	text-align: left;
}

.cgroi .cgroi-switch__yes,
.cgroi .cgroi-switch__input:checked ~ .cgroi-switch__state .cgroi-switch__no {
	display: none;
}

.cgroi .cgroi-switch__input:checked ~ .cgroi-switch__state .cgroi-switch__yes {
	display: inline;
}

/* Inputs */
.cgroi input[type="text"],
.cgroi input[type="email"],
.cgroi input[type="number"] {
	width: 100%;
	min-height: 2.75rem;
	margin: 0;
	padding: 0.55rem 0.75rem;
	border: 1px solid #8a8a8c; /* 3.4:1 against white for the field boundary */
	border-radius: 6px;
	background: #fff;
	color: var(--cgroi-ink);
	font: inherit;
	box-shadow: none;
}

.cgroi input.cgroi-number {
	width: 5.5rem;
	text-align: right;
}

.cgroi input:focus-visible,
.cgroi summary:focus-visible,
.cgroi a:focus-visible,
.cgroi button:focus-visible {
	outline: 3px solid var(--cgroi-focus);
	outline-offset: 2px;
}

.cgroi input[aria-invalid="true"] {
	border-color: var(--cgroi-error);
	box-shadow: 0 0 0 1px var(--cgroi-error);
}

.cgroi input:disabled {
	background: #f4f4f4;
	color: var(--cgroi-ink);
}

.cgroi .cgroi-fields {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 1rem;
	margin: 1rem 0;
}

.cgroi .cgroi-field label {
	display: block;
	margin-bottom: 0.3rem;
	font-weight: 600;
}

.cgroi .cgroi-req,
.cgroi .cgroi-opt {
	color: var(--cgroi-muted);
	font-size: 0.85em;
	font-weight: 400;
}

.cgroi .cgroi-field__error {
	margin: 0.3rem 0 0;
	color: var(--cgroi-error);
	font-size: 0.9rem;
	font-weight: 600;
}

.cgroi .cgroi-check {
	display: flex;
	align-items: flex-start;
	gap: 0.6rem;
	margin: 0.75rem 0 0;
}

.cgroi .cgroi-check input[type="checkbox"] {
	position: static;
	bottom: auto;
	flex: 0 0 auto;
	width: 1.25rem;
	height: 1.25rem;
	margin: 0.15rem 0 0;
	font-size: inherit;
	vertical-align: top;
	accent-color: var(--cgroi-brand-dark);
}

.cgroi .cgroi-check label {
	margin: 0;
	font-weight: 400;
}

.cgroi a {
	color: var(--cgroi-brand-dark);
	text-decoration: underline;
}

/* Honeypot: off-screen, not display:none (some bots skip hidden fields). */
.cgroi .cgroi-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.cgroi .cgroi-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.cgroi .cgroi-turnstile {
	margin-top: 1rem;
}

/* Buttons: pill shape to match the site. */
.cgroi .cgroi-btn {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 3rem;
	margin: 1.25rem 0 0;
	padding: 0.8rem 1.9rem;
	border: 2px solid transparent;
	border-radius: 999px;
	font: inherit;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

/*
 * Button and link colours use !important because themes and page builders (WPBakery, Kubio)
 * colour links with ID-based selectors such as "#kubio .style-123 a",
 * which no class selector can beat. Scoped to .cgroi, so nothing leaks out.
 */
.cgroi .cgroi-btn--primary,
.cgroi a.cgroi-btn--primary:link,
.cgroi a.cgroi-btn--primary:visited {
	background: var(--cgroi-brand) !important;
	color: var(--cgroi-on-brand) !important;
	text-decoration: none !important;
}

.cgroi .cgroi-btn--primary:hover,
.cgroi .cgroi-btn--primary:focus,
.cgroi a.cgroi-btn--primary:hover,
.cgroi a.cgroi-btn--primary:focus {
	background: #00525f !important;
	color: var(--cgroi-on-brand) !important;
}

.cgroi .cgroi-btn--secondary,
.cgroi .cgroi-btn--secondary:hover,
.cgroi .cgroi-btn--secondary:focus {
	border-color: var(--cgroi-brand-dark) !important;
	background: #fff !important;
	color: var(--cgroi-brand-dark) !important;
}

.cgroi .cgroi-btn--secondary:hover {
	background: var(--cgroi-brand-tint) !important;
}

/* Button labels and sublines always take the button's colour. */
.cgroi .cgroi-btn span {
	color: inherit !important;
}

/* Other links (e.g. privacy policy): dark gold passes contrast on white; theme gold does not. */
.cgroi a:not(.cgroi-btn),
.cgroi a:not(.cgroi-btn):visited,
.cgroi a:not(.cgroi-btn):hover {
	color: var(--cgroi-brand-dark) !important;
	text-decoration: underline !important;
}

.cgroi .cgroi-btn[disabled] {
	opacity: 0.7;
	cursor: progress;
}

.cgroi .cgroi-btn__sub {
	display: block;
	margin-top: 0.2rem;
	font-size: 0.82rem;
	font-weight: 400;
}

.cgroi .cgroi-alert {
	margin: 1rem 0 0;
	padding: 0.75rem 1rem;
	border-left: 4px solid var(--cgroi-error);
	border-radius: 4px;
	background: #fdf0ef;
	color: var(--cgroi-error);
	font-weight: 600;
}

/* Results */
.cgroi .cgroi__results {
	border: 2px solid var(--cgroi-brand);
	background: var(--cgroi-brand-tint);
}

.cgroi .cgroi-totals {
	width: 100%;
	max-width: 640px;
	margin: 0.75rem 0 1rem;
	border-collapse: collapse;
	background: #fff;
	font-size: 1rem;
	font-variant-numeric: tabular-nums;
}

.cgroi .cgroi-totals th,
.cgroi .cgroi-totals td {
	padding: 0.65rem 0.85rem;
	border: 0;
	border-bottom: 1px solid var(--cgroi-line);
	color: var(--cgroi-ink);
	text-align: left;
}

.cgroi .cgroi-totals td,
.cgroi .cgroi-totals thead th:not(:first-child) {
	text-align: right;
	white-space: nowrap;
}

.cgroi .cgroi-totals thead th {
	border-bottom: 2px solid var(--cgroi-brand);
	font-size: 0.85rem;
}

.cgroi .cgroi-totals tr.is-strong th,
.cgroi .cgroi-totals tr.is-strong td {
	font-weight: 700;
}

.cgroi .cgroi-totals tr.is-net th,
.cgroi .cgroi-totals tr.is-net td {
	border-bottom: 0;
	background: var(--cgroi-accent-tint);
	font-size: 1.1rem;
}

.cgroi .cgroi-subtitle {
	margin: 1.5rem 0 0;
	font-family: var(--cgroi-heading-font);
	font-size: 1.1rem;
	font-weight: 500;
	color: var(--cgroi-ink);
}

.cgroi .cgroi-breakeven {
	margin: 0 0 0.75rem;
	padding: 0;
	list-style: none;
}

.cgroi .cgroi-breakeven li {
	margin: 0 0 0.35rem;
}

.cgroi .cgroi-negative {
	padding: 0.75rem 1rem;
	border-left: 4px solid var(--cgroi-brand-dark);
	background: #fff;
}

.cgroi .cgroi-confirm {
	color: var(--cgroi-success);
	font-weight: 600;
}

.cgroi .cgroi-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.75rem 1rem;
}

.cgroi .cgroi-actions .cgroi-btn {
	margin-top: 0.5rem;
}

/* Compliance and FAQ */
.cgroi .cgroi__compliance {
	padding: 1.25rem 1.5rem;
	border-radius: var(--cgroi-radius);
	background: var(--cgroi-accent-tint);
	color: var(--cgroi-ink);
	font-size: 0.9rem;
}

.cgroi .cgroi__compliance p:last-child {
	margin-bottom: 0;
}

.cgroi .cgroi__faq {
	margin-top: 2.5rem;
}

.cgroi .cgroi-faq {
	border-bottom: 1px solid var(--cgroi-line);
}

.cgroi .cgroi-faq summary {
	padding: 0.9rem 0;
	cursor: pointer;
	font-weight: 600;
}

.cgroi .cgroi-faq p {
	padding-bottom: 0.75rem;
}

/* Your firm: number of partners. */
.cgroi .cgroi-fields--firm {
	grid-template-columns: minmax(0, 16rem);
	margin-top: 0.5rem;
}

.cgroi .cgroi-fields--firm input.cgroi-number {
	width: 7rem;
}





/* Marketing: what the firm pays now, as "£ [ ] a month" or "£ [ ] a day × [ ] days a year". */
.cgroi .cgroi-spend {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.35rem 0.75rem;
}

.cgroi .cgroi-spend__item {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	margin: 0;
	font-weight: 400;
	white-space: nowrap;
}

.cgroi .cgroi-spend__pound {
	font-weight: 600;
}

.cgroi .cgroi-spend__unit {
	color: var(--cgroi-muted);
	font-size: 0.9rem;
}

.cgroi input.cgroi-number--money {
	width: 6.5rem;
}

.cgroi input.cgroi-number--qty {
	width: 4.5rem;
}

/* The spend column reads left to right: £ [amount] a month. */
.cgroi .cgroi-table--marketing .cgroi-col-input,
.cgroi .cgroi-table--marketing thead th.cgroi-col-input {
	text-align: left;
}

.cgroi .cgroi__hint--after {
	margin: 0.75rem 0 0;
	font-size: 0.9rem;
}

/* Training: spend, people and (after submission) the saving side by side. */
.cgroi .cgroi-fields--training {
	grid-template-columns: repeat(3, minmax(0, 14rem));
	align-items: end;
}

.cgroi .cgroi-fields--training input.cgroi-number--money {
	width: 9rem;
}

.cgroi .cgroi-field__label {
	display: block;
	margin-bottom: 0.3rem;
	font-weight: 600;
}

.cgroi .cgroi-field__value {
	display: block;
	padding: 0.5rem 0;
	color: var(--cgroi-brand-dark);
	font-size: 1.1rem;
}

.cgroi .cgroi-fields--training .cgroi-col-result {
	text-align: left;
}

.cgroi .cgroi-marketing-note {
	margin: 0.75rem 0 0;
}

.cgroi .cgroi-summary {
	margin: 0.75rem 0 0;
	color: var(--cgroi-brand-dark);
	font-weight: 700;
}

/* Narrow column: tighten the tables. Container queries follow the calculator's own width, so it adapts to page builder columns as well as screens. */
@container cgroi (max-width: 960px) {
	.cgroi .cgroi-fields {
		grid-template-columns: 1fr;
	}

	.cgroi .cgroi-table th,
	.cgroi .cgroi-table td {
		padding: 0.6rem 0.5rem;
	}
}

/* Narrower than the six-column tables need: tables become stacked cards. */
@container cgroi (max-width: 900px) {
	.cgroi .cgroi__section {
		padding: 1rem;
	}

	.cgroi .cgroi-table,
	.cgroi .cgroi-table tbody,
	.cgroi .cgroi-table tr,
	.cgroi .cgroi-table th,
	.cgroi .cgroi-table td {
		display: block;
		width: 100%;
	}

	.cgroi .cgroi-table thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
	}

	.cgroi .cgroi-table tbody tr {
		margin: 0 0 0.85rem;
		padding: 0.75rem 0.9rem;
		border: 1px solid var(--cgroi-line);
		border-radius: 8px;
	}

	.cgroi .cgroi-table tbody th,
	.cgroi .cgroi-table tbody td {
		padding: 0.3rem 0;
		border: 0;
		text-align: left;
		white-space: normal;
	}

	.cgroi .cgroi-table tbody th {
		padding-bottom: 0.4rem;
		font-size: 1.05rem;
	}

	.cgroi .cgroi-table tbody td[data-label] {
		display: flex;
		justify-content: space-between;
		align-items: center;
		gap: 1rem;
		text-align: right;
	}

	.cgroi .cgroi-table tbody td[data-label]::before {
		content: attr(data-label);
		flex: 0 0 42%;
		text-align: left;
		color: var(--cgroi-muted);
		font-size: 0.85rem;
		font-weight: 600;
	}

	.cgroi .cgroi-table tbody td[data-empty] {
		display: none;
	}

	.cgroi .cgroi-table tbody td.cgroi-col-input,
	.cgroi .cgroi-table tbody td.cgroi-col-result {
		margin-top: 0.35rem;
		padding-top: 0.6rem;
		border-top: 1px solid var(--cgroi-line);
	}

	.cgroi .cgroi-table tbody td.cgroi-col-input + td.cgroi-col-result {
		margin-top: 0;
		border-top: 0;
	}

	.cgroi .cgroi-totals th,
	.cgroi .cgroi-totals td {
		padding: 0.55rem 0.5rem;
		font-size: 0.95rem;
	}

	/* Marketing spend: question above, boxes below, so "days a year" never spills out. */
	.cgroi .cgroi-table--marketing tbody td.cgroi-col-input[data-label] {
		flex-direction: column;
		align-items: flex-start;
		gap: 0.5rem;
	}

	.cgroi .cgroi-table--marketing tbody td.cgroi-col-input[data-label]::before {
		flex: 0 0 auto;
	}

	.cgroi .cgroi-btn {
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cgroi * {
		transition: none !important;
	}
}
