.pddc-calculator,
.pddc-calculator * {
	box-sizing: border-box;
}

.pddc-calculator {
	--pddc-bg: #f3f5f8;
	--pddc-card: #ffffff;
	--pddc-card-2: #f9fafb;
	--pddc-text: #172033;
	--pddc-muted: #637083;
	--pddc-border: #d9dee8;
	--pddc-accent: #555f70;
	--pddc-accent-2: #2f3744;
	--pddc-green: #1f7a4d;
	--pddc-red: #b42318;
	--pddc-shadow: 0 18px 45px rgba(22, 30, 46, 0.12);
	--pddc-radius: 22px;
	font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	color: var(--pddc-text);
	background: linear-gradient(180deg, rgba(247, 248, 250, 0.95), rgba(235, 238, 244, 0.95));
	border: 1px solid var(--pddc-border);
	border-radius: 28px;
	padding: 18px;
	width: 100% !important;
	max-width: 1120px !important;
	margin: 24px auto !important;
	clear: both !important;
	float: none !important;
}

.pddc-calculator.pddc-dark,
.pddc-calculator.pddc-theme-dark {
	--pddc-bg: #111827;
	--pddc-card: #172033;
	--pddc-card-2: #202b3e;
	--pddc-text: #f8fafc;
	--pddc-muted: #bcc6d4;
	--pddc-border: #364154;
	--pddc-accent: #aab4c3;
	--pddc-accent-2: #f3f4f6;
	--pddc-shadow: 0 20px 55px rgba(0, 0, 0, 0.35);
	background: linear-gradient(180deg, #111827, #0b1220);
}

.pddc-stack-only,
.pddc-calculator[data-pddc-layout="stacked"] .pddc-stack-only {
	display: flex !important;
	flex-direction: column !important;
	gap: 22px !important;
	width: 100% !important;
	max-width: 100% !important;
	grid-template-columns: 1fr !important;
	align-items: stretch !important;
}

.pddc-form-shell,
.pddc-output-below,
.pddc-results {
	display: block !important;
	width: 100% !important;
	max-width: 100% !important;
	min-width: 0 !important;
	clear: both !important;
	float: none !important;
	grid-column: 1 / -1 !important;
}

.pddc-form-shell { order: 1 !important; }
.pddc-output-below { order: 2 !important; }

.pddc-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 20px;
	background: var(--pddc-card);
	border: 1px solid var(--pddc-border);
	border-radius: var(--pddc-radius);
	box-shadow: var(--pddc-shadow);
}

.pddc-title-wrap {
	display: flex;
	align-items: center;
	gap: 14px;
	min-width: 0;
}

.pddc-icon {
	display: inline-grid;
	place-items: center;
	width: 46px;
	height: 46px;
	border-radius: 16px;
	background: linear-gradient(135deg, var(--pddc-accent), var(--pddc-accent-2));
	color: #fff;
	font-size: 22px;
	box-shadow: 0 10px 20px rgba(47, 55, 68, 0.2);
	flex: 0 0 auto;
}

.pddc-header h2,
.pddc-section-heading h3 {
	margin: 0;
	line-height: 1.18;
	letter-spacing: -0.025em;
}

.pddc-header h2 {
	font-size: clamp(1.35rem, 2.5vw, 2.15rem);
	font-weight: 800;
}

.pddc-header p,
.pddc-section-heading p {
	margin: 6px 0 0;
	color: var(--pddc-muted);
	font-size: 0.96rem;
}

.pddc-theme-toggle,
.pddc-btn {
	appearance: none;
	border: 1px solid var(--pddc-border);
	background: var(--pddc-card-2);
	color: var(--pddc-text);
	border-radius: 999px;
	min-height: 44px;
	padding: 10px 16px;
	font-weight: 700;
	cursor: pointer;
	transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.pddc-theme-toggle {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	white-space: nowrap;
}

.pddc-theme-toggle:hover,
.pddc-btn:hover {
	transform: translateY(-1px);
	box-shadow: 0 12px 24px rgba(22, 30, 46, 0.12);
}

.pddc-theme-toggle:focus-visible,
.pddc-btn:focus-visible,
.pddc-field input:focus-visible,
.pddc-field select:focus-visible,
.pddc-radio-group input:focus-visible,
.pddc-switch input:focus-visible + .pddc-slider {
	outline: 3px solid rgba(80, 103, 140, 0.38);
	outline-offset: 3px;
}

.pddc-alert {
	padding: 14px 16px;
	border-radius: 16px;
	border: 1px solid rgba(180, 35, 24, 0.35);
	background: rgba(180, 35, 24, 0.08);
	color: var(--pddc-red);
	font-weight: 700;
}

.pddc-form {
	display: grid;
	grid-template-columns: 1fr;
	gap: 18px;
	width: 100%;
}

.pddc-card {
	background: var(--pddc-card);
	border: 1px solid var(--pddc-border);
	border-radius: var(--pddc-radius);
	box-shadow: var(--pddc-shadow);
	padding: clamp(16px, 2.2vw, 24px);
	width: 100%;
}

.pddc-section-heading {
	margin-bottom: 18px;
}

.pddc-section-heading h3 {
	font-size: clamp(1.05rem, 2vw, 1.3rem);
	font-weight: 800;
}

.pddc-form-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 16px;
}

.pddc-field {
	display: grid;
	gap: 8px;
	font-weight: 750;
	min-width: 0;
}

.pddc-field span:first-child,
.pddc-radio-group legend {
	font-size: 0.92rem;
	color: var(--pddc-text);
}

.pddc-field small {
	color: var(--pddc-muted);
	font-weight: 600;
}

.pddc-field input,
.pddc-field select {
	width: 100%;
	min-height: 46px;
	border: 1px solid var(--pddc-border);
	border-radius: 14px;
	background: var(--pddc-card-2);
	color: var(--pddc-text);
	padding: 10px 12px;
	font: inherit;
}

.pddc-inline-unit {
	display: flex;
	align-items: center;
	gap: 10px;
	border: 1px solid var(--pddc-border);
	border-radius: 14px;
	background: var(--pddc-card-2);
	padding-right: 12px;
}

.pddc-inline-unit input {
	border: 0;
	background: transparent;
}

.pddc-inline-unit span {
	color: var(--pddc-muted);
	font-weight: 800;
	white-space: nowrap;
}

.pddc-radio-group {
	border: 1px solid var(--pddc-border);
	border-radius: 18px;
	padding: 14px;
	display: grid;
	grid-template-columns: 1fr;
	gap: 10px;
	margin: 0 0 16px;
}

.pddc-radio-group label {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 10px 12px;
	background: var(--pddc-card-2);
	border-radius: 12px;
	cursor: pointer;
}

.pddc-switch-grid {
	display: grid;
	gap: 12px;
	margin-top: 16px;
}

.pddc-switch {
	display: grid;
	grid-template-columns: 48px 1fr;
	align-items: center;
	gap: 12px;
	padding: 12px;
	border: 1px solid var(--pddc-border);
	border-radius: 16px;
	background: var(--pddc-card-2);
	font-weight: 700;
	cursor: pointer;
}

.pddc-switch input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.pddc-slider {
	position: relative;
	width: 48px;
	height: 28px;
	border-radius: 999px;
	background: #a9b1bf;
	transition: background 160ms ease;
}

.pddc-slider::after {
	content: "";
	position: absolute;
	top: 4px;
	left: 4px;
	width: 20px;
	height: 20px;
	border-radius: 999px;
	background: #fff;
	transition: transform 160ms ease;
	box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.pddc-switch input:checked + .pddc-slider {
	background: var(--pddc-accent-2);
}

.pddc-switch input:checked + .pddc-slider::after {
	transform: translateX(20px);
}

.pddc-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
}

.pddc-btn-primary {
	background: linear-gradient(135deg, var(--pddc-accent), var(--pddc-accent-2));
	border-color: transparent;
	color: #fff;
}

.pddc-result-card {
	border-width: 2px;
}

.pddc-result-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 14px;
}

.pddc-metric {
	padding: 16px;
	border-radius: 18px;
	background: var(--pddc-card-2);
	border: 1px solid var(--pddc-border);
	display: grid;
	gap: 6px;
}

.pddc-metric span {
	color: var(--pddc-muted);
	font-weight: 800;
	font-size: 0.86rem;
	text-transform: uppercase;
	letter-spacing: 0.045em;
}

.pddc-metric strong {
	font-size: clamp(1.35rem, 3.6vw, 2.1rem);
	letter-spacing: -0.035em;
}

.pddc-total {
	background: linear-gradient(135deg, rgba(85, 95, 112, 0.14), rgba(47, 55, 68, 0.08));
}

.pddc-visual {
	display: grid;
	gap: 14px;
	margin-top: 18px;
	padding: 16px;
	border: 1px solid var(--pddc-border);
	border-radius: 18px;
	background: var(--pddc-card-2);
}

.pddc-bar-row {
	display: grid;
	grid-template-columns: minmax(110px, 160px) 1fr 54px;
	gap: 10px;
	align-items: center;
	font-size: 0.9rem;
	font-weight: 800;
}

.pddc-progress {
	height: 14px;
	border-radius: 999px;
	background: rgba(128, 139, 156, 0.22);
	overflow: hidden;
}

.pddc-progress span {
	display: block;
	height: 100%;
	width: 0%;
	border-radius: inherit;
	background: linear-gradient(90deg, var(--pddc-accent), var(--pddc-accent-2));
	transition: width 200ms ease;
}

.pddc-table-wrap {
	width: 100%;
	overflow-x: auto;
	margin-top: 18px;
	border: 1px solid var(--pddc-border);
	border-radius: 18px;
}

.pddc-breakdown {
	width: 100%;
	border-collapse: collapse;
	min-width: 520px;
	background: var(--pddc-card);
}

.pddc-breakdown caption {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.pddc-breakdown th,
.pddc-breakdown td {
	padding: 13px 14px;
	border-bottom: 1px solid var(--pddc-border);
	text-align: left;
}

.pddc-breakdown tr:last-child td,
.pddc-breakdown tr:last-child th {
	border-bottom: 0;
}

.pddc-breakdown th {
	color: var(--pddc-muted);
	font-weight: 850;
}

.pddc-breakdown td {
	font-weight: 750;
	text-align: right;
}

@media (min-width: 640px) {
	.pddc-calculator {
		padding: 22px;
	}

	.pddc-form-grid,
	.pddc-result-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.pddc-radio-group {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 960px) {
	.pddc-form-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.pddc-result-grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.pddc-switch-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 560px) {
	.pddc-calculator {
		border-radius: 18px;
		padding: 12px;
	}

	.pddc-header {
		align-items: flex-start;
		flex-direction: column;
	}

	.pddc-title-wrap {
		align-items: flex-start;
	}

	.pddc-actions,
	.pddc-actions .pddc-btn {
		width: 100%;
	}

	.pddc-bar-row {
		grid-template-columns: 1fr;
	}
}

@media print {
	.pddc-theme-toggle,
	.pddc-actions,
	.pddc-form-shell {
		display: none !important;
	}

	.pddc-calculator,
	.pddc-card {
		box-shadow: none !important;
		border-color: #bbb !important;
	}
}


/* Critical stacked output override: keeps results below inputs on every theme and viewport. */
.pddc-calculator[data-pddc-layout="stacked"],
.pddc-calculator[data-pddc-layout="stacked"] > .pddc-stack-only {
	display: flex !important;
	flex-direction: column !important;
	align-items: stretch !important;
	justify-content: flex-start !important;
	width: 100% !important;
	max-width: 1120px !important;
	float: none !important;
	clear: both !important;
	grid-template-columns: 1fr !important;
}

.pddc-calculator[data-pddc-layout="stacked"] .pddc-header,
.pddc-calculator[data-pddc-layout="stacked"] .pddc-alert,
.pddc-calculator[data-pddc-layout="stacked"] .pddc-form-shell,
.pddc-calculator[data-pddc-layout="stacked"] .pddc-output-below,
.pddc-calculator[data-pddc-layout="stacked"] .pddc-results {
	display: block !important;
	flex: 0 0 auto !important;
	width: 100% !important;
	max-width: 100% !important;
	min-width: 0 !important;
	margin-left: 0 !important;
	margin-right: 0 !important;
	float: none !important;
	clear: both !important;
	grid-column: 1 / -1 !important;
	position: relative !important;
}

.pddc-calculator[data-pddc-layout="stacked"] .pddc-form-shell {
	order: 10 !important;
}

.pddc-calculator[data-pddc-layout="stacked"] .pddc-output-below,
.pddc-calculator[data-pddc-layout="stacked"] .pddc-results {
	order: 20 !important;
}

.pddc-calculator[data-pddc-layout="stacked"] .pddc-result-grid {
	width: 100% !important;
}
