/* Calendar budget includes the actual page header/filter height. */
@media (min-width:901px) {
 #pertihub-root .ph-calendar-fit-shell .ph-calendar-layout { grid-template-columns:minmax(0,1fr) 220px!important;gap:8px!important; }
 #pertihub-root .ph-calendar-fit-shell .ph-calendar-main { padding:8px!important; }
 #pertihub-root .ph-calendar-fit-shell .ph-cal-month-title { min-height:36px!important;padding:0 0 6px!important;font-size:23px!important; }
 #pertihub-root .ph-calendar-fit-shell .ph-calendar-week b { min-height:28px!important; }
 #pertihub-root .ph-calendar-fit-shell .ph-calendar-grid { height:var(--cal-grid-height,440px)!important;grid-template-rows:repeat(var(--cal-weeks,6),minmax(0,1fr))!important;grid-auto-rows:auto!important; }
 #pertihub-root .ph-calendar-fit-shell .ph-calendar-grid .ph-cal-cell { min-height:0!important;height:100%!important;aspect-ratio:auto!important;padding:6px!important; }
 #pertihub-root .ph-calendar-fit-shell .ph-calendar-grid .ph-cal-cell .ph-cal-num { margin-bottom:3px!important; }
 #pertihub-root .ph-calendar-fit-shell .ph-calendar-grid .ph-cal-cell .ph-cal-num b { font-size:22px!important; }
 #pertihub-root .ph-calendar-fit-shell .ph-calendar-grid .ph-cal-holiday,
 #pertihub-root .ph-calendar-fit-shell .ph-calendar-grid .ph-cal-leave,
 #pertihub-root .ph-calendar-fit-shell .ph-calendar-grid .ph-cal-more { font-size:9px!important;line-height:1.1!important;min-height:0!important;padding:1px 3px!important;margin-top:1px!important; }
 #pertihub-root .ph-calendar-fit-shell .ph-calendar-side { display:flex!important;flex-direction:column!important;gap:7px!important;max-height:var(--cal-panel-height,600px)!important;height:var(--cal-panel-height,600px)!important;overflow:auto!important; }
 #pertihub-root .ph-calendar-fit-shell .ph-cal-side-card { min-height:0!important;flex:0 0 auto!important;padding:8px!important; }
 #pertihub-root .ph-calendar-fit-shell .ph-cal-side-card:nth-child(2) { flex:1 1 auto!important;overflow:auto!important; }
 #pertihub-root .ph-calendar-fit-shell .ph-cal-side-scroll { max-height:160px!important;overflow:auto!important; }
 #pertihub-root .ph-calendar-fit-shell .ph-cal-side-scroll.leaves { max-height:none!important;min-height:0!important; }
}
#pertihub-root:has(.ph-chat-layout) .ph-topbar { position:sticky!important;top:0!important;z-index:20!important; }
#pertihub-root .ph-chat-layout { height:var(--chat-height,calc(100dvh - 110px))!important;min-height:0!important;max-height:none!important;overflow:hidden!important;grid-template-columns:220px minmax(0,1fr)!important; }
#pertihub-root .ph-chat-main { display:flex!important;flex-direction:column!important;height:100%!important;min-height:0!important;overflow:hidden!important; }
#pertihub-root .ph-chat-head { flex:0 0 62px!important;position:sticky!important;top:0!important;z-index:4!important;background:#fff!important; }
#pertihub-root .ph-chat-feed { flex:1 1 0!important;height:auto!important;min-height:0!important;overflow-y:auto!important;overscroll-behavior:contain; }
#pertihub-root .ph-chat-form { position:sticky!important;bottom:0!important;flex:0 0 auto!important;z-index:4!important; }
#pertihub-root .ph-chat-rooms { min-height:0;overflow:auto; }
#pertihub-root .ph-chat-images .ph-chat-photo { display:block;max-width:100%;padding:0;border:0;background:transparent;cursor:zoom-in; }
#pertihub-root .ph-chat-images .ph-chat-photo img { display:block;width:180px;height:140px;max-height:140px;object-fit:contain;background:#edf2f7;border-radius:10px; }
#pertihub-root .ph-chat-photo .ph-chat-photo-error { display:block;width:180px;max-width:100%;padding:16px;background:#edf2f7;border-radius:10px;font-size:12px;color:#475569; }
#pertihub-root .ph-chat-photo .ph-chat-photo-error[hidden] { display:none; }
@media(max-width:720px){
 #pertihub-root .ph-chat-layout { grid-template-columns:minmax(0,1fr)!important;grid-template-rows:auto minmax(0,1fr)!important; }
 #pertihub-root .ph-chat-rooms { display:flex;gap:5px;padding:7px;max-height:54px;overflow:auto; }
 #pertihub-root .ph-chat-side-head { display:none; }
 #pertihub-root .ph-room { width:auto;flex:0 0 auto;padding:8px; }
 #pertihub-root .ph-room small { display:none; }
 #pertihub-root .ph-chat-form { grid-template-columns:36px minmax(0,1fr) 64px!important;padding:8px;gap:5px; }
 #pertihub-root .ph-chat-form button { grid-column:auto!important; }
 #pertihub-root .ph-bubble { max-width:95%; }
}
.ph-chat-viewer { position:fixed;inset:0;width:100vw;height:100dvh;max-width:none;max-height:none;margin:0;padding:0;border:0;background:#080d16;color:#fff;overflow:hidden; }
.ph-chat-viewer::backdrop { background:#080d16; }
.ph-chat-viewer[open] { display:flex;flex-direction:column; }
.ph-chat-viewer-bar { flex:0 0 auto;display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:10px 14px;background:#111b2b;z-index:2; }
.ph-chat-viewer-bar strong { margin-right:auto;font:600 14px system-ui; }
.ph-chat-viewer-bar button,.ph-chat-viewer-bar a { border:1px solid #435168;border-radius:7px;padding:8px 12px;background:#1e293b;color:white;text-decoration:none;font:500 14px system-ui;cursor:pointer; }
.ph-chat-viewer-stage { position:relative;flex:1;min-height:0;overflow:hidden;touch-action:none;cursor:grab; }
.ph-chat-viewer-stage:active { cursor:grabbing; }
.ph-chat-viewer-stage img { position:absolute;left:50%;top:50%;max-width:none!important;max-height:none!important;object-fit:contain;transform-origin:center;user-select:none; }
.ph-chat-viewer-note { position:absolute;bottom:16px;left:16px;right:16px;text-align:center;font:13px system-ui;color:#cbd5e1;pointer-events:none; }

@media(min-width:721px){
 #pertihub-root .ph-chat-rooms { display:block!important; }
 #pertihub-root .ph-chat-rooms .ph-room { display:flex!important;align-items:center;gap:8px;width:100%!important;flex:none!important; }
 #pertihub-root .ph-chat-rooms .ph-room b { flex:1;text-align:left; }
 #pertihub-root .ph-chat-rooms .ph-room small { flex:0 0 auto; }
}

/* v701 calendar: every leave/holiday card participates in document scrolling. */
#pertihub-root .ph-calendar-fit-shell .ph-calendar-side,
#pertihub-root .ph-calendar-fit-shell .ph-cal-side-card,
#pertihub-root .ph-calendar-fit-shell .ph-cal-side-card:nth-child(2),
#pertihub-root .ph-calendar-fit-shell .ph-cal-side-scroll,
#pertihub-root .ph-calendar-fit-shell .ph-cal-side-scroll.leaves {
 height:auto!important;max-height:none!important;min-height:0!important;
 overflow:visible!important;flex:0 0 auto!important;
}
/* Chat is a viewport workspace. Message feed and left navigation each scroll independently. */
html.ph-chat-viewport,body.ph-chat-viewport { overflow:hidden!important;overscroll-behavior:none; }
#pertihub-root:has(.ph-chat-layout) { min-height:0!important; }
#pertihub-root .ph-app:has(.ph-chat-layout) {
 height:var(--chat-app-height,calc(100dvh - 16px))!important;
 min-height:0!important;max-height:var(--chat-app-height,calc(100dvh - 16px))!important;
 overflow:hidden!important;
}
#pertihub-root .ph-app:has(.ph-chat-layout)>.ph-main {
 display:flex!important;flex-direction:column!important;height:100%!important;
 min-height:0!important;overflow:hidden!important;
}
#pertihub-root .ph-app:has(.ph-chat-layout) .ph-topbar { flex:0 0 auto!important; }
#pertihub-root .ph-app:has(.ph-chat-layout) .ph-content {
 display:flex!important;flex-direction:column!important;flex:1 1 0!important;
 height:auto!important;min-height:0!important;overflow:hidden!important;
 box-sizing:border-box!important;padding:12px 16px!important;
}
#pertihub-root .ph-app:has(.ph-chat-layout) .ph-chat-layout {
 flex:1 1 0!important;height:100%!important;min-height:0!important;
 margin:0!important;box-sizing:border-box!important;
}
#pertihub-root .ph-app:has(.ph-chat-layout)>.ph-sidebar { height:100%!important;min-height:0!important;overflow:hidden!important; }
#pertihub-root .ph-app:has(.ph-chat-layout)>.ph-sidebar nav { min-height:0!important; }
#pertihub-root .ph-chat-rooms { overflow-y:auto!important;overscroll-behavior:contain; }
#pertihub-root .ph-app:has(.ph-chat-layout)>.ph-sidebar nav { overflow-y:auto!important;overscroll-behavior:contain; }
#pertihub-root .ph-chat-side-head { position:sticky;top:0;z-index:2;background:#f8fafc; }
#pertihub-root .ph-chat-feed { scrollbar-gutter:stable; }

/* v702: the application navigation scrolls on EVERY route. */
#pertihub-root .ph-app { overflow:visible!important;align-items:start!important; }
html body #pertihub-root .ph-app > aside.ph-sidebar.ph-sidebar {
 position:sticky!important;top:var(--nav-top,0px)!important;bottom:auto!important;
 align-self:start!important;display:flex!important;flex-direction:column!important;
 box-sizing:border-box!important;height:var(--nav-height,calc(100dvh - 8px))!important;
 max-height:var(--nav-height,calc(100dvh - 8px))!important;min-height:0!important;
 overflow:hidden!important;border-radius:18px 0 0 18px;transition:transform .2s ease!important;
}
html body #pertihub-root .ph-app > .ph-sidebar > .ph-brand,
html body #pertihub-root .ph-app > .ph-sidebar > .ph-user { flex:0 0 auto!important; }
html body #pertihub-root .ph-app > .ph-sidebar > nav {
 flex:1 1 0!important;height:auto!important;min-height:0!important;max-height:none!important;
 overflow-y:auto!important;overflow-x:hidden!important;overscroll-behavior-y:contain;
 scrollbar-width:thin;scrollbar-color:#94a3b8 transparent;scrollbar-gutter:stable;
}
@media(max-width:1100px){
 html body #pertihub-root .ph-app > aside.ph-sidebar.ph-sidebar {
  position:fixed!important;left:0!important;z-index:40!important;
  width:min(300px,90vw)!important;border-radius:0 14px 14px 0;
 }
}
/* V703: independent lanes and route-scoped sticky headers. */
#pertihub-root .ph-app[data-ph-route] > .ph-main{overflow:visible;min-width:0}
#pertihub-root .ph-app[data-ph-route]:not(:has(.ph-chat-layout)) > .ph-main > .ph-topbar{
 position:sticky!important;top:var(--nav-top,0px)!important;z-index:25;
 flex-shrink:0;background:#fff!important;
}
#pertihub-root .ph-receive-layout > .ph-receive-card:first-child{
 display:flex;flex-direction:column;align-self:start;min-height:0;box-sizing:border-box;
 height:var(--receive-list-height,calc(100dvh - 230px))!important;max-height:none;overflow:hidden!important;
}
#pertihub-root .ph-receive-layout > .ph-receive-card:first-child > :not(.ph-receive-customer-list){flex-shrink:0}
#pertihub-root .ph-receive-customer-list{
 flex:1 1 0;min-height:0;max-height:none!important;overflow-y:auto!important;
 overscroll-behavior:contain;scrollbar-gutter:stable;
}
#pertihub-root .ph-receive-customer-list > button{flex-shrink:0}
#pertihub-root .phsd-page[data-phsd-mode=history] .phsd-groups,
#pertihub-root .phsd-page[data-phsd-mode=history] .phsd-records{
 max-height:var(--history-list-height,calc(100dvh - 150px));overflow-y:auto!important;
 min-height:0;overscroll-behavior:contain;scrollbar-gutter:stable;
}
#pertihub-root .phsd-page[data-phsd-mode=users] .phsd-sheet{
 max-height:var(--driver-table-height,calc(100dvh - 230px));overflow:auto;
 overscroll-behavior:contain;scrollbar-gutter:stable;
}
#pertihub-root .phsd-page[data-phsd-mode=users] .phsd-sheet th{
 position:sticky!important;top:0!important;z-index:3;background:#eef3f8;
}
.ph-piutang-tree{padding:8px 14px 18px}
.ph-piutang-tree details{border:1px solid #e2e8f0;border-radius:10px;margin:8px 0;background:#fff}
.ph-piutang-tree summary{display:flex;align-items:center;gap:12px;cursor:pointer;padding:13px 14px;list-style:none;min-width:0}
.ph-piutang-tree summary:before{content:'›';font-size:20px;color:#64748b}
.ph-piutang-tree details[open]>summary:before{transform:rotate(90deg)}
.ph-piutang-tree summary b{font-size:14px;font-weight:600;flex:1;overflow-wrap:anywhere}
.ph-piutang-tree summary small{font-size:11px;color:#64748b}
.ph-piutang-tree summary strong{font-size:13px;white-space:nowrap;color:#1764a0}
.ph-piutang-spv>summary{background:#f5f8fc;border-radius:10px}
.ph-piutang-spv>div{padding:0 12px 6px 24px}
.ph-piutang-sales>div{padding:0 8px 8px 16px}
.ph-piutang-tree [hidden]{display:none!important}
@media(max-width:640px){.ph-piutang-tree summary{flex-wrap:wrap;gap:8px}.ph-piutang-tree summary strong{margin-left:auto}.ph-piutang-spv>div{padding-left:10px}}
