/*
 * ib-forms — public form. Mobile first (375px), RTL, logical properties only.
 * Everything is scoped under .ibf; controls use a doubled .ibf.ibf root so the
 * site theme (Amity + Elementor) cannot restyle them.
 *
 * Theme tokens (set inline from the form's appearance settings):
 *   --ibf-primary --ibf-secondary --ibf-text --ibf-accent --ibf-background
 *   --ibf-success --ibf-error --ibf-radius --ibf-scale
 * Components only read the derived --_* tokens below, so dark mode can swap them.
 * White on --ibf-primary (orange) is below 4.5:1: actions use --ibf-secondary (blue);
 * orange is for progress, markers and accents (with dark text when it is a fill).
 */

.ibf {
	--ibf-primary: #f27731;
	--ibf-secondary: #05629f;
	--ibf-text: #101840;
	--ibf-accent: #f2b12f;
	--ibf-background: #e2ebf1;
	--ibf-success: #1d6b3a;
	--ibf-error: #b3261e;
	--ibf-radius: 10px;
	--ibf-scale: 1;

	--_zoom: 1;
	--_page: var(--ibf-background);
	--_surface: #fff;
	--_surface-2: color-mix(in srgb, var(--ibf-background) 35%, #fff);
	--_ink: var(--ibf-text);
	--_muted: color-mix(in srgb, var(--ibf-text) 72%, #fff);
	--_line: color-mix(in srgb, var(--ibf-text) 14%, #fff);
	--_field-line: color-mix(in srgb, var(--ibf-text) 48%, #fff);
	--_input-bg: #fff;
	--_action: var(--ibf-secondary);
	--_action-hover: color-mix(in srgb, var(--ibf-secondary) 82%, #000);
	--_on-action: #fff;
	--_soft: color-mix(in srgb, var(--ibf-secondary) 8%, #fff);
	--_soft-line: color-mix(in srgb, var(--ibf-secondary) 30%, #fff);
	--_marker: var(--ibf-primary);
	--_on-marker: var(--ibf-text);
	--_err: var(--ibf-error);
	--_err-bg: color-mix(in srgb, var(--ibf-error) 7%, #fff);
	--_ok: var(--ibf-success);
	--_warn-bg: color-mix(in srgb, var(--ibf-accent) 20%, #fff);
	--_focus: var(--ibf-secondary);
	--_shadow: 0 1px 2px rgb(16 24 64 / 6%), 0 4px 16px rgb(16 24 64 / 6%);
	--_r: var(--ibf-radius);
	--_r-sm: calc(var(--ibf-radius) * 0.7);

	color-scheme: light;
	container: ibf / inline-size;
	display: block;
	box-sizing: border-box;
	inline-size: 100%;
	max-inline-size: 100%;
	margin: 0;
	padding: 0;
	background: none;
	color: var(--_ink);
	font-family: "Noto Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
	font-size: calc(17px * var(--ibf-scale) * var(--_zoom));
	font-weight: 400;
	line-height: 1.7;
	text-align: start;
	direction: rtl;
	scroll-margin-block-start: 80px;
	-webkit-text-size-adjust: 100%;
	overflow-wrap: anywhere;
}

.ibf--zoom {
	--_zoom: 1.18;
}

@media (prefers-color-scheme: dark) {
	.ibf {
		--_page: #0d1322;
		--_surface: #151d31;
		--_surface-2: #1a2440;
		--_ink: #e8edf6;
		--_muted: #aab4c8;
		--_line: #2a3553;
		--_field-line: #66739a;
		--_input-bg: #0f1628;
		--_action: color-mix(in srgb, var(--ibf-secondary) 45%, #fff);
		--_action-hover: color-mix(in srgb, var(--ibf-secondary) 30%, #fff);
		--_on-action: #0b1220;
		--_soft: color-mix(in srgb, var(--ibf-secondary) 24%, #151d31);
		--_soft-line: color-mix(in srgb, var(--ibf-secondary) 55%, #151d31);
		--_on-marker: #0b1220;
		--_err: color-mix(in srgb, var(--ibf-error) 45%, #fff);
		--_err-bg: color-mix(in srgb, var(--ibf-error) 18%, #151d31);
		--_ok: color-mix(in srgb, var(--ibf-success) 45%, #fff);
		--_warn-bg: color-mix(in srgb, var(--ibf-accent) 18%, #151d31);
		--_focus: color-mix(in srgb, var(--ibf-secondary) 45%, #fff);
		--_shadow: 0 1px 2px rgb(0 0 0 / 30%);

		color-scheme: dark;
	}
}

/* ------------------------------------------------------------ reset (theme-proof) */

.ibf *,
.ibf *::before,
.ibf *::after {
	box-sizing: border-box;
}

.ibf.ibf :where(h2, h3, h4, h5, p, ul, ol, li, dl, dt, dd, fieldset, legend, table, caption, th, td, figure, form, section, nav, header) {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	letter-spacing: normal;
	text-transform: none;
	text-align: start;
	line-height: inherit;
	box-shadow: none;
	min-inline-size: 0;
}

.ibf.ibf :where(ul, ol) {
	list-style: none;
}

.ibf.ibf :where(h2, h3, h4, h5) {
	font-weight: 700;
	line-height: 1.4;
	color: var(--_ink);
}

.ibf ::selection {
	background: color-mix(in srgb, var(--ibf-primary) 30%, transparent);
	color: inherit;
}

.ibf.ibf .ibf-input {
	caret-color: var(--_action);
}

.ibf :is(input, select, textarea, button, a, [tabindex="-1"]) {
	scroll-margin-block: 96px 132px; /* keep focused fields clear of the sticky action bar */
}

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

.ibf svg {
	display: block;
	flex: none;
}

.ibf .ibf-ico {
	display: inline-flex;
	flex: none;
}

.ibf .ibf-sr,
.ibf .ibf-hp {
	position: absolute !important;
	inline-size: 1px;
	block-size: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.ibf .ibf-hp {
	inset-inline-start: -10000px;
}

.ibf .ibf-muted {
	color: var(--_muted);
}

/* ------------------------------------------------------------ layout */

/*
 * Phones: one white sheet, edge to edge — no band, no card, 16px side padding.
 * From 600px of form width: the brand band with one card (step header, fields and
 * buttons) and, from 980px, the step list beside it.
 */

.ibf .ibf-app {
	display: grid;
	gap: 0;
	min-inline-size: 0;
	background: var(--_surface);
}

/*
 * On a phone the theme's own side gutter would eat the width: bleed the form to the screen
 * edges. !important only because WordPress's constrained layout pins child margins with it.
 * [ib_form bleed="0"] adds .ibf--nobleed and keeps the form inside its container.
 */
@media (max-width: 599.98px) {
	.ibf.ibf[data-form]:not(.ibf--nobleed) {
		inline-size: auto;
		max-inline-size: none;
		margin-inline: calc(50% - 50vw) !important;
	}
}

.ibf .ibf-head {
	display: grid;
	gap: 4px;
	padding: 20px 16px 4px;
}

.ibf.ibf .ibf-title {
	font-size: 1.5em;
	line-height: 1.4;
	text-wrap: balance;
}

.ibf .ibf-sub {
	color: var(--_muted);
	font-size: 0.95em;
	text-wrap: pretty;
}

.ibf .ibf-body {
	display: grid;
	gap: 16px;
	min-inline-size: 0;
}

.ibf .ibf-main {
	display: grid;
	gap: 20px;
	padding: 20px 16px 0;
	background: var(--_surface);
	min-inline-size: 0;
}

.ibf .ibf-rail {
	display: none;
}

.ibf .ibf-loading {
	padding: 24px 16px;
	text-align: center;
	color: var(--_muted);
	background: var(--_surface);
	border-radius: var(--_r);
}

/* ------------------------------------------------------------ step header + progress */

.ibf .ibf-progress {
	display: grid;
	gap: 2px;
}

.ibf .ibf-progress__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-block-start: -6px; /* the 48px zoom button sets the row height; keep the count close to the title */
}

.ibf.ibf .ibf-stepcount {
	color: var(--_action);
	font-size: 0.875em;
	font-weight: 700;
}

.ibf.ibf .ibf-steptitle {
	font-size: 1.4em;
	line-height: 1.4;
	text-wrap: balance;
	outline: none;
}

.ibf .ibf-progress__track {
	display: block;
	block-size: 6px;
	margin-block-start: 12px;
	border-radius: 999px;
	background: color-mix(in srgb, var(--_ink) 12%, transparent);
	overflow: hidden;
}

.ibf .ibf-progress__fill {
	display: block;
	block-size: 100%;
	inline-size: 0;
	border-radius: inherit;
	background: var(--_marker);
	transition: inline-size 0.35s ease;
}

/* ------------------------------------------------------------ fields */

.ibf .ibf-form {
	display: grid;
	gap: 20px;
	min-inline-size: 0;
}

.ibf .ibf-panel {
	display: grid;
	gap: 24px;
	min-inline-size: 0;
}

.ibf .ibf-intro {
	display: grid;
	gap: 6px;
	padding-block-end: 20px;
	border-block-end: 1px solid var(--_line);
}

.ibf .ibf-intro__text {
	text-wrap: pretty;
}

.ibf .ibf-intro__note {
	color: var(--_muted);
	font-size: 0.9em;
}

.ibf .ibf-grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 24px;
	min-inline-size: 0;
}

.ibf .ibf-field {
	display: grid;
	gap: 8px;
	align-content: start;
	min-inline-size: 0;
}

/* The hint belongs to its label: sit it close under it, then give the control room. */
.ibf .ibf-field > .ibf-label + .ibf-hint {
	margin-block-start: -6px;
}

.ibf .ibf-label {
	display: block;
	font-weight: 600;
	line-height: 1.55;
	color: var(--_ink);
}

.ibf .ibf-label__row {
	display: inline;
}

.ibf .ibf-optional {
	margin-inline-start: 6px;
	color: var(--_muted);
	font-size: 0.88em;
	font-weight: 400;
	white-space: nowrap;
}

.ibf .ibf-hint {
	color: var(--_muted);
	font-size: 0.9em;
	line-height: 1.6;
	text-wrap: pretty;
}

.ibf .ibf-err {
	display: flex;
	gap: 6px;
	color: var(--_err);
	font-size: 0.92em;
	font-weight: 600;
	line-height: 1.6;
}

.ibf .ibf-heading {
	display: grid;
	gap: 4px;
	grid-column: 1 / -1;
	margin-block-start: 8px;
	padding-block-start: 24px;
	border-block-start: 1px solid var(--_line);
}

.ibf.ibf .ibf-heading__title {
	font-size: 1.15em;
}

/* ------------------------------------------------------------ inputs */

.ibf.ibf .ibf-input {
	display: block;
	inline-size: 100%;
	max-inline-size: 100%;
	min-block-size: 52px;
	margin: 0;
	padding: 12px 14px;
	border: 1.5px solid var(--_field-line);
	border-radius: var(--_r-sm);
	background: var(--_input-bg);
	color: var(--_ink);
	font: inherit;
	font-size: max(16px, 1em);
	line-height: 1.5;
	letter-spacing: normal;
	text-transform: none;
	box-shadow: none;
	outline: none;
	appearance: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ibf.ibf .ibf-input[dir="ltr"] {
	text-align: end;
}

.ibf.ibf .ibf-input::placeholder {
	color: color-mix(in srgb, var(--_muted) 75%, transparent);
	opacity: 1;
}

.ibf.ibf .ibf-input:hover {
	border-color: color-mix(in srgb, var(--_ink) 70%, transparent);
}

.ibf.ibf .ibf-input:focus {
	border-color: var(--_focus);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--_focus) 28%, transparent);
}

.ibf.ibf .ibf-textarea {
	min-block-size: 132px;
	min-block-size: calc(4lh + 27px);
	max-block-size: calc(12lh + 27px);
	resize: vertical;
	field-sizing: content;
	overflow-x: hidden;
	overflow-wrap: anywhere;
}

.ibf.ibf .ibf-textarea--short {
	min-block-size: 102px;
	min-block-size: calc(3lh + 27px);
	max-block-size: calc(8lh + 27px);
}

.ibf .ibf-select-wrap {
	position: relative;
	display: block;
}

.ibf .ibf-select-wrap::after {
	content: "";
	position: absolute;
	inset-block: 0;
	inset-inline-end: 14px;
	inline-size: 18px;
	background: var(--_muted);
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 18px no-repeat;
	pointer-events: none;
}

.ibf.ibf .ibf-select {
	padding-inline-end: 44px;
	cursor: pointer;
}

.ibf.ibf .has-error > .ibf-input,
.ibf.ibf .has-error > .ibf-select-wrap > .ibf-input {
	border-color: var(--_err);
	background: var(--_err-bg);
}

/* ------------------------------------------------------------ choices (radio / checks / confirm) */

/* Equal cells: two on a phone, more as the form widens; long labels wrap inside their cell. */
.ibf .ibf-opts {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, max(9em, 30%)), 1fr));
	gap: 8px;
}

.ibf.ibf label.opt {
	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	min-block-size: 52px;
	margin: 0;
	padding: 8px 12px;
	border: 1.5px solid var(--_line);
	border-radius: var(--_r-sm);
	background: var(--_input-bg);
	color: var(--_ink);
	font-size: 1em;
	font-weight: 400;
	line-height: 1.45;
	cursor: pointer;
	user-select: none;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.ibf.ibf label.opt:hover {
	border-color: var(--_field-line);
}

.ibf.ibf label.opt input {
	flex: none;
	display: grid;
	place-content: center;
	inline-size: 22px;
	block-size: 22px;
	margin: 0;
	padding: 0;
	border: 2px solid var(--_field-line);
	border-radius: calc(var(--_r) * 0.6);
	background: var(--_input-bg);
	box-shadow: none;
	appearance: none;
	cursor: pointer;
}

.ibf.ibf label.opt input[type="radio"] {
	border-radius: 50%;
}

.ibf.ibf label.opt input::before {
	content: "";
	inline-size: 12px;
	block-size: 12px;
	transform: scale(0);
	transition: transform 0.12s ease;
}

.ibf.ibf label.opt input[type="checkbox"]::before {
	background: var(--_on-action);
	clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 8%, 38% 72%);
}

.ibf.ibf label.opt input[type="radio"]::before {
	border-radius: 50%;
	background: var(--_action);
}

.ibf.ibf label.opt input:checked {
	border-color: var(--_action);
}

.ibf.ibf label.opt input[type="checkbox"]:checked {
	background: var(--_action);
}

.ibf.ibf label.opt input:checked::before {
	transform: scale(1);
}

.ibf.ibf label.opt:has(input:checked) {
	border-color: var(--_action);
	background: var(--_soft);
	font-weight: 600;
}

.ibf.ibf label.opt:has(input:focus-visible) {
	outline: 3px solid var(--_focus);
	outline-offset: 2px;
}

.ibf.ibf .has-error label.opt {
	border-color: color-mix(in srgb, var(--_err) 55%, var(--_line));
}

.ibf.ibf label.opt--confirm {
	padding-block: 14px;
	font-weight: 600;
}

.ibf.ibf label.opt .opt__text {
	min-inline-size: 0;
}

/* ------------------------------------------------------------ buttons */

.ibf.ibf .ibf-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-block-size: 48px;
	min-inline-size: 48px;
	margin: 0;
	padding: 8px 20px;
	border: 2px solid transparent;
	border-radius: var(--_r-sm);
	background: transparent;
	color: var(--_action);
	font: inherit;
	font-size: 1em;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: normal;
	text-transform: none;
	text-decoration: none;
	text-shadow: none;
	box-shadow: none;
	white-space: nowrap;
	cursor: pointer;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.ibf.ibf .ibf-btn:focus-visible,
.ibf.ibf .ibf-rail__btn:focus-visible,
.ibf.ibf .ibf-errsum a:focus-visible {
	outline: 3px solid var(--_focus);
	outline-offset: 2px;
}

.ibf.ibf .ibf-btn:active:not(:disabled) {
	transform: scale(0.98);
}

.ibf.ibf .ibf-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.ibf.ibf .ibf-btn--primary {
	background: var(--_action);
	border-color: var(--_action);
	color: var(--_on-action);
}

.ibf.ibf .ibf-btn--primary:hover:not(:disabled) {
	background: var(--_action-hover);
	border-color: var(--_action-hover);
}

.ibf.ibf .ibf-btn--primary[aria-busy="true"] {
	cursor: progress;
}

.ibf.ibf .ibf-btn--secondary {
	background: var(--_surface);
	border-color: var(--_field-line);
	color: var(--_ink);
}

.ibf.ibf .ibf-btn--secondary:hover:not(:disabled) {
	border-color: var(--_ink);
}

.ibf.ibf .ibf-btn--ghost:hover:not(:disabled) {
	background: var(--_soft);
}

.ibf.ibf .ibf-btn--danger {
	color: var(--_err);
}

.ibf.ibf .ibf-btn--danger:hover:not(:disabled) {
	background: var(--_err-bg);
}

.ibf.ibf .ibf-btn--sm {
	padding-inline: 12px;
	font-size: 0.92em;
}

.ibf.ibf .ibf-btn--add {
	inline-size: 100%;
	min-block-size: 52px;
	border: 2px dashed var(--_soft-line);
	background: transparent;
}

.ibf.ibf .ibf-btn--add:hover {
	background: var(--_soft);
	border-color: var(--_action);
}

.ibf.ibf .ibf-zoom {
	flex: none;
	padding-inline: 12px;
	border-color: var(--_line);
	color: var(--_ink);
	font-size: 0.88em;
}

.ibf.ibf .ibf-zoom[aria-pressed="true"] {
	border-color: var(--_action);
	background: var(--_soft);
	color: var(--_action);
}

/* ------------------------------------------------------------ repeaters */

.ibf .ibf-rows {
	gap: 12px;
}

.ibf.ibf .ibf-rows__legend {
	font-size: 1.1em;
	font-weight: 700;
	margin-block-end: 4px;
}

.ibf .ibf-cards {
	display: grid;
	gap: 14px;
}

.ibf .ibf-card {
	display: grid;
	gap: 20px;
	padding: 12px 12px 16px;
	border: 1px solid var(--_line);
	border-radius: var(--_r);
	background: var(--_surface-2);
	min-inline-size: 0;
}

.ibf .ibf-card__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-block: -4px -4px;
}

.ibf.ibf .ibf-card__title {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 1em;
	outline: none;
}

.ibf.ibf .ibf-card__title::before {
	content: "";
	inline-size: 4px;
	block-size: 1.2em;
	border-radius: 2px;
	background: var(--_marker);
}

.ibf.ibf .ibf-card__title:focus-visible {
	outline: 3px solid var(--_focus);
	outline-offset: 4px;
	border-radius: 2px;
}

.ibf .ibf-rowtotal {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 4px 12px;
	padding-block-start: 12px;
	border-block-start: 1px dashed var(--_line);
	color: var(--_muted);
	font-weight: 600;
}

.ibf .ibf-money,
.ibf .ibf-stat__value,
.ibf .ibf-sumtable td,
.ibf .ibf-sumcard__amt {
	font-variant-numeric: tabular-nums;
}

.ibf .ibf-rowtotal .ibf-money {
	color: var(--_ink);
	font-size: 1.1em;
	font-weight: 700;
}

/* ------------------------------------------------------------ files */

.ibf.ibf .ibf-file__input {
	position: absolute;
	inline-size: 1px;
	block-size: 1px;
	opacity: 0;
	overflow: hidden;
}

.ibf.ibf .ibf-file__drop {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	min-block-size: 64px;
	padding: 14px;
	border: 2px dashed var(--_soft-line);
	border-radius: var(--_r);
	background: var(--_soft);
	color: var(--_action);
	font-weight: 600;
	text-align: center;
	cursor: pointer;
}

.ibf.ibf .ibf-file__drop:hover {
	border-color: var(--_action);
}

.ibf.ibf .ibf-file:has(.ibf-file__input:focus-visible) .ibf-file__drop {
	outline: 3px solid var(--_focus);
	outline-offset: 2px;
}

.ibf .ibf-files {
	display: grid;
	gap: 8px;
}

.ibf .ibf-files:empty {
	display: none;
}

.ibf .ibf-files__item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding-block: 4px;
	padding-inline: 12px 4px;
	border: 1px solid var(--_line);
	border-radius: var(--_r-sm);
	background: var(--_surface-2);
	min-inline-size: 0;
}

.ibf .ibf-files__name {
	flex: 1 1 auto;
	min-inline-size: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 600;
}

.ibf .ibf-files__size {
	color: var(--_muted);
	font-size: 0.85em;
	white-space: nowrap;
}

/* ------------------------------------------------------------ budget summary */

.ibf .ibf-budget-summary {
	display: grid;
	gap: 14px;
	grid-column: 1 / -1;
	padding: 16px 14px;
	border: 1px solid var(--_soft-line);
	border-radius: var(--_r);
	background: var(--_soft);
	outline: none;
}

.ibf .ibf-budget-summary:focus-visible {
	outline: 3px solid var(--_focus);
	outline-offset: 2px;
}

.ibf.ibf .ibf-budget-summary__title {
	font-size: 1.1em;
}

.ibf .ibf-sum-body {
	display: grid;
	gap: 14px;
}

.ibf .ibf-stats {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
}

.ibf .ibf-stat {
	display: grid;
	gap: 2px;
	padding: 12px;
	border-radius: var(--_r-sm);
	background: var(--_surface);
	border: 1px solid var(--_line);
	min-inline-size: 0;
}

.ibf .ibf-stat.is-key,
.ibf .ibf-stat.is-bad {
	grid-column: 1 / -1;
}

.ibf .ibf-stat__label {
	color: var(--_muted);
	font-size: 0.85em;
	font-weight: 600;
}

.ibf .ibf-stat__value {
	font-size: 1.25em;
	font-weight: 700;
	text-align: start;
}

.ibf .ibf-stat.is-key .ibf-stat__value {
	color: var(--_action);
	font-size: 1.5em;
}

.ibf .ibf-stat.is-bad {
	border-color: var(--_err);
	background: var(--_err-bg);
}

.ibf .ibf-stat.is-bad .ibf-stat__value {
	color: var(--_err);
	font-size: 1.5em;
}

.ibf .ibf-sumlines {
	display: grid;
	gap: 6px;
}

.ibf .ibf-sumline {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	font-weight: 600;
}

.ibf .ibf-sumline.is-ok {
	color: var(--_ok);
}

.ibf .ibf-sumline.is-bad {
	padding: 10px 12px;
	border-radius: var(--_r-sm);
	background: var(--_err-bg);
	color: var(--_err);
}

.ibf .ibf-sumline .ibf-ico {
	margin-block-start: 0.2em;
}

.ibf .ibf-sumtable {
	display: none;
}

.ibf .ibf-sumcards {
	display: grid;
	gap: 8px;
}

.ibf .ibf-sumcards__title {
	font-weight: 700;
}

.ibf .ibf-sumcards ul {
	display: grid;
	gap: 6px;
}

.ibf .ibf-sumcard {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto auto;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	border-radius: var(--_r-sm);
	background: var(--_surface);
}

.ibf .ibf-sumcard__amt {
	font-weight: 700;
}

.ibf .ibf-sumcard__pct {
	min-inline-size: 3.6em;
	padding: 0 6px;
	border-radius: 999px;
	background: color-mix(in srgb, var(--_ink) 7%, transparent);
	color: var(--_muted);
	font-size: 0.85em;
	text-align: center;
}

/* ------------------------------------------------------------ review */

.ibf .ibf-review {
	display: grid;
	gap: 14px;
	grid-column: 1 / -1;
}

.ibf.ibf .ibf-review__title {
	font-size: 1.15em;
	padding-block-start: 22px;
	border-block-start: 1px solid var(--_line);
}

.ibf .ibf-rev {
	display: grid;
	gap: 8px;
	padding: 6px 14px 12px;
	border: 1px solid var(--_line);
	border-radius: var(--_r);
	background: var(--_surface-2);
}

.ibf .ibf-rev__head {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.ibf.ibf .ibf-rev__title {
	font-size: 1em;
}

.ibf .ibf-rev__dl {
	display: grid;
}

.ibf .ibf-rev__pair {
	display: grid;
	gap: 2px;
	padding-block: 10px;
	border-block-start: 1px solid var(--_line);
	min-inline-size: 0;
}

.ibf.ibf .ibf-rev__pair dt {
	color: var(--_muted);
	font-size: 0.88em;
	font-weight: 600;
}

.ibf.ibf .ibf-rev__pair dd {
	white-space: pre-line;
}

.ibf .ibf-rev__rows {
	display: grid;
	gap: 8px;
	margin-block-start: 4px;
}

.ibf .ibf-rev__rows > li {
	padding: 8px 12px;
	border-radius: var(--_r-sm);
	background: var(--_surface);
}

.ibf .ibf-rev__rowtitle {
	font-weight: 700;
}

.ibf .ibf-rev__dl--sub .ibf-rev__pair {
	padding-block: 6px;
}

.ibf .ibf-rev__total {
	margin-block-start: 8px;
	font-weight: 700;
}

/* ------------------------------------------------------------ messages */

.ibf .ibf-errsum,
.ibf .ibf-notice {
	display: grid;
	gap: 8px;
	padding: 14px 16px;
	border: 2px solid var(--_err);
	border-radius: var(--_r);
	background: var(--_err-bg);
	color: var(--_err);
	outline: none;
}

.ibf .ibf-errsum:focus-visible {
	outline: 3px solid var(--_focus);
	outline-offset: 2px;
}

.ibf .ibf-notice {
	grid-template-columns: auto minmax(0, 1fr);
	align-items: start;
	font-weight: 600;
}

.ibf .ibf-notice .ibf-ico {
	margin-block-start: 0.25em;
}

.ibf .ibf-errsum__head {
	display: flex;
	align-items: center;
	gap: 8px;
}

.ibf.ibf .ibf-errsum__title {
	color: var(--_err);
	font-size: 1.02em;
}

.ibf .ibf-errsum__list {
	display: grid;
	gap: 4px;
}

.ibf.ibf .ibf-errsum a {
	display: inline-block;
	padding-block: 6px;
	color: var(--_err);
	text-decoration: underline;
	text-underline-offset: 3px;
	box-shadow: none;
}

.ibf .ibf-errsum__field {
	font-weight: 700;
}

.ibf .ibf-restored {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0 12px;
	padding-block: 4px;
	padding-inline: 14px 4px;
	border-radius: var(--_r-sm);
	background: var(--_warn-bg);
	font-size: 0.9em;
}

/* ------------------------------------------------------------ sticky action bar */

.ibf .ibf-actions {
	position: sticky;
	inset-block-end: 0;
	z-index: 20;
	display: grid;
	gap: 6px;
	margin-inline: -16px;
	padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
	background: color-mix(in srgb, var(--_surface) 96%, transparent);
	border-block-start: 1px solid var(--_line);
	box-shadow: 0 -4px 16px rgb(16 24 64 / 7%);
}

.ibf .ibf-actions__row {
	display: flex;
	gap: 10px;
}

.ibf .ibf-actions__row .ibf-btn {
	min-block-size: 52px;
}

.ibf .ibf-actions__row .ibf-next {
	flex: 1 1 auto;
}

.ibf .ibf-saved {
	color: var(--_muted);
	font-size: 0.78em;
	text-align: center;
}

.ibf .ibf-saved:empty {
	display: none;
}

/* ------------------------------------------------------------ success / closed */

.ibf .ibf-success,
.ibf .ibf-closed {
	display: grid;
	justify-items: center;
	gap: 14px;
	padding: 36px 16px;
	background: var(--_surface);
	text-align: center;
}

.ibf .ibf-success__icon {
	color: var(--_ok);
}

.ibf.ibf .ibf-success__title {
	font-size: 1.5em;
	outline: none;
	text-align: center;
}

.ibf .ibf-success__ref {
	display: grid;
	gap: 2px;
	justify-items: center;
	padding: 12px 24px;
	border: 2px dashed var(--_soft-line);
	border-radius: var(--_r);
	background: var(--_soft);
}

.ibf .ibf-success__reflabel {
	color: var(--_muted);
	font-size: 0.85em;
	font-weight: 600;
}

.ibf .ibf-ref {
	color: var(--_action);
	font-size: 1.4em;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.ibf .ibf-success__text,
.ibf .ibf-closed p {
	max-inline-size: 36em;
	text-align: center;
}

/* Done: one centred column on every width (the step rail column is gone). */
.ibf.is-done .ibf-body {
	display: block !important;
}

.ibf.is-done .ibf-rail,
.ibf.is-done .ibf-nav,
.ibf.is-done .ibf-stepcount,
.ibf.is-done .ibf-progress {
	display: none !important;
}

.ibf .ibf-success {
	max-inline-size: 640px;
	margin-inline: auto;
	border-radius: calc(var(--_r) + 4px);
	padding-block: 40px;
	padding-inline: 24px;
}

.ibf .ibf-success__ref {
	inline-size: min(100%, 22em);
}

.ibf .ibf-ref--name {
	font-size: 1.2em;
	line-height: 1.6;
	text-align: center;
}

.ibf .ibf-success__next {
	inline-size: 100%;
	max-inline-size: 32em;
	margin-block-start: 8px;
	padding: 16px 20px;
	border-radius: var(--_r);
	background: var(--_soft);
	text-align: start;
}

.ibf.ibf .ibf-success__nexttitle {
	margin: 0 0 8px;
	font-size: 1.05em;
}

.ibf.ibf .ibf-success__steps {
	margin: 0;
	padding-inline-start: 1.4em;
	display: grid;
	gap: 6px;
	line-height: 1.7;
}

.ibf.ibf .ibf-success__home {
	display: inline-flex;
	align-items: center;
	min-block-size: 48px;
	padding-inline: 20px;
	border-radius: var(--_r);
	background: var(--_action);
	color: #fff;
	font-weight: 700;
	text-decoration: none;
}

.ibf.ibf .ibf-success__home:focus-visible {
	outline: 3px solid var(--ibf-primary);
	outline-offset: 2px;
}

/*
 * Breakpoints follow the form's own width (container queries), not the viewport, so a
 * narrow theme column never squeezes the two-column layout or the rail. On phones the
 * form is narrower than 720px either way: one column, as the spec asks below 768px.
 */

/* ------------------------------------------------------------ ≥ 600px wide: band + one card */

@container ibf (min-width: 600px) {
	.ibf .ibf-app {
		gap: 20px;
		padding: 24px;
		background: var(--_page);
	}

	.ibf .ibf-head {
		padding: 4px 4px 0;
	}

	.ibf .ibf-main {
		gap: 24px;
		padding: 24px 24px 0;
		border-block-start: 4px solid var(--_marker);
		border-radius: var(--_r);
		box-shadow: var(--_shadow);
	}

	.ibf .ibf-actions {
		margin-inline: -24px;
		padding: 14px 24px;
		border-end-start-radius: var(--_r);
		border-end-end-radius: var(--_r);
		box-shadow: none;
	}

	.ibf .ibf-success,
	.ibf .ibf-closed {
		padding: 40px 24px;
		border-radius: var(--_r);
		box-shadow: var(--_shadow);
	}

	.ibf .ibf-card {
		padding: 14px 16px 18px;
	}
}

/* ------------------------------------------------------------ ≥ 720px wide: two columns */

@container ibf (min-width: 720px) {
	.ibf.ibf .ibf-title {
		font-size: 1.85em;
	}

	.ibf .ibf-main {
		padding: 28px 32px 0;
	}

	.ibf .ibf-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 24px 20px;
	}

	.ibf .ibf-grid > [data-width="full"] {
		grid-column: 1 / -1;
	}

	.ibf .ibf-card {
		padding: 16px 20px 20px;
	}

	.ibf .ibf-stats {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.ibf .ibf-stat.is-key,
	.ibf .ibf-stat.is-bad {
		grid-column: auto;
	}

	.ibf .ibf-sumcards {
		display: none;
	}

	.ibf.ibf .ibf-sumtable {
		display: table;
		inline-size: 100%;
		border-collapse: collapse;
		background: var(--_surface);
		border-radius: var(--_r-sm);
		overflow: hidden;
	}

	.ibf.ibf .ibf-sumtable caption {
		padding-block-end: 8px;
		font-weight: 700;
		caption-side: top;
	}

	.ibf.ibf .ibf-sumtable :is(th, td) {
		padding: 10px 14px;
		border-block-end: 1px solid var(--_line);
	}

	.ibf.ibf .ibf-sumtable thead th {
		color: var(--_muted);
		font-size: 0.85em;
		font-weight: 600;
	}

	.ibf.ibf .ibf-sumtable tbody th {
		font-weight: 500;
	}

	.ibf.ibf .ibf-sumtable :is(td, thead th:not(:first-child)) {
		text-align: end;
	}

	.ibf.ibf .ibf-sumtable tfoot :is(th, td) {
		border-block-end: 0;
		font-weight: 700;
	}

	.ibf .ibf-rev__pair {
		grid-template-columns: minmax(160px, 30%) minmax(0, 1fr);
		gap: 16px;
	}

	.ibf .ibf-rev__pair--rows {
		grid-template-columns: minmax(0, 1fr);
		gap: 6px;
	}

	.ibf .ibf-actions {
		margin-inline: -32px;
		padding: 16px 32px;
		grid-template-columns: minmax(0, 1fr) auto;
		align-items: center;
	}

	.ibf .ibf-actions__row {
		grid-column: 2;
		grid-row: 1;
		justify-content: flex-end;
	}

	.ibf .ibf-actions__row .ibf-btn {
		flex: none;
		min-inline-size: 140px;
	}

	.ibf .ibf-actions__row .ibf-next {
		min-inline-size: 180px;
	}

	.ibf .ibf-saved {
		grid-column: 1;
		grid-row: 1;
		text-align: start;
	}
}

/*
 * Two half-width fields side by side share label, hint, control and error rows, so their
 * inputs line up even when only one of them has a hint.
 */
@supports (grid-template-rows: subgrid) {
	@container ibf (min-width: 720px) {
		/* A subgrid keeps its parent's row gaps between its own rows: space fields with margins instead. */
		.ibf .ibf-grid {
			row-gap: 0;
		}

		.ibf .ibf-grid > * {
			margin-block-end: 24px;
		}

		.ibf .ibf-grid > :last-child {
			margin-block-end: 0;
		}

		.ibf .ibf-grid > div.ibf-field[data-width="half"] {
			grid-row: span 4;
			grid-template-rows: subgrid;
			row-gap: 0;
		}

		.ibf .ibf-grid > div.ibf-field[data-width="half"] > .ibf-label {
			grid-row: 1;
		}

		.ibf .ibf-grid > div.ibf-field[data-width="half"] > .ibf-hint {
			grid-row: 2;
			margin-block: 2px 0;
		}

		.ibf .ibf-grid > div.ibf-field[data-width="half"] > :not(.ibf-label, .ibf-hint, .ibf-err) {
			grid-row: 3;
			margin-block-start: 8px;
		}

		.ibf .ibf-grid > div.ibf-field[data-width="half"] > .ibf-err {
			grid-row: 4;
			margin-block-start: 8px;
		}
	}
}

/* ------------------------------------------------------------ ≥ 980px wide: step rail */

@container ibf (min-width: 980px) {
	.ibf .ibf-body {
		grid-template-columns: 260px minmax(0, 1fr);
		align-items: start;
		gap: 24px;
	}

	.ibf .ibf-rail {
		position: sticky;
		inset-block-start: 40px;
		display: block;
		padding-block-start: 8px;
	}

	.ibf .ibf-rail__list {
		display: grid;
		gap: 2px;
	}

	.ibf.ibf .ibf-rail__btn {
		display: flex;
		align-items: center;
		gap: 12px;
		inline-size: 100%;
		min-block-size: 52px;
		margin: 0;
		padding: 8px 10px;
		border: 0;
		border-radius: var(--_r-sm);
		background: transparent;
		color: var(--_muted);
		font: inherit;
		font-size: 0.95em;
		font-weight: 600;
		line-height: 1.4;
		text-align: start;
		text-transform: none;
		letter-spacing: normal;
		box-shadow: none;
		cursor: pointer;
	}

	.ibf.ibf .ibf-rail__btn:hover:not(:disabled) {
		background: color-mix(in srgb, var(--_surface) 60%, transparent);
		color: var(--_ink);
	}

	.ibf.ibf .ibf-rail__btn:disabled {
		cursor: default;
		opacity: 0.7;
	}

	.ibf .ibf-rail__num {
		flex: none;
		display: grid;
		place-items: center;
		inline-size: 30px;
		block-size: 30px;
		border: 2px solid var(--_field-line);
		border-radius: 50%;
		background: var(--_surface);
		color: var(--_muted);
		font-size: 0.9em;
		font-weight: 700;
		font-variant-numeric: tabular-nums;
	}

	.ibf .is-visited .ibf-rail__num {
		border-color: var(--_action);
		color: var(--_action);
	}

	.ibf .is-visited .ibf-rail__btn {
		color: var(--_ink);
	}

	.ibf.ibf .is-current .ibf-rail__btn {
		background: var(--_surface);
		color: var(--_ink);
		font-weight: 700;
	}

	.ibf .is-current .ibf-rail__num {
		border-color: var(--_marker);
		background: var(--_marker);
		color: var(--_on-marker);
	}

	.ibf .ibf-progress__track {
		display: none;
	}
}

/* ------------------------------------------------------------ motion */

@media (prefers-reduced-motion: reduce) {
	.ibf *,
	.ibf *::before,
	.ibf *::after {
		transition: none !important;
		animation: none !important;
		scroll-behavior: auto !important;
	}
}

@media (forced-colors: active) {
	.ibf.ibf label.opt input:checked::before {
		background: CanvasText;
	}

	.ibf .ibf-progress__fill {
		background: Highlight;
	}
}

/* Long explanatory headings (e.g. informed consent) keep their line breaks. */
.ibf .ibf-heading .ibf-hint {
	white-space: pre-line;
	line-height: 1.9;
}

/* A heading that opens a step needs no divider: the step intro already has one. */
.ibf .ibf-grid > .ibf-heading:first-child {
	margin-block-start: 0;
	padding-block-start: 0;
	border-block-start: 0;
}

/* Field hints: their own line with room to breathe under the question. */
.ibf .ibf-field > .ibf-hint,
.ibf .ibf-field .ibf-legend + .ibf-hint {
	display: block;
	margin-block: 6px 12px;
	line-height: 1.9;
	max-inline-size: 60ch;
}

.ibf.ibf .ibf-hint {
	margin-block: 4px 10px;
	line-height: 1.85;
}

/* Exactly four options (e.g. Washington Group scale): a tidy 2 × 2 grid. */
.ibf .ibf-opts:has(> :nth-child(4):last-child) {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Link under the dedicated form to the general form page («قدم فكرتك»). */
.ibf-general-link {
	box-sizing: border-box;
	max-inline-size: 1040px;
	margin: 24px auto 40px;
	padding: 16px 20px;
	border-radius: 12px;
	background: #F3F7FB;
	border: 1px solid #DCE7F0;
	color: #101740;
	font-size: 1rem;
	line-height: 1.8;
	text-align: center;
	direction: rtl;
}

.ibf-general-link a {
	color: #0561A0;
	font-weight: 700;
	text-decoration: underline;
}
