:root {
	--lfcr-bg: #f3f5f8;
	--lfcr-card: #ffffff;
	--lfcr-card-2: #f8fafc;
	--lfcr-text: #172033;
	--lfcr-muted: #5d677a;
	--lfcr-line: #dce2ea;
	--lfcr-primary: #374151;
	--lfcr-primary-2: #111827;
	--lfcr-accent: #64748b;
	--lfcr-good: #0f766e;
	--lfcr-danger: #b42318;
	--lfcr-shadow: 0 18px 42px rgba(15, 23, 42, 0.12);
	--lfcr-radius: 22px;
}

.lfcr-calculator {
	box-sizing: border-box;
	width: 100%;
	max-width: 1180px;
	margin: 0 auto;
	padding: 16px;
	font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	color: var(--lfcr-text);
}

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

.lfcr-calculator[data-theme="dark"] {
	--lfcr-bg: #111827;
	--lfcr-card: #182131;
	--lfcr-card-2: #111827;
	--lfcr-text: #f8fafc;
	--lfcr-muted: #cbd5e1;
	--lfcr-line: #334155;
	--lfcr-primary: #e5e7eb;
	--lfcr-primary-2: #f8fafc;
	--lfcr-accent: #94a3b8;
	--lfcr-shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
}

.lfcr-shell {
	width: 100%;
	background: linear-gradient(145deg, var(--lfcr-bg), var(--lfcr-card-2));
	border: 1px solid var(--lfcr-line);
	border-radius: calc(var(--lfcr-radius) + 6px);
	box-shadow: var(--lfcr-shadow);
	padding: 16px;
	overflow: hidden;
}

.lfcr-header {
	display: flex;
	flex-direction: column;
	gap: 16px;
	align-items: flex-start;
	justify-content: space-between;
	margin-bottom: 16px;
}

.lfcr-eyebrow {
	margin: 0 0 6px;
	font-size: 0.76rem;
	font-weight: 800;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--lfcr-muted);
}

.lfcr-header h2 {
	margin: 0;
	font-size: clamp(1.45rem, 5vw, 2.45rem);
	line-height: 1.08;
	letter-spacing: -0.04em;
	color: var(--lfcr-text);
}

.lfcr-theme-toggle,
.lfcr-button {
	appearance: none;
	border: 1px solid var(--lfcr-line);
	border-radius: 999px;
	background: var(--lfcr-card);
	color: var(--lfcr-text);
	font-weight: 800;
	font-size: 0.92rem;
	line-height: 1;
	padding: 12px 16px;
	cursor: pointer;
	transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
	touch-action: manipulation;
}

.lfcr-theme-toggle {
	display: inline-flex;
	gap: 8px;
	align-items: center;
}

.lfcr-theme-toggle:hover,
.lfcr-button:hover {
	transform: translateY(-1px);
	box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
}

.lfcr-theme-toggle:focus-visible,
.lfcr-button:focus-visible,
.lfcr-field input:focus-visible,
.lfcr-field select:focus-visible,
.lfcr-check input:focus-visible {
	outline: 3px solid rgba(100, 116, 139, 0.45);
	outline-offset: 3px;
}

.lfcr-primary {
	background: linear-gradient(135deg, var(--lfcr-primary), var(--lfcr-primary-2));
	color: #ffffff;
	border-color: transparent;
}

.lfcr-validation {
	margin: 0 0 16px;
	padding: 12px 14px;
	border-radius: 14px;
	background: #fef3f2;
	border: 1px solid #fecdca;
	color: var(--lfcr-danger);
	font-weight: 700;
}

.lfcr-calculator-layout,
.lfcr-stack-only .lfcr-calculator-layout {
	display: flex !important;
	flex-direction: column !important;
	gap: 24px;
	width: 100% !important;
	max-width: 100% !important;
	grid-template-columns: none !important;
}

.lfcr-card,
.lfcr-form-panel,
.lfcr-result-panel,
.lfcr-output-below {
	width: 100% !important;
	max-width: 100% !important;
	min-width: 0 !important;
	clear: both !important;
	float: none !important;
	grid-column: 1 / -1 !important;
}

.lfcr-form-panel {
	order: 1 !important;
}

.lfcr-result-panel,
.lfcr-output-below {
	order: 2 !important;
}

.lfcr-card {
	background: var(--lfcr-card);
	border: 1px solid var(--lfcr-line);
	border-radius: var(--lfcr-radius);
	box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
	padding: clamp(16px, 4vw, 26px);
}

.lfcr-section-heading {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 8px 0 16px;
	padding-bottom: 10px;
	border-bottom: 1px solid var(--lfcr-line);
}

.lfcr-section-heading h3 {
	margin: 0;
	font-size: 1.02rem;
	color: var(--lfcr-text);
}

.lfcr-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 14px;
	margin-bottom: 22px;
}

.lfcr-field {
	display: flex;
	flex-direction: column;
	gap: 8px;
	font-weight: 800;
	font-size: 0.9rem;
	color: var(--lfcr-text);
}

.lfcr-field input,
.lfcr-field select {
	width: 100%;
	min-height: 48px;
	border: 1px solid var(--lfcr-line);
	border-radius: 15px;
	background: var(--lfcr-card-2);
	color: var(--lfcr-text);
	font: inherit;
	font-weight: 700;
	padding: 12px 14px;
}

.lfcr-input-suffix {
	display: flex;
	align-items: center;
	gap: 8px;
	border: 1px solid var(--lfcr-line);
	border-radius: 15px;
	background: var(--lfcr-card-2);
	padding-right: 12px;
}

.lfcr-input-suffix input {
	border: 0;
	background: transparent;
}

.lfcr-input-suffix span {
	color: var(--lfcr-muted);
	font-weight: 800;
	white-space: nowrap;
}

.lfcr-slider-field input[type="range"] {
	padding: 0;
	min-height: 32px;
	accent-color: var(--lfcr-primary);
}

.lfcr-checkbox-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 12px;
	margin-bottom: 22px;
}

.lfcr-check {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 12px;
	background: var(--lfcr-card-2);
	border: 1px solid var(--lfcr-line);
	border-radius: 15px;
	font-weight: 700;
	color: var(--lfcr-text);
	cursor: pointer;
}

.lfcr-check input {
	width: 19px;
	height: 19px;
	margin-top: 1px;
	accent-color: var(--lfcr-primary);
	flex: 0 0 auto;
}

.lfcr-actions,
.lfcr-result-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 10px;
}

.lfcr-actions .lfcr-button,
.lfcr-result-actions .lfcr-button {
	flex: 1 1 150px;
}

.lfcr-result-header {
	display: flex;
	flex-direction: column;
	gap: 14px;
	align-items: flex-start;
	justify-content: space-between;
	margin-bottom: 16px;
}

.lfcr-total {
	font-size: clamp(2.2rem, 11vw, 4.4rem);
	line-height: 0.95;
	font-weight: 900;
	letter-spacing: -0.07em;
	color: var(--lfcr-text);
}

.lfcr-badge {
	border-radius: 999px;
	background: rgba(15, 118, 110, 0.1);
	color: var(--lfcr-good);
	font-weight: 900;
	padding: 8px 12px;
	border: 1px solid rgba(15, 118, 110, 0.25);
}

.lfcr-meter {
	width: 100%;
	height: 12px;
	border-radius: 999px;
	background: var(--lfcr-card-2);
	overflow: hidden;
	border: 1px solid var(--lfcr-line);
	margin-bottom: 16px;
}

.lfcr-meter span {
	display: block;
	width: 0;
	height: 100%;
	border-radius: inherit;
	background: linear-gradient(90deg, #9ca3af, #374151);
	transition: width 220ms ease;
}

.lfcr-result-summary {
	margin: 0 0 16px;
	padding: 14px;
	border-radius: 16px;
	background: var(--lfcr-card-2);
	border: 1px solid var(--lfcr-line);
	color: var(--lfcr-muted);
	font-weight: 700;
}

.lfcr-result-cards {
	display: grid;
	grid-template-columns: 1fr;
	gap: 12px;
	margin-bottom: 18px;
}

.lfcr-mini-card {
	padding: 14px;
	border: 1px solid var(--lfcr-line);
	background: var(--lfcr-card-2);
	border-radius: 16px;
}

.lfcr-mini-card span {
	display: block;
	font-size: 0.78rem;
	font-weight: 900;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--lfcr-muted);
	margin-bottom: 6px;
}

.lfcr-mini-card strong {
	font-size: 1.15rem;
	color: var(--lfcr-text);
}

.lfcr-breakdown-wrap {
	width: 100%;
	overflow-x: auto;
	border: 1px solid var(--lfcr-line);
	border-radius: 16px;
	margin-bottom: 16px;
}

.lfcr-breakdown {
	width: 100%;
	border-collapse: collapse;
	min-width: 0;
}

.lfcr-breakdown th,
.lfcr-breakdown td {
	padding: 12px 14px;
	border-bottom: 1px solid var(--lfcr-line);
	text-align: left;
	font-weight: 700;
	color: var(--lfcr-text);
}

.lfcr-breakdown tr:last-child td {
	border-bottom: 0;
}

.lfcr-breakdown td:last-child {
	text-align: right;
	white-space: nowrap;
}

@media (min-width: 600px) {
	.lfcr-header,
	.lfcr-result-header {
		flex-direction: row;
		align-items: center;
	}

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

	.lfcr-checkbox-grid,
	.lfcr-result-cards {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 980px) {
	.lfcr-shell {
		padding: 26px;
	}

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

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

	.lfcr-calculator-layout,
	.lfcr-stack-only .lfcr-calculator-layout {
		display: flex !important;
		flex-direction: column !important;
		grid-template-columns: none !important;
	}
}

@media print {
	.lfcr-theme-toggle,
	.lfcr-form-panel,
	.lfcr-result-actions,
	.lfcr-validation {
		display: none !important;
	}

	.lfcr-calculator,
	.lfcr-shell,
	.lfcr-card {
		box-shadow: none !important;
		border-color: #999 !important;
		background: #fff !important;
		color: #000 !important;
	}
}

/* Version 1.0.2: forced stacked layout so results always appear below inputs. */
.lfcr-calculator.lfcr-stack-only,
.lfcr-calculator.lfcr-stack-only .lfcr-shell,
.lfcr-calculator.lfcr-stack-only .lfcr-calculator-layout,
.lfcr-calculator.lfcr-stack-only .lfcr-form-panel,
.lfcr-calculator.lfcr-stack-only .lfcr-result-panel,
.lfcr-calculator.lfcr-stack-only .lfcr-output-below {
	display: block !important;
	width: 100% !important;
	max-width: 100% !important;
	min-width: 0 !important;
	clear: both !important;
	float: none !important;
	position: relative !important;
	grid-template-columns: none !important;
	grid-column: 1 / -1 !important;
	flex-direction: column !important;
}

.lfcr-calculator.lfcr-stack-only .lfcr-calculator-layout {
	margin-bottom: 24px !important;
}

.lfcr-calculator.lfcr-stack-only .lfcr-form-panel {
	order: 1 !important;
}

.lfcr-calculator.lfcr-stack-only .lfcr-result-panel,
.lfcr-calculator.lfcr-stack-only .lfcr-output-below {
	order: 2 !important;
	margin-top: 24px !important;
}
