/* ==========================================================================
   AfJARE front-end dashboard  —  [afjare_dashboard]
   Everything is scoped under .afjare-fe so it cannot leak into the theme.
   Layout responds to the width of its own column (container queries), so it
   works in a full-width page and in a narrow sidebar-style column alike.
   ========================================================================== */

.afjare-fe {
	--afj-ink: #14213d;
	--afj-muted: #5a6578;
	--afj-line: #e3e8ef;
	--afj-surface: #f4f6fa;
	--afj-card: #fff;
	--afj-navy: #12315a;
	--afj-blue: #1d4f91;
	--afj-green: #2e9e5b;
	--afj-orange: #c9622a;
	--afj-purple: #6b4fa3;
	--afj-teal: #0f7c86;
	--afj-radius: 16px;
	--afj-shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 6px 20px rgba(20, 33, 61, .05);

	container-type: inline-size;
	scroll-margin-top: 80px;
	display: flex;
	flex-direction: column;
	gap: 16px;
	box-sizing: border-box;
	width: 100%;
	max-width: 1200px;
	margin: 0 auto;
	font-family: inherit;
	font-size: 16px;
	line-height: 1.5;
	color: var(--afj-ink);
	-webkit-text-size-adjust: 100%;
}

.afjare-fe *,
.afjare-fe *::before,
.afjare-fe *::after {
	box-sizing: border-box;
}

.afjare-fe h2,
.afjare-fe h3,
.afjare-fe p,
.afjare-fe ol,
.afjare-fe ul {
	margin: 0;
	padding: 0;
	font-family: inherit;
	text-transform: none;
	letter-spacing: normal;
}

.afjare-fe ol,
.afjare-fe ul { list-style: none; }

.afjare-fe .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.afjare-fe .afj-icon {
	width: 20px;
	height: 20px;
	flex: none;
}

/* ---------- Buttons ------------------------------------------------------ */

.afjare-fe .afj-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 44px;
	padding: 0 18px;
	border: 1px solid transparent;
	border-radius: 10px;
	font: inherit;
	font-size: 15px;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	transition: background-color .15s, border-color .15s, color .15s;
}

.afjare-fe .afj-btn--primary {
	background: var(--afj-blue);
	color: #fff;
}
.afjare-fe .afj-btn--primary:hover { background: var(--afj-navy); color: #fff; }

.afjare-fe .afj-btn--ghost {
	background: rgba(255, 255, 255, .12);
	border-color: rgba(255, 255, 255, .35);
	color: #fff;
}
.afjare-fe .afj-btn--ghost:hover { background: rgba(255, 255, 255, .22); color: #fff; }

.afjare-fe .afj-btn:focus-visible,
.afjare-fe .afj-legend__item:focus-visible,
.afjare-fe .afj-more summary:focus-visible,
.afjare-fe select:focus-visible,
.afjare-fe input:focus-visible {
	outline: 3px solid #f2b705;
	outline-offset: 2px;
}

/* ---------- Hero --------------------------------------------------------- */

.afjare-fe .afj-hero {
	position: relative;
	overflow: hidden;
	padding: 20px;
	border-radius: var(--afj-radius);
	background: linear-gradient(135deg, var(--afj-navy) 0%, var(--afj-blue) 100%);
	color: #fff;
	-webkit-print-color-adjust: exact;
	print-color-adjust: exact;
}

.afjare-fe .afj-hero::before,
.afjare-fe .afj-hero::after {
	content: "";
	position: absolute;
	border-radius: 50%;
	pointer-events: none;
	background: rgba(255, 255, 255, .06);
}
.afjare-fe .afj-hero::before { width: 260px; height: 260px; right: -70px; top: -110px; }
.afjare-fe .afj-hero::after  { width: 160px; height: 160px; right: 120px; bottom: -100px; }

.afjare-fe .afj-hero__top {
	position: relative;
	z-index: 1;
	display: flex;
	flex-wrap: nowrap;
	align-items: flex-start;
	justify-content: space-between;
	gap: 14px;
	margin-bottom: 18px;
}
.afjare-fe .afj-hero__top:last-child { margin-bottom: 0; }
.afjare-fe .afj-hero__text { flex: 1 1 auto; min-width: 0; }
.afjare-fe .afj-hero__actions { flex: none; display: flex; gap: 8px; }
.afjare-fe .afj-lock { margin: 0; }

.afjare-fe .afj-eyebrow {
	font-size: 11.5px;
	font-weight: 600;
	letter-spacing: .08em !important;
	text-transform: uppercase !important;
	opacity: .78;
}

.afjare-fe .afj-hero .afj-title {
	margin: 4px 0 12px;
	font-size: 1.6rem;
	font-size: clamp(1.45rem, 1.05rem + 1.8cqi, 2.15rem);
	font-weight: 700;
	line-height: 1.18;
	color: #fff;
	border: 0;
	padding: 0;
}

.afjare-fe .afj-range {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 14.5px;
	color: rgba(255, 255, 255, .92);
}
.afjare-fe .afj-range .afj-icon { opacity: .85; }
.afjare-fe .afj-range strong { font-weight: 700; margin-right: 8px; }
.afjare-fe .afj-range__dates { opacity: .85; white-space: nowrap; }


/* ---------- Year / month / custom range ---------------------------------- */

.afjare-fe .afj-more {
	background: var(--afj-card);
	border: 1px solid var(--afj-line);
	border-radius: 12px;
}

.afjare-fe .afj-more summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 48px;
	padding: 10px 16px;
	font-size: 14.5px;
	font-weight: 600;
	color: var(--afj-ink);
	cursor: pointer;
	list-style: none;
	border-radius: 12px;
}
.afjare-fe .afj-more summary::-webkit-details-marker { display: none; }

.afjare-fe .afj-chev {
	flex: none;
	width: 9px;
	height: 9px;
	margin-right: 4px;
	border-right: 2px solid var(--afj-muted);
	border-bottom: 2px solid var(--afj-muted);
	transform: rotate(45deg) translateY(-2px);
	transition: transform .2s;
}
.afjare-fe .afj-more[open] .afj-chev { transform: rotate(-135deg); }

.afjare-fe .afj-more__body {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr));
	gap: 20px 28px;
	padding: 6px 16px 18px;
	border-top: 1px solid var(--afj-line);
	padding-top: 16px;
}

.afjare-fe .afj-form fieldset {
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}
.afjare-fe .afj-form legend {
	padding: 0;
	margin-bottom: 8px;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--afj-muted);
}

.afjare-fe .afj-form__row {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 10px;
}
.afjare-fe .afj-form__row label { display: block; flex: 1 1 120px; min-width: 0; }
.afjare-fe .afj-form__row .afj-btn { flex: 0 0 auto; }

.afjare-fe .afj-label {
	display: block;
	margin-bottom: 4px;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--afj-muted);
}

.afjare-fe .afj-form select,
.afjare-fe .afj-form input[type="date"] {
	display: block;
	width: 100%;
	height: 44px;
	margin: 0;
	padding: 0 12px;
	border: 1px solid #c9d1dd;
	border-radius: 10px;
	background-color: #fff;
	color: var(--afj-ink);
	font: inherit;
	font-size: 16px; /* 16px stops iOS zooming into the field */
	box-shadow: none;
}

/* ---------- Notices ------------------------------------------------------ */

.afjare-fe .afj-notice {
	padding: 12px 16px;
	border: 1px solid #f2d58a;
	border-radius: 12px;
	background: #fff8e6;
	font-size: 14px;
	color: #5c4400;
}
.afjare-fe .afj-notice a { color: inherit; font-weight: 700; }

/* ---------- KPI cards ---------------------------------------------------- */

.afjare-fe .afj-kpis {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
}
.afjare-fe .afj-kpi:last-child { grid-column: 1 / -1; }

.afjare-fe .afj-kpi {
	--accent: var(--afj-blue);
	--accent-bg: #e8f0fb;
	position: relative;
	padding: 16px 16px 14px;
	background: var(--afj-card);
	border: 1px solid var(--afj-line);
	border-top: 3px solid var(--accent);
	border-radius: 14px;
	box-shadow: var(--afj-shadow);
	min-width: 0;
}
.afjare-fe .afj-kpi--published { --accent: var(--afj-purple); --accent-bg: #efeaf8; }
.afjare-fe .afj-kpi--views     { --accent: var(--afj-green);  --accent-bg: #e4f5ec; }
.afjare-fe .afj-kpi--downloads { --accent: var(--afj-orange); --accent-bg: #fbece3; }
.afjare-fe .afj-kpi--avg       { --accent: var(--afj-teal);   --accent-bg: #e2f2f3; }

.afjare-fe .afj-kpi__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border-radius: 11px;
	background: var(--accent-bg);
	color: var(--accent);
}

.afjare-fe .afj-kpi__value {
	margin-top: 12px;
	font-size: 1.75rem;
	font-weight: 700;
	line-height: 1.1;
	color: var(--afj-ink);
	font-variant-numeric: tabular-nums;
	overflow-wrap: anywhere;
}

.afjare-fe .afj-kpi__label {
	margin-top: 4px;
	font-size: 13px;
	line-height: 1.35;
	color: var(--afj-muted);
}

.afjare-fe .afj-delta {
	position: absolute;
	top: 14px;
	right: 12px;
	display: inline-flex;
	align-items: center;
	gap: 2px;
	padding: 3px 8px 3px 5px;
	border-radius: 999px;
	font-size: 12.5px;
	font-weight: 700;
	line-height: 1.2;
	font-variant-numeric: tabular-nums;
	background: #eef1f5;
	color: #3f4a5c;
}
.afjare-fe .afj-delta--new,
.afjare-fe .afj-delta--flat { padding-left: 9px; }
.afjare-fe .afj-delta .afj-icon { width: 15px; height: 15px; stroke-width: 2.6; }
.afjare-fe .afj-delta--up   { background: #e3f5ea; color: #14683a; }
.afjare-fe .afj-delta--down { background: #fdeceb; color: #a8231a; }

.afjare-fe .afj-caption {
	margin-top: -6px;
	font-size: 12.5px;
	color: var(--afj-muted);
}

/* ---------- Cards -------------------------------------------------------- */

.afjare-fe .afj-card {
	padding: 18px;
	background: var(--afj-card);
	border: 1px solid var(--afj-line);
	border-radius: var(--afj-radius);
	box-shadow: var(--afj-shadow);
	min-width: 0;
}

.afjare-fe .afj-card__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 12px;
	margin-bottom: 12px;
}

.afjare-fe .afj-card h3 {
	font-size: 1.05rem;
	font-weight: 700;
	line-height: 1.3;
	color: var(--afj-ink);
	border: 0;
	padding: 0;
}

.afjare-fe .afj-tag {
	padding: 3px 10px;
	border-radius: 999px;
	background: var(--afj-surface);
	font-size: 12px;
	font-weight: 600;
	color: var(--afj-muted);
	white-space: nowrap;
}

.afjare-fe .afj-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
	gap: 16px;
}

.afjare-fe .afj-empty {
	padding: 26px 16px;
	border-radius: 12px;
	background: var(--afj-surface);
	text-align: center;
	font-size: 14px;
	color: var(--afj-muted);
}

.afjare-fe .afj-footnote {
	margin-top: 14px;
	font-size: 12.5px;
	color: var(--afj-muted);
}

/* ---------- Chart -------------------------------------------------------- */

.afjare-fe .afj-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 10px;
}

.afjare-fe .afj-legend__item {
	--dot: var(--afj-blue);
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 36px;
	padding: 0 14px 0 12px;
	border: 1px solid var(--afj-line);
	border-radius: 999px;
	background: #fff;
	font: inherit;
	font-size: 13.5px;
	font-weight: 600;
	color: var(--afj-ink);
	cursor: pointer;
	transition: opacity .15s, background-color .15s;
}
.afjare-fe .afj-legend__item:hover { background: var(--afj-surface); }
.afjare-fe .afj-legend__item--views       { --dot: var(--afj-green); }
.afjare-fe .afj-legend__item--downloads   { --dot: var(--afj-orange); }
.afjare-fe .afj-legend__item--submissions { --dot: var(--afj-blue); }

.afjare-fe .afj-legend__dot {
	width: 11px;
	height: 11px;
	border-radius: 50%;
	background: var(--dot);
	border: 2px solid var(--dot);
}
.afjare-fe .afj-legend__item[aria-pressed="false"] { opacity: .55; }
.afjare-fe .afj-legend__item[aria-pressed="false"] .afj-legend__dot { background: transparent; }

.afjare-fe .afj-chart {
	position: relative;
	height: 260px;
	height: clamp(250px, 36cqi, 380px);
}
.afjare-fe .afj-chart canvas { display: block; max-width: 100%; }

/* ---------- Ranked lists ------------------------------------------------- */

.afjare-fe .afj-rank-item {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 11px 0;
	border-bottom: 1px solid var(--afj-line);
}
.afjare-fe .afj-rank-item:first-child { padding-top: 2px; }
.afjare-fe .afj-rank-item:last-child  { padding-bottom: 0; border-bottom: 0; }

.afjare-fe .afj-rank-no {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	margin-top: 1px;
	border-radius: 50%;
	background: #eaf0f9;
	color: var(--afj-blue);
	font-size: 13px;
	font-weight: 700;
}
.afjare-fe .afj-rank-item:first-child .afj-rank-no { background: var(--afj-blue); color: #fff; }

.afjare-fe .afj-rank-body { flex: 1; min-width: 0; }

.afjare-fe .afj-rank-line {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 14px;
}

.afjare-fe .afj-rank-title {
	min-width: 0;
	font-size: 14.5px;
	font-weight: 600;
	line-height: 1.4;
	color: var(--afj-ink);
	text-decoration: none;
	overflow-wrap: anywhere;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	box-shadow: none;
}
.afjare-fe a.afj-rank-title:hover { color: var(--afj-blue); text-decoration: underline; }

.afjare-fe .afj-rank-val {
	flex: none;
	font-size: 15px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	color: var(--afj-ink);
}

.afjare-fe .afj-bar {
	height: 6px;
	margin-top: 8px;
	border-radius: 999px;
	background: var(--afj-surface);
	overflow: hidden;
	-webkit-print-color-adjust: exact;
	print-color-adjust: exact;
}
.afjare-fe .afj-bar > span {
	display: block;
	height: 100%;
	min-width: 4px;
	border-radius: 999px;
	background: var(--afj-blue);
}
.afjare-fe .afj-card--dl .afj-rank-no { background: #fbece3; color: #a24a1a; }
.afjare-fe .afj-card--dl .afj-rank-item:first-child .afj-rank-no { background: var(--afj-orange); color: #fff; }
.afjare-fe .afj-card--dl .afj-bar > span { background: var(--afj-orange); }
.afjare-fe .afj-card--vw .afj-rank-no { background: #e4f5ec; color: #1e7a45; }
.afjare-fe .afj-card--vw .afj-rank-item:first-child .afj-rank-no { background: var(--afj-green); color: #fff; }
.afjare-fe .afj-card--vw .afj-bar > span { background: var(--afj-green); }
.afjare-fe .afj-bar--alt > span { background: var(--afj-purple); }

/* Category list flows into columns when there is room. */
.afjare-fe .afj-cat-list {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
	gap: 16px 40px;
}

/* ---------- Submissions table ------------------------------------------- */

.afjare-fe .afj-table-wrap { overflow-x: auto; }

.afjare-fe .afj-table {
	width: 100%;
	margin: 0;
	border-collapse: collapse;
	border: 0;
	font-size: 14.5px;
}
.afjare-fe .afj-table th,
.afjare-fe .afj-table td {
	padding: 12px 12px;
	border: 0;
	border-bottom: 1px solid var(--afj-line);
	text-align: left;
	vertical-align: top;
	background: transparent;
}
.afjare-fe .afj-table thead th {
	padding-top: 6px;
	font-size: 11.5px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--afj-muted);
	border-bottom: 2px solid var(--afj-line);
}
.afjare-fe .afj-table tbody tr:last-child td { border-bottom: 0; }
.afjare-fe .afj-table tbody tr:hover td { background: #f8faff; }
.afjare-fe .afj-table td:first-child { white-space: nowrap; color: var(--afj-muted); }
.afjare-fe .afj-table__title { font-weight: 600; }

/* ---------- Footer ------------------------------------------------------- */

.afjare-fe .afj-foot {
	padding: 2px 4px 0;
	font-size: 12.5px;
	line-height: 1.5;
	color: var(--afj-muted);
}

/* Password form */
.afjare-fe .afj-gate__form { margin-top: 18px; text-align: left; display: grid; gap: 12px; }
.afjare-fe .afj-gate__form .afj-btn { width: 100%; }
.afjare-fe .afj-gate__form input[type="password"] {
	display: block; width: 100%; height: 48px; margin: 0; padding: 0 14px;
	border: 1px solid #c9d1dd; border-radius: 10px; background: #fff;
	color: var(--afj-ink); font: inherit; font-size: 16px; box-shadow: none;
}
.afjare-fe .afj-error {
	padding: 10px 14px; border-radius: 10px; background: #fdeceb; color: #a8231a;
	font-size: 14px; font-weight: 600;
}

/* ---------- Access gate -------------------------------------------------- */

.afjare-fe.afj-gate { align-items: center; }
.afjare-fe .afj-gate__card {
	width: 100%;
	max-width: 520px;
	padding: 36px 24px;
	background: var(--afj-card);
	border: 1px solid var(--afj-line);
	border-radius: var(--afj-radius);
	box-shadow: var(--afj-shadow);
	text-align: center;
}
.afjare-fe .afj-gate__card > * + * { margin-top: 12px; }
.afjare-fe .afj-gate__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: #e8f0fb;
	color: var(--afj-blue);
}
.afjare-fe .afj-gate__icon .afj-icon { width: 26px; height: 26px; }
.afjare-fe .afj-gate__title { font-size: 1.2rem; font-weight: 700; line-height: 1.3; }
.afjare-fe .afj-gate__card p { color: var(--afj-muted); font-size: 15px; }

/* ==========================================================================
   Wider columns
   ========================================================================== */

@container (min-width: 560px) {
	.afjare-fe .afj-hero { padding: 26px 28px; }

	.afjare-fe .afj-card { padding: 22px; }

	/* 3 + 2 layout: no orphan card in the second row. */
	.afjare-fe .afj-kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
	.afjare-fe .afj-kpi,
	.afjare-fe .afj-kpi:last-child { grid-column: span 2; }
	.afjare-fe .afj-kpi:nth-child(n+4) { grid-column: span 3; }
	.afjare-fe .afj-kpi__value { font-size: 1.95rem; }
}

@container (min-width: 920px) {
	.afjare-fe .afj-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
	.afjare-fe .afj-kpi,
	.afjare-fe .afj-kpi:last-child,
	.afjare-fe .afj-kpi:nth-child(n+4) { grid-column: span 1; }
	.afjare-fe .afj-kpi__value { font-size: 2rem; }
}

/* ==========================================================================
   Narrow columns: submissions become stacked cards
   ========================================================================== */

@container (max-width: 559px) {
	.afjare-fe .afj-table thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0, 0, 0, 0);
	}
	.afjare-fe .afj-table,
	.afjare-fe .afj-table tbody,
	.afjare-fe .afj-table tr,
	.afjare-fe .afj-table td { display: block; width: 100%; }

	.afjare-fe .afj-table tr {
		margin-bottom: 10px;
		padding: 4px 0;
		border: 1px solid var(--afj-line);
		border-radius: 12px;
		background: var(--afj-surface);
	}
	.afjare-fe .afj-table tbody tr:last-child { margin-bottom: 0; }
	.afjare-fe .afj-table tbody tr:hover td { background: transparent; }

	.afjare-fe .afj-table td {
		display: flex;
		gap: 12px;
		padding: 7px 14px;
		border: 0 !important;
		white-space: normal !important;
		color: var(--afj-ink) !important;
	}
	.afjare-fe .afj-table td::before {
		content: attr(data-label);
		flex: 0 0 84px;
		font-size: 11.5px;
		font-weight: 700;
		letter-spacing: .05em;
		text-transform: uppercase;
		color: var(--afj-muted);
		padding-top: 2px;
	}
}

@container (max-width: 380px) {
	.afjare-fe .afj-hero__actions .afj-btn span { display: none; }
	.afjare-fe .afj-hero__actions .afj-btn { padding: 0 12px; }
	.afjare-fe .afj-kpi__value { font-size: 1.5rem; }
	.afjare-fe .afj-delta { position: static; margin-top: 8px; }
}

/* ==========================================================================
   Motion + print
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
	.afjare-fe * { transition: none !important; }
}

@media print {
	.afjare-fe { max-width: none; gap: 12px; }
	.afjare-fe .afj-more,
	.afjare-fe .afj-print,
	.afjare-fe .afj-lock,
	.afjare-fe .afj-legend,
	.afjare-fe .afj-notice { display: none !important; }
	.afjare-fe .afj-hero { padding: 18px 22px; }
	.afjare-fe .afj-hero::before,
	.afjare-fe .afj-hero::after { display: none; }
	.afjare-fe .afj-card,
	.afjare-fe .afj-kpi { box-shadow: none; break-inside: avoid; page-break-inside: avoid; }
	.afjare-fe .afj-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
	.afjare-fe .afj-kpi,
	.afjare-fe .afj-kpi:last-child,
	.afjare-fe .afj-kpi:nth-child(n+4) { grid-column: span 1; padding: 12px; }
	.afjare-fe .afj-kpi__value { font-size: 1.4rem; }
	.afjare-fe .afj-kpi__icon { display: none; }
	.afjare-fe .afj-delta { position: static; margin-top: 6px; }
	.afjare-fe .afj-rank-title { -webkit-line-clamp: unset; display: block; }
}

/* In-place filtering: dim the dashboard while new figures load. */
.afjare-fe.is-loading {
	opacity: .55;
	transition: opacity .15s;
	pointer-events: none;
	cursor: progress;
}
