/* ── Variables ─────────────────────────────────────────── */
:root {
  --brand:       #6366f1;
  --brand-dark:  #4f46e5;
  --brand-light: #f0f0ff;
  --brand-bg:    #eff0fe;
  --nav-bg:      #0f172a;
  --nav-bg2:     #1e293b;
  --sidebar-w:   260px;
  --topnav-h:    56px;
  --white:       #ffffff;
  --gray-50:     #f8f9fc;
  --gray-100:    #f1f5f9;
  --gray-200:    #e2e8f0;
  --gray-300:    #cbd5e1;
  --gray-400:    #94a3b8;
  --gray-500:    #64748b;
  --gray-600:    #475569;
  --gray-700:    #334155;
  --gray-800:    #1e293b;
  --gray-900:    #0f172a;
  --red:         #ef4444;
  --red-light:   #fef2f2;
  --orange:      #f97316;
  --yellow:      #eab308;
  --green:       #22c55e;
  --green-light: #f0fdf4;
  --radius:      10px;
  --radius-lg:   14px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow:      0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:   0 16px 40px rgba(0,0,0,.14);
  --transition:  all .18s ease;
}

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-800);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;

  /* ── PWA / native-feel ── */
  /* Remove grey tap flash on Android */
  -webkit-tap-highlight-color: transparent;
  /* Prevent long-press text selection on UI chrome elements */
  -webkit-user-select: none;
  user-select: none;
}

/* Re-enable text selection inside content areas where it makes sense */
p, span, h1, h2, h3, h4, h5, li,
.ticket-desc, .msg-body, .chat-bubble,
textarea, input, [contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

/* Safe area padding — handles notch + home indicator on iPhone/Android */
#topnav {
  padding-top: env(safe-area-inset-top, 0px);
}
.mob-bottom-nav {
  padding-bottom: env(safe-area-inset-bottom, 0px);
  height: calc(56px + env(safe-area-inset-bottom, 0px));
}

/* Smooth scrolling everywhere */
html { scroll-behavior: smooth; }

/* ── Skeleton shimmer for load-more ── */
@keyframes sfShimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.sf-sk {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 800px 100%;
  animation: sfShimmer 1.4s infinite linear;
  flex-shrink: 0;
}
.tkt-skeleton-wrap { padding: 4px 0; }

/* ── Android WebView touch scroll fix ──
   touch-action: pan-y tells the browser "vertical scroll is intentional here"
   without this, Android WebView can misfire and eat touch events.
   Also ensure every scrollable element has explicit overflow-y:auto + dvh heights */
body,
.ticket-list-scroll,
.tab-pane,
.messages-scroll,
.dashboard-content,
.portal-content,
#app-content,
.sf-modal,
.modal-box,
.sf-modal-body,
.modal-body,
.fh-panel-body,
.settings-body,
.settings-content {
  touch-action: pan-y;
}

/* Scrollable modals need explicit overflow on mobile */
.sf-modal        { overflow-y: auto; }
.modal-box       { overflow-y: auto; max-height: 90dvh; }
.modal-body      { overflow-y: auto; }
.sf-modal-body   { overflow-y: auto; max-height: 60dvh; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-300); }

/* ── Top Nav ───────────────────────────────────────────── */
#topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topnav-h);
  background: linear-gradient(135deg, var(--nav-bg) 0%, var(--nav-bg2) 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 200;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.nav-brand { display: flex; align-items: center; gap: 10px; }
.brand-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 13px;
  flex-shrink: 0;
}
.brand-name { color: #fff; font-weight: 700; font-size: 17px; letter-spacing: -.4px; }
.brand-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .6px;
  background: rgba(99,102,241,.28); color: #a5b4fc;
  padding: 2px 8px; border-radius: 4px;
}
.nav-actions { display: flex; align-items: center; gap: 8px; }
.nav-btn {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  color: #94a3b8; border-radius: 8px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 15px; transition: var(--transition);
  position: relative; z-index: 1; /* below nav-profile-wrap */
}
.nav-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
.notif-dot {
  position: absolute; top: -4px; right: -4px;
  background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 8px; padding: 0 5px; min-width: 16px;
  height: 16px; display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.nav-user { display: flex; align-items: center; gap: 8px; margin-left: 4px; }
.nav-user-name { color: #e2e8f0; font-size: 13px; font-weight: 500; }
.mobile-menu-btn {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1);
  color: #94a3b8; border-radius: 8px; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px;
}

/* ── App Layout ────────────────────────────────────────── */
#app-layout {
  display: flex;
  height: 100dvh;
  padding-top: var(--topnav-h);
  /* dvh = dynamic viewport height: excludes mobile browser chrome in PWA mode */
}

/* ── Sidebar ───────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .3s cubic-bezier(.4,0,.2,1), min-width .3s cubic-bezier(.4,0,.2,1), transform .3s ease;
  flex-shrink: 0;
  z-index: 100;
}
#sidebar.collapsed {
  width: 60px;
  min-width: 60px;
}
#sidebar.collapsed .si-label,
#sidebar.collapsed .si-badge,
#sidebar.collapsed .sidebar-label,
#sidebar.collapsed .sidebar-user-info,
#sidebar.collapsed .btn-new span,
#sidebar.collapsed .sidebar-user-name,
#sidebar.collapsed .sidebar-user-role {
  display: none;
}
#sidebar.collapsed .sidebar-item {
  justify-content: center;
  padding: 8px;
}
#sidebar.collapsed .sidebar-section {
  padding: 8px 6px;
}
#sidebar.collapsed .btn-new {
  padding: 10px 0 !important;
  justify-content: center !important;
}
#sidebar.collapsed .sidebar-user {
  justify-content: center;
  padding: 12px 6px;
}
.sidebar-section { padding: 12px 14px; }
.sidebar-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--gray-400); margin-bottom: 6px; padding: 0 8px;
}
.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 400;
  color: var(--gray-500); transition: var(--transition);
  border: none; background: none; width: 100%; text-align: left;
  text-decoration: none; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden;
}
.sidebar-item:hover { background: var(--gray-100); color: var(--gray-700); }
.sidebar-item.active { background: var(--brand-bg); color: var(--brand); font-weight: 600; }
.sidebar-item .si-icon { width: 20px; text-align: center; font-size: 15px; flex-shrink: 0; }
.sidebar-item .si-label { flex: 1; }
.sidebar-item .si-badge {
  font-size: 11px; font-weight: 700;
  background: var(--brand); color: #fff;
  border-radius: 10px; padding: 1px 7px; min-width: 20px; text-align: center;
}
.sidebar-item.active .si-badge { background: var(--brand); }
.sidebar-collapse-btn {
  border-top: 1px solid var(--gray-200);
  padding: 10px; text-align: center;
  cursor: pointer; color: var(--gray-400); font-size: 14px;
  background: none; border-left: none; border-right: none; border-bottom: none;
  width: 100%; transition: var(--transition);
}
.sidebar-collapse-btn:hover { color: var(--gray-600); background: var(--gray-50); }
.sidebar-user {
  padding: 12px 14px;
  border-top: 1px solid var(--gray-200);
  display: flex; align-items: center; gap: 10px;
  overflow: hidden;
}
.sidebar-user-info { flex: 1; min-width: 0; overflow: hidden; }
.sidebar-user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--gray-400); }

/* Mobile overlay sidebar */
#mobile-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 150;
}
#mobile-overlay.show { display: block; }
@media (max-width: 767px) {
  #sidebar {
    position: fixed;
    top: var(--topnav-h); bottom: 0; left: 0;
    transform: translateX(-100%);
    z-index: 160;
    box-shadow: var(--shadow-lg);
  }
  #sidebar.mobile-open { transform: translateX(0); }
}

/* ── Main Content ──────────────────────────────────────── */
#main-content { flex: 1; display: flex; overflow: hidden; }

/* ── Ticket List Panel ─────────────────────────────────── */
#ticket-list-panel {
  width: 42%;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--gray-200);
  background: var(--white);
  overflow: hidden;
  transition: width .3s ease;
}
#ticket-list-panel.full-width { width: 100%; }
@media (max-width: 991px) {
  #ticket-list-panel { width: 100%; border-right: none; }
  #ticket-list-panel.detail-open { display: none; }
}

/* Toolbar */
.list-toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--white);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.search-box {
  flex: 1; min-width: 150px;
  display: flex; align-items: center; gap: 8px;
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: 8px; padding: 0 12px; transition: var(--transition);
}
.search-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.search-box input {
  border: none; background: none; outline: none;
  padding: 8px 0; font-size: 13px; flex: 1;
  font-family: inherit; color: var(--gray-800);
}
.search-box input::placeholder { color: var(--gray-400); }
.search-box .search-icon { color: var(--gray-400); font-size: 14px; }
.filter-select {
  border: 1px solid var(--gray-200); border-radius: 8px;
  padding: 7px 10px; font-size: 12px; background: var(--white);
  cursor: pointer; color: var(--gray-600); outline: none;
  font-family: inherit; transition: var(--transition);
}
.filter-select:focus { border-color: var(--brand); }
.btn-new {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; border: none; border-radius: 8px;
  padding: 7px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  display: flex; align-items: center; gap: 6px;
  transition: var(--transition); white-space: nowrap;
}
.btn-new:hover { opacity: .9; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,.3); }

/* Ticket rows */
.ticket-list-scroll {
  flex: 1; overflow-y: auto;
  padding: 12px 14px;
}
.ticket-count { font-size: 11px; color: var(--gray-400); font-weight: 600; margin-bottom: 10px; }
.ticket-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; background: var(--white);
  border-radius: 10px; margin-bottom: 5px;
  cursor: pointer; border: 1px solid var(--gray-100);
  transition: var(--transition);
}
.ticket-row:hover { background: var(--gray-50); border-color: var(--gray-200); }
.ticket-row.active { background: #f5f3ff; border-color: #c7d2fe; }
.priority-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ticket-row-body { flex: 1; min-width: 0; }
.ticket-row-top { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.ticket-id-label { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--gray-400); font-weight: 500; }
.ticket-title-row { font-size: 13px; font-weight: 600; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.ticket-row-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ticket-row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.msg-count { font-size: 10px; color: var(--gray-400); }
.escalation-flag { font-size: 11px; color: var(--red); font-weight: 700; }
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 60px 20px;
  color: var(--gray-400); text-align: center;
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 13px; }

/* ── Badges ────────────────────────────────────────────── */
.badge-status, .badge-priority {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px;
  white-space: nowrap;
}
.status-Open         { background: #eff6ff; color: #2563eb; }
.status-In-Progress  { background: #fef3c7; color: #d97706; }
.status-In-Review    { background: #f0e7fe; color: #7c3aed; }
.status-Escalated    { background: #fef2f2; color: #dc2626; }
.status-Closed       { background: #f0fdf4; color: #16a34a; }
.priority-Critical   { background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5; }
.priority-High       { background: #fff7ed; color: #ea580c; border: 1px solid #fdba74; }
.priority-Medium     { background: #fefce8; color: #ca8a04; border: 1px solid #fde047; }
.priority-Low        { background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; }

/* Deadline pill */
.deadline-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; }
.deadline-overdue { color: #dc2626; }
.deadline-urgent   { color: #d97706; }
.deadline-ok       { color: var(--gray-500); }

/* ── Ticket Detail Panel ───────────────────────────────── */
#ticket-detail-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--white);
  overflow: hidden;
  position: relative;
}
#detail-placeholder {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--gray-300); text-align: center;
  padding: 40px;
}
#detail-placeholder .ph-icon { font-size: 64px; margin-bottom: 16px; }
#detail-placeholder h4 { font-size: 18px; font-weight: 600; color: var(--gray-400); margin-bottom: 8px; }
#detail-placeholder p { font-size: 13px; color: var(--gray-400); }

/* Detail header */
#detail-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-100);
  background: #fafbfc;
}
.detail-header-top {
  display: flex; justify-content: space-between;
  align-items: flex-start; margin-bottom: 10px; gap: 12px;
}
.detail-header-left { flex: 1; min-width: 0; }
.detail-id-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.detail-title { font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--gray-900); }
.detail-close-btn {
  background: none; border: none; color: var(--gray-400);
  cursor: pointer; font-size: 18px; padding: 4px;
  transition: var(--transition); flex-shrink: 0;
}
.detail-close-btn:hover { color: var(--gray-600); }
.detail-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--gray-500); }
.detail-meta-sep { color: var(--gray-200); }

/* Progress bar */
.progress-bar-wrap { margin-top: 10px; }
.progress-bar-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--gray-500); margin-bottom: 4px; }
.progress-bar-track { height: 4px; background: var(--gray-200); border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 4px; transition: width .6s ease-out; }
.progress-bar-fill.complete { background: var(--green); }
.progress-bar-fill.partial  { background: var(--brand); }

/* Escalation banner */
.escalation-banner {
  margin-top: 10px; padding: 10px 14px;
  background: #fef2f2; border-radius: 8px; border: 1px solid #fecaca;
  display: flex; align-items: center; gap: 10px;
}
.escalation-banner .esc-icon { color: var(--red); font-size: 16px; flex-shrink: 0; }
.escalation-banner .esc-body { flex: 1; min-width: 0; }
.escalation-banner .esc-title { font-size: 12px; font-weight: 700; color: var(--red); }
.escalation-banner .esc-reason { font-size: 11px; color: #b91c1c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.escalation-banner .esc-date { font-size: 10px; color: var(--gray-400); flex-shrink: 0; }

/* Tabs */
.detail-tabs {
  display: flex; border-bottom: 1px solid var(--gray-200);
  background: #fafbfc; padding: 0 16px; flex-shrink: 0;
}
.detail-tab {
  padding: 10px 16px; font-size: 13px; font-weight: 500;
  color: var(--gray-500); border-bottom: 2px solid transparent;
  cursor: pointer; background: none; border-top: none; border-left: none; border-right: none;
  font-family: inherit; transition: var(--transition);
}
.detail-tab:hover { color: var(--gray-700); }
.detail-tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* Tab content */
.detail-tab-content { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.tab-pane { display: none; flex: 1; overflow: auto; }
.tab-pane.active { display: flex; flex-direction: column; }

/* ── Messages ──────────────────────────────────────────── */
.messages-scroll { flex: 1; overflow-y: auto; }
.message-card {
  padding: 14px 20px;
  border-bottom: 1px solid #f8fafc;
  border-left: 3px solid transparent;
  transition: background .15s ease;
}
.message-card:hover { background: #fafbfc; }
.message-card.pinned { background: #fffbeb; border-left-color: #f59e0b; }
.message-inner { display: flex; gap: 10px; }
.message-body { flex: 1; min-width: 0; }
.message-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; gap: 8px; }
.message-sender { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.message-actions { display: flex; align-items: center; gap: 6px; }
.message-time { font-size: 11px; color: var(--gray-400); white-space: nowrap; }
.pin-btn, .del-btn {
  background: none; border: none; cursor: pointer;
  font-size: 13px; padding: 2px; transition: var(--transition); line-height: 1;
}
.pin-btn { color: var(--gray-300); }
.pin-btn.pinned, .pin-btn:hover { color: #f59e0b; }
.del-btn { color: var(--gray-300); }
.del-btn:hover { color: var(--red); }
.message-text { font-size: 13px; color: var(--gray-600); line-height: 1.6; word-break: break-word; }
.attachments-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; padding: 3px 10px;
  background: var(--gray-100); border: 1px solid var(--gray-200);
  border-radius: 6px; color: var(--gray-500);
  cursor: pointer; text-decoration: none; transition: var(--transition);
}
.attach-chip:hover { background: var(--gray-200); color: var(--gray-700); }

/* Compose box */
.compose-box {
  padding: 12px 16px;
  border-top: 1px solid var(--gray-200);
  background: #fafbfc; flex-shrink: 0;
}
.compose-inner { display: flex; gap: 8px; align-items: flex-end; }
.compose-textarea {
  flex: 1; border: 1px solid var(--gray-200); border-radius: 8px;
  padding: 10px 13px; font-size: 13px; font-family: inherit;
  resize: none; outline: none; min-height: 42px; max-height: 120px;
  transition: var(--transition);
}
.compose-textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.compose-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-attach {
  width: 40px; height: 40px;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 8px; cursor: pointer; color: var(--gray-500);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; transition: var(--transition);
}
.btn-attach:hover { background: var(--gray-100); color: var(--gray-700); }
.btn-send {
  height: 40px; padding: 0 18px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; border: none; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; display: flex; align-items: center; gap: 6px;
  transition: var(--transition);
}
.btn-send:hover { opacity: .9; }
.btn-send:disabled { opacity: .4; cursor: not-allowed; }
.attach-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.attach-preview-item {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; padding: 3px 8px;
  background: var(--brand-light); border: 1px solid #c7d2fe;
  border-radius: 6px; color: var(--brand);
}
.attach-remove {
  cursor: pointer; color: var(--brand); font-weight: 700;
  background: none; border: none; padding: 0; line-height: 1;
}

/* ── Tasks ─────────────────────────────────────────────── */
.tasks-pane-content { padding: 18px; }
.tasks-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.tasks-title { font-size: 14px; font-weight: 700; color: var(--gray-800); }
.btn-add-task {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; border: none; border-radius: 8px;
  padding: 7px 14px; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  display: flex; align-items: center; gap: 5px;
}
.add-task-form {
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: 10px; padding: 14px; margin-bottom: 14px;
  animation: fadeIn .2s ease;
}
.task-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--gray-100); margin-bottom: 6px;
  background: var(--white); transition: var(--transition);
}
.task-row.done { background: var(--green-light); border-color: #bbf7d0; }
.task-checkbox {
  width: 18px; height: 18px; border-radius: 4px;
  border: 2px solid var(--gray-300); background: transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; margin-top: 1px;
  transition: var(--transition);
}
.task-checkbox.checked { background: var(--green); border-color: var(--green); color: #fff; font-size: 11px; }
.task-body { flex: 1; min-width: 0; }
.task-title-text { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.task-row.done .task-title-text { text-decoration: line-through; color: var(--gray-400); }
.task-desc { font-size: 11px; color: var(--gray-400); margin-top: 2px; }
.task-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.task-assignee { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--gray-500); }
.task-status-pill {
  font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: 4px;
}
.task-status-Done        { background: #dcfce7; color: #16a34a; }
.task-status-Pending     { background: var(--gray-100); color: var(--gray-500); }
.task-status-In-Progress { background: #fef3c7; color: #d97706; }
.task-del-btn { background: none; border: none; cursor: pointer; color: var(--gray-300); font-size: 13px; padding: 2px; flex-shrink: 0; }
.task-del-btn:hover { color: var(--red); }
.tasks-empty { text-align: center; padding: 40px 20px; color: var(--gray-400); font-size: 13px; }

/* ── Detail Info ───────────────────────────────────────── */
.detail-info-pane { padding: 18px; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.info-field-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--gray-400); margin-bottom: 4px; }
.info-field-value { font-size: 13px; font-weight: 500; color: var(--gray-700); }
.detail-description { font-size: 13px; color: var(--gray-600); line-height: 1.6; }
.recipients-list { display: flex; flex-wrap: wrap; gap: 6px; }
.recipient-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; background: var(--gray-100);
  border-radius: 20px; font-size: 12px; color: var(--gray-600);
}
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.btn-action {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500; padding: 6px 12px;
  border: 1px solid var(--gray-200); border-radius: 8px;
  background: var(--white); color: var(--gray-600);
  cursor: pointer; font-family: inherit; transition: var(--transition);
}
.btn-action:hover { background: var(--gray-50); border-color: var(--gray-300); }
.btn-escalate {
  background: #fef2f2; border-color: #fecaca; color: var(--red); font-weight: 600;
}
.btn-escalate:hover { background: #fee2e2; }
.btn-extend {
  background: #eff6ff; border-color: #bfdbfe; color: #2563eb; font-weight: 600;
}
.btn-extend:hover { background: #dbeafe; }
.section-divider { border: none; border-top: 1px solid var(--gray-200); margin: 14px 0; }

/* ── Dashboard ─────────────────────────────────────────── */
.dashboard-content { flex: 1; overflow-y: auto; padding: 24px; }
.dash-heading { font-size: 22px; font-weight: 800; letter-spacing: -.5px; margin-bottom: 4px; }
.dash-subheading { font-size: 13px; color: var(--gray-500); margin-bottom: 24px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 18px 20px; border: 1px solid var(--gray-200);
  position: relative; overflow: hidden; transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-accent { position: absolute; top: 0; left: 0; width: 4px; height: 100%; border-radius: 14px 0 0 14px; }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.stat-label { font-size: 12px; color: var(--gray-500); margin-top: 4px; font-weight: 500; }
.dash-section-title { font-size: 14px; font-weight: 700; color: var(--gray-800); margin-bottom: 12px; }
.priority-bar-wrap { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 16px; margin-bottom: 24px; }
.priority-bar { display: flex; gap: 3px; height: 28px; border-radius: 6px; overflow: hidden; margin-bottom: 10px; }
.priority-segment { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 700; min-width: 28px; transition: width .6s ease; }
.priority-legend { display: flex; gap: 16px; flex-wrap: wrap; }
.priority-legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--gray-500); }
.priority-legend-dot { width: 8px; height: 8px; border-radius: 2px; }
.activity-list { display: flex; flex-direction: column; gap: 8px; }
.activity-item {
  display: flex; gap: 12px; padding: 12px 14px;
  background: var(--white); border-radius: 10px;
  border: 1px solid var(--gray-100); cursor: pointer; transition: var(--transition);
}
.activity-item:hover { background: var(--gray-50); }
.activity-body { flex: 1; min-width: 0; }
.activity-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.activity-sender { font-size: 13px; font-weight: 600; color: var(--gray-700); }
.activity-time { font-size: 11px; color: var(--gray-400); flex-shrink: 0; }
.activity-text { font-size: 12px; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-ticket { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--gray-400); }

/* ── Avatars ───────────────────────────────────────────── */
.avatar {
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: #fff; font-weight: 700;
  flex-shrink: 0; letter-spacing: -.5px;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-md { width: 32px; height: 32px; font-size: 12px; }
.avatar-xs { width: 20px; height: 20px; font-size: 8px; }
.avatar-tag { display: flex; align-items: center; gap: 5px; }
.tag-pill {
  font-size: 11px; padding: 2px 8px;
  background: var(--gray-100); border-radius: 4px;
  color: var(--gray-500); font-weight: 500;
}

/* ── Modals ────────────────────────────────────────────── */
.sf-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  z-index: 400; display: flex; align-items: center;
  justify-content: center; padding: 16px;
  animation: fadeIn .15s ease;
}
.sf-modal {
  background: var(--white); border-radius: 16px;
  width: 100%; max-height: 90dvh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
.sf-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px 26px; border-bottom: 1px solid var(--gray-200);
}
.sf-modal-title { font-size: 17px; font-weight: 700; }
.sf-modal-close {
  background: none; border: none; color: var(--gray-400);
  cursor: pointer; font-size: 18px; padding: 4px;
}
.sf-modal-close:hover { color: var(--gray-600); }
.sf-modal-body { padding: 22px 26px; }
.sf-modal-footer {
  padding: 16px 26px; border-top: 1px solid var(--gray-200);
  display: flex; justify-content: flex-end; gap: 10px;
  background: #fafbfc;
}
.form-label-sm { font-size: 12px; font-weight: 600; color: var(--gray-500); display: block; margin-bottom: 5px; }
.form-control-sf {
  border: 1px solid var(--gray-200); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; font-family: inherit;
  outline: none; width: 100%; transition: var(--transition);
  background: var(--white);
}
.form-control-sf:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.form-control-sf.textarea { resize: vertical; min-height: 80px; }
.recipient-toggle {
  font-size: 12px; padding: 5px 12px; border-radius: 8px;
  border: 1px solid var(--gray-200); background: var(--white);
  color: var(--gray-500); cursor: pointer; font-family: inherit; transition: var(--transition);
}
.recipient-toggle:hover { border-color: var(--gray-300); }
.recipient-toggle.selected { background: var(--brand-bg); border-color: #c7d2fe; color: var(--brand); font-weight: 600; }

/* ── Buttons ───────────────────────────────────────────── */
.btn-primary-sf {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; border: none; border-radius: 8px;
  padding: 9px 22px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: var(--transition);
}
.btn-primary-sf:hover { opacity: .9; }
.btn-primary-sf:disabled { opacity: .4; cursor: not-allowed; }
.btn-ghost-sf {
  background: var(--white); border: 1px solid var(--gray-200);
  color: var(--gray-600); border-radius: 8px;
  padding: 9px 18px; font-size: 13px; cursor: pointer;
  font-family: inherit; transition: var(--transition);
}
.btn-ghost-sf:hover { background: var(--gray-50); }
.btn-danger-sf {
  background: #fef2f2; border: 1px solid #fecaca;
  color: var(--red); border-radius: 8px;
  padding: 9px 18px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: var(--transition);
}
.btn-danger-sf:hover { background: #fee2e2; }

/* ── Portal ────────────────────────────────────────────── */
.portal-container { padding: 28px; max-width: 1200px; margin: 0 auto; }
.portal-heading { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.portal-subheading { font-size: 13px; color: var(--gray-500); margin-bottom: 22px; }
.portal-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.portal-table-wrap { background: var(--white); border-radius: var(--radius-lg); border: 1px solid var(--gray-200); overflow: visible; }
.portal-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.portal-table thead th {
  background: var(--gray-900); color: #fff;
  padding: 12px 14px; font-weight: 600; font-size: 12px;
  text-align: left; white-space: nowrap;
}
.portal-table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.portal-table tbody tr:last-child td { border-bottom: none; }
.portal-table tbody tr:hover { background: var(--gray-50); }
.portal-table tbody tr.selected-row { background: var(--brand-bg); }
.portal-link { color: var(--brand); font-weight: 600; cursor: pointer; text-decoration: none; }
.portal-link:hover { text-decoration: underline; }

/* ── Animations ────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes slideInLeft { from { transform: translateX(-100%); } to { transform: translateX(0); } }

.animate-in { animation: fadeIn .25s ease-out; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 991px) {
  #ticket-detail-panel { position: fixed; inset: 0; top: var(--topnav-h); z-index: 120; display: none; }
  #ticket-detail-panel.mobile-open { display: flex; }
}
@media (max-width: 576px) {
  .list-toolbar { flex-wrap: wrap; }
  .search-box { min-width: 100%; order: -1; }
  .info-grid { grid-template-columns: 1fr; }
  .dashboard-content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .portal-container { padding: 16px; }
  .portal-table-wrap { overflow-x: auto; }
}

/* ── Phase 1: Announcement Banners ─────────────────────────────────────────── */
#sf-announcements {
  position: sticky; top: 0; z-index: 200;
}
.sf-announcement {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px; font-size: 13px; font-weight: 500;
  border-bottom: 1px solid rgba(0,0,0,.08);
}
.sf-ann-info     { background: #eff6ff; color: #1d4ed8; }
.sf-ann-warning  { background: #fffbeb; color: #92400e; }
.sf-ann-critical { background: #fef2f2; color: #991b1b; }
.sf-ann-icon  { flex-shrink: 0; font-size: 14px; }
.sf-ann-title { font-weight: 700; margin-right: 4px; }
.sf-ann-msg   { flex: 1; opacity: .85; }
.sf-ann-close {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: currentColor; opacity: .5; padding: 0 4px; flex-shrink: 0;
}
.sf-ann-close:hover { opacity: 1; }

/* ── Phase 1: Plan Usage Bar ───────────────────────────────────────────────── */
.plan-usage-bar {
  height: 6px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin-top: 6px;
}
.plan-usage-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  transition: width .4s ease;
}
.plan-usage-fill.warn  { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.plan-usage-fill.full  { background: #ef4444; }
.plan-usage-row {
  display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 2px; color: #64748b;
}
.plan-limit-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
  background: #eff6ff; color: #6366f1; margin-left: 6px;
}

/* ── Phase 1: Delete ticket confirmation ──────────────────────────────────── */
.delete-confirm-row {
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px;
  padding: 10px 14px; font-size: 13px; color: #dc2626;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 8px;
}

/* ── Phase 2: File Hub ──────────────────────────────────────────────────────── */

/* Breadcrumb */
.fh-breadcrumb { display:flex; align-items:center; gap:5px; font-size:13px; margin-bottom:2px; flex-wrap:wrap; }
.fh-bc-link    { color:#6366f1; text-decoration:none; font-weight:500; }
.fh-bc-link:hover { text-decoration:underline; }
.fh-bc-sep     { color:#cbd5e1; }
.fh-bc-current { color:#64748b; font-weight:600; }

/* Grid / List views */
.fh-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:12px; }
.fh-list { display:flex; flex-direction:column; gap:6px; }
.fh-list .fh-folder-card,
.fh-list .fh-file-card {
  flex-direction:row; align-items:center; gap:12px;
  padding:10px 14px; border-radius:8px;
}
.fh-list .fh-folder-icon,
.fh-list .fh-file-icon { width:32px; height:32px; font-size:18px; margin-bottom:0; }
.fh-list .fh-folder-meta,
.fh-list .fh-file-meta { margin-top:0; margin-left:auto; }
.fh-list .fh-card-actions { position:static; opacity:1; background:none; padding:0; }

/* Folder card */
.fh-folder-card {
  background:#fff; border:1.5px solid #e2e8f0; border-radius:10px;
  padding:14px 12px; cursor:pointer; position:relative; overflow:hidden;
  transition:all .15s; display:flex; flex-direction:column; align-items:flex-start; gap:4px;
}
.fh-folder-card:hover { border-color:#6366f1; box-shadow:0 4px 14px rgba(99,102,241,.12); transform:translateY(-1px); }
.fh-folder-icon { font-size:28px; color:#f59e0b; margin-bottom:4px; }
.fh-folder-name { font-size:13px; font-weight:600; color:#1e293b; word-break:break-word; line-height:1.3; }
.fh-folder-meta { font-size:11px; color:#94a3b8; }

/* File card */
.fh-file-card {
  background:#fff; border:1.5px solid #e2e8f0; border-radius:10px;
  padding:14px 12px; cursor:pointer; position:relative; overflow:hidden;
  transition:all .15s; display:flex; flex-direction:column; align-items:flex-start; gap:4px;
}
.fh-file-card:hover { border-color:#6366f1; box-shadow:0 4px 14px rgba(99,102,241,.12); transform:translateY(-1px); }
.fh-file-icon { font-size:26px; margin-bottom:4px; }
.fh-file-name { font-size:12px; font-weight:600; color:#1e293b; line-height:1.3; word-break:break-word; }
.fh-file-meta { font-size:11px; color:#94a3b8; }

/* Hover actions */
.fh-card-actions {
  position:absolute; bottom:0; left:0; right:0;
  background:linear-gradient(to top,rgba(255,255,255,.98) 60%,transparent);
  padding:10px 8px 8px;
  display:flex; gap:4px; opacity:0; transition:opacity .15s;
}
.fh-folder-card:hover .fh-card-actions,
.fh-file-card:hover .fh-card-actions { opacity:1; }
.fh-action-btn {
  display:inline-flex; align-items:center; justify-content:center;
  width:26px; height:26px; border-radius:6px; border:1px solid #e2e8f0;
  background:#fff; color:#475569; font-size:12px; cursor:pointer;
  text-decoration:none; transition:all .12s;
}
.fh-action-btn:hover { background:#eff6ff; border-color:#6366f1; color:#6366f1; }
.fh-action-btn.danger:hover { background:#fef2f2; border-color:#fecaca; color:#dc2626; }

/* Drop zone */
.fh-drop-zone {
  border:2px dashed #c7d2fe; border-radius:12px; padding:32px 20px;
  text-align:center; transition:all .2s; cursor:pointer; background:#fafbff;
}
.fh-drop-zone.drag-over { border-color:#6366f1; background:#eff6ff; }
.fh-drop-zone:hover { border-color:#a5b4fc; }

/* Detail panel (slide in from right) */
#fh-detail-panel {
  position:fixed; top:0; right:0; width:360px; height:100dvh;
  background:#fff; border-left:1px solid #e2e8f0;
  box-shadow:-4px 0 20px rgba(0,0,0,.08);
  z-index:200; display:flex; flex-direction:column;
  animation:slideInRight .2s ease;
}
@keyframes slideInRight { from { transform:translateX(100%); } to { transform:translateX(0); } }

/* Activity list */
.fh-activity-list { display:flex; flex-direction:column; gap:2px; }
.fh-activity-row  { display:flex; align-items:center; gap:10px; font-size:12px; padding:7px 10px; border-radius:6px; }
.fh-activity-row:hover { background:#f8fafc; }
.fh-act-badge     { font-size:10px; font-weight:700; padding:2px 7px; border-radius:4px; min-width:64px; text-align:center; }
.fh-act-upload    { background:#eff6ff; color:#6366f1; }
.fh-act-download  { background:#f0fdf4; color:#16a34a; }
.fh-act-delete    { background:#fef2f2; color:#dc2626; }
.fh-act-rename    { background:#fefce8; color:#854d0e; }
.fh-act-move      { background:#f0f9ff; color:#0369a1; }
.fh-act-view      { background:#f5f3ff; color:#7c3aed; }
.fh-act-version   { background:#fff7ed; color:#c2410c; }
.fh-act-file  { color:#475569; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.fh-act-user  { color:#94a3b8; min-width:80px; }
.fh-act-time  { color:#cbd5e1; font-size:11px; white-space:nowrap; }

/* File picker (attach from hub) */
.fh-fp-row {
  display:flex; align-items:center; gap:10px; padding:9px 12px;
  border-radius:7px; cursor:pointer; font-size:13px; transition:background .1s;
}
.fh-fp-row:hover { background:#eff6ff; }
.fh-fp-back { color:#6366f1; font-weight:600; }

/* View toggle */
.fh-view-btn {
  width:30px; height:30px; border:1px solid #e2e8f0; border-radius:6px;
  background:#fff; color:#94a3b8; font-size:13px; cursor:pointer;
  display:inline-flex; align-items:center; justify-content:center; transition:all .15s;
}
.fh-view-btn:hover { border-color:#6366f1; color:#6366f1; }
.fh-view-btn.active { background:#eff6ff; border-color:#6366f1; color:#6366f1; }

/* ════════════════════════════════════════════════════════════════════════
   RESPONSIVE + MOBILE — Consolidated (zero legacy patches)
   ════════════════════════════════════════════════════════════════════════ */

/* ── Compose bar — Teams style ── */
.compose-box { background: var(--white); border-top: 1px solid #e8edf3; flex-shrink: 0; padding: 6px 10px; position: relative; }
.compose-closed { padding: 12px 16px; text-align: center; font-size: 13px; color: var(--gray-400); background: var(--gray-50); border-top: 1px solid var(--gray-200); }
.attach-preview { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 8px 0; }
.ai-suggestions-bar { padding: 4px 8px 0; }
.compose-wrap { border: 1.5px solid #d8dce6; border-radius: 8px; background: #fff; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.compose-wrap:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91,95,199,.1); }
.compose-field { width: 100%; border: none; outline: none; resize: none; font-family: var(--font); font-size: 14px; color: var(--gray-700); background: transparent; padding: 8px 12px 4px; line-height: 1.5; min-height: 38px; max-height: 120px; overflow-y: auto; display: block; box-shadow: none; }
.compose-field::placeholder { color: #9ca3af; }
.compose-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 4px; border-top: 1px solid #f0f2f5; background: #f8f9fb; min-height: 32px; }
.compose-tools { display: flex; align-items: center; gap: 2px; }
.compose-tool { width: 28px; height: 28px; border-radius: 5px; border: none; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; color: #64748b; transition: background .1s; }
.compose-tool:hover { background: #e8edf3; color: #374151; }
.compose-tool-ai { color: var(--brand); }
.compose-tool-ai:hover { background: #eff0fe; }
.compose-send-btn { display: flex; align-items: center; gap: 5px; padding: 5px 12px; border-radius: 6px; border: none; background: var(--brand); color: #fff; font-family: var(--font); font-size: 11px; font-weight: 700; cursor: pointer; transition: background .12s, transform .1s; }
.compose-send-btn:hover { background: var(--brand-dark, #4f46e5); }
.compose-send-btn:active { transform: scale(.95); }
.compose-send-btn i { font-size: 12px; }

/* ── Profile dropdown ── */
.nav-profile-wrap { position: relative; }
.nav-avatar-btn { width: 32px; height: 32px; border-radius: 50%; border: none; background: transparent; cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: center; transition: transform .12s; }
.nav-avatar-btn:hover { transform: scale(1.08); }
.nav-profile-menu { position: absolute; top: calc(100% + 8px); right: 0; width: 230px; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,.14); z-index: 9999; overflow: hidden; opacity: 0; transform: translateY(-6px) scale(.97); pointer-events: none; transition: opacity .15s, transform .15s; }
.nav-profile-menu.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.npm-header { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px; border-bottom: 1px solid #f1f5f9; }
.npm-item { display: flex; align-items: center; gap: 9px; padding: 10px 14px; font-size: 13px; color: #374151; text-decoration: none; transition: background .1s; font-family: var(--font); }
.npm-item:hover { background: #f8fafc; }
.npm-item i { font-size: 15px; color: #64748b; width: 16px; }
.npm-divider { height: 1px; background: #f1f5f9; margin: 4px 0; }
.npm-danger { color: #dc2626; }
.npm-danger i { color: #dc2626; }
.npm-danger:hover { background: #fef2f2; }

/* ── Compact ticket header ── */
.detail-header-compact { flex-shrink: 0; border-bottom: 1px solid var(--gray-100); background: var(--white); }
.dh-compact-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 12px 3px; gap: 6px; }
.dh-compact-left { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; flex: 1; }
.dh-compact-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.dh-title { font-size: 14px; font-weight: 700; color: var(--gray-800); padding: 2px 12px 7px; line-height: 1.3; }
.dh-deadline { font-size: 10px; font-weight: 600; color: var(--gray-500); padding: 2px 6px; border-radius: 4px; background: var(--gray-100); }
.dh-deadline.overdue { color: var(--red); background: #fef2f2; }
.dh-deadline.due-soon { color: var(--orange); background: #fffbeb; }
.dh-expand-btn { width: 26px; height: 26px; border-radius: 5px; border: none; background: transparent; cursor: pointer; color: var(--gray-400); display: flex; align-items: center; justify-content: center; font-size: 13px; }
.dh-expand-btn:hover { background: var(--gray-100); color: var(--gray-700); }
.dh-expand-btn i { transition: transform .2s; }
.dh-expandable { overflow: hidden; }

/* ── Global nav drawer ── */
.gnav-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 8px; text-decoration: none; font-size: 14px; font-weight: 500; color: #374151; transition: background .1s; margin-bottom: 2px; }
.gnav-item i { font-size: 17px; color: #6366f1; width: 20px; flex-shrink: 0; }
.gnav-item:hover { background: #f1f5f9; }
.gnav-active { background: #eff0fe; color: #6366f1; font-weight: 600; }

/* ── Alert items ── */
.galert-item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid #f8fafc; }
.galert-item i { font-size: 18px; flex-shrink: 0; }
.galert-red i { color: #dc2626; }
.galert-amber i { color: #d97706; }
.galert-blue i { color: #6366f1; }
.galert-item > div { flex: 1; font-size: 13px; color: #1e293b; }
.galert-link { font-size: 11px; font-weight: 700; color: #6366f1; text-decoration: none; padding: 4px 10px; border-radius: 6px; border: 1px solid #c7d2fe; background: #eff0fe; white-space: nowrap; }

/* ── Bottom nav ── */
.mob-bottom-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; height: calc(56px + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); background: #fff; border-top: 1px solid #e8e8e8; z-index: 130; grid-template-columns: repeat(5, 1fr); max-width: 100vw; transition: transform .3s cubic-bezier(.4,0,.2,1); }
.mob-bottom-nav.nav-slid { transform: translateY(100%); }
.mob-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: none; background: transparent; cursor: pointer; font-family: var(--font); color: #94a3b8; font-size: 10px; font-weight: 500; text-decoration: none; padding: 6px 0; position: relative; -webkit-tap-highlight-color: transparent; transition: color .15s; }
.mob-tab i { font-size: 18px; }
.mob-tab.active { color: var(--brand); }
.mob-tab-new { color: #fff; }
.mob-tab-new::before { content: ""; position: absolute; width: 40px; height: 40px; top: 50%; left: 50%; transform: translate(-50%, -58%); border-radius: 50%; background: linear-gradient(135deg, var(--brand), #8b8fe8); box-shadow: 0 3px 12px rgba(91,95,199,.4); z-index: -1; }
.mob-tab-new i { font-size: 20px; }
.mob-tab-new span { display: none; }
.mob-badge { position: absolute; top: 2px; right: calc(50% - 16px); min-width: 16px; height: 16px; border-radius: 8px; background: #ef4444; color: #fff; font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 3px; }

/* ── Navbar icon/brand ── */
.navbar-icon { border-radius: 8px; flex-shrink: 0; }
.brand-name { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: -0.3px; white-space: nowrap; }
.brand-badge { font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: rgba(255,255,255,.12); color: rgba(255,255,255,.75); letter-spacing: .5px; white-space: nowrap; }
.nav-breadcrumb { font-size: 13px; color: rgba(255,255,255,.45); margin-left: 8px; white-space: nowrap; }
.hamburger-btn { display: none; border: none; background: rgba(255,255,255,.1); color: rgba(255,255,255,.8); width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 20px; align-items: center; justify-content: center; flex-shrink: 0; margin-right: 4px; }
.hamburger-btn:hover { background: rgba(255,255,255,.18); }

/* ── Prevent horizontal overflow without breaking touch scroll ── */
/* clip does not create a new scroll container (unlike hidden) so Android WebView
   touch events propagate correctly for vertical scroll */
html  { overflow-x: clip; max-width: 100vw; }
body  { overflow-x: clip; max-width: 100vw; }
#topnav { overflow: hidden; max-width: 100vw; }

/* ── Mobile PWA: full-page scroll pages ──
   Pages that don't use #app-layout (portal, documents, analytics, settings)
   rely on native document scroll. These rules ensure nothing blocks it. */
@media (max-width: 768px) {
  body:not(:has(#app-layout)) {
    height: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
}

/* ═══ TABLET (≤991px) ═══════════════════════════════════════════════════════ */
@media (max-width: 991px) {
  #ticket-detail-panel { position: fixed; top: var(--topnav-h); left: 0; right: 0; bottom: 0; z-index: 120; background: #fff; transform: translateX(100%); transition: transform .28s cubic-bezier(.4,0,.2,1); display: flex; flex-direction: column; }
  #ticket-detail-panel.mobile-open { transform: translateX(0); }
  .mob-back { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid #f1f5f9; background: #fff; border: none; width: 100%; cursor: pointer; font-family: var(--font); font-size: 14px; font-weight: 600; color: var(--brand); }
  .dh-expandable { display: none; }
  .dh-expandable.expanded { display: block; }
  .dh-expand-btn { display: flex; }
}
@media (min-width: 992px) {
  .dh-expandable { display: block; }
  .dh-expand-btn { display: none; }
  .dh-compact-row { padding: 10px 16px 4px; }
  .dh-title { font-size: 16px; padding: 2px 16px 8px; }
  .mob-back { display: none; }
}

/* ═══ MOBILE (≤768px) ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Show mobile elements */
  .mob-bottom-nav { display: grid; }
  .hamburger-btn { display: none; }

  /* Topnav actions (notification bell) duplicate bottom nav — hide on mobile */
  .topnav-bell { display: none; }

  /* Topnav */
  #topnav { padding: 0 10px; height: 50px; }

  /* Sidebar slide-over */
  #sidebar { position: fixed; top: 50px; left: 0; bottom: 0; width: 280px; z-index: 200; background: #fff; transform: translateX(-100%); transition: transform .28s cubic-bezier(.4,0,.2,1); }
  #sidebar.mobile-open { transform: translateX(0); box-shadow: 6px 0 28px rgba(0,0,0,.16); }
  #mobile-overlay { transition: opacity .28s; opacity: 0; pointer-events: none; backdrop-filter: blur(3px); background: rgba(0,0,0,.32); }
  #mobile-overlay.show { opacity: 1; pointer-events: auto; }
  #sidebar { overflow-y: auto; -webkit-overflow-scrolling: touch; }

  /* Ticket list */
  #ticket-list-panel { width: 100%; border-right: none; }
  #ticket-list-items { padding-bottom: 70px; }
  .ticket-row { padding: 10px 12px; }
  .ticket-title-row { font-size: 13px; }
  .ticket-id-label { font-size: 9px; }
  .badge-status, .badge-priority { font-size: 9px; padding: 1px 5px; }
  .msg-count { font-size: 9px; }
  .list-toolbar { flex-wrap: nowrap; padding: 8px 10px; gap: 6px; }
  .search-box { flex: 1 1 0; min-width: 0; }
  .filter-select { flex: 0 0 auto; max-width: 110px; font-size: 11px; padding: 5px 6px; }

  /* Detail panel */
  #ticket-detail-panel { top: 50px; bottom: 0; }
  .messages-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; }
  #tab-messages { display: none; flex-direction: column; flex: 1; overflow: hidden; }
  #tab-messages.active { display: flex; }

  /* Compose mobile */
  .compose-send-btn span { display: none; }
  .compose-send-btn { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: 50%; }
  .compose-field { font-size: 16px; }

  /* Tabs scroll */
  .detail-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; min-height: 34px; }
  .detail-tabs::-webkit-scrollbar { display: none; }
  .detail-tab { flex-shrink: 0; padding: 7px 12px; font-size: 11px; }

  /* Info grid */
  .info-grid { grid-template-columns: 1fr; }

  /* Modals → bottom sheet */
  .sf-modal-backdrop, .modal-overlay { align-items: flex-end; padding: 0; backdrop-filter: blur(4px); }
  .sf-modal, .modal-box { border-radius: 20px 20px 0 0; max-width: 100%; width: 100%; max-height: 92dvh; animation: sheetUp .3s cubic-bezier(.32,.72,0,1); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .sf-modal { max-width: 100%; }
  .modal-box { max-width: 100%; }
  @keyframes sheetUp { from { transform: translateY(100%); opacity: .8; } to { transform: translateY(0); opacity: 1; } }

  /* Profile dropdown — fixed on mobile */
  .nav-profile-menu { position: fixed; top: 52px; right: 8px; width: min(240px, calc(100vw - 16px)); z-index: 9999; transform-origin: top right; max-height: calc(100dvh - 70px); overflow-y: auto; }

  /* Notification drawer */
  .mob-notif-drawer { position: fixed; top: 50px; right: 0; bottom: 0; width: min(320px, 90vw); background: #fff; z-index: 210; transform: translateX(100%); transition: transform .28s cubic-bezier(.4,0,.2,1); box-shadow: -4px 0 24px rgba(0,0,0,.12); display: flex; flex-direction: column; overflow-y: auto; }
  .mob-notif-drawer.open { transform: translateX(0); }
  .mob-notif-backdrop { position: fixed; inset: 0; z-index: 205; background: rgba(0,0,0,.25); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .28s; display: block; }
  .mob-notif-backdrop.show { opacity: 1; pointer-events: auto; }

  /* Escalation compact */
  .escalation-banner { padding: 7px 12px; font-size: 12px; }
  .esc-title { font-size: 12px; }
  .esc-reason { font-size: 11px; }

  /* Settings */
  .settings-layout .settings-group { display: none; }
  .desktop-nav-only { display: none; }

  /* Analytics */
  .an-two-col { grid-template-columns: 1fr; }
  .dashboard-content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ═══ SMALL PHONES (≤380px) ═════════════════════════════════════════════════ */
@media (max-width: 380px) {
  .navbar-icon { width: 24px; height: 24px; }
  .brand-name { font-size: 14px; }
  .brand-badge { display: none; }
  .nav-breadcrumb { display: none; }
}

/* Desktop: hide mobile-only */
.mob-back { display: none; }
@media (min-width: 769px) {
  .mob-notif-drawer { display: none; }
  .mob-notif-backdrop { display: none; }
  .mob-bottom-nav { display: none; }
  .hamburger-btn { display: none; }
}


/* ═══════════════════════════════════════════════════════════════════════════════
   PRESENCE + TYPING + STATUS + RECONNECTION
   Production-grade real-time UI components
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── Typing indicator ──────────────────────────────────────────────────────── */
.typing-indicator-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #f0f0ff;
  border-radius: 10px;
  font-size: 12px;
  color: #6366f1;
  font-weight: 500;
  animation: fadeSlideUp .2s ease;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.typing-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #6366f1;
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .30s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.typing-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}


/* ── Presence dot ──────────────────────────────────────────────────────────── */
.presence-dot {
  display: inline-block;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background .2s;
}

.presence-avatar-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.presence-dot-overlay {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid white;
  transition: background .2s;
}


/* ── Presence row (teammates panel) ────────────────────────────────────────── */
.presence-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 8px;
  transition: background .12s;
  cursor: default;
}
.presence-row:hover {
  background: var(--gray-50, #f8fafc);
}

.presence-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700, #374151);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.presence-status-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
}

.presence-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-400, #94a3b8);
  padding: 10px 12px 4px;
}

.presence-empty {
  text-align: center;
  padding: 20px 12px;
  font-size: 13px;
  color: var(--gray-400, #94a3b8);
}


/* ── Status picker ─────────────────────────────────────────────────────────── */
.status-picker-wrapper {
  position: relative;
  display: inline-flex;
}

.status-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--gray-50, #f8fafc);
  border: 1px solid var(--gray-200, #e2e8f0);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600, #475569);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.status-picker-btn:hover {
  background: white;
  border-color: var(--gray-300, #cbd5e1);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.status-label-text {
  display: inline;
}
@media (max-width: 768px) {
  .status-label-text { display: none; }
}

.status-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: white;
  border: 1px solid var(--gray-200, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.10), 0 2px 8px rgba(0,0,0,.04);
  padding: 6px;
  z-index: 200;
  opacity: 0;
  transform: translateY(-6px) scale(.96);
  pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.status-dropdown.open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.status-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700, #374151);
  cursor: pointer;
  transition: background .1s;
}
.status-option:hover {
  background: var(--gray-50, #f8fafc);
}
.status-option.active {
  background: var(--primary-50, #eef2ff);
  color: var(--primary, #6366f1);
  font-weight: 600;
}


/* ── Viewer badges (who's looking at this ticket) ──────────────────────────── */
.viewer-badge {
  display: inline-flex;
  animation: fadeIn .2s ease;
}

#ticket-viewers {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}


/* ── Reconnection banner ───────────────────────────────────────────────────── */
#sf-reconnect-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fef3c7;
  color: #92400e;
  font-size: 13px;
  font-weight: 600;
  z-index: 10000;
  animation: slideDown .25s ease;
}
#sf-reconnect-banner.online {
  background: #d1fae5;
  color: #065f46;
  animation: fadeOut .8s ease 0.7s forwards;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to   { transform: none; }
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-100%); }
}


/* ── Online count badge ────────────────────────────────────────────────────── */
#sf-online-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #22c55e;
  color: white;
  font-size: 10px;
  font-weight: 700;
}


/* ── Smooth transitions for interactive elements ───────────────────────────── */
.ticket-row {
  transition: background .15s, transform .1s, box-shadow .15s;
}
.ticket-row:active {
  transform: scale(0.99);
}

.btn-primary-sf, .btn-ghost-sf {
  transition: all .15s ease;
}
.btn-primary-sf:active, .btn-ghost-sf:active {
  transform: scale(0.97);
}

/* Badge count bounce */
@keyframes badgeBounce {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.badge-bounce {
  animation: badgeBounce .3s ease;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   PROFILE MENU — STATUS + SOUND + PRESENCE DOT
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Fix: dropdown was clipping behind navbar */
.nav-profile-wrap    { position: relative; isolation: isolate; z-index: 1000; }
.nav-profile-menu    { z-index: 99999 !important; }   /* above everything */

/* Presence dot on avatar button */
.nav-avatar-btn      { position: relative; background: none; border: none; cursor: pointer; padding: 2px; border-radius: 50%; }
.nav-presence-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid white;
  background: #22c55e;
  transition: background .2s;
}

/* Presence dot inside menu header */
.npm-presence-dot {
  position: absolute; bottom: 0; right: 0;
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid white;
  background: #22c55e;
  transition: background .2s;
}

/* Status chip row */
.npm-status-row {
  padding: 8px 14px 4px;
}
.npm-status-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #94a3b8;
  display: block; margin-bottom: 6px;
}
.npm-status-chips {
  display: flex; flex-wrap: wrap; gap: 5px;
}
.npm-chip {
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; border: 1.5px solid transparent;
  cursor: pointer; transition: all .12s; background: #f8fafc; color: #475569;
}
.npm-chip:hover                          { transform: scale(1.05); }
.npm-chip.active, .npm-chip-available.active { background:#dcfce7; color:#15803d; border-color:#bbf7d0; }
.npm-chip-away.active                    { background:#fef9c3; color:#a16207; border-color:#fde68a; }
.npm-chip-busy.active                    { background:#fee2e2; color:#b91c1c; border-color:#fca5a5; }
.npm-chip-dnd.active                     { background:#fde8e8; color:#991b1b; border-color:#fca5a5; }

/* Sound toggle row */
.npm-sound-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; cursor: pointer; transition: background .1s;
  font-size: 13px; font-weight: 500; color: #374151;
}
.npm-sound-row:hover { background: #f8fafc; }

.npm-toggle {
  position: relative; width: 32px; height: 18px;
  background: #e2e8f0; border-radius: 9px;
  transition: background .2s; flex-shrink: 0;
}
.npm-toggle.on  { background: #6366f1; }
.npm-toggle-knob {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: white; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.npm-toggle.on .npm-toggle-knob { transform: translateX(14px); }

/* ── Storage bucket badges ── */
.badge-purpose, .badge-default, .badge-inactive,
.badge-access-private, .badge-access-public {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}
.badge-purpose       { background:#eef2ff; color:#4f46e5; }
.badge-default       { background:#f0fdf4; color:#15803d; }
.badge-inactive      { background:#f1f5f9; color:#94a3b8; }
.badge-access-private{ background:#fff7ed; color:#c2410c; }
.badge-access-public { background:#fef9c3; color:#a16207; }
.btn-xs { padding:4px 10px !important; font-size:11px !important; }
.btn-danger-ghost { color:#ef4444 !important; }
.btn-danger-ghost:hover { background:#fef2f2 !important; border-color:#fecaca !important; }

/* ═══════════════════════════════════════════════════════════════════════════════
   GLOBAL SEARCH OVERLAY
   ═══════════════════════════════════════════════════════════════════════════════ */

.nav-search-btn {
  background: none; border: none; cursor: pointer;
  color: var(--gray-400, #94a3b8);
  padding: 6px 8px; border-radius: 8px;
  font-size: 16px; transition: color .15s, background .15s;
}
.nav-search-btn:hover { background: var(--gray-100, #f1f5f9); color: var(--gray-700, #374151); }

#sf-search-overlay {
  position: fixed; inset: 0; z-index: 99999;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 80px;
  opacity: 0; transition: opacity .15s;
  pointer-events: none;
}
#sf-search-overlay.open { opacity: 1; pointer-events: auto; }

.sf-search-backdrop {
  position: absolute; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
}

.sf-search-modal {
  position: relative; z-index: 1;
  width: min(640px, 94vw);
  background: white;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,.2), 0 4px 16px rgba(0,0,0,.1);
  overflow: hidden;
  transform: translateY(-12px) scale(.97);
  transition: transform .15s;
}
#sf-search-overlay.open .sf-search-modal { transform: none; }

.sf-search-input-wrap {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100, #f1f5f9);
}
.sf-search-icon { font-size: 18px; color: var(--gray-400, #94a3b8); flex-shrink: 0; }
.sf-search-input {
  flex: 1; border: none; outline: none;
  font-size: 16px; font-weight: 500; color: var(--gray-900, #0f172a);
  background: transparent;
}
.sf-search-input::placeholder { color: var(--gray-400, #94a3b8); }
.sf-search-esc {
  padding: 3px 8px; border-radius: 5px;
  background: var(--gray-100, #f1f5f9);
  border: 1px solid var(--gray-200, #e2e8f0);
  font-size: 11px; font-weight: 600; color: var(--gray-500, #64748b);
  cursor: pointer; flex-shrink: 0;
}

.sf-search-results { max-height: 400px; overflow-y: auto; }
.sf-search-hint {
  padding: 20px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--gray-400, #94a3b8);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}

.sf-search-result {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; text-decoration: none; color: inherit;
  transition: background .1s;
  border-bottom: 1px solid var(--gray-50, #f8fafc);
}
.sf-search-result:hover { background: var(--gray-50, #f8fafc); }

.sf-sr-icon {
  width: 34px; height: 34px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-50, #eef2ff); border-radius: 8px;
  color: var(--primary, #6366f1); font-size: 16px;
}
.sf-sr-body { flex: 1; min-width: 0; }
.sf-sr-title {
  font-size: 13px; font-weight: 600; color: var(--gray-800, #1e293b);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sf-sr-excerpt {
  font-size: 11px; color: var(--gray-500, #64748b);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.sf-sr-type {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--gray-400, #94a3b8);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TEAMS-STYLE STATUS BADGES — override old dot styles
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Nav button presence dot — transparent bg, SVG renders inside */
.nav-presence-dot,
.npm-presence-dot {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  overflow: visible;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

/* Status chips — slightly bigger, icon + label layout */
.npm-status-chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.npm-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all .12s;
  background: var(--gray-50, #f8fafc);
  color: var(--gray-600, #475569);
  white-space: nowrap;
}
.npm-chip:hover { background: var(--gray-100, #f1f5f9); transform: scale(1.02); }
.npm-chip.active { border-color: currentColor; }
.npm-chip-available.active { background: #dcfce7; color: #15803d; }
.npm-chip-away.active      { background: #fef9c3; color: #a16207; }
.npm-chip-busy.active      { background: #fee2e2; color: #b91c1c; }
.npm-chip-dnd.active       { background: #fde8e8; color: #991b1b; }

.chip-svg-wrap {
  display: inline-flex;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

/* Profile menu — wider to fit DND label */
.nav-profile-menu {
  min-width: 220px !important;
}

/* ── Teams-style status chips — compact vertical list, not 2×2 grid ──────── */
.npm-status-chips {
  display: flex !important;
  flex-direction: column !important;
  gap: 3px !important;
}

.npm-chip {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 6px 10px !important;
  border-radius: 7px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  border: none !important;
  cursor: pointer;
  transition: background .1s;
  background: transparent !important;
  color: var(--gray-700, #374151) !important;
  width: 100%;
  text-align: left;
}
.npm-chip:hover { background: var(--gray-50, #f8fafc) !important; }
.npm-chip.active {
  background: var(--gray-100, #f1f5f9) !important;
  font-weight: 600 !important;
}
.npm-chip-available.active { color: #15803d !important; }
.npm-chip-away.active      { color: #a16207 !important; }
.npm-chip-busy.active      { color: #b91c1c !important; }
.npm-chip-dnd.active       { color: #991b1b !important; }

.chip-svg-wrap {
  display: inline-flex !important;
  width: 12px !important;
  height: 12px !important;
  flex-shrink: 0 !important;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ATTACHMENT LIGHTBOX
   ═══════════════════════════════════════════════════════════════════════════════ */

#sf-lightbox {
  position: fixed; inset: 0; z-index: 100000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .18s;
  pointer-events: none;
}
#sf-lightbox.open { opacity: 1; pointer-events: auto; }

.lb-backdrop {
  position: absolute; inset: 0;
  background: rgba(8, 10, 18, .88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.lb-shell {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  width: min(92vw, 1000px);
  height: 92vh;           /* fixed height so PDF fills it */
  max-height: 92dvh;
  background: #1a1d2e;
  border-radius: 14px;
  box-shadow: 0 32px 80px rgba(0,0,0,.6);
  overflow: hidden;
  transform: scale(.96);
  transition: transform .18s;
}
#sf-lightbox.open .lb-shell { transform: scale(1); }

@media (max-width: 768px) {
  .lb-shell {
    width: 100vw;
    height: 100dvh;       /* fill full screen on mobile */
    max-height: 100dvh;
    border-radius: 0;
  }
  #sf-lightbox { padding-top: 0; align-items: flex-start; }
}

/* Top bar */
.lb-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255,255,255,.05);
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.lb-title {
  font-size: 13px; font-weight: 600;
  color: rgba(255,255,255,.85);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 60%;
}
.lb-actions { display: flex; gap: 4px; }
.lb-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: rgba(255,255,255,.08);
  border: none; border-radius: 7px;
  color: rgba(255,255,255,.7); font-size: 14px;
  cursor: pointer; text-decoration: none;
  transition: background .12s, color .12s;
}
.lb-btn:hover { background: rgba(255,255,255,.16); color: white; }
.lb-close:hover { background: rgba(239,68,68,.25); color: #fca5a5; }

/* Stage */
.lb-stage {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
  background: #111320;
}

.lb-img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  cursor: zoom-in;
  transition: transform .25s;
  border-radius: 2px;
  display: block;
}
.lb-img.zoomed {
  max-width: none; max-height: none;
  cursor: zoom-out;
  transform: scale(1.8);
}
.lb-stage.zoomed { overflow: auto; cursor: zoom-out; }

.lb-file-fallback, .lb-error {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: rgba(255,255,255,.7);
}
.lb-file-fallback p, .lb-error p { color: rgba(255,255,255,.6); font-size: 13px; }
.lb-spinner {
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}

/* Arrow navigation */
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 56px;
  background: rgba(255,255,255,.08);
  border: none; border-radius: 8px;
  color: white; font-size: 16px;
  cursor: pointer; z-index: 10;
  transition: background .12s, opacity .12s;
  display: flex; align-items: center; justify-content: center;
}
.lb-nav:hover { background: rgba(255,255,255,.18); }
.lb-prev { left: 10px; }
.lb-next { right: 10px; }

/* Footer thumbnails */
.lb-footer {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 16px;
  background: rgba(255,255,255,.04);
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.lb-thumbs {
  display: flex; gap: 6px; align-items: center;
  overflow-x: auto; max-width: 80%;
  scrollbar-width: thin;
}
.lb-thumb {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 6px;
  background: rgba(255,255,255,.08);
  border: 2px solid transparent;
  overflow: hidden; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .12s;
}
.lb-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lb-thumb.active { border-color: #6366f1; }
.lb-thumb:hover  { border-color: rgba(99,102,241,.5); }
.lb-counter {
  font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,.4);
  white-space: nowrap;
}

/* Attachment chips in message */
.attach-chip-preview { cursor: pointer; }
.attach-name {
  max-width: 120px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  font-size: 11px;
}

.lb-pdf-wrap {
  display: flex; flex-direction: column;
  width: 100%; height: 100%;
}
.lb-pdf {
  flex: 1; width: 100%; min-height: 0; border: none; background: #1e2030;
  /* Remove any fixed min-height — flex:1 handles sizing */
}
.lb-pdf-fallback {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px;
}
.lb-pdf-actions .btn-ghost-sf:hover { border-color: rgba(255,255,255,.4) !important; }

/* ── Lightbox: CSV table preview ── */
.lb-csv-wrap {
  width: 100%; height: 100%;
  overflow: auto;
  padding: 8px;
}
.lb-csv-table {
  width: 100%; border-collapse: collapse;
  font-size: 12px; color: rgba(255,255,255,.85);
}
.lb-csv-table th {
  background: rgba(255,255,255,.08);
  padding: 6px 10px; text-align: left;
  font-weight: 700; font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: rgba(255,255,255,.5);
  position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.lb-csv-table td {
  padding: 5px 10px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  white-space: nowrap; max-width: 250px;
  overflow: hidden; text-overflow: ellipsis;
}
.lb-csv-table tbody tr:hover { background: rgba(255,255,255,.04); }

/* ── File Hub detail panel — mobile full screen ── */
@media (max-width: 768px) {
  /* Dimensions/position when the panel IS open (JS sets display:flex).
     Do NOT set display here — that overrides JS's display:none. */
  #fh-detail-panel {
    width: 100vw !important;
    top: 50px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    border-left: none !important;
    border-radius: 0 !important;
    flex-direction: column !important;
  }
  #fh-detail-content {
    flex-direction: column;
    height: 100%;
    font-size: 13px;
    overflow: hidden;
  }
  /* scrollable body — the second direct child div is the content area */
  #fh-detail-content > div:last-child {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
    padding-bottom: 80px;
  }
  /* hide extra columns on small screens */
  .fh-act-user,
  .fh-act-time { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   UNIFIED NOTIFICATION SYSTEM
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Individual notification item */
.notif-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(0,0,0,.05);
  transition: background .1s;
}
.notif-item:hover { filter: brightness(.97); }

.notif-item-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; background: rgba(0,0,0,.06);
  font-size: 15px;
}

.notif-item-body { flex: 1; min-width: 0; }

.notif-item-title {
  font-size: 13px; font-weight: 700;
  color: #1e293b; line-height: 1.3;
}

.notif-item-sub {
  font-size: 11px; color: #64748b;
  margin-top: 2px; line-height: 1.3;
}

.notif-item-links {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 8px;
}

/* Ticket ID pill — clickable deep link */
.notif-ticket-link {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 6px;
  background: rgba(0,0,0,.06);
  border: 1px solid rgba(0,0,0,.08);
  font-size: 11px; font-weight: 600;
  color: #374151; cursor: pointer;
  font-family: ui-monospace, monospace;
  transition: background .1s, color .1s;
  white-space: nowrap;
}
.notif-ticket-link:hover {
  background: #6366f1; color: white; border-color: #6366f1;
}

.notif-see-all {
  font-size: 11px; font-weight: 600; color: #6366f1;
  background: none; border: none; cursor: pointer; padding: 3px 4px;
}
.notif-see-all:hover { text-decoration: underline; }

/* Empty / loading states */
.notif-loading, .notif-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 20px; text-align: center;
  gap: 8px; color: #94a3b8;
}
.notif-empty p { margin: 0; font-size: 13px; }

/* #notif-badge on /app top-nav bell */
#notif-badge {
  position: absolute; top: -2px; right: -2px;
  font-size: 9px; font-weight: 700;
  background: #ef4444; color: white;
  border-radius: 8px; padding: 0 3px;
  line-height: 14px; min-width: 14px;
  text-align: center; pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   DOCUMENT PROCESSING MODAL
   ═══════════════════════════════════════════════════════════════════════════════ */

.proc-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(8,10,18,.6);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(4px);
}
@media (min-width: 600px) {
  .proc-overlay { align-items: center; }
}

.proc-modal {
  background: #fff;
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 24px 20px 32px;
  box-shadow: 0 -8px 40px rgba(0,0,0,.18);
}
@media (min-width: 600px) {
  .proc-modal { border-radius: 20px; }
}

/* Header */
.proc-header { display:flex; gap:14px; align-items:flex-start; margin-bottom:20px; }
.proc-header-icon { font-size:26px; flex-shrink:0; margin-top:2px; color:#6366f1; }
.proc-title { font-size:16px; font-weight:800; color:#1e293b; }
.proc-subtitle { font-size:12px; color:#64748b; margin-top:2px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:300px; }

/* Type selection grid */
.proc-section-label { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:#94a3b8; margin-bottom:10px; }
.proc-type-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-bottom:20px; }
@media (min-width:400px) { .proc-type-grid { grid-template-columns:repeat(4,1fr); } }

.proc-type-btn {
  display:flex; flex-direction:column; align-items:center; gap:4px;
  padding:12px 6px; border-radius:12px;
  border:2px solid #e2e8f0; background:#f8fafc;
  cursor:pointer; transition:all .15s;
  font-size:11px; font-weight:600; color:#475569; text-align:center;
}
.proc-type-btn:hover { border-color:#6366f1; background:#eef2ff; color:#6366f1; }
.proc-type-selected { border-color:#6366f1 !important; background:#eef2ff !important; color:#6366f1 !important; box-shadow:0 0 0 3px rgba(99,102,241,.15); }
.proc-type-auto { grid-column:1/-1; flex-direction:row; justify-content:flex-start; padding:12px 16px; gap:10px; text-align:left; }
.proc-type-icon { font-size:20px; }
.proc-type-hint { font-size:10px; font-weight:400; color:#94a3b8; margin-top:2px; }

/* Progress area */
.proc-progress-area { text-align:center; padding:20px 0 10px; }
.proc-spinner {
  width:44px; height:44px; border-radius:50%;
  border:4px solid #e2e8f0; border-top-color:#6366f1;
  animation:spin .8s linear infinite; margin:0 auto 16px;
}
@keyframes spin { to { transform:rotate(360deg); } }
@keyframes sfSlideUp { from { opacity:0;transform:translateX(-50%) translateY(20px); } to { opacity:1;transform:translateX(-50%) translateY(0); } }

.proc-progress-msg { font-size:13px; color:#475569; font-weight:600; margin-bottom:12px; }
.proc-progress-bar { height:6px; background:#e2e8f0; border-radius:3px; overflow:hidden; margin:0 0 14px; }
.proc-progress-fill { height:100%; background:linear-gradient(90deg,#6366f1,#8b5cf6); border-radius:3px; transition:width .6s ease; }

.proc-progress-steps { display:flex; gap:8px; justify-content:center; flex-wrap:wrap; }
.proc-step { font-size:11px; color:#94a3b8; padding:3px 8px; border-radius:20px; }
.proc-step.active { background:#eef2ff; color:#6366f1; font-weight:700; }
.proc-step.done { color:#22c55e; }

/* Page classification cards */
.proc-pages-list { display:flex; flex-direction:column; gap:8px; max-height:280px; overflow-y:auto; margin-bottom:12px; }
.proc-page-card {
  display:flex; gap:12px; align-items:flex-start;
  padding:10px 12px; border-radius:10px;
  border:1.5px solid #e2e8f0; background:#f8fafc;
  transition:border-color .15s;
}
.proc-page-ignore { opacity:.55; }
.proc-page-num { font-size:12px; font-weight:800; color:#94a3b8; min-width:24px; margin-top:4px; }
.proc-page-body { flex:1; min-width:0; }
.proc-page-type-sel { width:100%; font-size:12px; padding:5px 8px; border-radius:8px; border:1.5px solid #e2e8f0; background:#fff; color:#1e293b; font-weight:600; margin-bottom:4px; }
.proc-page-confidence { font-size:11px; font-weight:700; margin-bottom:2px; }
.conf-high { color:#16a34a; }
.conf-mid  { color:#d97706; }
.conf-low  { color:#dc2626; }
.proc-page-reason { font-size:10px; color:#94a3b8; line-height:1.3; }

.proc-classify-summary { font-size:12px; color:#64748b; background:#f1f5f9; border-radius:8px; padding:10px 12px; margin-bottom:18px; display:flex; gap:8px; }

/* Footer */
.proc-footer { display:flex; gap:10px; justify-content:flex-end; margin-top:20px; padding-top:16px; border-top:1px solid #f1f5f9; }
