/*
 * NWEH Exam Application – public form.
 * Palette derived from Primary #4D4289 and Secondary #C5A87D.
 * Contrast (WCAG 2.1): white on primary-500 8.6:1; primary-800 on secondary-400 6.0:1;
 * secondary-700 on white 6.0:1; neutral-600 on white 6.6:1; error on white 6.5:1.
 * Raw secondary-400 is never used for text on white (2.3:1) – fills and accents only.
 */
.nweh-form {
	--nweh-primary-50: #f3f1f9;
	--nweh-primary-100: #e4e0f1;
	--nweh-primary-200: #c9c2e3;
	--nweh-primary-400: #7d70b2;
	--nweh-primary-500: #4d4289;
	--nweh-primary-700: #3a3169;
	--nweh-primary-800: #2e2852;
	--nweh-secondary-50: #fbf7f1;
	--nweh-secondary-100: #f4ecdf;
	--nweh-secondary-200: #e8d9c1;
	--nweh-secondary-400: #c5a87d;
	--nweh-secondary-700: #7a5f32;
	--nweh-neutral-900: #2b2838;
	--nweh-neutral-600: #5e5a70;
	--nweh-neutral-100: #eeedf3;
	--nweh-disabled-text: #66627a;
	--nweh-white: #fff;
	--nweh-error: #b3261e;
	--nweh-error-bg: #fcebea;
	--nweh-success: #1e6b3a;
	--nweh-success-bg: #e7f4ec;
	--nweh-radius: 8px;
	--nweh-focus: 0 0 0 2px var(--nweh-white), 0 0 0 5px var(--nweh-primary-500);

	box-sizing: border-box;
	max-width: 820px;
	margin: 0 auto;
	padding: 0 16px 32px;
	color: var(--nweh-neutral-900);
	font-size: 1rem;
	line-height: 1.55;
	scroll-margin-top: 24px;
}
.nweh-form *,
.nweh-form *::before,
.nweh-form *::after {
	box-sizing: inherit;
}
.nweh-form [hidden] {
	display: none !important;
}
/* Keep fields clear of the sticky progress bar when scrolled to. */
.nweh-form .nweh-field,
.nweh-form .nweh-error-summary,
.nweh-form .nweh-step__title {
	scroll-margin-top: 110px;
}

.nweh-visually-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}
.nweh-hp {
	position: absolute;
	left: -10000px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* Header ---------------------------------------------------------------- */
.nweh-header {
	padding: 24px 0 8px;
}
.nweh-title {
	margin: 0 0 8px;
	color: var(--nweh-primary-800);
	font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.1rem);
	line-height: 1.2;
}
.nweh-intro {
	margin: 0 0 8px;
}
.nweh-nopay {
	display: inline-block;
	margin: 0;
	padding: 4px 12px;
	border-radius: 999px;
	background: var(--nweh-secondary-100);
	color: var(--nweh-secondary-700);
	font-size: 0.875rem;
	font-weight: 600;
}

/* Progress -------------------------------------------------------------- */
.nweh-progress {
	position: sticky;
	top: 0;
	z-index: 5;
	margin: 16px -16px 16px;
	padding: 12px 16px;
	background: var(--nweh-white);
	border-bottom: 1px solid var(--nweh-primary-100);
}
.admin-bar .nweh-progress {
	top: 46px;
}
.nweh-progress__compact {
	margin: 0 0 8px;
	color: var(--nweh-primary-800);
	font-weight: 700;
	font-size: 0.95rem;
}
.nweh-progress__list {
	display: flex;
	gap: 4px;
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: none;
}
.nweh-progress__item {
	flex: 1 1 0;
	height: 6px;
	border-radius: 3px;
	background: var(--nweh-primary-100);
}
.nweh-progress__item.is-done {
	background: var(--nweh-secondary-400);
}
.nweh-progress__item.is-current {
	background: var(--nweh-primary-500);
}
.nweh-progress__num,
.nweh-progress__label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
}

@media (min-width: 720px) {
	.nweh-progress {
		margin-left: 0;
		margin-right: 0;
		border: 1px solid var(--nweh-primary-100);
		border-radius: var(--nweh-radius);
	}
	.nweh-progress__compact {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
	}
	.nweh-progress__item {
		position: relative;
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 6px;
		height: auto;
		background: none;
		text-align: center;
		font-size: 0.8rem;
		color: var(--nweh-neutral-600);
	}
	.nweh-progress__item.is-done,
	.nweh-progress__item.is-current {
		background: none;
	}
	.nweh-progress__item::before {
		content: "";
		position: absolute;
		top: 16px;
		left: calc(-50% + 18px);
		right: calc(50% + 18px);
		height: 2px;
		background: var(--nweh-primary-100);
	}
	.nweh-progress__item:first-child::before {
		display: none;
	}
	.nweh-progress__item.is-done::before,
	.nweh-progress__item.is-current::before {
		background: var(--nweh-secondary-400);
	}
	.nweh-progress__num,
	.nweh-progress__label {
		position: static;
		width: auto;
		height: auto;
		overflow: visible;
		clip: auto;
	}
	.nweh-progress__num {
		display: grid;
		place-items: center;
		width: 32px;
		height: 32px;
		border: 2px solid var(--nweh-primary-200);
		border-radius: 50%;
		background: var(--nweh-white);
		color: var(--nweh-neutral-600);
		font-weight: 700;
	}
	.nweh-progress__item.is-done .nweh-progress__num {
		border-color: var(--nweh-secondary-400);
		background: var(--nweh-secondary-400);
		color: var(--nweh-primary-800);
	}
	.nweh-progress__item.is-current .nweh-progress__num {
		border-color: var(--nweh-primary-500);
		background: var(--nweh-primary-500);
		color: var(--nweh-white);
	}
	.nweh-progress__item.is-current {
		color: var(--nweh-primary-800);
		font-weight: 700;
	}
}

/* Layout ---------------------------------------------------------------- */
.nweh-body {
	margin: 0;
}
.nweh-step__title {
	margin: 8px 0 16px;
	color: var(--nweh-primary-800);
	font-size: 1.5rem;
	line-height: 1.25;
}
.nweh-step__title:focus {
	outline: none;
}
.nweh-section {
	display: flex;
	flex-wrap: wrap;
	gap: 0 16px;
	margin: 0 0 24px;
	padding: 20px 16px 4px;
	border: 1px solid var(--nweh-primary-100);
	border-radius: var(--nweh-radius);
	background: var(--nweh-white);
}
.nweh-section > * {
	flex: 1 1 100%;
}
.nweh-section__title {
	margin: 0 0 12px;
	color: var(--nweh-primary-800);
	font-size: 1.15rem;
}
.nweh-required-note {
	margin: 0 0 16px;
	color: var(--nweh-neutral-600);
	font-size: 0.9rem;
}
.nweh-muted {
	color: var(--nweh-neutral-600);
}

/* Fields ---------------------------------------------------------------- */
.nweh-field {
	margin: 0 0 20px;
	padding: 0;
	border: 0;
	min-width: 0;
}
@media (min-width: 640px) {
	.nweh-section > .nweh-field--half {
		flex: 1 1 calc(50% - 8px);
		max-width: calc(50% - 8px);
	}
}
.nweh-label {
	display: block;
	margin: 0 0 6px;
	padding: 0;
	font-weight: 600;
	color: var(--nweh-neutral-900);
}
.nweh-req {
	display: none;
	color: var(--nweh-error);
	font-weight: 700;
}
.is-required > .nweh-label .nweh-req,
.is-required > legend .nweh-req,
.is-required .nweh-check .nweh-req {
	display: inline;
}
.nweh-help {
	margin: -2px 0 8px;
	color: var(--nweh-neutral-600);
	font-size: 0.9rem;
}
.nweh-form input[type="text"],
.nweh-form input[type="email"],
.nweh-form input[type="tel"],
.nweh-form input[type="date"],
.nweh-form select,
.nweh-form textarea {
	display: block;
	width: 100%;
	min-height: 48px;
	margin: 0;
	padding: 10px 12px;
	border: 2px solid var(--nweh-primary-400);
	border-radius: 6px;
	background: var(--nweh-white);
	color: var(--nweh-neutral-900);
	font: inherit;
	line-height: 1.4;
	box-shadow: none;
}
.nweh-form textarea {
	min-height: 110px;
	resize: vertical;
}
.nweh-form input:hover,
.nweh-form select:hover,
.nweh-form textarea:hover {
	border-color: var(--nweh-primary-500);
}
.nweh-form input:focus-visible,
.nweh-form select:focus-visible,
.nweh-form textarea:focus-visible,
.nweh-form button:focus-visible,
.nweh-form a:focus-visible,
.nweh-form .nweh-file-btn:focus-within,
.nweh-error-summary:focus {
	outline: 3px solid transparent;
	box-shadow: var(--nweh-focus);
}
.nweh-form input:disabled,
.nweh-form select:disabled,
.nweh-form textarea:disabled {
	border-color: var(--nweh-primary-200);
	background: var(--nweh-neutral-100);
	color: var(--nweh-disabled-text);
}

/* Radios / checkboxes as large touch targets */
.nweh-choices {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.nweh-choices--stack {
	flex-direction: column;
}
.nweh-choice,
.nweh-check {
	position: relative;
	display: flex;
	align-items: flex-start;
	gap: 10px;
	min-height: 48px;
	padding: 12px 14px;
	border: 2px solid var(--nweh-primary-200);
	border-radius: 6px;
	background: var(--nweh-white);
	cursor: pointer;
}
.nweh-choice {
	flex: 1 1 auto;
}
.nweh-choice:hover,
.nweh-check:hover {
	border-color: var(--nweh-primary-400);
	background: var(--nweh-primary-50);
}
.nweh-choice:has(input:checked),
.nweh-check:has(input:checked) {
	border-color: var(--nweh-primary-500);
	background: var(--nweh-primary-50);
}
.nweh-choice input,
.nweh-check input {
	flex: 0 0 auto;
	width: 20px;
	height: 20px;
	margin: 2px 0 0;
	accent-color: var(--nweh-primary-500);
}
.nweh-check a,
.nweh-form a {
	color: var(--nweh-primary-500);
	text-decoration: underline;
	text-underline-offset: 2px;
}
.nweh-form a:hover {
	color: var(--nweh-primary-700);
}

/* Errors ---------------------------------------------------------------- */
.nweh-error {
	margin: 6px 0 0;
	color: var(--nweh-error);
	font-weight: 600;
	font-size: 0.95rem;
}
.nweh-error::before {
	content: "! ";
}
.has-error > .nweh-label,
.has-error > legend {
	color: var(--nweh-error);
}
.has-error input[type="text"],
.has-error input[type="email"],
.has-error input[type="tel"],
.has-error input[type="date"],
.has-error select,
.has-error textarea,
.has-error .nweh-choice,
.has-error .nweh-check {
	border-color: var(--nweh-error);
}
.nweh-error-summary {
	margin: 0 0 24px;
	padding: 16px;
	border: 3px solid var(--nweh-error);
	border-radius: var(--nweh-radius);
	background: var(--nweh-white);
}
.nweh-error-summary__title {
	margin: 0 0 8px;
	font-size: 1.15rem;
	color: var(--nweh-error);
}
.nweh-error-summary__list {
	margin: 0;
	padding-left: 20px;
}
.nweh-error-summary__list a {
	color: var(--nweh-error);
	font-weight: 600;
}

/* Callouts / flash ------------------------------------------------------ */
.nweh-callout {
	margin: 0 0 16px;
	padding: 12px 16px;
	border-left: 4px solid var(--nweh-primary-500);
	border-radius: 0 6px 6px 0;
	background: var(--nweh-primary-50);
}
.nweh-callout--accent,
.nweh-callout--warn {
	border-left-color: var(--nweh-secondary-700);
	background: var(--nweh-secondary-100);
}
.nweh-callout--error {
	border-left-color: var(--nweh-error);
	background: var(--nweh-error-bg);
}
.nweh-callout__title {
	margin: 0 0 4px;
	font-size: 1rem;
	color: var(--nweh-primary-800);
}
.nweh-callout p:last-child {
	margin-bottom: 0;
}
.nweh-flash {
	margin: 0 0 16px;
	padding: 12px 16px;
	border-radius: 6px;
	background: var(--nweh-primary-50);
	font-weight: 600;
}
.nweh-flash--success {
	background: var(--nweh-success-bg);
	color: var(--nweh-success);
}
.nweh-flash--error {
	background: var(--nweh-error-bg);
	color: var(--nweh-error);
}

/* Buttons --------------------------------------------------------------- */
.nweh-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-height: 48px;
	padding: 10px 22px;
	border: 2px solid transparent;
	border-radius: 6px;
	font: inherit;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
	text-decoration: none !important;
	cursor: pointer;
	transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.nweh-btn--primary {
	background: var(--nweh-primary-500);
	color: var(--nweh-white) !important;
}
.nweh-btn--primary:hover {
	background: var(--nweh-primary-700);
}
.nweh-btn--secondary {
	background: var(--nweh-secondary-400);
	color: var(--nweh-primary-800) !important;
}
.nweh-btn--secondary:hover {
	background: var(--nweh-secondary-200);
}
.nweh-btn--ghost {
	border-color: var(--nweh-primary-500);
	background: var(--nweh-white);
	color: var(--nweh-primary-500) !important;
}
.nweh-btn--ghost:hover {
	background: var(--nweh-primary-50);
	color: var(--nweh-primary-700) !important;
}
.nweh-btn--link,
.nweh-link-btn {
	min-height: 44px;
	padding: 8px 4px;
	border: 0;
	background: none;
	color: var(--nweh-primary-500);
	font: inherit;
	font-weight: 600;
	text-decoration: underline !important;
	text-underline-offset: 3px;
	cursor: pointer;
}
.nweh-link-btn {
	display: block;
	margin: -8px 0 16px;
	text-align: left;
}
.nweh-btn--small {
	min-height: 40px;
	padding: 6px 12px;
	font-size: 0.9rem;
}
.nweh-btn:disabled {
	border-color: var(--nweh-neutral-100);
	background: var(--nweh-neutral-100);
	color: var(--nweh-disabled-text) !important;
	cursor: not-allowed;
}

.nweh-nav {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
	margin-top: 24px;
	padding-top: 16px;
	border-top: 1px solid var(--nweh-primary-100);
}
.nweh-nav .nweh-next,
.nweh-nav .nweh-submit {
	margin-left: auto;
}
@media (max-width: 559px) {
	.nweh-nav {
		flex-direction: column-reverse;
		align-items: stretch;
	}
	.nweh-nav .nweh-btn {
		width: 100%;
		margin-left: 0;
	}
}

/* Exams ----------------------------------------------------------------- */
.nweh-series-line {
	margin: 0 0 12px;
	font-weight: 700;
	color: var(--nweh-primary-800);
}
.nweh-exam-list {
	display: grid;
	gap: 12px;
	margin: 0 0 16px;
}
.nweh-exam-card {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 4px 16px;
	padding: 14px 16px;
	border: 2px solid var(--nweh-primary-100);
	border-left: 6px solid var(--nweh-secondary-400);
	border-radius: var(--nweh-radius);
	background: var(--nweh-white);
}
.nweh-exam-card.is-editing {
	border-color: var(--nweh-primary-500);
}
.nweh-exam-card__title {
	margin: 0;
	font-size: 1.05rem;
	color: var(--nweh-primary-800);
}
.nweh-exam-card__meta {
	margin: 2px 0 0;
	color: var(--nweh-neutral-600);
	font-size: 0.9rem;
}
.nweh-exam-card__fee {
	margin: 0;
	font-weight: 700;
	text-align: right;
}
.nweh-exam-card__actions {
	grid-column: 1 / -1;
	display: flex;
	gap: 8px;
}
.nweh-exam-builder {
	display: flex;
	flex-wrap: wrap;
	gap: 0 16px;
	margin: 0 0 16px;
	padding: 20px 16px 8px;
	border: 2px dashed var(--nweh-primary-400);
	border-radius: var(--nweh-radius);
	background: var(--nweh-primary-50);
}
.nweh-exam-builder > * {
	flex: 1 1 100%;
}
@media (min-width: 640px) {
	.nweh-exam-builder > [data-builder="nweh-b-level"],
	.nweh-exam-builder > [data-builder="nweh-b-org"] {
		flex: 1 1 calc(50% - 8px);
	}
}
.nweh-static {
	margin: 0;
	padding: 10px 12px;
	border-radius: 6px;
	background: var(--nweh-white);
	font-weight: 700;
	font-size: 1.05rem;
	color: var(--nweh-primary-800);
}
.nweh-builder-fee {
	margin: 0 0 12px;
	font-weight: 600;
}
.nweh-builder-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin-bottom: 12px;
}
.nweh-add-exam {
	margin: 0 0 24px;
}

/* Cost summary ---------------------------------------------------------- */
.nweh-cost {
	margin: 0 0 24px;
}
.nweh-cost__table {
	width: 100%;
	border-collapse: collapse;
	margin: 0 0 8px;
	border: 1px solid var(--nweh-primary-100);
	font-size: 0.95rem;
}
.nweh-cost__title {
	padding: 12px 14px;
	background: var(--nweh-primary-500);
	color: var(--nweh-white);
	font-weight: 700;
	text-align: left;
}
.nweh-cost__table th,
.nweh-cost__table td {
	padding: 10px 14px;
	border-bottom: 1px solid var(--nweh-primary-100);
	text-align: left;
	vertical-align: top;
}
.nweh-cost__table td:last-child {
	text-align: right;
	white-space: nowrap;
}
.nweh-cost__table thead th {
	background: var(--nweh-primary-50);
	color: var(--nweh-primary-800);
}
.nweh-cost__table thead th:last-child {
	text-align: right;
}
.nweh-cost__table tfoot th,
.nweh-cost__table tfoot td {
	background: var(--nweh-secondary-100);
	font-weight: 700;
	border-bottom: 0;
}
@media (max-width: 479px) {
	.nweh-cost__table td:last-child {
		white-space: normal;
	}
}
.nweh-cost__band {
	margin: 0 0 4px;
	font-weight: 600;
	color: var(--nweh-secondary-700);
}
.nweh-cost__note {
	margin: 8px 0 0;
	color: var(--nweh-neutral-600);
	font-size: 0.875rem;
}

/* Files ----------------------------------------------------------------- */
.nweh-file-list {
	margin: 0 0 8px;
	padding: 0;
	list-style: none;
}
.nweh-file {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin: 0 0 6px;
	padding: 8px 12px;
	border-radius: 6px;
	background: var(--nweh-success-bg);
}
.nweh-file__name {
	font-weight: 600;
	word-break: break-all;
}
.nweh-file__size {
	color: var(--nweh-neutral-600);
	font-size: 0.875rem;
	margin-right: auto;
}
.nweh-file-btn {
	position: relative;
}
.nweh-file-status {
	display: block;
	margin-top: 6px;
	font-size: 0.9rem;
	color: var(--nweh-neutral-600);
}
.is-busy .nweh-file-btn {
	opacity: 0.6;
	pointer-events: none;
}
.nweh-help--types {
	font-size: 0.85rem;
}
.nweh-alt-route {
	margin: 0 0 20px;
	padding: 16px;
	border: 2px solid var(--nweh-secondary-400);
	border-radius: var(--nweh-radius);
	background: var(--nweh-secondary-50);
}

/* Review ---------------------------------------------------------------- */
.nweh-review {
	display: grid;
	gap: 16px;
	margin: 0 0 24px;
}
.nweh-review__card {
	border: 1px solid var(--nweh-primary-100);
	border-radius: var(--nweh-radius);
	overflow: hidden;
}
.nweh-review__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 8px 8px 8px 16px;
	background: var(--nweh-primary-50);
}
.nweh-review__title {
	margin: 0;
	font-size: 1.05rem;
	color: var(--nweh-primary-800);
}
.nweh-review__list {
	margin: 0;
	padding: 4px 16px 8px;
}
.nweh-review__row {
	display: grid;
	gap: 2px;
	padding: 8px 0;
	border-bottom: 1px solid var(--nweh-primary-50);
}
.nweh-review__row:last-child {
	border-bottom: 0;
}
.nweh-review__row dt {
	color: var(--nweh-neutral-600);
	font-size: 0.9rem;
}
.nweh-review__row dd {
	margin: 0;
	font-weight: 600;
	white-space: pre-line;
	word-break: break-word;
}
@media (min-width: 640px) {
	.nweh-review__row {
		grid-template-columns: 40% 1fr;
		gap: 16px;
	}
}

/* Confirmation ---------------------------------------------------------- */
.nweh-confirmation {
	padding: 32px 16px;
	border: 2px solid var(--nweh-secondary-400);
	border-radius: var(--nweh-radius);
	background: var(--nweh-secondary-50);
	text-align: center;
}
.nweh-confirmation__icon {
	display: grid;
	place-items: center;
	width: 64px;
	height: 64px;
	margin: 0 auto 12px;
	border-radius: 50%;
	background: var(--nweh-primary-500);
	color: var(--nweh-white);
	font-size: 2rem;
}
.nweh-confirmation__ref {
	display: inline-block;
	margin: 0 0 16px;
	padding: 8px 16px;
	border-radius: 6px;
	background: var(--nweh-white);
	color: var(--nweh-primary-800);
	font-size: 1.35rem;
	font-weight: 700;
	letter-spacing: 0.02em;
}
.is-submitted .nweh-nav {
	display: none;
}

/* Save dialog ----------------------------------------------------------- */
.nweh-dialog {
	width: min(520px, calc(100vw - 32px));
	padding: 0;
	border: 0;
	border-radius: var(--nweh-radius);
	color: var(--nweh-neutral-900);
	box-shadow: 0 20px 50px rgba(46, 40, 82, 0.35);
}
.nweh-dialog::backdrop {
	background: rgba(31, 27, 56, 0.55);
}
.nweh-dialog__form {
	padding: 24px;
}
.nweh-dialog__title {
	margin: 0 0 8px;
	color: var(--nweh-primary-800);
	font-size: 1.3rem;
}
.nweh-dialog__status {
	min-height: 1.5em;
	font-weight: 600;
	color: var(--nweh-success);
}
.nweh-dialog__actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 12px;
}

@media (prefers-reduced-motion: reduce) {
	.nweh-form * {
		transition: none !important;
		scroll-behavior: auto !important;
	}
}
@media print {
	.nweh-progress,
	.nweh-nav,
	.nweh-file-btn {
		display: none !important;
	}
}
