/**
 * Cash Flow Calculator — module styles.
 *
 * Inherits the shared design tokens (--bf-primary, --bf-accent, --bf-ink,
 * --bf-muted, --bf-border, --bf-bg-soft, --bf-radius, --bf-shadow) from
 * assets/css/frontend.css. Everything is scoped to .cfc. Mobile-first; two
 * columns at ≥820px. The chart is a zero-baseline column chart built from divs —
 * no canvas, no chart library. Print block included.
 */

.cfc {
	--cfc-pos: #16a34a;
	--cfc-neg: #e11d48;
	--cfc-warn: #f59e0b;
	color: var(--bf-ink, #0f172a);
	font-size: 16px;
	line-height: 1.5;
}
.cfc *,
.cfc *::before,
.cfc *::after { box-sizing: border-box; }

.cfc__grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 18px;
	align-items: start;
}
@media (min-width: 820px) {
	.cfc__grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
}

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

.cfc__inputs {
	border: 1px solid var(--bf-border, #e5e7eb);
	border-radius: var(--bf-radius, 16px);
	background: #fff;
	padding: 22px;
	margin: 0;
	min-width: 0;
}
.cfc__field { margin-top: 18px; }
.cfc__field:first-child { margin-top: 0; }
.cfc__field--split {
	display: grid;
	grid-template-columns: 1.5fr 1fr;
	gap: 12px;
}
@media (max-width: 430px) {
	.cfc__field--split { grid-template-columns: 1fr; }
}

.cfc__label {
	display: block;
	font-weight: 700;
	font-size: 13.5px;
	margin-bottom: 7px;
	color: var(--bf-ink, #0f172a);
}

.cfc__money,
.cfc__suffix {
	display: flex;
	align-items: center;
	border: 1px solid var(--bf-border, #e5e7eb);
	border-radius: 11px;
	background: var(--bf-bg-soft, #f8fafc);
	overflow: hidden;
	transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.cfc__money:focus-within,
.cfc__suffix:focus-within {
	border-color: var(--bf-primary, #4f46e5);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--bf-primary, #4f46e5) 18%, transparent);
	background: #fff;
}
.cfc__sym,
.cfc__unit {
	flex: 0 0 auto;
	padding: 0 11px;
	font-weight: 700;
	color: var(--bf-muted, #64748b);
	font-size: 14px;
}
.cfc__sym { border-right: 1px solid var(--bf-border, #e5e7eb); }
.cfc__unit { border-left: 1px solid var(--bf-border, #e5e7eb); }
.cfc__money input,
.cfc__suffix input {
	flex: 1 1 auto;
	width: 100%;
	min-width: 0;
	border: 0;
	background: transparent;
	padding: 11px 13px;
	font: inherit;
	font-weight: 700;
	font-size: 16px;
	color: var(--bf-ink, #0f172a);
	-moz-appearance: textfield;
}
.cfc__money input:focus,
.cfc__suffix input:focus { outline: none; }
.cfc__money input::-webkit-outer-spin-button,
.cfc__money input::-webkit-inner-spin-button,
.cfc__suffix input::-webkit-outer-spin-button,
.cfc__suffix input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.cfc__hint {
	margin: 8px 0 0;
	font-size: 12.5px;
	line-height: 1.45;
	color: var(--bf-muted, #64748b);
}

.cfc__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 22px;
	padding-top: 18px;
	border-top: 1px solid var(--bf-border, #e5e7eb);
}

/* -------------------------------------------------------------- results */

.cfc__results { min-width: 0; }

.cfc__hero {
	text-align: center;
	padding: 24px 22px;
	border-radius: var(--bf-radius, 16px);
	background: linear-gradient(135deg, color-mix(in srgb, var(--bf-primary, #4f46e5) 12%, #fff), color-mix(in srgb, var(--bf-accent, #0ea5e9) 10%, #fff));
	border: 1px solid var(--bf-border, #e5e7eb);
	margin-bottom: 14px;
}
.cfc__hero-label {
	display: block;
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .05em;
	color: var(--bf-muted, #64748b);
}
.cfc__hero-value {
	display: block;
	margin: 6px 0 10px;
	font-size: clamp(32px, 6.5vw, 48px);
	font-weight: 800;
	line-height: 1.02;
	letter-spacing: -.02em;
	color: var(--bf-primary, #4f46e5);
	font-variant-numeric: tabular-nums;
}
.cfc__status {
	display: inline-block;
	font-size: 13px;
	font-weight: 800;
	padding: 5px 14px;
	border-radius: 999px;
}
.cfc__status--good { background: color-mix(in srgb, var(--cfc-pos) 14%, #fff); color: #15803d; }
.cfc__status--warn { background: color-mix(in srgb, var(--cfc-warn) 16%, #fff); color: #b45309; }
.cfc__status--bad { background: color-mix(in srgb, var(--cfc-neg) 12%, #fff); color: #be123c; }
.cfc__status--neutral { background: var(--bf-bg-soft, #f8fafc); color: var(--bf-muted, #64748b); border: 1px solid var(--bf-border, #e5e7eb); }

.cfc__metrics {
	display: grid;
	grid-template-columns: 1fr;
	gap: 10px;
	margin-bottom: 14px;
}
@media (min-width: 520px) {
	.cfc__metrics { grid-template-columns: repeat(3, 1fr); }
}
.cfc__metric {
	border: 1px solid var(--bf-border, #e5e7eb);
	border-radius: 12px;
	background: #fff;
	padding: 12px 14px;
	text-align: center;
}
.cfc__metric-label {
	display: block;
	font-size: 11.5px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .03em;
	color: var(--bf-muted, #64748b);
	line-height: 1.3;
}
.cfc__metric-value {
	display: block;
	margin-top: 4px;
	font-size: 18px;
	font-weight: 800;
	color: var(--bf-ink, #0f172a);
	font-variant-numeric: tabular-nums;
}

/* Zero-baseline column chart. */
.cfc__chart-wrap {
	border: 1px solid var(--bf-border, #e5e7eb);
	border-radius: 12px;
	background: #fff;
	padding: 14px 16px 10px;
	margin-bottom: 14px;
}
.cfc__chart-title {
	font-size: 12.5px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .03em;
	color: var(--bf-muted, #64748b);
	margin-bottom: 12px;
}
.cfc__chart {
	display: flex;
	align-items: stretch;
	gap: 4px;
	height: 150px;
	position: relative;
}
/* The zero line sits at the boundary between the two halves. */
.cfc__chart::after {
	content: "";
	position: absolute;
	left: 0; right: 0;
	top: 50%;
	border-top: 1px dashed var(--bf-border, #e5e7eb);
	pointer-events: none;
}
.cfc__col {
	flex: 1 1 0;
	min-width: 0;
	display: flex;
	flex-direction: column;
	position: relative;
}
.cfc__col-half {
	flex: 0 0 50%;
	display: flex;
	min-height: 0;
}
.cfc__col-half--top { align-items: flex-end; }
.cfc__col-half--bottom { align-items: flex-start; }
.cfc__col-up,
.cfc__col-down {
	display: block;
	width: 100%;
	transition: height .25s ease;
}
.cfc__col-up { background: var(--cfc-pos); border-radius: 3px 3px 0 0; }
.cfc__col-down { background: var(--cfc-neg); border-radius: 0 0 3px 3px; }
.cfc__col-label {
	position: absolute;
	bottom: -18px;
	left: 0; right: 0;
	text-align: center;
	font-size: 9.5px;
	font-style: normal;
	color: #94a3b8;
}
.cfc__zero-note {
	margin-top: 24px;
	font-size: 11.5px;
	color: #94a3b8;
}

.cfc__breakdown {
	border: 1px solid var(--bf-border, #e5e7eb);
	border-radius: 12px;
	background: var(--bf-bg-soft, #f8fafc);
	padding: 4px 16px;
}
.cfc__break-row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 12px;
	padding: 11px 0;
	border-bottom: 1px dashed var(--bf-border, #e5e7eb);
	font-size: 14px;
}
.cfc__break-row:last-child { border-bottom: 0; }
.cfc__break-row span { color: var(--bf-muted, #64748b); }
.cfc__break-row strong {
	color: var(--bf-ink, #0f172a);
	font-weight: 800;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}
.cfc__break-row--accent strong { color: var(--bf-primary, #4f46e5); font-size: 16px; }

.cfc__notes {
	list-style: none;
	margin: 16px 0 0;
	padding: 0;
	display: grid;
	gap: 8px;
}
.cfc__notes:empty { display: none; }
.cfc__note {
	padding: 11px 14px 11px 38px;
	border: 1px solid var(--bf-border, #e5e7eb);
	border-radius: 10px;
	background: #fff;
	font-size: 13.5px;
	color: var(--bf-muted, #64748b);
	position: relative;
	line-height: 1.45;
}
.cfc__note::before {
	content: "ℹ";
	position: absolute;
	left: 14px; top: 10px;
	font-size: 14px;
	color: var(--bf-primary, #4f46e5);
	font-weight: 700;
}

/* -------------------------------------------------------- monthly table */

.cfc__section { margin-top: 26px; }
.cfc__section-title { margin: 0 0 12px; font-size: 18px; font-weight: 800; }
.cfc__table-wrap { overflow-x: auto; }
.cfc__table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
	font-variant-numeric: tabular-nums;
}
.cfc__table th,
.cfc__table td { text-align: right; padding: 10px 12px; border-bottom: 1px solid var(--bf-border, #e5e7eb); }
.cfc__table thead th {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: .03em;
	color: var(--bf-muted, #64748b);
	background: var(--bf-bg-soft, #f8fafc);
}
.cfc__table th[scope="row"] { text-align: left; font-weight: 700; color: var(--bf-ink, #0f172a); }
.cfc__table thead th:first-child { text-align: left; }
.cfc__td--pos { color: var(--cfc-pos); font-weight: 700; }
.cfc__td--neg { color: var(--cfc-neg); font-weight: 700; }
.cfc__td--strong { font-weight: 800; }
.cfc__table tr.is-negative th[scope="row"],
.cfc__table tr.is-negative .cfc__td--strong { color: var(--cfc-neg); }

/* Stacked, labelled table on small screens. */
@media (max-width: 620px) {
	.cfc__table thead { display: none; }
	.cfc__table, .cfc__table tbody, .cfc__table tr,
	.cfc__table th, .cfc__table td { display: block; width: 100%; }
	.cfc__table tr {
		border: 1px solid var(--bf-border, #e5e7eb);
		border-radius: 12px;
		margin-bottom: 10px;
		padding: 6px 12px;
	}
	.cfc__table th[scope="row"] { border: 0; padding: 8px 0 2px; }
	.cfc__table td {
		border: 0;
		border-top: 1px dashed var(--bf-border, #e5e7eb);
		padding: 6px 0;
		display: flex;
		justify-content: space-between;
		text-align: right;
	}
	.cfc__table td::before {
		content: attr(data-col);
		font-weight: 600;
		color: var(--bf-muted, #64748b);
	}
}

.cfc__disclaimer { margin-top: 22px; font-size: 12.5px; line-height: 1.5; }

/* --------------------------------------------------------------- print */

@media print {
	.cfc__inputs,
	.cfc__actions { display: none !important; }
	.cfc__grid { grid-template-columns: 1fr; }
	.cfc__hero { background: #fff; }
	.cfc__hero-value { color: #000; }
	.cfc { color: #000; font-size: 11pt; }
	.cfc__metric, .cfc__breakdown, .cfc__chart-wrap { break-inside: avoid; }
	.cfc__table { font-size: 9.5pt; }
}
