/* ================= Calc Modal ================= */
.calc-modal {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: none;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	padding: 40px 20px;
	font-family: 'Source Sans Pro', 'Open Sans', Arial, sans-serif;
}
.calc-modal.is-open { display: flex; }

.calc-modal__overlay {
	position: fixed;
	inset: 0;
	background: rgba(20, 20, 20, 0.35);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	border: 3px solid rgba(255, 255, 255, 0.28);
	box-sizing: border-box;
	z-index: 1;
}

.calc-modal__window {
	position: relative;
	z-index: 2;
	width: 100%;
	max-width: 818px;
	max-height: calc(100vh - 80px);
	background: #FFFFFF;
	border: 20px solid #E31E24;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	margin: auto;
	overflow: hidden;
}

/* ---------- Header ---------- */
.calc-modal__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	padding: 25px 30px 15px;
}
.calc-modal__header-left {
	display: flex;
	gap: 14px;
	align-items: flex-start;
	flex: 1;
}
.calc-modal__header-icon { flex-shrink: 0; }
.calc-modal__title {
	margin: 0 0 4px;
	font-family: 'Open Sans', sans-serif;
	font-weight: 700;
	font-size: 18px;
	line-height: 25px;
	color: #5B5B5B;
}
.calc-modal__desc {
	margin: 0;
	font-size: 16px;
	line-height: 20px;
	color: #5B5B5B;
}
.calc-modal__close {
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
	flex-shrink: 0;
}

/* ---------- Scroll area ---------- */
.calc-modal__form {
	display: flex;
	flex-direction: column;
	min-height: 0;
}
.calc-modal__scroll {
	padding: 20px 30px;
	overflow-y: auto;
	max-height: calc(100vh - 340px);
}
.calc-modal__scroll::-webkit-scrollbar { width: 11px; }
.calc-modal__scroll::-webkit-scrollbar-track { background: #EAEAEA; border-radius: 10px; }
.calc-modal__scroll::-webkit-scrollbar-thumb { background: #C4C4C4; border-radius: 10px; }

/* ---------- Block (fieldset) ---------- */
.calc-block {
	position: relative;
	border: 1px solid #F4D4D6;
	border-radius: 4px;
	padding: 18px 15px 15px;
	margin: 0 0 18px;
	min-width: 0;
}
.calc-block__title {
	background: #FFFFFF;
	padding: 0 8px;
	margin-left: 6px;
	font-family: 'Open Sans', sans-serif;
	font-weight: 700;
	font-size: 16px;
	line-height: 22px;
	color: #5B5B5B;
}
.calc-block__body { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Field wrapper (подсказка с красной *) ---------- */
.calc-field { position: relative; }
.calc-field__label {
	position: absolute;
	left: 17px;
	top: 50%;
	transform: translateY(-50%);
	pointer-events: none;
	font: 400 14px/18px 'Source Sans Pro', sans-serif;
	color: #8A8A8A;
	transition: opacity .15s;
}
.calc-field__req {
	color: #E31E24;
	font-weight: 700;
	margin-left: 1px;
}
.calc-field .calc-input:focus ~ .calc-field__label,
.calc-field .calc-input:not(:placeholder-shown) ~ .calc-field__label { opacity: 0; }

.calc-service-blocks.is-hidden { display: none; }

/* ---------- Inputs ---------- */
.calc-input {
	width: 100%;
	height: 42px;
	background: #F4D4D6;
	border: 1px solid transparent;
	border-radius: 10px;
	padding: 0 17px;
	font-family: 'Source Sans Pro', sans-serif;
	font-size: 14px;
	line-height: 18px;
	color: #5B5B5B;
	box-sizing: border-box;
	outline: none;
	transition: border-color .2s;
}
.calc-input::placeholder { color: #8A8A8A; }
.calc-input:focus { border-color: #E31E24; }
.calc-input.is-error { border-color: #E31E24; background: #FBEAEB; }

/* Custom dropdown */
.calc-select-native { display: none; }
.calc-dd { position: relative; width: 100%; }
.calc-dd__head {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	text-align: left;
	cursor: pointer;
}
.calc-dd__label { color: #5B5B5B; font-size: 14px; }
.calc-dd__label.is-placeholder { color: #8A8A8A; }
.calc-dd__req { color: #E31E24; font-weight: 700; margin-left: 1px; }
.calc-dd__arrow { transition: transform .2s; flex-shrink: 0; margin-left: 10px; }
.calc-dd.is-open .calc-dd__arrow { transform: rotate(180deg); }
.calc-dd__menu {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	margin: 0;
	padding: 4px;
	list-style: none;
	background: #EBCCCE;
	border-radius: 10px;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
	z-index: 10001;
	max-height: 0;
	overflow: hidden;
	opacity: 0;
	transform: translateY(-4px);
	transition: opacity .18s, transform .18s, max-height .18s;
	pointer-events: none;
}
.calc-dd.is-open .calc-dd__menu {
	max-height: 300px;
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}
.calc-dd__item {
	padding: 10px 14px;
	border-radius: 8px;
	font-size: 14px;
	color: #5B5B5B;
	cursor: pointer;
	transition: background .15s;
}
.calc-dd__item:hover { background: #E0B8BB; }

/* hide add-button by default; JS toggles .has-selection on panel */
.calc-panel .calc-add { display: none; }
.calc-panel.has-selection .calc-add { display: flex; }

/* Textarea */
.calc-textarea {
	height: auto;
	min-height: 42px;
	max-height: 240px;
	padding-top: 11px;
	padding-bottom: 11px;
	resize: none;
	overflow: hidden;
	font-family: 'Source Sans Pro', sans-serif;
	line-height: 18px;
}

/* ---------- Tabs ---------- */
.calc-tabs {
	flex-direction: row;
	gap: 20px;
}
.calc-tab {
	flex: 1;
	height: 42px;
	background: #F4D4D6;
	border: 0;
	border-radius: 10px;
	font-family: 'Source Sans Pro', sans-serif;
	font-weight: 400;
	font-size: 14px;
	line-height: 18px;
	color: #8A8A8A;
	cursor: pointer;
	transition: background .2s, color .2s;
}
.calc-tab:hover { background: #ebc1c4; }
.calc-tab.is-active { background: #E31E24; color: #FFFFFF; }

/* ---------- Objects ---------- */
.calc-panel.is-hidden { display: none; }
.calc-objects { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.calc-object-row--pair { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.calc-panel { display: flex; flex-direction: column; align-items: stretch; }
.calc-add {
	display: flex;
	align-items: center;
	justify-content: center;
	align-self: center;
	margin: 8px 0 0;
	width: 36px;
	height: 36px;
	padding: 0;
	background: transparent;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	transition: transform .15s ease, opacity .15s;
}
.calc-add svg { display: block; }
.calc-add:hover { transform: scale(1.12); }
.calc-add:active { transform: scale(0.94); }

.calc-object-remove {
	flex-shrink: 0;
	width: 24px;
	height: 24px;
	margin-left: 4px;
	padding: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: 0;
	border-radius: 50%;
	color: #5B5B5B;
	cursor: pointer;
	opacity: .7;
	transition: transform .18s ease, opacity .18s, background .18s, color .18s;
}
.calc-object-remove:hover {
	opacity: 1;
	background: #F4D4D6;
	color: #E31E24;
	transform: rotate(90deg) scale(1.1);
}
.calc-object-remove:active { transform: rotate(90deg) scale(0.9); }
.calc-object-remove svg { display: block; }

/* row expand / remove animations */
.calc-object-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 0;
	transition: opacity .18s, transform .18s;
}
.calc-object-row .calc-dd { width: 47%; }
.calc-object-row__right { width: 47%; }
.calc-object-row__right {
	display: flex;
	align-items: center;
	gap: 8px;
	animation: calcSlideIn .22s ease both;
}
.calc-object-row__right .calc-input { flex: 1 1 auto; min-width: 0; }
.calc-object-row.is-removing {
	opacity: 0;
	transform: translateX(8px);
}
.calc-object-row > .calc-input + .calc-input,
.calc-object-row > .calc-object-remove {
	animation: calcSlideIn .22s ease both;
}
@keyframes calcSlideIn {
	from { opacity: 0; transform: translateY(-4px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Yes / No ---------- */
.calc-row-yesno {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 0;
	align-items: center;
	background: #F4D4D6;
	border-radius: 10px;
	padding-right: 17px;
}
.calc-yesno { display: flex; gap: 20px; }
.calc-yesno__item {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	color: #8A8A8A;
	cursor: pointer;
	user-select: none;
}
.calc-yesno__item input { position: absolute; opacity: 0; pointer-events: none; }
.calc-check {
	width: 19px;
	height: 19px;
	border-radius: 5px;
	background: #FFFFFF;
	border: 1px solid #C4C4C4;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: border-color .15s;
}
.calc-check::after {
	content: '';
	width: 10px;
	height: 6px;
	border-left: 2px solid #5B5B5B;
	border-bottom: 2px solid #5B5B5B;
	transform: rotate(-45deg) translate(1px, -1px);
	opacity: 0;
	transition: opacity .15s;
}
.calc-yesno__item input:checked + .calc-check { border-color: #5B5B5B; }
.calc-yesno__item input:checked + .calc-check::after { opacity: 1; }

/* readonly mirror inputs — transparent, parent provides pink bg */
.calc-row-yesno .calc-input[data-yesno-display] {
	background: transparent;
	border: 0;
	color: #5B5B5B;
	pointer-events: none;
}
.calc-field--yesno { display: flex; align-items: center; }
.calc-field--yesno .calc-input { height: 42px; }
.calc-row-yesno.is-error { box-shadow: 0 0 0 1px #E31E24 inset; }
.calc-tabs.is-error .calc-tab { border-color: #E31E24; }
.calc-dd__head.is-error { border-color: #E31E24; background: #FBEAEB; }

/* ---------- Footer ---------- */
.calc-modal__footer {
	padding: 0 30px 16px;
	border-top: 0;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	justify-content: flex-end;
	min-height: 120px;
	gap: 6px;
}
.calc-modal__submit { order: 2; margin-top: 0; margin-bottom: 6px; }
.calc-modal__message { order: 1; }
.calc-modal__agreement {
	align-self: flex-start;
	order: 3;
	margin: 0;
	font-family: 'Source Serif Pro', serif;
	font-weight: 700;
	font-size: 12px;
	line-height: 15px;
	color: #000000;
}
.calc-modal__agreement a { color: #E31E24; text-decoration: none; }
.calc-modal__agreement a:hover { text-decoration: underline; text-decoration-color: #E31E24; }
.calc-modal__submit {
	min-width: 207px;
	height: 56px;
	padding: 0 24px;
	background: #E31E24;
	color: #FFFFFF;
	font-family: 'Source Sans Pro', sans-serif;
	font-weight: 700;
	font-size: 18px;
	line-height: 23px;
	border: 0;
	border-radius: 10px;
	box-shadow: 0 20px 35px rgba(0, 0, 0, 0.15);
	cursor: pointer;
	transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease, opacity .2s;
}
.calc-modal__submit:hover {
	transform: translateY(-3px);
	box-shadow: 0 24px 40px rgba(0, 0, 0, 0.22);
	background-color: #f02a31;
}
.calc-modal__submit:active {
	transform: translateY(1px) scale(0.97);
	box-shadow: none;
	transition-duration: .1s;
}
.calc-modal__submit:disabled { opacity: .6; cursor: default; transform: none; }

/* Bubbly particles — red to match button color */
.calc-modal__submit.bubbly-button:before,
.calc-modal__submit.bubbly-button:after {
	position: absolute;
	content: "";
	display: block;
	width: 140%;
	height: 100%;
	left: -20%;
	z-index: -1000;
	-webkit-transition: all ease-in-out 0.5s;
	transition: all ease-in-out 0.5s;
	background-repeat: no-repeat;
}
.calc-modal__submit.bubbly-button:before {
	display: none;
	top: -75%;
	background-image:
		radial-gradient(circle, #E31E24 20%, transparent 20%),
		radial-gradient(circle, transparent 20%, #E31E24 20%, transparent 30%),
		radial-gradient(circle, #E31E24 20%, transparent 20%),
		radial-gradient(circle, #E31E24 20%, transparent 20%),
		radial-gradient(circle, transparent 10%, #E31E24 15%, transparent 20%),
		radial-gradient(circle, #E31E24 20%, transparent 20%),
		radial-gradient(circle, #E31E24 20%, transparent 20%),
		radial-gradient(circle, #E31E24 20%, transparent 20%),
		radial-gradient(circle, #E31E24 20%, transparent 20%);
	background-size: 10% 10%, 20% 20%, 15% 15%, 20% 20%, 18% 18%, 10% 10%, 15% 15%, 10% 10%, 18% 18%;
}
.calc-modal__submit.bubbly-button:after {
	display: none;
	bottom: -75%;
	background-image:
		radial-gradient(circle, #E31E24 20%, transparent 20%),
		radial-gradient(circle, #E31E24 20%, transparent 20%),
		radial-gradient(circle, transparent 10%, #E31E24 15%, transparent 20%),
		radial-gradient(circle, #E31E24 20%, transparent 20%),
		radial-gradient(circle, #E31E24 20%, transparent 20%),
		radial-gradient(circle, #E31E24 20%, transparent 20%),
		radial-gradient(circle, #E31E24 20%, transparent 20%);
	background-size: 15% 15%, 20% 20%, 18% 18%, 20% 20%, 15% 15%, 10% 10%, 20% 20%;
}
.calc-modal__submit.bubbly-button.animate:before {
	display: block;
	-webkit-animation: topBubbles ease-in-out 0.75s forwards;
	animation: topBubbles ease-in-out 0.75s forwards;
}
.calc-modal__submit.bubbly-button.animate:after {
	display: block;
	-webkit-animation: bottomBubbles ease-in-out 0.75s forwards;
	animation: bottomBubbles ease-in-out 0.75s forwards;
}

@-webkit-keyframes topBubbles {
	0%   { background-position: 5% 90%, 10% 90%, 10% 90%, 15% 90%, 25% 90%, 25% 90%, 40% 90%, 55% 90%, 70% 90%; }
	50%  { background-position: 0% 80%, 0% 20%, 10% 40%, 20% 0%, 30% 30%, 22% 50%, 50% 50%, 65% 20%, 90% 30%; background-size: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%; }
	100% { background-position: 0% 80%, 0% 20%, 10% 40%, 20% 0%, 30% 30%, 22% 50%, 50% 50%, 65% 20%, 90% 30%; background-size: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%; }
}
@keyframes topBubbles {
	0%   { background-position: 5% 90%, 10% 90%, 10% 90%, 15% 90%, 25% 90%, 25% 90%, 40% 90%, 55% 90%, 70% 90%; }
	50%  { background-position: 0% 80%, 0% 20%, 10% 40%, 20% 0%, 30% 30%, 22% 50%, 50% 50%, 65% 20%, 90% 30%; background-size: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%; }
	100% { background-position: 0% 80%, 0% 20%, 10% 40%, 20% 0%, 30% 30%, 22% 50%, 50% 50%, 65% 20%, 90% 30%; background-size: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%; }
}
@-webkit-keyframes bottomBubbles {
	0%   { background-position: 10% -10%, 30% 10%, 55% -10%, 70% -10%, 85% -10%, 70% -10%, 70% 0%; }
	50%  { background-position: 0% 80%, 20% 80%, 45% 60%, 60% 100%, 75% 70%, 95% 60%, 105% 0%; background-size: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%; }
	100% { background-position: 0% 80%, 20% 80%, 45% 60%, 60% 100%, 75% 70%, 95% 60%, 105% 0%; background-size: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%; }
}
@keyframes bottomBubbles {
	0%   { background-position: 10% -10%, 30% 10%, 55% -10%, 70% -10%, 85% -10%, 70% -10%, 70% 0%; }
	50%  { background-position: 0% 80%, 20% 80%, 45% 60%, 60% 100%, 75% 70%, 95% 60%, 105% 0%; background-size: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%; }
	100% { background-position: 0% 80%, 20% 80%, 45% 60%, 60% 100%, 75% 70%, 95% 60%, 105% 0%; background-size: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%; }
}

.calc-modal__message:empty { display: none; }
.calc-modal__message {
	margin: 0;
	align-self: stretch;
	font-size: 14px;
	line-height: 18px;
	color: #5B5B5B;
}
.calc-modal__message.is-success { color: #1b8c3a; }
.calc-modal__message.is-error { color: #E31E24; }

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
	.calc-modal { padding: 0; }
	.calc-modal__window {
		border-width: 10px;
		min-height: 100vh;
	}
	.calc-modal__header,
	.calc-modal__footer,
	.calc-modal__scroll { padding-left: 16px; padding-right: 16px; }
	.calc-modal__scroll { max-height: none; }
	.calc-tabs { flex-wrap: wrap; gap: 8px; }
	.calc-tab { flex: 1 0 calc(50% - 8px); }
	.calc-object-row--pair { grid-template-columns: 1fr; gap: 8px; }
	.calc-row-yesno { grid-template-columns: 1fr; gap: 8px; }
	.calc-modal__submit { width: 100%; }
	.calc-modal__footer { height: auto; }

	.calc-input { font-size: 14px; padding: 0 14px; }
	.calc-block__body { gap: 14px; }

	.calc-field { display: flex; flex-direction: column; }
	.calc-field__label {
		position: static;
		transform: none;
		display: block;
		white-space: normal;
		font-size: 13px;
		line-height: 16px;
		margin: 0 0 6px 4px;
		color: #5B5B5B;
		order: -1;
	}
	.calc-field .calc-input:focus ~ .calc-field__label,
	.calc-field .calc-input:not(:placeholder-shown) ~ .calc-field__label { opacity: 1; }

	.calc-field--yesno { display: flex; flex-direction: column; }
	.calc-field--yesno .calc-input { display: none; }
	.calc-row-yesno { gap: 6px; }

	.calc-textarea { min-height: 44px; height: 44px; }

	.calc-dd__head {
		min-height: 42px;
		height: auto;
		align-items: center;
		padding: 8px 14px;
		white-space: normal;
	}
}

body.calc-modal-open { overflow: hidden; }
