/* ==========================================================================
   JY Global · Internal AI Portal — Prototype Styles
   Built on the locked design system: design-system.md
   ========================================================================== */

/* ---- Base ---- */
body { font-family: 'Manrope', system-ui, sans-serif; background: #F5F7FA; }
* { box-sizing: border-box; }

/* ---- Design system utilities ---- */
.ease-spring { transition-timing-function: cubic-bezier(0.32, 0.72, 0, 1); }
.tabular { font-variant-numeric: tabular-nums; }
.text-balance { text-wrap: balance; }
.text-pretty { text-wrap: pretty; }

/* ---- Shadows ---- */
.card-shadow    { box-shadow: 0 1px 3px rgba(15,23,42,0.04), 0 8px 30px -12px rgba(11,31,53,0.08); }
.card-shadow-lg { box-shadow: 0 1px 3px rgba(15,23,42,0.04), 0 20px 50px -20px rgba(11,31,53,0.18); }
.nav-shadow     { box-shadow: 0 1px 0 rgba(15,23,42,0.04); }
.hero-stats-shadow {
  box-shadow:
    0 1px 3px rgba(11,31,53,0.06),
    0 30px 60px -20px rgba(11,31,53,0.25),
    0 12px 24px -12px rgba(21,181,199,0.08);
}

/* ---- Underline grow link ---- */
.underline-grow {
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 400ms cubic-bezier(0.32, 0.72, 0, 1);
}
.group:hover .underline-grow,
a:hover .underline-grow { background-size: 100% 1px; }

/* ---- Grid + dot patterns ---- */
.grid-bg {
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 64px 64px;
}
.dot-bg {
  background-image: radial-gradient(rgba(15,23,42,0.06) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ---- App shell ---- */
.app-shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.app-sidebar {
  background: #FFFFFF;
  border-right: 1px solid #E2E8F0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.app-main { background: #F5F7FA; min-width: 0; }

/* sidebar nav item */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms cubic-bezier(0.32, 0.72, 0, 1);
  position: relative;
  text-decoration: none;
}
.nav-item:hover { background: #F0F4F8; color: #0F172A; }
.nav-item.active {
  background: #0B1F35;
  color: #FFFFFF;
}
.nav-item.active i { color: #15B5C7; }
.nav-item .nav-badge {
  margin-left: auto;
  background: rgba(21,181,199,0.15);
  color: #0E9DAE;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
}
.nav-item.active .nav-badge { background: rgba(21,181,199,0.2); color: #15B5C7; }

.nav-section-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 700;
  color: #64748B;
  padding: 0 12px;
  margin-bottom: 6px;
}

/* ---- Top bar ---- */
.app-topbar {
  background: #FFFFFF;
  border-bottom: 1px solid #E2E8F0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 20;
}

/* ---- Eyebrow pill ---- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #F0F4F8;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  color: #0B1F35;
}
.eyebrow::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #0B1F35;
}
.eyebrow.eyebrow-cyan { color: #15B5C7; background: rgba(21,181,199,0.1); }
.eyebrow.eyebrow-cyan::before { background: #15B5C7; }
.eyebrow.eyebrow-dark { background: rgba(255,255,255,0.08); color: #15B5C7; border: 1px solid rgba(255,255,255,0.15); }
.eyebrow.eyebrow-dark::before { background: #15B5C7; }

/* ---- Browser chrome (mockup wrapper) ---- */
.browser-chrome {
  background: linear-gradient(to bottom, #F8FAFC, #F1F5F9);
  border-bottom: 1px solid #E2E8F0;
}

/* ---- Citation ---- */
.citation {
  background: #ECFDFD;
  color: #0E9DAE;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: 600;
  border: 1px solid #B6EAEF;
}

/* ---- Custom scrollbar ---- */
.chat-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.chat-scroll::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
.chat-scroll::-webkit-scrollbar-track { background: transparent; }

/* ---- Typing cursor + dots ---- */
.typing-cursor::after {
  content: '▍';
  color: #15B5C7;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 8px 12px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  background: #15B5C7;
  border-radius: 999px;
  animation: pulse-dot 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse-dot {
  0%, 60%, 100% { transform: scale(0.6); opacity: 0.4; }
  30% { transform: scale(1); opacity: 1; }
}

/* ---- Animations: reveal on scroll ---- */
html.anim-on .anim-up { opacity: 0; transform: translateY(20px); transition: opacity 700ms cubic-bezier(0.16, 1, 0.3, 1), transform 700ms cubic-bezier(0.16, 1, 0.3, 1); }
html.anim-on .anim-up.is-visible { opacity: 1; transform: translateY(0); }
html.anim-on .anim-stagger > * { opacity: 0; transform: translateY(16px); transition: opacity 600ms cubic-bezier(0.16, 1, 0.3, 1), transform 600ms cubic-bezier(0.16, 1, 0.3, 1); }
html.anim-on .anim-stagger.is-visible > *:nth-child(1) { opacity: 1; transform: translateY(0); transition-delay: 0ms; }
html.anim-on .anim-stagger.is-visible > *:nth-child(2) { opacity: 1; transform: translateY(0); transition-delay: 80ms; }
html.anim-on .anim-stagger.is-visible > *:nth-child(3) { opacity: 1; transform: translateY(0); transition-delay: 160ms; }
html.anim-on .anim-stagger.is-visible > *:nth-child(4) { opacity: 1; transform: translateY(0); transition-delay: 240ms; }
html.anim-on .anim-stagger.is-visible > *:nth-child(5) { opacity: 1; transform: translateY(0); transition-delay: 320ms; }
html.anim-on .anim-stagger.is-visible > *:nth-child(6) { opacity: 1; transform: translateY(0); transition-delay: 400ms; }
html.anim-on .anim-stagger.is-visible > *:nth-child(n+7) { opacity: 1; transform: translateY(0); transition-delay: 480ms; }
html.anim-on .anim-fade { opacity: 0; transition: opacity 1000ms ease-out; }
html.anim-on .anim-fade.is-visible { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .anim-up, .anim-stagger > *, .anim-fade { transition: none !important; opacity: 1 !important; transform: none !important; }
  .typing-cursor::after { animation: none; }
  .typing-dots span { animation: none; opacity: 0.7; }
}

/* ---- Float ---- */
.float-slow { animation: float-slow 6s ease-in-out infinite; }
@keyframes float-slow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ---- Toast / notification ---- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0B1F35;
  color: #FFFFFF;
  padding: 14px 20px;
  border-radius: 12px;
  box-shadow: 0 20px 50px -20px rgba(11,31,53,0.4);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 300ms cubic-bezier(0.32, 0.72, 0, 1), transform 300ms cubic-bezier(0.32, 0.72, 0, 1);
  pointer-events: none;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast i { color: #15B5C7; font-size: 18px; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6,21,37,0.6);
  backdrop-filter: blur(4px);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms cubic-bezier(0.32, 0.72, 0, 1);
  display: grid;
  place-items: center;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal-card {
  background: #FFFFFF;
  border-radius: 16px;
  max-width: 480px;
  width: calc(100% - 48px);
  padding: 32px;
  transform: scale(0.95);
  transition: transform 250ms cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 30px 60px -20px rgba(11,31,53,0.4);
}
.modal-overlay.show .modal-card { transform: scale(1); }

/* ---- Stat counter ---- */
.stat-num {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.025em;
  line-height: 1;
}

/* ---- Hover lifts ---- */
.lift-on-hover { transition: all 300ms cubic-bezier(0.32, 0.72, 0, 1); }
.lift-on-hover:hover { transform: translateY(-2px); box-shadow: 0 1px 3px rgba(15,23,42,0.04), 0 20px 50px -20px rgba(11,31,53,0.18); }

/* ---- Phone frame ---- */
.phone-frame {
  border-radius: 44px;
  background: linear-gradient(145deg, #0B1F35, #061525);
  padding: 12px;
  box-shadow:
    0 30px 60px -20px rgba(0,0,0,0.6),
    0 0 0 1px rgba(255,255,255,0.05) inset,
    0 0 0 8px rgba(15,23,42,0.4) inset;
}
.phone-screen {
  border-radius: 34px;
  overflow: hidden;
  background: #FFFFFF;
  position: relative;
}

/* ---- Buttons (design system primitives) ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: #15B5C7;
  color: #061525;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  border: 0;
  transition: all 200ms cubic-bezier(0.32, 0.72, 0, 1);
}
.btn-primary:hover { background: #2DC4D5; }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: #0B1F35;
  color: #FFFFFF;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  border: 0;
  transition: all 200ms cubic-bezier(0.32, 0.72, 0, 1);
}
.btn-secondary:hover { background: #15324F; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #FFFFFF;
  color: #0F172A;
  border-radius: 8px;
  font-weight: 600;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid #E2E8F0;
  transition: all 200ms cubic-bezier(0.32, 0.72, 0, 1);
}
.btn-ghost:hover { background: #F0F4F8; }

/* ---- Project card on hover ---- */
.project-card {
  transition: all 250ms cubic-bezier(0.32, 0.72, 0, 1);
  cursor: pointer;
}
.project-card:hover {
  border-color: rgba(11,31,53,0.3);
  transform: translateY(-2px);
  box-shadow: 0 1px 3px rgba(15,23,42,0.04), 0 20px 50px -20px rgba(11,31,53,0.18);
}

/* ---- Demo banner ---- */
.demo-banner {
  background: linear-gradient(90deg, #061525 0%, #0B1F35 100%);
  color: #FFFFFF;
  padding: 8px 16px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.demo-banner a { color: #15B5C7; text-decoration: none; font-weight: 700; }
.demo-banner a:hover { color: #2DC4D5; }

/* ---- Personal Assistant nav CTA ---- */
.nav-assistant {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  background: linear-gradient(135deg, #15B5C7, #0E9DAE);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 8px 18px -8px rgba(14,157,174,0.45);
  transition: transform 200ms cubic-bezier(0.32, 0.72, 0, 1), box-shadow 200ms cubic-bezier(0.32, 0.72, 0, 1);
}
.nav-assistant:hover { transform: translateY(-1px); box-shadow: 0 12px 24px -8px rgba(14,157,174,0.55); }
.nav-assistant:active { transform: translateY(0); }
.nav-assistant i { font-size: 17px; }
.nav-assistant .na-dot {
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.28);
}
.nav-divider { height: 1px; background: #E8EDF2; margin: 12px 4px 6px; }

/* ==========================================================================
   Responsive layer — off-canvas sidebar + injected mobile chrome
   Injected top bar (.mobile-topbar) and .sidebar-scrim are created by app.js;
   they stay hidden on desktop and activate at <=1024px.
   ========================================================================== */
.mobile-topbar { display: none; }
.sidebar-scrim { display: none; }
.ih-short { display: none; }   /* short composer disclaimer — phones only */

@media (max-width: 1024px) {
  /* Collapse whatever grid shell directly holds the sidebar, regardless of its
     page-specific class name (.app-shell, .record-shell, .inv-shell, ...).
     overflow-x: clip is a safety net so a stray wide child can't scroll the page. */
  *:has(> .app-sidebar) { display: block !important; overflow-x: clip; }

  /* The "app" pages lock the viewport (html,body{overflow:hidden;height:100%}) and
     scroll internally. On a phone that clips any stacked content, so switch every
     page to natural document scroll and let the page grow with its content. */
  html, body { height: auto !important; min-height: 0 !important; overflow-x: clip !important; overflow-y: visible !important; }
  body { display: block !important; }

  /* Record pages (client/supplier detail): keep the tab bar on one line but let it
     swipe-scroll instead of forcing the whole page wider, and stop the content grid's
     1fr track from being blown out by min-content. */
  .record-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .record-tabs::-webkit-scrollbar { display: none; }
  .record-grid { grid-template-columns: minmax(0, 1fr) !important; }

  /* Project / workspace detail grids: stack to one column and let items shrink so
     their tab bars and chat rows don't blow the track out to desktop width. */
  .project-grid, .workspace-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .project-grid > *, .workspace-grid > * { min-width: 0; }
  .project-tabs, .doc-tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .project-tabs::-webkit-scrollbar, .doc-tabs::-webkit-scrollbar { display: none; }

  /* CRM "app" pages (crm/invoices/pipeline/campaigns) share these header classes.
     Their dense control rows are flex with space-between and would be clipped by the
     page's overflow:hidden — let them wrap, and let tab/KPI strips swipe-scroll. */
  .crm-topbar { flex-wrap: wrap; gap: 10px 12px; padding: 12px 16px !important; }
  .topbar-actions { flex-wrap: wrap; }
  .toolbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px !important; }
  .toolbar-search { width: 100% !important; }
  .ar-band, .stats-strip { flex-wrap: wrap; gap: 12px 18px; padding: 12px 16px !important; }
  .stats-group, .ar-kpis, .meta-group, .filter-actions { flex-wrap: wrap; }
  .ar-aging { min-width: 100% !important; max-width: 100% !important; }
  .filter-tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; max-width: 100%; }
  .filter-tabs::-webkit-scrollbar { display: none; }
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Raw tables not wrapped in a .table-scroll (e.g. campaigns recent-sends) become
     self-scrolling so their right-hand columns stay reachable. */
  .cmp-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }


  /* ===== Record groups (Module 05) — mobile =============================
     Joins the central 1024px pass rather than carrying its own breakpoint,
     per the pattern the rest of this file already sets. */

  /* The toolbar already wraps. The divider was drawn to separate two tab
     groups on one line; once they stack it separates nothing. */
  .grp-divider { display: none; }
  .grp-filter { flex: 1 1 auto; justify-content: space-between; }

  /* The consequence strip is the one line that states who can see these
     records — it keeps its full text and wraps rather than truncating. */
  .grp-note { padding: 9px 16px; align-items: flex-start; line-height: 1.45; }

  /* Bulk actions swipe-scroll instead of wrapping into a three-line wall that
     pushes the table off screen. "Clear" loses its margin-left:auto, which
     would otherwise strand it a screen-width away inside a scroller. */
  .bulk-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-left: 16px; padding-right: 16px;
  }
  .bulk-bar::-webkit-scrollbar { display: none; }
  .bulk-btn { flex: 0 0 auto; }
  .bulk-clear { margin-left: 12px; flex: 0 0 auto; }

  /* Manage groups: a near-full-height sheet, since a 520px card floating in a
     640px viewport wastes the room the list actually needs. */
  .gm-card { max-height: calc(100vh - 32px) !important; }
  .gm-head { padding: 18px 16px 0; }
  .gm-tools { flex-wrap: wrap; }
  .gm-search { flex: 1 1 100%; }
  .gm-newbtn { flex: 1 1 100%; justify-content: center; }
  .gm-foot { padding: 11px 16px; gap: 10px; }

  /* Row: name on its own line, counts beneath. Side by side at 360px the name
     truncates to two words and the counts become the loudest thing on screen. */
  /* Two lines, not three. `order` is load-bearing: the counts take the full
     width and sit BEFORE the ⋯ in the DOM, so without it the ⋯ wraps onto a
     third line and each row grows tall enough that only three groups fit. */
  .gm-item { flex-wrap: wrap; padding: 11px 16px; row-gap: 2px; }
  .gm-dot { order: 1; }
  .gm-nm { order: 2; flex: 1 1 auto; min-width: 0; }
  .gm-more { order: 3; }
  .gm-restore { order: 3; margin-left: auto; }
  .gm-ct { order: 4; flex: 1 1 100%; padding-left: 20px; }
  /* Touch has no hover, so the ⋯ that reveals Rename/Colour/Archive would be
     unreachable. It is always visible here — the trade the pointer version
     avoids only because hovering exists. */
  .gm-more { visibility: visible !important; }

  /* Popovers are positioned from getBoundingClientRect in JS; cap them so a
     menu opened near the right edge cannot push the document sideways. */
  .grp-menu { max-width: calc(100vw - 24px); }

  /* Users: the row is six columns wide; let it scroll rather than crush the
     Groups chips, and keep the locked-out banner readable. */
  .u-banner { margin: 14px 16px 0; align-items: flex-start; line-height: 1.45; }
  .u-head { padding: 20px 16px 0; }

  /* Personal Assistant chat: the column is overflow:hidden (a scrollport that defeats
     sticky), so on mobile we let it flow and pin the composer to the viewport bottom.
     position:sticky reserves its own space — no overlap, no padding hacks — and the
     input stays reachable without scrolling the whole conversation. */
  .assistant-main, .chat-col { overflow: visible !important; }
  .chat-input-area {
    position: sticky;
    bottom: 0;
    z-index: 30;
    background: #FFFFFF;
    border-top: 1px solid #E2E8F0;
    box-shadow: 0 -14px 30px -18px rgba(11,31,53,0.22);
  }
  /* Assistant header: its fixed 64px row can't hold the title + 3 actions on a phone,
     so let it grow and wrap — title on top, actions in a clean row beneath. */
  .assistant-topbar {
    height: auto !important;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px !important;
  }
  .assistant-topbar .topbar-actions { flex-wrap: wrap; }
  .assistant-topbar .topbar-btn { padding: 6px 11px; }
  .tg-label { display: none; }   /* Telegram view → icon-only on phones, keeps the action row to one line */

  /* Compact the composer so it doesn't dominate the small screen: tighter padding,
     shorter input box, smaller controls, and a single-line privacy note. */
  .chat-input-area { padding: 9px 14px 11px !important; }
  .chat-input-wrap { padding: 7px 9px !important; border-radius: 14px !important; }
  .chat-input-wrap textarea { min-height: 22px !important; padding: 3px 6px !important; font-size: 14px !important; }
  .chat-input-footer { padding-top: 2px !important; }
  .input-icon-btn { width: 30px !important; height: 30px !important; }
  .send-btn { width: 34px !important; height: 34px !important; }
  .input-helper { margin-top: 5px !important; font-size: 10.5px !important; line-height: 1.3; }
  .ih-full { display: none; }
  .ih-short { display: inline-flex; align-items: center; gap: 5px; }

  /* Sidebar becomes an off-canvas drawer (overrides page-level .X-shell .app-sidebar rules). */
  .app-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 280px !important;
    max-width: 84vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    transform: translateX(-100%);
    transition: transform 300ms cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 80 !important;
    box-shadow: 0 30px 70px -20px rgba(6,21,37,0.55);
    overflow-y: auto;
  }
  .app-sidebar.open { transform: translateX(0); }

  /* Secondary rails (projects / categories / context) become off-canvas drawers.
     JS injects a trigger into the mobile top bar and reuses the same scrim.
     overflow-x:clip on <body> hides them off-canvas and prevents a h-scrollbar. */
  [data-mobile-rail] {
    display: flex !important;          /* override the pages' "drop the rail below lg" rule */
    flex-direction: column;
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    width: 320px !important;
    max-width: 86vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 80 !important;
    overflow-y: auto !important;
    transition: transform 300ms cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 30px 70px -20px rgba(6,21,37,0.55);
  }
  [data-mobile-rail="left"]  { left: 0 !important; right: auto !important; transform: translateX(-100%); }
  [data-mobile-rail="right"] { right: 0 !important; left: auto !important; transform: translateX(100%); }
  [data-mobile-rail].rail-open { transform: translateX(0); }

  .mobile-rail-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
    border: 1px solid #E2E8F0; background: #FFFFFF; color: #0F172A;
    font-size: 19px; cursor: pointer;
    transition: background 150ms ease;
  }
  .mobile-rail-btn:active { background: #F0F4F8; }

  /* Scrim behind the drawer */
  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(6,21,37,0.5);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 70;
  }
  .sidebar-scrim.show { opacity: 1; pointer-events: auto; }

  /* Injected slim top bar */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 60;
    height: 54px;
    flex-shrink: 0;
    padding: 0 14px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid #E2E8F0;
  }
  .mobile-burger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px;
    border: 1px solid #E2E8F0; background: #FFFFFF; color: #0F172A;
    font-size: 20px; cursor: pointer; flex-shrink: 0;
    transition: background 150ms ease;
  }
  .mobile-burger:active { background: #F0F4F8; }
  .mobile-brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; margin-right: auto; }
  .mb-logo {
    width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #15B5C7, #0E9DAE);
    color: #FFFFFF; font-size: 11px; font-weight: 800;
  }
  .mb-name { font-size: 15px; font-weight: 800; color: #0B1F35; letter-spacing: -0.01em; }
  .mobile-assist {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
    background: linear-gradient(135deg, #15B5C7, #0E9DAE); color: #FFFFFF; font-size: 18px;
    text-decoration: none;
  }

  /* Pages with their own .app-topbar (dashboard, meeting-detail) already carry a
     burger + sticky header. The injected mobile bar now owns nav, so drop the
     in-page burger and stop the page header sticking under the mobile bar. */
  .app-topbar { position: static !important; }
  .app-topbar [data-sidebar-toggle] { display: none; }
}

/* ==========================================================================
   TEMPORARY — hide not-yet-released CRM modules from the sidebar nav.
   To restore, delete this single block. (Sidebar-scoped, so it also covers the
   mobile drawer; the pages themselves remain reachable by direct URL.)
   ========================================================================== */
/* Invoices & AR is back: it now shows the read-only Xero copy (payment bot, 2026-09-28). */
.app-sidebar a[href="pipeline.html"],
.app-sidebar a[href="campaigns.html"] { display: none !important; }
