/* CAMCUDA Sidebar & AppShell Unified Styles v2
 * Shared identically by crm-host and noncrm-host to eliminate split-bundle layout/color jitter.
 */
.rc-shell-root {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  background: #f4f5f7;
}

.rc-shell-aside {
  display: none;
  height: 100%;
  width: 212px;
  flex-shrink: 0;
  border-right: 1px solid #e2e8f0;
  background: #ffffff;
  transition: width 160ms cubic-bezier(0.2, 0, 0, 1);
  overflow: hidden;
  z-index: 35;
}

.rc-shell-aside.is-rail {
  width: 58px;
  overflow: visible;
}

@media (min-width: 1024px) {
  .rc-shell-aside {
    display: flex;
    flex-direction: column;
  }
}

/* Sticky top brand header + collapse toggle */
.rc-sb-nav {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  width: 100%;
  background: #ffffff;
  user-select: none;
}

.rc-sb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  height: 48px;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.rc-sb-brand-wrap {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.rc-sb-rail-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 120ms, color 120ms;
}

.rc-sb-rail-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

/* Scrollable body (quiet scrollbar hidden at rest so right-side badges stay airy) */
.rc-sb-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 10px 10px 16px;
  scrollbar-width: none;
}

.rc-sb-scroll:hover {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.rc-sb-scroll::-webkit-scrollbar {
  width: 0;
}

.rc-sb-scroll:hover::-webkit-scrollbar {
  width: 4px;
}

.rc-sb-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

/* Pinned top AI shortcut */
.rc-sb-pinned {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
}

/* Sections */
.rc-sb-section.is-secondary {
  margin-top: 2px;
}

.rc-sb-section.is-primary + .rc-sb-section.is-secondary {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}

.rc-sb-sec-primary {
  margin: 0 0 4px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.04em;
}

.rc-sb-sec-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 30px;
  padding: 0 10px;
  margin-bottom: 1px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background-color 120ms, color 120ms;
}

.rc-sb-sec-btn:hover {
  background: #f8fafc;
  color: #0f172a;
}

.rc-sb-sec-btn[aria-expanded="true"] {
  color: #0f172a;
  margin-bottom: 3px;
}

.rc-sb-sec-btn.has-active-child[aria-expanded="false"] {
  background: #eff6ff;
  color: #1d4ed8;
}

.rc-sb-sec-right {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.rc-sb-sec-count {
  font-size: 11px;
  font-weight: 500;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
  line-height: 16px;
}

.rc-sb-sec-caret {
  color: #94a3b8;
  opacity: 0.65;
  transition: opacity 120ms ease, color 120ms ease, transform 120ms ease;
}

.rc-sb-sec-btn[aria-expanded="true"] .rc-sb-sec-caret {
  opacity: 0;
}

.rc-sb-sec-btn:hover .rc-sb-sec-caret {
  opacity: 0.9;
  color: #475569;
}

.rc-sb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rc-sb-list[hidden] {
  display: none !important;
}

/* Nav item link */
.rc-sb-item-li {
  position: relative;
}

.rc-sb-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  color: #334155;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.25;
  text-decoration: none;
  transition: background-color 120ms, color 120ms;
}

.rc-sb-link:hover {
  background: #f8fafc;
  color: #0f172a;
}

.rc-sb-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: #64748b;
  transition: color 120ms;
}

.rc-sb-link:hover svg {
  color: #1e293b;
}

.rc-sb-link.is-active,
.rc-sb-link[aria-current="page"] {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

.rc-sb-link.is-active::before,
.rc-sb-link[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #2563eb;
}

.rc-sb-link.is-active svg,
.rc-sb-link[aria-current="page"] svg {
  color: #2563eb;
}

/* De-box open parent item when inline child tree is expanded right underneath */
.rc-sb-item-li.is-open-tree > .rc-sb-link.is-active,
.rc-sb-item-li.is-open-tree > .rc-sb-link[aria-current="page"] {
  background: transparent;
  color: #0f172a;
  font-weight: 600;
}

.rc-sb-item-li.is-open-tree > .rc-sb-link.is-active:hover,
.rc-sb-item-li.is-open-tree > .rc-sb-link[aria-current="page"]:hover {
  background: #f8fafc;
}

.rc-sb-item-li.is-open-tree > .rc-sb-link.is-active::before,
.rc-sb-item-li.is-open-tree > .rc-sb-link[aria-current="page"]::before {
  display: none;
}

.rc-sb-open-caret {
  width: 13px !important;
  height: 13px !important;
  color: #94a3b8 !important;
  flex-shrink: 0;
}

.rc-sb-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rc-sb-badge {
  flex-shrink: 0;
  border-radius: 999px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  line-height: 17px;
  background: #fee2e2;
  color: #dc2626;
  font-variant-numeric: tabular-nums;
}

.rc-sb-link.is-active .rc-sb-badge {
  background: #dbeafe;
  color: #1d4ed8;
}

/* Narrow Icon-Rail Mode (58px desktop) */
.rc-sb-nav.is-rail .rc-sb-head {
  justify-content: center;
  padding: 0 6px;
}

.rc-sb-nav.is-rail .rc-sb-brand-wrap {
  display: none;
}

.rc-sb-nav.is-rail .rc-sb-scroll {
  padding: 8px 7px 14px;
}

.rc-sb-nav.is-rail .rc-sb-section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #f1f3f5;
}

.rc-sb-nav.is-rail .rc-sb-section:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.rc-sb-nav.is-rail .rc-sb-sec-btn,
.rc-sb-nav.is-rail .rc-sb-sec-primary {
  display: none;
}

.rc-sb-nav.is-rail .rc-sb-list[hidden] {
  display: flex !important;
}

.rc-sb-nav.is-rail .rc-sb-link {
  justify-content: center;
  padding: 0;
  height: 36px;
  width: 42px;
  margin: 0 auto;
  border-radius: 8px;
}

.rc-sb-nav.is-rail .rc-sb-label,
.rc-sb-nav.is-rail .rc-sb-badge,
.rc-sb-nav.is-rail .rc-sb-open-caret {
  display: none;
}

.rc-sb-nav.is-rail .rc-sb-link.has-badge::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 7px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #dc2626;
}

/* Fixed viewport tooltip for narrow icon-rail (never clipped by scroll container) */
.rc-sb-tooltip {
  position: fixed;
  z-index: 9999;
  transform: translateY(-50%);
  background: #0f172a;
  color: #f8fafc;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  padding: 5px 10px;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.22);
  pointer-events: none;
  white-space: nowrap;
}

.rc-sb-tooltip-sec {
  color: #94a3b8;
  margin-right: 5px;
  font-size: 11px;
}

/* Touch / Mobile Drawer adjustments */
@media (max-width: 1023px), (pointer: coarse) {
  .rc-sb-rail-btn {
    display: none;
  }
  .rc-sb-link {
    height: 36px;
  }
}

/* Scheme 3: Single-Sidebar Accordion Subtree & Narrow-Rail Flyout */
.rc-sb-sec-static {
  margin: 0 0 3px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.04em;
}

.rc-sb-sublist {
  list-style: none;
  margin: 2px 0 6px 18px;
  padding: 2px 0 2px 10px;
  border-left: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rc-sb-subitem {
  margin: 0;
  padding: 0;
}

.rc-sb-sublink {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #475569;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.rc-sb-sublink:hover {
  background: #f8fafc;
  color: #0f172a;
}

.rc-sb-sublink.is-active {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

.rc-sb-sublink.is-active::before {
  content: "";
  position: absolute;
  left: -11px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
  background: #2563eb;
}

.rc-sb-sublabel {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rc-sb-subcnt {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 500;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

.rc-sb-sublink.is-active .rc-sb-subcnt {
  color: #2563eb;
  font-weight: 600;
}

.rc-sb-subcnt.urg {
  background: #fee2e2;
  color: #dc2626 !important;
  font-weight: 600;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10.5px;
  line-height: 17px;
}

.rc-sb-subcnt.new {
  background: #dcfce7;
  color: #15803d !important;
  font-weight: 600;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10.5px;
  line-height: 17px;
}

.rc-sb-subcnt.doc {
  background: #e0f2fe;
  color: #0369a1 !important;
  font-weight: 600;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10.5px;
  line-height: 17px;
}

.rc-sb-sub-caret {
  width: 13px !important;
  height: 13px !important;
  flex-shrink: 0;
  color: #94a3b8 !important;
  opacity: 0;
  transform: translateX(-2px);
  transition: opacity 0.14s ease, transform 0.14s ease, color 0.14s ease;
}

.rc-sb-link:hover .rc-sb-sub-caret {
  color: #2563eb !important;
  opacity: 0.85;
  transform: translateX(0);
}

.rc-sb-nav.is-rail .rc-sb-sub-caret,
.rc-sb-nav.is-rail .rc-sb-sublist,
.rc-sb-nav.is-rail .rc-sb-sec-static {
  display: none !important;
}

.rc-sb-flyout {
  position: fixed;
  z-index: 9999;
  min-width: 188px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Invisible hover bridge so moving diagonally from sidebar into flyout never drops hover */
.rc-sb-flyout::before {
  content: "";
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: -14px;
  width: 16px;
}

.rc-sb-flyout-hd {
  padding: 5px 8px 6px;
  margin-bottom: 2px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 11.5px;
  font-weight: 600;
  color: #64748b;
}

.rc-sb-flyout-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #334155;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background-color 120ms ease, color 120ms ease;
}

.rc-sb-flyout-item:hover {
  background: #f8fafc;
  color: #0f172a;
}

.rc-sb-flyout-item.is-active {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

.rc-sb-flyout-item b {
  font-size: 11px;
  font-weight: 500;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
  padding: 0 5px;
  border-radius: 999px;
}

.rc-sb-flyout-item b.tone-urg {
  background: #fee2e2;
  color: #dc2626;
  font-weight: 600;
}

.rc-sb-flyout-item b.tone-new {
  background: #dcfce7;
  color: #15803d;
  font-weight: 600;
}

.rc-sb-flyout-item b.tone-doc {
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 600;
}

/* Hide redundant topbar subnav buttons on /orders since they live in Scheme-3 sidebar subtree */
.rc-ord-ws .rc-ord-btn-subnav {
  display: none !important;
}

/* Hide outer shell topbar on desktop for self-header workspace routes (/orders, /pi, /products) */
@media (min-width: 1024px) {
  header.rc-self-header-route {
    display: none !important;
  }
}

/* 1) Full-bleed inner-scrolling workspaces (/messages, /crm/*, /products, /ai) */
main.rc-main-locked {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 0% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}
main.rc-main-locked > .crm-v19-shell {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 0% !important;
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}
.cv6-root {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 0% !important;
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}
.cv6-scroll {
  flex: 1 1 0% !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.pdb-root {
  flex: 1 1 0% !important;
  height: 100% !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

/* 2) Outer-scrolling pages (/ai/settings, /orders/*, /pi, /growth/*, /access, /system/*, etc.) */
main.rc-main-scroll {
  display: block !important;
  flex: 1 1 0% !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
main.rc-main-scroll.rc-main-bleed {
  padding: 0 !important;
}
main.rc-main-scroll > .crm-v19-shell,
main.rc-main-scroll > div:has(> .rc-ai-ws) {
  display: block !important;
  height: auto !important;
  min-height: 100% !important;
  overflow: visible !important;
}

/* 3) Mobile (<= 768px) Full-Page Scroll Unification for Multi-Toolbar Workspaces (/finance/*) */
@media (max-width: 768px) {
  main.rc-shell-main:has(.fh-root) {
    display: block !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  main.rc-shell-main:has(.fh-root) > .crm-v19-shell {
    display: block !important;
    height: auto !important;
    min-height: 100% !important;
    overflow: visible !important;
  }
  .fh-root {
    height: auto !important;
    min-height: 100% !important;
    overflow: visible !important;
  }
  .fh-body {
    flex: none !important;
    height: auto !important;
    max-height: none !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
  }
}

/* 4) Runtime Scroll Integrity Guard Rescue Classes (Zero-Deadlock Guarantee) */
main.rc-scroll-rescued {
  display: block !important;
  flex: 1 1 0% !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch !important;
}
.rc-scroll-rescue-pass {
  height: auto !important;
  max-height: none !important;
  min-height: 0 !important;
  overflow: visible !important;
}
