/* ============================================================================
   HTS — QA Announcement System · V2.0 · Global Stylesheet
   ----------------------------------------------------------------------------
   Sections:
     1. Reset & base typography
     2. CSS design tokens (colors, shadows, radii, z-index)
     3. App shell layout (top bar, sidebar, main)
     4. Initial loading skeleton (static HTML in index.html)
     5. In-app skeleton loaders (data loading)
     6. Sidebar navigation (redesigned)
     7. Top bar (search, notifications, profile)
     8. Cards & content surfaces
     9. Buttons, badges, pills
    10. Forms, inputs, contenteditable editor
    11. Modals & toasts
    12. Mentions, popovers, editor popups
    13. Role badges
    14. Responsive & accessibility
   ============================================================================ */

/* 1. RESET & BASE TYPOGRAPHY ----------------------------------------------- */
* { box-sizing: border-box; }
html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
}
body {
  background-color: #fbfbfd;
  color: #1d1d1f;
  letter-spacing: -0.01em;
  margin: 0;
}
* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
h1, h2, h3, h4, h5 { letter-spacing: -0.025em; margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { display: block; max-width: 100%; }

/* Custom scrollbar (used in sidebar + main + modals) */
.custom-scrollbar::-webkit-scrollbar { width: 8px; height: 8px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); background-clip: padding-box; border: 2px solid transparent; }

/* 2. DESIGN TOKENS --------------------------------------------------------- */
:root {
  /* Brand & ink shades (mirrors tailwind.config) */
  --brand-50:#f0f6ff; --brand-100:#d8e8ff; --brand-200:#b3d0ff; --brand-300:#80b3ff;
  --brand-400:#4d96ff; --brand-500:#1e7bff; --brand-600:#0071e3; --brand-700:#0058b8;
  --brand-800:#004a96; --brand-900:#003a75;
  --ink-50:#fbfbfd; --ink-100:#f5f5f7; --ink-200:#e8e8ed; --ink-300:#d2d2d7;
  --ink-400:#a1a1a6; --ink-500:#86868b; --ink-600:#6e6e73; --ink-700:#3a3a3c;
  --ink-800:#1d1d1f; --ink-900:#000000;

  /* Surfaces */
  --surface-bg:        #fbfbfd;
  --surface-card:      #ffffff;
  --surface-elevated:  rgba(255,255,255,0.72);
  --surface-overlay:   rgba(255,255,255,0.92);

  /* Borders */
  --border-hair:    rgba(0,0,0,0.08);
  --border-strong:  rgba(0,0,0,0.16);
  --border-brand:   rgba(0,113,227,0.18);

  /* Shadows */
  --shadow-soft: 0 1px 2px 0 rgba(0,0,0,0.04), 0 1px 3px 0 rgba(0,0,0,0.04);
  --shadow-card: 0 1px 3px 0 rgba(0,0,0,0.04), 0 4px 12px -2px rgba(0,0,0,0.04);
  --shadow-lift: 0 4px 16px -2px rgba(0,0,0,0.08), 0 2px 6px -1px rgba(0,0,0,0.04);
  --shadow-pop:  0 8px 32px -4px rgba(0,0,0,0.12), 0 4px 12px -2px rgba(0,0,0,0.06);
  --shadow-focus:0 0 0 4px rgba(0,113,227,0.15);

  /* Radii */
  --r-pill:9999px;
  --r-sm:6px; --r-md:10px; --r-lg:14px; --r-xl:18px; --r-2xl:22px;

  /* Sidebar dimensions */
  --sidebar-w:264px;
  --sidebar-w-collapsed:72px;
  --topbar-h:56px;

  /* Sidebar accent by role (set on <aside> via [data-active-role]) */
  --role-accent:#0071e3;
}

/* 3. APP SHELL ------------------------------------------------------------- */
.contents { display: contents; }

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.app-topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border-bottom: 0.5px solid var(--border-hair);
  position: relative;
  z-index: 30;
}

.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0; /* allow children to scroll */
}

.app-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  position: relative;
}
.app-main:focus { outline: none; }

/* Frosted glass panels (Apple-style) */
.glass-panel {
  background: var(--surface-elevated);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 0.5px solid rgba(255,255,255,0.6);
}
.glass-header {
  background: var(--surface-elevated);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
}

/* 4. INITIAL LOADING SKELETON (rendered in index.html) -------------------- */
.initial-loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--surface-bg);
  color: var(--ink-800);
  z-index: 9999;
  letter-spacing: -0.025em;
  overflow: hidden;
  font-family: inherit;
}

.sk-topbar {
  height: var(--topbar-h);
  border-bottom: 0.5px solid var(--border-hair);
  background: rgba(255,255,255,0.72);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}
.sk-brand { display:flex; align-items:center; gap:10px; }
.sk-logo  {
  width:28px; height:28px; border-radius:7px;
  background: linear-gradient(135deg, #0071e3 0%, #0058b8 100%);
}
.sk-stack { display:flex; flex-direction:column; gap:3px; }
.sk-topbar-right { display:flex; align-items:center; gap:8px; }
.sk-body { flex:1; display:flex; overflow:hidden; }
.sk-sidebar {
  width: var(--sidebar-w);
  border-right: 0.5px solid var(--border-hair);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex-shrink: 0;
}
@media (max-width: 767px) { .sk-sidebar { display: none; } }
.sk-main { flex:1; padding: 32px; overflow:hidden; }
.sk-list { display:flex; flex-direction:column; gap:6px; }
.sk-card-list { display:flex; flex-direction:column; gap:16px; }
.sk-card {
  background: #fff;
  border: 0.5px solid var(--border-hair);
  border-radius: var(--r-xl);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sk-card-row { display:flex; gap:8px; }

/* Generic skeleton line primitive */
.hts-skel {
  background: var(--ink-100);
  display: block;
}
.sk-line { display:block; background: var(--ink-100); }
.sk-rounded-6 { border-radius: 6px; }
.sk-rounded-8 { border-radius: 8px; }
.sk-rounded-10 { border-radius: 10px; }
.sk-rounded-circle { border-radius: 50%; }
.sk-mb8  { margin-bottom: 8px; }
.sk-mb24 { margin-bottom: 24px; }
.sk-w28  { width: 28px; }
.sk-w50  { width: 50px; }
.sk-w60  { width: 60px; }
.sk-w80  { width: 80px; }
.sk-w140 { width: 140px; }
.sk-w200 { width: 200px; }
.sk-w280 { width: 280px; }
.sk-w180 { width: 180px; }
.sk-w-100p { width: 100%; }
.sk-w-80p  { width: 80%; }
.sk-w-70p  { width: 70%; }
.sk-w-60p  { width: 60%; }
.sk-w-50p  { width: 50%; }
.sk-h9   { height: 9px; }
.sk-h10  { height: 10px; }
.sk-h11  { height: 11px; }
.sk-h13  { height: 13px; }
.sk-h18  { height: 18px; }
.sk-h24  { height: 24px; }
.sk-h30  { height: 30px; }
.sk-h32  { height: 32px; }

/* Skeleton pulse animation — opacity-only, compositor-friendly */
@keyframes hts-skel-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
.hts-skel { animation: hts-skel-pulse 1.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .hts-skel { animation: none; } }

/* 5. IN-APP SKELETON LOADERS ----------------------------------------------- */
/* Render these inside #app while data is still loading. */
.skeleton-view { padding: 32px; display:flex; flex-direction:column; gap:20px; }
.skeleton-view .sk-toolbar {
  display:flex; align-items:center; gap:8px; justify-content:space-between;
}
.skeleton-view .sk-grid {
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.skeleton-view .sk-card { background:#fff; border:0.5px solid var(--border-hair); border-radius: var(--r-xl); padding:20px; display:flex; flex-direction:column; gap:10px; }

/* 6. SIDEBAR --------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border-right: 0.5px solid var(--border-hair);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Sidebar header (brand + role chip) */
.sidebar-header {
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 0.5px solid var(--border-hair);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand .brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-600) 0%, var(--brand-800) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px -2px rgba(0,113,227,0.4);
}
.sidebar-brand .brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.sidebar-brand .brand-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-brand .brand-sub {
  font-size: 10px;
  color: var(--ink-500);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}

/* Role chip in sidebar header */
.sidebar-role-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--role-accent) 12%, transparent);
  color: color-mix(in srgb, var(--role-accent) 75%, black 0%);
  border: 0.5px solid color-mix(in srgb, var(--role-accent) 35%, transparent);
  align-self: flex-start;
}
.sidebar-role-chip .role-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--role-accent);
}

/* Sidebar scroll area */
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Sidebar nav group */
.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-500);
  padding: 6px 10px 6px 12px;
}
.sidebar-group-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Nav item */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-700);
  cursor: pointer;
  position: relative;
  transition: background-color 0.18s ease, color 0.18s ease;
  user-select: none;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  background: var(--ink-100);
  color: var(--ink-900);
}
.nav-item.active {
  background: color-mix(in srgb, var(--role-accent) 10%, transparent);
  color: color-mix(in srgb, var(--role-accent) 70%, black 0%);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--role-accent);
  border-radius: 2px;
}
.nav-item .nav-icon {
  width: 16px;
  height: 16px;
  color: var(--ink-500);
  flex-shrink: 0;
}
.nav-item.active .nav-icon {
  color: color-mix(in srgb, var(--role-accent) 80%, black 0%);
}
.nav-item .nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item .nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: 700;
  background: var(--brand-600);
  color: #fff;
  line-height: 1;
}
.nav-item .nav-badge.urgent { background: #dc2626; }
.nav-item .nav-badge.muted   { background: var(--ink-400); }

/* Sidebar footer (collapse / expand + version) */
.sidebar-footer {
  padding: 10px 12px 14px;
  border-top: 0.5px solid var(--border-hair);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: var(--ink-500);
}
.sidebar-footer .version-pill {
  padding: 2px 8px;
  background: var(--ink-100);
  border-radius: var(--r-pill);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--ink-500);
  cursor: pointer;
  transition: background 0.18s ease;
}
.sidebar-collapse-btn:hover { background: var(--ink-100); color: var(--ink-800); }

/* Mobile sidebar (drawer) */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 35;
}
@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: var(--sidebar-w);
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 40;
    border-right: 0;
    border-left: 0.5px solid var(--border-hair);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.mobile-hidden { display: none; }
}

/* 7. TOP BAR --------------------------------------------------------------- */
.topbar-search {
  position: relative;
  flex: 1;
  max-width: 480px;
}
.topbar-search input {
  width: 100%;
  height: 36px;
  padding: 0 36px 0 36px;
  border-radius: 10px;
  border: 0.5px solid var(--border-hair);
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(12px);
  font-size: 13px;
  color: var(--ink-800);
  transition: box-shadow 0.18s, border-color 0.18s;
}
.topbar-search input::placeholder { color: var(--ink-400); }
.topbar-search input:focus {
  border-color: var(--brand-300);
  box-shadow: var(--shadow-focus);
}
.topbar-search .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-400);
  pointer-events: none;
}
.topbar-search .search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  color: var(--ink-500);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: none;
}
.topbar-search .search-clear:hover { background: var(--ink-100); color: var(--ink-800); }
.topbar-search .search-clear.visible { display: inline-flex; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.topbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--ink-600);
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  position: relative;
}
.topbar-icon-btn:hover { background: var(--ink-100); color: var(--ink-800); }
.topbar-icon-btn .icon-badge {
  position: absolute;
  top: 6px; right: 6px;
  min-width: 14px; height: 14px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: #dc2626;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #fff;
}

/* Profile dropdown */
.profile-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--r-pill);
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: background 0.18s ease;
}
.profile-trigger:hover { background: var(--ink-100); }
.profile-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-400), var(--brand-700));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 12px;
  overflow: hidden;
  flex-shrink: 0;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: 12px; font-weight: 600; color: var(--ink-800); white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.profile-meta { font-size: 10px; color: var(--ink-500); font-weight: 500; }

.profile-dropdown-menu {
  position: absolute;
  right: 0; top: calc(100% + 8px);
  width: 264px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 0.5px solid var(--border-hair);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  z-index: 50;
  padding: 6px;
  transform-origin: top right;
}
.profile-dropdown-menu .menu-section { padding: 4px 4px; }
.profile-dropdown-menu .menu-section + .menu-section { border-top: 0.5px solid var(--border-hair); margin-top: 4px; padding-top: 8px; }
.profile-dropdown-menu .menu-header {
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px 10px;
}
.profile-dropdown-menu .menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink-700);
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
}
.profile-dropdown-menu .menu-item:hover { background: var(--ink-100); color: var(--ink-900); }
.profile-dropdown-menu .menu-item.danger { color: #dc2626; }
.profile-dropdown-menu .menu-item.danger:hover { background: rgba(239,68,68,0.08); }
@media (max-width: 640px) {
  .profile-dropdown-menu {
    position: fixed !important;
    left: 12px !important;
    right: 12px !important;
    top: 64px !important;
    width: auto !important;
  }
}

/* 8. CARDS & CONTENT SURFACES --------------------------------------------- */
.card {
  background: var(--surface-card);
  border: 0.5px solid var(--border-hair);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.card-hover:hover { box-shadow: 0 6px 24px -6px rgba(0,0,0,0.10); border-color: var(--border-strong); }
.card-pad { padding: 20px; }
.card-pad-lg { padding: 24px; }

.surface-soft  { background: var(--ink-100); border-radius: var(--r-lg); }
.surface-info  { background: var(--brand-50); border: 0.5px solid color-mix(in srgb, var(--brand-300) 50%, transparent); border-radius: var(--r-lg); }
.surface-warn  { background: #fef3c7; border: 0.5px solid #fde68a; border-radius: var(--r-lg); }
.surface-danger{ background: #fee2e2; border: 0.5px solid #fecaca; border-radius: var(--r-lg); }

/* Page header */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.page-subtitle { font-size: 13px; color: var(--ink-500); font-weight: 500; margin-top: 4px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* 9. BUTTONS, BADGES, PILLS ----------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  border: 0.5px solid transparent;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.05s;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  background: var(--brand-600); color: #fff;
  border-color: var(--brand-700);
  box-shadow: 0 1px 2px -1px rgba(0,113,227,0.5);
}
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-800); }
.btn-secondary {
  background: #fff; color: var(--ink-800);
  border-color: var(--ink-200);
}
.btn-secondary:hover { background: var(--ink-100); border-color: var(--ink-300); }
.btn-ghost { background: transparent; color: var(--ink-700); }
.btn-ghost:hover { background: var(--ink-100); color: var(--ink-900); }
.btn-danger { background: #dc2626; color: #fff; border-color: #b91c1c; }
.btn-danger:hover { background: #b91c1c; }
.btn-danger-secondary { background: #fff; color: #dc2626; border-color: #fecaca; }
.btn-danger-secondary:hover { background: rgba(239,68,68,0.08); }
.btn-sm  { padding: 5px 10px; font-size: 11px; }
.btn-lg  { padding: 12px 20px; font-size: 14px; }
.btn-block { width: 100%; }

/* Badges & pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.4;
  border: 0.5px solid transparent;
  text-transform: uppercase;
}
.badge-info { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-200); }
.badge-warn { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge-danger{ background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge-success{ background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge-muted { background: var(--ink-100); color: var(--ink-700); border-color: var(--ink-200); }

/* 10. FORMS --------------------------------------------------------------- */
.input, .textarea, .select {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r-md);
  border: 0.5px solid var(--ink-200);
  background: #fff;
  font-size: 13px;
  color: var(--ink-800);
  font-family: inherit;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-400); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--brand-300);
  box-shadow: var(--shadow-focus);
}
.label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-600);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.field-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .field-grid { grid-template-columns: 1fr; } }

/* Rich text editor */
[contenteditable]:empty:before { content: attr(placeholder); color: var(--ink-400); pointer-events: none; display: block; }
[contenteditable] { outline: none; caret-color: var(--brand-600); }
[contenteditable]::-webkit-scrollbar { display: none; }
.rich-editor {
  min-height: 200px;
  padding: 14px 16px;
  border: 0.5px solid var(--ink-200);
  border-radius: var(--r-md);
  background: #fff;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-800);
  overflow-y: auto;
  max-height: 60vh;
}
.rich-editor:focus { border-color: var(--brand-300); box-shadow: var(--shadow-focus); }
.rich-editor a { color: var(--brand-600); text-decoration: underline; }
.rich-editor a:hover { color: var(--brand-700); }
.rich-editor pre {
  background: var(--ink-100);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  overflow-x: auto;
}
.rich-editor blockquote {
  border-left: 3px solid var(--brand-400);
  padding: 4px 12px;
  margin: 6px 0;
  color: var(--ink-700);
  font-style: italic;
}
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 8px;
  border: 0.5px solid var(--ink-200);
  border-bottom: 0;
  border-radius: var(--r-md) var(--r-md) 0 0;
  background: var(--ink-50);
}
.editor-toolbar .tb-btn {
  padding: 6px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  color: var(--ink-700);
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
}
.editor-toolbar .tb-btn:hover { background: var(--ink-100); color: var(--ink-900); }

/* 11. MODAL & TOAST ------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-panel {
  background: #fff;
  border: 0.5px solid var(--border-hair);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
  max-width: 560px;
  width: 100%;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-panel.modal-lg { max-width: 760px; }
.modal-panel.modal-xl { max-width: 960px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 0.5px solid var(--border-hair);
  flex-shrink: 0;
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--ink-900); }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 0.5px solid var(--border-hair);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.modal-close {
  border: 0;
  background: transparent;
  color: var(--ink-500);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
}
.modal-close:hover { background: var(--ink-100); color: var(--ink-800); }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 0.5px solid var(--border-hair);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  padding: 12px 16px;
  min-width: 280px;
  max-width: 360px;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.toast-title { font-size: 13px; font-weight: 700; color: var(--ink-900); display: flex; align-items: center; gap: 8px; }
.toast-msg { font-size: 12px; color: var(--ink-600); }
.toast.success .toast-title { color: #166534; }
.toast.error   .toast-title { color: #991b1b; }
.toast.warn    .toast-title { color: #92400e; }

/* 12. MENTIONS, POPOVERS, EDITOR POPUPS ----------------------------------- */
.mention-tag {
  display: inline-block;
  background: linear-gradient(135deg, var(--brand-100), var(--brand-200));
  color: var(--brand-700);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.92em;
  line-height: 1.4;
  vertical-align: baseline;
  border: 0.5px solid var(--border-brand);
}
.editor-popup {
  position: absolute;
  background: var(--surface-overlay);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 0.5px solid var(--border-hair);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  z-index: 60;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 200px;
}
.editor-popup button {
  padding: 8px 12px; font-size: 13px; text-align: left; border-radius: 8px;
  transition: background 0.15s; width: 100%; border: 0; background: transparent;
  cursor: pointer; color: var(--ink-700);
}
.editor-popup button:hover, .editor-popup button.active { background: rgba(0,113,227,0.08); }
.editor-color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 6px; }
.editor-color-grid button { width: 28px; height: 28px; border-radius: 8px; border: 0.5px solid var(--border-hair); cursor: pointer; padding: 0; }

/* Mention popup (floating, anchored to caret) */
.mention-popup-floating {
  position: absolute;
  background: var(--surface-overlay);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 0.5px solid var(--border-hair);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  z-index: 70;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 220px;
  max-height: 260px;
  overflow-y: auto;
}
.mention-popup-floating .mention-opt {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink-700);
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mention-popup-floating .mention-opt.active { background: rgba(0,113,227,0.1); color: var(--brand-700); }

/* 13. ROLE BADGES ---------------------------------------------------------- */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 0.5px solid transparent;
  white-space: nowrap;
}
.role-badge[data-role="SUPER_ADMIN"]   { background: #f3e8ff; color: #6b21a8; border-color: #d8b4fe; }
.role-badge[data-role="AGENT_ADMIN"]   { background: #cffafe; color: #155e75; border-color: #67e8f9; }
.role-badge[data-role="QA_ADMIN"]     { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.role-badge[data-role="SME_ADMIN"]    { background: #ccfbf1; color: #115e59; border-color: #5eead4; }
.role-badge[data-role="QA_TEAM"]       { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.role-badge[data-role="TEAM_LEADER"]   { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.role-badge[data-role="SME"]           { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.role-badge[data-role="ADMIN"]         { background: var(--ink-100); color: var(--ink-700); border-color: var(--ink-300); }
.role-badge[data-role="TEAMMATE"]      { background: var(--ink-100); color: var(--ink-600); border-color: var(--ink-300); }

/* 14. RESPONSIVE & A11Y --------------------------------------------------- */
@media (max-width: 1023px) {
  .desktop-only { display: none !important; }
  .topbar-search { max-width: none; }
}
@media (min-width: 1024px) {
  .mobile-only { display: none !important; }
}

/* Profile dropdown animation (intentionally subtle, transform-origin kept for future) */
@keyframes profileDropdownOpen {
  from { opacity: 0; transform: translateY(-6px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
.profile-dropdown-menu { transform-origin: top right; }

/* Legacy spinner kept for any inline indicators */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { animation: spin 0.9s linear infinite; }

/* Focus ring */
:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-radius: 4px; }

/* Utility — fade entrance (used sparingly) */
.view-fade { animation: viewFade 0.18s ease-out; }
@keyframes viewFade {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Auth (login) view */
.login-bg {
  background:
    radial-gradient(60% 80% at 20% 15%, rgba(0,113,227,0.18) 0%, transparent 60%),
    radial-gradient(50% 60% at 85% 80%, rgba(94,92,230,0.15) 0%, transparent 60%),
    radial-gradient(40% 50% at 50% 50%, rgba(255,255,255,0.4) 0%, transparent 50%),
    linear-gradient(180deg, #fbfbfd 0%, #f5f5f7 100%);
}
