/* ==========================================================================
   Eligara Sites – Main Stylesheet
   ========================================================================== */

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---------- Design Tokens ---------- */
:root {
  /* ── Typography ─────────────────────────────────────────────────── */
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body:    'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'SF Mono', 'Fira Code', monospace;

  /* ── Brand ───────────────────────────────────────────────────────── */
  --brand:       #7c6bc4;
  --brand-dark:  #6b5b95;
  --brand-light: #9b81d4;
  --brand-tint:  #f0ecfa;

  /* ── Eligara.ai palette ──────────────────────────────────────────── */
  /* Pulled from the eligara.ai marketing site */
  --eligara-navy:  #1a1a2e; /* deep navy — primary dark */
  --eligara-slate: #e2e8f0; /* steel blue-gray — secondary surface/text */

  /* ── Text ────────────────────────────────────────────────────────── */
  /* WCAG AA note: text-primary (17:1), text-secondary (10:1), text-muted (4.8:1)
     all pass 4.5:1 on white. text-subtle (2.54:1) is used only for placeholder
     and decorative text — exempt under WCAG 1.4.3. brand color (4.41:1) passes
     3:1 for large/bold text (buttons, headings). */
  --text-primary:   #1a1a2e;
  --text-secondary: #374151;
  --text-muted:     #6b7280;
  --text-subtle:    #9ca3af;

  /* ── Surfaces ────────────────────────────────────────────────────── */
  --surface:       #f7f5fb;
  --surface-card:  #ffffff;
  --surface-admin: #f9fafb;

  /* ── Grays ───────────────────────────────────────────────────────── */
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* ── Borders ─────────────────────────────────────────────────────── */
  --border:        #e5e7eb;
  --border-subtle: #f3f4f6;
  --border-brand:  #c4b5e0;

  /* ── Semantic colours ───────────────────────────────────────────── */
  --success:        #059669;
  --success-bg:     #f0fdf4;
  --success-border: #86efac;
  --error:          #b91c1c;
  --error-bg:       #fef2f2;
  --info:           #2563eb;
  --info-bg:        #eff6ff;
  --info-border:    #bfdbfe;

  /* ── Shadows ─────────────────────────────────────────────────────── */
  --shadow-sm:    0 2px 12px rgba(0, 0, 0, 0.05);
  --shadow-md:    0 4px 24px rgba(0, 0, 0, 0.10);
  --shadow-lg:    0 8px 40px rgba(0, 0, 0, 0.14);
  --shadow-brand: 0 8px 40px rgba(124, 107, 196, 0.12);

  /* ── Radius ──────────────────────────────────────────────────────── */
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-full: 999px;

  /* ── Transitions ─────────────────────────────────────────────────── */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;

  /* ── Warning / Amber ───────────────────────────────────────────── */
  --warning:               #d97706;
  --warning-bg:            #fffbeb;
  --warning-bg-subtle:     #fef3c7;
  --warning-border:        #fcd34d;
  --warning-border-subtle: #fde68a;
  --warning-text:          #78350f;
  --warning-text-dark:     #92400e;

  /* ── Extended error colours ─────────────────────────────────────── */
  --error-mid:    #dc2626;
  --error-dark:   #991b1b;
  --error-darker: #7f1d1d;
  --error-border: #fca5a5;

  /* ── Extended success colours ───────────────────────────────────── */
  --success-light:         #4caf50;
  --success-mid:           #45a049;
  --success-dark:          #047857;
  --success-darker:        #065f46;
  --success-text:          #15803d;
  --success-text-dark:     #2e7d32;
  --success-bg-hover:      #dcfce7;
  --success-border-hover:  #4ade80;
  --success-border-active: #22c55e;

  /* ── Extended info / link colours ──────────────────────────────── */
  --info-dark:         #1d4ed8;
  --info-darker:       #1e40af;
  --info-text:         #0369a1;
  --info-text-dark:    #0c4a6e;
  --info-bg-subtle:    #f0f9ff;
  --info-border-hover: #93c5fd;

  /* ── Surface subtle ─────────────────────────────────────────────── */
  --surface-subtle: #f0f0f5;

  /* ── Brand lavender surfaces & borders ──────────────────────────── */
  --surface-lavender:       #eae4f2;
  --surface-lavender-light: #f0eef5;
  --border-lavender:        #e8e4ee;

  /* ── Gradient palette (login / error page backgrounds) ──────────── */
  --gradient-lavender:   #e8dff5;
  --gradient-pink:       #f5e6f0;
  --gradient-periwinkle: #dce8fa;
  --gradient-purple:     #f0e4f7;

  /* ── Dark hero backgrounds ──────────────────────────────────────── */
  --bg-dark:        #0d1117;
  --bg-dark-purple: #1e1b4b;
  --bg-dot:         rgba(30, 27, 75, 0.08);

  /* ── On-dark text / icons ───────────────────────────────────────── */
  --brand-on-dark:      #a78bfa;
  --text-on-dark-muted: #94a3b8;

  /* ── White ──────────────────────────────────────────────────────── */
  --white: #ffffff;

  /* ── Accent / Indigo (admin) ────────────────────────────────────── */
  --accent:      #6366f1;
  --accent-dark: #4f46e5;
  --accent-bg:   rgba(99, 102, 241, 0.1);

  /* ── Orange (cart / alert) ──────────────────────────────────────── */
  --orange:              #c2410c;
  --orange-bg:           #fff7ed;
  --orange-bg-hover:     #ffedd5;
  --orange-border:       #fdba74;
  --orange-border-hover: #fb923c;

  /* ── Role badge ─────────────────────────────────────────────────── */
  --role-bg: #dbeafe;

  /* ── Google sign-in button ──────────────────────────────────────── */
  --google-border:         #dadce0;
  --google-text:           #3c4043;
  --google-bg-hover:       #f8f9fa;
  --google-bg-active:      #f1f3f4;
  --google-border-hover:   #c4c7ca;
  /* Google Maps / branded UI colors */
  --google-dark-text:      #202124;
  --google-secondary-text: #5f6368;
  --google-blue:           #1a73e8;
  --google-surface-border: #e8eaed;

  /* ── Tonal state overlays ───────────────────────────────────────── */
  --tonal-secondary:       rgba(55, 65, 81, 0.08);
  --tonal-secondary-press: rgba(55, 65, 81, 0.12);

  /* ── Shadow & ring extensions ───────────────────────────────────── */
  --shadow-brand-sm:    0 6px 24px rgba(124, 107, 196, 0.12);
  --shadow-brand-hover: 0 4px 14px rgba(124, 107, 196, 0.35);
  --shadow-brand-card:  0 8px 40px rgba(124, 107, 196, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-success:     0 4px 12px rgba(5, 150, 105, 0.30);
  --shadow-success-sm:  0 2px 8px rgba(76, 175, 80, 0.35);
  --shadow-indigo:      0 4px 12px rgba(99, 102, 241, 0.30);
  --shadow-google:      0 1px 6px rgba(60, 64, 67, 0.18);
  --ring-brand:         0 0 0 3px rgba(124, 107, 196, 0.15);
  --ring-info:          0 0 0 2px rgba(37, 99, 235, 0.15);
  --ring-info-glow:     0 0 0 2px rgba(191, 219, 254, 0.33);
  --ring-success-glow:  0 0 0 2px rgba(34, 197, 94, 0.20);

  /* ── Legacy aliases (backward-compat) ───────────────────────────── */
  --color-brand:      var(--brand);
  --color-brand-dark: var(--brand-dark);
  --color-text:       var(--text-primary);
  --color-text-muted: var(--text-muted);
  --color-surface:    var(--surface);
}

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ---------- Page Backgrounds ---------- */

.page-home {
  /* Dark navy gradient matching eligara.ai */
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--eligara-navy) 40%, var(--bg-dark-purple) 70%, var(--bg-dark) 100%);
}

.page-search,
.page-advanced-search,
.page-cases {
  background-color: var(--surface);
  background-image: radial-gradient(circle, var(--bg-dot) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ---------- Hero (Home) ---------- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem;
  text-align: center;
}

.brand {
  font-size: clamp(2.8rem, 14vw, 5.95rem);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--border-brand); /* light lavender on dark bg */
  margin-bottom: 1rem;
  font-family: 'Sora', sans-serif;
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  color: var(--eligara-slate); /* #e2e8f0 — matches eligara.ai */
  margin-bottom: 2.5rem;
  max-width: 720px;
  line-height: 1.25;
}

/* ---------- Search Bar ---------- */

.search-bar {
  display: flex;
  align-items: stretch;
  background: var(--surface-card);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-brand);
  max-width: 720px;
  width: 100%;
  overflow: hidden;
}

.search-field {
  flex: 1;
  padding: 1rem 1.6rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.search-field + .search-field {
  border-left: 1px solid var(--border-lavender);
}

.search-field label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.search-field input {
  border: none;
  outline: none;
  font-size: 0.95rem;
  color: var(--text-primary);
  background: transparent;
  width: 100%;
  font-family: inherit;
}

.search-field input::placeholder {
  color: var(--text-subtle);
}

.search-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 2rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--white);
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  border-radius: var(--radius-full);
  margin: 6px;
  white-space: nowrap;
  transition: opacity var(--transition-base);
}

.search-btn:hover {
  opacity: 0.9;
}

.search-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Search bar – compact variant (topbar on search page) */

.search-bar--compact {
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.35);
  max-width: 700px;
}

.search-bar--compact .search-field {
  padding: 0.8rem 1.4rem;
}

.search-bar--compact .search-field label {
  font-size: 0.65rem;
}

.search-bar--compact .search-field input {
  font-size: 0.88rem;
  color: var(--text-primary);
}

.search-bar--compact .search-field input::placeholder {
  color: var(--gray-400);
}

.search-bar--compact .search-btn {
  gap: 0.4rem;
  padding: 0 1.6rem;
  font-size: 0.9rem;
  margin: 5px;
}

.search-bar--compact .search-btn svg {
  width: 16px;
  height: 16px;
}

/* ---------- Role Boxes (Home) ---------- */

.role-boxes {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}

.role-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1.6rem;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.3);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--eligara-slate);
  cursor: pointer;
  transition: transform var(--transition-base), box-shadow var(--transition-base), background var(--transition-base), border-color var(--transition-base);
}

.role-box:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.4);
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.22);
}

.role-box svg {
  width: 22px;
  height: 22px;
  color: var(--brand-on-dark); /* light violet on dark bg */
  flex-shrink: 0;
}

/* ---------- Stats (Home) ---------- */

.stats {
  display: flex;
  gap: 2.5rem;
  margin-top: 3rem;
  flex-wrap: wrap;
  justify-content: center;
}

.stat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-on-dark-muted); /* muted light on dark bg */
}

.stat svg {
  width: 22px;
  height: 22px;
  color: var(--brand-on-dark);
  flex-shrink: 0;
}

/* ---------- Top Bar (Search) ---------- */

.topbar {
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--eligara-navy) 60%, var(--bg-dark-purple) 100%);
  padding: 1.5rem 2rem 2rem;
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.topbar .back {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--brand-on-dark);
  margin-bottom: 1rem;
}

.topbar .back:hover {
  opacity: 0.8;
}

.topbar-title {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.75rem;
  letter-spacing: 0;
  color: var(--eligara-slate);
}

/* ---------- Results (Search) ---------- */

.results {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.results-header {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.results-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

.results-header .count {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

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

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.2rem;
}

.trial-card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  transition: box-shadow var(--transition-base);
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-badges {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-study-type {
  background: var(--surface-lavender);
  color: var(--brand-dark);
}

.nct {
  font-size: 0.75rem;
  color: var(--info);
  font-weight: 500;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.nct::after,
.nct-id::after {
  content: '\2197'; /* ↗ north-east arrow */
  font-size: 0.85em;
  margin-left: 0.25em;
  vertical-align: super;
  font-family: inherit;
  opacity: 0.85;
}

.card-title-wrap {
  min-height: 8.5rem; /* reserve space for ~6 lines so summary aligns across cards */
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
}

.card-summary {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  background: var(--brand-tint);
  color: var(--brand-dark);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid var(--surface-lavender-light);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.card-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand);
}

.card-link:hover {
  text-decoration: underline;
}

/* Location link inside trial cards */
.tl-card-link {
  color: inherit;
  text-decoration: none;
}
.tl-card-link:hover {
  color: var(--brand);
  text-decoration: underline;
}

/* ---------- Empty State ---------- */

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-subtle);
}

.empty h3 {
  font-size: 1.2rem;
  margin: 1rem 0 0.5rem;
  color: var(--text-secondary);
}

.empty p {
  font-size: 0.95rem;
}

/* ---------- Error Pages ---------- */

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 2rem;
  background: linear-gradient(135deg, var(--gradient-lavender) 0%, var(--gradient-periwinkle) 100%);
}

.error-page h1 {
  font-size: 4rem;
  font-weight: 800;
  color: var(--brand-dark);
  margin-bottom: 0.5rem;
}

.error-page p {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.error-page a {
  color: var(--brand);
  font-weight: 600;
}

.error-page a:hover {
  text-decoration: underline;
}

/* ---------- Advanced Search ---------- */

.adv-search-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.adv-search-content h1 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.adv-search-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.adv-search-main {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
  margin-bottom: 3rem;
}

.patient-info-section,
.checklist-section {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 2rem;
}

.patient-info-section label {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.patient-textarea {
  width: 100%;
  min-height: 280px;
  padding: 1rem;
  border: 2px solid var(--border-lavender);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-primary);
  resize: vertical;
  transition: border-color var(--transition-base);
}

.patient-textarea:focus {
  outline: none;
  border-color: var(--brand);
}

.example-hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-subtle);
}

.example-hint-label {
  font-weight: 500;
}

.example-hint-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: 600;
  color: var(--color-brand);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.example-hint-btn:hover {
  color: var(--color-brand-dark);
}

.btn-analyze {
  margin-top: 1rem;
  width: 100%;
  padding: 0.9rem;
  background: var(--brand);
  color: var(--white);
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-base);
}

.btn-analyze:hover {
  background: var(--brand-dark);
}

.btn-analyze:disabled,
.btn-analyze.processing {
  background: var(--gray-400);
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-analyze.processing {
  background: var(--warning);
  cursor: wait;
  opacity: 1;
}

.auto-analyze-status {
  display: none;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--info);
}

.status-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--info-border);
  border-top: 2px solid var(--info);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.checklist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

.checklist-chevron {
  display: none;
  color: var(--text-subtle);
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.checklist-chevron.collapsed {
  transform: rotate(-90deg);
}

.checklist-body {
  overflow: hidden;
  margin-top: 1.5rem;
  max-height: 2000px;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  opacity: 1;
}

.checklist-body.collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  pointer-events: none;
}

.checklist-section h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0;
}

.checklist-pills {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 1.1rem;
  background: var(--surface-subtle);
  color: var(--text-muted);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.3s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  max-width: fit-content;
}

.pill--satisfied {
  background: linear-gradient(135deg, var(--success-light) 0%, var(--success-mid) 100%);
  color: var(--white);
  box-shadow: var(--shadow-success-sm);
  font-weight: 600;
}

.pill-label {
  font-weight: 600;
}

.pill-value {
  margin-left: 0.25rem;
  font-weight: 400;
}

.checklist-status {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--surface-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
}

.checklist-status.searching {
  background: var(--info-bg);
  color: var(--info);
}

.checklist-status.success {
  background: var(--success-bg);
  color: var(--success-text-dark);
}

.checklist-status.error {
  background: var(--error-bg);
  color: var(--error);
}

.trials-section {
  margin-top: 3rem;
}

.trials-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.loading-indicator {
  text-align: center;
  padding: 3rem;
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  border: 4px solid var(--surface-subtle);
  border-top: 4px solid var(--brand);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-indicator p {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.adv-search-placeholder {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  color: var(--text-subtle);
}

.adv-search-placeholder svg {
  width: 48px;
  height: 48px;
  color: var(--border-brand);
  margin-bottom: 1rem;
}

.adv-search-placeholder h3 {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.adv-search-placeholder p {
  font-size: 0.95rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
  .adv-search-main {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .checklist-header {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .checklist-chevron {
    display: block;
  }

  .checklist-body {
    margin-top: 0;
  }

  .checklist-body:not(.collapsed) {
    margin-top: 1.25rem;
  }
}

@media (max-width: 600px) {
  /* ── Advanced Search ── */
  .adv-search-content {
    padding: 1.5rem 1rem;
  }

  .adv-search-content h1 {
    font-size: 1.4rem;
  }

  .adv-search-main {
    gap: 1rem;
    margin-bottom: 1.5rem;
  }

  .patient-info-section,
  .checklist-section {
    padding: 1.25rem;
  }

  .patient-textarea {
    min-height: 200px;
    font-size: 0.9rem;
  }

  /* ── Hero ── */
  .hero {
    padding: 2.5rem 1.25rem 1.5rem;
    justify-content: flex-start;
    gap: 0;
  }

  .brand {
    margin-bottom: 0.75rem;
  }

  .hero h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
  }

  /* ── Search bar ── */
  .search-bar {
    flex-direction: column;
    border-radius: 20px;
  }

  .search-bar--compact {
    border-radius: 16px;
  }

  .search-field {
    padding: 0.85rem 1.2rem;
  }

  .search-field + .search-field {
    border-left: none;
    border-top: 1px solid var(--border-lavender);
  }

  .search-btn {
    border-radius: var(--radius-full);
    margin: 8px;
    padding: 0.9rem;
    justify-content: center;
  }

  /* ── Role boxes ── */
  .role-boxes {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
  }

  .role-box {
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    gap: 0.4rem;
    border-radius: 10px;
  }

  .role-box svg {
    width: 18px;
    height: 18px;
  }

  /* ── Stats ── */
  .stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem 1.5rem;
    margin-top: 1.75rem;
    text-align: left;
  }

  .stat {
    font-size: 0.85rem;
  }

  /* ── Grid ── */
  .grid {
    grid-template-columns: 1fr;
  }

  /* ── Navbar ── */
  .user-bar {
    padding: 0 0.75rem;
    height: 48px;
  }

  .nav-links {
    gap: 0;
  }

  .nav-link {
    font-size: 0.8125rem;
    padding: 0.35rem 0.5rem;
  }

  /* ── Feedback popup ── */
  .feedback-popup {
    left: 12px;
    right: 12px;
    width: auto;
  }
}

/* ---------- Impersonation Banner ---------- */
.impersonation-banner {
  background: var(--warning-bg-subtle);
  border-bottom: 2px solid var(--warning-border);
  padding: 0.75rem max(1rem, env(safe-area-inset-right)) 0.75rem max(1rem, env(safe-area-inset-left));
  text-align: center;
  font-size: 0.875rem;
  color: var(--warning-text);
}

.impersonation-banner strong {
  font-weight: 600;
}

/* ---------- User Bar & Navigation ---------- */
.user-bar {
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding: 0 max(1.25rem, env(safe-area-inset-right)) 0 max(1.25rem, env(safe-area-inset-left));
  height: 52px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-links {
  display: flex;
  gap: 0.125rem;
  align-items: center;
}

.nav-link {
  color: var(--gray-600);
  font-weight: 500;
  font-size: 0.875rem;
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-full);
  transition: background var(--transition-fast), color var(--transition-fast);
  letter-spacing: -0.01em;
}

.nav-link:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--gray-900);
}

.nav-link.active {
  background: rgba(0, 0, 0, 0.07);
  color: var(--gray-900);
  font-weight: 600;
}

.logo-link {
  display: flex;
  align-items: center;
  line-height: 0;
}

.nav-logo {
  height: 32px;
  width: auto;
  display: block;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-name {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---------- Case Management Buttons ---------- */
.case-management-bar {
  margin-bottom: 2rem;
  padding: 1rem 0;
}

.case-management-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.case-actions-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  flex-shrink: 0;
}

.case-name-wrapper {
  flex: 1;
  min-width: 0;
}

.case-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.case-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0 1rem;
  min-height: 44px; /* Apple HIG minimum touch target */
  border: none;
  border-radius: 10px; /* iOS rounded-rect */
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.00625em;
  cursor: pointer;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
  touch-action: manipulation; /* removes 300ms iOS tap delay */
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  text-decoration: none;
}

.btn-icon {
  font-size: 1.1em;
  line-height: 1;
}

.btn-text {
  line-height: 1;
}

/* MD3 filled button – primary role */
.case-btn--load {
  background: var(--info);
  color: var(--white);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
}

.case-btn--load:hover {
  background: var(--info-dark);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
}

.case-btn--load:active {
  background: var(--info-darker);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
}

/* MD3 filled button – secondary/tonal role */
.case-btn--save {
  background: var(--success);
  color: var(--white);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
}

.case-btn--save:hover {
  background: var(--success-dark);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
}

.case-btn--save:active {
  background: var(--success-darker);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
}

/* MD3 filled button – error role */
.case-btn--danger {
  background: var(--error);
  color: var(--white);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
}

.case-btn--danger:hover {
  background: var(--error-dark);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
}

.case-btn--danger:active {
  background: var(--error-darker);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
}

/* Outlined – secondary action */
.case-btn--secondary {
  background: transparent;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
  box-shadow: none;
}

.case-btn--secondary:hover {
  background: var(--tonal-secondary);
  border-color: var(--gray-400);
}

.case-btn--secondary:active {
  background: var(--tonal-secondary-press);
}

/* Cart link button in trials header */
.case-btn--cart {
  background: var(--orange-bg);
  color: var(--orange);
  border: 1px solid var(--orange-border);
  box-shadow: none;
  text-decoration: none;
}

.case-btn--cart:hover {
  background: var(--orange-bg-hover);
  border-color: var(--orange-border-hover);
}

.case-btn--results {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
  box-shadow: none;
  text-decoration: none;
}
.case-btn--results:hover { background: var(--success-bg-hover); border-color: var(--success-border-hover); }

/* Disabled state */
.case-btn--disabled,
.case-btn--results.case-btn--disabled {
  background: var(--gray-100) !important;
  color: var(--text-subtle) !important;
  border-color: var(--border) !important;
  cursor: not-allowed;
  box-shadow: none !important;
}

.case-btn--disabled:hover,
.case-btn--results.case-btn--disabled:hover {
  background: var(--gray-100) !important;
  color: var(--text-subtle) !important;
  border-color: var(--border) !important;
}

/* Per-trial cart toggle button */
.cart-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  background: var(--surface-card);
  cursor: pointer;
  line-height: 0;
  transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.cart-toggle-btn:hover {
  background: var(--info-bg-subtle);
  border-color: var(--info-border-hover);
  box-shadow: var(--ring-info-glow);
}

.cart-toggle-btn.cart-btn--active {
  background: var(--success-bg);
  border-color: var(--success-border-active);
  box-shadow: var(--ring-success-glow);
}

.cart-toggle-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.card-bottom {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.cart-notes-inline {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.notes-input {
  flex: 1;
  font-size: 0.875rem;
  border: 1px solid var(--gray-300);
  border-radius: 0.375rem;
  padding: 0.375rem 0.625rem;
  outline: none;
  transition: border-color var(--transition-fast);
  min-width: 0;
}

.notes-input:focus {
  border-color: var(--info);
  box-shadow: var(--ring-info);
}

.notes-save-indicator {
  font-size: 0.75rem;
  white-space: nowrap;
  min-width: 3.5rem;
}

/* Readonly notes display */
.card-notes-readonly {
  font-size: 0.8125rem;
  color: var(--gray-600);
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.375rem 0.625rem;
}
.card-notes-label {
  font-weight: 600;
  color: var(--gray-700);
}

.cart-icon {
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  pointer-events: none;
}

.loaded-case-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--info-text-dark);
}

.loaded-case-badge strong {
  font-weight: 600;
  color: var(--info-text);
}

/* ---------- Load Case Dropdown ---------- */
.load-case-dropdown {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
  max-height: 400px;
  overflow-y: auto;
}

.dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.dropdown-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.75rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition-base);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.close-btn:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.case-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  max-height: min(90vh, calc(100dvh - 2rem));
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.modal-body {
  padding: 1.5rem;
}

.modal-body label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
}

.modal-footer .btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  background: linear-gradient(135deg, var(--success) 0%, var(--success) 100%);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}

.modal-footer .btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-success);
}

.modal-footer .btn:active {
  transform: translateY(0);
}


/* ==========================================================================
   Admin Section
   ========================================================================== */

/* Admin Layout */
.admin-page {
  background: var(--surface-admin);
  min-height: 100vh;
}

.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 260px;
  background: var(--eligara-navy);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
}

.admin-sidebar-header {
  padding: 2rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-sidebar-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white);
  margin: 0;
}

.admin-nav {
  flex: 1;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.5rem;
  color: var(--eligara-slate);
  font-size: 0.95rem;
  font-weight: 500;
  transition: all var(--transition-base);
  border-left: 3px solid transparent;
}

.admin-nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--white);
}

.admin-nav-link.active {
  background: var(--accent-bg);
  color: var(--white);
  border-left-color: var(--accent);
}

.admin-nav-icon {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
}

.admin-nav-divider {
  margin: 0.5rem 1.5rem;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-main {
  flex: 1;
  margin-left: 260px;
  padding: 2rem;
  margin-top: 60px; /* Account for user-bar */
}

/* Admin Dashboard */
.admin-dashboard h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 2rem;
}

.admin-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.admin-card {
  background: var(--surface-card);
  border-radius: var(--radius-md);
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all var(--transition-base);
  cursor: pointer;
  display: block;
}

.admin-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.admin-card-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin-card-disabled:hover {
  transform: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.admin-card-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.admin-card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0 0 0.5rem 0;
}

.admin-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
}

/* Admin Users Page */
.admin-users h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 2rem;
}

.users-table-container {
  background: var(--surface-card);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
}

.users-table thead {
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
}

.users-table th {
  text-align: left;
  padding: 1rem 1.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.users-table td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.9rem;
  color: var(--gray-700);
}

.users-table tbody tr:last-child td {
  border-bottom: none;
}

.users-table tbody tr:hover {
  background: var(--gray-50);
}

.user-roles {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.role-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--role-bg);
  color: var(--info-darker);
}

.role-badge-none {
  background: var(--gray-100);
  color: var(--text-muted);
}

.text-muted {
  color: var(--text-subtle);
  font-size: 0.85rem;
}

.btn-secondary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
}

.btn-secondary:hover {
  box-shadow: var(--shadow-indigo);
}

/* ============================================================
   Profile Dropdown Menu
   ============================================================ */

.profile-trigger {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-sm);
  user-select: none;
  transition: background var(--transition-fast);
}

.profile-trigger:hover {
  background: var(--gray-100);
}

/* Avatar */
.profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-initials {
  color: var(--white);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
}

/* Large avatar in dropdown header */
.profile-avatar-lg {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-avatar-lg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-lg .profile-avatar-initials {
  font-size: 1.125rem;
}

.profile-trigger-name {
  font-size: 0.875rem;
  color: var(--gray-700);
  font-weight: 500;
}

.profile-chevron {
  color: var(--text-subtle);
  transition: transform var(--transition-base);
  display: flex;
  align-items: center;
}

.profile-trigger.profile-open .profile-chevron {
  transform: rotate(180deg);
}

/* Dropdown panel */
.profile-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 200;
  overflow: hidden;
}

.profile-trigger.profile-open .profile-dropdown-menu {
  display: block;
}

/* Header: avatar + name + email */
.profile-menu-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.profile-menu-header-text {
  min-width: 0;
}

.profile-menu-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-menu-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Credits row */
.profile-menu-credits {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--info-darker);
  font-weight: 500;
}

.profile-menu-credits-icon {
  font-size: 1rem;
  line-height: 1;
}

/* Divider */
.profile-menu-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0.25rem 0;
}

/* Menu items */
.profile-menu-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 1rem;
  color: var(--gray-700);
  font-size: 0.875rem;
  text-decoration: none;
  transition: background var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.profile-menu-item:hover {
  background: var(--gray-50);
  color: var(--gray-900);
}

.profile-menu-item--danger {
  color: var(--error);
}

.profile-menu-item--danger:hover {
  background: var(--error-bg);
  color: var(--error-dark);
}

.profile-menu-version {
  padding: 0.35rem 1rem 0.5rem;
  font-size: 0.7rem;
  color: var(--text-subtle);
  user-select: text;
}

/* ==========================================================================
   Mobile Improvements (Apple HIG)
   ========================================================================== */

/* Focus indicators for keyboard / switch control users */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}

/* Badge font-size floor on small screens */
@media (max-width: 640px) {
  .badge {
    font-size: 0.75rem;
    padding: 0.3rem 0.7rem;
  }

  .nct {
    font-size: 0.8125rem;
  }

  .card-title {
    min-height: 5rem;
  }

  .card-meta {
    gap: 0.5rem;
    font-size: 0.7rem;
  }

  .modal-content {
    width: calc(100% - 2rem);
    border-radius: var(--radius-md);
  }

  .empty-state__icon {
    width: clamp(3rem, 20vw, 4rem);
    height: clamp(3rem, 20vw, 4rem);
  }
}

/* ============================================================
   Admin Feedback Page
   ============================================================ */

.admin-feedback h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.25rem;
}

.admin-feedback-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.feedback-table-container {
  background: var(--surface-card);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.feedback-table th,
.feedback-table td {
  vertical-align: top;
}

.feedback-td-date {
  white-space: nowrap;
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 130px;
}

.feedback-td-user {
  min-width: 160px;
}

.feedback-user-email {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--gray-800);
}

.feedback-user-id {
  font-size: 0.75rem;
  color: var(--text-subtle);
}

.feedback-td-url {
  max-width: 220px;
}

.feedback-url-link {
  font-size: 0.8rem;
  color: var(--accent);
  word-break: break-all;
}

.feedback-url-link:hover {
  text-decoration: underline;
}

.feedback-td-session {
  max-width: 120px;
}

.feedback-session-id {
  font-size: 0.75rem;
  color: var(--text-muted);
  word-break: break-all;
}

.feedback-td-message {
  min-width: 260px;
}

.feedback-message-text {
  font-size: 0.875rem;
  color: var(--gray-700);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 6rem;
  overflow-y: auto;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  justify-content: center;
}

.pagination-btn {
  padding: 0.5rem 1rem;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--gray-700);
  transition: background var(--transition-fast);
}

.pagination-btn:hover {
  background: var(--gray-100);
}

.pagination-info {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.admin-empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.admin-empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* ============================================================
   Feedback / Bug Report Widget
   ============================================================ */

.feedback-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.feedback-btn:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.feedback-popup {
  position: fixed;
  top: 56px;
  right: 12px;
  width: 340px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.feedback-popup[hidden] {
  display: none;
}

.feedback-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.feedback-popup-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--gray-800);
}

.feedback-popup-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.feedback-popup-close:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.feedback-textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.75rem;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--gray-800);
  line-height: 1.5;
  outline: none;
  transition: border-color var(--transition-fast);
}

.feedback-textarea:focus {
  border-color: var(--brand);
  box-shadow: var(--ring-brand);
}

.feedback-popup-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.feedback-status {
  font-size: 0.8125rem;
  flex: 1;
  min-width: 0;
}

.feedback-status--success {
  color: var(--success);
}

.feedback-status--error {
  color: var(--error-mid);
}

/* ==========================================================================
   Login Page
   ========================================================================== */

.page-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--gradient-lavender) 0%, var(--gradient-pink) 25%, var(--gradient-periwinkle) 50%, var(--gradient-purple) 75%, var(--gradient-lavender) 100%);
}

.login-card {
  background: var(--surface-card);
  border-radius: 20px;
  box-shadow: var(--shadow-brand-card);
  padding: 3rem 2.5rem 2.5rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-brand {
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand-dark);
  font-family: 'Sora', sans-serif;
  margin-bottom: 0.35rem;
}

.login-tagline {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 2.25rem;
  font-weight: 400;
}

/* Google sign-in — follows Google brand guidelines */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1.25rem;
  border: 1.5px solid var(--google-border);
  border-radius: 10px;
  background: var(--surface-card);
  color: var(--google-text);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  letter-spacing: 0.01em;
}

.btn-google:hover {
  background: var(--google-bg-hover);
  box-shadow: var(--shadow-google);
  border-color: var(--google-border-hover);
}

.btn-google:active {
  background: var(--google-bg-active);
}

.btn-google svg {
  flex-shrink: 0;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.75rem 0;
  color: var(--text-subtle);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

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

.sso-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sso-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.sso-input::placeholder {
  color: var(--text-subtle);
}

.sso-input:focus {
  border-color: var(--brand);
  box-shadow: var(--ring-brand);
}

.btn-sso {
  width: 100%;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: var(--white);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition-fast), box-shadow var(--transition-fast);
  letter-spacing: 0.01em;
}

.btn-sso:hover {
  opacity: 0.92;
  box-shadow: var(--shadow-brand-hover);
}

.btn-sso:active {
  opacity: 0.85;
}

.sso-hint {
  font-size: 0.78125rem;
  color: var(--text-subtle);
  margin-top: 0.25rem;
}

.login-alert {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border-subtle);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  text-align: left;
  font-size: 0.875rem;
  color: var(--warning-text-dark);
  line-height: 1.5;
}

.login-alert strong {
  display: block;
  margin-bottom: 0.35rem;
}

.login-alert code {
  background: rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  font-size: 0.85em;
}

.login-alert a {
  color: var(--brand);
  text-decoration: underline;
}

.login-footer {
  margin-top: 2rem;
  font-size: 0.78125rem;
  color: var(--text-subtle);
  line-height: 1.6;
}

/* ==========================================================================
   Toast / Snackbar
   ========================================================================== */

#toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  pointer-events: none;
  max-width: min(22rem, calc(100vw - 2rem));
}

@media (max-width: 600px) {
  #toast-container {
    right: 50%;
    transform: translateX(50%);
    bottom: 1rem;
    width: calc(100vw - 2rem);
    max-width: none;
  }
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.45;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(0.5rem);
  transition: opacity 0.22s ease, transform 0.22s ease;
  border: 1px solid transparent;
  max-width: 100%;
  word-break: break-word;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--hiding {
  opacity: 0;
  transform: translateY(0.5rem);
}

.toast--success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-darker);
}

.toast--error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error);
}

.toast--info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-darker);
}

.toast-message {
  flex: 1;
}

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
  color: inherit;
  opacity: 0.55;
  flex-shrink: 0;
}

.toast-close:hover {
  opacity: 1;
}

/* ==========================================================================
   Confirm Dialog  –  Material Design 3
   ========================================================================== */

.confirm-dialog {
  border: none;
  border-radius: 28px;
  box-shadow: 0 4px 8px 3px rgba(0,0,0,.15), 0 1px 3px rgba(0,0,0,.3);
  padding: 0;
  max-width: min(23rem, calc(100vw - 3rem));
  width: 100%;
  font-family: var(--font-body);
  background: var(--surface-card);
  /* M3 entrance animation */
  animation: confirm-dialog-in 0.2s cubic-bezier(0.2, 0, 0, 1);
}

@keyframes confirm-dialog-in {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(2px);
  animation: confirm-scrim-in 0.22s ease;
}

@keyframes confirm-scrim-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.confirm-dialog-inner {
  padding: 1.5rem 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* M3 dialog icon */
.confirm-dialog-icon {
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 1rem;
  color: var(--error);
  display: flex;
  align-items: center;
  justify-content: center;
}

.confirm-dialog-icon svg {
  width: 100%;
  height: 100%;
}

/* M3 headline-small */
.confirm-dialog-title {
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.75rem;
  color: var(--text-primary);
  margin: 0 0 0.5rem;
  letter-spacing: 0;
}

/* M3 body-medium */
.confirm-dialog-body {
  font-size: 0.875rem;
  line-height: 1.43;
  color: var(--text-muted);
  margin: 0 0 0.25rem;
}

/* M3 action row */
.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
  width: 100%;
}

/* Shared button base */
.confirm-dialog-btn {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.00625rem;
  line-height: 1.25rem;
  padding: 0.625rem 1.5rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: background-color 0.1s ease, box-shadow 0.1s ease;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

/* M3 text button (Cancel) */
.confirm-dialog-btn--text {
  background: transparent;
  color: var(--brand);
}

.confirm-dialog-btn--text:hover {
  background: color-mix(in srgb, var(--brand) 8%, transparent);
}

.confirm-dialog-btn--text:active {
  background: color-mix(in srgb, var(--brand) 12%, transparent);
}

/* M3 filled-tonal (destructive) button */
.confirm-dialog-btn--filled {
  background: var(--error-mid);
  color: var(--white);
}

.confirm-dialog-btn--filled:hover {
  background: var(--error);
  box-shadow: 0 1px 2px rgba(0,0,0,.3), 0 1px 3px 1px rgba(0,0,0,.15);
}

.confirm-dialog-btn--filled:active {
  background: var(--error-dark);
  box-shadow: none;
}

/* Non-destructive variant (confirm-dialog-btn--filled when confirmVariant=primary) */
.confirm-dialog-btn--filled.confirm-dialog-btn--primary {
  background: var(--brand);
}

.confirm-dialog-btn--filled.confirm-dialog-btn--primary:hover {
  background: var(--brand-dark);
}

/* Legacy btn variants kept for backward compat */
.btn--ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn--ghost:hover {
  background: var(--gray-100);
}

.btn--danger {
  background: var(--error-mid);
  border: 1px solid var(--error-mid);
  color: var(--white);
}

.btn--danger:hover {
  background: var(--error);
  border-color: var(--error);
}

.btn--primary {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: var(--white);
}

.btn--primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}
