/* 1.55: page-specific working space. Common navigation and inbox live elsewhere. */
:is(.work-page,.work-detail-page,.lead-page,.catalog-page,.team-page,.traction-list-page,.traction-new-page,.traction-order-page,.production-line-page,.production-order-page,.party-page,.mail-compose-page,.quick-document-page,.document-new-page,.document-editor-page,.paper-editor-page,.payroll-page) main>header{margin-bottom:10px;gap:12px}
:is(.work-page,.work-detail-page,.lead-page,.catalog-page,.team-page,.traction-list-page,.traction-new-page,.traction-order-page,.production-line-page,.production-order-page,.party-page,.mail-compose-page,.quick-document-page,.document-new-page,.document-editor-page,.paper-editor-page,.payroll-page) main>header p{margin:3px 0 0}
:is(.work-page,.lead-page,.catalog-page,.team-page,.traction-order-page,.production-order-page,.party-page,.mail-compose-page,.quick-document-page) .panel{margin-top:12px;margin-bottom:12px}
.page-back{display:inline-block;margin:0 0 5px;font-size:13px}
.team-page .page-help{margin:4px 0 10px;font-size:13px}
.team-page .page-help[open]{padding:10px 14px;background:#fff;border:1px solid var(--line);border-radius:8px}
.team-page .page-help p{max-width:1100px;margin:8px 0 0}

/* Board controls share one row; expanded creation/settings remain ordinary forms. */
.work-page .work-toolbar{display:flex;gap:8px 12px;align-items:center;flex-wrap:wrap;margin:6px 0 0}
.work-page .work-views{display:flex;gap:3px;align-items:center;flex-wrap:wrap}
.work-page .work-views a{margin:0;padding:8px 10px;border:1px solid transparent;border-radius:7px;color:var(--ink,#25313a);font-size:14px}
.work-page .work-views a:hover,.work-page .work-views a.active{border-color:#d8ca97;background:#fff6d5}
.work-page .task-action-sheet{margin:0;min-width:0}
.work-page .task-action-sheet>summary{padding:8px 12px;background:#fff;border:1px solid var(--line);border-radius:7px;min-height:38px;font-size:14px}
.work-page .task-action-sheet[open]{order:2;flex-basis:100%;padding:12px;background:#fff;border:1px solid var(--line);border-radius:9px}
.work-page .task-action-sheet[open]>summary{display:inline-block;background:#fff8dd}
.work-page .task-action-sheet .grid-form{margin-top:14px;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px 16px}
.work-page .task-action-sheet .grid-form>p{grid-column:1/-1;margin:0}
.work-page .task-action-sheet .grid-form label{margin:0}
.work-page .work-mine-filter{display:flex;align-items:center;gap:8px;margin-left:auto}
.work-page .work-mine-filter label{margin:0;white-space:nowrap}
.work-page .work-mine-filter button{min-height:36px;padding:6px 10px}
.work-page .archive-settings .toolbar{margin-top:12px;align-items:end}
.work-page .archive-settings .toolbar label{max-width:320px;margin:0}
.work-page .board-caption{margin:8px 0 0;font-size:12px}
.work-page .task-board{margin:10px 0 14px;gap:12px;align-items:start}
.work-page .task-board>section{min-width:0}
.work-page .task-board>section>h2,.work-page .task-board>section>h3{margin:0 0 8px}
.work-page .task-card{line-height:1.4}
.work-page #calendar{margin-top:14px}
.work-page #calendar .toolbar{margin-bottom:10px}
.work-page #calendar .toolbar label{max-width:220px;margin:0}
.work-overview-page .overview-filter{gap:8px 12px;margin:8px 0 10px}
.work-overview-page .overview-filter label{margin:0;flex:0 1 240px}
.work-overview-page .overview-filter label:first-child{flex:1 1 300px}
.work-overview-page .overview-filter .check{flex:none}
.work-overview-page .overview-section{margin:12px 0}
.work-overview-page .overview-section>header{margin-bottom:6px}
.work-overview-page .overview-section>header h2{margin:0}
.work-overview-page .overview-section .kanban{gap:10px}
.work-detail-page .task-type-details{margin:8px 0;font-size:14px}
.work-detail-page .task-kind-switch{margin:8px 0;padding:10px 12px}
.work-detail-page main>.panel{margin:10px 0}

/* The lead starts with its conversation, with client and controls alongside it. */
.lead-page .lead-steps{margin:4px 0 8px}
.lead-page .lead-workspace{gap:16px;align-items:start}
.lead-page .lead-workspace>section>.panel:first-child{margin-top:0}
.lead-page .lead-context .panel{padding:12px 14px}
.lead-page .lead-context .customer-card>summary{font-size:14px;line-height:1.45}
.lead-page .lead-context .customer-card .grid-form{grid-template-columns:1fr;gap:6px;margin-top:12px}
.lead-page .lead-context label{margin-bottom:10px}
.lead-page .lead-context .lead-next-step{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 12px}
.lead-page .lead-next-step>h2,.lead-page .lead-next-step>label:has(textarea),.lead-page .lead-next-step>label:has([name=next_action]){grid-column:1/-1}
.lead-page .lead-next-step>label{margin:0;min-width:0}.lead-page .lead-next-step>label:has([name=next_at]){grid-column:1/-1}.lead-page .lead-next-step input,.lead-page .lead-next-step select{min-width:0;max-width:100%}
.lead-page .lead-next-step>button{align-self:end;justify-self:start}
.lead-page .lead-files>.entity-files-panel{border:0;box-shadow:none;padding:10px 0 0;margin:0}
.lead-page .lead-files .entity-files-panel>h2{display:none}
.lead-page .lead-files .file-drop{padding:10px}
.lead-page .lead-context #documents .button{margin:4px 0}

/* Drafting an email deserves the majority of the viewport. */
.mail-compose-page .mail-compose{grid-template-columns:minmax(0,1fr) 340px;gap:18px 24px;padding:18px;margin:0}
.mail-compose-page .mail-compose-addresses{display:grid;grid-template-columns:1fr 1fr;gap:8px 16px}
.mail-compose-page .mail-compose-addresses>label{margin-bottom:0}
.mail-compose-page .mail-compose-addresses>.notice,.mail-compose-page .mail-compose-subject{grid-column:1/-1}
.mail-compose-page .mail-compose-message{display:flex;flex-direction:column;min-width:0}
.mail-compose-page .mail-compose-body{display:flex;flex-direction:column;flex:1;margin:12px 0 10px;min-height:0}
.mail-compose-page .mail-compose-body textarea{flex:1;min-height:330px;font-size:16px;line-height:1.6;padding:14px 16px}
.mail-compose-page .mail-compose-message>.check{margin:0}
.mail-compose-page .mail-compose-context{border-left:1px solid var(--line);padding-left:20px}
.mail-compose-page .mail-compose-context h2{margin:0 0 10px}
.mail-compose-page .mail-compose-attachments{max-height:34dvh;overflow:auto;overflow-wrap:anywhere}
.mail-compose-page .mail-compose-attachments:empty{display:none}
.mail-compose-page .mail-compose-attachments .check{align-items:start;padding:7px 0;margin:0;border-bottom:1px solid #e4e8eb;flex-wrap:wrap;gap:6px}
.mail-compose-page .mail-compose-attachments input{flex:none;margin-top:3px}
.mail-compose-page .mail-compose-context>.muted{margin:6px 0 18px;font-size:12px}
.mail-compose-page .mail-compose .mail-footer{border-top:1px solid var(--line);padding-top:10px;display:flex;align-items:center;gap:14px;justify-content:flex-start}
.mail-compose-page .mail-compose .mail-footer button{margin:0}
.mail-compose-page .mail-compose .mail-footer .editor-error{margin:0}

/* Tables retain their full width and sticky headers; only the lead-in is compacted. */
.catalog-page .queue-filters{margin:6px 0 8px;gap:10px 14px}
.catalog-page .queue-filters label:first-child{max-width:none;flex:1}
.catalog-page .queue-filters input,.catalog-page .queue-filters select{min-height:38px}
.catalog-page main>p{margin:6px 0 10px;font-size:13px}
.catalog-page td p{margin:4px 0;max-width:none}
.catalog-page td small{margin:2px 0}
.catalog-page th,.catalog-page td{padding:10px 12px}
.catalog-page .table-wrap{max-height:calc(100dvh - 235px)}
.traction-list-page .table-wrap,.production-line-page .table-wrap{max-height:calc(100dvh - 170px)}
.traction-list-page td,.production-line-page td{padding:11px 14px}
.traction-new-page .settings-form{max-width:900px;display:grid;grid-template-columns:1fr 1fr;gap:10px 18px;margin-top:12px}
.traction-new-page .settings-form label{margin:0}
.traction-new-page .settings-form label:first-of-type{grid-column:1/-1}
.traction-new-page .settings-form button{justify-self:start;grid-column:1/-1}
.traction-order-page #acceptance-form{margin-top:0}
.traction-order-page #acceptance-form>.form-columns{grid-template-columns:repeat(3,minmax(0,1fr))}
.traction-order-page #acceptance-form>.form-columns>label:first-child{grid-column:span 2}
.traction-order-page .acceptance-fields{margin:10px 0 12px}
.traction-order-page #traction-result>.panel:first-child{margin-top:0}
.traction-order-page .workflow-actions{margin:8px 0 12px}
.production-order-page .two-cols{gap:16px;align-items:start}
.production-order-page .two-cols>section>.panel:first-child{margin-top:0}
.production-order-page .stage-row{margin:8px 0;padding:10px 12px}
.production-order-page .stage-row[open] form{padding-top:10px}
.production-order-page .stage-row label{margin-bottom:10px}
.production-order-page .stage-row textarea{min-height:90px}
.party-page .party-layout{grid-template-columns:300px minmax(0,1fr);gap:16px}
.party-page .party-layout .two-cols{gap:16px}
.party-page .party-layout .panel{padding:14px 16px}
.party-page .party-layout h2{margin-top:0}
.party-page .party-layout h2:not(:first-child){margin-top:18px}
.team-page .team-search{margin-bottom:10px}
.team-page .team-access-card{padding:12px 16px}
.team-page .team-access-card>summary{gap:18px}
.team-page .team-access-card[open]>summary{padding-bottom:12px;margin-bottom:12px}
.payroll-page .payroll-nav{margin:6px 0 10px}
.payroll-page .payroll-nav a{padding:7px 11px}
.payroll-page .payroll-console{padding:8px 12px;gap:12px}
.payroll-page .payroll-console input,.payroll-page .payroll-console select{min-height:36px;padding:6px 9px}
.payroll-page .payroll-console .payroll-filter button{min-height:36px;padding:6px 12px}
.payroll-page .payroll-summary{gap:14px}
.payroll-page .reorder-hint{margin:7px 0}
.payroll-page .timesheet-scroll{max-height:var(--timesheet-height,calc(100dvh - 248px))}

/* Document data and preview begin higher; PDF zoom/placement semantics are unchanged. */
.document-editor-page .editor-header{margin-bottom:8px}
.document-editor-page .editor-header h1{margin:3px 0}
.document-editor-page .editor-toolbar{padding:7px 10px;gap:6px 8px}
.document-editor-page .editor-viewbar{margin:6px 0;gap:12px;position:relative}
.document-editor-page .editor-viewbar>.document-settings[open]{top:100%;right:0}
.document-editor-page .print-workspace{gap:14px!important;margin:6px 0!important}
.document-editor-page .placement-controls{width:280px!important;padding:12px!important}
.document-editor-page .placement-controls fieldset{margin:8px 0;padding:8px 10px}
.document-editor-page .placement-controls label{margin-bottom:9px}
.document-editor-page .placement-controls>p{margin:6px 0 10px}
.paper-editor-page .paper-toolbar{margin:6px 0;padding:7px 10px}
.paper-editor-page .paper-view-tools{margin:5px 0;gap:14px}
.paper-editor-page .paper-controls{padding:12px 14px}
.paper-editor-page .paper-controls>.muted{margin:8px 0}
.quick-document-page #quick-document>.panel{margin:0;padding:16px}
.quick-document-page #quick-document h2{font-size:18px;margin-bottom:12px}
.quick-document-page #quick-document label{margin-bottom:10px}
.quick-document-page #quick-document>.panel>p{margin:6px 0 10px}
.quick-document-page #quick-document .invoice-line{padding:10px 0}
.quick-document-page #quick-document .invoice-footer{padding:12px 18px}

@media(min-width:1200px){
  .work-page:not(.work-overview-page) .task-board{max-height:calc(100dvh - 210px);overflow:auto}
  .work-overview-page .overview-section .task-board,.work-overview-page .overview-section .kanban{max-height:calc(100dvh - 235px);overflow:auto}
  .work-overview-page:has(.overview-section+.overview-section) .overview-section .task-board,.work-overview-page:has(.overview-section+.overview-section) .overview-section .kanban{max-height:calc((100dvh - 285px)/2)}
  .lead-page .lead-workspace{grid-template-columns:minmax(0,1fr) 350px}
  .mail-compose-page .mail-compose{min-height:calc(100dvh - 180px)}
  .traction-order-page .two-cols{grid-template-columns:minmax(0,1.45fr) minmax(350px,1fr);gap:16px}
  .production-order-page .two-cols{grid-template-columns:minmax(0,1.5fr) minmax(340px,1fr)}
}
@media(min-width:1450px){
  .quick-document-page #quick-document{display:grid;grid-template-columns:360px minmax(0,1fr);gap:14px 18px;align-items:start}
  .quick-document-page #quick-document>section:first-of-type{grid-column:1;grid-row:1/3}
  .quick-document-page #quick-document>section:nth-of-type(2),.quick-document-page #quick-document>section:nth-of-type(3){grid-column:2}
  .quick-document-page #quick-document>section:first-of-type .two-cols{grid-template-columns:1fr;gap:0}
  .quick-document-page #quick-document>.invoice-footer{grid-column:1/-1}
}
@media(max-width:1199px){
  .mail-compose-page .mail-compose{grid-template-columns:minmax(0,1fr) 300px;gap:16px}
  .traction-order-page #acceptance-form>.form-columns{grid-template-columns:1fr 1fr}
  .traction-order-page #acceptance-form>.form-columns>label:first-child{grid-column:auto}
  .party-page .party-layout{grid-template-columns:270px minmax(0,1fr)}
  .party-page .party-layout .two-cols{grid-template-columns:1fr}
  .quick-document-page #quick-document>.panel{margin-bottom:12px}
}
@media(max-width:900px){
  .work-page .work-toolbar{gap:8px}
  .work-page .work-views{width:100%;overflow:auto;flex-wrap:nowrap}
  .work-page .work-views a{white-space:nowrap;padding:8px}
  .work-page .work-mine-filter{margin-left:0}
  .work-page .task-action-sheet .grid-form{grid-template-columns:1fr 1fr}
  .work-page .task-board{max-height:none}
  .work-overview-page .overview-filter label{flex:1 1 140px}
  .work-overview-page .overview-filter label:first-child{flex-basis:100%}
  .lead-page .lead-workspace{grid-template-columns:1fr}
  .lead-page .lead-context .lead-next-step{grid-template-columns:1fr 1fr}
  .mail-compose-page .mail-compose{display:block;padding:14px;min-height:0}
  .mail-compose-page .mail-compose-addresses{grid-template-columns:1fr}
  .mail-compose-page .mail-compose-body textarea{min-height:280px}
  .mail-compose-page .mail-compose-context{margin-top:18px;padding:14px 0 0;border-left:0;border-top:1px solid var(--line)}
  .mail-compose-page .mail-compose .mail-footer{margin-top:14px}
  .mail-compose-page .mail-compose-attachments{max-height:45dvh}
  .traction-list-page .table-wrap,.production-line-page .table-wrap,.catalog-page .table-wrap{max-height:70dvh}
  .party-page .party-layout{grid-template-columns:1fr}
  .payroll-page .payroll-summary{flex-wrap:wrap;justify-content:flex-start}
  .payroll-page .timesheet-scroll{max-height:65dvh}
  .document-editor-page .placement-controls{width:auto!important}
  .document-editor-page .editor-viewbar>.document-settings[open]{position:static;width:100%;max-height:none}
  .paper-editor-page .paper-view-tools{justify-content:flex-start}
}
@media(max-width:600px){
  .work-page .task-action-sheet .grid-form,.traction-new-page .settings-form{grid-template-columns:1fr}
  .work-page .task-action-sheet .grid-form>p,.traction-new-page .settings-form label:first-of-type{grid-column:auto}
  .traction-order-page #acceptance-form>.form-columns{grid-template-columns:1fr 1fr}
  .traction-order-page #acceptance-form>.form-columns>label:first-child{grid-column:1/-1}
  .team-page .team-access-card>summary strong{min-width:0}
  .team-page .team-access-card>summary{gap:4px 12px}
  .team-page .team-access-card{padding:12px}
}
@media print{
  .work-page .task-board,.work-overview-page .overview-section .kanban,.catalog-page .table-wrap,.traction-list-page .table-wrap,.production-line-page .table-wrap,.payroll-page .timesheet-scroll{max-height:none!important;overflow:visible!important}
  .quick-document-page #quick-document{display:block}
}
