/* Shared operational layout. Semantic colors, tables and all actions retained. */
:root{--e6-space:16px;--e6-control:40px;--e6-touch:44px;--e6-line:#d5dfeb;--e6-surface:#fff;--e6-muted:#51667e}
body:is(.portal-active,.portal-invoices) #portal-shell .p-top{min-height:60px;padding-block:8px}
body:is(.portal-active,.portal-invoices) #portal-shell .p-nav-horizontal{padding-block:4px 8px;gap:8px}
body:is(.portal-active,.portal-invoices) #portal-shell .p-subnav{display:flex;flex-wrap:wrap;align-items:stretch;gap:6px;grid-auto-rows:auto;padding:8px 24px;min-height:0}
body:is(.portal-active,.portal-invoices) #portal-shell .p-subnav>button{width:auto;max-width:none;height:auto;max-height:none;min-width:0;min-height:44px;flex:0 1 auto;padding:8px 12px;border-radius:8px;gap:3px;text-align:left}
body:is(.portal-active,.portal-invoices) #portal-shell .p-subnav>button>strong{font-size:13px;line-height:1.4;white-space:normal;overflow:visible}
body:is(.portal-active,.portal-invoices) #portal-shell .p-subnav>button>small{display:none}
body:is(.portal-active,.portal-invoices) #portal-shell .p-subnav>button:focus-visible{outline:2px solid #8196b1;outline-offset:2px}
/* The rail occupies 44px; reserve a real gutter instead of painting over text. */
@media(min-width:761px){
 body.portal-active>main,body.portal-active:has(.p-context)>main{padding-left:68px!important;padding-right:24px}
 body.portal-invoices:has(.cmp-section-rail:not([hidden]))>main{padding-left:68px!important}
 body:is(.portal-active,.portal-invoices) .cmp-section-rail{max-height:calc(100dvh - 160px);overflow:visible}
}
/* Mobile: one labeled, 44px control, anchored away from reading and forms. */
@media(max-width:760px){
 body:is(.portal-active,.portal-invoices) #portal-shell .p-nav-horizontal{display:flex;flex-wrap:nowrap;overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:thin;padding:4px 12px 8px}
 body:is(.portal-active,.portal-invoices) #portal-shell .p-nav-horizontal>button{flex:0 0 auto;width:auto;max-width:none;min-width:100px;min-height:44px;padding:8px 12px}
 body:is(.portal-active,.portal-invoices) #portal-shell .p-subnav{display:flex;flex-wrap:nowrap;overflow-x:auto;overscroll-behavior-x:contain;padding:8px 12px;scrollbar-width:thin}
 body:is(.portal-active,.portal-invoices) #portal-shell .p-subnav>button{flex:0 0 auto;min-height:44px;max-width:240px}
 body:is(.portal-active,.portal-invoices) .cmp-section-rail{left:12px;top:auto;bottom:20px;transform:none;max-width:calc(100vw - 24px);z-index:55}
 body:is(.portal-active,.portal-invoices) .cmp-rail-toggle{display:block;box-sizing:border-box;width:44px;height:44px;min-height:44px;min-width:44px;border:1px solid #c5d0de;border-radius:10px;background:#0a2547!important;color:#fff;font-size:20px;box-shadow:0 3px 12px #0a25471a}
 body:is(.portal-active,.portal-invoices) .cmp-section-rail .cmp-rail-links{display:none}
 body:is(.portal-active,.portal-invoices) .cmp-section-rail.is-open .cmp-rail-links{display:flex;position:absolute;left:0;top:auto;bottom:52px;max-height:min(60dvh,420px);overflow:auto;padding:6px;border-radius:10px;background:#fff;border:1px solid #c5d0de;box-shadow:0 6px 24px #0a25471a}
 body:is(.portal-active,.portal-invoices) .cmp-section-rail.is-open .cmp-section-link{width:min(260px,calc(100vw - 52px));height:auto;min-height:48px}
 body:is(.portal-active,.portal-invoices) .cmp-section-rail .cmp-section-link::before{left:0;border-radius:7px;clip-path:none}
 body:is(.portal-active,.portal-invoices) .cmp-section-rail.is-open .cmp-rail-label{opacity:1}
 body.portal-active>main{padding-bottom:84px}
 body:is(.portal-active,.portal-invoices) :is(.p-toolbar,.rc-tools,.kw-sheet-controls){max-width:100%;min-width:0;flex-wrap:wrap}
 body:is(.portal-active,.portal-invoices) :is(.p-toolbar,.rc-tools,.kw-sheet-controls)>*{max-width:100%;min-width:0}
 body:is(.portal-active,.portal-invoices) :is(.p-toolbar,.rc-tools,.kw-sheet-controls) :is(button,input,select){min-height:44px}
 body:is(.portal-active,.portal-invoices) :is(input,select,textarea){font-size:16px}
}
@media(max-width:480px){
 body:is(.portal-active,.portal-invoices) .p-toolbar>label{flex:1 1 100%;width:100%;max-width:100%;min-width:0}
 body:is(.portal-active,.portal-invoices) .p-toolbar>label>:is(input,select){width:100%;min-width:0;max-width:100%}
}
/* Homepage: shorter greeting, metrics first, distinct but lighter shortcuts. */
body.portal-active #module-home .p-hero{min-height:0;padding:18px 20px;background:#f7fafc;box-shadow:none}
body.portal-active #module-home .p-hero h2{font-size:24px;line-height:1.35;margin:0 0 6px;max-width:none}
body.portal-active #module-home .p-hero p{margin:0;max-width:none;background:transparent}
body.portal-active #module-home .e6-shortcuts-heading{font-size:16px;line-height:1.4;margin:24px 0 10px}
body.portal-active #module-home .p-shortcuts{grid-template-columns:repeat(auto-fit,minmax(min(100%,225px),1fr));gap:10px}
body.portal-active #module-home .p-shortcut{min-height:84px;padding:14px;background:#fff;box-shadow:none;border:1px solid var(--e6-line)}
body.portal-active #module-home .p-shortcut:hover{border-color:#8196b1;box-shadow:0 2px 8px #0a25470a;transform:none}
body.portal-active #module-home .p-shortcut>strong{font-size:14px}
body.portal-active #module-home .p-shortcut>p{font-size:12px;color:var(--e6-muted)}
body.portal-active #module-home .p-shortcut .p-icon{width:32px;height:32px}
/* Shared headings and readable control rhythm; never style data-cell colors. */
body:is(.portal-active,.portal-invoices) :is(#module-kw,#module-home,#module-reporting,#module-sources,#module-planning,#module-analytics,#module-reports)>.p-heading.cmp-heading{padding:12px 0!important;background:transparent;border-color:transparent;box-shadow:none}
body:is(.portal-active,.portal-invoices) .cmp-heading-line{min-height:40px}
body:is(.portal-active,.portal-invoices) .cmp-heading-more>summary{min-height:40px;display:flex;align-items:center}
body:is(.portal-active,.portal-invoices) :is(.p-table-wrap,.r-table,.kw-day-scroll){overscroll-behavior-x:contain;scrollbar-gutter:stable}
body:is(.portal-active,.portal-invoices) :is(.p-error,.r-error,[role=alert]){overflow-wrap:anywhere}
@media(prefers-reduced-motion:reduce){body:is(.portal-active,.portal-invoices) #portal-shell *,body.portal-active #module-home .p-shortcut{scroll-behavior:auto;transition:none!important;animation:none!important}}
