/* ============================================================
   SampleFlux — app.css  |  Production Design System v2
   Typefaces: Inter (body/UI) · DM Mono (code/data)
   Google Fonts loaded via @import below.
   Audited & improved: layout, spacing, typography, responsive,
   sidebar, topbar, cards, tables, forms, buttons, loaders.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=DM+Mono:ital,wght@0,400;0,500;1,400&display=swap');


/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Typefaces */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'DM Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* Layout */
  --sidebar-expanded: 284px;
  --sidebar-collapsed: 72px;
  --shell-motion: 240ms cubic-bezier(.4, 0, .2, 1);
  --topbar-h: 68px;

  /* Surfaces */
  --bg: #F0F4F8;
  --panel: #FFFFFF;
  --panel-alt: #FAFBFF;
  --line: #C7D7F5;
  --line-soft: #DDE3F0;
  --ui-border-width: 1.5px;
  --ui-border-soft-width: 1px;
  --ui-border: var(--ui-border-width) solid var(--line);
  --ui-border-soft: var(--ui-border-soft-width) solid var(--line-soft);

  /* Text */
  --text: #141928;
  --text-2: #3C4462;
  --muted: #6E7898;
  --muted-2: #9AA3C0;

  /* Navigation */
  --nav: #141928;
  --nav-2: #1B2240;
  --navText: #BDC6E0;

  /* Brand */
  --brand: #4361EE;
  --brandHover: #3451D1;
  --brandActive: #2A41BE;
  --brandLight: rgba(67, 97, 238, .10);
  --brandLighter: rgba(67, 97, 238, .06);
  --focusRing: rgba(67, 97, 238, .22);

  /* Semantic */
  --metric-total: #4F62C8;
  --metric-total-light: rgba(79, 98, 200, .10);
  --status-active: #059669;
  --status-active-light: rgba(22, 163, 74, .10);
  --status-draft: #64748B;
  --status-draft-light: rgba(100, 116, 139, .10);
  --status-paused: #D97706;
  --status-paused-light: rgba(217, 119, 6, .12);
  --status-closed: #475569;
  --status-closed-light: rgba(71, 85, 105, .10);
  --status-archived: #94A3B8;
  --status-archived-light: rgba(148, 163, 184, .14);
  --status-blocked: #DC2626;
  --status-blocked-light: rgba(220, 38, 38, .10);
  --status-testing: #2563EB;
  --status-testing-light: rgba(37, 99, 235, .10);
  --status-complete: #059669;
  --status-terminate: #EA580C;
  --status-pre-screener: #7F77DD;
  --status-quotafull: #F59E0B;
  --status-quality-failed: #DC2626;
  --status-started: #4F62C8;
  --status-sample-achieved: #14B8A6;
  --status-rejected: #E11D48;
  --status-fulfilled: #14B8A6;
  --status-cancelled: #DC2626;
  --chart-category-1: #4F62C8;
  --chart-category-2: #059669;
  --chart-category-3: #D97706;
  --chart-category-4: #7F77DD;
  --chart-category-5: #14B8A6;
  --chart-category-6: #EA580C;
  --chart-category-7: #64748B;
  --success: #059669;
  --successLight: rgba(22, 163, 74, .10);
  --warning: #D97706;
  --warningLight: rgba(217, 119, 6, .12);
  --danger: #DC2626;
  --dangerLight: rgba(220, 38, 38, .10);
  --info: #4F62C8;
  --infoLight: rgba(79, 98, 200, .10);

  /* Export */
  --export: #3A6EFC;
  --exportHover: #2D5FE8;

  /* Shadows */
  --shadow-xs: 0 1px 3px rgba(20, 25, 40, .07);
  --shadow-sm: 0 2px 8px rgba(20, 25, 40, .06), 0 1px 3px rgba(20, 25, 40, .04);
  --shadow-md: 0 6px 20px rgba(20, 25, 40, .07), 0 2px 6px rgba(20, 25, 40, .04);
  --shadow-lg: 0 16px 40px rgba(20, 25, 40, .10), 0 4px 12px rgba(20, 25, 40, .05);
  --panelShadow: var(--shadow-sm);

  /* Radii — differentiated for proper visual hierarchy */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-xl: 12px;

  /* Type scale */
  --text-xs: 0.72rem;
  --text-sm: 0.84rem;
  --text-base: 1rem;
  --text-md: 1.08rem;
  --text-lg: 1.2rem;
  --text-xl: 1.45rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.1rem;

  /* Soft buttons */
  --softButton: #FFFFFF;
  --softButtonHover: #F5F7FF;
  --softButtonText: #2C3454;

  /* Touch tap target minimum */
  --tap-min: 44px;
}


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

html {
  scroll-behavior: smooth;
  /* Prevent layout shift from scrollbar appearing/disappearing */
  overflow-y: scroll;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-optical-sizing: auto;
  font-feature-settings: "cv02", "cv03", "cv04", "kern";
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Inherit font on all interactive elements */
body, button, input, select, textarea { font: inherit; }

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

/* Consolidated focus-visible — single rule, no browser outline */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
}

/* Images/media are responsive by default */
img, video, svg { max-width: 100%; display: block; }

/* Remove default list styles when used as nav */
ul, ol { list-style: none; margin: 0; padding: 0; }

/* ── App Shell ──────────────────────────────────────────────── */
.app-shell {
  position: relative;
  min-height: 100vh;
  background: var(--bg);
  /* FIX: removed overflow:hidden which can clip fixed elements incorrectly */
  border-radius: 0;
}


/* ═══════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 30;
  width: var(--sidebar-expanded);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 14px 24px;
  background: var(--nav);
  color: var(--navText);
  border-right: 1px solid rgba(255, 255, 255, .04);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .08) transparent;
  transition:
    width var(--shell-motion),
    padding var(--shell-motion),
    box-shadow var(--shell-motion);
  /* Prevent overscroll from propagating to body */
  overscroll-behavior: contain;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .08);
  border-radius: 999px;
}

/* Mobile backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(10, 15, 30, .52);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--shell-motion), visibility 0s linear 240ms;
  z-index: 34;
}

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

/* Brand / Logo area */
.brand-home {
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 8;
  flex: 0 0 var(--topbar-h);
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  background: var(--nav);
  padding: 0;
  overflow: hidden;
  box-shadow: 0 8px 14px rgba(20, 25, 40, .92);
  transition: padding var(--shell-motion);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  transition:
    padding var(--shell-motion),
    justify-content var(--shell-motion),
    gap var(--shell-motion);
}

.sidebar-brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.sidebar-brand-icon-shell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 12px;
  background: #02081F;
  border: 1px solid rgba(86, 122, 255, .36);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .10),
    0 0 0 1px rgba(34, 230, 208, .08),
    0 14px 30px rgba(0, 0, 0, .28),
    0 0 26px rgba(31, 93, 255, .22);
  flex-shrink: 0;
}

.sidebar-brand-icon-shell::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 16px;
  background: radial-gradient(circle, rgba(35, 230, 208, .18) 0%, transparent 70%);
  z-index: -1;
}

.sidebar-brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 11px;
}

.sidebar-brand-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  transition:
    opacity var(--shell-motion),
    max-width var(--shell-motion),
    transform var(--shell-motion);
}

.sidebar-brand-name {
  font-size: 1rem;
  font-weight: 800;
  color: #F0F4FF;
  line-height: 1.1;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-name span {
  color: #0A8FEA;
  background: linear-gradient(90deg, #0B63D8 0%, #0A8FEA 58%, #0EA5E9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-brand-subtitle {
  font-size: .72rem;
  font-weight: 500;
  color: #7D8DB8;
  line-height: 1.2;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Navigation ─────────────────────────────────────────────── */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0 0;
  transition: padding var(--shell-motion);
}

.sidebar-section-label {
  padding: 16px 12px 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: #4E5F88;
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: anywhere;
  transition:
    opacity var(--shell-motion),
    max-height var(--shell-motion),
    margin var(--shell-motion),
    padding var(--shell-motion);
}

.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, .06);
  margin: 6px 0;
  transition: margin var(--shell-motion), opacity var(--shell-motion);
}

/* Nav group (details/summary accordion) */
.nav-group { overflow: hidden; }

/* Shared base for nav links and summary */
.nav-link,
.nav-group summary,
.nav-group a {
  display: flex;
  font-size: 13.5px;
  font-weight: 500;
  color: #8898C4;
  border-left: 2px solid transparent;
  background: transparent;
  text-decoration: none;
  /* Ensure consistent tap target */
  min-height: 42px;
  transition:
    background .14s ease,
    color .14s ease,
    border-color .14s ease,
    box-shadow .14s ease;
}

.nav-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  list-style: none;
  cursor: pointer;
  margin: 0 2px;
}

/* Remove default summary marker in all browsers */
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::marker { content: none; display: none; }

.nav-parent-main {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  /* Prevent text overflow in collapsed state */
  overflow: hidden;
  transition:
    gap var(--shell-motion),
    justify-content var(--shell-motion),
    width var(--shell-motion);
}

.nav-parent-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
  transition:
    opacity var(--shell-motion),
    max-width var(--shell-motion),
    transform var(--shell-motion);
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  color: currentColor;
}

.nav-icon svg,
.nav-chevron svg,
.sidebar-brand-icon svg { display: block; }

.nav-text {
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition:
    opacity var(--shell-motion),
    max-width var(--shell-motion),
    transform var(--shell-motion);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  margin: 0 2px;
  transition:
    background .14s ease,
    color .14s ease,
    border-color .14s ease,
    box-shadow .14s ease,
    padding var(--shell-motion),
    justify-content var(--shell-motion);
}

.nav-link .nav-parent-main { width: 100%; }

/* Hover states */
.nav-link:hover,
.nav-group summary:hover {
  color: #D8E2FF;
  background: rgba(255, 255, 255, .07);
  border-left-color: var(--brand);
}

/* Active/current states */
.nav-group.is-current summary,
.nav-link.active {
  color: #EEF2FF;
  background: rgba(67, 97, 238, .18);
  border-left-color: var(--brand);
  font-weight: 600;
}

/* Focus-visible states */
.nav-link:focus-visible,
.nav-group summary:focus-visible,
.nav-group a:focus-visible {
  color: #D8E2FF;
  background: rgba(255, 255, 255, .08);
  border-left-color: var(--brand);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}

/* Chevron */
.nav-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
  flex-shrink: 0;
  transition:
    transform .2s ease,
    opacity var(--shell-motion),
    max-width var(--shell-motion);
}

.nav-group[open] > .nav-parent .nav-chevron { transform: rotate(180deg); }

/* Nav badge */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 17px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(67, 97, 238, .20);
  color: #C4D0FF;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .01em;
  flex-shrink: 0;
  transition:
    opacity var(--shell-motion),
    max-width var(--shell-motion),
    margin var(--shell-motion),
    padding var(--shell-motion);
}

/* Submenu accordion */
.nav-submenu {
  display: grid;
  /* FIX: use grid rows trick instead of max-height for smoother animation */
  grid-template-rows: 0fr;
  overflow: hidden;
  transition: grid-template-rows .22s ease, padding var(--shell-motion);
  padding: 0;
}

.nav-submenu > * { min-height: 0; overflow: hidden; }

.nav-group[open] > .nav-submenu {
  grid-template-rows: 1fr;
  padding: 2px 0 6px;
}

/* Submenu links */
.nav-group a {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 2px;
  margin-right: 2px;
  padding: 7px 12px 7px 44px;
  min-height: 38px;
  font-size: 12.5px;
  color: #6D80B0;
  border-radius: var(--r-sm);
  border-left-color: transparent !important;
  position: relative;
}

.nav-group a:hover {
  color: #D8E2FF;
  background: rgba(255, 255, 255, .07);
}

.nav-group a.active {
  background: rgba(67, 97, 238, .14);
  color: #C8D5FF;
  font-weight: 600;
}

/* Submenu bullet dot */
.nav-group a::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: .75;
  flex: 0 0 auto;
}

.nav-group a.active::before,
.nav-group a:hover::before { opacity: 1; }


/* ── Collapsed Sidebar ──────────────────────────────────────── */
html.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed);
  padding-left: 8px;
  padding-right: 8px;
  overflow-x: hidden;
}

html.sidebar-collapsed .main-shell {
  margin-left: var(--sidebar-collapsed);
  width: calc(100% - var(--sidebar-collapsed));
}

html.sidebar-collapsed .brand-home { padding: 0; }

html.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  gap: 0;
  padding-left: 8px;
  padding-right: 8px;
}

html.sidebar-collapsed .sidebar-brand-icon-shell {
  width: 34px;
  height: 34px;
  padding: 6px;
  border-radius: 8px;
}

html.sidebar-collapsed .sidebar-brand-copy,
html.sidebar-collapsed .sidebar-section-label,
html.sidebar-collapsed .nav-text,
html.sidebar-collapsed .nav-chevron,
html.sidebar-collapsed .nav-badge {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateX(-5px);
}

html.sidebar-collapsed .sidebar-section-label {
  max-height: 0;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
}

html.sidebar-collapsed .sidebar-divider { margin: 5px 6px; opacity: .5; }

html.sidebar-collapsed .nav-parent-main {
  width: 100%;
  justify-content: center;
  gap: 0;
}

html.sidebar-collapsed .nav-parent-meta {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  transform: translateX(5px);
  pointer-events: none;
}

html.sidebar-collapsed .nav-group summary,
html.sidebar-collapsed .nav-link {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

/* FIX: collapse submenu with same grid-rows trick */
html.sidebar-collapsed .nav-group > .nav-submenu {
  grid-template-rows: 0fr !important;
  padding: 0 !important;
}

html.sidebar-collapsed .nav-group a { display: none; }


/* ── Reduced Motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .sidebar, .brand-home, .sidebar-brand, .sidebar-brand-copy,
  .sidebar-nav, .sidebar-section-label, .sidebar-divider,
  .nav-parent-main, .nav-parent-meta, .nav-text, .nav-link,
  .nav-chevron, .nav-badge, .nav-submenu, .main-shell,
  .sidebar-toggle, .survey-terminate-option,
  .page-loading-overlay, .page-loading-spinner {
    transition: none !important;
    animation-duration: 1ms !important;
  }

  .page-loading-spinner { animation-duration: 1.4s !important; }
}


/* ═══════════════════════════════════════════════════════════════
   MAIN SHELL & TOPBAR
   ═══════════════════════════════════════════════════════════════ */
.main-shell {
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
  margin-left: var(--sidebar-expanded);
  width: calc(100% - var(--sidebar-expanded));
  height: 100vh;
  /* FIX: use dvh for mobile viewport accuracy */
  height: 100dvh;
  overflow: hidden;
  transition:
    margin-left var(--shell-motion),
    width var(--shell-motion);
  border-radius: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  min-width: 0;
  padding: 12px 24px;
  background: #fff;
  border-bottom: var(--ui-border);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 0 var(--line-soft);
  /* Prevent shrinking below its content */
  flex-shrink: 0;
  border-radius: 0;
}

.topbar-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1 1 auto;
}

.topbar-title {
  min-width: 0;
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0;
  /* FIX: prevent title overflow on narrow screens */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar toggle button */
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  border: var(--ui-border);
  background: #fff;
  color: var(--text-2);
  cursor: pointer;
  flex: 0 0 auto;
  transition:
    background-color .18s ease,
    border-color .18s ease,
    color .18s ease,
    box-shadow .18s ease,
    transform .14s ease;
}

.sidebar-toggle:hover {
  background: var(--softButtonHover);
  border-color: #C6CEEA;
  color: var(--text);
}

.sidebar-toggle:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focusRing);
}

.sidebar-toggle:active { transform: translateY(1px); }
.sidebar-toggle-icon { display: block; }

/* User area */
.topbar-user {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  /* FIX: no-wrap to keep user area compact and aligned */
  flex-wrap: nowrap;
  min-width: 0;
  flex-shrink: 0;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-2);
  font-weight: 600;
  min-width: 0;
}

.user-chip > span:last-child {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand) 0%, #7B6EE3 100%);
  color: #fff;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .02em;
  box-shadow: 0 2px 6px rgba(67, 97, 238, .28);
  flex-shrink: 0;
}

.topbar-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 16px;
  background: var(--bg);
  color: var(--text-2);
  border: var(--ui-border);
  border-radius: var(--r-md);
  white-space: nowrap;
  font-weight: 600;
  font-size: var(--text-sm);
  letter-spacing: .01em;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition:
    background-color .15s ease,
    color .15s ease,
    border-color .15s ease,
    box-shadow .15s ease,
    transform .14s ease;
}

.topbar-logout:hover {
  background: #E8ECF7;
  border-color: #C6CEEA;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.topbar-logout:active {
  transform: translateY(0);
  box-shadow: var(--shadow-xs);
}

.topbar-logout:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focusRing);
}


/* ═══════════════════════════════════════════════════════════════
   CONTENT SHELL & PAGE STRUCTURE
   ═══════════════════════════════════════════════════════════════ */
.content-shell {
  position: relative;
  flex: 1 1 auto;
  padding: 20px 24px 32px;
  overflow: auto;
  min-height: 0;
  min-width: 0;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* FIX: removed scrollbar-gutter:stable both-edges — 'both-edges' not widely supported */
  scrollbar-gutter: stable;
  border-radius: 0;
}

.page-head {
  margin-bottom: 16px;
  display: flex;
  /* FIX: align-items should default to center, not justify-content flush-end */
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.page-head.is-empty { display: none; margin-bottom: 0; }

.page-head-tools {
  margin-left: auto;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  flex: 1 1 640px;
  min-width: 0;
}

.page-body { display: block; min-width: 0; }

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


/* ═══════════════════════════════════════════════════════════════
   CARDS & PANELS
   ═══════════════════════════════════════════════════════════════ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stat-card,
.panel-card {
  background: var(--panel);
  border: var(--ui-border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--panelShadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  will-change: transform;
}

.stat-card { text-align: center; }

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

.section-block {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.section-block > h3 {
  margin: 0;
  font-size: var(--text-md);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

/* Stat card typography */
.stat-card h3,
.stat-card > span {
  display: block;
  margin: 0;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--text);
}

.stat-card small,
.stat-card > .muted {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.45;
}

.panel-card h3 {
  margin: 0 0 14px;
  font-size: var(--text-md);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0;
  color: var(--text);
}

.panel-card > p:last-child,
.panel-card > .help-text:last-child { margin-bottom: 0; }


/* ── Analytics Scope ─────────────────────────────────────────── */
.analytics-scope-panel {
  margin-top: 20px;
  position: relative;
  display: grid;
  gap: 14px;
  min-width: 0;
}

.analytics-scope-panel-primary {
  padding-left: 14px;
  border-left: 3px solid var(--brand);
}

.analytics-scope-head { margin-bottom: 0; align-items: flex-start; }
.analytics-scope-head-filter-only { justify-content: flex-end; margin-bottom: 12px; }
.analytics-scope-head-split {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.analytics-scope-selected {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding-top: 2px;
}

.analytics-scope-selected span {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.analytics-scope-selected strong {
  color: var(--text);
  font-size: .96rem;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-chart-card-head { align-items: flex-start; margin-bottom: 14px; }
.analytics-scope-head h3 { margin: 2px 0 4px; }

.analytics-section-eyebrow {
  display: inline-flex;
  align-items: center;
  color: var(--brand);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.analytics-scope-filter {
  min-width: 260px;
  max-width: 360px;
  flex: 0 1 320px;
  margin-left: auto;
}

.analytics-scope-filter-auto {
  min-width: 0;
  max-width: 100%;
  width: auto;
  flex: 0 0 auto;
}

.analytics-scope-filter-auto select { width: auto; min-width: 0; max-width: 100%; }

.analytics-scope-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
  margin-left: auto;
}

.analytics-scope-filter-row .analytics-scope-filter-auto {
  margin-left: 0;
}

.analytics-scope-refresh {
  min-height: 40px;
  white-space: nowrap;
}

.analytics-section-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  background: rgba(242, 244, 248, .54);
  backdrop-filter: blur(2.5px);
  -webkit-backdrop-filter: blur(2.5px);
}

.analytics-section-loading-overlay .page-loading-spinner {
  animation-play-state: running;
}

.analytics-scope-grid { margin-top: 14px; }
.analytics-scope-grid > .panel-card { min-width: 0; }
.analytics-scope-grid-1 { grid-template-columns: 1fr; }
.analytics-scope-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.analytics-prescreener-section { margin-top: 18px; }
.analytics-prescreener-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.analytics-prescreener-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.analytics-prescreener-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 12px;
}
.analytics-prescreener-head span {
  display: block;
  color: var(--primary);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.analytics-prescreener-head h3 {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}
.analytics-prescreener-head small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.45;
}
.chart-frame-prescreener { height: 280px; }

.analytics-overview-grid {
  margin-top: 20px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}


/* ═══════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════ */
.table-wrap {
  overflow: auto;
  border: var(--ui-border);
  border-radius: var(--r-md);
  background: var(--panel);
  width: 100%;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
  scrollbar-gutter: stable;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}

th, td {
  padding: 12px 14px;
  border-bottom: var(--ui-border-soft);
  /* FIX: left-align is better default for data tables than center */
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
}

th {
  background: #F0F2FA;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--brand);
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: var(--ui-border);
}

tbody tr { transition: background .12s ease; }
tbody tr:hover td { background: #F5F7FF; }
tbody tr:last-child td { border-bottom: none; }

/* Sticky columns */
.data-table th.is-sticky-col,
.data-table td.is-sticky-col {
  position: sticky;
  background: var(--panel);
  z-index: 2;
  background-clip: padding-box;
}

.data-table thead th.is-sticky-col {
  background: #F0F2FA;
  z-index: 4;
}

.data-table .sticky-shadow {
  box-shadow: 8px 0 14px -12px rgba(13, 27, 42, .30);
}

.data-table th.col-internal_rid,
.data-table td.col-internal_rid,
.data-table th.col-supplier_rid,
.data-table td.col-supplier_rid {
  width: 1%;
  min-width: max-content;
  max-width: none;
}

.data-table td.col-internal_rid,
.data-table td.col-supplier_rid {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}


/* ═══════════════════════════════════════════════════════════════
   PAGE LOADING OVERLAY & SPINNER
   ═══════════════════════════════════════════════════════════════ */
.page-loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(242, 244, 248, .56);
  backdrop-filter: blur(2.5px);
  -webkit-backdrop-filter: blur(2.5px);
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s ease-out, visibility 0s linear .22s;
  will-change: opacity;
  contain: layout paint style;
}

/* FIX: shell variant should be absolute within the content area */
.page-loading-overlay-shell {
  position: absolute;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 60;
}

.page-loading-overlay.is-active,
html.page-loader-pending .page-loading-overlay-shell {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity .16s ease-out, visibility 0s linear 0s;
}

.page-loading-spinner {
  position: relative;
  width: 58px;
  height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  pointer-events: none;
  box-sizing: border-box;
  border-radius: 50%;
  border: 4px solid rgba(67, 97, 238, .16);
  border-top-color: var(--brand);
  border-right-color: var(--brand);
  animation: sms-loader-spin .78s linear infinite;
  animation-play-state: paused;
  transform-origin: 50% 50%;
  will-change: transform;
  backface-visibility: hidden;
  transform: translateZ(0);
  contain: layout paint style;
  isolation: isolate;
}

.page-loading-spinner::before,
.page-loading-spinner::after { content: none; }

.page-loading-spinner > svg { display: none !important; }

.page-loading-overlay.is-active .page-loading-spinner,
html.page-loader-pending .page-loading-overlay-shell .page-loading-spinner {
  animation-play-state: running;
}


/* ═══════════════════════════════════════════════════════════════
   TOOLBAR & FILTERS
   ═══════════════════════════════════════════════════════════════ */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}

.toolbar select,
.toolbar input {
  padding: 9px 12px;
  border: var(--ui-border);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--text);
  font-size: var(--text-sm);
  /* FIX: consistent height with buttons */
  min-height: 40px;
  transition: border-color .14s ease, box-shadow .14s ease;
}

.toolbar button,
.toolbar a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: none;
  border-radius: var(--r-sm);
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  transition:
    background-color .14s ease,
    box-shadow .14s ease,
    transform .12s ease;
}

.toolbar button:hover,
.toolbar a:hover {
  background: var(--brandHover);
  box-shadow: 0 4px 12px rgba(67, 97, 238, .22);
  transform: translateY(-1px);
}

.toolbar button:active,
.toolbar a:active { transform: translateY(0); }

/* View Filters */
.view-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.view-filter-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

.view-filter-row select,
.view-filter-row input {
  padding: 8px 10px;
  border: var(--ui-border);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--text);
  min-width: 130px;
  height: 38px;
  font-size: var(--text-sm);
  transition: border-color .14s ease, box-shadow .14s ease;
}

.view-filter-row .filter-wide { min-width: 170px; }
.view-filter-row .filter-date { min-width: 145px; }
.view-filter-row .multi-select-dropdown.filter-inline-multi {
  width: min(260px, 100%);
  min-width: 220px;
  flex: 1 1 240px;
}

.view-filter-row .btn-primary,
.view-filter-row .btn-secondary {
  padding: 8px 14px;
  height: 38px;
}

/* Shared hover/focus for all inputs */
.form-field input:hover,
.form-field select:hover,
.form-field textarea:hover,
.toolbar select:hover,
.toolbar input:hover,
.view-filter-row select:hover,
.view-filter-row input:hover { border-color: #B4BFDD; }

.form-field input:focus-visible,
.form-field select:focus-visible,
.form-field textarea:focus-visible,
.toolbar select:focus-visible,
.toolbar input:focus-visible,
.view-filter-row select:focus-visible,
.view-filter-row input:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focusRing);
}


/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */
.btn-primary, .btn-secondary, .btn-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 16px;
  border-radius: var(--r-md);
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-sm);
  letter-spacing: .01em;
  transition:
    background-color .16s ease,
    border-color .16s ease,
    color .16s ease,
    box-shadow .16s ease,
    opacity .16s ease,
    transform .12s ease;
}

/* Primary */
.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px rgba(67, 97, 238, .24);
}

.btn-primary:hover {
  background: var(--brandHover);
  box-shadow: 0 4px 14px rgba(67, 97, 238, .32);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(67, 97, 238, .18);
}

.btn-primary:focus-visible { box-shadow: 0 0 0 3px var(--focusRing); }

.btn-primary:disabled {
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Secondary */
.btn-secondary {
  background: var(--softButton);
  border: var(--ui-border);
  color: var(--softButtonText);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: var(--softButtonHover);
  border-color: #C6CEEA;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:focus-visible {
  box-shadow: 0 0 0 3px rgba(107, 120, 168, .25);
}

.btn-secondary:disabled {
  opacity: .60;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Export */
.btn-export {
  background: var(--export);
  border: 1px solid var(--export);
  color: #fff;
  box-shadow: 0 2px 8px rgba(58, 110, 252, .22);
}

.btn-export:hover {
  background: var(--exportHover);
  border-color: var(--exportHover);
  box-shadow: 0 4px 14px rgba(58, 110, 252, .30);
  transform: translateY(-1px);
}

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

.btn-export:focus-visible {
  box-shadow: 0 0 0 3px rgba(58, 110, 252, .28);
}

.btn-export:disabled {
  opacity: .60;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Export CSV id-specific (inherits btn-export styles) */
#exportCsvBtn { background: var(--export); border: 1px solid var(--export); color: #fff; }
#exportCsvBtn:hover { background: var(--exportHover); border-color: var(--exportHover); color: #fff; }
#exportCsvBtn:focus-visible {
  background: var(--export);
  border-color: #7EA8FF;
  box-shadow: 0 0 0 3px rgba(58, 110, 252, .28);
  color: #fff;
}

/* Small variant */
.btn-small {
  padding: 6px 10px;
  font-size: var(--text-xs);
  border-radius: var(--r-sm);
  min-height: 32px;
}

/* Table action link */
.table-action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 12px;
  border-radius: var(--r-sm);
  background: var(--brandLighter);
  border: 1px solid rgba(67, 97, 238, .18);
  color: var(--brand);
  font-weight: 600;
  font-size: var(--text-xs);
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(67, 97, 238, .08);
  transition:
    background-color .16s ease,
    color .16s ease,
    border-color .16s ease,
    box-shadow .16s ease,
    transform .12s ease;
}

.table-action-link:hover {
  background: var(--brandLight);
  color: var(--brandHover);
  border-color: rgba(67, 97, 238, .28);
  box-shadow: 0 4px 12px rgba(67, 97, 238, .18);
  transform: translateY(-1px);
}

.table-action-link:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(67, 97, 238, .08);
}

.table-action-link:focus-visible { box-shadow: 0 0 0 3px var(--focusRing); }


/* ═══════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════ */
.module-stack { display: grid; gap: 20px; }
.project-form-alerts { display: grid; gap: 10px; }
.project-update-log-view {
  margin: 14px 0 0;
  padding: 16px;
  max-height: 520px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8fafc;
  border: var(--ui-border);
  border-radius: var(--r-md);
  color: var(--ink);
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .span-2,
.form-grid .form-full { grid-column: 1 / -1; }
.compact-grid { align-items: end; }
.project-form-grid { align-items: start; }
.project-form-section-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 10px 0 2px;
  color: var(--primary);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.project-form-section-divider::before,
.project-form-section-divider::after {
  content: "";
  height: 1px;
  flex: 1 1 auto;
  background: var(--line);
}

.form-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.form-field label {
  font-weight: 600;
  font-size: var(--text-sm);
  line-height: 1.35;
  color: var(--text-2);
}

.form-field.is-required > label::after {
  content: " *";
  color: var(--danger);
  font-weight: 800;
}

.field-required { color: var(--danger); }
.field-hint {
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.45;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 11px 13px;
  border: var(--ui-border);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--text);
  font-size: var(--text-sm);
  transition:
    border-color .14s ease,
    box-shadow .14s ease,
    background-color .14s ease;
}

.form-field input::placeholder,
.form-field textarea::placeholder { color: var(--muted-2); }

/* FIX: unified disabled/readonly state */
.form-field input[readonly],
.form-field input:disabled,
.form-field select:disabled,
.form-field textarea:disabled {
  background: #F6F8FC;
  color: var(--muted);
  border-color: var(--line-soft);
  cursor: not-allowed;
  /* Prevent browser dimming on top of our styling */
  opacity: 1;
}

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

.nested-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 6px;
}

.inline-actions { align-self: end; }
.form-action-hint { flex: 1 1 100%; }

.textarea-compact { min-height: 55px !important; }

.form-full { grid-column: 1 / -1; }

.form-error {
  font-size: var(--text-sm);
  color: var(--danger);
  line-height: 1.35;
}

.form-field small {
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.45;
}

.phone-combo {
  display: grid;
  grid-template-columns: minmax(88px, .32fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.multi-select-dropdown {
  position: relative;
  width: 100%;
}

.multi-select-dropdown summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border: var(--ui-border);
  border-radius: var(--r-sm);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .02);
  transition: border-color .16s ease, box-shadow .16s ease;
}

.multi-select-dropdown summary::-webkit-details-marker { display: none; }
.multi-select-dropdown summary::marker { content: ""; }

.multi-select-dropdown summary:hover { border-color: #B4BFDD; }

.multi-select-dropdown[open] summary {
  border-color: #80a8ff;
  box-shadow: 0 0 0 4px var(--focusRing);
}

.multi-select-dropdown.is-invalid summary {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(217, 70, 56, .12);
}

.multi-select-dropdown.is-disabled summary {
  background: #F6F8FC;
  color: var(--muted);
  border-color: var(--line-soft);
  cursor: not-allowed;
}

.multi-select-dropdown [data-multi-summary] {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select-caret {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform .16s ease;
}

.multi-select-dropdown[open] .multi-select-caret {
  transform: rotate(225deg);
}

.multi-select-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow: auto;
  padding: 8px;
  border: var(--ui-border);
  border-radius: var(--r-sm);
  background: #ffffff;
  box-shadow: var(--shadow-lg);
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--r-xs);
  color: var(--text);
  font-size: var(--text-sm);
  line-height: 1.35;
  cursor: pointer;
}

.multi-select-option:hover { background: var(--brandLighter); }

.multi-select-option input[type="checkbox"] {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  margin: 0;
  box-shadow: none;
}

/* Validation state */
#userManagementForm input[aria-invalid="true"],
#userManagementForm select[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(217, 70, 56, .12);
}

.form-field input[aria-invalid="true"],
.form-field select[aria-invalid="true"],
.form-field textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(217, 70, 56, .12);
}

/* Input with action button inside */
.input-action-shell { position: relative; display: flex; align-items: center; }
.input-action-shell input { padding-right: 52px; }

.field-action-button {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--brand);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: background-color .14s ease;
}

.field-action-button svg { width: 18px; height: 18px; display: block; }
.field-action-button:hover { background: var(--brandLighter); }
.field-action-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focusRing);
}

/* Password strength */
.password-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.password-strength-cluster {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
}

.password-strength-bar {
  width: 120px;
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .22);
  overflow: hidden;
}

.password-strength-fill {
  display: block;
  height: 100%;
  width: 34%;
  border-radius: inherit;
  transition: width .18s ease, background-color .18s ease;
}

.password-strength-fill.strength-weak { width: 34%; background: var(--danger); }
.password-strength-fill.strength-medium { width: 67%; background: var(--warning); }
.password-strength-fill.strength-strong { width: 100%; background: var(--success); }

.password-strength-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-2);
}

/* Inline checkboxes */
.inline-checkboxes { display: flex; gap: 12px; flex-wrap: wrap; }

.inline-checkboxes label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border: var(--ui-border);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--text);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color .14s ease, background-color .14s ease;
}

.inline-checkboxes label:hover {
  border-color: #C6CEEA;
  background: var(--softButtonHover);
}

.inline-checkboxes input[type="checkbox"] { margin: 0; accent-color: var(--brand); }


/* ═══════════════════════════════════════════════════════════════
   ALERTS & FEEDBACK
   ═══════════════════════════════════════════════════════════════ */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  line-height: 1.55;
}

.alert-success {
  background: var(--successLight);
  border-color: rgba(14, 164, 114, .22);
  color: #0A6B4A;
}

.alert-error {
  background: var(--dangerLight);
  border-color: rgba(217, 70, 56, .22);
  color: #9E2B1E;
}

.alert-info {
  background: var(--infoLight);
  border-color: rgba(67, 97, 238, .20);
  color: #2D42A8;
}

/* FIX: added missing warning alert variant */
.alert-warning {
  background: var(--warningLight);
  border-color: rgba(232, 145, 10, .22);
  color: #8A5200;
}

.page-action-feedback { width: 100%; margin-bottom: 12px; }
.page-action-feedback-copy { display: grid; gap: 4px; }
.page-action-feedback-copy strong { font-size: var(--text-sm); line-height: 1.35; }
.page-action-feedback-copy span { font-size: var(--text-xs); line-height: 1.48; }

.module-load-feedback {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.module-load-feedback-inline { margin-bottom: 14px; }
.module-load-feedback-card { min-height: 160px; }
.module-load-feedback-copy { display: grid; gap: 6px; min-width: 0; }
.module-load-feedback-copy strong { font-size: var(--text-sm); line-height: 1.35; }
.module-load-feedback-copy span { color: inherit; line-height: 1.5; }

.module-load-feedback-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}


/* ═══════════════════════════════════════════════════════════════
   PAGINATION
   ═══════════════════════════════════════════════════════════════ */
.pagination-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.pagination-meta { color: var(--muted); font-size: var(--text-sm); }
.pagination-actions { display: flex; align-items: center; gap: 8px; }

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  transition:
    background-color .14s ease,
    border-color .14s ease,
    box-shadow .14s ease,
    transform .12s ease;
}

.page-btn:hover {
  background: var(--brandHover);
  border-color: var(--brandHover);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(67, 97, 238, .20);
}

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

.page-btn:focus-visible { box-shadow: 0 0 0 3px var(--focusRing); }

.page-btn.is-disabled {
  pointer-events: none;
  opacity: .45;
  transform: none;
}

.page-status {
  color: var(--text);
  font-weight: 600;
  font-size: var(--text-sm);
}


/* ═══════════════════════════════════════════════════════════════
   MISC UI COMPONENTS
   ═══════════════════════════════════════════════════════════════ */
.muted { color: var(--muted); }

.empty {
  padding: 28px;
  background: var(--panel);
  border: 1.5px dashed var(--line);
  border-radius: var(--r-lg);
  color: var(--muted);
  font-size: var(--text-sm);
  text-align: center;
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
  min-width: 0;
}

.button-row > * { min-width: 0; max-width: 100%; }

.entity-form-actions { align-items: center; }

.inline-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  min-width: 0;
}

.inline-toolbar .form-field { min-width: 220px; max-width: 100%; }

.inline-copy { display: flex; gap: 10px; align-items: center; min-width: 0; }
.inline-copy input { flex: 1 1 auto; min-width: 0; }

/* Copy icon button */
.copy-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: var(--ui-border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-2);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition:
    background-color .14s ease,
    color .14s ease,
    border-color .14s ease;
}

.copy-icon svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.8; }

.copy-icon:hover {
  background: var(--brandLighter);
  color: var(--brand);
  border-color: rgba(67, 97, 238, .24);
}

.copy-icon:focus-visible { box-shadow: 0 0 0 3px var(--focusRing); }

/* Cell truncation helpers */
.cell-truncate-20, .cell-truncate-30, .country-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.country-list-cell {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
}

.cell-truncate-20 .text {
  display: inline-block;
  max-width: 20ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-truncate-30 .text {
  display: inline-block;
  max-width: 30ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-copy-value {
  gap: 8px;
}

.cell-muted-dash {
  color: var(--muted);
  font-weight: 700;
}

/* Country flag */
.country-flag {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 12px;
  flex: 0 0 18px;
  overflow: hidden;
  border-radius: 3px;
  background: linear-gradient(180deg, #FFF 0%, #F8FAFC 100%);
  box-shadow: inset 0 0 0 1px rgba(20, 25, 40, .12);
}

.country-flag-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  transform: translateZ(0);
}

.country-flag-fallback { display: none; width: 100%; height: 100%; }
.country-flag.is-fallback { background: linear-gradient(180deg, #F8FAFC 0%, #E2E8F0 100%); }
.country-flag.is-fallback .country-flag-fallback { display: block; }

.country-flag.is-fallback::before {
  content: "";
  position: absolute;
  inset: 2px 4px;
  border-radius: 999px;
  border: 1.2px solid #64748B;
  opacity: .65;
}

.country-flag.is-fallback::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  height: 1px;
  background: #64748B;
  opacity: .65;
  transform: translateY(-50%);
}


/* ═══════════════════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════════════════ */
.dashboard-stack { display: grid; gap: 22px; }

.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.dashboard-kpi-card {
  background: linear-gradient(160deg, #fff 0%, #f8faff 100%);
  box-shadow: 0 4px 18px rgba(20, 25, 40, .05);
}

.dashboard-kpi-metric {
  font-size: 2.35rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  margin: 8px 0 10px;
  color: var(--text);
}

.dashboard-mini-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.dashboard-mini-grid div {
  padding: 14px;
  border: var(--ui-border-soft);
  border-radius: var(--r-md);
  background: var(--panel-alt);
  transition: box-shadow .14s ease, border-color .14s ease;
}

.dashboard-mini-grid div:hover {
  border-color: var(--line);
  box-shadow: var(--shadow-xs);
}

.dashboard-mini-grid strong {
  display: block;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 4px;
}

.dashboard-mini-grid span {
  display: block;
  font-size: var(--text-xs);
  color: var(--muted);
}

.dashboard-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

/* FIX: consolidate height rule */
.dashboard-grid-2 > .panel-card,
.dashboard-grid-3 > .panel-card {
  min-width: 0;
  height: 100%;
}

.dashboard-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}

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

.dashboard-panel-head p {
  max-width: 64ch;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.6;
}

/* Charts */
.chart-frame { position: relative; width: 100%; min-width: 0; }
.chart-frame-lg { height: 320px; }
.chart-frame-md { height: 260px; }
.chart-frame-sm { height: 220px; }
.chart-frame-country { height: 260px; }
.chart-frame-stats { height: 260px; }
.panel-card canvas { width: 100% !important; height: 100% !important; max-width: 100%; }


/* ═══════════════════════════════════════════════════════════════
   COUNTRY MAP
   ═══════════════════════════════════════════════════════════════ */
.country-volume-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.25fr;
  gap: 18px;
  align-items: stretch;
}

.country-map-shell {
  display: grid;
  grid-template-rows: minmax(220px, 1fr) auto;
  gap: 14px;
}

.country-map-stage {
  position: relative;
  min-height: 220px;
  border: var(--ui-border);
  border-radius: var(--r-xl);
  background: linear-gradient(160deg, #f6f9ff 0%, #EDF2FF 100%);
  overflow: hidden;
}

.map-blob {
  position: absolute;
  background: rgba(67, 97, 238, .07);
  border: 1px solid rgba(67, 97, 238, .10);
  filter: drop-shadow(0 14px 18px rgba(67, 97, 238, .06));
}

.map-blob-americas { left: 8%; top: 18%; width: 28%; height: 46%; border-radius: 42% 58% 53% 47% / 36% 41% 59% 64%; }
.map-blob-europe { left: 42%; top: 20%; width: 16%; height: 18%; border-radius: 56% 44% 51% 49% / 45% 41% 59% 55%; }
.map-blob-asia { left: 54%; top: 26%; width: 28%; height: 34%; border-radius: 47% 53% 42% 58% / 48% 37% 63% 52%; }
.map-blob-oceania { left: 77%; top: 67%; width: 12%; height: 14%; border-radius: 52% 48% 60% 40% / 45% 49% 51% 55%; }

.map-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  border: none;
  background: transparent;
  padding: 0;
  cursor: default;
}

.map-marker-dot {
  display: block;
  border-radius: 999px;
  border: 2px solid transparent;
  box-shadow: 0 6px 16px rgba(20, 25, 40, .12);
}

.map-marker-flag {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: .95rem;
  line-height: 1;
}

.country-map-legend { display: grid; gap: 8px; }

.country-map-legend-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border: var(--ui-border-soft);
  border-radius: var(--r-sm);
  background: var(--panel-alt);
  transition: border-color .12s ease;
}

.country-map-legend-item:hover { border-color: var(--line); }
.legend-swatch { width: 9px; height: 9px; border-radius: 999px; }
.legend-label { font-size: var(--text-sm); color: var(--text-2); }


/* ═══════════════════════════════════════════════════════════════
   RECONCILIATION
   ═══════════════════════════════════════════════════════════════ */
.reconciliation-view-layout,
.reconciliation-history-layout,
.reconciliation-workspace-layout { min-width: 0; }

.reconciliation-workspace-panel { min-width: 0; overflow: hidden; }

.reconciliation-kpi-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
}

.reconciliation-source-grid,
.reconciliation-rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.reconciliation-source-grid > .panel-card,
.reconciliation-rule-grid > .panel-card,
.reconciliation-source-card { min-width: 0; }

.reconciliation-allocation-stack {
  display: grid;
  gap: 14px;
}

.reconciliation-allocation-card {
  border: var(--ui-border);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.reconciliation-allocation-card[hidden] { display: none; }

.reconciliation-allocation-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.reconciliation-allocation-head strong,
.reconciliation-allocation-head span,
.reconciliation-allocation-head small { display: block; }

.reconciliation-allocation-head span,
.reconciliation-allocation-head small { color: var(--muted); }

.reconciliation-allocation-meta {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 6px;
  text-align: right;
}

.recon-type-badge {
  display: inline-flex !important;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border: 1px solid rgba(79, 70, 229, 0.2);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
  min-width: 78px;
  justify-content: center;
  background: rgba(79, 70, 229, 0.1);
  color: #4338ca;
}

.recon-type-parent { background: rgba(5, 150, 105, 0.12); border-color: rgba(5, 150, 105, 0.24); color: #047857; }
.recon-type-child { background: rgba(37, 99, 235, 0.12); border-color: rgba(37, 99, 235, 0.24); color: #1d4ed8; }
.recon-type-adhoc { background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.28); color: #b45309; }
.recon-type-tracker { background: rgba(124, 58, 237, 0.12); border-color: rgba(124, 58, 237, 0.24); color: #6d28d9; }
.recon-type-recontact { background: rgba(14, 165, 233, 0.12); border-color: rgba(14, 165, 233, 0.24); color: #0369a1; }

.recon-source-textarea { min-height: 180px; resize: vertical; }
.recon-run-feedback:empty { display: none; }

.reconciliation-summary-panel,
.reconciliation-result-panel,
.reconciliation-history-panel { min-width: 0; overflow: hidden; }

.reconciliation-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.reconciliation-summary-grid > .panel-card { min-width: 0; }
.reconciliation-summary-grid ul { margin: 0; padding-left: 18px; }
.reconciliation-summary-grid li { overflow-wrap: anywhere; }
.reconciliation-summary-grid li .table-action-link { margin-left: 8px; vertical-align: middle; }
.reconciliation-summary-grid li .help-text { margin: 4px 0 0; }

.reconciliation-result-panel .table-wrap,
.reconciliation-history-panel .table-wrap { max-width: 100%; overflow: auto; }

.reconciliation-history-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.reconciliation-result-table,
.reconciliation-history-table { width: max-content; min-width: 100%; }

.reconciliation-result-table th.col-source-value,
.reconciliation-result-table td.col-source-value,
.reconciliation-result-table th.col-internal-rid,
.reconciliation-result-table td.col-internal-rid,
.reconciliation-result-table th.col-supplier-rid,
.reconciliation-result-table td.col-supplier-rid {
  width: 1%;
  min-width: max-content;
  max-width: none;
}

.reconciliation-result-table td.col-source-value,
.reconciliation-result-table td.col-internal-rid,
.reconciliation-result-table td.col-supplier-rid {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.reconciliation-result-table td:nth-child(10) { max-width: 320px; white-space: normal; }

.reconciliation-history-table td:nth-child(3),
.reconciliation-history-table td:nth-child(4) { white-space: nowrap; }


/* ═══════════════════════════════════════════════════════════════
   SURVEY
   ═══════════════════════════════════════════════════════════════ */
.survey-panel {
  box-shadow: 0 8px 24px rgba(20, 25, 40, .05);
  background: linear-gradient(170deg, #fff 0%, #fafbff 100%);
}

.survey-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.survey-section-head > div { width: 100%; }
.survey-section-head h3 { margin: 0; }

.survey-section-head p {
  margin: 6px 0 0;
  color: var(--muted);
  max-width: none;
  line-height: 1.65;
  font-size: var(--text-sm);
}

.survey-toolbar {
  justify-content: flex-start;
  align-items: flex-end;
}

.survey-toolbar-field {
  min-width: 280px;
  flex: 1 1 280px;
}
.survey-toolbar-actions {
  display: flex;
  align-items: flex-end;
  flex: 0 0 auto;
}

.survey-toolbar-note {
  margin-top: 8px;
}

.survey-toolbar-note small {
  display: block;
  color: var(--muted);
  line-height: 1.55;
}

.survey-meta-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.survey-meta-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.survey-link-grid { margin-top: 20px; align-items: start; }
.survey-link-grid-equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.survey-link-pack {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid rgba(67, 97, 238, .12);
  border-radius: var(--r-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .82) 0%, rgba(248, 251, 255, .96) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .72),
    0 12px 28px rgba(20, 25, 40, .04);
}

.survey-link-pack .survey-link-grid {
  margin-top: 0;
}

.survey-link-grid-equal > .survey-links-panel {
  min-width: 0;
  height: 100%;
}

.survey-form-grid .form-field label,
.survey-prescreener-grid .form-field label { color: var(--text); }

.survey-validation-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}

.survey-rule-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border: var(--ui-border);
  border-radius: var(--r-lg);
  background: linear-gradient(170deg, #fff 0%, #f8fbff 100%);
  min-height: 100%;
  box-shadow: var(--shadow-xs);
}

.survey-rule-head {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.survey-rule-head label {
  margin: 0;
}

.survey-rule-head small {
  color: var(--muted);
  line-height: 1.55;
}

.survey-load-panel .survey-toolbar {
  align-items: end;
}

.survey-meta-card {
  text-align: left;
  align-items: flex-start;
}

.survey-meta-card strong {
  width: 100%;
  font-size: 1.25rem;
  line-height: 1.35;
  word-break: break-word;
}

.survey-meta-card span {
  width: 100%;
}

.survey-links-panel .form-grid {
  gap: 14px;
}

.survey-links-panel {
  display: flex;
  flex-direction: column;
}

.survey-links-panel .survey-form-grid {
  flex: 1 1 auto;
  align-content: start;
}

.survey-links-head-action {
  flex: 0 0 min(360px, 100%);
  width: min(360px, 100%);
}

.survey-links-head-action-field {
  gap: 0;
  margin: 0;
}

.survey-links-section-head {
  display: grid;
  gap: 12px;
  align-items: start;
}

.survey-links-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
}

.survey-links-head-row h3 {
  margin: 0;
  flex: 1 1 auto;
}

.survey-links-section-head > p {
  width: 100%;
  margin: 0;
  max-width: none;
}

.survey-links-head-action-field select {
  width: 100%;
  min-width: 0;
}

.survey-links-panel .inline-copy {
  align-items: stretch;
}

.survey-links-panel .inline-copy input {
  background: #fff;
}

.survey-links-panel .inline-copy .btn-primary {
  align-self: stretch;
  min-width: 98px;
}

.survey-url-note {
  margin-top: 2px;
  padding: 12px 14px;
  border: 1px dashed rgba(67, 97, 238, .22);
  border-radius: var(--r-md);
  background: rgba(67, 97, 238, .04);
}

.survey-url-note small {
  color: var(--text-2);
  line-height: 1.55;
}

/* Survey terminate options */
.survey-terminate-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  width: 100%;
}

.survey-terminate-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 12px 14px;
  border: var(--ui-border);
  border-radius: var(--r-md);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition:
    border-color .16s ease,
    box-shadow .16s ease,
    background-color .16s ease,
    transform .14s ease;
}

.survey-terminate-option:hover {
  border-color: #C6CEEA;
  background: var(--softButtonHover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.survey-terminate-option:has(input:checked) {
  border-color: rgba(67, 97, 238, .50);
  background: var(--brandLighter);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, .10);
  transform: translateY(0);
}

.survey-terminate-option input[type="checkbox"] {
  width: 16px !important;
  min-width: 16px;
  max-width: 16px;
  height: 16px;
  margin: 0;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  display: block;
  appearance: auto;
  -webkit-appearance: checkbox;
  flex: 0 0 16px;
  accent-color: var(--brand);
}

/* FIX: remove duplicate rules — combined into one */
.survey-terminate-option input[type="checkbox"]:hover,
.survey-terminate-option input[type="checkbox"]:focus-visible,
.survey-terminate-option input[type="checkbox"]:disabled {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
}

.survey-terminate-option-text {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  font-size: var(--text-sm);
  line-height: 1.45;
  word-break: normal;
  overflow-wrap: break-word;
}

.survey-checkbox-row {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  margin-top: 2px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.45;
  cursor: pointer;
}

.survey-checkbox-row input[type="checkbox"] {
  margin: 0;
  order: 0;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.survey-checkbox-row span { order: 1; display: inline-block; }

.survey-prescreener-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.survey-quota-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.survey-copy-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
  margin: 0 0 18px;
  padding: 16px;
  border: var(--ui-border);
  border-radius: var(--r-lg);
  background: linear-gradient(170deg, #fff 0%, #f8fbff 100%);
  box-shadow: var(--shadow-xs);
}

.survey-copy-panel h4 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: var(--text-md);
}

.survey-copy-panel p {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.55;
}

.survey-copy-toolbar {
  display: block;
  width: 100%;
  margin: 0;
}

.survey-copy-field {
  width: 100%;
  max-width: 760px;
  min-width: 0;
}

.survey-copy-input-row {
  display: grid;
  grid-template-columns: minmax(280px, 620px) max-content;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.survey-copy-input-row select {
  width: 100%;
  min-width: 0;
  max-width: none;
}

.survey-copy-input-row .btn-secondary {
  flex: 0 0 auto;
  width: auto;
  min-width: 120px;
  justify-self: start;
  white-space: nowrap;
}

.survey-copy-field small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.survey-question-card {
  border: var(--ui-border);
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow: var(--shadow-xs);
  padding: 0;
  overflow: hidden;
  transition: border-color .16s ease, box-shadow .16s ease, opacity .16s ease, background-color .16s ease;
}

.survey-question-card + .survey-question-card { margin-top: 4px; }

.survey-question-card.is-disabled {
  background: #F8FAFC;
  opacity: .82;
}

.survey-question-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  margin: 0;
}

.survey-question-collapse {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

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

.survey-question-title-row strong {
  color: var(--text);
  font-size: var(--text-lg);
}

.survey-question-title-row em {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--brandLighter);
  color: var(--brand);
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.survey-question-title-row em.is-enabled {
  background: rgba(5, 150, 105, .12);
  color: #047857;
}

.survey-question-title-row em.is-required {
  background: rgba(67, 97, 238, .10);
  color: var(--brand);
}

.survey-question-title-row em.is-disabled {
  background: #E5E7EB;
  color: #64748B;
}

.survey-question-card.is-disabled .survey-question-title-row em {
  background: #E5E7EB;
  color: #64748B;
}

.survey-question-head h4 {
  margin: 0;
  color: var(--text);
  font-size: var(--text-lg);
}

.survey-question-head p,
.survey-question-collapse small {
  display: block;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.55;
}

.survey-question-chevron {
  position: relative;
  display: inline-flex;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  align-items: center;
  justify-content: center;
  border: var(--ui-border);
  border-radius: var(--r-md);
  background: var(--softButton);
}

.survey-question-chevron::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--brand);
  border-bottom: 2px solid var(--brand);
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform .16s ease;
}

.survey-question-card:not(.is-collapsed) .survey-question-chevron::before {
  transform: rotate(225deg) translate(-1px, -1px);
}

.survey-question-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 38px;
  padding: 8px 12px;
  border: var(--ui-border);
  border-radius: var(--r-md);
  background: var(--softButton);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
}

.survey-question-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--brand);
}

.survey-question-controls {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  padding: 0 16px 16px;
  border-top: var(--ui-border);
}

.survey-question-card.is-collapsed .survey-question-body {
  display: none;
}

.survey-checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}

.survey-checkbox-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.survey-checkbox-row label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

@media (max-width: 768px) {
  .survey-copy-panel {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .survey-copy-toolbar {
    display: block;
  }

  .survey-copy-field {
    min-width: 0;
    max-width: none;
  }

  .survey-copy-input-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .survey-copy-input-row select {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .survey-copy-input-row .btn-secondary {
    width: 100%;
  }

  .survey-validation-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .survey-question-head {
    flex-direction: column;
    align-items: stretch;
  }

  .survey-question-toggle {
    justify-content: center;
    width: 100%;
  }

  .survey-question-controls {
    grid-template-columns: 1fr;
  }
}


/* ═══════════════════════════════════════════════════════════════
   USER MANAGEMENT
   ═══════════════════════════════════════════════════════════════ */
.user-management-layout,
.user-management-panel,
.user-management-table-panel,
.user-management-table-card { min-width: 0; }

.user-management-panel,
.user-management-table-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.user-management-alert:empty { display: none; }

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

.user-management-head h3 { margin-bottom: 8px; }

.user-management-role-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--brandLighter);
  border: 1px solid rgba(67, 97, 238, .16);
  color: var(--brand);
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: .02em;
  white-space: nowrap;
}

.user-management-form-grid { align-items: start; }
.user-management-actions { margin-top: 14px; justify-content: flex-start; }
.user-management-table-card { width: 100%; max-width: 100%; overflow: hidden; }

.user-management-table-card .table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.user-management-table-card .data-table {
  width: max-content;
  min-width: 100%;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  border: var(--ui-border);
  background: var(--soft);
  color: var(--text-2);
  font-size: var(--text-xs);
  font-weight: 800;
  white-space: nowrap;
}

.user-badge-role-admin,
.user-badge-status-active {
  background: rgba(5, 150, 105, .10);
  border-color: rgba(5, 150, 105, .24);
  color: var(--success);
}

.user-badge-role-manager,
.user-badge-role-project-manager {
  background: var(--brandLighter);
  border-color: rgba(67, 97, 238, .18);
  color: var(--brand);
}

.user-badge-role-finance {
  background: rgba(245, 158, 11, .12);
  border-color: rgba(245, 158, 11, .25);
  color: #B45309;
}

.user-badge-status-inactive,
.user-badge-status-archived,
.user-badge-role-viewer {
  background: rgba(100, 116, 139, .10);
  border-color: rgba(100, 116, 139, .22);
  color: var(--muted);
}

.user-badge-status-blocked {
  background: rgba(220, 38, 38, .10);
  border-color: rgba(220, 38, 38, .22);
  color: var(--danger);
}


/* ═══════════════════════════════════════════════════════════════
   SUPPORT
   ═══════════════════════════════════════════════════════════════ */
.support-help-card,
.support-section-card { padding: 22px; }

.support-help-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(180deg, #fff 0%, rgba(248, 250, 252, .96) 100%);
}

.support-help-card.has-support-bg {
  min-height: 360px;
  padding: clamp(24px, 2.4vw, 36px);
  background-color: #fff;
  background-image: var(--support-help-bg-image);
  background-size: auto 100%;
  background-position: top right;
  background-repeat: no-repeat;
  border-color: rgba(67, 97, 238, .16);
  box-shadow: 0 22px 42px rgba(15, 23, 42, .10);
}

.support-help-card.has-support-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(90deg, rgba(255,255,255,.99) 0%, rgba(255,255,255,.97) 36%, rgba(255,255,255,.72) 64%, rgba(255,255,255,.10) 100%),
    linear-gradient(180deg, rgba(240,244,255,.10) 0%, rgba(255,255,255,.04) 100%);
  pointer-events: none;
}

.support-help-card.has-support-bg::after {
  content: "";
  position: absolute;
  inset: 42px auto auto 58%;
  width: 160px;
  height: 96px;
  z-index: 0;
  background-image: radial-gradient(circle, rgba(67, 97, 238, .24) 0 1.4px, transparent 1.8px);
  background-size: 22px 22px;
  opacity: .42;
  pointer-events: none;
}

.support-help-layout {
  position: relative;
  z-index: 1;
  display: grid;
  gap: clamp(22px, 2.4vw, 32px);
}

.support-help-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.support-help-kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: 16px;
  background: rgba(240, 244, 255, .88);
  border: 1px solid rgba(67, 97, 238, .10);
  color: var(--brand);
  font-weight: 900;
  font-size: clamp(.78rem, .88vw, .95rem);
  text-transform: uppercase;
  letter-spacing: .08em;
  box-shadow: 0 14px 28px rgba(67, 97, 238, .08);
}

.support-help-kicker svg {
  flex: 0 0 auto;
}

.support-help-copy h2 {
  margin: 22px 0 12px;
  font-size: clamp(1.75rem, 2.4vw, 2.35rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0;
}

.support-help-copy p {
  margin: 0;
  color: var(--muted);
  font-size: clamp(.94rem, 1.02vw, 1.06rem);
  line-height: 1.65;
  max-width: 56ch;
}

.support-help-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: clamp(14px, 1.1vw, 18px);
}

.support-help-contact {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-height: 168px;
  padding: 22px 22px 28px;
  border: var(--ui-border);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, .94);
  min-width: 0;
  overflow: hidden;
  box-shadow: 0 14px 28px rgba(15, 23, 42, .07);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background-color .16s ease;
}

.support-help-card.has-support-bg .support-help-contact {
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-color: rgba(67, 97, 238, .14);
}

.support-help-contact:hover {
  transform: translateY(-2px);
  border-color: rgba(67, 97, 238, .22);
  background: #fff;
  box-shadow: 0 18px 34px rgba(15, 23, 42, .10);
}

.support-help-contact > div {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.support-contact-icon,
.support-topic-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: var(--r-sm);
  background: var(--brandLighter);
  color: var(--brand);
  border: 1px solid rgba(67, 97, 238, .16);
}

.support-contact-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
}

.support-topic-icon {
  width: 38px;
  height: 38px;
}

.support-help-contact > div > span {
  font-size: clamp(.72rem, .78vw, .84rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--brand);
}

.support-help-contact strong,
.support-help-contact a {
  font-size: clamp(.90rem, .94vw, 1rem);
  font-weight: 900;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
}

.support-help-contact p {
  margin: 0;
  color: var(--muted);
  font-size: clamp(.78rem, .82vw, .88rem);
  line-height: 1.55;
}

.support-help-contact p b {
  color: var(--text);
  font-weight: 800;
}

.support-help-contact-email .support-contact-icon {
  background: rgba(67, 97, 238, .10);
  border-color: rgba(67, 97, 238, .18);
  color: var(--brand);
}

.support-help-contact-email::after,
.support-help-contact-hours::after,
.support-help-contact-response::after,
.support-help-contact-critical::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 4px;
  background: var(--brand);
}

.support-help-contact-hours .support-contact-icon {
  background: rgba(5, 150, 105, .12);
  border-color: rgba(5, 150, 105, .18);
  color: var(--success);
}

.support-help-contact-hours > div > span {
  color: var(--success);
}

.support-help-contact-hours::after {
  background: var(--success);
}

.support-help-contact-response .support-contact-icon {
  background: rgba(124, 58, 237, .12);
  border-color: rgba(124, 58, 237, .18);
  color: var(--info);
}

.support-help-contact-response > div > span {
  color: var(--info);
}

.support-help-contact-response::after {
  background: var(--info);
}

.support-help-contact-critical .support-contact-icon {
  background: rgba(245, 158, 11, .13);
  border-color: rgba(245, 158, 11, .24);
  color: var(--warning);
}

.support-help-contact-critical > div > span {
  color: var(--warning);
}

.support-help-contact-critical::after {
  background: var(--warning);
}

.support-section-card {
  display: grid;
  gap: 18px;
}

.support-section-head {
  display: grid;
  gap: 6px;
}

.support-section-head h3 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--text);
}

.support-section-eyebrow {
  color: var(--brand);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.support-topic-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.support-topic-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 10px;
  min-width: 0;
  min-height: 152px;
  padding: 18px;
  border: var(--ui-border);
  border-radius: var(--r-md);
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
  overflow: hidden;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.support-topic-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--brand);
  opacity: .82;
}

.support-topic-card:hover {
  transform: translateY(-2px);
  border-color: rgba(67, 97, 238, .22);
  box-shadow: 0 16px 28px rgba(15, 23, 42, .08);
}

.support-topic-card h4 {
  margin: 0;
  color: var(--text);
  font-size: .98rem;
  font-weight: 800;
  line-height: 1.35;
}

.support-topic-card p,
.support-faq-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.62;
  font-size: var(--text-sm);
}

.support-faq-list {
  display: grid;
  gap: 10px;
}

.support-faq-item {
  border: var(--ui-border);
  border-radius: var(--r-md);
  background: #fff;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
  transition: border-color .16s ease, box-shadow .16s ease;
}

.support-faq-item:hover {
  border-color: rgba(67, 97, 238, .20);
  box-shadow: 0 10px 22px rgba(15, 23, 42, .06);
}

.support-faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 48px;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--text);
  font-weight: 800;
  list-style: none;
}

.support-faq-item summary::-webkit-details-marker { display: none; }

.support-faq-item summary::after {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--brandLighter);
  color: var(--brand);
  font-weight: 900;
  line-height: 1;
}

.support-faq-item[open] summary {
  border-bottom: var(--ui-border);
  background: var(--panel-alt);
}

.support-faq-item[open] summary::after { content: "-"; }

.support-faq-item p { padding: 13px 14px 15px; }

/* ═══════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════ */
.help-text { font-size: var(--text-sm); color: var(--muted); line-height: 1.55; }
.is-hidden { display: none !important; }
.form-stack-spaced { margin-top: 16px; }
.filter-block-spaced { margin: 12px 0 16px; }
.filter-row-start { justify-content: flex-start; }
.panel-card-spaced { margin-top: 22px; }

/* Code/monospace block */
.setup-code-block {
  display: block;
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(217, 70, 56, .15);
  border-radius: var(--r-sm);
  background: #fff;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

#loadRespondentForm { margin-bottom: 16px; }


/* ═══════════════════════════════════════════════════════════════
   KEYFRAMES
   ═══════════════════════════════════════════════════════════════ */
@keyframes sms-spin { to { transform: rotate(360deg); } }

@keyframes sms-loader-spin {
  from { transform: translateZ(0) rotate(0turn); }
  to   { transform: translateZ(0) rotate(1turn); }
}


/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   Hierarchy: 1600 → 1366 → 1100 (sidebar overlay) → 900 → 760 → 700
   ═══════════════════════════════════════════════════════════════ */

/* ── 1600px ──────────────────────────────────────────────────── */
@media (max-width: 1600px) {
  :root {
    --sidebar-expanded: 258px;
    --sidebar-collapsed: 72px;
    --topbar-h: 62px;
  }

  body { font-size: 14px; }

  .sidebar { padding: 18px 12px; }
  .topbar { padding: 10px 18px; min-height: 62px; }
  .topbar-title { font-size: 1.22rem; }
  .content-shell { padding: 14px 16px 20px; }
  .page-head { margin-bottom: 12px; gap: 12px; }
  .page-head-tools { flex-basis: 520px; min-width: 280px; }
  .card-grid { gap: 12px; }
  .section-block { gap: 12px; }
  .stat-card, .panel-card { padding: 16px; }
  .stat-card h3, .stat-card > span { font-size: .70rem; }
  .stat-card strong { font-size: 1.65rem; margin-top: 8px; }
  .analytics-scope-panel { margin-top: 16px; }
  .analytics-scope-head { margin-bottom: 0; }
  .analytics-scope-grid { margin-top: 10px; }
  .dashboard-kpi-metric { font-size: 1.90rem; }
  .dashboard-mini-grid { gap: 10px; margin-top: 12px; }
  .dashboard-mini-grid div { padding: 10px; }
  .dashboard-mini-grid strong { font-size: .96rem; }
  .dashboard-panel-head { margin-bottom: 10px; }
  .chart-frame-lg { height: 280px; }
  .chart-frame-md, .chart-frame-country, .chart-frame-stats { height: 222px; }
  .chart-frame-sm { height: 190px; }
  .toolbar { margin-bottom: 12px; }
  .toolbar select, .toolbar input { padding: 8px 10px; font-size: .88rem; }
  .toolbar button, .toolbar a { padding: 8px 11px; font-size: .88rem; }
  .view-filter-row { gap: 8px; }
  .view-filter-row select, .view-filter-row input {
    min-width: 118px; height: 34px; padding: 7px 9px; font-size: .84rem;
  }
  .view-filter-row .filter-wide { min-width: 148px; }
  .view-filter-row .filter-date { min-width: 130px; }
  .view-filter-row .multi-select-dropdown.filter-inline-multi {
    width: min(232px, 100%);
    min-width: 188px;
    flex-basis: 210px;
  }
  .view-filter-row .btn-primary, .view-filter-row .btn-secondary { height: 34px; padding: 7px 11px; }
  .form-grid { gap: 12px; }
  .form-field input, .form-field select, .form-field textarea { padding: 9px 10px; font-size: .88rem; }
  .button-row { gap: 10px; }
  .btn-primary, .btn-secondary, .btn-export { padding: 8px 13px; font-size: .88rem; }
  .inline-toolbar .form-field { min-width: 180px; }
  .survey-toolbar-field { min-width: 332px; flex-basis: 332px; }
  .support-help-card { padding: 20px; }
  .support-help-layout { gap: 20px; }
  .support-help-copy h2 { font-size: 1.34rem; }
  .table-wrap { border-radius: var(--r-md); }
  .table-wrap table { width: max-content; min-width: 100%; table-layout: auto; }
  .data-table th, .data-table td { white-space: nowrap; }
  .data-table th { padding: 9px 10px; font-size: .70rem; letter-spacing: normal; }
  .data-table td { padding: 9px 10px; font-size: .84rem; }
  .data-table th.col-internal_rid, .data-table td.col-internal_rid,
  .data-table th.col-supplier_rid, .data-table td.col-supplier_rid {
    width: 1%; min-width: max-content; max-width: none;
  }
  .table-action-link { padding: 4px 8px; font-size: .74rem; }
  .pagination-bar { margin-top: 10px; }
  .page-btn { padding: 7px 11px; font-size: .84rem; }
}


/* ── 1366px ──────────────────────────────────────────────────── */
@media (max-width: 1366px) {
  :root {
    --sidebar-expanded: 232px;
    --sidebar-collapsed: 68px;
    --topbar-h: 58px;
  }

  body { font-size: 13px; }

  .sidebar { padding: 16px 10px; }
  .topbar { padding: 10px 14px; min-height: 58px; }
  .topbar-title { font-size: 1.12rem; }
  .user-avatar { width: 30px; height: 30px; font-size: .76rem; }
  .topbar-logout { min-height: 34px; padding: 6px 12px; font-size: .84rem; }
  .content-shell { padding: 10px 12px 16px; }
  .page-head { margin-bottom: 9px; gap: 10px; }
  .page-head-tools { min-width: 250px; }
  .card-grid { gap: 10px; }
  .section-block { gap: 10px; }
  .stat-card, .panel-card { padding: 12px; border-radius: var(--r-md); }
  .stat-card h3, .stat-card > span { font-size: .66rem; }
  .stat-card strong { font-size: 1.45rem; margin-top: 6px; }
  .analytics-scope-panel { margin-top: 12px; }
  .analytics-scope-head { margin-bottom: 0; }
  .analytics-section-eyebrow { font-size: .60rem; }
  .analytics-scope-filter { min-width: 220px; max-width: 320px; }
  .analytics-scope-filter-auto { min-width: 0; max-width: 100%; }
  .analytics-scope-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-kpi-metric { font-size: 1.72rem; margin: 5px 0 7px; }
  .dashboard-stack, .dashboard-kpi-grid, .module-stack { gap: 12px; }
  .dashboard-mini-grid { gap: 8px; margin-top: 10px; }
  .dashboard-mini-grid div { padding: 8px; border-radius: var(--r-sm); }
  .dashboard-mini-grid strong { font-size: .88rem; }
  .dashboard-mini-grid span { font-size: .70rem; }
  .dashboard-panel-head { gap: 10px; margin-bottom: 8px; }
  .chart-frame-lg { height: 252px; }
  .chart-frame-md, .chart-frame-country, .chart-frame-stats { height: 202px; }
  .chart-frame-sm { height: 172px; }
  .toolbar { gap: 7px; margin-bottom: 10px; }
  .toolbar select, .toolbar input, .toolbar button, .toolbar a { padding: 7px 9px; font-size: .84rem; }
  .view-filters { gap: 5px; }
  .view-filter-row { gap: 7px; }
  .view-filter-row select, .view-filter-row input {
    min-width: 108px; height: 30px; padding: 5px 8px; font-size: .80rem;
  }
  .view-filter-row .filter-wide { min-width: 136px; }
  .view-filter-row .filter-date { min-width: 122px; }
  .view-filter-row .multi-select-dropdown.filter-inline-multi {
    width: min(220px, 100%);
    min-width: 176px;
    flex-basis: 196px;
  }
  .view-filter-row .btn-primary, .view-filter-row .btn-secondary { height: 30px; padding: 5px 9px; font-size: .80rem; }
  .form-grid { gap: 10px; }
  .form-field { gap: 5px; }
  .form-field label { font-size: .80rem; }
  .form-field input, .form-field select, .form-field textarea { padding: 8px 9px; font-size: .84rem; }
  .form-field textarea { min-height: 76px; }
  .button-row { gap: 8px; }
  .btn-primary, .btn-secondary, .btn-export { padding: 7px 11px; font-size: .84rem; }
  .btn-small { padding: 4px 8px; font-size: .74rem; }
  .inline-toolbar { gap: 8px; }
  .inline-toolbar .form-field { min-width: 162px; }
  .survey-section-head { gap: 10px; margin-bottom: 10px; }
  .survey-section-head p { margin-top: 3px; font-size: .84rem; line-height: 1.40; }
  .survey-toolbar-field { min-width: 298px; flex-basis: 298px; }
  .survey-rule-card { padding: 11px; border-radius: var(--r-md); }
  .survey-link-grid { margin-top: 12px; }
  .survey-link-pack {
    margin-top: 12px;
    padding: 12px;
    border-radius: var(--r-lg);
  }
  .survey-links-section-head {
    gap: 10px;
  }
  .survey-links-head-row {
    gap: 12px;
  }
  .survey-links-head-action {
    flex-basis: min(320px, 100%);
    width: min(320px, 100%);
  }
  .support-help-card { padding: 18px; }
  .support-help-card.has-support-bg { min-height: 330px; padding: 22px 24px; background-size: auto 88%; }
  .support-help-layout { gap: 22px; }
  .support-help-hero { gap: 8px; }
  .support-help-kicker { min-height: 44px; padding: 9px 16px; border-radius: 14px; }
  .support-help-copy h2 { margin: 18px 0 10px; font-size: 1.75rem; }
  .support-help-copy p, .support-topic-card p, .support-faq-item p { font-size: .86rem; line-height: 1.52; }
  .support-help-contact { min-height: 150px; padding: 17px 16px 22px; gap: 12px; }
  .support-contact-icon { width: 44px; height: 44px; }
  .support-help-contact a { font-size: .96rem; }
  .support-topic-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .support-topic-card { min-height: 118px; padding: 12px; }
  .survey-terminate-options { grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 10px; }
  .survey-terminate-option { min-height: 52px; padding: 10px 12px; }
  .table-wrap { border-radius: var(--r-sm); overflow: auto; }
  .table-wrap table { width: max-content; min-width: 100%; table-layout: auto; }
  th, td { padding: 7px 8px; font-size: .74rem; line-height: 1.22; white-space: nowrap; }
  .data-table th {
    white-space: normal; word-break: keep-all; overflow-wrap: normal;
    line-height: 1.18; min-width: 88px; font-size: .66rem;
  }
  .data-table td { max-width: 190px; overflow: hidden; text-overflow: ellipsis; font-size: .78rem; }
  .data-table th.col-internal_rid, .data-table td.col-internal_rid,
  .data-table th.col-supplier_rid, .data-table td.col-supplier_rid {
    width: 1%; min-width: max-content; max-width: none;
  }
  .data-table td.col-internal_rid, .data-table td.col-supplier_rid { overflow: visible; text-overflow: clip; }
  .data-table td.is-sticky-col, .data-table th.is-sticky-col { background-clip: padding-box; }
  .cell-truncate-20, .cell-truncate-30, .country-cell { justify-content: center; flex-wrap: nowrap; }
  .cell-truncate-20 .text { max-width: 14ch; white-space: nowrap; }
  .cell-truncate-30 .text { max-width: 20ch; white-space: nowrap; }
  .copy-icon { width: 18px; height: 18px; flex: 0 0 auto; }
  .table-action-link { padding: 4px 7px; font-size: .70rem; white-space: nowrap; }
  .pagination-bar { gap: 8px; margin-top: 8px; }
  .pagination-meta, .page-status { font-size: .76rem; }
  .page-btn { padding: 5px 9px; font-size: .78rem; }
  .dashboard-kpi-grid > .panel-card,
  .dashboard-grid-2 > .panel-card,
  .dashboard-grid-3 > .panel-card { min-width: 0; }
  .dashboard-grid-2, .dashboard-grid-3 { gap: 10px; }
}


/* ── 1100px — sidebar becomes overlay drawer ─────────────────── */
@media (max-width: 1100px) {
  /* Reset sidebar to overlay drawer mode */
  .sidebar,
  html.sidebar-collapsed .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 36;
    width: min(86vw, 320px);
    max-width: calc(100vw - 28px);
    padding: 0 16px 18px;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    visibility: hidden;
    pointer-events: none;
    box-shadow: 0 24px 60px rgba(10, 15, 30, .28);
    will-change: transform;
    transition: transform var(--shell-motion), visibility 0s linear 240ms;
  }

  html.sidebar-mobile-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    transition: transform var(--shell-motion), visibility 0s linear 0ms;
  }

  .sidebar-backdrop { display: block; }

  html.sidebar-mobile-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity var(--shell-motion), visibility 0s linear 0ms;
  }

  /* Main shell takes full width */
  .main-shell,
  html.sidebar-collapsed .main-shell {
    margin-left: 0;
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
  }

  .page-loading-overlay-shell { top: var(--topbar-h); }

  /* FIX: sidebar-collapsed overrides are undone at this breakpoint */
  html.sidebar-collapsed .brand-home { padding: 0; }

  html.sidebar-collapsed .sidebar-brand {
    justify-content: flex-start;
    gap: 10px;
    padding-left: 12px;
    padding-right: 12px;
  }

  html.sidebar-collapsed .sidebar-brand-icon-shell {
    width: 36px; height: 36px; padding: 6px; border-radius: 8px;
  }

  html.sidebar-collapsed .sidebar-brand-copy,
  html.sidebar-collapsed .sidebar-section-label,
  html.sidebar-collapsed .nav-text,
  html.sidebar-collapsed .nav-chevron,
  html.sidebar-collapsed .nav-badge,
  html.sidebar-collapsed .nav-parent-meta {
    opacity: 1;
    max-width: none;
    overflow: visible;
    pointer-events: auto;
    transform: none;
  }

  html.sidebar-collapsed .sidebar-section-label {
    max-height: none;
    margin: 0;
    padding: 14px 12px 4px;
  }

  html.sidebar-collapsed .sidebar-divider { margin: 6px 0; opacity: 1; }
  html.sidebar-collapsed .nav-parent-main { width: auto; justify-content: flex-start; gap: 10px; }

  html.sidebar-collapsed .nav-group summary,
  html.sidebar-collapsed .nav-link {
    justify-content: flex-start;
    padding-left: 12px;
    padding-right: 12px;
  }

  html.sidebar-collapsed .nav-group > .nav-submenu {
    grid-template-rows: 0fr !important;
    padding: 0 !important;
  }

  html.sidebar-collapsed .nav-group[open] > .nav-submenu {
    grid-template-rows: 1fr !important;
    padding: 2px 0 6px !important;
  }

  html.sidebar-collapsed .nav-group a { display: flex; }

  /* Grids */
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-kpi-grid, .dashboard-grid-2, .dashboard-grid-3,
  .country-volume-grid, .survey-validation-grid,
  .survey-prescreener-grid, .survey-quota-grid,
  .support-help-layout { grid-template-columns: 1fr; }
  .support-help-hero { grid-template-columns: 1fr; }
  .support-help-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .survey-terminate-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .page-head { flex-direction: column; }
  .page-head-tools { margin-left: 0; min-width: 100%; width: 100%; }
  .view-filter-row { justify-content: flex-start; }

  .survey-meta-grid,
  .survey-meta-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .survey-toolbar { justify-content: flex-start; }
  .survey-toolbar-field { min-width: 100%; }
  .survey-links-head-row {
    flex-wrap: wrap;
  }
  .survey-links-head-action {
    flex-basis: 100%;
    width: 100%;
  }
  .survey-toolbar-actions {
    width: 100%;
  }
  .survey-toolbar-actions > * {
    width: 100%;
    justify-content: center;
  }
  .survey-validation-grid {
    grid-template-columns: 1fr;
  }

  .analytics-scope-head,
  .analytics-chart-card-head { flex-direction: column; }

  .analytics-scope-filter { min-width: 100%; max-width: none; width: 100%; margin-left: 0; }
  .analytics-scope-filter-auto { width: auto; min-width: 0; max-width: 100%; }
  .analytics-scope-filter-auto select { width: auto; max-width: 100%; }

  .analytics-scope-grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .analytics-scope-grid.dashboard-grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .analytics-prescreener-grid { grid-template-columns: 1fr; }
  .analytics-prescreener-head { grid-template-columns: 1fr; }

  .inline-copy { flex-direction: column; align-items: stretch; }
  .support-help-copy h2 { font-size: 1.24rem; }
  .support-topic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module-load-feedback { flex-direction: column; align-items: flex-start; }

  .nav-group summary, .nav-link { min-height: 46px; }
  .nav-group a { min-height: 42px; padding-top: 10px; padding-bottom: 10px; }

  .reconciliation-source-grid,
  .reconciliation-rule-grid { grid-template-columns: 1fr; }

  .reconciliation-kpi-row {
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .reconciliation-summary-grid { grid-template-columns: 1fr; }

  .user-management-head,
  .user-management-table-panel .dashboard-panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .user-management-role-chip { align-self: flex-start; }
}


/* ── 900px ───────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .content-shell { padding: 12px 12px 20px; }

  .dashboard-panel-head,
  .analytics-scope-head,
  .analytics-chart-card-head { flex-direction: column; align-items: stretch; }

  .page-head-tools,
  .page-head-tools .view-filters { width: 100%; min-width: 0; }

  .toolbar,
  .view-filter-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 8px;
  }

  .toolbar > *,
  .view-filter-row > * { width: 100%; min-width: 0; }
  .phone-combo { grid-template-columns: 1fr; }
  .multi-select-panel {
    position: static;
    max-height: 220px;
    margin-top: 6px;
    box-shadow: var(--shadow-sm);
  }

  .form-field input, .form-field select,
  .toolbar select, .toolbar input,
  .view-filter-row select, .view-filter-row input {
    min-height: 40px;
    height: auto;
  }

  .btn-primary, .btn-secondary, .btn-export,
  .page-btn, .topbar-logout, .sidebar-toggle, .table-action-link { min-height: 40px; }

  .button-row { align-items: stretch; }
  .button-row > * { flex: 1 1 calc(50% - 6px); min-width: 140px; justify-content: center; }

  .inline-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }

  .inline-toolbar .form-field { min-width: 0; width: 100%; }
}


/* ── 760px ───────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .main-shell { height: 100dvh; min-height: 100dvh; }

  .sidebar-brand { gap: 12px; padding: 0 12px; }
  .sidebar-brand-icon-shell { width: 34px; height: 34px; padding: 6px; border-radius: 8px; }
  .sidebar-brand-name { font-size: .94rem; }
  .sidebar-brand-subtitle { font-size: .72rem; }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
  }

  .topbar-main { width: 100%; min-width: 0; }
  .topbar-title { font-size: 1.02rem; }

  .topbar-user {
    width: auto;
    min-width: 0;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    justify-self: end;
  }

  .user-chip { max-width: 100%; min-width: 0; gap: 8px; font-size: .86rem; }
  .user-chip > span:last-child { max-width: 84px; }
  .user-avatar { width: 30px; height: 30px; font-size: .76rem; }

  .topbar-logout {
    width: auto;
    min-height: 34px;
    padding: 6px 11px;
    border-radius: var(--r-sm);
    font-size: .82rem;
    flex: 0 0 auto;
  }

  .page-head { align-items: stretch; margin-bottom: 8px; }
  .page-head.is-empty { margin-bottom: 0; }
  .content-shell { padding: 8px 10px 18px; overflow-x: hidden; }

  .page-loading-spinner { width: 52px; height: 52px; }

  .page-body, .module-stack, .panel-card { min-width: 0; max-width: 100%; }
  .module-stack { gap: 12px; }
  .panel-card, .stat-card { padding: 12px; border-radius: var(--r-md); }

  .table-wrap { overflow-x: auto; overflow-y: hidden; }
  .table-wrap table { width: max-content; min-width: 100%; }
  th, td { padding: 8px 9px; }

  .chart-frame-lg { height: 244px; }
  .chart-frame-md, .chart-frame-country, .chart-frame-stats { height: 204px; }
  .chart-frame-sm { height: 180px; }

  /* Stack all grids to single column on mobile */
  .card-grid:not(.reconciliation-kpi-row),
  .dashboard-kpi-grid, .dashboard-grid-2, .dashboard-grid-3,
  .analytics-scope-grid-1, .analytics-scope-grid-3,
  .analytics-scope-grid.dashboard-grid-2,
  .country-volume-grid, .survey-meta-grid, .survey-meta-grid-3,
  .survey-link-grid, .support-help-layout {
    grid-template-columns: 1fr !important;
  }

  .reconciliation-kpi-row {
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .reconciliation-kpi-row > .stat-card { min-width: 180px; }
  .reconciliation-summary-grid { grid-template-columns: 1fr; }

  .toolbar, .view-filter-row { grid-template-columns: 1fr; }
  .inline-toolbar { grid-template-columns: 1fr; }

  .toolbar button, .toolbar a,
  .view-filter-row .btn-primary,
  .view-filter-row .btn-secondary,
  .view-filter-row .btn-export { width: 100%; }

  .analytics-scope-filter, .analytics-scope-filter-auto {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .analytics-scope-filter-row {
    width: 100%;
    justify-content: stretch;
    margin-left: 0;
  }

  .analytics-scope-filter-row .analytics-scope-filter-auto {
    flex: 1 1 100%;
  }

  .analytics-scope-filter-auto select { width: 100% !important; max-width: none; }
  .analytics-scope-selected strong { white-space: normal; }

  .support-help-grid { grid-template-columns: 1fr; }
  .support-help-card.has-support-bg {
    min-height: auto;
    padding: 22px;
    background-size: auto 245px;
    background-position: top right;
  }
  .support-help-card.has-support-bg::before {
    background:
      linear-gradient(90deg, rgba(255,255,255,.99) 0%, rgba(255,255,255,.96) 58%, rgba(255,255,255,.78) 100%),
      linear-gradient(180deg, rgba(240,244,255,.14) 0%, rgba(255,255,255,.04) 100%);
  }
  .support-help-layout { gap: 18px; }
  .support-help-kicker { min-height: 46px; padding: 10px 15px; font-size: .82rem; border-radius: var(--r-md); }
  .support-help-copy h2 { margin: 18px 0 10px; font-size: 2rem; }
  .support-help-contact { min-height: auto; padding: 18px 18px 24px; }
  .support-topic-grid { grid-template-columns: 1fr; }
  .nested-field-grid { grid-template-columns: 1fr; }

  .button-row { flex-direction: column; gap: 10px; }
  .button-row > * { width: 100%; min-width: 0; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions > * { width: 100%; justify-content: center; }

  .entity-form-actions {
    flex-direction: row;
    align-items: stretch;
    justify-content: flex-start;
    gap: 10px;
  }

  .entity-form-actions > * { flex: 1 1 calc(50% - 5px); min-width: 140px; width: auto; }
  .entity-form-actions > a:last-child { flex-basis: 100%; }

  .user-management-head { flex-direction: column; align-items: stretch; }
  .user-management-role-chip { align-self: flex-start; }

  .pagination-bar { justify-content: stretch; }
  .pagination-actions { width: 100%; justify-content: space-between; }
}


/* ── 700px ───────────────────────────────────────────────────── */
@media (max-width: 700px) {
  :root { --sidebar-collapsed: 64px; }

  .survey-terminate-options { grid-template-columns: 1fr; }
  .survey-terminate-option { min-height: auto; padding: 10px 12px; }

  .card-grid,
  .analytics-scope-grid-1,
  .analytics-scope-grid-3,
  .survey-meta-grid,
  .survey-meta-grid-3 { grid-template-columns: 1fr; }

  .reconciliation-kpi-row {
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .analytics-scope-grid.dashboard-grid-2 { grid-template-columns: 1fr; }
  .dashboard-mini-grid { grid-template-columns: 1fr; }

  .inline-copy { flex-direction: column; align-items: stretch; }
  .support-help-copy h2 { font-size: 1.14rem; }
}

/* Grouped project allocation table */
.project-grouped-table {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.project-group {
  border: var(--ui-border);
  border-radius: var(--r-md);
  background: var(--panel);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.project-group-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  background: linear-gradient(180deg, #FFFFFF 0%, #FAFBFF 100%);
  transition: background .16s ease, border-color .16s ease;
}

.project-group-summary::-webkit-details-marker { display: none; }
.project-group[open] .project-group-summary { border-bottom: var(--ui-border-soft); }
.project-group-summary:hover { background: #F7F9FF; }

.project-group-chevron {
  position: relative;
  width: 28px;
  height: 28px;
  border: var(--ui-border);
  border-radius: var(--r-md);
  background: var(--panel);
  flex: 0 0 auto;
}

.project-group-chevron::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 10px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--text-2);
  border-bottom: 2px solid var(--text-2);
  transform: rotate(45deg);
  transition: transform .16s ease, top .16s ease;
}

.project-group[open] .project-group-chevron::before {
  top: 11px;
  transform: rotate(225deg);
}

.project-group-heading {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.project-group-title {
  color: var(--text);
  font-weight: 800;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-group-name {
  color: var(--muted);
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-group-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.project-group-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 9px;
  border: var(--ui-border);
  border-radius: 999px;
  color: var(--text-2);
  background: var(--panel-alt);
  font-size: var(--text-xs);
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.project-group-badge-active,
.project-group-badge-live {
  color: var(--status-active);
  border-color: rgba(5, 150, 105, .24);
  background: var(--status-active-light);
}

.project-group-badge-draft {
  color: var(--status-draft);
  border-color: rgba(100, 116, 139, .24);
  background: var(--status-draft-light);
}

.project-group-badge-paused,
.project-group-badge-on-hold {
  color: var(--status-paused);
  border-color: rgba(217, 119, 6, .26);
  background: var(--status-paused-light);
}

.project-group-badge-closed {
  color: var(--status-closed);
  border-color: rgba(71, 85, 105, .24);
  background: var(--status-closed-light);
}

.project-group-badge-archived {
  color: var(--status-archived);
  border-color: rgba(148, 163, 184, .30);
  background: var(--status-archived-light);
}

.project-group-badge-blocked,
.project-group-badge-cancelled {
  color: var(--status-blocked);
  border-color: rgba(220, 38, 38, .24);
  background: var(--status-blocked-light);
}

.project-group-badge-fulfilled,
.project-group-badge-sample-achieved {
  color: var(--status-fulfilled);
  border-color: rgba(20, 184, 166, .26);
  background: rgba(20, 184, 166, .10);
}

.project-group-badge-complete {
  color: var(--status-active);
  border-color: rgba(5, 150, 105, .24);
  background: var(--status-active-light);
}

.project-group-badge-started {
  color: var(--brand);
  border-color: rgba(67, 97, 238, .24);
  background: var(--brandLight);
}

.project-group-badge-terminate,
.project-group-badge-terminated,
.project-group-badge-rejected {
  color: var(--status-blocked);
  border-color: rgba(220, 38, 38, .24);
  background: var(--status-blocked-light);
}

.project-group-badge-quality-failed {
  color: #B45309;
  border-color: rgba(180, 83, 9, .26);
  background: rgba(245, 158, 11, .12);
}

.project-group-badge-quotafull,
.project-group-badge-quota-full {
  color: var(--status-paused);
  border-color: rgba(217, 119, 6, .26);
  background: var(--status-paused-light);
}

.respondent-badge {
  min-height: 22px;
  padding-inline: 8px;
}

.respondent-badge-yes {
  color: var(--status-blocked);
  border-color: rgba(220, 38, 38, .24);
  background: var(--status-blocked-light);
}

.respondent-badge-no {
  color: var(--status-active);
  border-color: rgba(5, 150, 105, .24);
  background: var(--status-active-light);
}

.project-group-badge-parent,
.project-group-badge-tracker,
.project-group-badge-recontact,
.project-group-badge-child,
.project-group-badge-adhoc {
  color: var(--brand);
  border-color: rgba(67, 97, 238, .24);
  background: var(--brandLight);
}

.project-group-body {
  display: grid;
  gap: 14px;
  padding: 14px 16px 16px;
  min-width: 0;
}

.project-group-meta {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.project-group-meta > div,
.project-group-url,
.project-group-kpi {
  min-width: 0;
  border: var(--ui-border-soft);
  border-radius: var(--r-md);
  background: var(--panel-alt);
  padding: 10px 12px;
}

.project-group-meta > div {
  display: grid;
  gap: 3px;
}

.project-group-meta span,
.project-group-url > span,
.project-group-kpi span {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.project-group-meta strong,
.project-group-url strong,
.project-group-kpi strong {
  min-width: 0;
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 800;
}

.project-group-meta .country-cell { justify-content: flex-start; }

.project-group-url {
  display: grid;
  grid-template-columns: minmax(120px, 160px) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.project-group-url .cell-truncate-20 {
  max-width: 100%;
  justify-content: flex-start;
}

.project-group-url .cell-truncate-20 .text {
  max-width: min(76ch, 100%);
}

.project-group-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.project-group-kpi {
  display: grid;
  gap: 4px;
  justify-items: center;
  text-align: center;
}

.project-group-kpi strong {
  font-size: var(--text-lg);
  line-height: 1.2;
}

.project-allocation-scroll {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border: var(--ui-border);
  border-radius: var(--r-md);
  background: var(--panel);
  -webkit-overflow-scrolling: touch;
}

.project-allocation-table th,
.project-allocation-table td {
  padding: 10px 12px;
  font-size: var(--text-sm);
}

.project-allocation-table th {
  font-size: 10px;
}

.project-allocation-table .table-action-link {
  min-width: max-content;
}

@media (max-width: 1180px) {
  .project-group-meta { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .project-group-summary {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
  }

  .project-group-pills {
    grid-column: 2;
    justify-content: flex-start;
  }

  .project-group-body { padding: 12px; }
  .project-group-meta { grid-template-columns: 1fr; }
  .project-group-url { grid-template-columns: 1fr; }
  .project-group-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  .project-group-kpis { grid-template-columns: 1fr; }
}


/* AUDIT LOGS */
#page-root[data-page="audit_logs"] {
  min-width: 0;
  max-width: 100%;
}

#page-root[data-page="audit_logs"] .panel-card,
#page-root[data-page="audit_logs"] .table-wrap {
  min-width: 0;
  max-width: 100%;
}

#page-root[data-page="audit_logs"] .table-wrap {
  overflow: auto;
  overscroll-behavior-x: contain;
}

#page-root[data-page="audit_logs"] .data-table td {
  vertical-align: top;
  white-space: normal;
  max-width: none;
}

#page-root[data-page="audit_logs"] .data-table td.col-field_changes_meta {
  min-width: 0;
}

#page-root[data-page="audit_logs"] .data-table th,
#page-root[data-page="audit_logs"] .data-table td {
  width: auto;
}

.audit-log-row-details summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--brand);
  font-weight: 800;
  list-style: none;
  white-space: nowrap;
  font-size: var(--text-sm);
}

.audit-log-summary-label {
  color: var(--brand);
}

.audit-log-copy-icon {
  flex: 0 0 auto;
}

.audit-log-row-details summary::marker { content: ""; }

.audit-log-row-detail-body {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  max-height: 180px;
  overflow: auto;
  padding: 8px;
  border: var(--ui-border-soft);
  border-radius: var(--r-sm);
  background: #F8FAFF;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.45;
  max-width: min(720px, 70vw);
}

.audit-log-row-detail-body div {
  overflow-wrap: anywhere;
  white-space: normal;
}
