/* One permanent controls row; page headings retain their original module scope.
   Studio's section buttons use 48px. Hiding Back must not remove its slot. */
html body.section-return-layout:not(.auth-mode) #top {
 --header-action:48px; --header-field-height:48px;
 display:flex!important;flex-wrap:nowrap!important;align-items:center;
 height:64px!important;min-height:64px!important;max-height:64px;
 box-sizing:border-box;gap:8px;padding:8px 0;margin-bottom:0!important;
}
html body.section-return-layout #top::before { display:none; }
html body.section-return-layout #top > #section-return {
 display:flex!important;align-items:center;flex:1 1 0;min-width:44px;
 height:48px;min-height:48px;max-height:48px;margin:0;padding:0;
}
html body.section-return-layout #top > #section-return[hidden] {
 visibility:hidden;pointer-events:none;
}
html body.section-return-layout #top > #section-return button {
 display:inline-flex;align-items:center;gap:10px;width:100%;max-width:100%;
 height:48px;min-height:48px;max-height:48px;padding:4px 0;
 border:0;border-radius:6px;background:transparent;box-shadow:none;
 color:var(--muted,#71839b);font:inherit;font-size:14px;font-weight:400;
 text-align:left;line-height:1.35;white-space:nowrap;cursor:pointer;
}
html body.section-return-layout #section-return button svg { width:24px;height:24px;flex:none; }
html body.section-return-layout #section-return button span {
 min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;
}
html body.section-return-layout #section-return button:hover { color:var(--blue,#087cfa); }
html body.section-return-layout #section-return button:focus-visible {
 outline:2px solid var(--blue,#087cfa);outline-offset:2px;
}
html body.section-return-layout #top > :is(#country,.header-organization) {
 position:static;transform:none;translate:none!important;
 flex:0 0 clamp(140px,18vw,240px);width:clamp(140px,18vw,240px);
 min-width:0;max-width:35%;margin:0!important;align-self:center;
 height:48px!important;min-height:48px!important;max-height:48px!important;
 box-sizing:border-box;
}
html body.section-return-layout #top > :is(#notifications,#refresh,#fullscreen,#profile) {
 flex:0 0 48px;width:48px!important;min-width:48px!important;max-width:48px;
 height:48px!important;min-height:48px!important;max-height:48px;
 box-sizing:border-box;align-self:center;margin-block:0;translate:none!important;
}
html body.section-return-layout #top > #profile { padding:0;object-fit:cover; }
/* Production keeps its real search form. Share the controls row instead of
   inheriting the older compositor's unconditional full-width search lane. */
html body.section-return-layout #top > #searchform:not([hidden]) {
 order:0;flex:1 1 160px;width:auto;min-width:100px;max-width:none;margin:0;
 height:48px;min-height:48px;max-height:48px;
 position:static;transform:none;translate:none;align-self:center;
}
@media (max-width:700px) {
 html body.section-return-layout #top:has(> #searchform:not([hidden])) {
  flex-wrap:wrap!important;height:auto!important;max-height:none;
 }
 html body.section-return-layout #top > #searchform:not([hidden]) {
  order:3;flex:1 0 100%;width:100%;min-width:0;
 }
}
/* Keep the existing heading node and its delegated actions. The first heading
   row starts below the controls both on direct entry and after a return. */
html body.section-return-layout:not(.auth-mode) #content .alp-top-heading {
 position:static!important;inset:auto!important;width:100%!important;max-width:100%!important;
 min-height:36px!important;height:auto!important;max-height:none!important;
 margin:0!important;padding:0!important;flex-wrap:wrap!important;
}
/* DEMO v196: 36px title row, 44px when it includes actions, then the existing
   shared 8px content gap. Do not add a second margin below the title. */
html body.section-return-layout #content .alp-top-heading .page-heading { min-height:36px!important; }
html body.section-return-layout #content .alp-top-heading:has(.erp-title-create,.erp-title-action,.erp-create-menu,.acc-heading-actions > :is(button,a,[role=button])),
html body.section-return-layout #content .alp-top-heading .page-heading:has(>.erp-title-create,>.erp-title-action,>.erp-create-menu) {
 min-height:40px!important;
}
html body.section-return-layout #content .alp-top-heading h1,
html body.section-return-layout #content h1.alp-top-heading {
 line-height:1.15!important;min-height:0;white-space:nowrap;
}
html body.section-return-layout #content h1.alp-top-heading { display:flex!important;align-items:center!important;min-height:36px!important; }
html body.section-return-layout #content .alp-top-heading :is(button,a,[role=button]) { translate:none!important; }
/* Keep ordinary title actions beside the heading instead of reserving an
   unconditional second row for every journal on tablets and Desktop. */
html body.section-return-layout #content .alp-top-heading > .page-heading {
 flex:1 1 auto!important;width:auto!important;min-width:0;max-width:100%;
}
html body.section-return-layout #content .alp-top-heading .acc-heading-actions {
 flex:0 1 auto!important;min-width:0;max-width:100%;margin:0!important;
 align-self:center;justify-content:flex-end;
}
html body.section-return-layout #content .alp-top-heading h1 { min-width:0;overflow:hidden;text-overflow:ellipsis; }
html body.section-return-layout #content .push-page-heading { margin:0;gap:8px;min-width:0;max-width:100%; }
html body.section-return-layout #content .push-page-heading > .alp-top-heading { flex:1 1 auto;width:auto!important;min-width:0; }
/* Async journals use a normal-flow .iam-page instead of the shell's flex gap. */
html body.section-return-layout #content :is(.iam-page,.pay-page) > .alp-top-heading + .page-main-toolbar { margin-top:8px!important; }
html body.section-return-layout #content .pay-page { margin:0;max-width:100%; }
/* Shared primary context: the approved tenant/month caption-value geometry.
   Values and calendar/date handlers remain owned by their original module. */
html body.section-return-layout #content .page-main-toolbar {
 --page-context-width:var(--filter-control-width);
}
html body.section-return-layout #content .page-main-toolbar:has(> .page-context > .date-range) {
 --page-context-width:var(--filter-period-width);
}
html body.section-return-layout #content .page-main-toolbar > .page-context {
 align-items:stretch;gap:8px;
}
html body.section-return-layout #content .page-main-toolbar > .page-context > .page-context-field {
 display:flex;flex:0 0 auto;flex-direction:column;align-items:stretch;justify-content:center;
 width:var(--page-context-width)!important;min-width:0;max-width:100%;margin:0!important;
 height:auto!important;min-height:var(--filter-control-height)!important;max-height:none!important;
 padding:calc(7 * var(--u)) calc(13 * var(--u))!important;gap:3px!important;
 border:1px solid var(--line);border-radius:10px;background:#fff;box-sizing:border-box;
 text-align:left;font:inherit;font-weight:400;line-height:1.3!important;
}
html body.section-return-layout #content .page-main-toolbar > .page-context > .page-context-field > :is(small,label) {
 display:block!important;margin:0;padding:0;font-size:.8rem;font-weight:400;line-height:1.3;color:var(--muted);
}
html body.section-return-layout #content .page-main-toolbar > .page-context > .page-context-field > :is(span,button,input) {
 flex:0 0 auto;min-width:0;width:100%;margin:0;line-height:1.4;
 white-space:nowrap;
}
html body.section-return-layout #content .page-main-toolbar > .page-context > .page-context-field > button,
html body.section-return-layout #content .page-main-toolbar > .page-context > .page-context-field > input {
 min-height:0;height:1.4em;padding:0;border:0;border-radius:0;background:transparent;
 font:inherit;line-height:1.4;text-align:left;
}
html body.section-return-layout #content .page-context-field > span { display:flex;align-items:center;gap:8px; }
html body.section-return-layout #content .page-context-field :is(.filter-value,.calendar-value) {
 overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;
}
html body.section-return-layout #content .page-context-field svg { width:20px;height:20px;flex:none; }
html body.section-return-layout #content .page-context-field > .page-context-value { overflow:hidden;text-overflow:ellipsis; }
/* Match DEMO v201: a 40px tab row with a 44px touch area, without
   shifting period fields outside the shared panel. */
html body.section-return-layout #content .page-main-toolbar {
 --alp-primary-tab-row-height:40px;--alp-primary-tab-inset:0px;
 column-gap:12px;row-gap:8px;
}
html body.section-return-layout #content .page-main-toolbar > .page-primary-tabs {
 display:flex;align-items:center;flex-wrap:nowrap;gap:8px;
 height:40px;min-height:40px;max-height:40px;
 margin:0!important;padding:0!important;border:0;scrollbar-width:none;
}
html body.section-return-layout #content .page-main-toolbar > .page-primary-tabs::-webkit-scrollbar {display:none;}
html body.section-return-layout #content .page-main-toolbar > .page-primary-tabs > button {
 --alp-page-button-height:40px;
 position:relative;flex:0 0 auto;height:40px;min-height:40px;max-height:40px;
 padding:8px calc(12 * var(--u))!important;line-height:22px!important;overflow:visible!important;
}
html body.section-return-layout #content .page-main-toolbar > .page-primary-tabs > button::after {
 content:"";position:absolute;inset:auto 0;top:50%;height:44px;transform:translateY(-50%);
}
/* Empty legacy filter shells must not retain their former layout row. */
html body.section-return-layout #content .page-context > .utilities-context-filters { margin:0; }
@media (min-width:701px) {
 html[data-calendar-demo="257"] body.section-return-layout #content .page-main-toolbar:has(.calendar-standard-field):not(:has(> .page-context > .date-range)) {
  --page-context-width:clamp(180px,18vw,250px);
 }
 html body.section-return-layout #content .page-main-toolbar:has(> .page-primary-tabs) {align-items:end;}
 html body.section-return-layout #content .page-main-toolbar:not(.page-toolbar-context-only) > .page-context {
  position:relative;z-index:21;translate:none;
 }
}
@media (max-width:700px) {
 html body.section-return-layout #content .page-main-toolbar > .page-context { flex-wrap:wrap; }
 html body.section-return-layout #content .page-main-toolbar > .page-context > .page-context-field {
  flex:1 0 100%;width:100%!important;
 }
}
/* Small phones retain the same Back slot while the context field gets its own
   row. iPad and desktop keep all controls on the single top row. */
@media (max-width:480px) {
 html body.section-return-layout:not(.auth-mode) #top {
  flex-wrap:wrap!important;height:auto!important;max-height:none;gap:6px;
 }
 html body.section-return-layout #top > #section-return { flex:1 1 0;order:0; }
 html body.section-return-layout #top > :is(#notifications,#refresh,#profile) { order:1; }
 html body.section-return-layout #top > :is(#country,.header-organization) {
  order:2;flex:1 0 100%;width:100%;max-width:100%;
 }
}
@media print { html body.section-return-layout #top > #section-return { display:none!important; } }

/* Cashbox selection is the real details control beside the period. Both use
   the same width token and caption/value geometry; its form stays attached. */
html body.section-return-layout #content .page-main-toolbar > .page-context > .page-cashbox {
 flex:0 0 auto;align-self:stretch;width:var(--page-context-width)!important;
 min-width:0;max-width:100%;margin:0!important;
}
html body.section-return-layout #content .page-context > .page-cashbox > summary {
 height:100%;min-height:var(--filter-control-height);padding:calc(7 * var(--u)) calc(13 * var(--u));
 align-items:stretch;gap:3px;font:inherit;font-weight:400;line-height:1.3;text-align:left;
}
html body.section-return-layout #content .page-cashbox > summary > small {font-size:.8rem;line-height:1.3;}
html body.section-return-layout #content .page-cashbox > summary > span {line-height:1.4;}
html body.section-return-layout #content .page-cashbox > .cashbox-picker-menu {left:auto;right:0;}
@media(max-width:700px) {
 html body.section-return-layout #content .page-main-toolbar > .page-context-with-cashbox {
  display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%;
 }
 html body.section-return-layout #content .page-main-toolbar > .page-context-with-cashbox > :is(.page-cashbox,.page-period) {
  min-width:0;width:100%!important;box-sizing:border-box;
 }
 html body.section-return-layout #content .page-cashbox > .cashbox-picker-menu {
  left:0;right:auto;width:calc(200% + 8px);max-width:calc(100vw - 24px);
 }
}

/* Shared page actions follow the 40px Business overview controls. */
body.section-return-layout {--alp-page-button-height:40px;--page-action-height:40px;}
html body.section-return-layout #content .alp-page-button,
html body.section-return-layout #content .alp-top-heading .alp-page-button,
html body.section-return-layout #content .alp-top-heading .erp-create-menu > summary {
 box-sizing:border-box;height:var(--alp-page-button-height)!important;
 min-height:var(--alp-page-button-height)!important;max-height:var(--alp-page-button-height)!important;
 padding-top:0!important;padding-bottom:0!important;
 font-size:1rem!important;line-height:22px!important;white-space:nowrap!important;overflow:hidden;text-overflow:ellipsis;max-width:100%;
}
html body.section-return-layout.erp-compact #content .alp-top-heading .erp-title-action {
 display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;
 gap:8px;width:auto!important;min-width:0!important;max-width:none!important;
 padding-inline:12px!important;margin:0;border:1px solid var(--line);border-radius:8px;
 background:#fff;color:var(--muted);box-shadow:none;font:inherit;font-weight:400;
 white-space:nowrap;text-decoration:none;
}
html body.section-return-layout #content .alp-top-heading .erp-title-action > svg {width:20px;height:20px;flex:none;}
html body.section-return-layout #content .alp-top-heading .erp-title-action:hover {background:#f4f7fc;}
html body.section-return-layout #content .alp-top-heading .erp-title-action:focus-visible {outline:2px solid var(--blue);outline-offset:2px;}
html body.section-return-layout.erp-compact #content .alp-top-heading .erp-title-action > [data-bank-upload-label] {display:inline!important;}
@media(max-width:700px) {
 html body.section-return-layout.erp-compact #content .alp-top-heading .erp-title-action {
  width:40px!important;min-width:40px!important;max-width:40px!important;padding-inline:0!important;
 }
 html body.section-return-layout.erp-compact #content .alp-top-heading .erp-title-action > [data-bank-upload-label] {
  position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;
 }
}


/* Keep 8px below headings and 12px after page control rows. Inner cards and
   data tables retain their content layout and their own scroll containers. */
html body.section-return-layout #content .alp-page-frame,
html body.section-return-layout #content.alp-page-frame {row-gap:8px!important;}
html body.section-return-layout #content .page-toolbar-empty {display:none!important;margin:0!important;padding:0!important;}
html body.section-return-layout #content .alp-top-heading {flex:none!important;}
html body.section-return-layout #content .alp-page-frame > :is(.people-toolbar,.settle-filters,.alp-secret-toolbar,.tariffs-toolbar,.res-provider-bar) ,
html body.section-return-layout #content.alp-page-frame > :is(.people-toolbar,.settle-filters,.alp-secret-toolbar,.tariffs-toolbar,.res-provider-bar) {
 margin-block:0!important;
}
html body.section-return-layout #content .alp-page-frame > .alp-secret-toolbar {padding:0!important;}
html body.section-return-layout #content .alp-page-frame > p {margin-block:0;}
html body.section-return-layout #content .alp-page-frame > :is(.scroll-content,.res-scroll,.sec-scroll),
html body.section-return-layout #content.alp-page-frame > :is(.scroll-content,.res-scroll,.sec-scroll) {padding-top:0!important;}
/* The counterparty module's older absolute heading must obey normal flow. */
html body.section-return-layout.erp-compact #content .party-directory > .acc-heading.alp-top-heading:has(.acc-heading-actions) {
 position:static!important;inset:auto!important;width:100%!important;max-width:100%!important;
 height:auto!important;min-height:40px!important;flex-wrap:wrap!important;
}
html body.section-return-layout.erp-compact #content :is(.alp-icon-button,.erp-title-create,.erp-create-menu > summary) {
 flex:0 0 40px;width:40px!important;min-width:40px!important;max-width:40px!important;padding-inline:0!important;
}
/* The same ordinary action height also applies to existing dialog footers.
   Calendar cells, choice cards and caption/value fields are separate controls. */
html body.section-return-layout #dialog :is(.modal-foot button,.modal-actions button,.modal-body button.primary,.modal-body button.secondary,.modal-body button.sec-button) {
 box-sizing:border-box;height:40px!important;min-height:40px!important;max-height:40px!important;
 padding-block:0!important;font-size:1rem;line-height:22px!important;
}
html body.section-return-layout #dialog .modal-actions button {width:40px;min-width:40px;padding-inline:0;}

/* DEMO v201 spacing: preserve each control's existing box and add the extra
   4px outside the panel. Empty legacy rows keep display:none. */
html body.section-return-layout #content .alp-page-frame > :is(.page-main-toolbar,.list-toolbar,.tpl-toolbar,.biz-calendar-toolbar,.biz-integration-filter,.people-toolbar,.settle-filters,.alp-secret-toolbar,.tariffs-toolbar,.res-provider-bar,.gpt-topline,.np-brand),
html body.section-return-layout #content.alp-page-frame > :is(.page-main-toolbar,.list-toolbar,.tpl-toolbar,.biz-calendar-toolbar,.biz-integration-filter,.people-toolbar,.settle-filters,.alp-secret-toolbar,.tariffs-toolbar,.res-provider-bar,.gpt-topline,.np-brand) {margin-block:0 4px!important;}

html body.section-return-layout #content.alp-page-frame > p {margin-block:0;}
/* Plain-flow journals and directories keep the same external spacing. */
html body.section-return-layout #content :is(.iam-page,.warehouse-page,.management-directory):has(> .alp-top-heading) > * {margin-block:8px 0!important;}
html body.section-return-layout #content :is(.iam-page,.warehouse-page,.management-directory):has(> .alp-top-heading) > .alp-top-heading {margin-top:0!important;}
html body.section-return-layout #content :is(.iam-page,.warehouse-page,.management-directory):has(> .alp-top-heading) > :is(.page-main-toolbar,.iam-toolbar,.warehouse-toolbar):not(.page-toolbar-empty) {margin-bottom:12px!important;}
html body.section-return-layout #content .page-main-toolbar.page-toolbar-context-only:not(:has(> .page-primary-tabs)):not(:has(> .page-context:not([hidden]))) {display:none!important;}
html body.section-return-layout #content .alp-page-frame > .gpt-setup {margin-block:0!important;}
html body.section-return-layout #content .estimates-content > .list-toolbar {margin-bottom:12px!important;}
