/*
 * HENDAR UALL-P — universal page scrolling and tender-entry operability.
 *
 * Normal pages have one scroll owner: the browser document.  This avoids the
 * competing 100vh/100dvh containers that previously trapped long pages on
 * Windows and mobile browsers.  Chat and dialogs remain bounded surfaces.
 */

html[data-auth-surface="app"],
html[data-auth-surface="app"] body,
body.hendar-authenticated {
  width:100% !important;
  height:auto !important;
  min-height:100% !important;
  max-height:none !important;
  overflow-x:hidden !important;
  overflow-y:auto !important;
  overscroll-behavior-x:none !important;
  overscroll-behavior-y:auto !important;
  touch-action:pan-y !important;
  -webkit-overflow-scrolling:touch !important;
}

html[data-auth-surface="app"] .app-shell:not(.hidden),
body.hendar-authenticated .app-shell:not(.hidden) {
  width:100% !important;
  height:auto !important;
  min-height:100dvh !important;
  max-height:none !important;
  overflow:visible !important;
}

html[data-auth-surface="app"] .main-content,
body.hendar-authenticated .main-content {
  height:auto !important;
  min-height:100dvh !important;
  max-height:none !important;
  overflow:visible !important;
  contain:none !important;
  touch-action:pan-y !important;
}

html[data-auth-surface="app"] .main-content > .view.active:not([hidden]),
body.hendar-authenticated .main-content > .view.active:not([hidden]) {
  position:relative !important;
  inset:auto !important;
  display:flow-root !important;
  width:auto !important;
  height:auto !important;
  min-height:calc(100dvh - 72px) !important;
  max-height:none !important;
  overflow:visible !important;
  transform:none !important;
  touch-action:pan-y !important;
  padding-bottom:max(48px, calc(env(safe-area-inset-bottom) + 30px)) !important;
}

html[data-auth-surface="app"] #projectWorkspaceView:not(.project-chat-active) .project-workspace-layout,
html[data-auth-surface="app"] #projectWorkspaceView:not(.project-chat-active) .project-workspace-main,
html[data-auth-surface="app"] #projectWorkspaceView:not(.project-chat-active) #projectWorkspaceContent,
body.hendar-authenticated #projectWorkspaceView:not(.project-chat-active) .project-workspace-layout,
body.hendar-authenticated #projectWorkspaceView:not(.project-chat-active) .project-workspace-main,
body.hendar-authenticated #projectWorkspaceView:not(.project-chat-active) #projectWorkspaceContent {
  height:auto !important;
  min-height:0 !important;
  max-height:none !important;
  overflow:visible !important;
}

html[data-auth-surface="app"] body.modal-open,
body.hendar-authenticated.modal-open {
  height:100% !important;
  max-height:100% !important;
  overflow-x:hidden !important;
  overflow-y:hidden !important;
  touch-action:none !important;
}

.modal-backdrop:not(.hidden) {
  overflow-x:hidden !important;
  overflow-y:auto !important;
  overscroll-behavior:contain !important;
  touch-action:pan-y !important;
  -webkit-overflow-scrolling:touch !important;
}

.modal-backdrop:not(.hidden) > .modal:not(.hidden) {
  max-height:calc(100dvh - 32px) !important;
  overflow-x:hidden !important;
  overflow-y:auto !important;
  overscroll-behavior:contain !important;
  touch-action:pan-y !important;
  -webkit-overflow-scrolling:touch !important;
}

html[data-auth-surface="app"] #projectWorkspaceView.project-chat-active,
body.hendar-authenticated #projectWorkspaceView.project-chat-active {
  height:calc(100dvh - 72px) !important;
  min-height:0 !important;
  max-height:calc(100dvh - 72px) !important;
  padding-bottom:0 !important;
  overflow:hidden !important;
  touch-action:manipulation !important;
}

#projectWorkspaceView.project-chat-active .project-chat-messages,
#projectWorkspaceView.project-chat-active .project-chat-roster-rows,
.hendar-chat-widget-v084 .hcw-messages {
  min-height:0 !important;
  overflow-x:hidden !important;
  overflow-y:auto !important;
  overscroll-behavior-y:contain !important;
  touch-action:pan-y !important;
  -webkit-overflow-scrolling:touch !important;
}

@supports selector(body:has(*)) {
  html[data-auth-surface="app"]:has(#projectWorkspaceView.project-chat-active),
  html[data-auth-surface="app"]:has(#projectWorkspaceView.project-chat-active) body,
  body.hendar-authenticated:has(#projectWorkspaceView.project-chat-active),
  body.hendar-authenticated:has(#projectWorkspaceView.project-chat-active) .app-shell:not(.hidden),
  body.hendar-authenticated:has(#projectWorkspaceView.project-chat-active) .main-content {
    height:100dvh !important;
    min-height:0 !important;
    max-height:100dvh !important;
    overflow:hidden !important;
  }
}

.tender-entry-expenses {
  margin:4px 0;
  padding:16px;
  border:1px solid #c7dce8;
  border-radius:16px;
  background:linear-gradient(135deg,#f8fbff,#eef8f5);
}
.tender-entry-expenses-heading { display:flex;align-items:center;justify-content:space-between;gap:12px; }
.tender-entry-expenses-heading span { display:block;color:#0b587b;font-weight:900; }
.tender-entry-expenses-heading small { display:block;margin-top:4px;color:var(--steel-500);line-height:1.6; }
.tender-entry-expense-drafts { display:grid;gap:10px;margin-top:12px; }
.tender-entry-expense-draft { border:1px solid var(--steel-200);border-radius:13px;background:#fff;overflow:hidden; }
.tender-entry-expense-draft > summary { display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:10px;padding:11px 12px;cursor:pointer;background:#f6fafc;list-style:none; }
.tender-entry-expense-draft > summary::-webkit-details-marker { display:none; }
.tender-entry-expense-draft > summary span { color:#0b6781;font-weight:900; }
.tender-entry-expense-draft > summary strong { min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ink); }
.tender-entry-expense-draft > summary button { border:0;border-radius:9px;padding:7px 9px;background:#fde9eb;color:#a52335;font-weight:850;cursor:pointer; }
.tender-entry-expense-grid { display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;padding:12px; }
.tender-entry-expense-grid label { display:grid;gap:6px; }
.tender-entry-expense-grid .wide { grid-column:span 2; }
.tender-entry-expense-empty { margin:12px 0 0;color:var(--steel-500);font-size:11px; }
.document-governance-note { border-right:3px solid #b07d22;padding:7px 9px;background:#fff8e6;color:#714d0d !important; }

@media(max-width:980px){
  .tender-entry-expense-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:620px){
  .tender-entry-expenses-heading{align-items:stretch;display:grid}
  .tender-entry-expenses-heading .button{width:100%}
  .tender-entry-expense-draft>summary{grid-template-columns:auto minmax(0,1fr)}
  .tender-entry-expense-draft>summary button{grid-column:1/-1;width:100%}
  .tender-entry-expense-grid{grid-template-columns:1fr}
  .tender-entry-expense-grid .wide{grid-column:auto}
}
