/* BWD Calculators 2.0.0 — built on the theme's .bwd-tool tokens. */
.bwdmc {
	--bwdmc-good: #15803d;
	--bwdmc-good-bg: #f0fdf4;
	--bwdmc-warn: #b45309;
	--bwdmc-warn-bg: #fffbeb;
	--bwdmc-bad: var(--bwd-t-fail, #a3231b);
	--bwdmc-bad-bg: #fef2f2;
	--bwdmc-info-bg: #fff7ed;
	--bwdmc-ease: cubic-bezier(.22, 1, .36, 1);
	--bwdmc-shadow: 0 1px 2px rgba(16, 21, 31, .05), 0 6px 18px rgba(249, 125, 10, .06);
	gap: 20px;
}
.bwdmc [hidden] { display: none !important; }
/* Grid children may shrink below their content, so wide tables scroll instead of widening the page. */
.bwdmc > *, .bwdmc-grid > *, .bwdmc-panel > * { min-width: 0; max-width: 100%; }

.bwdmc-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.bwdmc-currency { width: 130px; }

.bwdmc-grid { display: grid; gap: 18px; }
@media (min-width: 1000px) {
	.bwdmc-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
	.bwdmc-panel--input { position: sticky; top: 96px; }
}

.bwdmc-panel { display: grid; gap: 16px; min-width: 0; padding: 20px; border: 1px solid var(--bwd-t-line); border-radius: 14px; background: var(--bwd-t-raised); scroll-margin-top: 96px; }
.bwdmc-panel--output { background: var(--bwd-t-surface); box-shadow: var(--bwdmc-shadow); }
.bwdmc-panel__title { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }

.bwdmc-fields { display: grid; gap: 14px; }
@media (min-width: 560px) { .bwdmc-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Side-by-side fields keep their inputs level when one label wraps onto two lines. */
.bwdmc-fields > .bwdmc-field { display: grid; grid-template-rows: 1fr auto auto; align-content: stretch; }
.bwdmc-fields > .bwdmc-field > .bwd-tool__label { align-self: end; }
.bwdmc-field { align-content: start; }
.bwdmc-field .bwd-tool__label { line-height: 1.35; }

/* Inputs with currency and unit affixes */
.bwdmc-affix { position: relative; display: flex; align-items: stretch; }
.bwdmc-affix .bwdmc-input { flex: 1 1 auto; min-width: 0; font-variant-numeric: tabular-nums; }
.bwdmc-affix.has-pre .bwdmc-input { padding-left: 44px; }
/* Room for the unit: set from its length by the engine; the five bespoke tools use the fallback. */
.bwdmc-affix.has-post .bwdmc-input { padding-right: calc(var(--bwdmc-post, 9.2) * 7.4px + 24px); }
.bwdmc-affix__pre, .bwdmc-affix__post { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; color: var(--bwd-t-muted); font-size: 13.5px; pointer-events: none; }
.bwdmc-affix__pre { left: 12px; min-width: 26px; font-weight: 600; }
/* Selects render shorter than text inputs; match them so rows of mixed fields line up. */
.bwdmc-affix > select.bwdmc-input { min-height: 48px; }
.bwdmc-affix__post { right: 12px; }

/* Segmented radio buttons */
.bwdmc-seg-wrap { display: grid; gap: 8px; }
.bwdmc-seg { display: flex; flex-wrap: wrap; gap: 8px; }
.bwdmc-seg--platforms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bwdmc-seg__btn--wide { grid-column: 1 / -1; }
.bwdmc-seg__btn {
	min-height: 44px; padding: 9px 16px; border: 1px solid var(--bwd-t-line); border-radius: 10px;
	background: var(--bwd-t-surface); color: var(--bwd-t-ink); font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer;
	transition: transform .18s var(--bwdmc-ease), opacity .18s ease;
}
.bwdmc-seg__btn:hover { transform: translateY(-1px); }
.bwdmc-seg__btn:active { transform: translateY(0); opacity: .85; }
.bwdmc-seg__btn:focus-visible { outline: 2px solid var(--bwd-t-brand); outline-offset: 2px; }
.bwdmc-seg__btn[aria-checked="true"] { border-color: var(--bwd-t-brand); background: var(--bwd-t-brand); color: #fff; box-shadow: 0 4px 14px rgba(249, 125, 10, .28); }

/* Collapsible groups */
.bwdmc-more { border-top: 1px dashed var(--bwd-t-line); padding-top: 12px; }
.bwdmc-more > .bwdmc-fields { margin-top: 12px; }
.bwdmc-more__summary { cursor: pointer; font-size: 14px; font-weight: 700; list-style-position: inside; border-radius: 6px; }
.bwdmc-more__summary:hover { color: var(--bwd-t-brand); }
.bwdmc-more__summary:focus-visible { outline: 2px solid var(--bwd-t-brand); outline-offset: 3px; }
.bwdmc-cta { justify-content: center; width: 100%; }
@media (min-width: 1000px) { .bwdmc-cta { display: none; } }

/* Result tiles */
.bwdmc-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .bwdmc-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.bwdmc-stat { display: grid; align-content: start; gap: 4px; min-width: 0; padding: 14px; border: 1px solid var(--bwd-t-line); border-radius: 12px; background: var(--bwd-t-raised); }
.bwdmc-stat--hero { border-color: rgba(249, 125, 10, .45); background: linear-gradient(160deg, rgba(249, 125, 10, .10), rgba(249, 125, 10, .02)); }
.bwdmc-stat__label { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--bwd-t-muted); text-transform: uppercase; letter-spacing: .04em; }
.bwdmc-stat__value { margin: 0; font-size: clamp(20px, 2.4vw, 26px); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.bwdmc-stat__note { margin: 0; min-height: 1.2em; font-size: 12.5px; color: var(--bwd-t-muted); }
.bwdmc-stat--long { grid-column: 1 / -1; }
.bwdmc-stat--long .bwdmc-stat__value { font-size: 17px; font-weight: 700; letter-spacing: 0; line-height: 1.45; }
.bwdmc-stat[data-tone="good"] .bwdmc-stat__value { color: var(--bwdmc-good); }
.bwdmc-stat[data-tone="bad"] .bwdmc-stat__value { color: var(--bwdmc-bad); }
.bwdmc-stat[data-tone="warn"] .bwdmc-stat__value { color: var(--bwdmc-warn); }
.bwdmc-stat.is-fresh .bwdmc-stat__value { animation: bwdmc-fresh .45s var(--bwdmc-ease); }
@keyframes bwdmc-fresh { from { opacity: .35; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Funnel and comparison bars */
.bwdmc-funnel, .bwdmc-ab { display: grid; gap: 10px; }
.bwdmc-funnel__row, .bwdmc-ab__row { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 13.5px; }
.bwdmc-ab__row { grid-template-columns: 24px minmax(0, 1fr) 64px; }
.bwdmc-funnel__label, .bwdmc-ab__name { font-weight: 600; color: var(--bwd-t-muted); }
.bwdmc-funnel__value, .bwdmc-ab__value { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.bwdmc-funnel__track, .bwdmc-ab__track { position: relative; height: 12px; border-radius: 999px; background: var(--bwd-t-raised); overflow: hidden; }
.bwdmc-funnel__bar, .bwdmc-ab__fill { position: absolute; inset: 0; border-radius: 999px; background: linear-gradient(90deg, #f97d0a, #fb923c); transform-origin: left center; transform: scaleX(0); transition: transform .6s var(--bwdmc-ease); }
.bwdmc-ab__row:nth-child(2) .bwdmc-ab__fill { background: linear-gradient(90deg, #10151f, #46505f); }

/* Meters: markers are full-width layers moved with transform, so clip them to the meter. */
.bwdmc-gauge, .bwdmc-ratio { overflow: hidden; padding: 6px 3px; }

/* Profitability gauge (ROAS) */
.bwdmc-gauge__track { position: relative; display: block; height: 14px; border-radius: 999px; background: var(--bwd-t-raised); }
.bwdmc-gauge__fill { position: absolute; inset: 0; border-radius: 999px; background: var(--bwdmc-good); transform-origin: left center; transform: scaleX(0); transition: transform .6s var(--bwdmc-ease); }
.bwdmc-gauge[data-tone="bad"] .bwdmc-gauge__fill { background: var(--bwdmc-bad); }
.bwdmc-gauge__mark { position: absolute; inset: -5px 0; transition: transform .6s var(--bwdmc-ease); pointer-events: none; }
.bwdmc-gauge__mark::before { content: ""; position: absolute; top: 0; bottom: 0; left: -1px; width: 3px; border-radius: 2px; background: var(--bwd-t-ink); }
.bwdmc-gauge__text { margin: -6px 0 0; font-size: 13.5px; color: var(--bwd-t-muted); }

/* LTV:CAC scale */
.bwdmc-ratio { display: grid; gap: 6px; }
.bwdmc-ratio__track { position: relative; display: grid; grid-template-columns: 1fr 2fr 2fr 1fr; height: 14px; border-radius: 999px; overflow: visible; }
.bwdmc-ratio__zone:first-child { border-radius: 999px 0 0 999px; }
.bwdmc-ratio__zone.is-bad { background: rgba(163, 35, 27, .55); border-radius: 999px 0 0 999px; }
.bwdmc-ratio__zone.is-warn { background: rgba(180, 83, 9, .45); }
.bwdmc-ratio__zone.is-good { background: rgba(21, 128, 61, .55); }
.bwdmc-ratio__zone.is-high { background: rgba(21, 128, 61, .3); border-radius: 0 999px 999px 0; }
.bwdmc-ratio__marker { position: absolute; inset: -6px 0; transition: transform .6s var(--bwdmc-ease); pointer-events: none; }
.bwdmc-ratio__marker::before { content: ""; position: absolute; top: 0; bottom: 0; left: -2px; width: 4px; border-radius: 2px; background: var(--bwd-t-ink); box-shadow: 0 0 0 2px var(--bwd-t-surface); }
.bwdmc-ratio__labels { position: relative; height: 16px; font-size: 12px; color: var(--bwd-t-muted); }
.bwdmc-ratio__labels span { position: absolute; top: 0; transform: translateX(-50%); }
.bwdmc-ratio__labels span:nth-child(1) { left: 0; transform: none; }
.bwdmc-ratio__labels span:nth-child(2) { left: 16.67%; }
.bwdmc-ratio__labels span:nth-child(3) { left: 50%; }
.bwdmc-ratio__labels span:nth-child(4) { left: 83.33%; }

/* Verdict, insights and helper text */
.bwdmc-verdict { margin: 0; padding: 12px 14px; border-radius: 10px; font-weight: 700; background: var(--bwdmc-info-bg); }
.bwdmc-verdict:empty { display: none; }
.bwdmc-verdict[data-tone="good"] { background: var(--bwdmc-good-bg); color: var(--bwdmc-good); }
.bwdmc-verdict[data-tone="bad"] { background: var(--bwdmc-bad-bg); color: var(--bwdmc-bad); }
.bwdmc-verdict[data-tone="warn"] { background: var(--bwdmc-warn-bg); color: var(--bwdmc-warn); }
.bwdmc-insights { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.bwdmc-insight { position: relative; margin: 0; padding: 10px 12px 10px 30px; border-radius: 10px; background: var(--bwd-t-raised); font-size: 14px; line-height: 1.55; }
.bwdmc-insight::before { content: ""; position: absolute; left: 12px; top: 17px; width: 8px; height: 8px; border-radius: 50%; background: var(--bwd-t-brand); }
.bwdmc-insight[data-tone="good"]::before { background: var(--bwdmc-good); }
.bwdmc-insight[data-tone="bad"]::before { background: var(--bwdmc-bad); }
.bwdmc-insight[data-tone="warn"]::before { background: var(--bwdmc-warn); }
.bwdmc-identity { margin: 0; font-size: 13px; color: var(--bwd-t-muted); font-variant-numeric: tabular-nums; }
.bwdmc-identity:empty { display: none; }

/* Platform comparison table */
.bwdmc-compare { display: grid; gap: 10px; }
.bwdmc-compare__title { margin: 0; font-size: 15px; font-weight: 700; }
.bwdmc-table-scroll { overflow-x: auto; border: 1px solid var(--bwd-t-line); border-radius: 12px; }
.bwdmc-table-scroll:focus-visible { outline: 2px solid var(--bwd-t-brand); outline-offset: 2px; }
.bwdmc-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.bwdmc-table th, .bwdmc-table td { padding: 10px 12px; border-bottom: 1px solid var(--bwd-t-line); text-align: right; white-space: nowrap; }
.bwdmc-table thead th { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--bwd-t-muted); background: var(--bwd-t-raised); }
.bwdmc-table th[scope="row"], .bwdmc-table thead th:first-child { text-align: left; }
.bwdmc-table tbody tr:last-child > * { border-bottom: 0; }
.bwdmc-table tr.is-current { background: rgba(249, 125, 10, .08); }
.bwdmc-linkbtn { padding: 2px 0; border: 0; background: none; color: var(--bwd-t-ink); font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; text-decoration-color: rgba(249, 125, 10, .5); text-underline-offset: 3px; transition: opacity .16s ease; }
.bwdmc-linkbtn:hover { color: var(--bwd-t-brand); }
.bwdmc-linkbtn:active { opacity: .7; }
.bwdmc-linkbtn:focus-visible { outline: 2px solid var(--bwd-t-brand); outline-offset: 2px; border-radius: 4px; }
.bwdmc-badge { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: var(--bwdmc-good-bg); color: var(--bwdmc-good); font-size: 11.5px; font-weight: 700; vertical-align: 1px; }

/* Checkbox fields */
.bwdmc-field--wide { grid-column: 1 / -1; }
.bwdmc-field--check { align-content: end; }
.bwdmc-fields > .bwdmc-field--check > .bwdmc-checkrow { align-self: end; }
.bwdmc-checkrow { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.bwdmc-checkrow .bwd-tool__label { margin: 0; cursor: pointer; }
.bwdmc-check { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--bwd-t-brand); cursor: pointer; transition: transform .16s var(--bwdmc-ease); }
.bwdmc-check:hover { transform: scale(1.08); }
.bwdmc-check:active { transform: scale(.94); }
.bwdmc-check:focus-visible { outline: 2px solid var(--bwd-t-brand); outline-offset: 2px; }

/* Repeatable rows (courses, debts, line items) */
.bwdmc-rows { display: grid; gap: 10px; min-width: 0; }
.bwdmc-rows > .bwd-tool__label { margin: 0; }
.bwdmc-rows__list { display: grid; gap: 10px; }
.bwdmc-rows__row { position: relative; display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 48px 12px 12px; border: 1px solid var(--bwd-t-line); border-radius: 12px; background: var(--bwd-t-surface); }
.bwdmc-rows__cell { display: grid; grid-template-rows: 1fr auto; gap: 4px; flex: 1 1 96px; min-width: 0; }
.bwdmc-rows__cell > .bwdmc-rows__label { align-self: end; }
.bwdmc-rows__cell:first-child { flex: 2 1 140px; }
.bwdmc-rows__label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--bwd-t-muted); }
.bwdmc-rows__row .bwdmc-affix.has-pre .bwdmc-input { padding-left: 34px; }
.bwdmc-rows__row .bwdmc-affix__pre { left: 10px; min-width: 0; }
.bwdmc-rows__remove {
	position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
	border: 1px solid transparent; border-radius: 8px; background: none; color: var(--bwd-t-muted); font: inherit; font-size: 20px; line-height: 1; cursor: pointer;
	transition: transform .16s var(--bwdmc-ease), opacity .16s ease;
}
.bwdmc-rows__remove:hover { color: var(--bwdmc-bad); background: var(--bwdmc-bad-bg); }
.bwdmc-rows__remove:active { transform: scale(.92); }
.bwdmc-rows__remove:focus-visible { outline: 2px solid var(--bwd-t-brand); outline-offset: 2px; }
.bwdmc-rows__add { justify-self: start; }

.bwdmc-actions { align-items: center; }
.bwdmc-status:empty { display: none; }

/* Article tables on the calculator pages (outside the tool itself) */
.bwdmc-prose-table { max-width: 100%; overflow-x: auto; margin: 1.25em 0; border-radius: 8px; }
.bwdmc-prose-table > table { margin: 0; }
.bwdmc-prose-table:focus-visible { outline: 2px solid #f97d0a; outline-offset: 2px; }

@media (prefers-color-scheme: dark) {
	.bwdmc {
		--bwdmc-good: #4ade80;
		--bwdmc-good-bg: rgba(74, 222, 128, .1);
		--bwdmc-warn: #fbbf24;
		--bwdmc-warn-bg: rgba(251, 191, 36, .1);
		--bwdmc-bad: #f87171;
		--bwdmc-bad-bg: rgba(248, 113, 113, .1);
		--bwdmc-info-bg: rgba(249, 125, 10, .12);
		--bwdmc-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
	}
	.bwdmc-ab__row:nth-child(2) .bwdmc-ab__fill { background: linear-gradient(90deg, #eef1f6, #a6afbd); }
}

@media (prefers-reduced-motion: reduce) {
	.bwdmc *, .bwdmc *::before { transition: none !important; animation: none !important; }
}

@media print {
	.bwdmc-actions, .bwdmc-cta, .bwdmc-currency { display: none; }
	.bwdmc-panel--input { position: static; }
}
