/* =========================================================
   RxMatch: Design Tokens & Base Styles
   Healthcare-professional palette with teal/green accent
   ========================================================= */

:root {
	/* Brand: clinical teal */
	--primary:           #0d9488;   /* teal-600 */
	--primary-hover:     #0f766e;   /* teal-700 */
	--primary-active:    #115e59;   /* teal-800 */
	--primary-soft:      #f0fdfa;   /* teal-50  */
	--primary-soft-2:    #ccfbf1;   /* teal-100 */
	--primary-ring:      rgba(13, 148, 136, 0.18);

	/* Supporting greens (used for "activate", success) */
	--success:           #059669;   /* emerald-600 */
	--success-soft:      #ecfdf5;
	--success-border:    #a7f3d0;

	/* Status colors */
	--warning:           #b45309;   /* amber-700 */
	--warning-soft:      #fffbeb;
	--warning-border:    #fde68a;

	--danger:            #b91c1c;   /* red-700 */
	--danger-soft:       #fef2f2;
	--danger-border:     #fecaca;

	--info:              #0369a1;   /* sky-700 */
	--info-soft:         #f0f9ff;
	--info-border:       #bae6fd;

	/* Neutrals */
	--bg:                #f6f8fa;
	--bg-subtle:         #f1f4f7;
	--surface:           #ffffff;
	--surface-2:         #fafbfc;

	--border:            #e4e9ee;
	--border-strong:     #cfd6dd;

	--text:              #0f172a;
	--text-secondary:    #334155;
	--text-muted:        #64748b;
	--text-soft:         #94a3b8;

	/* Sidebar (light, clinical) */
	--sidebar-bg:        #ffffff;
	--sidebar-border:    #e4e9ee;
	--sidebar-text:      #475569;
	--sidebar-text-hover:#0f172a;
	--sidebar-hover-bg:  #f1f5f9;
	--sidebar-active-bg: var(--primary-soft);
	--sidebar-active-text: var(--primary-active);

	/* Radii */
	--radius-xs: 6px;
	--radius-sm: 8px;
	--radius:    10px;
	--radius-md: 12px;
	--radius-lg: 16px;
	--radius-pill: 999px;

	/* Shadows */
	--shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
	--shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
	--shadow:    0 4px 12px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
	--shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10), 0 2px 6px rgba(15, 23, 42, 0.06);
	--shadow-xl: 0 24px 60px rgba(15, 23, 42, 0.16), 0 4px 12px rgba(15, 23, 42, 0.08);

	/* Spacing scale */
	--space-1: 4px;
	--space-2: 8px;
	--space-3: 12px;
	--space-4: 16px;
	--space-5: 20px;
	--space-6: 24px;
	--space-8: 32px;
	--space-10: 40px;

	/* Motion */
	--ease: cubic-bezier(0.2, 0.8, 0.2, 1);
	--dur-fast: 120ms;
	--dur: 180ms;

	/* Typography */
	--font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

html, body {
	height: 100%;
}

body {
	margin: 0;
	font-family: var(--font-sans);
	font-size: 14px;
	line-height: 1.5;
	color: var(--text);
	background: var(--bg);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
}

a {
	text-decoration: none;
	color: var(--primary);
	transition: color var(--dur-fast) var(--ease);
}

a:hover {
	color: var(--primary-hover);
}

h1, h2, h3, h4, h5, h6 {
	margin: 0;
	font-weight: 600;
	color: var(--text);
	letter-spacing: -0.01em;
}

h1 { font-size: 22px; line-height: 1.3; }
h2 { font-size: 18px; line-height: 1.35; }
h3 { font-size: 16px; line-height: 1.4; }
h4 { font-size: 14px; line-height: 1.4; }

p  { margin: 0 0 var(--space-3); }

::selection {
	background: var(--primary-soft-2);
	color: var(--primary-active);
}

/* Focus ring for keyboard users */
:focus-visible {
	outline: 2px solid var(--primary);
	outline-offset: 2px;
	border-radius: 4px;
}

/* Scrollbar polish (WebKit) */
::-webkit-scrollbar           { width: 10px; height: 10px; }
::-webkit-scrollbar-track     { background: transparent; }
::-webkit-scrollbar-thumb     { background: #d6dde3; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #b8c1c9; background-clip: padding-box; border: 2px solid transparent; }

/* Utility */
.muted { color: var(--text-muted); }
.subtle { color: var(--text-soft); }
.mono { font-family: var(--font-mono); }

/* Hide visually but keep accessible */
.sr-only {
	position: absolute;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0,0,0,0);
	white-space: nowrap; border: 0;
}

/* =========================================================
   Dashboard: Hero, stat tiles, action tiles
   (bundled into base.css to avoid sync/cache issues)
   ========================================================= */

.dash-hero {
	position: relative;
	overflow: hidden;
	border-radius: var(--radius-lg);
	padding: 36px 36px 38px;
	margin-bottom: 20px;
	background:
		radial-gradient(900px 320px at 110% -30%, rgba(45, 212, 191, 0.28) 0%, transparent 60%),
		radial-gradient(700px 280px at -10% 130%, rgba(16, 185, 129, 0.20) 0%, transparent 55%),
		linear-gradient(135deg, #0f766e 0%, #0d9488 45%, #0b8378 100%);
	color: #fff;
	box-shadow:
		0 18px 40px rgba(13, 148, 136, 0.22),
		0 2px 6px rgba(13, 148, 136, 0.18);
}

.dash-hero-inner {
	position: relative;
	z-index: 1;
	max-width: 640px;
}

.dash-eyebrow {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: #fff;
	background: rgba(255, 255, 255, 0.16);
	border: 1px solid rgba(255, 255, 255, 0.25);
	padding: 4px 10px;
	border-radius: var(--radius-pill);
	margin-bottom: 14px;
	backdrop-filter: blur(4px);
}

.dash-eyebrow i { font-size: 10px; }

.dash-hero h2 {
	font-size: 28px;
	font-weight: 700;
	letter-spacing: -0.02em;
	color: #fff;
	margin: 0 0 8px;
	line-height: 1.2;
}

.dash-sub {
	font-size: 14.5px;
	color: rgba(255, 255, 255, 0.86);
	line-height: 1.55;
	margin: 0;
	max-width: 540px;
}

.dash-hero-bg {
	position: absolute;
	right: -60px;
	top: -60px;
	width: 320px;
	height: 320px;
	border-radius: 999px;
	background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 60%);
	pointer-events: none;
}

.dash-hero::after {
	content: "";
	position: absolute;
	left: -20px;
	bottom: -90px;
	width: 240px;
	height: 240px;
	border-radius: 999px;
	background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0) 65%);
	pointer-events: none;
}

@media (max-width: 720px) {
	.dash-hero { padding: 26px 22px; }
	.dash-hero h2 { font-size: 22px; }
}

/* ---------- Stat tiles ---------- */
.dash-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 14px;
	margin-bottom: 20px;
}

.stat-tile {
	position: relative;
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 16px 18px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	text-decoration: none;
	color: inherit;
	box-shadow: var(--shadow-xs);
	transition:
		transform 80ms var(--ease),
		box-shadow var(--dur) var(--ease),
		border-color var(--dur) var(--ease);
	overflow: hidden;
}

.stat-tile:hover {
	transform: translateY(-1px);
	box-shadow: var(--shadow);
	border-color: var(--border-strong);
	color: inherit;
}

.stat-tile-icon {
	flex-shrink: 0;
	width: 44px;
	height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--radius-sm);
	font-size: 18px;
	background: var(--primary-soft);
	color: var(--primary);
	border: 1px solid var(--primary-soft-2);
}

.stat-tile-body { flex: 1; min-width: 0; }

.stat-tile-value {
	font-size: 22px;
	font-weight: 700;
	letter-spacing: -0.02em;
	color: var(--text);
	line-height: 1.1;
}

.stat-tile-label {
	font-size: 12.5px;
	color: var(--text-muted);
	margin-top: 3px;
	font-weight: 500;
}

.stat-tile-arrow {
	color: var(--text-soft);
	font-size: 13px;
	transition: transform var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.stat-tile:hover .stat-tile-arrow {
	color: var(--primary);
	transform: translateX(3px);
}

.stat-tile--primary .stat-tile-icon {
	background: var(--primary-soft);
	color: var(--primary);
	border-color: var(--primary-soft-2);
}
.stat-tile--success .stat-tile-icon {
	background: var(--success-soft);
	color: var(--success);
	border-color: var(--success-border);
}
.stat-tile--warning .stat-tile-icon {
	background: var(--warning-soft);
	color: var(--warning);
	border-color: var(--warning-border);
}
.stat-tile--info .stat-tile-icon {
	background: var(--info-soft);
	color: var(--info);
	border-color: var(--info-border);
}
.stat-tile--danger .stat-tile-icon {
	background: var(--danger-soft);
	color: var(--danger);
	border-color: var(--danger-border);
}

/* ---------- Quick action tiles ---------- */
.dash-actions {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 12px;
}

.action-tile {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 14px 16px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	text-decoration: none;
	color: inherit;
	transition:
		background var(--dur-fast) var(--ease),
		border-color var(--dur-fast) var(--ease),
		box-shadow var(--dur-fast) var(--ease),
		transform 80ms var(--ease);
}

.action-tile:hover {
	background: var(--primary-soft);
	border-color: var(--primary-soft-2);
	box-shadow: 0 6px 16px rgba(13, 148, 136, 0.10);
	color: inherit;
	transform: translateY(-1px);
}

.action-tile-icon {
	flex-shrink: 0;
	width: 36px;
	height: 36px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--radius-xs);
	font-size: 15px;
	background: var(--primary-soft);
	color: var(--primary);
	border: 1px solid var(--primary-soft-2);
	transition: background var(--dur-fast) var(--ease);
}

.action-tile:hover .action-tile-icon {
	background: var(--primary);
	color: #fff;
	border-color: var(--primary);
}

.action-tile-title {
	font-size: 14px;
	font-weight: 600;
	color: var(--text);
	line-height: 1.3;
}

.action-tile-desc {
	font-size: 12.5px;
	color: var(--text-muted);
	line-height: 1.4;
	margin-top: 2px;
}

.action-tile-chev {
	margin-left: auto;
	color: var(--text-soft);
	font-size: 12px;
	transition: color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.action-tile:hover .action-tile-chev {
	color: var(--primary);
	transform: translateX(2px);
}

/* =========================================================
   Page header (used on list/index pages)
   ========================================================= */

.page-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 18px;
}

.page-header-text h2 {
	font-size: 20px;
	font-weight: 700;
	letter-spacing: -0.015em;
	margin: 0;
	color: var(--text);
}

.page-header-text .page-subtitle {
	font-size: 13px;
	color: var(--text-muted);
	margin-top: 4px;
}

.page-header-actions {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
}

/* =========================================================
   Studies: Recruitment funnel, contact cell, algorithm note
   ========================================================= */

/* Title cell: bold name with subtle id/meta below */
.study-name {
	font-weight: 700;
	font-size: 14px;
	color: var(--text);
	letter-spacing: -0.005em;
}

.study-name-id {
	font-size: 11.5px;
	color: var(--text-soft);
	font-family: var(--font-mono);
	margin-top: 2px;
}

/* Recruitment funnel: compact stacked stats */
.recruit {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 13px;
	line-height: 1.2;
}

.recruit-line {
	display: inline-flex;
	align-items: baseline;
	gap: 6px;
	color: var(--text-secondary);
}

.recruit-line b {
	font-weight: 700;
	min-width: 18px;
	display: inline-block;
	text-align: right;
}

.recruit-line.invited b   { color: var(--text); }
.recruit-line.enrolled    { color: var(--success); }
.recruit-line.enrolled b  { color: var(--success); }
.recruit-line.denied      { color: var(--danger); }
.recruit-line.denied b    { color: var(--danger); }
.recruit-line.reapplied   { color: var(--primary); }
.recruit-line.reapplied b { color: var(--primary); }

/* Contact cell */
.contact-cell {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.contact-cell-name {
	font-weight: 600;
	color: var(--text);
}

.contact-cell-meta {
	font-size: 12px;
	color: var(--text-muted);
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}

.contact-cell-meta .dot {
	width: 3px;
	height: 3px;
	border-radius: 999px;
	background: var(--text-soft);
	display: inline-block;
}

.contact-cell-meta.empty {
	color: var(--text-soft);
	font-style: italic;
}

/* Enrollment cell */
.enroll-cell {
	color: var(--text-secondary);
	font-size: 13px;
}

.enroll-cell.open {
	color: var(--text-muted);
	font-style: italic;
}

.enroll-cell b { color: var(--text); font-weight: 600; }

/* Algorithm note: subtle expanded row */
.algorithm-note {
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 10px 14px;
	font-size: 12.5px;
	color: var(--text-secondary);
	line-height: 1.6;
	display: flex;
	align-items: flex-start;
	gap: 10px;
}
.algorithm-note p,
.algorithm-note p:first-child,
.algorithm-note p:last-child {
	margin: 0;
}

.algorithm-note::before {
	content: "\f0d0"; /* fa-wand-magic-sparkles fallback to fa-cog */
	font-family: "Font Awesome 6 Free", "Font Awesome 5 Free", FontAwesome;
	font-weight: 900;
	color: var(--primary);
	font-size: 12px;
	line-height: 1.6;          /* match the body's line-height so the */
	height: 1.6em;             /* icon's box centres against the first */
	display: inline-flex;      /* text line, not against its top edge. */
	align-items: center;
	flex-shrink: 0;
}

.algorithm-note.empty {
	color: var(--text-soft);
	font-style: italic;
}

.algorithm-note.empty::before {
	color: var(--text-soft);
	content: "\f071"; /* fa-triangle-exclamation */
}

/* Sub-row holding the algorithm note */
tr.subrow td {
	border-top: none !important;
	padding-top: 0 !important;
	padding-bottom: 16px !important;
}

tr.subrow + tr td { border-top: 1px solid var(--border); }

/* Action button: disabled-look helper used in studies actions */
.action-btn.disabled,
.action-btn[aria-disabled="true"] {
	color: var(--text-soft);
	background: var(--surface);
	border-color: var(--border);
	cursor: not-allowed;
	opacity: 0.75;
}

/* "Invite" action: uses primary teal */
.action-btn.invite {
	color: var(--primary-hover);
	border-color: var(--primary-soft-2);
	background: var(--primary-soft);
}
.action-btn.invite:hover {
	background: var(--primary-soft-2);
	border-color: var(--primary);
	color: var(--primary-active);
}

/* =========================================================
   Filter bar: search input + status chips
   ========================================================= */

.filter-bar {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: 10px 12px;
	box-shadow: var(--shadow-xs);
	margin-bottom: 16px;
}

.filter-search {
	position: relative;
	flex: 1;
	min-width: 240px;
	max-width: 420px;
}

.filter-search i {
	position: absolute;
	left: 12px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--text-soft);
	font-size: 13px;
	pointer-events: none;
}

.filter-search input {
	width: 100%;
	padding: 9px 12px 9px 34px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	font-size: 13.5px;
	transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.filter-search input:focus {
	outline: none;
	border-color: var(--primary);
	box-shadow: 0 0 0 3px var(--primary-ring);
	background: var(--surface);
}

.filter-chips {
	display: inline-flex;
	gap: 4px;
	background: var(--bg-subtle);
	border-radius: var(--radius-sm);
	padding: 3px;
}

.filter-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--text-secondary);
	border: 1px solid transparent;
	border-radius: var(--radius-xs);
	background: transparent;
	cursor: pointer;
	transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
	text-decoration: none;
}

.filter-chip:hover {
	background: var(--surface);
	color: var(--text);
}

.filter-chip.active {
	background: var(--surface);
	color: var(--primary-active);
	box-shadow: var(--shadow-xs);
	border-color: var(--border);
}

.filter-chip-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0 6px;
	min-width: 18px;
	height: 18px;
	font-size: 10.5px;
	font-weight: 700;
	color: var(--text-muted);
	background: var(--bg-subtle);
	border-radius: var(--radius-pill);
	line-height: 1;
}

.filter-chip.active .filter-chip-count {
	background: var(--primary-soft);
	color: var(--primary-hover);
}

.filter-spacer { flex: 1; }

/* =========================================================
   Study cards
   ========================================================= */

.studies-list {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.study-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: 18px 22px 20px;
	box-shadow: var(--shadow-xs);
	transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.study-card:hover {
	box-shadow: var(--shadow-sm);
}

.study-card-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 14px;
	margin-bottom: 16px;
}

.study-card-title {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}

.study-card-title-row {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

.study-card-name {
	font-size: 17px;
	font-weight: 700;
	color: var(--text);
	letter-spacing: -0.01em;
	line-height: 1.25;
}

.study-card-id {
	font-family: var(--font-mono);
	font-size: 11px;
	color: var(--text-soft);
	letter-spacing: 0.02em;
}

.study-card-actions {
	display: inline-flex;
	gap: 8px;
	flex-shrink: 0;
}

/* Metrics row */
.study-metrics {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
	gap: 10px;
	margin-bottom: 14px;
}

.study-metric {
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 10px 14px;
	display: flex;
	flex-direction: column;
	gap: 2px;
	position: relative;
}

.study-metric-value {
	font-size: 20px;
	font-weight: 700;
	color: var(--text);
	letter-spacing: -0.02em;
	line-height: 1.1;
}

.study-metric-label {
	font-size: 11.5px;
	color: var(--text-muted);
	font-weight: 500;
	letter-spacing: 0.02em;
	text-transform: uppercase;
}

.study-metric--enrolled .study-metric-value { color: var(--success); }
.study-metric--denied   .study-metric-value { color: var(--danger); }
.study-metric--reapplied .study-metric-value { color: var(--primary); }

/* Section grouping for related metric rows */
.study-metrics-section { margin-bottom: 14px; }
.study-metrics-section .study-metrics { margin-bottom: 6px; }
.study-metrics-section-label {
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--text-muted);
	margin-bottom: 6px;
}

/* Patient-activity metric variants (icon in top-right) */
.study-metric--matched,
.study-metric--texted,
.study-metric--responded,
.study-metric--rate {
	padding-right: 38px;
}
.study-metric-icn {
	position: absolute;
	top: 10px;
	right: 12px;
	width: 24px;
	height: 24px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 999px;
	font-size: 10.5px;
	color: var(--primary);
}
.study-metric--matched .study-metric-value   { color: var(--primary); }
.study-metric--texted .study-metric-value    { color: var(--text); }
.study-metric--responded .study-metric-value { color: var(--success); }
.study-metric--responded .study-metric-icn { color: var(--success); border-color: var(--success-border); }
.study-metric--rate .study-metric-value      { color: var(--text); }
.study-metric--rate .study-metric-icn { color: var(--text-secondary); }

/* Meta row: enrollment + contact */
.study-meta {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 10px 18px;
	padding: 12px 14px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	margin-bottom: 12px;
	font-size: 13px;
}

.study-meta-item {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.study-meta-label {
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: 0.08em;
	color: var(--text-muted);
	text-transform: uppercase;
}

.study-meta-value {
	color: var(--text);
	font-weight: 500;
	overflow: hidden;
	text-overflow: ellipsis;
}

.study-meta-value .sep {
	color: var(--text-soft);
	margin: 0 4px;
}

.study-meta-value .icn {
	color: var(--text-muted);
	font-size: 11px;
	margin-right: 4px;
}

.study-meta-value.muted {
	color: var(--text-soft);
	font-style: italic;
	font-weight: 400;
}

/* Empty state for no results */
.empty-results {
	background: var(--surface);
	border: 1px dashed var(--border-strong);
	border-radius: var(--radius-md);
	padding: 36px 24px;
	text-align: center;
	color: var(--text-muted);
}

.empty-results i {
	font-size: 28px;
	color: var(--text-soft);
	margin-bottom: 10px;
	display: block;
}

.empty-results .empty-title {
	font-size: 14px;
	font-weight: 600;
	color: var(--text-secondary);
	margin-bottom: 4px;
}

.empty-results .empty-sub {
	font-size: 13px;
	color: var(--text-muted);
}

/* Hidden by JS filter */
.study-card[hidden] { display: none; }

@media (max-width: 720px) {
	.study-card-head { flex-direction: column; align-items: stretch; }
	.study-card-actions { justify-content: flex-end; }
	.filter-bar { flex-direction: column; align-items: stretch; }
	.filter-search { max-width: none; }
}

/* =========================================================
   Match-set builder (drug groups w/ AND/OR logic)
   ========================================================= */

.match-builder {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.match-builder-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 4px;
}

.match-builder-head h4 {
	font-size: 14px;
	font-weight: 600;
	color: var(--text);
	margin: 0;
}

.match-builder-head .hint-pill {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: var(--bg-subtle);
	border: 1px solid var(--border);
	color: var(--text-muted);
	font-size: 11.5px;
	padding: 3px 9px;
	border-radius: var(--radius-pill);
	font-weight: 500;
}

.match-set {
	border: 1px dashed var(--border-strong);
	border-radius: var(--radius-sm);
	padding: 12px 14px;
	background: var(--surface-2);
	transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.match-set:hover {
	border-color: var(--primary-soft-2);
}

.match-set-head {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 10px;
}

.match-set-label {
	font-size: 10.5px;
	font-weight: 700;
	color: var(--text-muted);
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.match-set-label .num {
	color: var(--primary-hover);
}

.match-set-remove {
	margin-left: auto;
	background: transparent;
	border: none;
	color: var(--text-muted);
	cursor: pointer;
	font-size: 12px;
	font-weight: 500;
	padding: 4px 8px;
	border-radius: var(--radius-xs);
	display: inline-flex;
	align-items: center;
	gap: 4px;
	transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.match-set-remove:hover {
	background: var(--danger-soft);
	color: var(--danger);
}

.match-set-body {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-items: center;
}

/* Drug group chip */
.dg-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 5px 6px 5px 12px;
	background: var(--primary-soft);
	color: var(--primary-active);
	border: 1px solid var(--primary-soft-2);
	border-radius: var(--radius-pill);
	font-size: 12.5px;
	font-weight: 600;
	line-height: 1;
	transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.dg-chip.danger {
	background: var(--danger-soft);
	color: var(--danger);
	border-color: var(--danger-border);
}

.dg-chip-remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	border: none;
	background: transparent;
	color: inherit;
	opacity: 0.55;
	border-radius: 999px;
	cursor: pointer;
	font-size: 11px;
	transition: opacity var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.dg-chip-remove:hover {
	opacity: 1;
	background: rgba(0,0,0,0.06);
}

.dg-chip.danger .dg-chip-remove:hover {
	background: rgba(185, 28, 28, 0.12);
}

/* "Add drug group" combobox trigger button */
.dg-add-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 12px;
	background: var(--surface);
	border: 1px dashed var(--border-strong);
	color: var(--text-secondary);
	border-radius: var(--radius-pill);
	font-size: 12.5px;
	font-weight: 600;
	cursor: pointer;
	line-height: 1;
	transition:
		background var(--dur-fast) var(--ease),
		border-color var(--dur-fast) var(--ease),
		color var(--dur-fast) var(--ease);
}

.dg-add-btn:hover {
	background: var(--primary-soft);
	border-color: var(--primary);
	color: var(--primary-active);
}

.dg-add-btn i { font-size: 10px; }

/* OR divider between sets */
.match-or-divider {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 2px 0;
}

.match-or-divider::before,
.match-or-divider::after {
	content: "";
	flex: 1;
	height: 1px;
	background: var(--border);
}

.match-or-divider span {
	font-size: 10.5px;
	font-weight: 700;
	color: var(--text-muted);
	letter-spacing: 0.18em;
}

/* Add OR alternative button */
.match-add-set {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	width: 100%;
	padding: 9px 14px;
	background: var(--surface);
	border: 1px dashed var(--border-strong);
	border-radius: var(--radius-sm);
	color: var(--primary-hover);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.match-add-set:hover {
	background: var(--primary-soft);
	border-color: var(--primary);
}

/* Live algorithm preview panel */
.algo-preview {
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: 14px 16px;
}

.algo-preview-label {
	font-size: 10.5px;
	font-weight: 700;
	color: var(--text-muted);
	letter-spacing: 0.08em;
	text-transform: uppercase;
	margin-bottom: 6px;
	display: flex;
	align-items: center;
	gap: 6px;
}

.algo-preview-label .dot {
	width: 6px;
	height: 6px;
	background: var(--primary);
	border-radius: 999px;
	display: inline-block;
	animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
	0%, 100% { opacity: 1; }
	50%      { opacity: 0.4; }
}

.algo-preview-body {
	font-size: 13.5px;
	color: var(--text);
	line-height: 1.65;
}

.algo-preview-body em {
	color: var(--text-muted);
	font-style: italic;
}

.algo-preview-body b {
	font-weight: 600;
}

/* =========================================================
   Combobox dropdown (typeahead)
   ========================================================= */

.combobox {
	position: relative;
	display: inline-block;
}

.combobox-panel {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	z-index: 60;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-lg);
	min-width: 240px;
	max-width: 360px;
	padding: 6px;
	display: none;
	animation: dropdownIn 140ms var(--ease);
}

.combobox.open .combobox-panel { display: block; }

.combobox-search {
	width: 100%;
	padding: 7px 10px;
	font-size: 13px;
	border: 1px solid var(--border);
	border-radius: var(--radius-xs);
	margin-bottom: 6px;
	background: var(--surface-2);
}

.combobox-search:focus {
	outline: none;
	border-color: var(--primary);
	box-shadow: 0 0 0 2px var(--primary-ring);
}

.combobox-options {
	max-height: 220px;
	overflow-y: auto;
}

.combobox-option {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 7px 10px;
	font-size: 13px;
	color: var(--text);
	border-radius: var(--radius-xs);
	cursor: pointer;
	user-select: none;
}

.combobox-option:hover,
.combobox-option.active {
	background: var(--primary-soft);
	color: var(--primary-active);
}

.combobox-option.in-use {
	color: var(--text-soft);
	cursor: not-allowed;
}

.combobox-option.in-use::after {
	content: "added";
	margin-left: auto;
	font-size: 10.5px;
	color: var(--text-soft);
	background: var(--bg-subtle);
	padding: 2px 7px;
	border-radius: var(--radius-pill);
	font-weight: 600;
}

.combobox-option:hover.in-use {
	background: transparent;
}

.combobox-empty {
	padding: 10px;
	font-size: 12.5px;
	color: var(--text-muted);
	text-align: center;
	font-style: italic;
}

/* =========================================================
   Tabs: used on study edit page
   ========================================================= */

.tabs {
	display: flex;
	gap: 2px;
	border-bottom: 1px solid var(--border);
	margin-bottom: 18px;
	padding: 0 2px;
	overflow-x: auto;
	scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 16px;
	background: transparent;
	border: none;
	border-bottom: 2px solid transparent;
	color: var(--text-muted);
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
	transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
	position: relative;
	top: 1px;
}

.tab-btn:hover {
	color: var(--text);
}

.tab-btn.active {
	color: var(--primary-active);
	border-bottom-color: var(--primary);
}

.tab-btn i {
	font-size: 13px;
	color: inherit;
}

.tab-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 6px;
	font-size: 10.5px;
	font-weight: 700;
	color: var(--text-muted);
	background: var(--bg-subtle);
	border-radius: var(--radius-pill);
	margin-left: 2px;
	line-height: 1;
}

.tab-btn.active .tab-badge {
	background: var(--primary-soft);
	color: var(--primary-hover);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* =========================================================
   Filter cards: collapsible per-filter sections
   ========================================================= */

.filter-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-xs);
	transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease);
}

.filter-card + .filter-card { margin-top: 12px; }

.filter-card.is-enabled {
	border-color: var(--primary-soft-2);
}

.filter-card-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 14px 18px;
	cursor: default;
}

.filter-card-title {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
	flex: 1;
}

.filter-card-icon {
	width: 32px;
	height: 32px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--bg-subtle);
	border-radius: var(--radius-sm);
	color: var(--text-muted);
	font-size: 13px;
	flex-shrink: 0;
	transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.filter-card.is-enabled .filter-card-icon {
	background: var(--primary-soft);
	color: var(--primary);
}

.filter-card-text {
	min-width: 0;
}

.filter-card-name {
	font-size: 14px;
	font-weight: 600;
	color: var(--text);
	letter-spacing: -0.005em;
}

.filter-card-desc {
	font-size: 12.5px;
	color: var(--text-muted);
	margin-top: 1px;
}

/* Toggle switch */
.filter-toggle {
	position: relative;
	display: inline-block;
	width: 36px;
	height: 20px;
	flex-shrink: 0;
}

.filter-toggle input {
	opacity: 0;
	width: 0;
	height: 0;
}

.filter-toggle-slider {
	position: absolute;
	cursor: pointer;
	inset: 0;
	background: var(--border-strong);
	border-radius: var(--radius-pill);
	transition: background var(--dur-fast) var(--ease);
}

.filter-toggle-slider::before {
	content: "";
	position: absolute;
	left: 2px;
	top: 2px;
	width: 16px;
	height: 16px;
	background: #fff;
	border-radius: 999px;
	box-shadow: 0 1px 3px rgba(0,0,0,0.18);
	transition: transform var(--dur-fast) var(--ease);
}

.filter-toggle input:checked + .filter-toggle-slider {
	background: var(--primary);
}

.filter-toggle input:checked + .filter-toggle-slider::before {
	transform: translateX(16px);
}

.filter-toggle input:focus-visible + .filter-toggle-slider {
	box-shadow: 0 0 0 3px var(--primary-ring);
}

/* Body: only visible when filter is enabled */
.filter-card-body {
	padding: 0 18px 18px;
	border-top: 1px solid var(--border);
	margin-top: 2px;
	display: none;
}

.filter-card.is-enabled .filter-card-body {
	display: block;
}

/* Split form for include/exclude pairs */
.filter-split {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
	margin-top: 14px;
}

.filter-split-col h5 {
	font-size: 11px;
	font-weight: 700;
	color: var(--text-muted);
	letter-spacing: 0.08em;
	text-transform: uppercase;
	margin: 0 0 8px;
}

@media (max-width: 720px) {
	.filter-split { grid-template-columns: 1fr; }
}

/* =========================================================
   Sticky save bar
   ========================================================= */

.save-bar {
	position: sticky;
	bottom: 0;
	z-index: 40;
	background: var(--surface);
	border-top: 1px solid var(--border);
	border-bottom-left-radius: var(--radius-md);
	border-bottom-right-radius: var(--radius-md);
	margin: 24px -28px -32px;
	padding: 14px 28px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.06);
	backdrop-filter: blur(6px);
}

.save-bar-status {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	color: var(--text-muted);
}

.save-bar-status .pulse {
	width: 8px;
	height: 8px;
	background: var(--warning);
	border-radius: 999px;
	display: inline-block;
}

.save-bar-status.clean .pulse { background: var(--success); }

.save-bar-actions {
	display: inline-flex;
	gap: 10px;
	align-items: center;
}

/* Compact preview that sits above the form, sticky */
.algo-preview.sticky {
	position: sticky;
	top: 60px;
	z-index: 20;
	margin-bottom: 18px;
}

/* =========================================================
   Drug typeahead: visible search input with live result dropdown
   ========================================================= */

.drug-typeahead {
	position: relative;
	margin-bottom: 14px;
}

.drug-typeahead-input-wrap {
	position: relative;
}

.drug-typeahead-input-wrap i {
	position: absolute;
	left: 12px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--text-soft);
	pointer-events: none;
	font-size: 13px;
}

.drug-typeahead-input-wrap input {
	padding-left: 36px;
}

.drug-typeahead-results {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	right: 0;
	z-index: 30;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-lg);
	max-height: 280px;
	overflow-y: auto;
	display: none;
	padding: 6px;
}

.drug-typeahead-results.open { display: block; }

.drug-typeahead-result {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 8px 10px;
	border-radius: var(--radius-xs);
	cursor: pointer;
	transition: background var(--dur-fast) var(--ease);
}

.drug-typeahead-result:hover,
.drug-typeahead-result.active {
	background: var(--primary-soft);
}

.drug-typeahead-result-name {
	font-size: 13.5px;
	font-weight: 600;
	color: var(--text);
	overflow: hidden;
	text-overflow: ellipsis;
}

.drug-typeahead-result-detail {
	font-size: 11.5px;
	color: var(--text-muted);
}

.drug-typeahead-result-detail .mono {
	font-family: var(--font-mono);
	letter-spacing: 0.02em;
}

.drug-typeahead-empty {
	padding: 10px;
	text-align: center;
	font-size: 12.5px;
	color: var(--text-muted);
	font-style: italic;
}

/* =========================================================
   Drug list: assigned drugs rendered as compact rows
   ========================================================= */

.drug-list-wrap {
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface);
	max-height: 480px;
	overflow-y: auto;
}

.drug-list-empty {
	padding: 28px 20px;
	text-align: center;
	color: var(--text-muted);
	font-size: 13px;
	font-style: italic;
}

.drug-list-empty i {
	display: block;
	font-size: 22px;
	color: var(--text-soft);
	margin-bottom: 6px;
	opacity: 0.7;
}

.drug-row {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 11px 14px;
	border-bottom: 1px solid var(--border);
	transition: background var(--dur-fast) var(--ease);
}

.drug-row:last-child { border-bottom: none; }

.drug-row:hover { background: var(--surface-2); }

.drug-row-meta {
	flex: 1;
	min-width: 0;
}

.drug-row-name {
	font-size: 13.5px;
	font-weight: 600;
	color: var(--text);
	line-height: 1.3;
	overflow-wrap: break-word;
}

.drug-row-detail {
	font-size: 11.5px;
	color: var(--text-muted);
	margin-top: 2px;
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.drug-row-detail .mono {
	font-family: var(--font-mono);
	letter-spacing: 0.02em;
}

.drug-row-detail .sep { color: var(--text-soft); }

.drug-row-remove {
	flex-shrink: 0;
	width: 28px;
	height: 28px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--text-muted);
	border-radius: var(--radius-xs);
	cursor: pointer;
	font-size: 11px;
	transition:
		background var(--dur-fast) var(--ease),
		color var(--dur-fast) var(--ease),
		border-color var(--dur-fast) var(--ease);
}

.drug-row-remove:hover {
	background: var(--danger-soft);
	color: var(--danger);
	border-color: var(--danger-border);
}

.drug-list-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 14px;
	background: var(--surface-2);
	border-bottom: 1px solid var(--border);
	font-size: 12px;
	font-weight: 600;
	color: var(--text-muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
	position: sticky;
	top: 0;
	z-index: 1;
}

/* Pagination */
.pagination {
	display: inline-flex;
	gap: 4px;
	margin-top: 16px;
	padding: 4px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-xs);
}

.pagination-page {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 32px;
	height: 32px;
	padding: 0 10px;
	font-size: 13px;
	font-weight: 500;
	color: var(--text-secondary);
	border-radius: var(--radius-xs);
	text-decoration: none;
	transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.pagination-page:hover {
	background: var(--bg-subtle);
	color: var(--text);
}

.pagination-page.active {
	background: var(--primary);
	color: #fff;
	font-weight: 600;
}
