/*
 * Forces Brands — Affiliate portal
 *
 * The affiliate area is its own surface, parallel to the seller portal but never
 * borrowing its markup or classes. Everything here is namespaced .fm-aff-* and
 * built entirely from the --fb-* design tokens, so a token change re-skins it.
 *
 * Breakpoints accounted for: 1440, 1024, 900 (sidebar becomes a drawer), 768, 375.
 */

/* =====================================================================
   Local tokens
   ===================================================================== */

.fm-aff-shell,
.fm-aff-public,
.fm-aff-gate {
	--fm-aff-gap: 20px;
	--fm-aff-radius: var(--fb-radius-md);
	--fm-aff-card-bg: var(--fb-surface);
	--fm-aff-card-border: var(--fb-border);
	--fm-aff-inset: var(--fb-sand);
	font-family: var(--fb-font-body);
	color: var(--fb-ink);
}

/* Page chrome: the portal owns the full viewport, so the theme's page title and
   content padding would only fight it. */
body.fm-affiliate-portal-page .entry-title,
body.fm-affiliate-portal-page .page-title,
body.fm-affiliate-portal-page .entry-header {
	display: none;
}

body.fm-affiliate-portal-page,
body.fm-affiliate-public-page {
	background: var(--fb-cream);
	color: var(--fb-ink);
}

/* The portal is a full-bleed app shell, so the theme's centred page container
   would otherwise inset it and leave dead margins either side of the sidebar. */
body.fm-affiliate-portal-page .fbm-main,
body.fm-affiliate-portal-page .fbm-container,
body.fm-affiliate-portal-page .fbm-page,
body.fm-affiliate-portal-page .fbm-page__content {
	max-width: none;
	width: 100%;
	margin: 0;
	padding: 0;
}

/* =====================================================================
   Shell
   ===================================================================== */

.fm-aff-shell {
	display: flex;
	min-height: 100vh;
	background: var(--fb-cream);
}

.fm-aff-skip {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 300;
	padding: 10px 16px;
	background: var(--fb-blue);
	color: var(--fb-on-accent);
	border-radius: 0 0 var(--fb-radius-sm) 0;
	font-size: 14px;
	font-weight: 600;
}

.fm-aff-skip:focus {
	left: 0;
}

.fm-aff-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
	z-index: 149;
}

.fm-aff-overlay--visible {
	display: block;
}

/* ---- Sidebar ---- */

.fm-aff-sidebar {
	width: 232px;
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 22px 14px 18px;
	background: linear-gradient(180deg, #101827 0%, var(--fb-cream) 100%);
	border-right: 1px solid var(--fb-border);
	position: sticky;
	top: 0;
	height: 100vh;
	overflow-y: auto;
	z-index: 150;
}

.fm-aff-sidebar__brand {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 0 6px 14px;
}

.fm-aff-sidebar__mark {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	flex-shrink: 0;
	border-radius: 10px;
	background: linear-gradient(135deg, var(--fb-blue) 0%, var(--fb-blue-deep) 100%);
	color: var(--fb-on-accent);
	box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

/* Their own logo replaces the bolt: no gradient fill behind a supplied image */
.fm-aff-sidebar__mark--logo {
	background: var(--fb-surface);
	border: 1px solid var(--fb-border);
	box-shadow: none;
	overflow: hidden;
	padding: 0;
}

.fm-aff-sidebar__mark--logo img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.fm-aff-sidebar__brand-text {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.fm-aff-sidebar__brand-name {
	font-family: var(--fb-font-heading);
	font-size: 14px;
	font-weight: 700;
	line-height: 1.25;
	color: var(--fb-ink);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.fm-aff-sidebar__brand-role {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	color: var(--fb-ink-soft);
}

.fm-aff-sidebar__status {
	align-self: flex-start;
	margin: 0 6px 14px;
}

/* ---- Nav ---- */

.fm-aff-nav {
	flex: 1;
}

.fm-aff-nav__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.fm-aff-nav__item {
	margin: 0;
}

.fm-aff-nav__link {
	display: flex;
	align-items: center;
	gap: 11px;
	min-height: var(--fb-tap-min);
	padding: 10px 12px;
	border-radius: var(--fb-radius-sm);
	color: var(--fb-ink-soft);
	font-size: 14px;
	font-weight: 500;
	text-decoration: none;
	transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.fm-aff-nav__link:hover,
.fm-aff-nav__link:focus-visible {
	background: rgba(124, 192, 255, 0.09);
	color: var(--fb-ink);
}

.fm-aff-nav__link--active {
	background: var(--fb-khaki);
	color: var(--fb-ink);
	font-weight: 600;
	box-shadow: inset 3px 0 0 var(--fb-azure);
}

.fm-aff-nav__icon {
	display: inline-flex;
	flex-shrink: 0;
	color: currentColor;
	opacity: 0.9;
}

.fm-aff-sidebar__footer {
	padding-top: 12px;
	border-top: 1px solid var(--fb-border);
}

.fm-aff-sidebar__logout {
	display: flex;
	align-items: center;
	gap: 9px;
	min-height: var(--fb-tap-min);
	padding: 10px 12px;
	border-radius: var(--fb-radius-sm);
	color: var(--fb-ink-soft);
	font-size: 13px;
	font-weight: 500;
	text-decoration: none;
}

.fm-aff-sidebar__logout:hover,
.fm-aff-sidebar__logout:focus-visible {
	background: rgba(255, 255, 255, 0.05);
	color: var(--fb-ink);
}

.fm-aff-sidebar__close {
	display: none;
	position: absolute;
	top: 12px;
	right: 12px;
	width: 36px;
	height: 36px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.08);
	color: var(--fb-ink);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}

/* ---- Body + topbar ---- */

.fm-aff-body {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
}

.fm-aff-topbar {
	position: sticky;
	top: 0;
	z-index: 120;
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 60px;
	padding: 10px 24px;
	background: rgba(14, 19, 32, 0.88);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--fb-border);
}

.fm-aff-topbar__toggle {
	display: none;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	flex-shrink: 0;
	border: 1px solid var(--fb-border);
	border-radius: var(--fb-radius-sm);
	background: var(--fb-surface);
	color: var(--fb-ink);
	cursor: pointer;
}

.fm-aff-topbar__title {
	margin: 0;
	font-family: var(--fb-font-heading);
	font-size: 17px;
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var(--fb-ink);
}

.fm-aff-topbar__actions {
	margin-left: auto;
	display: flex;
	align-items: center;
	gap: 12px;
}

.fm-aff-code-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 6px 12px;
	border: 1px solid var(--fb-border-strong);
	border-radius: 999px;
	background: var(--fb-sand);
}

.fm-aff-code-chip__label {
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--fb-ink-soft);
}

.fm-aff-code-chip__value {
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.06em;
	color: var(--fb-azure);
}

.fm-aff-topbar__logout {
	font-size: 13px;
	font-weight: 600;
	color: var(--fb-ink-soft);
	text-decoration: none;
}

.fm-aff-topbar__logout:hover {
	color: var(--fb-ink);
}

.fm-aff-main {
	flex: 1;
	min-width: 0;
	padding: 26px 24px 56px;
	display: flex;
	flex-direction: column;
	gap: var(--fm-aff-gap);
	max-width: 1280px;
	width: 100%;
}

/*
 * Flex and grid children default to `min-width: auto`, which means they refuse
 * to shrink below their content. The referral table carries `min-width: 560px`
 * for its own horizontal scroll, and without this it would push the entire
 * portal wider than a phone viewport and clip everything on the right.
 */
.fm-aff-main > *,
.fm-aff-grid > *,
.fm-aff-grid__main > *,
.fm-aff-grid__side > *,
.fm-aff-tiles > *,
.fm-aff-card,
.fm-aff-section,
.fm-aff-hero,
.fm-aff-hero > * {
	min-width: 0;
}

/* =====================================================================
   Hero
   ===================================================================== */

.fm-aff-hero {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
	gap: 24px;
	align-items: center;
	padding: 26px 28px;
	border: 1px solid var(--fb-border);
	border-radius: var(--fb-radius-lg);
	background:
		radial-gradient(120% 160% at 100% 0%, rgba(59, 130, 246, 0.16) 0%, rgba(59, 130, 246, 0) 58%),
		var(--fb-surface);
	box-shadow: var(--fb-shadow-sm);
}

.fm-aff-hero__eyebrow {
	margin: 0 0 2px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--fb-azure);
}

.fm-aff-hero__title {
	margin: 0 0 8px;
	font-family: var(--fb-font-heading);
	font-size: clamp(26px, 3.4vw, 36px);
	font-weight: 800;
	line-height: 1.1;
	letter-spacing: -0.025em;
	color: var(--fb-ink);
}

.fm-aff-hero__lead {
	margin: 0;
	max-width: 46ch;
	font-size: 15px;
	line-height: 1.6;
	color: var(--fb-ink-soft);
}

.fm-aff-hero__lead strong {
	color: var(--fb-ink);
	font-weight: 700;
}

/* ---- Link card ---- */

.fm-aff-linkcard {
	padding: 18px;
	border: 1px solid var(--fb-border-strong);
	border-radius: var(--fm-aff-radius);
	background: var(--fb-cream);
}

.fm-aff-linkcard--muted {
	opacity: 0.9;
}

.fm-aff-linkcard__label {
	display: block;
	margin-bottom: 9px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--fb-ink-soft);
}

.fm-aff-linkcard__hint {
	margin: 11px 0 0;
	font-size: 13px;
	line-height: 1.55;
	color: var(--fb-ink-soft);
}

.fm-aff-linkcard__hint a {
	color: var(--fb-azure);
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
}

.fm-aff-linkcard__hint a:hover {
	text-decoration: underline;
}

/* ---- Code card ---- */

.fm-aff-codecard {
	padding: 20px;
	border: 1px solid var(--fb-border-strong);
	border-radius: var(--fm-aff-radius);
	background: var(--fb-cream);
}

.fm-aff-codecard--muted {
	opacity: 0.9;
}

.fm-aff-codecard__main .fm-aff-copy__input {
	padding: 14px 18px;
	border-style: dashed;
	border-color: var(--fb-blue);
	background: rgba( 59, 130, 246, 0.12 );
	color: var(--fb-ink);
	font-size: 26px;
	font-weight: 800;
	letter-spacing: 0.14em;
	text-align: center;
}

.fm-aff-codecard__main .fm-aff-copy__btn {
	padding-left: 20px;
	padding-right: 20px;
}

.fm-aff-codecard__steps {
	margin: 18px 0 0;
	padding-left: 20px;
	display: grid;
	gap: 6px;
	font-size: 14px;
	line-height: 1.55;
	color: var(--fb-ink-soft);
}

.fm-aff-codecard__note {
	margin: 14px 0 0;
	font-size: 13px;
	line-height: 1.55;
	color: var(--fb-ink-soft);
}

@media (max-width: 560px) {
	.fm-aff-codecard__main {
		flex-direction: column;
	}
	.fm-aff-codecard__main .fm-aff-copy__input {
		font-size: 21px;
		letter-spacing: 0.1em;
	}
}

/* =====================================================================
   Copy control
   ===================================================================== */

.fm-aff-copy {
	display: flex;
	align-items: stretch;
	gap: 8px;
}

.fm-aff-copy__input {
	flex: 1;
	min-width: 0;
	padding: 11px 13px;
	border: 1px solid var(--fb-border-strong);
	border-radius: var(--fb-radius-sm);
	background: var(--fb-sand);
	color: var(--fb-ink);
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
	font-size: 13px;
	line-height: 1.4;
	text-overflow: ellipsis;
}

.fm-aff-copy__input:focus {
	outline: none;
	border-color: var(--fb-azure);
	box-shadow: var(--fb-focus-ring);
}

.fm-aff-copy__btn {
	flex-shrink: 0;
	min-width: 92px;
	min-height: var(--fb-tap-min);
	padding: 0 18px;
	border: 0;
	border-radius: var(--fb-radius-sm);
	background: linear-gradient(135deg, var(--fb-blue) 0%, var(--fb-blue-deep) 100%);
	color: var(--fb-on-accent);
	font-family: var(--fb-font-body);
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	transition: filter 0.16s ease, transform 0.16s ease;
}

.fm-aff-copy__btn:hover {
	filter: brightness(1.08);
}

.fm-aff-copy__btn:active {
	transform: translateY(1px);
}

.fm-aff-copy__btn:focus-visible {
	outline: none;
	box-shadow: var(--fb-focus-ring);
}

.fm-aff-copy__btn--done {
	background: var(--fb-khaki);
	color: var(--fb-azure);
	box-shadow: inset 0 0 0 1px var(--fb-azure);
}

.fm-aff-copy--compact .fm-aff-copy__input {
	font-size: 12px;
	padding: 9px 11px;
}

.fm-aff-copy--compact .fm-aff-copy__btn {
	min-width: 74px;
	min-height: 40px;
	padding: 0 14px;
	font-size: 13px;
}

/* =====================================================================
   Banner + notices
   ===================================================================== */

.fm-aff-banner {
	display: flex;
	gap: 14px;
	padding: 16px 18px;
	border: 1px solid var(--fb-border-strong);
	border-left: 3px solid var(--fb-azure);
	border-radius: var(--fm-aff-radius);
	background: var(--fb-accent-bg);
}

.fm-aff-banner__icon {
	flex-shrink: 0;
	color: var(--fb-azure);
	padding-top: 1px;
}

.fm-aff-banner__title {
	margin: 0 0 3px;
	font-size: 14px;
	font-weight: 700;
	color: var(--fb-ink);
}

.fm-aff-banner__text {
	margin: 0;
	font-size: 13px;
	line-height: 1.55;
	color: var(--fb-ink-soft);
}

.fm-aff-notice {
	padding: 13px 16px;
	border-radius: var(--fb-radius-sm);
	border: 1px solid var(--fb-border-strong);
	background: var(--fb-sand);
	color: var(--fb-ink);
	font-size: 14px;
	line-height: 1.5;
}

.fm-aff-notice--success {
	border-color: rgba(74, 222, 128, 0.4);
	background: rgba(74, 222, 128, 0.1);
}

.fm-aff-notice--error {
	border-color: rgba(248, 113, 113, 0.45);
	background: rgba(248, 113, 113, 0.1);
}

.fm-aff-notice--info {
	border-color: rgba(124, 192, 255, 0.4);
	background: var(--fb-accent-bg);
}

/* =====================================================================
   Stat tiles
   ===================================================================== */

.fm-aff-tiles {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 14px;
}

.fm-aff-tile {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 5px;
	padding: 18px 18px 17px;
	border: 1px solid var(--fb-border);
	border-radius: var(--fm-aff-radius);
	background: var(--fb-surface);
	overflow: hidden;
}

.fm-aff-tile::before {
	content: "";
	position: absolute;
	inset: 0 auto 0 0;
	width: 3px;
	background: var(--fb-border-strong);
}

.fm-aff-tile--clicks::before,
.fm-aff-tile--conversion::before {
	background: var(--fb-azure);
}

.fm-aff-tile--orders::before {
	background: var(--fb-blue);
}

.fm-aff-tile--earned::before,
.fm-aff-tile--paid::before {
	background: var(--fb-blue-deep);
}

.fm-aff-tile--pending::before {
	background: var(--fb-border-strong);
}

.fm-aff-tile__label {
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--fb-ink-soft);
}

.fm-aff-tile__value {
	font-family: var(--fb-font-heading);
	font-size: clamp(24px, 2.6vw, 30px);
	font-weight: 800;
	line-height: 1.1;
	letter-spacing: -0.02em;
	color: var(--fb-ink);
	font-variant-numeric: tabular-nums;
}

.fm-aff-tile__sub {
	font-size: 12.5px;
	line-height: 1.45;
	color: var(--fb-green-soft);
}

/* =====================================================================
   Layout grid
   ===================================================================== */

.fm-aff-grid {
	display: grid;
	grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr);
	gap: var(--fm-aff-gap);
	align-items: start;
}

.fm-aff-grid__main,
.fm-aff-grid__side {
	display: flex;
	flex-direction: column;
	gap: var(--fm-aff-gap);
	min-width: 0;
}

.fm-aff-grid--account {
	grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr);
}

/* =====================================================================
   Cards + sections
   ===================================================================== */

.fm-aff-card {
	padding: 20px 22px 22px;
	border: 1px solid var(--fb-border);
	border-radius: var(--fm-aff-radius);
	background: var(--fb-surface);
}

.fm-aff-card__header {
	margin-bottom: 16px;
}

.fm-aff-card__header--split {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 14px;
}

.fm-aff-card__title {
	margin: 0;
	font-family: var(--fb-font-heading);
	font-size: 15px;
	font-weight: 700;
	letter-spacing: -0.005em;
	color: var(--fb-ink);
}

.fm-aff-card__lead {
	margin: 6px 0 0;
	font-size: 13.5px;
	line-height: 1.55;
	color: var(--fb-ink-soft);
}

.fm-aff-card__meta {
	font-size: 12px;
	font-weight: 600;
	color: var(--fb-ink-soft);
	white-space: nowrap;
}

.fm-aff-card__meta-link {
	font-size: 12.5px;
	font-weight: 600;
	color: var(--fb-azure);
	text-decoration: none;
	white-space: nowrap;
}

.fm-aff-card__meta-link:hover {
	text-decoration: underline;
}

.fm-aff-card__link {
	display: inline-block;
	margin-top: 14px;
	font-size: 13px;
	font-weight: 600;
	color: var(--fb-azure);
	text-decoration: none;
}

.fm-aff-card__link:hover {
	text-decoration: underline;
}

.fm-aff-card__empty {
	margin: 0;
	font-size: 13.5px;
	line-height: 1.6;
	color: var(--fb-ink-soft);
}

.fm-aff-card__warning {
	margin: 0 0 14px;
	font-size: 12.5px;
	line-height: 1.55;
	color: var(--fb-green-soft);
}

.fm-aff-section {
	padding: 22px 24px 24px;
	border: 1px solid var(--fb-border);
	border-radius: var(--fb-radius-lg);
	background: var(--fb-surface);
}

.fm-aff-section__header {
	margin-bottom: 18px;
}

.fm-aff-section__title {
	margin: 0;
	font-family: var(--fb-font-heading);
	font-size: 18px;
	font-weight: 700;
	letter-spacing: -0.015em;
	color: var(--fb-ink);
}

.fm-aff-section__lead {
	margin: 6px 0 0;
	max-width: 62ch;
	font-size: 14px;
	line-height: 1.6;
	color: var(--fb-ink-soft);
}

/* =====================================================================
   Chart
   ===================================================================== */

.fm-aff-chartcard__total {
	margin: 4px 0 0;
	font-family: var(--fb-font-heading);
	font-size: 26px;
	font-weight: 800;
	line-height: 1.1;
	letter-spacing: -0.02em;
	color: var(--fb-ink);
	font-variant-numeric: tabular-nums;
}

.fm-aff-chartcard__empty {
	margin: 12px 0 0;
	font-size: 13px;
	color: var(--fb-green-soft);
}

.fm-aff-chart {
	position: relative;
}

.fm-aff-chart__svg {
	display: block;
	width: 100%;
	height: auto;
	overflow: visible;
}

.fm-aff-chart__grid {
	stroke: var(--fb-border);
	stroke-width: 1;
	shape-rendering: crispEdges;
}

.fm-aff-chart__ylabel,
.fm-aff-chart__xlabel {
	fill: var(--fb-green-soft);
	font-family: var(--fb-font-body);
	font-size: 11px;
	font-variant-numeric: tabular-nums;
}

.fm-aff-chart__line {
	fill: none;
	stroke: var(--fb-azure);
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.fm-aff-chart__area {
	stroke: none;
}

.fm-aff-chart__dot {
	fill: var(--fb-azure);
	stroke: var(--fb-surface);
	stroke-width: 2;
}

.fm-aff-chart__crosshair {
	stroke: var(--fb-border-strong);
	stroke-width: 1;
	stroke-dasharray: 3 3;
}

.fm-aff-chart__focus {
	fill: var(--fb-azure);
	stroke: var(--fb-surface);
	stroke-width: 2;
}

/* The `hidden` attribute is HTML-only — SVG elements ignore it, so without this
   the crosshair and focus dot both paint at the origin before first hover. */
.fm-aff-chart__crosshair[hidden],
.fm-aff-chart__focus[hidden] {
	display: none;
}

.fm-aff-chart__hit {
	fill: transparent;
	cursor: crosshair;
}

.fm-aff-chart__tip {
	position: absolute;
	z-index: 5;
	transform: translate(-50%, -100%);
	padding: 7px 11px;
	border: 1px solid var(--fb-border-strong);
	border-radius: var(--fb-radius-sm);
	background: var(--fb-cream);
	box-shadow: var(--fb-shadow-md);
	pointer-events: none;
	white-space: nowrap;
}

.fm-aff-chart__tip-label {
	display: block;
	font-size: 11px;
	font-weight: 600;
	color: var(--fb-ink-soft);
}

.fm-aff-chart__tip-value {
	display: block;
	font-size: 15px;
	font-weight: 700;
	color: var(--fb-ink);
	font-variant-numeric: tabular-nums;
}

.fm-aff-chart__table {
	margin-top: 12px;
	font-size: 12.5px;
	color: var(--fb-ink-soft);
}

.fm-aff-chart__table summary {
	cursor: pointer;
	color: var(--fb-azure);
	font-weight: 600;
}

.fm-aff-chart__table table {
	width: 100%;
	margin-top: 10px;
	border-collapse: collapse;
}

.fm-aff-chart__table th,
.fm-aff-chart__table td {
	padding: 5px 8px;
	border-bottom: 1px solid var(--fb-border);
	text-align: left;
}

/* =====================================================================
   Bars (commission breakdown) + sources
   ===================================================================== */

.fm-aff-bars,
.fm-aff-sources {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 15px;
}

.fm-aff-bars__head,
.fm-aff-sources__head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 7px;
}

.fm-aff-bars__label,
.fm-aff-sources__name {
	font-size: 13px;
	font-weight: 500;
	color: var(--fb-ink-soft);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.fm-aff-bars__value,
.fm-aff-sources__count {
	font-size: 14px;
	font-weight: 700;
	color: var(--fb-ink);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.fm-aff-bars__track,
.fm-aff-sources__track,
.fm-aff-payout__track {
	height: 8px;
	border-radius: 999px;
	background: var(--fb-sand);
	overflow: hidden;
}

.fm-aff-bars__fill,
.fm-aff-sources__fill,
.fm-aff-payout__fill {
	display: block;
	height: 100%;
	border-radius: 999px;
	background: var(--fb-azure);
	transition: width 0.4s ease;
}

.fm-aff-bars__fill--ready {
	background: linear-gradient(90deg, var(--fb-azure) 0%, var(--fb-blue) 100%);
}

.fm-aff-bars__fill--pending {
	background: var(--fb-border-strong);
}

.fm-aff-bars__fill--paid {
	background: var(--fb-blue-deep);
}

/* =====================================================================
   Payout progress
   ===================================================================== */

.fm-aff-payout__track {
	height: 10px;
}

.fm-aff-payout__fill {
	background: linear-gradient(90deg, var(--fb-azure) 0%, var(--fb-blue-deep) 100%);
}

.fm-aff-payout__text {
	margin: 12px 0 0;
	font-size: 13.5px;
	line-height: 1.55;
	color: var(--fb-ink-soft);
}

.fm-aff-payout__warning {
	margin: 8px 0 0;
	font-size: 13px;
	color: var(--fb-danger);
}

.fm-aff-payout__warning a {
	color: var(--fb-azure);
	font-weight: 600;
}

/* =====================================================================
   Pills
   ===================================================================== */

.fm-aff-pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	border-radius: 999px;
	border: 1px solid var(--fb-border-strong);
	background: var(--fb-sand);
	font-size: 12px;
	font-weight: 600;
	line-height: 1.4;
	color: var(--fb-ink-soft);
	white-space: nowrap;
}

.fm-aff-pill__dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
	flex-shrink: 0;
}

.fm-aff-pill--approved,
.fm-aff-pill--confirmed {
	border-color: rgba(124, 192, 255, 0.45);
	background: var(--fb-accent-bg);
	color: var(--fb-azure);
}

.fm-aff-pill--paid {
	border-color: rgba(74, 222, 128, 0.4);
	background: rgba(74, 222, 128, 0.12);
	color: var(--fb-success);
}

.fm-aff-pill--pending {
	border-color: var(--fb-border-strong);
	background: var(--fb-sand);
	color: var(--fb-ink-soft);
}

.fm-aff-pill--suspended,
.fm-aff-pill--rejected,
.fm-aff-pill--cancelled {
	border-color: rgba(248, 113, 113, 0.4);
	background: rgba(248, 113, 113, 0.1);
	color: var(--fb-danger);
}

/* =====================================================================
   Tables
   ===================================================================== */

.fm-aff-table-wrap {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.fm-aff-table {
	width: 100%;
	min-width: 560px;
	border-collapse: collapse;
	font-size: 13.5px;
}

.fm-aff-table th {
	padding: 0 12px 10px;
	border-bottom: 1px solid var(--fb-border);
	text-align: left;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.07em;
	text-transform: uppercase;
	color: var(--fb-green-soft);
	white-space: nowrap;
}

.fm-aff-table td {
	padding: 13px 12px;
	border-bottom: 1px solid var(--fb-border);
	color: var(--fb-ink-soft);
	vertical-align: middle;
}

.fm-aff-table tr:last-child td {
	border-bottom: 0;
}

.fm-aff-table__num {
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.fm-aff-table__ref {
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
	font-weight: 600;
	color: var(--fb-ink);
}

.fm-aff-table__commission {
	font-weight: 700;
	color: var(--fb-ink);
}

/* =====================================================================
   Empty state
   ===================================================================== */

.fm-aff-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding: 34px 20px 30px;
	text-align: center;
}

.fm-aff-empty__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	margin-bottom: 4px;
	border-radius: 50%;
	background: var(--fb-accent-bg);
	color: var(--fb-azure);
}

.fm-aff-empty__title {
	margin: 0;
	font-family: var(--fb-font-heading);
	font-size: 16px;
	font-weight: 700;
	color: var(--fb-ink);
}

.fm-aff-empty__text {
	margin: 0 0 8px;
	max-width: 42ch;
	font-size: 13.5px;
	line-height: 1.6;
	color: var(--fb-ink-soft);
}

/* =====================================================================
   Buttons
   ===================================================================== */

.fm-aff-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: var(--fb-tap-min);
	padding: 0 22px;
	border: 1px solid transparent;
	border-radius: var(--fb-radius-sm);
	font-family: var(--fb-font-body);
	font-size: 14px;
	font-weight: 700;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	transition: filter 0.16s ease, background-color 0.16s ease, transform 0.16s ease;
}

.fm-aff-btn--primary {
	background: linear-gradient(135deg, var(--fb-blue) 0%, var(--fb-blue-deep) 100%);
	color: var(--fb-on-accent);
	box-shadow: 0 6px 18px rgba(37, 99, 235, 0.28);
}

.fm-aff-btn--primary:hover {
	filter: brightness(1.08);
	color: var(--fb-on-accent);
}

.fm-aff-btn--ghost {
	background: transparent;
	border-color: var(--fb-border-strong);
	color: var(--fb-ink);
}

.fm-aff-btn--ghost:hover {
	background: var(--fb-sand);
	color: var(--fb-ink);
}

.fm-aff-btn--block {
	width: 100%;
}

.fm-aff-btn--lg {
	min-height: 52px;
	padding: 0 30px;
	font-size: 15px;
}

.fm-aff-btn:active {
	transform: translateY(1px);
}

.fm-aff-btn:focus-visible {
	outline: none;
	box-shadow: var(--fb-focus-ring);
}

/* =====================================================================
   Forms
   ===================================================================== */

.fm-aff-form {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.fm-aff-form__row {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 16px;
}

.fm-aff-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}

/* `display: flex` outranks the user-agent `[hidden] { display: none }`, so the
   custom-path field would stay visible when the builder hides it. */
.fm-aff-field[hidden] {
	display: none;
}

.fm-aff-field__label {
	font-size: 13px;
	font-weight: 600;
	color: var(--fb-ink);
}

.fm-aff-field__input {
	width: 100%;
	min-height: var(--fb-tap-min);
	padding: 11px 13px;
	border: 1px solid var(--fb-border-strong);
	border-radius: var(--fb-radius-sm);
	background: var(--fb-sand);
	color: var(--fb-ink);
	font-family: var(--fb-font-body);
	font-size: 14px;
	line-height: 1.45;
}

.fm-aff-field__input::placeholder {
	color: var(--fb-green-soft);
}

.fm-aff-field__input:focus {
	outline: none;
	border-color: var(--fb-azure);
	box-shadow: var(--fb-focus-ring);
}

.fm-aff-field__input--area {
	min-height: 88px;
	resize: vertical;
}

.fm-aff-field__hint {
	font-size: 12px;
	line-height: 1.5;
	color: var(--fb-green-soft);
}

/* ---- Logo upload ---- */

.fm-aff-logo__row {
	display: flex;
	align-items: flex-start;
	gap: 16px;
}

.fm-aff-logo__preview {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 76px;
	height: 76px;
	border-radius: 12px;
	border: 1px dashed var(--fb-border-strong);
	background: var(--fb-cream);
	overflow: hidden;
}

.fm-aff-logo__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.fm-aff-logo__empty {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--fb-ink-soft);
	text-align: center;
	padding: 0 6px;
}

.fm-aff-logo__controls {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 9px;
}

.fm-aff-logo__pickwrap {
	position: relative;
	display: inline-flex;
}

/* The native file input is replaced by its own label, styled as a button.
   Clipped rather than display:none, so it keeps its place in the tab order. */
.fm-aff-logo__input {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.fm-aff-logo__pick {
	display: inline-flex;
	align-items: center;
	min-height: var(--fb-tap-min);
	padding: 0 18px;
	border: 1px solid var(--fb-border-strong);
	border-radius: var(--fb-radius-sm);
	background: transparent;
	color: var(--fb-ink);
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
}

.fm-aff-logo__pick:hover {
	border-color: var(--fb-blue);
	color: var(--fb-azure);
}

.fm-aff-logo__input:focus-visible + .fm-aff-logo__pick,
.fm-aff-logo__pick:focus-visible {
	outline: 2px solid var(--fb-blue);
	outline-offset: 2px;
}

.fm-aff-logo__remove {
	display: flex;
	align-items: center;
	gap: 7px;
	font-size: 13px;
	color: var(--fb-ink-soft);
	cursor: pointer;
}

@media (max-width: 560px) {
	.fm-aff-logo__row {
		flex-direction: column;
	}
	.fm-aff-logo__controls {
		width: 100%;
	}
}

.fm-aff-form__actions {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 10px;
	margin-top: 4px;
}

.fm-aff-form__note {
	margin: 0;
	font-size: 13px;
	color: var(--fb-ink-soft);
}

.fm-aff-form__note a {
	color: var(--fb-azure);
	font-weight: 600;
}

.fm-aff-code-display {
	margin: 0 0 16px;
	padding: 14px;
	border: 1px dashed var(--fb-border-strong);
	border-radius: var(--fb-radius-sm);
	background: var(--fb-cream);
	text-align: center;
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
	font-size: 22px;
	font-weight: 700;
	letter-spacing: 0.12em;
	color: var(--fb-azure);
	word-break: break-all;
}

.fm-aff-meta {
	margin: 0 0 16px;
	display: flex;
	flex-direction: column;
	gap: 11px;
}

.fm-aff-meta__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.fm-aff-meta__row dt {
	font-size: 13px;
	color: var(--fb-ink-soft);
}

.fm-aff-meta__row dd {
	margin: 0;
	font-size: 13.5px;
	font-weight: 600;
	color: var(--fb-ink);
	text-align: right;
	word-break: break-word;
}

/* =====================================================================
   Link builder
   ===================================================================== */

.fm-aff-builder {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 20px;
}

.fm-aff-builder__controls {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 16px;
}

.fm-aff-field--custom {
	grid-column: 1 / -1;
}

.fm-aff-builder__output {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 176px;
	gap: 20px;
	/* The QR block is the taller of the two, so centre the link column against it
	   rather than leaving a block of dead space beneath the copy row. */
	align-items: center;
	padding: 18px;
	border: 1px solid var(--fb-border-strong);
	border-radius: var(--fm-aff-radius);
	background: var(--fb-cream);
}

.fm-aff-builder__link {
	display: flex;
	flex-direction: column;
	gap: 10px;
	min-width: 0;
}

.fm-aff-builder__link-hint {
	margin: 0;
	font-size: 12.5px;
	line-height: 1.55;
	color: var(--fb-green-soft);
}

.fm-aff-builder__qr {
	text-align: center;
}

.fm-aff-qr {
	width: 136px;
	height: 136px;
	margin: 0 auto;
	padding: 8px;
	border-radius: var(--fb-radius-sm);
	background: var(--fb-white);
}

.fm-aff-qr svg {
	display: block;
	width: 100%;
	height: 100%;
}

.fm-aff-builder__qr-hint {
	margin: 9px 0 0;
	font-size: 11.5px;
	line-height: 1.45;
	color: var(--fb-green-soft);
}

/* ---- Presets ---- */

.fm-aff-presets {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 14px;
}

.fm-aff-preset {
	padding: 14px 16px 16px;
	border: 1px solid var(--fb-border);
	border-radius: var(--fm-aff-radius);
	background: var(--fb-cream);
}

.fm-aff-preset__label {
	display: block;
	margin-bottom: 9px;
	font-size: 13px;
	font-weight: 700;
	color: var(--fb-ink);
}

/* ---- Facts ---- */

.fm-aff-facts {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 16px;
}

.fm-aff-fact {
	padding: 16px 18px 18px;
	border: 1px solid var(--fb-border);
	border-radius: var(--fm-aff-radius);
	background: var(--fb-cream);
}

.fm-aff-fact__title {
	margin: 0 0 6px;
	font-family: var(--fb-font-heading);
	font-size: 14px;
	font-weight: 700;
	color: var(--fb-ink);
}

.fm-aff-fact__body {
	margin: 0;
	font-size: 13px;
	line-height: 1.6;
	color: var(--fb-ink-soft);
}

/* =====================================================================
   Gate panel
   ===================================================================== */

.fm-aff-gate {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 60vh;
	padding: 48px 20px;
	background: var(--fb-cream);
}

.fm-aff-gate__card {
	width: 100%;
	max-width: 480px;
	padding: 34px 32px 32px;
	border: 1px solid var(--fb-border);
	border-radius: var(--fb-radius-lg);
	background: var(--fb-surface);
	box-shadow: var(--fb-shadow-md);
	text-align: center;
}

.fm-aff-gate__mark {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	margin-bottom: 16px;
	border-radius: 16px;
	background: linear-gradient(135deg, var(--fb-blue) 0%, var(--fb-blue-deep) 100%);
	color: var(--fb-on-accent);
	box-shadow: 0 8px 22px rgba(37, 99, 235, 0.3);
}

.fm-aff-gate__title {
	margin: 0 0 10px;
	font-family: var(--fb-font-heading);
	font-size: 22px;
	font-weight: 800;
	letter-spacing: -0.02em;
	color: var(--fb-ink);
}

.fm-aff-gate__message {
	margin: 0 0 22px;
	font-size: 14.5px;
	line-height: 1.6;
	color: var(--fb-ink-soft);
}

.fm-aff-gate__actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 10px;
}

/* =====================================================================
   Public join page
   ===================================================================== */

.fm-aff-public {
	max-width: var(--fb-container);
	margin: 0 auto;
	padding: 8px 20px 64px;
	display: flex;
	flex-direction: column;
	gap: 40px;
}

.fm-aff-public__hero {
	padding: 52px 40px 46px;
	border: 1px solid var(--fb-border);
	border-radius: var(--fb-radius-lg);
	background:
		radial-gradient(110% 150% at 85% 0%, rgba(59, 130, 246, 0.22) 0%, rgba(59, 130, 246, 0) 60%),
		var(--fb-surface);
	text-align: center;
}

.fm-aff-public__eyebrow {
	display: inline-block;
	margin-bottom: 14px;
	padding: 5px 14px;
	border: 1px solid rgba(124, 192, 255, 0.4);
	border-radius: 999px;
	background: var(--fb-accent-bg);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--fb-azure);
}

.fm-aff-public__title {
	margin: 0 0 16px;
	font-family: var(--fb-font-heading);
	font-size: clamp(30px, 5vw, 52px);
	font-weight: 800;
	line-height: 1.05;
	letter-spacing: -0.03em;
	color: var(--fb-ink);
}

.fm-aff-public__lead {
	max-width: 60ch;
	margin: 0 auto;
	font-size: clamp(15px, 1.6vw, 18px);
	line-height: 1.6;
	color: var(--fb-ink-soft);
}

.fm-aff-public__lead strong {
	color: var(--fb-azure);
	font-weight: 700;
}

.fm-aff-public__stats {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 14px;
	margin-top: 32px;
}

.fm-aff-public__stat {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 132px;
	padding: 16px 22px;
	border: 1px solid var(--fb-border-strong);
	border-radius: var(--fm-aff-radius);
	background: var(--fb-cream);
}

.fm-aff-public__stat-value {
	font-family: var(--fb-font-heading);
	font-size: 26px;
	font-weight: 800;
	line-height: 1.1;
	color: var(--fb-ink);
}

.fm-aff-public__stat-label {
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--fb-ink-soft);
}

.fm-aff-public__section-title {
	margin: 0 0 22px;
	font-family: var(--fb-font-heading);
	font-size: clamp(22px, 2.6vw, 28px);
	font-weight: 800;
	letter-spacing: -0.02em;
	color: var(--fb-ink);
	text-align: center;
}

.fm-aff-steps {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
	gap: 18px;
	counter-reset: fm-aff-step;
}

.fm-aff-step {
	padding: 24px 24px 26px;
	border: 1px solid var(--fb-border);
	border-radius: var(--fm-aff-radius);
	background: var(--fb-surface);
}

.fm-aff-step__num {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	margin-bottom: 14px;
	border-radius: 10px;
	background: var(--fb-accent-bg);
	color: var(--fb-azure);
	font-family: var(--fb-font-heading);
	font-size: 15px;
	font-weight: 800;
}

.fm-aff-step__title {
	margin: 0 0 7px;
	font-family: var(--fb-font-heading);
	font-size: 16px;
	font-weight: 700;
	color: var(--fb-ink);
}

.fm-aff-step__body {
	margin: 0;
	font-size: 14px;
	line-height: 1.6;
	color: var(--fb-ink-soft);
}

.fm-aff-public__form-section {
	display: flex;
	justify-content: center;
}

.fm-aff-card--form {
	width: 100%;
	max-width: 720px;
	padding: 32px 34px 34px;
	border-radius: var(--fb-radius-lg);
	display: flex;
	flex-direction: column;
	gap: 18px;
}

.fm-aff-card--form .fm-aff-card__header {
	margin-bottom: 0;
}

/* =====================================================================
   Responsive — 1024px
   ===================================================================== */

@media ( max-width: 1180px ) {
	.fm-aff-hero {
		grid-template-columns: minmax(0, 1fr);
	}

	.fm-aff-grid,
	.fm-aff-grid--account {
		grid-template-columns: minmax(0, 1fr);
	}
}

@media ( max-width: 1024px ) {
	.fm-aff-tiles {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.fm-aff-main {
		padding: 22px 20px 48px;
	}

	.fm-aff-builder__output {
		grid-template-columns: minmax(0, 1fr);
	}

	.fm-aff-builder__qr {
		justify-self: center;
	}
}

/* =====================================================================
   Responsive — drawer below 900px
   ===================================================================== */

@media ( max-width: 899px ) {
	.fm-aff-shell {
		flex-direction: column;
		overflow-x: hidden;
	}

	.fm-aff-sidebar {
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		height: 100%;
		width: 268px;
		max-width: 84vw;
		transform: translateX(-100%);
		transition: transform 0.24s ease;
		border-right: 1px solid var(--fb-border-strong);
		box-shadow: none;
	}

	.fm-aff-sidebar--open {
		transform: translateX(0);
		box-shadow: var(--fb-shadow-strong);
	}

	.fm-aff-sidebar__close {
		display: block;
	}

	.fm-aff-topbar__toggle {
		display: inline-flex;
	}

	.fm-aff-topbar {
		padding: 10px 16px;
	}

	.fm-aff-topbar__logout {
		display: none;
	}
}

/* =====================================================================
   Responsive — 768px
   ===================================================================== */

@media ( max-width: 768px ) {
	.fm-aff-hero {
		padding: 22px 20px;
	}

	.fm-aff-section {
		padding: 20px 18px 22px;
	}

	.fm-aff-card {
		padding: 18px 18px 20px;
	}

	.fm-aff-builder__controls,
	.fm-aff-form__row {
		grid-template-columns: minmax(0, 1fr);
	}

	.fm-aff-public__hero {
		padding: 38px 22px 34px;
	}

	.fm-aff-card--form {
		padding: 24px 20px 26px;
	}

	/* Proportional scaling makes axis text too small to read down here — the
	   card total, the tooltip, and the table view carry the numbers instead. */
	.fm-aff-chart__ylabel,
	.fm-aff-chart__xlabel {
		display: none;
	}
}

/* =====================================================================
   Responsive — 375px
   ===================================================================== */

@media ( max-width: 480px ) {
	.fm-aff-tiles {
		grid-template-columns: minmax(0, 1fr);
	}

	.fm-aff-main {
		padding: 18px 14px 44px;
	}

	.fm-aff-topbar__title {
		font-size: 16px;
	}

	.fm-aff-code-chip__label {
		display: none;
	}

	.fm-aff-copy {
		flex-direction: column;
	}

	.fm-aff-copy__btn {
		width: 100%;
	}

	.fm-aff-public {
		padding: 8px 14px 48px;
		gap: 30px;
	}

	.fm-aff-public__stat {
		flex: 1 1 100%;
	}

	.fm-aff-gate__card {
		padding: 26px 20px 24px;
	}

	.fm-aff-gate__actions .fm-aff-btn {
		width: 100%;
	}
}

/* =====================================================================
   Motion preference
   ===================================================================== */

@media ( prefers-reduced-motion: reduce ) {
	.fm-aff-sidebar,
	.fm-aff-bars__fill,
	.fm-aff-sources__fill,
	.fm-aff-payout__fill,
	.fm-aff-nav__link,
	.fm-aff-btn,
	.fm-aff-copy__btn {
		transition: none;
	}
}
