.taxfilter-wrapper {
	margin: 1.5rem 0;
	font-family: inherit;
	--taxfilter-primary: #111;
	--taxfilter-btn-radius: 999px;
	--taxfilter-bg: #f4f4f5;
	--taxfilter-bg-hover: #e8e8ea;
	--taxfilter-border: transparent;
	--taxfilter-text: #18181b;
	--taxfilter-text-muted: #71717a;
}

/* ---------- Filter chips ---------- */
.taxfilter-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.taxfilter-align-center .taxfilter-filters { justify-content: center; }
.taxfilter-align-right  .taxfilter-filters { justify-content: flex-end; }

.taxfilter-btn {
	background: var(--taxfilter-bg);
	border: 1px solid var(--taxfilter-border);
	color: var(--taxfilter-text);
	padding: 0.55rem 1.1rem;
	cursor: pointer;
	border-radius: var(--taxfilter-btn-radius);
	font-size: 0.9rem;
	font-weight: 500;
	line-height: 1.2;
	letter-spacing: -0.01em;
	transition: background .18s ease, color .18s ease, transform .1s ease, box-shadow .18s ease;
	font-family: inherit;
}
.taxfilter-btn:hover  { background: var(--taxfilter-bg-hover); }
.taxfilter-btn:active { transform: scale(0.97); }
.taxfilter-btn.is-active {
	background: var(--taxfilter-primary);
	color: #fff;
	box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.taxfilter-btn:focus-visible {
	outline: 2px solid var(--taxfilter-primary);
	outline-offset: 2px;
}

.taxfilter-count {
	opacity: .6;
	margin-left: .3rem;
	font-size: .8em;
	font-weight: 400;
}

/* ---------- Trigger (mobile only) ---------- */
.taxfilter-trigger {
	display: none;
	align-items: center;
	gap: 0.5rem;
	background: #fff;
	border: 1px solid #e4e4e7;
	color: var(--taxfilter-text);
	padding: 0.7rem 1.2rem;
	border-radius: var(--taxfilter-btn-radius);
	font-size: 0.95rem;
	font-weight: 500;
	cursor: pointer;
	box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
	font-family: inherit;
	transition: background .18s ease, box-shadow .18s ease, transform .1s ease;
}
.taxfilter-trigger:hover  { background: #fafafa; box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.taxfilter-trigger:active { transform: scale(0.97); }
.taxfilter-trigger-icon   { flex-shrink: 0; }

.taxfilter-trigger-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.4rem;
	height: 1.4rem;
	padding: 0 0.4rem;
	background: var(--taxfilter-primary);
	color: #fff;
	border-radius: 999px;
	font-size: 0.75rem;
	font-weight: 600;
	margin-left: 0.2rem;
}

/* ---------- Modal (off by default on desktop) ---------- */
.taxfilter-modal                 { display: block; }
.taxfilter-modal-backdrop,
.taxfilter-modal-header,
.taxfilter-modal-footer,
.taxfilter-modal-close           { display: none; }
.taxfilter-modal-panel           { all: unset; display: block; }
.taxfilter-modal-body            { display: block; }

/* ---------- Empty state ---------- */
.taxfilter-empty {
	margin-top: 1.25rem;
	padding: 1.25rem 1.5rem;
	background: #fafafa;
	border: 1px dashed #e4e4e7;
	border-radius: 12px;
	color: var(--taxfilter-text-muted);
	text-align: center;
	font-size: 0.95rem;
}

.taxfilter-hidden { display: none !important; }

/* ---------- Mobile: activate modal ---------- */
@media (max-width: 767px) {
	.taxfilter-trigger { display: inline-flex; }

	/* align trigger button per align setting */
	.taxfilter-align-center .taxfilter-trigger { margin: 0 auto; }
	.taxfilter-align-right  .taxfilter-trigger { margin-left: auto; }
	.taxfilter-wrapper[class*="taxfilter-align-"] {
		display: flex;
		flex-direction: column;
	}

	.taxfilter-modal {
		position: fixed;
		inset: 0;
		z-index: 999999;
		display: none;
		align-items: flex-end;
		justify-content: center;
	}
	.taxfilter-modal.is-open { display: flex; }

	.taxfilter-modal-backdrop {
		display: block;
		position: absolute;
		inset: 0;
		background: rgba(15, 15, 20, 0.45);
		backdrop-filter: blur(10px) saturate(140%);
		-webkit-backdrop-filter: blur(10px) saturate(140%);
		animation: taxfilter-fade-in .25s ease forwards;
	}

	.taxfilter-modal-panel {
		all: unset;
		position: relative;
		display: flex;
		flex-direction: column;
		width: 100%;
		max-width: 560px;
		max-height: 85vh;
		background: #fff;
		border-top-left-radius: 20px;
		border-top-right-radius: 20px;
		box-shadow: 0 -10px 40px rgba(0,0,0,0.18);
		animation: taxfilter-slide-up .3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
		overflow: hidden;
	}

	.taxfilter-modal-panel::before {
		content: "";
		position: absolute;
		top: 8px;
		left: 50%;
		transform: translateX(-50%);
		width: 40px;
		height: 4px;
		background: #e4e4e7;
		border-radius: 999px;
	}

	.taxfilter-modal-header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 1.5rem 1.25rem 0.75rem;
		border-bottom: 1px solid #f4f4f5;
	}
	.taxfilter-modal-title {
		margin: 0;
		font-size: 1.125rem;
		font-weight: 600;
		color: var(--taxfilter-text);
		letter-spacing: -0.01em;
	}
	.taxfilter-modal-close {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 36px;
		height: 36px;
		background: #f4f4f5;
		border: none;
		border-radius: 999px;
		color: var(--taxfilter-text);
		cursor: pointer;
		transition: background .18s ease;
		padding: 0;
	}
	.taxfilter-modal-close:hover { background: #e4e4e7; }

	.taxfilter-modal-body {
		padding: 1rem 1.25rem 1.25rem;
		overflow-y: auto;
		flex: 1;
		-webkit-overflow-scrolling: touch;
	}

	.taxfilter-modal-body .taxfilter-filters {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 0.6rem;
	}
	.taxfilter-modal-body .taxfilter-btn {
		width: 100%;
		padding: 0.85rem 1rem;
		border-radius: 12px;
		font-size: 0.95rem;
		text-align: center;
		justify-content: center;
	}

	.taxfilter-modal-footer {
		display: flex;
		gap: 0.75rem;
		padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom));
		border-top: 1px solid #f4f4f5;
		background: #fff;
	}
	.taxfilter-modal-reset {
		flex: 0 0 auto;
		background: transparent;
		border: 1px solid #e4e4e7;
		color: var(--taxfilter-text);
		padding: 0.85rem 1.25rem;
		border-radius: 12px;
		font-size: 0.95rem;
		font-weight: 500;
		cursor: pointer;
		font-family: inherit;
		transition: background .18s ease;
	}
	.taxfilter-modal-reset:hover { background: #f4f4f5; }
	.taxfilter-modal-apply {
		flex: 1;
		background: var(--taxfilter-primary);
		color: #fff;
		border: none;
		padding: 0.85rem 1.25rem;
		border-radius: 12px;
		font-size: 0.95rem;
		font-weight: 600;
		cursor: pointer;
		font-family: inherit;
		transition: opacity .18s ease, transform .1s ease;
	}
	.taxfilter-modal-apply:hover  { opacity: 0.92; }
	.taxfilter-modal-apply:active { transform: scale(0.98); }

	/* hide the inline chips on mobile — they live in the modal */
	.taxfilter-wrapper > .taxfilter-filters { display: none; }

	body.taxfilter-modal-open { overflow: hidden; }
}

@keyframes taxfilter-fade-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}
@keyframes taxfilter-slide-up {
	from { transform: translateY(100%); }
	to   { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
	.taxfilter-modal-backdrop,
	.taxfilter-modal-panel { animation: none; }
	.taxfilter-btn,
	.taxfilter-trigger,
	.taxfilter-modal-apply { transition: none; }
}
