/* v1.7: navigation stays outside the scrolling content frames. */
@media screen and (min-width:951px) {
  html:has(body.kiss-framed-pages) { height:100%; overflow:hidden; }
  body.kiss-framed-pages { height:100vh; height:100dvh; min-height:0; display:flex; flex-direction:column; overflow:hidden; }
  body.kiss-framed-pages > header { flex:none; }
  body.kiss-framed-pages > main { flex:1; min-height:0; min-width:0; max-width:100%; overflow:auto; overscroll-behavior:contain; }
  body.kiss-framed-pages > .kiss-powered-by { flex:none; padding:4px 12px !important; }
  body.kiss-framed-pages > main:has(> .page-scroll-frame) { display:flex; flex-direction:column; overflow:hidden; }
  body.kiss-framed-pages .page-scroll-frame { flex:1; min-height:0; min-width:0; width:100%; max-height:100%; box-sizing:border-box; overflow:auto; overscroll-behavior:contain; }
  body.kiss-framed-pages .page-table-frame { min-width:0; overflow:auto; max-height:var(--page-table-height,65dvh); overscroll-behavior:contain; }
  body.kiss-framed-pages .page-table-frame > table > thead { position:sticky; top:0; z-index:3; background:var(--surface,#f8fafb); }
  body.kiss-framed-pages .page-table-frame > table { border-collapse:separate; border-spacing:0; }
  body.kiss-framed-pages .page-table-frame:focus-visible { outline:2px solid var(--teal,#147d79); outline-offset:-2px; }
  /* Common list layouts: keep their heading, filters and pagination outside tables. */
  body.kiss-framed-pages .page-list-frame { display:flex; flex-direction:column; overflow:hidden; padding-top:14px; padding-bottom:8px; }
  body.kiss-framed-pages .page-list-frame > :not(.page-list-fill) { flex:none; }
  body.kiss-framed-pages .page-list-fill { flex:1; min-height:0; min-width:0; }
  body.kiss-framed-pages .page-list-frame :is(.invoice-page-layout,.jobs-page-layout) { align-items:stretch; grid-template-rows:minmax(0,1fr); overflow:hidden; }
  body.kiss-framed-pages .page-list-frame .invoice-page-layout.without-queues { display:flex; flex-direction:column; }
  body.kiss-framed-pages .page-list-frame .invoice-page-layout.without-queues > .invoice-list-main { flex:1; }
  body.kiss-framed-pages .page-list-frame :is(.invoice-list-main,.jobs-list-main,.jobs-table-card) { display:flex; flex-direction:column; min-height:0; min-width:0; }
  body.kiss-framed-pages .page-list-frame :is(.invoice-list-main,.jobs-list-main) > .jobs-table-card { flex:1; }
  body.kiss-framed-pages .page-list-frame .jobs-table-card > .jobs-table-scroll { flex:1; min-height:0; max-height:none; overflow:auto; }
  body.kiss-framed-pages .page-list-frame :is(.invoice-queue-column,.jobs-no-appointment-queue) { position:static; height:auto; min-height:0; max-height:none; overflow:hidden; }
  body.kiss-framed-pages .page-list-frame .invoice-queue-column { display:flex; flex-direction:column; }
  body.kiss-framed-pages .page-list-frame .invoice-queue-panel { flex:1; min-height:0; max-height:none; display:flex; flex-direction:column; }
  body.kiss-framed-pages .page-list-frame .queue-list { flex:1; min-height:0; overflow:auto; overscroll-behavior:contain; }
  body.kiss-framed-pages .page-list-frame :is(.panel-heading,.invoice-queue-actions) { flex:none; }
  body.kiss-framed-pages .page-filter-frame { position:fixed !important; z-index:90; box-sizing:border-box; overflow:auto; overscroll-behavior:contain; max-width:calc(100vw - 24px) !important; }
  /* Existing Schedule and Timecard own their internal layout and scrolling. */
  body.kiss-framed-pages > main:has(> :is(.schedule-page,.timecard-page)) { overflow:hidden; }
  body.kiss-framed-pages.account-shell > main { display:flex; justify-content:center; align-items:center; padding:16px; }
  body.kiss-framed-pages.account-shell .account-card { flex:0 1 auto; max-height:100%; overflow:auto; overscroll-behavior:contain; }
  @media(max-width:950px) {
    body.kiss-framed-pages .page-list-frame :is(.invoice-page-layout,.jobs-page-layout):has(> aside) { grid-template-rows:minmax(0,1fr) minmax(0,1fr); gap:10px; }
    body.kiss-framed-pages .page-list-frame .invoice-queue-column { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); grid-template-rows:minmax(0,1fr) auto; gap:8px; }
    body.kiss-framed-pages .page-list-frame .invoice-queue-actions { gap:6px; }
    body.kiss-framed-pages .page-list-frame .panel-heading { padding:6px 10px; min-height:0; }
    body.kiss-framed-pages .page-list-frame .panel-heading h2 { font-size:17px; }
  }
  /* If controls alone fill a small screen, scroll the enclosing frame as well. */
  body.kiss-framed-pages .page-list-frame.page-short-frame { overflow:auto; }
  body.kiss-framed-pages .page-short-frame > .page-list-fill { flex:none; min-height:300px; height:65dvh; }
}
@media print {
  .page-scroll-frame,.page-table-frame,.page-list-fill { height:auto !important; max-height:none !important; overflow:visible !important; }
}
/* v1.7 / v0.4v: phones and compact/tablet views scroll the document.
   Keep horizontal table/timeline scrolling and modal scroll containment. */
@media screen and (max-width:950px) {
  html:has(body.kiss-framed-pages) { height:auto; overflow-x:hidden; overflow-y:auto; }
  body.kiss-framed-pages,
  body.kiss-framed-pages:has(> main > :is(.schedule-page,.timecard-page)) { height:auto; min-height:100dvh; display:block; overflow:visible; }
  body.kiss-framed-pages > main,
  body.kiss-framed-pages > main:has(> :is(.schedule-page,.timecard-page,.qb-conflicts-page)) { display:block; height:auto; max-height:none; overflow:visible; }
  body.kiss-framed-pages .page-scroll-frame { height:auto; max-height:none; min-width:0; box-sizing:border-box; overflow:visible; }
  body.kiss-framed-pages .page-table-frame { height:auto; max-height:none; overflow:auto; overscroll-behavior:auto; }
  body.kiss-framed-pages .jobs-table-scroll { max-height:none; }
  body.kiss-framed-pages .my-day-scroll { height:auto; max-height:none; }
  body.kiss-framed-pages :is(.schedule-page,.timecard-page) { flex:none; height:auto; overflow:visible; }
  body.kiss-framed-pages .schedule-page .dispatch-layout { display:flex; flex-direction:column; overflow:visible; }
  body.kiss-framed-pages .schedule-page .queue-panels { flex:none; grid-template-rows:auto; overscroll-behavior:auto; }
  body.kiss-framed-pages .schedule-page .queue-panel { height:auto; max-height:none; }
  body.kiss-framed-pages .schedule-page .queue-list { flex:none; max-height:none; overflow:visible; }
  body.kiss-framed-pages .schedule-page .timeline-card { height:auto; min-height:360px; }
  body.kiss-framed-pages .schedule-page .schedule-workspace { flex:auto; min-height:320px; }
  body.kiss-framed-pages .schedule-page .timeline-scroll { overscroll-behavior:auto; }
  body.kiss-framed-pages .schedule-page .schedule-legend { max-height:none; overscroll-behavior:auto; }
  body.kiss-framed-pages .schedule-page .schedule-map-body { min-height:320px; }
  body.kiss-framed-pages .timecard-page .timecard-scroll { flex:none; height:auto; max-height:none; overscroll-behavior:auto; }
  body.kiss-framed-pages .timecard-page .azuga-evidence { flex:none; overflow:visible; }
  body.kiss-framed-pages .qb-conflicts-page.page-scroll-frame,
  body.kiss-framed-pages .qb-conflicts-page #sync-conflicts,
  body.kiss-framed-pages .qb-conflicts-page #qb-conflict-decisions { display:block; overflow:visible; }
  body.kiss-framed-pages .qb-conflicts-page .qb-conflict-list { max-height:none; overflow:visible; }
  /* Filters are floating controls on both layouts, not document frames. */
  body.kiss-framed-pages .page-filter-frame { position:fixed !important; z-index:90; box-sizing:border-box; overflow:auto; overscroll-behavior:contain; max-width:calc(100vw - 24px) !important; }
  html:has(body.kiss-framed-pages:is(.modal-open,.pto-modal-open,.save-dialog-open,.mobile-line-modal-open)),
  html:has(body.kiss-framed-pages dialog[open]),
  body.kiss-framed-pages:is(.modal-open,.pto-modal-open,.save-dialog-open,.mobile-line-modal-open),
  body.kiss-framed-pages:has(dialog[open]) { overflow:hidden; }
}
