:root {
  --brand-primary: #1A1F4E;
  --brand-primary-light: #2D3463;
  --brand-secondary: #5B2C91;
  --brand-secondary-light: #7D46B8;
  --brand-accent: #2E8BC0;
  --brand-accent-light: #4FA8DB;
  --brand-gradient: linear-gradient(135deg, #5B2C91 0%, #2E8BC0 100%);
  --brand-gradient-soft: linear-gradient(135deg, rgba(91,44,145,0.08) 0%, rgba(46,139,192,0.08) 100%);

  --bg-main: #FAFAFC;
  --bg-card: #FFFFFF;
  --bg-subtle: #F3F4F9;
  --bg-hover: #EDEFF7;

  --text-primary: #1A1F4E;
  --text-secondary: #4A4E6A;
  --text-tertiary: #7A7F9A;
  --text-muted: #A8ACC2;

  --border: #E5E7EF;
  --border-strong: #CED1DE;

  --shadow-sm: 0 1px 2px rgba(26,31,78,0.04);
  --shadow-md: 0 4px 16px rgba(26,31,78,0.08);
  --shadow-lg: 0 12px 32px rgba(26,31,78,0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

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

.glossary-page {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

.glossary-page h1,
.glossary-page h2,
.glossary-page h3,
.glossary-page h4,
.glossary-page h5,
.glossary-page h6,
.glossary-page p,
.glossary-page ul,
.glossary-page ol {
  margin: 0;
  padding: 0;
}

/* HERO */
.hero {
  position: relative;
  background: var(--brand-primary);
  color: white;
  padding: 5rem 2rem 4rem;
  overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; top: -50%; right: -10%;
  width: 60%; height: 200%;
  background: radial-gradient(ellipse, rgba(91,44,145,0.35) 0%, transparent 60%);
  pointer-events: none;
}
.hero::after {
  content: ""; position: absolute; bottom: -50%; left: -10%;
  width: 50%; height: 150%;
  background: radial-gradient(ellipse, rgba(46,139,192,0.25) 0%, transparent 60%);
  pointer-events: none;
}
.hero-inner {
  position: relative; max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: auto 1fr;
  gap: 3rem; align-items: center;
}
.hero-logo {
  width: 140px; height: 140px; border-radius: 50%;
  background: white; padding: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  flex-shrink: 0;
}
.hero-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }

.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 6px 14px; border-radius: 100px;
  font-size: 0.8125rem; font-weight: 500;
  letter-spacing: 0.02em; margin-bottom: 1.25rem;
  color: rgba(255,255,255,0.9);
}
.hero-badge-dot {
  width: 6px; height: 6px; background: #4ADE80;
  border-radius: 50%; box-shadow: 0 0 8px rgba(74,222,128,0.6);
}
.hero h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 600; letter-spacing: -0.02em;
  line-height: 1.05; margin-bottom: 0.75rem;
}
.hero h1 .accent {
  font-style: italic; font-weight: 400;
  background: linear-gradient(135deg, #A78BFA 0%, #60A5FA 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-tagline {
  font-size: 1.125rem; color: rgba(255,255,255,0.75);
  max-width: 620px; line-height: 1.6; font-weight: 300;
}
.hero-subtag {
  margin-top: 0.5rem; font-size: 0.9375rem;
  color: rgba(255,255,255,0.55); font-style: italic;
}

/* STATS BAR */
.stats-bar {
  background: white; border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
.stats-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 1rem 2rem;
  display: flex; align-items: center; gap: 2rem; flex-wrap: wrap;
}
.stats-brand {
  display: flex; align-items: center; gap: 10px;
  font-family: 'Fraunces', serif; font-weight: 600;
  font-size: 1.125rem; color: var(--brand-primary);
}
.stats-brand img { width: 28px; height: 28px; border-radius: 50%; }
.stats-divider { width: 1px; height: 24px; background: var(--border); }
.stats-chip {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 0.875rem; color: var(--text-secondary);
}
.stats-chip strong {
  font-size: 1rem; font-weight: 700;
  color: var(--brand-primary); font-variant-numeric: tabular-nums;
}
.stats-download {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--brand-primary); color: white;
  padding: 8px 16px; border-radius: var(--radius-md);
  font-size: 0.875rem; font-weight: 600;
  text-decoration: none;
  transition: transform 0.2s, background 0.2s;
  border: none; cursor: pointer; font-family: inherit;
}
.stats-download:hover {
  background: var(--brand-secondary); transform: translateY(-1px);
}

/* SEARCH */
.search-section {
  max-width: 1200px; margin: 0 auto; padding: 2rem;
}
.search-wrapper { position: relative; margin-bottom: 1.5rem; }
.search-input {
  width: 100%; padding: 18px 20px 18px 56px;
  font-size: 1rem; font-family: inherit;
  background: white; border: 2px solid var(--border);
  border-radius: var(--radius-lg); color: var(--text-primary);
  transition: all 0.2s; box-shadow: var(--shadow-sm);
}
.search-input:focus {
  outline: none; border-color: var(--brand-secondary);
  box-shadow: 0 0 0 4px rgba(91,44,145,0.1), var(--shadow-md);
}
.search-input::placeholder { color: var(--text-muted); }
.search-icon {
  position: absolute; left: 20px; top: 50%;
  transform: translateY(-50%); color: var(--text-tertiary);
  pointer-events: none;
}
.search-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 0.75rem; padding: 0 0.25rem;
  font-size: 0.875rem; color: var(--text-tertiary);
}
.search-count strong {
  color: var(--brand-primary);
  font-variant-numeric: tabular-nums; font-weight: 600;
}
.clear-btn {
  background: none; border: none; color: var(--brand-secondary);
  cursor: pointer; font-size: 0.875rem; font-weight: 500;
  font-family: inherit; padding: 4px 8px;
  border-radius: 6px; transition: background 0.2s;
}
.clear-btn:hover { background: var(--bg-subtle); }

/* CATEGORY FILTERS */
.category-filters {
  display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 0.5rem;
}
.category-chip {
  background: white; border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 100px;
  font-size: 0.8125rem; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  transition: all 0.15s; font-family: inherit;
  display: inline-flex; align-items: center; gap: 8px;
}
.category-chip:hover {
  border-color: var(--brand-secondary);
  color: var(--brand-primary); transform: translateY(-1px);
}
.category-chip.active {
  background: var(--brand-primary); border-color: var(--brand-primary); color: white;
}
.category-chip.active .chip-count {
  background: rgba(255,255,255,0.25); color: white;
}
.chip-count {
  background: var(--bg-subtle); color: var(--text-tertiary);
  padding: 2px 8px; border-radius: 100px;
  font-size: 0.6875rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* TERMS */
.terms-section {
  max-width: 1200px; margin: 0 auto; padding: 0 2rem 6rem;
}
.category-group { margin-bottom: 3rem; }
.category-header {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1.5rem; padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--brand-secondary);
}
.category-header h2 {
  font-family: 'Fraunces', serif;
  font-size: 1.5rem; font-weight: 600;
  letter-spacing: -0.01em; color: var(--brand-primary); flex-grow: 1;
}
.category-header .count {
  background: var(--brand-gradient-soft); color: var(--brand-secondary);
  padding: 4px 12px; border-radius: 100px;
  font-size: 0.8125rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.terms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 1rem;
}
.term-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 1.25rem 1.5rem;
  transition: all 0.2s; position: relative; overflow: hidden;
}
.term-card::before {
  content: ""; position: absolute; left: 0; top: 0;
  width: 3px; height: 100%;
  background: var(--brand-gradient);
  opacity: 0; transition: opacity 0.2s;
}
.term-card:hover {
  border-color: var(--brand-secondary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.term-card:hover::before { opacity: 1; }
.term-name {
  font-family: 'Fraunces', serif;
  font-size: 1.125rem; font-weight: 600;
  color: var(--brand-primary); margin-bottom: 0.5rem;
  letter-spacing: -0.01em; line-height: 1.3;
}
.term-name code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95em;
  background: var(--bg-subtle);
  padding: 1px 5px; border-radius: 4px;
  color: var(--brand-secondary);
}
.term-definition {
  font-size: 0.9375rem; color: var(--text-secondary);
  line-height: 1.6; margin-bottom: 0.75rem;
}
.term-sources {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 0.5rem;
}
.source-badge {
  display: inline-flex; align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem; font-weight: 500;
  padding: 3px 8px; border-radius: 4px;
  background: var(--bg-subtle); color: var(--text-tertiary);
  letter-spacing: 0.01em;
}

/* Source color coding */
.source-badge[data-source*="GS1"] { background: rgba(46,139,192,0.12); color: #1E5A7A; }
.source-badge[data-source*="WHO"] { background: rgba(220,38,38,0.08); color: #991B1B; }
.source-badge[data-source*="Tatmeen"] { background: rgba(16,185,129,0.1); color: #065F46; }
.source-badge[data-source*="EPTTS"] { background: rgba(234,88,12,0.1); color: #9A3412; }
.source-badge[data-source*="MediTrack"] { background: rgba(139,92,246,0.12); color: #5B21B6; }
.source-badge[data-source*="MoHAP"] { background: rgba(16,185,129,0.1); color: #065F46; }
.source-badge[data-source*="EFDA"] { background: rgba(245,158,11,0.12); color: #92400E; }
.source-badge[data-source*="FMD"] { background: rgba(37,99,235,0.1); color: #1E40AF; }
.source-badge[data-source*="DSCSA"] { background: rgba(220,38,38,0.08); color: #991B1B; }
.source-badge[data-source*="ISO"] { background: rgba(100,116,139,0.15); color: #334155; }
.source-badge[data-source*="RSD-SFDA"] { background: rgba(16,185,129,0.1); color: #065F46; }

.no-results {
  text-align: center; padding: 4rem 2rem; color: var(--text-tertiary);
}
.no-results h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.5rem; color: var(--brand-primary);
  margin-bottom: 0.5rem;
}

mark {
  background: linear-gradient(to bottom, transparent 60%, rgba(91,44,145,0.25) 60%);
  color: inherit; padding: 0 2px; border-radius: 2px;
}

/* RESPONSIVE */
/* AUTH BANNER */
.glossary-auth-banner {
  background: linear-gradient(135deg, rgba(91,44,145,0.08) 0%, rgba(46,139,192,0.08) 100%);
  border-bottom: 1px solid var(--border);
}
.glossary-auth-banner-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0.875rem 2rem;
  display: flex; align-items: center; gap: 0.875rem; flex-wrap: wrap;
  color: var(--text-secondary); font-size: 0.9375rem;
}
.glossary-auth-banner-inner svg { color: var(--brand-secondary); flex-shrink: 0; }
.glossary-auth-banner-cta {
  display: inline-flex; align-items: center;
  padding: 6px 14px; border-radius: var(--radius-md);
  background: var(--brand-primary); color: white;
  text-decoration: none; font-weight: 600; font-size: 0.875rem;
  transition: background 0.2s, transform 0.2s;
}
.glossary-auth-banner-cta:hover { background: var(--brand-secondary); transform: translateY(-1px); color: white; }
.glossary-auth-banner-cta--ghost {
  background: transparent; color: var(--brand-primary);
  border: 1px solid var(--border-strong);
}
.glossary-auth-banner-cta--ghost:hover { background: white; color: var(--brand-secondary); }

/* LOCKED TERM CARDS */
.term-card--locked .term-name { opacity: 0.95; }
.term-locked {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.875rem 1rem;
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  margin-top: 0.75rem;
}
.term-locked-icon { color: var(--brand-secondary); flex-shrink: 0; }
.term-locked-cta {
  color: var(--brand-primary); font-weight: 600;
  text-decoration: none; font-size: 0.9375rem;
}
.term-locked-cta:hover { color: var(--brand-secondary); text-decoration: underline; }

@media (max-width: 768px) {
  .hero { padding: 3rem 1.5rem 2.5rem; }
  .hero-inner { grid-template-columns: 1fr; gap: 1.5rem; text-align: center; }
  .hero-logo { width: 100px; height: 100px; margin: 0 auto; }
  .hero h1 { font-size: 2.25rem; }
  .hero-tagline { font-size: 1rem; }
  .stats-inner { padding: 0.875rem 1rem; gap: 0.75rem; }
  .stats-divider, .stats-chip:nth-child(n+4) { display: none; }
  .stats-download { margin-left: auto; }
  .search-section, .terms-section { padding-left: 1rem; padding-right: 1rem; }
  .terms-grid { grid-template-columns: 1fr; }
}

@media print {
  .stats-bar, .search-section { display: none; }
  .hero { background: white; color: var(--brand-primary); }
  .term-card { break-inside: avoid; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.term-card { animation: fadeInUp 0.3s ease-out backwards; }
