/* ============================================================
   RAIN Project — Design System v3
   design-taste-frontend · DESIGN_VARIANCE:8 · MOTION_INTENSITY:6 · VISUAL_DENSITY:4
   Brand: KSU Purple · Gold
   Fonts: Outfit (display) · Space Grotesk (body)
   ============================================================ */

/* ── 1. DESIGN TOKENS ──────────────────────────────────────── */
:root {
  /* ── Brand Accent (KSU Purple, refined & desaturated) */
  --accent:        #5e3a9e;
  --accent-dark:   #3d1f78;
  --accent-mid:    #7e5bba;
  --accent-subtle: #f0ecf8;
  --accent-border: rgba(94, 58, 158, 0.18);
  --accent-glow:   rgba(94, 58, 158, 0.18);
  --accent-hover:  #3d1f78;     /* darker accent for hover states */

  /* ── Gold */
  --gold:       #c49a15;
  --gold-dark:  #8a6d00;
  --gold-light: #fdf8e8;

  /* ── Semantic */
  --success: #166534;
  --success-bg: #f0fdf4;
  --warning: #92400e;
  --warning-bg: #fffbeb;
  --danger:  #991b1b;
  --danger-bg: #fef2f2;
  --info:    #1e40af;
  --info-bg: #eff6ff;

  /* ── Surfaces (warm neutral) */
  --bg:        #f6f5f8;
  --bg-2:      #eeeef1;
  --bg-3:      #e2e1e6;     /* hover/interactive bg, one step darker than bg-2 */
  --bg-light:  #f3f2f6;     /* soft light surface variant for form areas */
  --surface:   #ffffff;
  --surface-2: #fafafe;
  --bg-nav:    rgba(248, 247, 245, 0.92);
  --overlay:   rgba(24, 22, 20, 0.5);

  /* ── Borders */
  --border:        #e2e1e6;
  --border-md:     #cdcdd4;
  --border-strong: #b0aeb8;

  /* ── Text */
  --text-1: #16141d;
  --text-2: #4a4658;
  --text-3: #7d7a8a;
  --text-4: #aca9b8;
  /* Legacy aliases */
  --text-primary:   #16141d;
  --text-secondary: #4a4658;
  --text-muted:     #7d7a8a;
  --text-on-accent: #ffffff;

  /* ── Shadows (warm, tinted) */
  --shadow-xs: 0 1px 2px rgba(94, 58, 158, .04);
  --shadow-sm: 0 2px 6px rgba(94, 58, 158, .06), 0 0 0 1px rgba(94, 58, 158, .04);
  --shadow:    0 4px 16px rgba(94, 58, 158, .08), 0 0 0 1px rgba(94, 58, 158, .04);
  --shadow-md: 0 6px 20px rgba(94, 58, 158, .09), 0 0 0 1px rgba(94, 58, 158, .04);
  --shadow-lg: 0 12px 32px rgba(94, 58, 158, .10), 0 0 0 1px rgba(94, 58, 158, .04);
  --shadow-xl: 0 24px 56px rgba(94, 58, 158, .14);
  --shadow-accent: 0 8px 24px rgba(94, 58, 158, .24);
  /* Diffusion shadow (Bento 2.0) */
  --shadow-diffuse: 0 20px 40px -12px rgba(94, 58, 158, .07);

  /* ── Radius */
  --r-xs: 6px;
  --r-sm: 10px;
  --r:    14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-2xl: 36px;
  /* Legacy alias */
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-2xl: 32px;

  /* ── Easings (strong, punchy) */
  --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease:        cubic-bezier(0.4, 0, 0.2, 1);

  /* ── Duration */
  --dur-fast: 150ms;
  --dur-ui:   250ms;
  --dur-page: 320ms;

  /* ── Layout */
  --nav-height: 68px;
  --max-w:      1400px;
  --page-px:    clamp(1rem, 4vw, 2rem);

  /* ── Typography */
  --font:         'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-data:    'Space Grotesk', -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', 'Courier New', monospace;
}

/* ── 2. RESET + BASE ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg); background-image: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(94,58,158,.03) 0%, transparent 70%);
  color: var(--text-1);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  font-size: 0.9375rem;
  letter-spacing: -0.005em;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: var(--font); border: none; background: none; }
input, select, textarea { font-family: var(--font); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text-1);
}

/* ── 3. SCROLLBAR ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ── 4. NAVBAR ─────────────────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--bg-nav);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  border-bottom: 1px solid transparent;
  z-index: 1000;
  transition:
    border-color var(--dur-ui) ease,
    box-shadow var(--dur-ui) ease;
}

.navbar.scrolled {
  border-bottom-color: rgba(94, 58, 158, 0.08);
  box-shadow: 0 1px 0 var(--border-md), 0 4px 20px rgba(94, 58, 158, .06);
}

.nav-container {
  display: flex;
  align-items: center;
  height: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--page-px);
  gap: .5rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-shrink: 0;
  text-decoration: none;
  margin-right: .75rem;
  outline: none;
}

@media (hover: hover) and (pointer: fine) {
  .nav-brand:hover .nav-logo { transform: scale(1.05); }
}

.nav-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  transition: transform 250ms var(--ease-spring); filter: drop-shadow(0 1px 3px rgba(94, 58, 158, .12));
}

.nav-brand-text { display: flex; flex-direction: column; line-height: 1.15; }

.nav-title {
  font-family: var(--font-heading);
  font-size: .9375rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.02em;
}

.nav-subtitle {
  font-size: .6875rem;
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: 0;
}

/* Nav links */
.nav-links {
  display: flex;
  align-items: center;
  gap: .125rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .375rem .625rem;
  border-radius: var(--r-sm);
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font);
  transition: color var(--dur-fast) ease, background var(--dur-fast) ease;
  white-space: nowrap;
  letter-spacing: 0;
  position: relative;
}

@media (hover: hover) and (pointer: fine) {
  .nav-link:hover:not(.active) {
    color: var(--text-1);
    background: var(--bg-2);
  }
}

.nav-link.active {
  box-shadow: 0 0 0 1px rgba(94, 58, 158, .08);
  color: var(--accent);
  background: var(--accent-subtle);
  font-weight: 600;
}

/* Nav auth area */
.nav-auth {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-left: auto;
  flex-shrink: 0;
}

/* Auth loading */
.auth-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

/* Sign in button */
.btn-signin {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .4375rem .875rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-mid));
  color: #fff;
  border-radius: var(--r-sm);
  font-size: .8125rem;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) ease;
  white-space: nowrap;
  letter-spacing: 0;
}

@media (hover: hover) and (pointer: fine) {
  .btn-signin:hover {
    background: var(--accent-dark);
    box-shadow: var(--shadow-accent);
    transform: translateY(-1px);
  }
}

.btn-signin:active {
  transform: scale(0.97);
  transition-duration: 100ms;
}

/* User menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.user-avatar-link, .user-name-link {
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-sm);
  transition: opacity var(--dur-fast) ease;
}

@media (hover: hover) and (pointer: fine) {
  .user-avatar-link:hover, .user-name-link:hover { opacity: .75; }
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-md);
  transition: border-color var(--dur-fast) ease;
}

@media (hover: hover) and (pointer: fine) {
  .user-avatar:hover { border-color: var(--accent); }
}

.user-name {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-1);
  padding: 0 .25rem;
}

.btn-signout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  color: var(--text-3);
  transition: color var(--dur-fast) ease, background var(--dur-fast) ease, border-color var(--dur-fast) ease;
  cursor: pointer;
  background: none;
}

@media (hover: hover) and (pointer: fine) {
  .btn-signout:hover {
    color: var(--danger);
    background: var(--danger-bg);
    border-color: rgba(153, 27, 27, .2);
  }
}

/* Hamburger */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  gap: 5px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: .25rem;
  transition: background var(--dur-fast) ease, border-color var(--dur-fast) ease;
  touch-action: manipulation; /* eliminate 300ms tap delay on mobile */
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1001; /* above nav-links dropdown */
}

.nav-hamburger span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--text-2);
  border-radius: 2px;
  transition: transform var(--dur-ui) var(--ease-out), opacity var(--dur-ui) ease, width var(--dur-ui) ease;
}

@media (hover: hover) and (pointer: fine) {
  .nav-hamburger:hover { background: var(--bg-2); border-color: var(--border-md); }
}

/* Mobile nav items */
.nav-mobile-only { display: none !important; }
.nav-mobile-divider { display: none !important; }
.nav-mobile-btn {
  width: 100%;
  text-align: left;
  padding: .625rem .875rem;
  border-radius: var(--r-sm);
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font);
  transition: color var(--dur-fast) ease, background var(--dur-fast) ease;
}

/* Notification Bell */
.notif-bell {
  position: relative;
  flex-shrink: 0;
}

.notif-bell-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: color var(--dur-fast) ease, background var(--dur-fast) ease, border-color var(--dur-fast) ease;
  font-size: .9375rem;
}

@media (hover: hover) and (pointer: fine) {
  .notif-bell-btn:hover {
    color: var(--text-1);
    background: var(--bg-2);
    border-color: var(--border-md);
  }
}

.notif-badge {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 18px;
  height: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-mid));
  color: #fff;
  border-radius: 99px;
  font-size: .625rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg);
  animation: notif-pop 300ms var(--ease-spring);
}

@keyframes notif-pop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  transform-origin: top right;
  animation: dropdown-enter 180ms var(--ease-out) forwards;
}

@keyframes dropdown-enter {
  from { opacity: 0; transform: scale(0.94) translateY(-6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

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

.notif-list { max-height: 320px; overflow-y: auto; }

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--dur-fast) ease;
  cursor: pointer;
}

.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--accent-subtle); }

@media (hover: hover) and (pointer: fine) {
  .notif-item:hover { background: var(--bg-2); }
}

.notif-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-mid));
  flex-shrink: 0;
  margin-top: .375rem;
}

.notif-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-3);
  font-size: .875rem;
}

/* ── 5. PAGE LAYOUT ────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.page-content {
  flex: 1;
  padding-top: var(--nav-height);
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
  padding-left: var(--page-px);
  padding-right: var(--page-px);
  padding-bottom: 3rem;
}

/* Page transitions */
@keyframes page-enter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes page-exit {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-6px); }
}

.page-entering {
  animation: page-enter var(--dur-page) var(--ease-out) forwards;
}

.page-exiting {
  animation: page-exit 180ms var(--ease-in-out) forwards;
  pointer-events: none;
}

/* ── 6. FOOTER ─────────────────────────────────────────────── */
.app-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: auto;
}

.footer-bottom {
  padding: 1.25rem var(--page-px);
}

.footer-bottom-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  font-size: .75rem;
  color: var(--text-3);
}

.footer-auth-link {
  transition: opacity 200ms ease;
}

/* ── 7. HERO — SPLIT SCREEN ────────────────────────────────── */
.hero-split {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  align-items: center;
  gap: 3rem;
  min-height: clamp(460px, 68vh, 740px);
  padding: 5rem var(--page-px) 4rem;
  overflow: hidden;
}

/* Subtle purple-to-transparent radial that fades toward right */
.hero-split::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 90% at 20% 50%,
    rgba(90,58,143,.07) 0%, transparent 70%);
  pointer-events: none;
}

/* Particle canvas */
#hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: .18;
  z-index: 1;
}

/* Content column */
.hero-split-left {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Lab label badge */
.hero-label {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .3125rem .875rem;
  background: rgba(90,58,143,.08);
  border: 1px solid rgba(90,58,143,.2);
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .03em;
  width: fit-content;
}

.hero-label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold, #c8a84b);
  animation: pulse-dot 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(0.8); }
}

.hero-title {
  font-family: var(--font-heading);
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--text-1);
}

.hero-typewriter { color: var(--accent); }

.hero-title .cursor-blink::after {
  content: '|';
  animation: blink-cursor 1s step-end infinite;
  color: var(--accent);
  font-weight: 300;
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.hero-desc {
  font-size: 1rem;
  line-height: 1.78;
  color: var(--text-2);
  max-width: 52ch;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

/* Image column */
.hero-split-right {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-split-right img {
  width: 100%;
  max-width: 680px;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  display: block;
}

/* Decorative blobs hidden */
.hero-blob { display: none; }

/* ── 8. SECTION TITLES ─────────────────────────────────────── */
.section-title {
  display: flex;
  align-items: center;
  gap: .625rem;
  font-family: var(--font-heading);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.025em;
  margin-bottom: 1.25rem;
}

.section-title i, .section-title .icon {
  font-size: 1.125rem;
}

.text-accent  { color: var(--accent) !important; }
.text-purple  { color: var(--accent) !important; }
.text-gold    { color: var(--gold) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger  { color: var(--danger) !important; }
.text-info    { color: var(--info) !important; }
.text-muted   { color: var(--text-3) !important; }
.text-sm      { font-size: .875rem !important; }
.text-xs      { font-size: .75rem !important; }
.fw-600       { font-weight: 600 !important; }
.fw-700       { font-weight: 700 !important; }
.mt-1 { margin-top: .5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }
.mb-1 { margin-bottom: .5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }

/* ── 9. CARDS ──────────────────────────────────────────────── */
/* Spotlight border: JS sets --spotlight-x/y via mousemove */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition:
    transform 220ms var(--ease-out),
    box-shadow 220ms ease,
    border-color 220ms ease;
}

/* Spotlight glow border */
.card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: radial-gradient(
    280px circle at var(--spotlight-x, 50%) var(--spotlight-y, 50%),
    rgba(94, 58, 158, .14),
    transparent 70%
  );
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
  z-index: 0;
}

@media (hover: hover) and (pointer: fine) {
  .card:hover {
  transform: translateY(-3px); transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-md); }
  .card:hover::before { opacity: 1; }
}

/* Ensure card content stays above spotlight */
.card > * { position: relative; z-index: 1; }

.card.no-lift {
  transition: none;
}

@media (hover: hover) and (pointer: fine) {
  .card.no-lift:hover { transform: none; box-shadow: var(--shadow-sm); }
}

/* ── 10. BUTTONS ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4375rem;
  padding: .5625rem 1.0625rem;
  border-radius: var(--r-sm);
  font-size: .875rem;
  font-weight: 600;
  font-family: var(--font);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: -0.005em;
  position: relative;
  overflow: hidden;
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) ease,
    box-shadow var(--dur-fast) ease,
    color var(--dur-fast) ease,
    transform var(--dur-fast) var(--ease-out);
  user-select: none;
  -webkit-user-select: none;
}

/* Ripple layer */
.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transform: scale(0);
  animation: ripple-expand 550ms var(--ease-out) forwards;
  pointer-events: none;
  width: 60px;
  height: 60px;
  margin-left: -30px;
  margin-top: -30px;
}

@keyframes ripple-expand {
  to { transform: scale(6); opacity: 0; }
}

/* Active press feedback — Emil */
.btn:active:not(:disabled) {
  transform: scale(0.97);
  transition-duration: 100ms;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-mid));
  color: #fff;
  border-color: var(--accent);
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not(:disabled) {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    box-shadow: var(--shadow-accent);
    transform: translateY(-1px);
  }
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-1);
  border-color: var(--border);
}

@media (hover: hover) and (pointer: fine) {
  .btn-secondary:hover:not(:disabled) {
    background: var(--bg-2);
    border-color: var(--border-md);
  }
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(153, 27, 27, .25);
}

@media (hover: hover) and (pointer: fine) {
  .btn-danger:hover:not(:disabled) {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
  }
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  .btn-ghost:hover:not(:disabled) {
    background: var(--bg-2);
    color: var(--text-1);
  }
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* Sizes */
.btn-xs { padding: .25rem .5rem; font-size: .75rem; border-radius: var(--r-xs); }
.btn-sm { padding: .375rem .75rem; font-size: .8125rem; }
.btn-lg { padding: .6875rem 1.375rem; font-size: 1rem; border-radius: var(--r); }

/* Magnetic hero buttons */
.btn-hero-primary {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1.5rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-mid));
  color: #fff;
  border-radius: var(--r);
  font-size: .9375rem;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    transform 200ms var(--ease-spring),
    box-shadow 200ms ease;
  white-space: nowrap;
  letter-spacing: -0.01em;
  position: relative;
  overflow: hidden;
}

@media (hover: hover) and (pointer: fine) {
  .btn-hero-primary:hover {
    background: var(--accent-dark);
    box-shadow: var(--shadow-accent);
  }
}

.btn-hero-primary:active { transform: scale(0.97); transition-duration: 100ms; }

.btn-hero-secondary {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6875rem 1.4375rem;
  background: var(--surface);
  color: var(--text-1);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: .9375rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) ease,
    box-shadow var(--dur-fast) ease,
    transform 200ms var(--ease-spring);
  white-space: nowrap;
  letter-spacing: -0.01em;
  text-decoration: none;
  box-shadow: var(--shadow-xs);
}

@media (hover: hover) and (pointer: fine) {
  .btn-hero-secondary:hover {
    background: var(--bg-2);
    border-color: var(--border-md);
    box-shadow: var(--shadow-sm);
  }
}

.btn-hero-secondary:active { transform: scale(0.97); transition-duration: 100ms; }

/* ── 11. RESEARCH — ZIG-ZAG GRID ───────────────────────────── */
.research-zig {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.research-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  cursor: default;
  transition:
    transform 220ms var(--ease-out),
    box-shadow 220ms ease,
    border-color 220ms ease;
}

/* All four cards in an even 2×2 grid */
.research-zig .research-card:first-child {
  grid-column: auto;
}

.research-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: radial-gradient(
    260px circle at var(--spotlight-x, 50%) var(--spotlight-y, 50%),
    rgba(94, 58, 158, .12),
    transparent 70%
  );
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .research-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--border-md);
  }
  .research-card:hover::before { opacity: 1; }
}

.research-card > * { position: relative; z-index: 1; }

.research-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--r);
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 1.125rem;
  flex-shrink: 0;
}

.research-card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.research-card h3 i {
  color: var(--accent);
  font-size: .9375rem;
}

.research-card p {
  font-size: .875rem;
  color: var(--text-2);
  line-height: 1.7;
}

/* Legacy grid class (keep compatible) */
.research-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* ── 12. LEADERSHIP CARD ───────────────────────────────────── */
.leadership-card { position: relative; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem; position: relative; overflow: hidden;
  position: relative;
  overflow: hidden;
}

.leadership-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}

.leadership-card h3 {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--text-1);
  margin-bottom: .375rem;
  letter-spacing: -0.025em;
}

.leadership-card .role {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: .01em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.leadership-card p {
  font-size: .9375rem;
  color: var(--text-2);
  line-height: 1.75;
  max-width: none;
  margin-bottom: 1.25rem;
}

.award-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}

.award-badge {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .3125rem .75rem;
  background: var(--gold-light);
  border: 1px solid rgba(181, 144, 16, .25);
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--gold-dark);
}

.award-badge i { color: var(--gold); }

/* ── 13. RESEARCH AREAS ────────────────────────────────────── */
.research-areas-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.research-areas-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .375rem 2rem;
}

.research-area-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
  color: var(--text-2);
  line-height: 1.4;
}

.research-area-item:nth-last-child(-n+2) { border-bottom: none; }

.research-area-item::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-mid));
  flex-shrink: 0;
  opacity: .6;
}

/* ── 14. SCROLL ANIMATIONS ─────────────────────────────────── */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity 500ms var(--ease-out),
    transform 500ms var(--ease-out);
  transition-delay: calc(var(--i, 0) * 55ms);
}

.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── 15. FORM ELEMENTS ─────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .375rem; }

.form-label {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.005em;
}

.form-input {
  width: 100%;
  padding: .5625rem .875rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .9375rem;
  color: var(--text-1);
  font-family: var(--font);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
  outline: none;
  line-height: 1.5;
}

.form-input::placeholder { color: var(--text-4); }

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94, 58, 158, .12);
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

select.form-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23837f79' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2.25rem;
}

.form-helper {
  font-size: .75rem;
  color: var(--text-3);
}

/* ── 16. PAGE HEADER ───────────────────────────────────────── */
.page-header {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .375rem;
  padding: 2.5rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.page-header h1 {
  display: flex;
  align-items: center;
  gap: .625rem;
  font-family: var(--font-heading);
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.03em;
}

.page-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  border-radius: var(--r-sm);
  color: var(--accent);
  font-size: 1rem;
}

.page-header p {
  font-size: .9375rem;
  color: var(--text-2);
  max-width: 60ch;
}

/* ── 17. MODALS ────────────────────────────────────────────── */
.modal-overlay {
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: overlay-in 180ms ease forwards;
}

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

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modal-enter 240ms var(--ease-out) forwards;
  transform-origin: center;
}

@keyframes modal-enter {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header h3 {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-1);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-xs);
  border: none;
  background: var(--bg-2);
  color: var(--text-3);
  cursor: pointer;
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}

@media (hover: hover) and (pointer: fine) {
  .modal-close:hover { background: var(--danger-bg); color: var(--danger); }
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

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

.modal-overlay.hidden { display: none; }

/* ── 18. TOAST NOTIFICATIONS ───────────────────────────────── */
.toast-container {
  position: fixed;
  top: calc(var(--nav-height) + 1rem);
  right: 1rem;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
  max-width: 360px;
  width: calc(100vw - 2rem);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toast-enter 280ms var(--ease-out) forwards;
  transition: transform 220ms var(--ease-out), opacity 220ms ease;
}

@keyframes toast-enter {
  from { opacity: 0; transform: translateX(20px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

.toast.toast-exit {
  animation: toast-exit 180ms var(--ease-in-out) forwards;
}

@keyframes toast-exit {
  to { opacity: 0; transform: translateX(20px) scale(0.95); }
}

.toast-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: .0625rem;
  font-size: .875rem;
  border-radius: 50%;
}

.toast-message {
  flex: 1;
  font-size: .875rem;
  line-height: 1.5;
  color: var(--text-1);
}

.toast-success { border-left: 3px solid var(--success); }
.toast-success .toast-icon { color: var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-error   .toast-icon { color: var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info    { border-left: 3px solid var(--info); }
.toast-info    .toast-icon { color: var(--info); }

/* ── 19. SKELETON LOADERS ──────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-2) 25%,
    var(--border) 50%,
    var(--bg-2) 75%
  );
  background-size: 400% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--r-sm);
}

@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.skeleton-text  { height: 1em; width: 100%; margin-bottom: .5rem; }
.skeleton-title { height: 1.5em; width: 60%; margin-bottom: .75rem; }
.skeleton-card  { height: 120px; width: 100%; }

/* ── 20. BADGES + STATUS ───────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .1875rem .5rem;
  border-radius: 99px;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.badge-purple, .badge-accent { background: var(--accent-subtle); color: var(--accent); }
.badge-gold    { background: var(--gold-light); color: var(--gold-dark); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  }
.badge-info    { background: var(--info-bg);    color: var(--info);    }
.badge-neutral { background: var(--bg-2); color: var(--text-2); }

/* ── 21. TABLES ────────────────────────────────────────────── */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}

table.data-table {
  width: auto;
  border-collapse: collapse;
  font-size: .8125rem;
}

table.data-table th {
  background: var(--bg-2);
  padding: .625rem .875rem;
  text-align: left;
  font-size: .6875rem;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: .06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  min-width: 120px;
  position: sticky;
  top: 0;
  z-index: 1;
}

table.data-table td {
  padding: .625rem .875rem;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  white-space: normal;
  word-break: break-word;
  max-width: 220px;
  min-width: 80px;
  vertical-align: top;
}

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

@media (hover: hover) and (pointer: fine) {
  table.data-table tbody tr:hover td { background: var(--bg-2); }
}

/* ── 22. UPLOAD PAGE ───────────────────────────────────────── */
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  border: 2px dashed var(--border-md);
  border-radius: var(--r-lg);
  background: var(--bg-2);
  text-align: center;
  cursor: pointer;
  transition:
    border-color 180ms ease,
    background 180ms ease;
  gap: 1rem;
}

@media (hover: hover) and (pointer: fine) {
  .upload-zone:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
  }
}

.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-subtle);
  transform: scale(1.01);
}

.upload-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  border-radius: var(--r);
  color: var(--accent);
  font-size: 1.375rem;
}

.upload-zone h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-1);
}

.upload-zone p {
  font-size: .875rem;
  color: var(--text-3);
}

/* Storage file browser */
.storage-browser {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
}

.storage-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .875rem 1rem;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.storage-breadcrumb {
  display: flex;
  align-items: center;
  gap: .25rem;
  font-size: .8125rem;
  color: var(--text-3);
  flex: 1;
  overflow: hidden;
  flex-wrap: wrap;
}

.storage-breadcrumb span { color: var(--text-2); font-weight: 600; }

.storage-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--dur-fast) ease;
}

.storage-item:last-child { border-bottom: none; }

@media (hover: hover) and (pointer: fine) {
  .storage-item:hover { background: var(--bg-2); }
}

.storage-item-icon { color: var(--accent); font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.storage-item-name { flex: 1; font-size: .875rem; color: var(--text-1); font-weight: 500; }
.storage-item-meta { font-size: .75rem; color: var(--text-3); }

/* Selected folder highlight */
.storage-item-selected {
  background: rgba(90,58,143,.08) !important;
  border-left: 3px solid var(--accent);
  padding-left: calc(1rem - 3px);
}
.storage-item-selected .storage-item-name { color: var(--accent); font-weight: 600; }

/* Navigate-into-subfolder button (chevron on right) */
.storage-item-nav-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-3);
  font-size: .75rem;
  cursor: pointer;
  transition: background 150ms, border-color 150ms, color 150ms, transform 120ms var(--ease-out);
  margin-left: auto;
}
@media (hover: hover) and (pointer: fine) {
  .storage-item-nav-btn:hover {
    background: linear-gradient(135deg, var(--accent), var(--accent-mid));
    border-color: var(--accent);
    color: #fff;
    transform: translateX(2px);
  }
}
.storage-item-nav-btn:active { transform: scale(.92); }

/* "Click to select · → to open" hint in section label */
.storage-section-hint {
  font-size: .6875rem;
  color: var(--text-4, #aaa);
  font-weight: 400;
  margin-left: .375rem;
}

/* Hamburger open → X animation */
.nav-hamburger.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; width: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

.storage-file-row {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: .8125rem;
}

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

@media (hover: hover) and (pointer: fine) {
  .storage-file-row:hover { background: var(--bg-2); }
}

/* ── 23. PROGRESS + LOADING ────────────────────────────────── */
.progress {
  width: 100%;
  height: 6px;
  background: var(--bg-2);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-mid));
  border-radius: 99px;
  transition: width 300ms var(--ease-out);
}

/* Spinners */
.spinner-sm {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-lg {
  width: 52px; height: 52px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Loading states */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 4rem 2rem;
  text-align: center;
}

.loading-state p { color: var(--text-3); font-size: .9375rem; }

/* Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  padding: 4rem 2rem;
  text-align: center;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-2);
  border-radius: var(--r-lg);
  color: var(--text-3);
  font-size: 1.5rem;
  margin-bottom: .25rem;
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-1);
}

.empty-state p {
  font-size: .875rem;
  color: var(--text-3);
  max-width: 32ch;
}

/* ── 24. VISUALIZATIONS PAGE ───────────────────────────────── */
.viz-builder {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.25rem;
  align-items: start;
}

.viz-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: calc(var(--nav-height) + 1rem);
}

.viz-panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}

.viz-panel-body { padding: 1.25rem; display: flex; flex-direction: column; gap: .875rem; }

.viz-canvas-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 360px;
}

.chart-canvas-wrap canvas {
  width: 100% !important;
  max-width: 100% !important;
}

.viz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease, transform 200ms var(--ease-out);
  box-shadow: var(--shadow-sm);
}

@media (hover: hover) and (pointer: fine) {
  .viz-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(94, 58, 158, .1);
    transform: translateY(-1px);
  }
}

.viz-card.selected {
  border-color: var(--accent);
  background: var(--accent-subtle);
  box-shadow: 0 0 0 3px rgba(94, 58, 158, .1);
}

/* Viz gallery */
.viz-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.viz-gallery-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform 200ms var(--ease-out), box-shadow 200ms ease;
  box-shadow: var(--shadow-sm);
}

@media (hover: hover) and (pointer: fine) {
  .viz-gallery-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
  }
}

.viz-gallery-thumb {
  height: 160px;
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-4);
  font-size: 2rem;
  border-bottom: 1px solid var(--border);
}

.viz-gallery-info { padding: 1rem; }

/* ── 25. VIEW DATA PAGE ────────────────────────────────────── */
.view-data-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.25rem;
  align-items: start;
}

.file-tree {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: calc(var(--nav-height) + 1rem);
  max-height: calc(100vh - var(--nav-height) - 2rem);
  overflow-y: auto;
}

.data-view-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── 26. DATA SCHEDULE ─────────────────────────────────────── */
.schedule-grid {
  display: grid;
  gap: 1rem;
}

.schedule-row {
  display: grid;
  grid-template-columns: 200px 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: .875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-fast) ease;
}

@media (hover: hover) and (pointer: fine) {
  .schedule-row:hover { border-color: var(--border-md); }
}

/* ── 27. PROFILE PAGE ──────────────────────────────────────── */
.profile-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.profile-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  box-shadow: var(--shadow);
}

.profile-info h2 {
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: .25rem;
}

.profile-info p { font-size: .875rem; color: var(--text-3); }

/* ── 28. ADMIN PAGE ────────────────────────────────────────── */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: .25rem;
  position: relative;
  overflow: hidden;
  transition: transform 200ms var(--ease-out), box-shadow 200ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
}

.stat-card .stat-label {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.stat-card .stat-value {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.04em;
  line-height: 1;
}

.stat-card .stat-sub {
  font-size: .75rem;
  color: var(--text-3);
}

/* Admin access list */
.access-list { display: flex; flex-direction: column; gap: 0; }

.access-item {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--dur-fast) ease;
}

.access-item:last-child { border-bottom: none; }

@media (hover: hover) and (pointer: fine) {
  .access-item:hover { background: var(--bg-2); }
}

.access-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.access-info { flex: 1; min-width: 0; }
.access-name { font-size: .875rem; font-weight: 600; color: var(--text-1); }
.access-email { font-size: .75rem; color: var(--text-3); }
.access-actions { display: flex; align-items: center; gap: .375rem; }

/* Audit log */
.audit-list { display: flex; flex-direction: column; gap: 0; }

.audit-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .8125rem;
}

.audit-item:last-child { border-bottom: none; }

.audit-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border-md);
  flex-shrink: 0;
  margin-top: .375rem;
}

.audit-text { flex: 1; color: var(--text-2); line-height: 1.5; }
.audit-time { color: var(--text-3); font-size: .75rem; white-space: nowrap; flex-shrink: 0; }

/* ── 29. CONTACT PAGE ──────────────────────────────────────── */
.contact-top-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.contact-name-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.contact-info-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  border-radius: var(--r-sm);
  color: var(--accent);
  font-size: .875rem;
  flex-shrink: 0;
}

/* ── 30. NOT FOUND ─────────────────────────────────────────── */
.not-found-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6rem 2rem;
  gap: 1rem;
}

.not-found-code {
  background: linear-gradient(135deg, var(--accent-subtle), var(--gold-light));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  font-family: var(--font-heading);
  font-size: 7rem;
  font-weight: 900;
  color: var(--border-md);
  line-height: 1;
  letter-spacing: -0.05em;
}

.not-found-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-1);
}

.not-found-desc { color: var(--text-3); font-size: .9375rem; max-width: 36ch; }

/* ── 31. UTILITY LAYOUT ────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }

.hidden { display: none !important; }

/* ── 32. PAGINATION ────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: .375rem;
  justify-content: center;
  flex-wrap: wrap;
  padding: 1rem 0;
}

.pagination-btn, .pagination-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 .625rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: .8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease;
  font-family: var(--font);
}

.pagination-page.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-mid));
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

@media (hover: hover) and (pointer: fine) {
  .pagination-btn:hover:not(:disabled),
  .pagination-page:hover:not(.active) {
    background: var(--bg-2);
    border-color: var(--border-md);
    color: var(--text-1);
  }
}

.pagination-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── 33. TABS ──────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: .625rem .875rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--dur-fast) ease, border-color var(--dur-fast) ease;
  font-family: var(--font);
  margin-bottom: -1px;
  white-space: nowrap;
  letter-spacing: 0;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

@media (hover: hover) and (pointer: fine) {
  .tab-btn:hover:not(.active) { color: var(--text-1); }
}

/* ── 34. VIZ LIST ──────────────────────────────────────────── */
.viz-list { display: flex; flex-direction: column; gap: 0; }

.viz-list-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--dur-fast) ease;
  font-size: .875rem;
}

.viz-list-item:last-child { border-bottom: none; }

@media (hover: hover) and (pointer: fine) {
  .viz-list-item:hover { background: var(--bg-2); }
}

.viz-list-item .viz-thumb {
  width: 48px; height: 36px;
  background: var(--bg-2);
  border-radius: var(--r-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: .875rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

/* ── 35. INPUT GROUPS + RANGE SLIDERS ─────────────────────── */
.input-group {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94, 58, 158, .12);
}

.input-group .form-input {
  border: none;
  box-shadow: none;
  border-radius: 0;
}

.input-group .form-input:focus { border-color: transparent; box-shadow: none; }

.input-group-addon {
  display: flex;
  align-items: center;
  padding: 0 .75rem;
  background: var(--bg-2);
  border-right: 1.5px solid var(--border);
  color: var(--text-3);
  font-size: .875rem;
  flex-shrink: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--bg-2);
  border-radius: 99px;
  outline: none;
  accent-color: var(--accent);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-mid));
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(94, 58, 158, .3);
  transition: transform 120ms ease;
}

input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* ── 36. CHECKBOXES + RADIOS ───────────────────────────────── */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
  width: 16px; height: 16px;
  cursor: pointer;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-size: .875rem;
  color: var(--text-2);
}

/* ── 37. OFFLINE BANNER ────────────────────────────────────── */
#offline-banner {
  position: fixed;
  top: var(--nav-height);
  left: 0; right: 0;
  z-index: 999;
  background: var(--danger);
  color: #fff;
  text-align: center;
  padding: .5rem 1rem;
  font-size: .8125rem;
  font-weight: 600;
}

/* ── 38. CONFETTI CANVAS ───────────────────────────────────── */
#confetti-canvas {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 99998;
  display: none;
}

/* ── 39. LEGACY / COMPAT ───────────────────────────────────── */
/* Keep these so existing JS page renderers work */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

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

.divider {
  height: 1px;
  background: var(--border);
  margin: 1rem 0;
}

/* Cursor elements — hidden (custom cursors banned per design principles) */
.cursor-dot, .cursor-ring { display: none !important; }

/* ── 39b. ALGORITHMIC ART CARD ─────────────────────────────── */
.algo-art-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  min-height: 260px;
  position: relative;
  transition: box-shadow 300ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .algo-art-card:hover { box-shadow: var(--shadow-lg); }
}

.algo-art-canvas {
  position: relative;
  background: #0e0b08;
  overflow: hidden;
  min-height: 260px;
}

/* Mini preview canvas injected by JS */
.algo-art-canvas canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

.algo-art-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: .875rem;
  padding: 2rem 1.75rem;
}

.algo-art-label {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
}

.algo-art-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.algo-art-desc {
  font-size: .875rem;
  color: var(--text-2);
  line-height: 1.75;
  max-width: 44ch;
}

/* ── 40. RESPONSIVE — 1200px ───────────────────────────────── */
@media (max-width: 1200px) {
  .viz-builder { grid-template-columns: 280px 1fr; }
  .view-data-grid { grid-template-columns: 260px 1fr; }
}

/* ── 41. RESPONSIVE — 1024px ───────────────────────────────── */
@media (max-width: 1024px) {
  :root { --nav-height: 64px; }

  .hero-split {
    grid-template-columns: 1fr 1fr;
    min-height: auto;
    padding: 2.5rem 0 2rem;
    gap: 2rem;
  }

  .hero-split-left { padding-right: 0; }
  .hero-blob-1 { display: none; }

  .hero-title { font-size: clamp(2rem, 6vw, 3rem); }

  .viz-builder {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .viz-panel { position: static; }

  /* Config panel must scroll with the page on single-column layout */
  .viz-config-panel {
    position: static;
    max-height: none;
    overflow-y: visible;
  }

  .view-data-grid { grid-template-columns: 1fr; }
  .file-tree { position: static; max-height: 300px; }

  .contact-top-grid { grid-template-columns: 1fr; }

  .research-zig { grid-template-columns: 1fr; }
  .research-zig .research-card:first-child { grid-column: 1; }
}

/* ── 42. RESPONSIVE — 768px ────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --page-px: 1rem;
    --nav-height: 60px;
  }

  /* Navbar — transform-based show/hide (avoids display:none toggle failures) */
  .nav-links {
    display: flex !important;          /* always in DOM + flex, never toggled */
    flex-direction: column;
    align-items: stretch;
    gap: .25rem;
    padding: .75rem .75rem 1rem;
    /* positioning */
    position: fixed;
    top: var(--nav-height);
    left: 0; right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    z-index: 1002;
    /* hidden state — slid up + invisible */
    transform: translateY(-110%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
      transform 220ms var(--ease-out),
      opacity   180ms ease,
      visibility 0ms linear 220ms;
  }

  .nav-links.open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition:
      transform 220ms var(--ease-out),
      opacity   180ms ease,
      visibility 0ms linear 0ms;
  }

  .nav-links .nav-link {
    padding: .625rem .875rem;
    font-size: .9375rem;
    border-radius: var(--r-sm);
    width: 100%;
  }

  .nav-mobile-only:not(.hidden) { display: flex !important; }
  .nav-mobile-divider {
    display: block !important;
    height: 1px;
    background: var(--border);
    margin: .375rem 0;
  }

  .nav-brand-text .nav-subtitle { display: none; }
  .user-name { display: none; }

  .nav-hamburger { display: flex; }

  /* Hero — single column on mobile, image below text */
  .hero-split {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 2.5rem var(--page-px) 2rem;
    gap: 1.75rem;
  }
  .hero-split-right { display: none; }  /* hide image on mobile */
  .hero-title { font-size: 2rem; }
  .hero-desc { font-size: .9375rem; }

  /* Algo art card → stack */
  .algo-art-card {
    grid-template-columns: 1fr;
  }
  .algo-art-canvas { min-height: 200px; }

  /* Research grid → 1 col */
  .research-zig,
  .research-grid,
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }

  /* Page header */
  .page-header {
  position: relative; padding: 1.5rem 0 1.25rem; margin-bottom: 1.25rem; }
  .page-header h1 { font-size: 1.5rem; }

  /* Section title */
  .section-title { font-size: 1.125rem; }

  /* Admin stats */
  .admin-stats { grid-template-columns: repeat(2, 1fr); }

  /* Contact name row */
  .contact-name-row { grid-template-columns: 1fr; }

  /* Profile header */
  .profile-header { flex-direction: column; text-align: center; gap: 1rem; }

  /* Chart height */
  .chart-canvas-wrap { height: 260px; }

  /* Viz panel */
  .viz-canvas-wrap { padding: 1rem; }

  /* Schedule */
  .schedule-row {
    grid-template-columns: 1fr;
    gap: .625rem;
  }

  /* Tables — keep as Excel scroll */
  .table-wrap { border-radius: var(--r); }
}

/* ── 43. RESPONSIVE — 640px ────────────────────────────────── */
@media (max-width: 640px) {
  .hero-title { font-size: 1.75rem; }

  .card { padding: 1.125rem; }

  .admin-stats { grid-template-columns: 1fr 1fr; }

  .toast-container { right: .75rem; left: .75rem; width: auto; max-width: none; }

  .modal-box { border-radius: var(--r-lg); }

  .leadership-card { position: relative; overflow: hidden; padding: 1.25rem; }
  .leadership-card h3 { font-size: 1.125rem; }

  .page-header h1 { font-size: 1.25rem; }
  .page-icon { width: 32px; height: 32px; font-size: .875rem; }

  .research-areas-grid { grid-template-columns: 1fr; }
  .research-area-item:nth-last-child(-n+2) { border-bottom: 1px solid var(--border); }
  .research-area-item:last-child { border-bottom: none; }
}

/* ── 44. RESPONSIVE — 480px ────────────────────────────────── */
@media (max-width: 480px) {
  :root { --page-px: .875rem; }

  .hero-title { font-size: 1.625rem; }

  .admin-stats { grid-template-columns: 1fr; }

  .btn { font-size: .8125rem; padding: .5rem .875rem; }
  .btn-lg { font-size: .9375rem; padding: .625rem 1.125rem; }

  .tabs { overflow-x: auto; }
  .tab-btn { padding: .5rem .75rem; font-size: .8125rem; flex-shrink: 0; }

  .section-title { font-size: 1rem; }

  /* Hero actions stack on tiny screens */
  .hero-actions { flex-direction: column; align-items: flex-start; }
  .btn-hero-primary, .btn-hero-secondary { width: 100%; justify-content: center; }
}

/* ── 45. PREFERS REDUCED MOTION ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .animate-on-scroll {
    opacity: 1;
    transform: none;
  }

  .hero-blob { animation: none; }
}

/* ── 46. PRODUCTION FIXES & MISSING CLASSES ─────────────────── */

/* ─ Missing token fallback ─ */
:root { --border-strong: rgba(0,0,0,.18); }
[data-theme="dark"] { --border-strong: rgba(255,255,255,.2); }

/* ─ Utility Classes (non-duplicate additions only) ─ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .375rem; }
.gap-2 { gap: .75rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }
.w-full { width: 100%; }
.mb-0 { margin-bottom: 0 !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mt-0 { margin-top: 0 !important; }
.mt-4 { margin-top: 1.5rem !important; }
.fw-500 { font-weight: 500; }
/* mb-1–mb-3, mt-1–mt-3, fw-600, fw-700, text-xs, text-sm, text-accent, text-gold
   are defined canonically in section 8 — do NOT re-define here. */

/* ─ btn-purple alias ─ */
.btn-purple { background: linear-gradient(135deg, var(--accent), var(--accent-mid)); color: #fff; border-color: var(--accent); }
.btn-purple:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ─ btn-xs ─ */
.btn-xs { font-size: .75rem; padding: .25rem .625rem; border-radius: calc(var(--r) - 2px); }

/* ─ form-select — styled native dropdown ─ */
.form-select {
  width: 100%;
  padding: .5625rem .875rem;
  padding-right: 2.5rem;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  background-size: 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-family: inherit;
  font-size: .875rem;
  color: var(--text-1);
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s;
}
.form-select:hover { border-color: var(--accent); }
.form-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(90,58,143,.12); }

/* Style all bare selects in page content */
.page-content select:not(.unstyled) {
  padding: .5rem .875rem;
  padding-right: 2.5rem;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  background-size: 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-family: inherit;
  font-size: .875rem;
  color: var(--text-1);
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s;
  min-width: 140px;
}
.page-content select:not(.unstyled):hover { border-color: var(--accent); }
.page-content select:not(.unstyled):focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(90,58,143,.12); }

/* ─ Search bars with icon prefix ─ */
/* ─ Shared search icon SVG (data URI reused below) ─ */
/* ─ All type=search inputs — icon padding so placeholder never overlaps icon ─ */
input[type="search"].form-input {
  padding-left: 2.125rem !important; /* force left room for the search icon */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: .625rem center;
  background-size: .875rem;
  /* do NOT set width here — let .form-input's width:100% or inline flex:N apply */
}
input[type="search"].form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90,58,143,.12);
}

/* ─ Storage folder search (narrow, standalone) ─ */
.storage-search {
  padding: .4375rem .75rem .4375rem 2.125rem;
  height: 36px;
  background-color: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .8125rem;
  color: var(--text-1);
  font-family: var(--font);
  outline: none;
  min-width: 0;
  width: 180px;
  max-width: 220px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: .625rem center;
  background-size: .875rem;
}
.storage-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90,58,143,.12);
}
.storage-search::placeholder { color: var(--text-4, #aaa); }
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  width: 1rem;
  height: 1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2.5'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  cursor: pointer;
}

/* ─ Storage Breadcrumb & Toolbar ─ */
.storage-toolbar {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  padding: .75rem 1rem;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  border-radius: var(--r) var(--r) 0 0;
}
.storage-toolbar-actions { display: flex; align-items: center; gap: .375rem; margin-left: auto; flex-shrink: 0; }
.storage-breadcrumb {
  display: flex;
  align-items: center;
  gap: .125rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
  font-size: .8125rem;
  color: var(--text-3);
}
.storage-breadcrumb-btn {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .1875rem .5rem;
  border-radius: calc(var(--r) - 4px);
  background: transparent;
  border: none;
  font-size: .8125rem;
  font-family: inherit;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.storage-breadcrumb-btn:hover { background: var(--bg-3); color: var(--accent); }
.storage-breadcrumb-sep { color: var(--border-strong); font-size: .75rem; flex-shrink: 0; }
.storage-grid-container { padding: .75rem; }
.storage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .625rem;
}
.storage-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .375rem;
  padding: .875rem .625rem .75rem;
  border-radius: var(--r);
  background: var(--surface);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: border-color .18s, transform .18s var(--ease-out), box-shadow .18s;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.storage-grid-item:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.storage-grid-item:active { transform: scale(.97); }
.storage-grid-item .item-icon { font-size: 2rem; line-height: 1; }
.storage-grid-item .item-name { font-size: .75rem; font-weight: 500; color: var(--text-1); word-break: break-all; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.storage-grid-item .item-meta { font-size: .6875rem; color: var(--text-3); }
.storage-list-item { display: flex; align-items: center; gap: .75rem; padding: .625rem .875rem; border-radius: var(--r); cursor: pointer; transition: background .15s; }
.storage-list-item:hover { background: var(--bg-2); }
.storage-list-item .item-icon { font-size: 1.25rem; flex-shrink: 0; }
.storage-list-item .item-name { flex: 1; font-size: .875rem; font-weight: 500; color: var(--text-1); }
.storage-list-item .item-meta { font-size: .75rem; color: var(--text-3); white-space: nowrap; }
.storage-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem; padding: 4rem 1rem; color: var(--text-3); text-align: center; }
.storage-empty i { font-size: 2.5rem; opacity: .4; }

/* .research-zig is defined canonically in section 11 — not duplicated here. */

/* ─ Data Schedule Table ─ */
.sched-table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r); border: 1.5px solid var(--border); }
.sched-table { width: 100%; min-width: 800px; border-collapse: collapse; font-size: .875rem; }
.sched-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-2);
  color: var(--text-2);
  font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: .75rem 1rem; text-align: left;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
.sched-table tbody tr { transition: background .15s; border-bottom: 1px solid var(--border); }
.sched-table tbody tr:last-child { border-bottom: none; }
.sched-table tbody tr:hover { background: var(--bg-2); }
.sched-table tbody td { padding: .75rem 1rem; color: var(--text-1); vertical-align: middle; }
.sched-status-active   { display: inline-flex; align-items: center; gap: .25rem; padding: .1875rem .625rem; border-radius: 99px; font-size: .75rem; font-weight: 600; background: rgba(34,197,94,.12); color: #16a34a; }
.sched-status-pending  { display: inline-flex; align-items: center; gap: .25rem; padding: .1875rem .625rem; border-radius: 99px; font-size: .75rem; font-weight: 600; background: rgba(234,179,8,.12); color: #b45309; }
.sched-status-complete { display: inline-flex; align-items: center; gap: .25rem; padding: .1875rem .625rem; border-radius: 99px; font-size: .75rem; font-weight: 600; background: rgba(99,102,241,.12); color: #4f46e5; }
.sched-status-inactive { display: inline-flex; align-items: center; gap: .25rem; padding: .1875rem .625rem; border-radius: 99px; font-size: .75rem; font-weight: 600; background: var(--bg-3); color: var(--text-3); }
.sched-filter-bar { display: flex; align-items: center; flex-wrap: wrap; gap: .625rem; margin-bottom: 1rem; }
.sched-filter-bar input, .sched-filter-bar select { flex: 1; min-width: 160px; }

/* ─ Create Visualization Panel ─ */
.viz-config-panel {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  position: sticky;
  top: calc(var(--nav-height) + 1rem);
  max-height: calc(100vh - var(--nav-height) - 2rem);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.viz-config-panel::-webkit-scrollbar { width: 4px; }
.viz-config-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.viz-config-section { padding: 1rem; border-bottom: 1px solid var(--border); }
.viz-config-section:last-child { border-bottom: none; }
.viz-config-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-bottom: .625rem; }

.chart-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .375rem; margin-bottom: .75rem; }
.chart-type-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .25rem; padding: .625rem .375rem;
  border-radius: var(--r); border: 1.5px solid var(--border);
  background: var(--bg-2); font-family: inherit;
  font-size: .6875rem; font-weight: 500; color: var(--text-2);
  cursor: pointer;
  transition: border-color .18s, background .18s, color .18s, transform .18s var(--ease-out);
}
.chart-type-btn i { font-size: 1.125rem; }
.chart-type-btn:hover { border-color: var(--accent); background: rgba(90,58,143,.07); color: var(--accent); transform: translateY(-1px); }
.chart-type-btn:active { transform: scale(.97); }
.chart-type-btn.active { border-color: var(--accent); background: rgba(90,58,143,.12); color: var(--accent); font-weight: 600; }

.details-summary {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .75rem 1rem; background: var(--bg-2);
  cursor: pointer; user-select: none;
  font-size: .875rem; font-weight: 500; color: var(--text-1);
  list-style: none; border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.details-summary:hover { background: var(--bg-3); }
.details-summary::marker { display: none; }
details[open] .details-summary .summary-arrow { transform: rotate(180deg); }
.summary-arrow { transition: transform .2s var(--ease-out); font-size: .75rem; color: var(--text-3); }
.details-body { padding: .875rem 1rem; }

/* ─ Saved Viz Gallery Cards ─ */
.viz-gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.viz-gallery-card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
  transition: border-color .2s, transform .2s var(--ease-out), box-shadow .2s;
}
.viz-gallery-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.viz-gallery-thumb {
  width: 100%; height: 148px;
  background: var(--bg-2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.viz-gallery-thumb canvas, .viz-gallery-thumb img { width: 100%; height: 100%; object-fit: contain; }
.viz-gallery-thumb .thumb-placeholder { font-size: 2.5rem; opacity: .25; }
.viz-gallery-body { padding: .875rem; flex: 1; display: flex; flex-direction: column; gap: .375rem; }
.viz-gallery-title { font-size: .9375rem; font-weight: 600; color: var(--text-1); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.viz-gallery-meta { font-size: .75rem; color: var(--text-3); }
.viz-gallery-actions { display: flex; align-items: center; gap: .375rem; padding: .625rem .875rem; border-top: 1px solid var(--border); background: var(--bg-2); }
.viz-gallery-actions .btn { flex: 1; justify-content: center; }

/* ─ Tabs Header (used by Visualizations page) ─ */
.tabs-header {
  display: flex; gap: .25rem;
  border-bottom: 2px solid var(--border); margin-bottom: 1.5rem;
  overflow-x: auto; scrollbar-width: none;
}
.tabs-header::-webkit-scrollbar { display: none; }
.tabs-header .tab-btn {
  padding: .625rem 1.125rem; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  background: transparent; font-family: inherit;
  font-size: .875rem; font-weight: 500; color: var(--text-3);
  cursor: pointer; white-space: nowrap;
  transition: color .18s, border-color .18s;
  border-radius: var(--r) var(--r) 0 0;
}
.tabs-header .tab-btn:hover { color: var(--text-1); }
.tabs-header .tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ─ Admin Mini Browser ─ */
.admin-mini-browser { border: 1.5px solid var(--border); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.admin-mini-browser-crumb {
  display: flex; align-items: center; gap: .25rem; flex-wrap: wrap;
  padding: .5rem .75rem; background: var(--bg-2); border-bottom: 1px solid var(--border);
  font-size: .8125rem;
}
.ambc-btn {
  display: inline-flex; align-items: center; padding: .125rem .4375rem;
  border-radius: calc(var(--r) - 3px); background: transparent; border: none;
  font-size: .8125rem; font-family: inherit; color: var(--text-2);
  cursor: pointer; transition: background .14s, color .14s; white-space: nowrap;
}
.ambc-btn:hover { background: var(--bg-3); color: var(--accent); }
.ambc-sep { color: var(--border-strong); font-size: .6875rem; }
.admin-mini-browser-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .5rem; padding: .625rem; min-height: 80px; }

/* Admin Collapsible Cards */
.admin-card-header { display: flex; align-items: center; gap: .75rem; cursor: pointer; padding: 1rem 1.25rem; border-radius: var(--r); transition: background .15s; }
.admin-card-header:hover { background: rgba(90,58,143,.04); }
.admin-card-header h3 { flex: 1; margin: 0; font-size: 1rem; font-weight: 600; color: var(--text-1); }
.card-collapse-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--r);
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-3); font-size: .75rem; cursor: pointer;
  transition: background .15s, color .15s, transform .22s var(--ease-out); flex-shrink: 0;
}
.card-collapse-btn.open { transform: rotate(180deg); }
.admin-card-body { padding: 0 1.25rem 1.25rem; }

/* ─ Active File Permissions — horizontal scroll ─ */
.admin-perm-table-wrap,
#admin-permissions-list {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r);
  border: 1.5px solid var(--border);
}
#admin-permissions-list table, .admin-perm-table-wrap table {
  min-width: 700px; width: 100%; border-collapse: collapse; font-size: .875rem;
}
#admin-permissions-list th, .admin-perm-table-wrap th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-2); padding: .625rem 1rem;
  text-align: left; font-size: .75rem; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; color: var(--text-3);
  border-bottom: 1.5px solid var(--border); white-space: nowrap;
}
#admin-permissions-list td, .admin-perm-table-wrap td { padding: .625rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-1); }
#admin-permissions-list tr:last-child td, .admin-perm-table-wrap tr:last-child td { border-bottom: none; }
#admin-permissions-list tr:hover td, .admin-perm-table-wrap tr:hover td { background: var(--bg-2); }

/* ─ Checkboxes — always left-aligned ─ */
input[type="checkbox"] {
  flex-shrink: 0;
  align-self: flex-start;
  margin: .125rem 0 0;
  vertical-align: middle;
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}
label:has(input[type="checkbox"]) { display: flex; align-items: flex-start; gap: .5rem; cursor: pointer; }

/* ─ Loading Wrap ─ */
.loading-wrap { display: flex; align-items: center; justify-content: center; gap: .75rem; padding: 3.5rem 1rem; color: var(--text-3); font-size: .9375rem; }
.loading-wrap .spinner { width: 1.25rem; height: 1.25rem; }

/* ─ Upload progress bar ─ */
.upload-progress-bar-wrap { width: 100%; height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden; margin: .5rem 0; }
.upload-progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-hover)); border-radius: 3px; transition: width .3s var(--ease-out); }

/* ─ File nav spacing ─ */
.file-nav-item { display: flex; align-items: center; gap: .625rem; padding: .5rem .875rem; border-radius: var(--r); cursor: pointer; font-size: .875rem; color: var(--text-1); transition: background .15s; }
.file-nav-item:hover { background: var(--bg-2); }
.file-nav-item i { width: 1.125rem; text-align: center; color: var(--text-3); flex-shrink: 0; }
.file-nav-item .file-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-nav-item .file-size { font-size: .75rem; color: var(--text-3); flex-shrink: 0; }
.file-nav-item[data-depth="1"] { padding-left: 1.5rem; }
.file-nav-item[data-depth="2"] { padding-left: 2.25rem; }
.file-nav-item[data-depth="3"] { padding-left: 3rem; }

/* ─ Notification Bell ─ */
.notif-bell { position: relative; }
.notif-bell-btn { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; background: var(--bg-2); border: 1.5px solid var(--border); color: var(--text-2); font-size: 1rem; cursor: pointer; transition: background .18s, color .18s, border-color .18s; position: relative; }
.notif-bell-btn:hover { background: var(--bg-3); border-color: var(--accent); color: var(--accent); }
.notif-badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 99px; background: linear-gradient(135deg, var(--accent), var(--accent-mid)); color: #fff; font-size: .625rem; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; border: 2px solid var(--bg); }
.notif-dropdown { position: absolute; top: calc(100% + .5rem); right: 0; width: 320px; background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); z-index: 200; overflow: hidden; }
.notif-dropdown-header { display: flex; align-items: center; justify-content: space-between; padding: .875rem 1rem; border-bottom: 1px solid var(--border); }
.notif-list { max-height: 320px; overflow-y: auto; }
.notif-item { display: flex; gap: .75rem; padding: .875rem 1rem; border-bottom: 1px solid var(--border); transition: background .15s; cursor: pointer; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-2); }
.notif-item.unread { background: rgba(90,58,143,.04); }
.notif-item-icon { font-size: 1.125rem; color: var(--accent); flex-shrink: 0; padding-top: .125rem; }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-msg { font-size: .8125rem; color: var(--text-1); line-height: 1.4; }
.notif-item-time { font-size: .6875rem; color: var(--text-3); margin-top: .125rem; }

/* ─ Profile ─ */
.profile-header { display: flex; align-items: center; gap: 1.5rem; margin-bottom: 1.5rem; }
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-avatar { width: 80px; height: 80px; border-radius: 50%; border: 3px solid var(--accent); object-fit: cover; }
.profile-name { font-size: 1.375rem; font-weight: 700; color: var(--text-1); }
.profile-email { font-size: .875rem; color: var(--text-3); }
.profile-role { display: inline-flex; align-items: center; gap: .375rem; padding: .1875rem .75rem; border-radius: 99px; font-size: .75rem; font-weight: 600; background: rgba(90,58,143,.1); color: var(--accent); margin-top: .25rem; }

/* ─ Contact ─ */
.contact-wrap { max-width: 640px; margin: 0 auto; }

/* ── 47. VIEW DATA PAGE ─────────────────────────────────────── */

/* ─ Sheet tab switcher (Excel) ─ */
.sheet-tabs {
  display: flex;
  gap: .375rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: .75rem 1rem;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
}
.sheet-tabs::-webkit-scrollbar { display: none; }
.sheet-tab {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .375rem .9375rem;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-family: inherit;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color .18s, background .18s, color .18s, transform .15s var(--ease-out);
}
.sheet-tab:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.sheet-tab:active { transform: scale(.97); }
.sheet-tab.active { background: linear-gradient(135deg, var(--accent), var(--accent-mid)); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ─ File details panel ─ */
.vd-file-details {
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
  transition: border-color .18s;
}
.vd-file-details:hover { border-color: rgba(90,58,143,.3); }
.vd-file-details-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background .15s;
}
.vd-file-details-summary:hover { background: var(--bg-2); }
.vd-file-details-summary::marker,
.vd-file-details-summary::-webkit-details-marker { display: none; }
.vd-file-summary-left { display: flex; align-items: center; gap: .875rem; min-width: 0; flex: 1; }
.vd-file-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: var(--r);
  background: rgba(90,58,143,.1);
  color: var(--accent);
  font-size: 1.3125rem;
  flex-shrink: 0;
}
.vd-file-title { font-size: 1rem; font-weight: 600; color: var(--text-1); word-break: break-all; line-height: 1.3; }
.vd-file-sub { display: flex; align-items: center; gap: .5rem; margin-top: .3rem; font-size: .8125rem; color: var(--text-3); }
.vd-file-summary-actions { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }
.vd-details-chevron { color: var(--text-3); font-size: .875rem; transition: transform .22s var(--ease-out); line-height: 1; }
details[open] .vd-details-chevron { transform: rotate(180deg); }
.vd-file-details-body { padding: 0 1.25rem 1.25rem; }
.vd-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .875rem 1.5rem;
  padding-top: .875rem;
  margin-top: .125rem;
  border-top: 1px solid var(--border);
}
.vd-meta-item { display: flex; flex-direction: column; gap: .25rem; }
.vd-meta-full { grid-column: 1 / -1; }
.vd-meta-label {
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: .375rem;
}
.vd-meta-value { font-size: .875rem; color: var(--text-1); line-height: 1.5; }

/* ─ KPI cards ─ */
.vd-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
  margin-bottom: 1rem;
}
.vd-kpi-card {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: 1rem 1.125rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  transition: border-color .18s, transform .18s var(--ease-out), box-shadow .18s;
}
.vd-kpi-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.vd-kpi-card.vd-kpi-warn { border-color: rgba(234,179,8,.4); }
.vd-kpi-card.vd-kpi-warn .vd-kpi-icon { background: rgba(234,179,8,.12); color: #b45309; }
.vd-kpi-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r);
  background: rgba(90,58,143,.1);
  color: var(--accent);
  font-size: 1.0625rem;
  flex-shrink: 0;
}
.vd-kpi-body { min-width: 0; }
.vd-kpi-value { font-size: 1.625rem; font-weight: 800; color: var(--text-1); font-family: var(--font-heading); line-height: 1; }
.vd-kpi-label { font-size: .75rem; color: var(--text-3); font-weight: 500; margin-top: .1875rem; }

/* ─ Section accordion (vd-section) ─ */
.vd-section {
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
}
.vd-section-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .875rem 1.125rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  text-align: left;
  transition: background .15s;
  gap: .5rem;
}
.vd-section-summary:hover { background: var(--bg-2); }
.vd-section-summary::marker,
.vd-section-summary::-webkit-details-marker { display: none; }
.vd-section-label {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: .5rem;
  text-align: left;
  flex: 1;
}
.vd-section-label i { color: var(--accent); }
.vd-chevron { color: var(--text-3); font-size: .75rem; transition: transform .22s var(--ease-out); flex-shrink: 0; }
details[open] .vd-chevron { transform: rotate(180deg); }
.vd-section-body { padding: 1rem 1.125rem; }

/* ─ Table horizontal scroll ─ */
.vd-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r);
  border: 1px solid var(--border);
}
.vd-table-scroll .data-table { margin: 0; border-radius: 0; }
.vd-table-scroll::-webkit-scrollbar { height: 6px; }
.vd-table-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.vd-table-scroll::-webkit-scrollbar-track { background: transparent; }

/* ─ Pagination toolbar ─ */
.vd-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .625rem;
  padding: .875rem 0;
  margin-bottom: .625rem;
}
.vd-table-count { font-size: .875rem; color: var(--text-2); }
.vd-table-count strong { color: var(--text-1); }
.vd-table-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* ─ Statistical test tabs ─ */
.vd-test-tabs {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1.5px solid var(--border);
}
.vd-test-tabs::-webkit-scrollbar { display: none; }
.vd-test-tab {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: .3125rem;
  padding: .625rem 1.125rem;
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  background: var(--bg-2);
  font-family: inherit;
  font-size: .75rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 90px;
  text-align: center;
  transition: border-color .18s, background .18s, color .18s, transform .18s var(--ease-out);
}
.vd-test-tab i { font-size: 1.0625rem; }
.vd-test-tab:hover { border-color: var(--accent); color: var(--accent); background: rgba(90,58,143,.06); transform: translateY(-1px); }
.vd-test-tab:active { transform: scale(.97); }
.vd-test-tab.active { background: linear-gradient(135deg, var(--accent), var(--accent-mid)); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ─ Test panels ─ */
.vd-test-panel { display: none; }
.vd-test-panel.active { display: block; }
.vd-test-desc {
  font-size: .8125rem;
  color: var(--text-2);
  line-height: 1.7;
  margin-bottom: .875rem;
  padding: .625rem .875rem;
  background: var(--bg-2);
  border-radius: var(--r);
  border-left: 3px solid var(--accent);
  display: flex;
  gap: .5rem;
  align-items: flex-start;
}
.vd-test-desc i { color: var(--accent); flex-shrink: 0; margin-top: .125rem; }
.vd-test-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; margin-bottom: .75rem; }
.vd-test-empty {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .875rem;
  border-radius: var(--r);
  background: var(--bg-2);
  font-size: .875rem;
  color: var(--text-3);
}
.vd-test-empty i { color: var(--accent); }

/* ─ Test results ─ */
.vd-result {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-2);
  border-radius: var(--r-lg);
  border: 1.5px solid var(--border);
}
.vd-result-header { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .875rem; }
.vd-result-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .5rem;
  margin-bottom: .75rem;
}
.vd-result-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: .5625rem .875rem;
}
.vd-result-stat-label { font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; }
.vd-result-stat-value { font-size: 1.0625rem; font-weight: 700; margin-top: .1875rem; font-family: var(--font-heading); }
.vd-result-interp { font-size: .875rem; color: var(--text-2); line-height: 1.7; margin-bottom: 0; }
.vd-result-pre {
  font-size: .75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: .75rem;
  overflow-x: auto;
  white-space: pre;
  margin-top: .625rem;
  color: var(--text-2);
  line-height: 1.5;
}

/* ─ Responsive ─ */
@media (max-width: 900px) {
  .vd-kpi-row { grid-template-columns: 1fr 1fr; }
  .vd-test-form { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .vd-meta-grid { grid-template-columns: 1fr; }
  .vd-file-summary-actions .btn { display: none; } /* hide download btn in header on tiny screens */
}
@media (max-width: 480px) {
  .vd-kpi-row { grid-template-columns: 1fr 1fr; }
  .vd-kpi-value { font-size: 1.25rem; }
}

/* ─ Alpha / confidence bar ─ */
.vd-alpha-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .625rem 1rem;
  background: rgba(90,58,143,.06);
  border: 1.5px solid rgba(90,58,143,.2);
  border-radius: var(--r);
  margin-bottom: 1.25rem;
}
.vd-alpha-label {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-2);
}
.vd-alpha-input {
  width: 5.5rem;
  padding: .25rem .5rem;
  font-size: .875rem;
  text-align: center;
}
.vd-ci-label {
  font-size: .8125rem;
  font-weight: 700;
  color: var(--accent);
}
.vd-alpha-hint {
  margin-left: auto;
  font-size: .75rem;
  color: var(--text-3);
}
@media (max-width: 640px) {
  .vd-alpha-bar { gap: .5rem; }
  .vd-alpha-hint { display: none; }
}

/* ─ Column type badges ─ */
.vd-col-badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .6875rem;
  font-weight: 600;
  padding: .125rem .4375rem;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: .375rem;
  letter-spacing: .02em;
}
.vd-col-num {
  background: rgba(22,163,74,.12);
  color: #16a34a;
  border: 1px solid rgba(22,163,74,.25);
}
.vd-col-cat {
  background: rgba(234,88,12,.12);
  color: #c2410c;
  border: 1px solid rgba(234,88,12,.25);
}

/* ─ Group preview ─ */
.vd-group-preview {
  font-size: .8125rem;
  padding: .4375rem .75rem;
  border-radius: var(--r);
  margin-top: .375rem;
  display: flex;
  align-items: flex-start;
  gap: .4375rem;
  line-height: 1.55;
  grid-column: 1 / -1;
}
.vd-group-preview code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: .25rem;
  padding: 0 .3125rem;
  font-size: .75rem;
  font-family: monospace;
}
.vd-group-valid {
  background: rgba(22,163,74,.08);
  border: 1px solid rgba(22,163,74,.22);
  color: #15803d;
}
.vd-group-valid i { color: #16a34a; flex-shrink: 0; margin-top: .125rem; }
.vd-group-invalid {
  background: rgba(220,38,38,.07);
  border: 1px solid rgba(220,38,38,.2);
  color: #b91c1c;
}
.vd-group-invalid i { color: #dc2626; flex-shrink: 0; margin-top: .125rem; }

/* ─ CI result label ─ */
.vd-ci-result-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ══════════════════════════════════════════════════════════════════
   48. VIZ BUILDER / ADMIN FIXES
   ══════════════════════════════════════════════════════════════════ */

/* ─ Global data-table scroll wrapper ─ */
.data-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 380px;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-lg);
  border: 1.5px solid var(--border);
  background: var(--surface);
}
.data-table-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.data-table-wrap::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.data-table-wrap::-webkit-scrollbar-track { background: transparent; }

/* ─ Viz sidebar padding ─ */
.viz-config-panel { padding: 1rem 1.125rem !important; }

/* ─ Viz sidebar details/summary — icon+text left, arrow right ─ */
.viz-config-panel details > summary,
.viz-config-panel .details-summary {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: .5rem;
  text-align: left !important;
  cursor: pointer;
  list-style: none;
}
.viz-config-panel details > summary::-webkit-details-marker,
.viz-config-panel details > summary::marker { display: none; }
/* The .details-sum-text span groups icon+text as one flex item → stays left */
.details-sum-text {
  display: inline-flex;
  align-items: center;
  gap: .4375rem;
  flex: 1;
  text-align: left;
}
/* Rotate chevron arrow when open */
.viz-config-panel details[open] > summary .summary-arrow,
details[open] > .details-summary .summary-arrow { transform: rotate(180deg); }

/* ─ Viz sidebar checkboxes — left-aligned ─ */
.viz-config-panel .form-group:has(input[type="checkbox"]),
.viz-config-panel label:has(input[type="checkbox"]) {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: .5rem !important;
  text-align: left !important;
}
.viz-config-panel input[type="checkbox"] { flex-shrink: 0; order: 0; margin: 0; }

/* ─ Saved Visualizations list view — constrain image ─ */
.viz-list-img-wrap {
  width: 100px !important;
  height: 76px !important;
  flex-shrink: 0 !important;
  overflow: hidden;
  border-radius: var(--r);
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.viz-list-img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block;
}

/* ─ Admin file browser — vertical list ─ */
.admin-mini-browser-grid {
  display: flex !important;
  flex-direction: column !important;
  gap: 0 !important;
  padding: .25rem !important;
  grid-template-columns: unset !important;
}
.admin-mini-browser-item {
  display: flex !important;
  align-items: center !important;
  gap: .625rem !important;
  padding: .4375rem .75rem !important;
  border-radius: var(--r) !important;
  cursor: pointer;
  transition: background 150ms;
  font-size: .84375rem;
  color: var(--text-1);
  width: 100%;
  box-sizing: border-box;
  text-align: left !important;
}
.admin-mini-browser-item:hover { background: var(--bg-2); }
.admin-mini-browser-item > i { flex-shrink: 0; width: 1.125rem; text-align: center; color: var(--text-3); }
.admin-mini-browser-item > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-mini-browser-item .ambi-nav,
.admin-mini-browser-item > button { margin-left: auto; flex-shrink: 0; }

/* ─ Admin checkboxes — left-aligned ─ */
.admin-section label:has(input[type="checkbox"]),
.modal-body label:has(input[type="checkbox"]),
#page-content label:has(input[type="checkbox"]) {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: .45rem !important;
  text-align: left !important;
}
#page-content input[type="checkbox"] {
  flex-shrink: 0;
  order: 0;
  margin: 0;
}

/* ─ Admin Audit Log date filters — auto-width, wrappable ─ */
#audit-date-from,
#audit-date-to {
  width: auto !important;
  min-width: 0 !important;
  flex-shrink: 1 !important;
}
/* Audit log container — always scrollable */
#admin-audit-list { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 600px) {
  .viz-list-img-wrap { width: 72px !important; height: 56px !important; }
  .admin-mini-browser-item { font-size: .8125rem; padding: .375rem .625rem !important; }
}

/* ══════════════════════════════════════════════════════════════════
   49. PROFILE PAGE REDESIGN
   ══════════════════════════════════════════════════════════════════ */

/* ─ Profile card wrapper ─ */
.profile-card { padding: 1.5rem !important; }

/* ─ Top row: avatar left, identity right ─ */
.profile-card-top {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
.profile-avatar-wrap { flex-shrink: 0; }
.profile-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  object-fit: cover;
  display: block;
}
.profile-avatar-placeholder {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-3);
}

/* ─ Identity column ─ */
.profile-identity {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .25rem;
  min-width: 0;
}
.profile-name  { font-size: 1.375rem; font-weight: 700; color: var(--text-1); line-height: 1.2; }
.profile-email { font-size: .875rem; color: var(--text-3); }
.profile-badge {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .1875rem .75rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
  background: rgba(90,58,143,.1);
  color: var(--accent);
  margin-top: .25rem;
}
.profile-badge-manager { background: rgba(90,58,143,.18); }

/* ─ Sign-out: compact, auto-width ─ */
.profile-signout-btn {
  margin-top: .625rem !important;
  width: auto !important;
  align-self: flex-start;
  padding-left: 1rem !important;
  padding-right: 1rem !important;
}

/* ─ Stat cards row (4 across) ─ */
.profile-stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.profile-stat-card {
  display: flex;
  align-items: flex-start;
  gap: .625rem;
  padding: .875rem .9375rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.profile-stat-card-icon {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(90,58,143,.1);
  border-radius: var(--r-sm);
  color: var(--accent);
  font-size: .9375rem;
  margin-top: .0625rem;
}
.profile-stat-card-body { min-width: 0; }
.profile-stat-card-label {
  font-size: .6875rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  font-weight: 600;
  margin-bottom: .1875rem;
  white-space: nowrap;
}
.profile-stat-card-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-1);
  font-family: var(--font-heading);
  line-height: 1.2;
  display: flex;
  align-items: center;
}

/* ─ Recent activity: 2-column grid ─ */
.profile-recent-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* ─ Responsive ─ */
@media (max-width: 900px) {
  .profile-stat-row { grid-template-columns: 1fr 1fr; }
  .profile-recent-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .profile-card-top { gap: .875rem; }
  .profile-avatar, .profile-avatar-placeholder { width: 68px; height: 68px; }
  .profile-name { font-size: 1.125rem; }
  .profile-stat-row { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .profile-stat-card { padding: .75rem .75rem; }
  .profile-stat-card-label { white-space: normal; }
}

/* ── Profile recent activity list ─────────────────────────────── */
.profile-file-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.profile-file-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--dur-fast) ease;
}
.profile-file-item:last-child { border-bottom: none; }
@media (hover: hover) and (pointer: fine) {
  .profile-file-item:hover { background: var(--bg-2); }
}
.profile-file-item .file-icon { font-size: 1rem; flex-shrink: 0; }
.profile-file-info { min-width: 0; }
.profile-file-info .text-sm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── View-data file layout ─────────────────────────────────────── */
.vd-file-layout {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-top: .75rem;
}
.vd-metadata-top { /* collapsible metadata panel — no extra styles needed */ }
.vd-main-preview  { /* main preview area — inherits from .card children */ }

/* ── Transformation Pipeline ───────────────────────────────────── */
.pipeline-steps {
  display: flex;
  flex-direction: column;
  gap: .375rem;
  margin-bottom: .5rem;
}
.pipeline-step {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .375rem .625rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .8125rem;
}
.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-mid));
  color: #fff;
  border-radius: 50%;
  font-size: .6875rem;
  font-weight: 700;
  flex-shrink: 0;
}
.step-desc {
  flex: 1;
  color: var(--text-2);
  word-break: break-all;
}
.step-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  padding: .125rem .25rem;
  border-radius: var(--r-sm);
  transition: color var(--dur-fast) ease, background var(--dur-fast) ease;
  flex-shrink: 0;
  line-height: 1;
}
.step-remove:hover { color: var(--danger); background: rgba(239,68,68,.08); }

/* ══════════════════════════════════════════════════════════════════
   50. MOBILE NAV & NOTIFICATION FIXES
   ══════════════════════════════════════════════════════════════════ */

/* ─ Notification dropdown — fixed position on mobile so it never clips ─ */
@media (max-width: 768px) {
  .notif-dropdown {
    position: fixed !important;
    top: var(--nav-height) !important;
    right: .75rem !important;
    left: auto !important;
    width: min(320px, calc(100vw - 1.5rem)) !important;
    transform-origin: top right;
  }
}

/* ─ Make sure #nav-links always starts hidden at mobile ─ */
@media (max-width: 768px) {
  /* Ensure the hamburger has enough tap area */
  .nav-hamburger {
    width: 44px !important;
    height: 44px !important;
  }
}


/* Progress bar shine effect */
.progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.2), transparent);
  animation: progress-shine 2s ease-in-out infinite;
}

@keyframes progress-shine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}


/* Page header accent line */
.page-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  border-radius: 2px;
}

.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(21, 128, 61, .18);
}
@media (hover: hover) and (pointer: fine) {
  .btn-success:hover:not(:disabled) {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(21, 128, 61, .2);
  }
}

.card-sm { padding: 1rem; }
.card-collapse-btn {
  display: flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: transparent;
  cursor: pointer; color: var(--text-2);
  transition: background var(--dur-fast) var(--ease-out);
}
.card-collapse-btn:hover { background: var(--bg-light); }
.admin-card-header { cursor: pointer; user-select: none; }
.admin-card-body { overflow: hidden; transition: opacity 0.2s ease; }
.admin-card-body.collapsed { display: none; }
.badge-gray { background: var(--bg-2); color: var(--text-2); }

.upload-zone-icon {
  width: 60px; height: 60px; display: flex; align-items: center; justify-content: center;
  background: var(--accent-subtle); border: 1px solid var(--accent-border);
  border-radius: var(--r); color: var(--accent); font-size: 1.5rem;
}
.supported {
  font-size: .8125rem; color: var(--text-4);
  font-family: var(--font-mono); letter-spacing: .02em;
}
.btn-upload-browse {
  padding: .625rem 1.5rem; border-radius: var(--r-sm);
  background: var(--accent-subtle); color: var(--accent);
  border: 1.5px solid var(--accent-border);
  font-size: .875rem; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: all var(--dur-fast) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .btn-upload-browse:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
}
.file-queue { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.file-queue-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem; background: var(--bg-light);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  animation: slideUp .3s var(--ease-out);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.file-queue-item:hover { background: var(--bg-2); border-color: var(--border-strong); }
.file-queue-item.fqi-active {
  background: rgba(var(--accent-rgb, 121,80,196), 0.07);
  border-color: var(--accent);
}
.file-queue-item.fqi-active .file-name { color: var(--accent); }

/* ── Upload file preview card (full-width section below the upload grid) ── */
.upload-preview-card {
  /* The card itself is full-width and has a hard boundary — nothing inside
     is allowed to widen the page. The table scrolls within this box. */
  width: 100%;
  min-width: 0;
  overflow: hidden;   /* hard clip — prevents table from stretching the page */
  box-sizing: border-box;
}
.upload-preview-card #preview-body {
  /* Remove the card's side padding so the scroll wrapper reaches edge-to-edge */
  margin: 0 -1.5rem -1.5rem;
}
.upload-preview-card .data-table-wrap {
  /* Full-width, fixed height — table scrolls both axes inside this box */
  width: 100%;
  max-height: 420px;
  overflow-x: auto;
  overflow-y: auto;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  border: none;
  border-top: 1px solid var(--border);
}
/* Non-table previews (text, image, docx) keep their padding */
.upload-preview-card pre,
.upload-preview-card img,
.upload-preview-card .docx-viewer {
  margin: 0;
  padding: 0 1.5rem 1.5rem;
}

/* ── XLSX sheet tabs ── */
.preview-sheet-tabs {
  display: flex; gap: .25rem; flex-wrap: wrap;
  padding: .5rem .75rem .25rem;
  border-bottom: 1px solid var(--border);
}
.preview-sheet-tab {
  padding: .25rem .75rem; font-size: .75rem; font-weight: 600;
  border: 1px solid var(--border); border-radius: 99px;
  background: var(--bg-light); color: var(--text-2);
  cursor: pointer; transition: all var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.preview-sheet-tab:hover { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb, 121,80,196), 0.06); }
.preview-sheet-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.file-icon { color: var(--accent); font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.file-icon-sm { font-size: .75rem; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: .875rem; font-weight: 500; color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: .75rem; color: var(--text-3); }
.file-remove {
  background: none; border: none; cursor: pointer; color: var(--text-3);
  padding: .25rem; border-radius: var(--r-xs);
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.file-remove:hover { color: var(--danger); background: var(--danger-bg); }
.file-row-badge { margin-left: .5rem; }
.file-row-name { font-weight: 500; color: var(--text-1); }
.file-manager-actions { display: flex; gap: .375rem; }
.upload-progress-bar {
  height: 4px; background: var(--bg-2); border-radius: 99px;
  overflow: hidden; margin-top: .5rem;
}
.upload-progress-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-mid));
  transition: width 350ms var(--ease-out);
}
.upload-status { font-size: .75rem; color: var(--text-3); }
.fq-status { font-size: .75rem; }
.fqs { margin-top: .25rem; }

.skeleton-line { height: .875rem; margin-bottom: .5rem; border-radius: var(--r-xs); }
.skeleton-block { height: 80px; margin-bottom: .75rem; border-radius: var(--r-sm); }

.w-40 { width: 40% !important; } .w-60 { width: 60% !important; }
.w-70 { width: 70% !important; } .w-80 { width: 80% !important; }
.w-full { width: 100% !important; }
.mb-0 { margin-bottom: 0 !important; } .mt-0 { margin-top: 0 !important; }
.mt-0\.5 { margin-top: .125rem !important; } .ml-2 { margin-left: .5rem !important; } .mr-1 { margin-right: .25rem !important; }
.gap-1 { gap: .25rem !important; } .fw-400 { font-weight: 400 !important; }

/* ── Visualization Card Details ── */
.viz-card-body { padding: .875rem; }
.viz-card-title { font-size: .9375rem; font-weight: 600; color: var(--text-1); margin-bottom: .25rem; }
.viz-card-desc { font-size: .8125rem; color: var(--text-3); line-height: 1.5; }
.viz-card-img-wrap { overflow: hidden; }
.viz-card-img { width: 100%; height: 120px; object-fit: cover; transition: transform 400ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .viz-gallery-card:hover .viz-card-img { transform: scale(1.05); } }
.viz-thumb-fallback { font-size: 2rem; color: var(--text-4); }
.viz-details-config { }
.viz-preview-panel { }
.viz-list-img-wrap { width: 48px; height: 36px; border-radius: var(--r-xs); overflow: hidden; flex-shrink: 0; }
.viz-list-img { width: 100%; height: 100%; object-fit: cover; }
.viz-gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.chart-type-btn { padding: .5rem; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); cursor: pointer; color: var(--text-2); font-family: var(--font); transition: all var(--dur-fast) var(--ease-out); text-align: center; font-size: .8125rem; }
.chart-type-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-subtle); }
@media (hover: hover) and (pointer: fine) { .chart-type-btn:hover:not(.active) { border-color: var(--border-md); background: var(--bg-light); } }
.chart-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.save-viz-form { }
.sheet-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.sheet-tab { padding: .5rem .875rem; font-size: .8125rem; color: var(--text-3); cursor: pointer; border: none; border-bottom: 2px solid transparent; background: none; font-family: var(--font); transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out); }
.sheet-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.docx-viewer { padding: 2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); min-height: 400px; }
.docx-viewer h1, .docx-viewer h2, .docx-viewer h3 { margin-bottom: .5rem; }
.docx-viewer p { margin-bottom: .75rem; line-height: 1.7; }
.modal-title { font-size: 1.0625rem; font-weight: 700; }
.loading-wrap { display: flex; align-items: center; justify-content: center; gap: .75rem; padding: 2rem; }
.loading-wrap p { color: var(--text-3); font-size: .875rem; }
.summary-arrow { transition: transform var(--dur-fast) var(--ease-out); font-size: .75rem; color: var(--text-3); }

/* ── Responsive: Profile Stats ── */
@media (max-width: 900px) {
  .profile-stat-row { grid-template-columns: 1fr 1fr; }
  .profile-recent-grid { grid-template-columns: 1fr; }
  .admin-mini-browser-item { font-size: .75rem; }
}
@media (max-width: 520px) {
  .profile-card-top { gap: .875rem; }
  .profile-avatar, .profile-avatar-placeholder { width: 68px; height: 68px; }
  .profile-name { font-size: 1.125rem; }
  .profile-stat-row { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .profile-stat-card { padding: .75rem .75rem; }
  .profile-stat-card-label { white-space: normal; }
  .vd-meta-grid { grid-template-columns: 1fr; }
  .vd-result-stats { grid-template-columns: 1fr; }
  .chart-type-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Form range / select helpers ── */
.form-range { width: 100%; }
.form-select { width: 100%; }

/* ── Misc utilities used by JS ── */
.alert { padding: .875rem 1.125rem; border-radius: var(--r-sm); font-size: .875rem; margin-bottom: 1rem; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(185,28,28,.18); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(161,98,7,.18); }

/* Notif mobile fix */
@media (max-width: 768px) {
  .notif-dropdown {
    position: fixed !important;
    top: var(--nav-height) !important;
    right: .75rem !important;
    left: auto !important;
    width: min(320px, calc(100vw - 1.5rem)) !important;
    transform-origin: top right;
  }
  .nav-hamburger { width: 44px !important; height: 44px !important; }
}
