/* Detail layout: scoped to deal/task cards and the project overview. */
:root :is(.deal-detail-modal,.task-detail-panel) .modal-body{padding:18px 24px}
:root :is(.deal-detail-modal,.task-detail-panel) .modal-head{min-height:60px;padding:12px 24px}
:root :is(.deal-detail-modal,.task-detail-panel) .modal-footer{min-height:58px;padding:10px 24px}
:root :is(.deal-detail-modal,.task-detail-panel) .modal-footer .btn{min-height:36px;padding:7px 13px}
:root :is(.dc-workspace,.tc-compact-layout,.pc-layout){gap:16px}
:root :is(.dc-sidebar,.tc-main,.pc-sidebar){gap:12px}
:root :is(.deal-detail-modal,.task-detail-panel,.pc-layout) .tc-card{padding:var(--ui-card-pad);box-shadow:none}
:root :is(.dc-heading,.tc-heading,.pc-heading) .tc-title-field>.tc-edit{margin:0;padding:4px 0;border:0;background:transparent;box-shadow:none;align-items:center}
:root :is(.dc-heading,.tc-heading,.pc-heading) .tc-title-field .tc-value{line-height:1.35}
:root :is(#app,#modal-root) :is(.dc-heading,.tc-heading,.pc-title) .tc-field.tc-title-field>.tc-edit{padding:4px 0;margin:0;background:transparent;border-color:transparent;box-shadow:none}
:root :is(#app,#modal-root) :is(.dc-heading,.tc-heading,.pc-title) .tc-field.tc-title-field>.tc-edit:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
:root :is(#modal-root,.pc-heading) .tc-title-field .tc-readonly{font-size:var(--fs-3xl);font-weight:650;line-height:1.35;padding:4px 0}
:root :is(.dc-heading,.tc-heading){margin-bottom:12px}
:root :is(.deal-detail-modal,.task-detail-panel,.pc-layout,.pc-heading) .tc-pencil{display:inline-flex;align-items:center;justify-content:center;flex:none;width:24px;height:24px;opacity:.7;line-height:0}
:root :is(.deal-detail-modal,.task-detail-panel,.pc-layout,.pc-heading) .tc-pencil .icon{display:block;width:16px;height:16px}
:root #modal-root .tc-status-control .tc-pencil{display:none}
:root #modal-root .tc-status-control .tc-edit{margin:0}
:root :is(.dc-workspace,.tc-compact-layout,.pc-layout) .tc-section-head{min-height:30px;margin-bottom:10px;gap:8px}
:root :is(.dc-workspace,.tc-compact-layout,.pc-layout) .tc-section-head h3{font-size:var(--fs-md);line-height:1.4}
:root :is(.dc-workspace,.tc-compact-layout,.pc-layout) .tc-section-head .btn{min-height:34px;padding:6px 10px;font-size:var(--fs-xs)}
:root :is(.tc-disclosure,.dc-extra,.pc-extra)>summary{line-height:20px;padding:8px 10px}
:root :is(.tc-compact-layout,.pc-layout) .tc-content{gap:10px}
:root :is(.tc-compact-layout,.pc-layout) .tc-content>.tc-section-head{margin-bottom:0}
:root :is(.tc-disclosure,.dc-extra,.pc-extra)[open]>.tc-field{margin-top:10px}

/* Field labels and values use the same baseline; editors occupy the whole row. */
:root :is(.tc-properties,.dc-properties,.pc-properties)>.tc-field{display:grid;grid-template-columns:100px minmax(0,1fr);align-items:center;gap:10px;padding:6px 0;margin:0;border:0}
:root :is(.tc-properties,.dc-properties,.pc-properties)>.tc-field>.tc-label{margin:0;line-height:1.4}
:root :is(.tc-properties,.dc-properties,.pc-properties)>.tc-field>.tc-edit{align-items:center;min-height:38px}
:root :is(.tc-properties,.dc-properties,.pc-properties)>.tc-field:has(form){grid-template-columns:minmax(0,1fr)}
:root :is(#tc-inline-form,#dc-inline-form,#pc-inline-form){width:100%;box-sizing:border-box;gap:8px;padding:10px;margin:0;border-radius:var(--r-sm)}
:root :is(#tc-inline-form,#dc-inline-form,#pc-inline-form) .field{margin:0;gap:5px}
:root :is(#tc-inline-form,#dc-inline-form,#pc-inline-form) :is(input:not([type=checkbox]):not([type=color]),select,.filter-select-trigger){min-height:38px;height:38px;max-width:100%;font-size:var(--fs-sm);padding-top:7px;padding-bottom:7px}
:root :is(#tc-inline-form,#dc-inline-form,#pc-inline-form) textarea{min-height:96px;line-height:1.5;font-size:var(--fs-md)}
:root :is(#tc-inline-form,#dc-inline-form,#pc-inline-form) .inline-save-hint{margin:2px 0 0;font-size:var(--fs-xs);line-height:1.5;color:var(--muted)}
:root :is(#tc-inline-error,#dc-inline-error,#pc-inline-error,#project-comment-error):empty{display:none}
:root .dc-save-actions{gap:10px;align-items:center;flex-wrap:wrap}
:root .dc-save-actions .deal-save-button{min-height:38px;padding:7px 12px;margin-left:auto}

/* Deal actions sit beside the heading rather than taking a separate full row. */
.dc-card-header{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:20px;row-gap:12px;margin-bottom:16px;padding-bottom:14px;border-bottom:1px solid var(--line)}
.dc-card-header>.dc-heading{grid-column:1;grid-row:1;min-width:0}
.dc-card-header>.dc-heading .tc-heading{margin:0}
.dc-card-header>.dc-toolbar{grid-column:2;grid-row:1;align-self:start;margin:0;padding:4px 0 0;border:0;max-width:420px}
.dc-card-header>.dc-toolbar .deal-detail-actions{justify-content:flex-end}
.dc-card-header>.dc-stage-selector{grid-column:1/-1;grid-row:2;margin:0}
:root .dc-card-header>.dc-heading{margin:0}
:root .dc-card-header .dc-toolbar .btn{min-height:36px;padding:7px 11px;font-size:var(--fs-xs)}
:root .dc-card-header .dc-stage-selector-head{margin-bottom:6px}
:root .dc-summary .tc-label{margin-bottom:5px}
:root .dc-summary .tc-edit{min-height:44px}
:root .dc-workspace .da-compose{padding:var(--ui-card-pad)}
:root .dc-workspace .da-actions{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}
:root .dc-workspace .da-actions .btn{min-height:36px;padding:7px 10px;font-size:var(--fs-xs)}
:root .dc-contact-top{gap:10px}
:root .dc-contact-link{min-height:30px;line-height:1.45;align-items:center}
:root .dc-contact-link>span{overflow-wrap:anywhere;min-width:0}
:root .dc-extra{padding-top:10px;margin-top:10px}
:root .dc-workspace .da-empty{padding:16px}
:root .dc-workspace .da-upcoming:not(:has(.da-upcoming-item)){flex-wrap:wrap;padding:12px 14px}
:root .dc-workspace .da-upcoming:not(:has(.da-upcoming-item)) .tc-section-head{min-height:0;margin:0}

/* Task files and discussion keep their actions aligned without empty footers. */
:root .tc-compact-layout .tc-properties>.tc-disclosure{padding-top:10px;margin-top:6px}
:root .tc-compact-layout .tc-links>summary{margin-bottom:0}
:root .tc-compact-layout .tc-links[open]>summary{margin-bottom:10px}
:root .tc-files .tc-file{gap:8px;padding:8px 0}
:root .tc-file>.text-link{font-size:var(--fs-xs);line-height:1.4;min-height:32px;display:inline-flex;align-items:center}
:root .tc-upload{min-height:32px;border:1px solid var(--line);border-radius:var(--r-sm);padding:5px 9px;line-height:20px}
:root .tc-upload:hover{border-color:var(--accent);background:var(--blue-soft)}
:root .tc-upload:focus-within{outline:2px solid var(--accent);outline-offset:2px}
:root .task-detail-panel #task-comment{margin:10px 0 0}
:root .task-detail-panel #task-comment>.field{margin:0 0 8px}
:root .task-detail-panel .tc-comment-actions{align-items:flex-end;gap:10px}
:root .task-detail-panel .tc-comment-actions .btn{min-height:38px;padding:8px 13px}
:root .task-detail-panel .tc-comment-actions .field{font-size:var(--fs-xs);gap:4px}
:root .task-detail-panel .tc-comment-actions :is(select,.filter-select-trigger){min-height:38px;height:38px}

/* Keep the team separate from essential project fields, particularly on tablets. */
.pc-sidebar{display:grid;align-content:start;min-width:0}
:root .pc-sidebar .pc-properties{display:block}
:root .pc-team-card .project-team-compact{margin:0;padding:0;border:0}
:root .pc-team-card .project-team-group{margin:10px 0 0}
:root .pc-team-card .project-team-group:has(>.muted){display:flex;align-items:center;justify-content:space-between;gap:8px}
:root .pc-team-card .project-team-group:has(>.muted) h4{margin:0}
:root .pc-team-card .project-team-group h4{margin-bottom:6px;line-height:1.4}
:root .pc-team-card .project-team-person{min-height:30px;line-height:1.4}
:root .pc-layout .pc-extra{padding-top:10px;margin-top:8px}
:root .pc-properties>h3{margin:0 0 8px}
:root .pc-simple-tasks .pc-attention{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 12px;padding:10px 0;align-items:center}
:root .pc-simple-tasks .pc-attention>.project-list-title{grid-column:1;grid-row:1/3;font-size:var(--fs-md);line-height:1.45;text-align:left}
:root .pc-simple-tasks .pc-attention>.project-status{grid-column:2;justify-self:end}
:root .pc-simple-tasks .pc-attention>small{grid-column:2;justify-self:end;font-size:var(--fs-xs)}
:root .pc-simple-tasks>.btn{margin-top:10px}
:root .pc-management .project-actions{margin:12px 0 0;gap:8px}

@container crm-form (max-width:900px){
  .dc-card-header{grid-template-columns:minmax(0,1fr);gap:10px}
  .dc-card-header>.dc-toolbar{grid-column:1;grid-row:2;max-width:none;padding:0}
  .dc-card-header>.dc-toolbar .deal-detail-actions{justify-content:flex-start}
  .dc-card-header>.dc-stage-selector{grid-row:3}
}
@container crm-form (max-width:760px){
  :root .tc-compact-layout .tc-properties>.tc-field{display:block;padding:6px 0}
  :root .tc-compact-layout .tc-properties>.tc-field>.tc-label{margin:0 0 5px}
  :root .tc-compact-layout .tc-properties>.tc-field:has(form){grid-column:1/-1}
  :root .dc-workspace{grid-template-columns:minmax(0,1fr);gap:12px}
  :root .dc-sidebar{display:contents}
  :root .dc-sidebar .dc-summary{order:0}
  :root .dc-sidebar .dc-client{order:1}
  :root .dc-journal{order:2}
  :root .dc-sidebar .dc-properties{order:3}
  :root .dc-sidebar .dc-agreements{order:4}
}
@media(max-width:1050px){
  :root .pc-layout{grid-template-columns:minmax(0,1fr)}
  .pc-sidebar{display:contents}
  :root .pc-sidebar .pc-properties{order:0;grid-row:auto;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 16px}
  :root .pc-sidebar .pc-properties>h3,:root .pc-sidebar .pc-properties>.pc-extra{grid-column:1/-1}
  :root .pc-sidebar .pc-properties>.tc-field{display:block;padding:0}
  :root .pc-sidebar .pc-properties>.tc-field>.tc-label{margin:0 0 5px}
  :root .pc-layout>.tc-main{order:1}
  :root .pc-team-card{order:2}
  :root .pc-team-card .project-team-compact{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px 20px}
  :root .pc-team-card .tc-section-head{grid-column:1/-1;margin:0}
  :root .pc-team-card .project-team-group{margin:0}
}
@media(max-width:650px){
  :root :is(.deal-detail-modal,.task-detail-panel) .modal-body{padding:14px}
  :root :is(.deal-detail-modal,.task-detail-panel) :is(.modal-head,.modal-footer){padding:10px 14px}
  :root :is(.dc-workspace,.tc-compact-layout,.pc-layout){gap:12px}
  :root .pc-team-card .project-team-compact{grid-template-columns:minmax(0,1fr)}
  :root .tc-file .tc-file-title{flex-basis:calc(100% - 32px)}
  :root .tc-file>.work-file-remove{margin-left:auto}
  :root .dc-card-header .dc-stage-selector-head{gap:3px}
}
@media(max-width:420px){
  :root .pc-sidebar .pc-properties{grid-template-columns:minmax(0,1fr)}
  :root .tc-compact-layout .tc-properties{grid-template-columns:minmax(0,1fr)}
}
/* Header without the old toolbar: title, then the key facts, then the stages — one column, full width */
.dc-card-header:not(:has(>.dc-toolbar)){grid-template-columns:minmax(0,1fr)}
.dc-card-header>.dc-facts{grid-column:1/-1;grid-row:2;margin:0}
.dc-card-header:has(>.dc-facts)>.dc-stage-selector{grid-row:3}
