/* FinFigured calculators — core UI. Theme-independent: every value is a
   token below, so changing theme never breaks the calculators. */

.ffc {
	--ffc-primary: var(--ff-primary, #136F5B);
	--ffc-primary-dark: var(--ff-primary-dark, #0D5545);
	--ffc-accent: var(--ff-highlight, #FFD84D);
	--ffc-text: var(--ff-ink, #12302A);
	--ffc-body: var(--ff-body, #34504A);
	--ffc-muted: var(--ff-muted, #5A6B65);
	--ffc-bg: var(--ff-bg, #ffffff);
	--ffc-surface: var(--ff-paper, #FAFBF8);
	--ffc-border: var(--ff-grid, #DCEBE4);
	--ffc-radius: 20px;
	--ffc-good: #136F5B;
	--ffc-bad: #9A2B12;
	--ffc-s1: #136F5B;
	--ffc-s2: #C98F00;

	color: var(--ffc-text);
	background: var(--ffc-bg);
	border: 1px solid var(--ffc-border);
	border-radius: var(--ffc-radius);
	box-shadow: 0 18px 40px -28px rgba(18, 48, 42, .4);
	overflow: hidden;
	margin: 0 0 2em;
	font-family: var(--ff-font-body, "Public Sans", system-ui, sans-serif);
	font-size: 16px;
	line-height: 1.5;
	box-sizing: border-box;
}
.ffc > form { padding: clamp(18px, 3vw, 28px); margin: 0; }
.ffc *, .ffc *::before, .ffc *::after { box-sizing: border-box; }

.ffc h2, .ffc h3 { margin: 0 0 .6em; line-height: 1.25; font-family: var(--ff-font-head, inherit); letter-spacing: -0.01em; }
.ffc h3 { font-size: 1.1em; }
.ffc-muted { color: var(--ffc-muted); font-size: .9em; }

/* ---------- form ---------- */
.ffc-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.ffc-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ffc-field > label, .ffc-label { font-size: .85em; font-weight: 600; color: var(--ffc-muted); }

.ffc-input { position: relative; display: flex; align-items: center; }
.ffc-input input, .ffc-input select, .ffc input.ffc-plain {
	width: 100%;
	height: 46px;
	padding: 0 12px;
	border: 1.5px solid var(--ffc-border);
	border-radius: 10px;
	font-size: 16px;
	background: var(--ffc-bg);
	color: var(--ffc-text);
	font: inherit;
	font-variant-numeric: tabular-nums;
	-moz-appearance: textfield;
}
.ffc-input input::-webkit-outer-spin-button, .ffc-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ffc-input input:focus, .ffc input.ffc-plain:focus { outline: 2px solid var(--ffc-primary); outline-offset: -1px; border-color: transparent; }
.ffc-input--prefix input { padding-left: 26px; }
.ffc-input--suffix input { padding-right: 30px; }
.ffc-input .ffc-pre, .ffc-input .ffc-suf { position: absolute; color: var(--ffc-muted); pointer-events: none; font-size: .95em; }
.ffc-input .ffc-pre { left: 11px; }
.ffc-input .ffc-suf { right: 11px; }

/* ---------- buttons ---------- */
.ffc-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-height: 40px; padding: 0 16px;
	border: 1px solid var(--ffc-primary); border-radius: 8px;
	background: var(--ffc-primary); color: #fff;
	font: inherit; font-weight: 600; font-size: .92em;
	cursor: pointer; text-decoration: none; transition: background .15s;
}
.ffc-btn:hover { background: var(--ffc-primary-dark); color: #fff; }
.ffc-btn--ghost { background: var(--ffc-bg); border-width: 1.5px; color: var(--ffc-primary); }
.ffc-btn--ghost:hover { background: var(--ffc-surface); color: var(--ffc-primary-dark); }
.ffc-btn--dashed { background: transparent; color: var(--ffc-primary); border-style: dashed; border-width: 1.5px; min-height: 46px; border-radius: 10px; }
.ffc-btn--dashed:hover { background: var(--ffc-surface); color: var(--ffc-primary-dark); }
.ffc-btn { border-radius: 10px; }
.ffc-btn--icon { min-height: 40px; width: 40px; padding: 0; border-color: var(--ffc-border); background: transparent; color: var(--ffc-muted); }
.ffc-btn--icon:hover { background: var(--ffc-surface); color: var(--ffc-bad); }
.ffc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ---------- results ---------- */
.ffc-results {
	border-top: 1px solid var(--ffc-border);
	padding: clamp(18px, 3vw, 28px);
	background-color: var(--ffc-surface);
	background-image: linear-gradient(var(--ffc-border) 1px, transparent 1px), linear-gradient(90deg, var(--ffc-border) 1px, transparent 1px);
	background-size: 24px 24px;
	background-position: -1px -1px;
}
.ffc-results:empty { display: none; }
.ffc-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.ffc-card { background: var(--ffc-bg); border: 1px solid var(--ffc-border); border-radius: 16px; padding: 22px; }
.ffc-card--win { border: 2px solid var(--ffc-primary); padding: 21px; }
.ffc-card__title { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 10px; }
.ffc-badge { flex-shrink: 0; white-space: nowrap; font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--ffc-primary); color: #fff; }
.ffc-badge--win { background: var(--ffc-accent); color: var(--ffc-text); }
.ffc-stat { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: .95em; }
.ffc-stat b { font-variant-numeric: tabular-nums; }
.ffc-big { font-family: var(--ff-font-head, inherit); font-size: 34px; font-weight: 800; letter-spacing: -0.01em; color: var(--ffc-text); }
.ffc-card--win .ffc-big { color: var(--ffc-primary); }
.ffc-summary { margin: 0 0 8px; font-size: clamp(18px, 2vw, 20px); line-height: 1.55; max-width: 860px; }
.ffc-hl { background: linear-gradient(transparent 50%, var(--ffc-accent) 50%, var(--ffc-accent) 92%, transparent 92%); padding: 0 .15em; font-weight: 800; font-variant-numeric: tabular-nums; }
.ffc-results .ffc-muted { margin: 0 0 18px; }
.ffc-alert { margin: 16px 0 0; padding: 12px 14px; border-radius: 8px; background: #fef2f2; color: var(--ffc-bad); border: 1px solid #fecaca; font-size: .95em; }

/* ---------- tables ---------- */
.ffc-table-wrap { overflow-x: auto; margin-top: 10px; border: 1px solid var(--ffc-border); border-radius: 12px; background: var(--ffc-bg); }
.ffc-table { width: 100%; border-collapse: collapse; font-size: .9em; margin: 0; }
.ffc-table th, .ffc-table td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--ffc-border); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ffc-table th:first-child, .ffc-table td:first-child { text-align: left; }
.ffc-table thead th { position: sticky; top: 0; background: var(--ffc-surface); font-weight: 700; }
.ffc-table tr.is-paid td { color: var(--ffc-good); font-weight: 600; }

.ffc details { margin-top: 18px; }
.ffc summary { cursor: pointer; font-weight: 700; color: var(--ffc-primary); }

/* ---------- tabs ---------- */
.ffc-tabs { display: inline-flex; border: 1px solid var(--ffc-border); border-radius: 8px; overflow: hidden; margin: 10px 0; }
.ffc-tabs button { border: 0; background: transparent; padding: 8px 14px; font: inherit; font-size: .9em; cursor: pointer; color: var(--ffc-muted); }
.ffc-tabs button[aria-selected="true"] { background: var(--ffc-primary); color: #fff; }

/* ---------- chart ---------- */
.ffc-chart { margin-top: 20px; background: var(--ffc-bg); border: 1px solid var(--ffc-border); border-radius: 16px; padding: 18px 18px 8px; }
.ffc-chart__wrap { position: relative; }
.ffc-chart__svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.ffc-chart__grid { stroke: var(--ffc-border); stroke-width: 1; }
.ffc-chart__tick { fill: var(--ffc-muted); font-size: 11px; }
.ffc-chart__line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.ffc-chart__cursor { stroke: var(--ffc-muted); stroke-dasharray: 3 3; }
.ffc-chart__legend { display: flex; gap: 16px; font-size: .85em; margin-bottom: 6px; }
.ffc-chart__legend i, .ffc-chart__tip i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.ffc-chart__tip { position: absolute; top: 8px; background: var(--ffc-bg); border: 1px solid var(--ffc-border); border-radius: 8px; padding: 8px 10px; font-size: .82em; box-shadow: 0 4px 16px rgba(0,0,0,.08); pointer-events: none; white-space: nowrap; }

/* ---------- ads (reserved space = no CLS) ---------- */
.ffc-ad { margin: 0 0 2em; text-align: center; overflow: hidden; }
.ffc-ad__label { display: block; font-size: 11px; color: #9ca3af; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }

.ffc-error { color: #b91c1c; }

@media (max-width: 600px) {
	.ffc > form, .ffc-results { padding: 14px; }
	.ffc-big { font-size: 28px; }
}

@media print {
	.ffc-actions, .ffc-ad, .ffc-btn--icon { display: none !important; }
	.ffc details { display: block; }
}
