/* Primary role-aware navigation. Content filter tabs remain in their own pages. */
#workspace{--crm-sidebar-width:246px;--crm-header-height:92px;--sidebar-accent:#237c67;--sidebar-active:#e7f3ee}
#workspace[hidden],#crm-sidebar[hidden],#sidebar-backdrop[hidden],#sidebar-close[hidden]{display:none!important}
body:not(.portal-page) #workspace>.masthead{position:sticky;top:0;z-index:40}
body:not(.portal-page) #workspace>.masthead:before{background:linear-gradient(90deg,transparent 2%,#1b8d77 30%,#64d7c5 50%,#1b8d77 70%,transparent 98%)}
body:not(.portal-page) #workspace .topline{max-width:none;padding-inline:24px;gap:24px}
#workspace .sidebar-toggle{display:flex;align-items:center;justify-content:center;gap:9px;flex:none;min-width:44px;height:44px;padding:0 12px;border:1px solid #ffffff24;border-radius:10px;background:#ffffff08;color:#d9ede5;font-size:12px;font-weight:500}
#workspace .sidebar-toggle:hover{background:#ffffff14;border-color:#64d7c566}
#workspace .sidebar-toggle svg,#workspace .sidebar-close svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
#workspace .crm-layout{display:grid;grid-template-columns:var(--crm-sidebar-width) minmax(0,1fr);align-items:start;min-height:calc(100dvh - var(--crm-header-height))}
#workspace.sidebar-collapsed .crm-layout{grid-template-columns:minmax(0,1fr)}
#workspace .crm-sidebar{position:sticky;top:var(--crm-header-height);display:flex;flex-direction:column;height:calc(100dvh - var(--crm-header-height));min-height:300px;background:var(--surface);border-right:1px solid var(--line);min-width:0;overflow:hidden}
#workspace .sidebar-heading{padding:29px 22px 20px;display:flex;align-items:center;justify-content:space-between;gap:10px;flex:none}
#workspace .sidebar-eyebrow{font-size:9px;font-weight:700;letter-spacing:1.8px;color:var(--sidebar-accent)}
#workspace .sidebar-heading h2{font-size:12px;letter-spacing:0;font-weight:500;color:var(--text-secondary);margin:7px 0 0}
#workspace .sidebar-close{width:40px;height:40px;padding:10px;border-radius:9px;border:1px solid var(--line);background:var(--surface);color:var(--text-secondary);flex:none}
body:not(.portal-page) #workspace .crm-sidebar .nav-wrap{position:static;display:block;flex:1;min-height:0;height:auto;max-width:none;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;padding:4px 12px 20px;border:0;box-shadow:none;background:transparent;scrollbar-width:thin;scroll-padding-block:12px}
body:not(.portal-page) #workspace #nav{display:flex;flex-direction:column;align-items:stretch;gap:5px;min-width:0;width:100%;overflow:visible}
body:not(.portal-page) #workspace #nav button{display:flex;justify-content:flex-start;gap:11px;width:100%;min-height:45px;padding:11px 13px;text-align:left;border:1px solid transparent;border-radius:9px;white-space:normal;font-size:12px;font-weight:500;line-height:1.5;color:var(--text-secondary)}
body:not(.portal-page) #workspace #nav button:hover{background:var(--surface-muted);color:var(--text)}
body:not(.portal-page) #workspace #nav button.active{background:var(--sidebar-active);border-color:#237c671a;color:var(--sidebar-accent)}
body:not(.portal-page) #workspace #nav svg{display:block;width:18px;height:18px;flex:none;stroke-width:1.6}
body:not(.portal-page) #workspace #nav .nav-count{margin-left:auto;flex:none;font-size:10px;padding:1px 6px;border-radius:5px}
body:not(.portal-page) #workspace #nav button.active .nav-count{background:var(--sidebar-accent);color:#fff}
#workspace .sidebar-foot{padding:20px 23px 24px;border-top:1px solid var(--line);display:grid;gap:8px;flex:none}
body:not(.portal-page) #workspace .sidebar-foot .role-chip{display:flex;align-self:auto;margin:0;font-size:10px;letter-spacing:0;color:var(--text-secondary)}
body:not(.portal-page) #workspace .sidebar-foot .role-chip i{background:var(--sidebar-accent);box-shadow:0 0 0 3px var(--sidebar-active)}
#workspace .sidebar-foot>span:last-child{font-size:10px;color:var(--text-muted);line-height:1.6}
#workspace .crm-content{min-width:0;width:100%}
body:not(.portal-page) #workspace #main{max-width:1640px;width:100%;min-height:calc(100dvh - var(--crm-header-height) - 84px);margin-inline:auto;padding:32px 34px 36px}
body:not(.portal-page) #workspace .app-footer{max-width:none;width:100%;margin:0;padding:18px 34px 24px}
#workspace .local-preview-inner{max-width:none;padding-inline:34px}
#workspace .sidebar-backdrop{position:fixed;inset:0;background:#0a242360;backdrop-filter:blur(2px);z-index:80}
:root[data-theme=dark] #workspace{--sidebar-accent:#80d6bd;--sidebar-active:#1c3932}
:root[data-theme=dark] #workspace #nav button.active{border-color:#80d6bd25}
#workspace .sidebar-toggle:focus-visible,#workspace .sidebar-close:focus-visible,#workspace #nav button:focus-visible{outline:3px solid #59bda0;outline-offset:2px}
@media(min-width:961px) and (max-width:1270px){
  #workspace{--crm-sidebar-width:224px}
  body:not(.portal-page) #workspace .topline{gap:18px}
  #workspace .sidebar-toggle span{display:none}
  body:not(.portal-page) #workspace .brand>span{display:none}
  body:not(.portal-page) #workspace #main{padding-inline:26px}
  #workspace .local-preview-inner{padding-inline:26px}
  body:not(.portal-page) #workspace .app-footer{padding-inline:26px}
  #workspace:not(.sidebar-collapsed) #main>.workspace{grid-template-columns:minmax(0,1fr)}
}
@media(max-width:960px){
  #workspace .crm-layout{display:block}
  #workspace .crm-sidebar{position:fixed;inset:0 auto 0 0;top:0;width:min(300px,calc(100vw - 48px));height:100dvh;min-height:0;z-index:81;border-right:0;box-shadow:20px 0 70px #082e3a30}
  #workspace .sidebar-heading{padding-top:max(24px,env(safe-area-inset-top));padding-bottom:24px}
  #workspace .sidebar-foot{padding-bottom:max(24px,env(safe-area-inset-bottom))}
  #workspace .sidebar-toggle span{display:none}
  body:not(.portal-page) #workspace .topline{gap:16px}
  body:not(.portal-page) #workspace .brand>span{display:none}
  body:not(.portal-page) #workspace #nav button{min-height:48px;font-size:13px}
  #workspace .crm-sidebar:not([hidden]){animation:meridian-sidebar-in .16s ease-out}
}
@media(max-width:600px){
  body:not(.portal-page) #workspace .topline{display:grid;grid-template-columns:44px minmax(0,1fr) auto;gap:12px 10px;padding-inline:16px}
  #workspace .sidebar-toggle{grid-column:1;grid-row:1;padding:0}
  body:not(.portal-page) #workspace .brand{grid-column:2;grid-row:1;min-width:0}
  body:not(.portal-page) #workspace .brand img{width:128px;max-width:100%;height:36px}
  body:not(.portal-page) #workspace .top-actions{grid-column:3;grid-row:1;gap:8px}
  body:not(.portal-page) #workspace .global-search{grid-column:1/-1;grid-row:2}
  body:not(.portal-page) #workspace .masthead .theme-toggle{width:38px;height:38px;border-radius:10px}
  body:not(.portal-page) #workspace #main{padding:24px 16px 28px}
  #workspace .local-preview-inner{padding-inline:16px}
  body:not(.portal-page) #workspace .app-footer{padding:18px 16px max(24px,env(safe-area-inset-bottom))}
}
@media(max-width:380px){body:not(.portal-page) #workspace .masthead .theme-toggle{display:none}}
@keyframes meridian-sidebar-in{from{transform:translateX(-100%)}to{transform:translateX(0)}}
@media(prefers-reduced-motion:reduce){#workspace .crm-sidebar:not([hidden]){animation:none}}
