/* Compact workspace: final layout layer over the shared form styles.
   Explicit areas prevent old media/container rules from placing siblings together. */
body.workspace-compact { --workspace-control: 44px; }
body.workspace-compact .workspace-nav { box-sizing: border-box; max-width: 1000px; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: start; }
body.workspace-compact .workspace-nav>.workspace-brand { display: block; background: none; padding: 0; color: #233b48; font-size: 18px; font-weight: 800; }
body.workspace-compact .workspace-channel { margin-top: 3px; }
body.workspace-compact .workspace-channel .channel-badge { padding: 0; border: 0; background: none; font-size: 11px; font-weight: 600; color: #607080; }
body.workspace-compact .workspace-help { min-width: 0; font-size: 12px; }
body.workspace-compact .workspace-help>summary { cursor: pointer; padding: 8px 0; }
body.workspace-compact .workspace-help[open] { grid-column: 1/-1; }
body.workspace-compact .workspace-help-content { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 0 0; border-top: 1px solid #dce4e8; }
body.workspace-compact .workspace-help-content #versionLine { flex-basis: 100%; font-size: 12px; margin: 0; }
body.workspace-compact .workspace-help-content .button { font-size: 12px; }
body.workspace-compact :is(.field,.choice-field,.item-body,.condition-form,.party-list,.money-editor,.legal-grid)>* { min-width: 0; }
body.workspace-compact :is(button,summary,label,legend,h2,h3,.notice,.field-detail) { word-break: normal; overflow-wrap: break-word; }
body.workspace-compact :is(button,summary):focus-visible { outline: 3px solid #80b7b1; outline-offset: 2px; }
body.workspace-compact .item-head { display: grid!important; grid-template-columns: minmax(0,1fr) auto; align-items: start; }
body.workspace-compact .item-title { width: auto!important; min-width: 0; }
body.workspace-compact .item-title h3 { font-size: 19px; line-height: 1.4; overflow-wrap: break-word; }
body.workspace-compact .item-tools { max-width: none; gap: 8px; align-items: start; }
body.workspace-compact .item-tools :is(.button,.item-more>summary) { min-height: 40px; padding: 9px 12px!important; font-size: 13px; line-height: 20px; }
body.workspace-compact .item-more[open] { flex: initial; }
body.workspace-compact .item-more .item-inline-actions { display: grid; grid-template-columns: 1fr; }
body.workspace-compact .item-body { margin-top: 16px; }
body.workspace-compact .item-card .fields { display: grid!important; grid-template-columns: repeat(2,minmax(0,1fr))!important; gap: 16px; margin: 0; align-items: start; }
body.workspace-compact .item-card .fields>.field { grid-column: auto!important; grid-row: auto!important; display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: auto; align-content: start; gap: 6px; max-width: none; width: 100%; }
body.workspace-compact .item-card .fields>.field.full,
body.workspace-compact .item-card .fields>.transaction-share-field,
body.workspace-compact .item-card .fields>.choice-field:has(>.choices-3) { grid-column: 1/-1!important; }
body.workspace-compact .item-card .fields>.field>span:first-child { min-height: 20px; margin: 0; line-height: 1.4; }
body.workspace-compact .item-card .fields>.field.checkbox { display: flex; align-items: center; }
body.workspace-compact .field.checkbox input { flex: 0 0 18px; width: 18px; height: 18px!important; min-height: 18px!important; margin: 0; padding: 0; accent-color: var(--workspace-accent); }
body.workspace-compact .item-card .fields>.field.checkbox>span { min-height: 0; }
body.workspace-compact .field>input[type=number] { max-width: 140px; }
body.workspace-compact .choice-buttons { height: auto!important; min-height: var(--workspace-control); align-items: stretch; padding: 3px; gap: 3px; }
body.workspace-compact .choice-button { height: auto!important; min-height: 36px; line-height: 1.3; padding: 7px 10px; white-space: normal; }
body.workspace-compact .action-benefit-field { padding: 12px!important; border: 1px solid #e1d9ef; border-left: 3px solid #8b70b8; background: #faf8fd; border-radius: 8px; }
body.workspace-compact .action-benefit-field>:is(span,select,.field-detail,.field-inline-info) { grid-column: 1!important; grid-row: auto!important; }
body.workspace-compact .trust-fields .action-benefit-field { padding: 0!important; border: 0; background: none; }
body.workspace-compact .item-card .fields.trust-fields { grid-template-columns: minmax(0,1.2fr) minmax(0,1fr) 132px!important; gap: 14px 12px!important; }
body.workspace-compact .trust-fields>.trust-scenario-field { grid-column: 1/-1!important; }
body.workspace-compact .trust-fields>:is(.trust-relation,.trust-principal,.trust-representatives) { align-self: start; grid-template-rows: 36px 56px!important; }
body.workspace-compact .trust-fields>:is(.trust-relation,.trust-principal,.trust-representatives)>span { display: flex!important; align-items: end; min-height: 0!important; }
body.workspace-compact .trust-fields>:is(.trust-relation,.trust-principal)>.choice-buttons,
body.workspace-compact .trust-fields>.trust-representatives>input { height: 56px!important; }
body.workspace-compact .trust-fields>.action-benefit-field { margin-top: 2px; }
body.workspace-compact .trust-fields>.trust-representatives input { max-width: 132px; }

/* Each list provides its actual usable width, independently of the window. */
body.workspace-compact .parties-field { min-width: 0; padding: 12px; container: workspace-parties / inline-size; }
body.workspace-compact .parties-field .party-row { display: grid!important; grid-template-columns: minmax(0,1fr) minmax(0,1fr)!important; grid-template-areas: "heading actions" "type role" "share share" "benefit benefit"; gap: 12px!important; padding: 12px; margin: 0; align-items: start; }
body.workspace-compact .parties-field .party-row>* { width: auto!important; min-width: 0; margin: 0!important; }
body.workspace-compact .parties-field .party-row>.party-heading { grid-area: heading!important; padding: 8px; }
body.workspace-compact .parties-field .party-row>.party-type-wrap { grid-area: type!important; }
body.workspace-compact .parties-field .party-row>.party-role-wrap { grid-area: role!important; }
body.workspace-compact .parties-field .party-row>.party-auxiliary { grid-area: share!important; display: block; }
body.workspace-compact .parties-field .party-row>.party-benefit-wrap { grid-area: benefit!important; }
body.workspace-compact .parties-field .party-row>.party-row-actions { grid-area: actions!important; display: flex; gap: 4px; justify-self: end; flex-wrap: nowrap; align-items: center; }
body.workspace-compact .parties-field .party-row-actions>button { margin: 0!important; flex: 0 0 32px; width: 32px!important; height: 32px; min-height: 32px; }
body.workspace-compact .party-row :is(.party-type-wrap,.party-role-wrap,.party-benefit-wrap,.party-share-wrap) { gap: 6px; }
body.workspace-compact .party-row :is(.party-type-wrap,.party-role-wrap,.party-benefit-wrap,.party-share-wrap)>span:first-child { line-height: 18px; }
body.workspace-compact .party-row .choice-button { font-size: 12px; padding: 6px 8px; }
body.workspace-compact .party-row select { height: 44px; min-height: 44px; }
body.workspace-compact .party-row .party-share-wrap { width: min(190px,100%)!important; }
body.workspace-compact .party-row .party-auxiliary:not(:has(.party-share-wrap:not([hidden]))) { display: none; }
body.workspace-compact .party-row:is(.role-locked,:not(:has(>.party-role-wrap))) { grid-template-areas: "heading actions" "type type" "share share" "benefit benefit"; }
body.workspace-compact .party-heading .party-switch { max-width: none; }
body.workspace-compact .party-heading .party-switch span { font-size: 12px; line-height: 1.35; hyphens: auto; overflow-wrap: anywhere; }
@container workspace-parties (min-width:720px) {
  body.workspace-compact .parties-field .party-row { grid-template-columns: minmax(200px,.95fr) minmax(140px,1fr) minmax(160px,1.15fr) 104px!important; grid-template-areas: "heading type role actions" "heading share benefit benefit"; }
  body.workspace-compact .parties-field .party-row:is(.role-locked,:not(:has(>.party-role-wrap))) { grid-template-columns: minmax(200px,.95fr) minmax(140px,1fr) minmax(180px,1.4fr) 104px!important; grid-template-areas: "heading type benefit actions" "heading share benefit actions"; }
  body.workspace-compact .parties-field .party-row:has(>input.party-type) { grid-template-areas: "heading role share actions" "heading benefit benefit benefit"; }
  body.workspace-compact .parties-field .party-row>.party-row-actions { padding-top: 24px; }
}
@container workspace-parties (max-width:399px) {
  body.workspace-compact .parties-field .party-row { grid-template-columns: minmax(0,1fr)!important; grid-template-areas: "heading" "type" "role" "share" "benefit" "actions"; }
  body.workspace-compact .parties-field .party-row:is(.role-locked,:not(:has(>.party-role-wrap))) { grid-template-areas: "heading" "type" "share" "benefit" "actions"; }
}

/* Secondary information remains in flow; one small separator per section. */
body.workspace-compact .condition-form .conditions-actions { margin: 8px 0 0!important; padding: 12px 0 0!important; min-height: 0; }
body.workspace-compact .workspace-outcall { margin: 12px 0 0!important; padding: 8px 0 0!important; }
body.workspace-compact :is(.workspace-outcall,.workspace-related,.workspace-bank)>summary { padding: 6px 0; line-height: 1.5; }
body.workspace-compact .workspace-related { margin: 12px 0 0!important; padding: 8px 0 0; }
body.workspace-compact .workspace-related .next9-related-list { display: grid; gap: 0; }
body.workspace-compact .workspace-related .next9-related-list button { display: grid; grid-template-columns: minmax(0,1fr); width: 100%; text-align: left; padding: 10px 0!important; gap: 4px; border-radius: 0; }
body.workspace-compact .workspace-related .next9-related-list em { white-space: normal; justify-self: start; }
body.workspace-compact .compact-legal-basis { margin-top: 14px; }
body.workspace-compact .workspace-meaning { margin: 10px 0 0; }
body.workspace-compact .legal-grid { grid-template-columns: 145px minmax(0,1fr); line-height: 1.5; }
body.workspace-compact .legal-grid>span { overflow-wrap: break-word; }
body.workspace-compact .summary-actions { gap: 8px; }
body.workspace-compact .summary-actions .button { flex: none; }
body.workspace-compact #summary .result-benefits-visible { grid-row: auto!important; }
body.workspace-compact .workspace-global-actions:has(#calculateAll[hidden]),
body.workspace-compact.workspace-single-editing .workspace-global-actions { display: none; }

/* Account lists: stable number/amount columns, safe wrapping of identifiers. */
body.workspace-compact .money-row { grid-template-columns: 20px 22px minmax(0,1fr) 40px; }
body.workspace-compact .money-row>input[type=text] { font-weight: 650; }
body.workspace-compact .money-row>.button { padding: 8px; min-width: 0; }
body.workspace-compact .bank-account-table { table-layout: fixed; }
body.workspace-compact .bank-account-table th:first-child { width: 32px; }
body.workspace-compact .bank-account-table :is(td,th) { vertical-align: top; overflow-wrap: anywhere; }
body.workspace-compact .bank-account-table :is(td,th):last-child { width: 35%; }
body.workspace-compact .bank-express-copy textarea { height: auto; min-height: 64px; }
body.workspace-compact .manual-account-grid { align-items: start; }
body.workspace-compact .manual-account-grid label>span { min-height: 34px; display: flex; align-items: end; }
body.workspace-compact .account-conversion { align-items: start; }
body.workspace-compact .matcap-advisor-fields { align-items: start; }
body.workspace-compact .matcap-advisor-fields label>span { min-height: 38px; display: flex; align-items: end; }
body.workspace-compact .matcap-variants span { grid-template-columns: minmax(0,1fr) auto auto; }
body.workspace-compact .workspace-history[open] { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; }
body.workspace-compact .workspace-history>summary { grid-column: 1/-1; }
body.workspace-compact .workspace-history .workspace-switcher { width: 100%; min-width: 0; max-width: none; margin: 0; }
body.workspace-compact .workspace-history select { width: 100%; max-width: 100%; text-overflow: ellipsis; }
body.workspace-compact .workspace-history .ux-tools-menu { min-width: 0; margin: 0; }
body.workspace-compact .workspace-history .ux-tools-menu[open] { grid-column: 1/-1; }
body.workspace-compact .workspace-history .ux-tools-menu>summary { width: max-content; }
body.workspace-compact .workspace-history .ux-tools-popover { position: static; inset: auto; min-width: 0; width: 100%; margin-top: 8px; padding: 0; border: 0; box-shadow: none; background: none; grid-template-columns: repeat(4,minmax(0,1fr)); }
body.workspace-compact .workspace-history .ux-tools-popover :is(.button,.file-button) { min-width: 0; justify-content: center; text-align: center; }
body.workspace-compact #meaningDialog .ux-meaning-fact { min-width: 0; overflow-wrap: break-word; }

@media(max-width:839px) {
  body.workspace-compact .item-card .fields:not(.trust-fields) { grid-template-columns: minmax(0,1fr)!important; }
  body.workspace-compact .item-card .fields.trust-fields { grid-template-columns: minmax(0,1fr) 132px!important; }
  body.workspace-compact .item-card .fields.trust-fields>.trust-relation { grid-column: 1/-1!important; grid-template-rows: auto auto!important; }
  body.workspace-compact .trust-fields>.trust-relation>.choice-buttons { height: auto!important; }
}
@media(max-width:680px) {
  body.workspace-compact .item-card .fields { grid-template-columns: minmax(0,1fr)!important; }
  body.workspace-compact .item-head { grid-template-columns: minmax(0,1fr); gap: 10px; }
  body.workspace-compact .item-title h3 { font-size: 18px; }
  body.workspace-compact .item-tools { justify-content: start; }
  body.workspace-compact .toolbar .workspace-title-field { min-width: 0; flex-basis: 100%; }
  body.workspace-compact .toolbar #newWorkspace { width: auto; }
  body.workspace-compact .workspace-nav { flex-wrap: wrap; }
  body.workspace-compact .workspace-history[open] { grid-template-columns: minmax(0,1fr); }
  body.workspace-compact .workspace-history .ux-tools-menu { margin-top: 8px; }
  body.workspace-compact .workspace-history .ux-tools-popover { grid-template-columns: repeat(2,minmax(0,1fr)); }
  body.workspace-compact .legal-grid { grid-template-columns: minmax(0,1fr); gap: 4px; }
  body.workspace-compact .legal-grid b:not(:first-child) { margin-top: 8px; }
  body.workspace-compact .matcap-variants span { grid-template-columns: minmax(0,1fr) auto; }
  body.workspace-compact .matcap-variants em { grid-column: 1/-1; }
  body.workspace-compact #summary .summary-actions { width: auto; }
}
@media(max-width:479px) {
  body.workspace-compact .item-card .fields.trust-fields { grid-template-columns: minmax(0,1fr)!important; }
  body.workspace-compact .trust-fields>:is(.trust-principal,.trust-representatives) { grid-template-rows: auto auto!important; }
  body.workspace-compact .trust-fields>.trust-representatives>input { height: 44px!important; }
  body.workspace-compact .manual-account-grid label>span { min-height: 0; }
  body.workspace-compact .choice-buttons.choices-3 { grid-template-columns: minmax(0,1fr); }
}
