.project-page,
.weekly-planner-page,
.team-schedule-page {
  --task-not-started-bg: #ff7a59;
  --task-not-started-border: #a83215;
  --task-not-started-text: #351208;
  --task-in-progress-bg: #3dbdf6;
  --task-in-progress-border: #0875a7;
  --task-in-progress-text: #082634;
  --task-complete-bg: #17b2a6;
  --task-complete-border: #08786f;
  --task-complete-text: #062c29;
  --task-legacy-bg: #e3e6e8;
  --task-legacy-border: #6b737a;
  --task-legacy-text: #252a2e;
  --task-overlap: #b42318;
}
.project-page .task-status-not-started,
.weekly-planner-page .task-status-not-started,
.team-schedule-page .task-status-not-started { border-color: var(--task-not-started-border); background-color: var(--task-not-started-bg); color: var(--task-not-started-text); }
.project-page .task-status-in-progress,
.weekly-planner-page .task-status-in-progress,
.team-schedule-page .task-status-in-progress { border-color: var(--task-in-progress-border); background-color: var(--task-in-progress-bg); color: var(--task-in-progress-text); }
.project-page .task-status-complete,
.weekly-planner-page .task-status-complete,
.team-schedule-page .task-status-complete { border-color: var(--task-complete-border); background-color: var(--task-complete-bg); color: var(--task-complete-text); }
.project-page .task-status-legacy,
.weekly-planner-page .task-status-legacy,
.team-schedule-page .task-status-legacy { border-color: var(--task-legacy-border); border-style: dashed; background-color: var(--task-legacy-bg); color: var(--task-legacy-text); }
.task-status-badge { display: inline-block; width: max-content; max-width: 100%; padding: .12rem .28rem; overflow: hidden; border: 1px solid; border-radius: 3px; font-size: .6rem; font-weight: 800; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }

/* Compact renovation Project create/edit form. */
.project-form-page { padding-top: 1.25rem; }
.project-create-page { max-width: 760px; }
.project-create-page > .back-link { margin-bottom: .55rem; }
.project-form-heading { margin-bottom: .75rem; }
.project-form-heading h1 { margin-bottom: .18rem; font-size: clamp(1.45rem, 3vw, 1.9rem); }
.project-form-heading .eyebrow { margin-bottom: .2rem; }
.project-form-heading .muted { margin-bottom: 0; font-size: .8rem; }
.project-form-compact { padding: .8rem; box-shadow: none; }
.project-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem .7rem; }
.project-form-grid label { min-width: 0; }
.project-form-grid label > span { margin-bottom: .2rem; font-size: .72rem; }
.project-form-grid input,
.project-form-grid select,
.project-form-grid textarea { min-height: 36px; padding: .42rem .55rem; }
.project-form-grid .money-input span { padding-left: .55rem; }
.project-form-grid .money-input input { min-height: 34px; }
.project-form-wide { grid-column: 1 / -1; }
.project-notes-field textarea { min-height: 68px; max-height: 180px; }
.project-form-actions { margin-top: .65rem; padding-top: .6rem; border-top: 1px solid var(--line); gap: .4rem; }
.project-form-actions .button { min-height: 36px; padding: .42rem .75rem; }
.project-source-options { margin-bottom: .65rem; }

@media (max-width: 620px) {
  .project-form-page { padding-top: 1rem; }
  .project-form-grid { grid-template-columns: minmax(0, 1fr); }
  .project-form-wide { grid-column: 1; }
}

/* Corrective rendered-UI pass: final selectors intentionally sit last in the cascade. */
.templates-page .template-structure { min-width: 0; }
.templates-page .template-structure > .bulk-toolbar,
.templates-page .template-stage-body > .bulk-toolbar,
.templates-page .template-task-body > .bulk-toolbar {
  min-height: 21px;
  margin: 1px 0;
  padding: 1px 3px;
  gap: 2px;
  line-height: 1;
}
.templates-page .bulk-toolbar .button,
.templates-page .template-row-actions .button,
.templates-page .template-material-row > .template-row-editor > summary.button,
.templates-page .template-add-control > summary.button {
  min-height: 20px;
  padding: 1px 5px;
  font-size: .61rem;
  line-height: 1;
}
.templates-page .bulk-selected-count { min-width: 56px; font-size: .61rem; }
.templates-page .bulk-toolbar-actions select { min-height: 20px; padding-block: 0; }
.templates-page .template-stage-list { gap: 2px; }
.templates-page .template-stage-header { min-height: 24px; padding: 1px 4px; }
.templates-page .template-stage-header .template-row-identity { font-size: .78rem; }
.templates-page .template-stage-body { padding: 1px 2px 2px 5px; }
.templates-page .template-task-list { gap: 0; margin-left: 4px; }
.templates-page .template-task-header { min-height: 22px; padding: 1px 2px 1px 5px; }
.templates-page .template-task-header .template-row-identity { font-size: .72rem; line-height: 1; }
.templates-page .template-row-identity small { font-size: .61rem; }
.templates-page .template-task-body { gap: 0; margin-left: 6px; padding: 0 1px 1px 4px; }
.templates-page .template-material-row { min-height: 22px; gap: 3px; padding: 0 1px 0 4px; }
.templates-page .template-material-data { font-size: .67rem; line-height: 1; }
.templates-page .template-add-control { margin-top: 1px; }
.templates-page .template-task-body > .template-add-control,
.templates-page .template-stage-body > .template-add-control { margin-left: 2px; }

.task-materials-dialog .task-material-editor[open] {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
  padding: 3px 0 4px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.task-materials-dialog .task-material-editor[open] > summary { justify-self: end; margin-bottom: 3px; }
.task-materials-dialog .task-material-editor-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 4px;
}
.task-materials-dialog .task-material-edit-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 3px;
  width: 100%;
  margin: 0;
}
.task-materials-dialog .task-material-edit-form label {
  display: grid;
  min-width: 0;
  gap: 1px;
  color: var(--muted);
  font-size: .61rem;
  font-weight: 700;
}
.task-materials-dialog .task-material-edit-form input,
.task-materials-dialog .task-material-edit-form select {
  min-width: 0;
  min-height: 27px;
  padding: 2px 4px;
  font-size: .69rem;
}
.task-materials-dialog .task-material-edit-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.task-materials-dialog .task-material-remove-form { margin: 0; }
.task-materials-dialog .task-material-add-section {
  margin-top: 8px;
  padding-top: 5px;
  border-top: 2px solid var(--line);
  background: color-mix(in srgb, var(--color-subtle) 45%, transparent);
}
.task-materials-dialog .task-material-add-section > h3 { margin: 0 0 3px; font-size: .72rem; }
.task-materials-dialog .task-material-procurement-form {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 3px;
  margin: 0;
}
.task-materials-dialog .task-material-procurement-form .procurement-notes { grid-column: 1 / 6; }
.task-materials-dialog .task-material-procurement-form .procurement-submit { grid-column: 6; align-self: end; }
.task-materials-dialog .task-material-procurement-form textarea { min-height: 31px; max-height: 48px; }

.schedule-tasks-workspace .integrated-schedule,
.integrated-schedule {
  --integrated-day-width: 42px;
  grid-template-columns: minmax(700px, .9fr) repeat(var(--schedule-days), var(--integrated-day-width));
}
.integrated-schedule > .schedule-date,
.integrated-stage-cell,
.integrated-task-cell,
.integrated-add-task-cell { min-width: var(--integrated-day-width); }
.integrated-task-cell { min-height: 42px; }
.integrated-task-cell.has-task { height: 36px; min-height: 36px; margin-top: 3px; }
.integrated-task-segment {
  width: calc(var(--span) * var(--integrated-day-width));
  min-width: var(--integrated-day-width);
}
.integrated-task-segment .schedule-task-body { padding: 3px 8px; font-size: .62rem; line-height: 1.08; }
.integrated-task-segment .schedule-task-body strong { font-size: .66rem; line-height: 1.08; }
.integrated-task-segment .schedule-task-body span { display: block; margin-top: 2px; font-size: .56rem; line-height: 1.05; opacity: .82; }
.integrated-schedule > .schedule-date .today-label { padding-inline: 3px; font-size: .48rem; }

@media (max-width: 820px) {
  .task-materials-dialog .task-material-edit-form,
  .task-materials-dialog .task-material-procurement-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-materials-dialog .task-material-edit-actions,
  .task-materials-dialog .task-material-procurement-form .procurement-notes,
  .task-materials-dialog .task-material-procurement-form .procurement-submit { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .task-materials-dialog .task-material-editor-body,
  .task-materials-dialog .task-material-edit-form,
  .task-materials-dialog .task-material-procurement-form { grid-template-columns: minmax(0, 1fr); }
  .task-materials-dialog .task-material-edit-actions,
  .task-materials-dialog .task-material-procurement-form .procurement-notes,
  .task-materials-dialog .task-material-procurement-form .procurement-submit { grid-column: 1; }
}

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  .materials-page-header .button-row,
  .materials-controls,
  .materials-cost-summary,
  .materials-list,
  .bulk-toolbar { display: none !important; }
  .materials-page-header { margin-bottom: 3mm; padding-bottom: 2mm; }
  .materials-page-header h1 { margin: 0; font-size: 15pt; }
  .materials-print-meta { grid-template-columns: repeat(5, 1fr); margin-bottom: 3mm; }
  .materials-print-meta > div { padding: 1.2mm 2mm; }
  .items-print-table { display: table !important; width: 100%; border-collapse: collapse; table-layout: fixed; color: #000; font-size: 6.8pt; line-height: 1.15; }
  .items-print-table thead { display: table-header-group; }
  .items-print-table tr { break-inside: avoid; }
  .items-print-table th,
  .items-print-table td { padding: 1mm 1.1mm; border: .25mm solid #999; vertical-align: top; overflow-wrap: anywhere; }
  .items-print-table th { border-color: #555; background: #e8e8e8 !important; font-weight: 800; text-align: left; }
  .items-print-table th:nth-child(1) { width: 17%; }
  .items-print-table th:nth-child(2) { width: 12%; }
  .items-print-table th:nth-child(3),
  .items-print-table th:nth-child(4) { width: 10%; }
  .items-print-table th:nth-child(5) { width: 5%; }
  .items-print-table th:nth-child(6) { width: 5%; }
  .items-print-table th:nth-child(7) { width: 8%; }
  .items-print-table th:nth-child(8) { width: 10%; }
  .items-print-table th:nth-child(9) { width: 8%; }
  .items-print-table th:nth-child(10),
  .items-print-table th:nth-child(11) { width: 7.5%; text-align: right; }
  .items-print-table .currency { text-align: right; white-space: nowrap; }
}

/* Projects portfolio dashboard */
.projects-portfolio-page { max-width: 1500px; }
.projects-portfolio-page .portfolio-heading { margin-bottom: .7rem; }
.projects-portfolio-page .portfolio-heading > div:first-child > p:last-child { margin: .2rem 0 0; color: var(--muted); font-size: .82rem; }
.portfolio-filters { display: flex; align-items: end; gap: .55rem; margin-bottom: .85rem; padding: .55rem .65rem; border: 1px solid var(--line); background: var(--surface); }
.portfolio-filters label { display: grid; grid-template-columns: auto minmax(150px, 220px); align-items: center; gap: .4rem; font-size: .72rem; font-weight: 750; }
.portfolio-filters select { min-height: 34px; padding: .35rem .55rem; font-size: .78rem; }
.portfolio-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: .45rem; }
.portfolio-section-heading h2 { margin: 0; font-size: 1rem; letter-spacing: 0; text-transform: none; }
.portfolio-section-heading .eyebrow { margin-bottom: .12rem; }
.portfolio-section-heading > p, .portfolio-section-heading > span, .portfolio-section-heading > a { margin: 0; color: var(--muted); font-size: .74rem; }
.portfolio-kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .45rem; margin: 0 0 .75rem; }
.portfolio-kpi-grid > div { min-width: 0; padding: .62rem .68rem; border: 1px solid var(--line); border-top: 3px solid var(--brand-teal); background: var(--surface); }
.portfolio-kpi-grid dt { color: var(--muted); font-size: .64rem; font-weight: 750; letter-spacing: .035em; text-transform: uppercase; }
.portfolio-kpi-grid dd { margin: .2rem 0 .12rem; font-size: 1.05rem; font-weight: 850; overflow-wrap: anywhere; }
.portfolio-kpi-grid small { display: block; color: var(--muted); font-size: .62rem; line-height: 1.25; }
.portfolio-kpi-grid .portfolio-kpi-attention { border-top-color: var(--danger); }
.variance-over { color: var(--danger) !important; }
.variance-under { color: #247047 !important; }
.portfolio-panel { min-width: 0; margin-bottom: .65rem; padding: .65rem .75rem; border: 1px solid var(--line); background: var(--surface); }
.portfolio-project-table { display: grid; border-top: 1px solid var(--line); }
.portfolio-project-entry { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; border-bottom: 1px solid var(--line); }
.portfolio-project-entry:hover { background: color-mix(in srgb, var(--brand-teal) 5%, white); }
.portfolio-project-primary { display: grid; grid-template-columns: minmax(185px, 1.3fr) minmax(560px, 5fr); gap: .7rem; min-width: 0; padding: .48rem .4rem; color: inherit; text-decoration: none; }
.portfolio-project-primary:focus-visible { position: relative; z-index: 2; }
.portfolio-project-identity { display: grid; align-content: start; min-width: 0; }
.portfolio-project-identity > div { display: flex; align-items: center; gap: .35rem; min-width: 0; }
.portfolio-project-identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--brand-navy); }
.portfolio-project-identity .status { flex: 0 0 auto; padding: .12rem .35rem; font-size: .55rem; }
.portfolio-project-identity span, .portfolio-project-identity small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .69rem; }
.portfolio-project-metrics { display: grid; grid-template-columns: repeat(8, minmax(68px, 1fr)); gap: .3rem; margin: 0; min-width: 0; }
.portfolio-project-metrics > div { min-width: 0; padding-left: .4rem; border-left: 1px solid var(--line); }
.portfolio-project-metrics dt { color: var(--muted); font-size: .57rem; font-weight: 750; letter-spacing: .025em; text-transform: uppercase; }
.portfolio-project-metrics dd { margin: .17rem 0 0; font-size: .7rem; font-weight: 780; line-height: 1.2; overflow-wrap: anywhere; }
.portfolio-project-metrics dd small { display: block; color: var(--muted); font-size: .58rem; font-weight: 600; }
.portfolio-project-actions { position: relative; z-index: 2; display: flex; align-items: center; gap: .4rem; padding: .45rem; }
.portfolio-project-actions a { font-size: .68rem; }
.portfolio-empty { padding: 1.25rem; text-align: center; }
.portfolio-empty h3 { margin: 0 0 .25rem; }
.portfolio-empty p { margin: .2rem 0 .65rem; color: var(--muted); }
.portfolio-two-column { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(330px, .75fr); gap: .65rem; }
.portfolio-lower-grid { grid-template-columns: minmax(0, 1fr) minmax(330px, .8fr); }
.task-attention-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); }
.task-attention-group { min-width: 0; padding: .48rem; border-right: 1px solid var(--line); }
.task-attention-group:last-child { border-right: 0; }
.task-attention-group h3 { display: flex; justify-content: space-between; margin: 0 0 .3rem; font-size: .68rem; text-transform: uppercase; }
.task-attention-group h3 span { display: grid; place-items: center; min-width: 19px; height: 19px; border-radius: 99px; background: var(--color-subtle); }
.task-attention-overdue h3 { color: var(--danger); }
.task-attention-group ul { display: grid; gap: .2rem; margin: 0; padding: 0; list-style: none; }
.task-attention-group li a { display: grid; padding: .28rem .3rem; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.task-attention-group li:first-child a { border-top: 0; }
.task-attention-group li a:hover { background: var(--color-subtle); }
.task-attention-group strong, .task-attention-group span, .task-attention-group small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-attention-group strong { font-size: .7rem; }
.task-attention-group span, .task-attention-group small, .task-attention-group > p { margin: 0; color: var(--muted); font-size: .61rem; }
.task-attention-more { display: block; margin-top: .35rem; font-size: .65rem; }
.portfolio-material-statuses { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; margin-bottom: .5rem; }
.portfolio-material-statuses a { display: flex; justify-content: space-between; gap: .4rem; padding: .4rem .45rem; border: 1px solid var(--line); color: inherit; text-decoration: none; font-size: .69rem; }
.portfolio-material-statuses a:hover { border-color: var(--brand-teal); background: color-mix(in srgb, var(--brand-teal) 5%, white); }
.portfolio-summary-list { display: grid; margin: 0; }
.portfolio-summary-list > div { display: flex; justify-content: space-between; gap: 1rem; padding: .38rem .1rem; border-top: 1px solid var(--line); }
.portfolio-summary-list dt { color: var(--muted); font-size: .69rem; }
.portfolio-summary-list dd { margin: 0; text-align: right; font-size: .76rem; font-weight: 800; }
.portfolio-summary-list dd small { display: block; color: var(--muted); font-size: .6rem; }
.portfolio-note, .portfolio-callout { margin: .45rem 0 0; color: var(--muted); font-size: .64rem; }
.portfolio-callout { margin: 0 0 .45rem; padding: .38rem .5rem; border-left: 3px solid var(--brand-teal); background: var(--color-subtle); }
.portfolio-financial-list > div:last-child { border-top: 2px solid var(--brand-navy); }
.portfolio-activity-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.portfolio-activity-list li { display: grid; grid-template-columns: 120px minmax(120px, .7fr) minmax(180px, 1.5fr); gap: .45rem; padding: .38rem .1rem; border-top: 1px solid var(--line); font-size: .68rem; }
.portfolio-activity-list li:first-child { border-top: 0; }
.portfolio-activity-list time { color: var(--muted); font-size: .61rem; }
.portfolio-activity-list p { margin: 0; }
.portfolio-empty-line { margin: .6rem 0; color: var(--muted); font-size: .72rem; }
.portfolio-secondary-schedule { padding: 0; }
.portfolio-primary-schedule { border-top: 3px solid var(--brand-teal); }
.portfolio-secondary-schedule > details > summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem .75rem; cursor: pointer; list-style: none; }
.portfolio-secondary-schedule > details > summary span:first-child { display: grid; }
.portfolio-secondary-schedule > details > summary small { color: var(--muted); font-size: .65rem; font-weight: 500; }
.portfolio-secondary-schedule-body { padding: 0 .75rem .75rem; border-top: 1px solid var(--line); }
.portfolio-schedule-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem 0; }
.portfolio-schedule-toolbar p { margin: 0; color: var(--muted); font-size: .7rem; }
.portfolio-schedule-region + .portfolio-schedule-region { margin-top: .75rem; }
.portfolio-schedule-region h3 { margin: 0 0 .35rem; font-size: .72rem; }
@media (max-width: 1250px) {
  .portfolio-kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .portfolio-project-primary { grid-template-columns: minmax(180px, .8fr) minmax(0, 3fr); }
  .portfolio-project-metrics { grid-template-columns: repeat(4, minmax(90px, 1fr)); gap: .35rem .25rem; }
  .portfolio-two-column { grid-template-columns: 1fr; }
  .portfolio-lower-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .portfolio-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .portfolio-filters { flex-wrap: wrap; }
  .portfolio-filters label { grid-template-columns: 1fr; }
  .portfolio-lower-grid { grid-template-columns: 1fr; }
  .task-attention-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-attention-group:nth-child(2) { border-right: 0; }
  .task-attention-group:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .portfolio-project-entry { grid-template-columns: minmax(0, 1fr); }
  .portfolio-project-primary { grid-template-columns: 1fr; gap: .35rem; }
  .portfolio-project-actions { padding-top: 0; }
  .portfolio-project-metrics > div:first-child { border-left: 0; }
  .portfolio-schedule-toolbar { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 650px) {
  .portfolio-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portfolio-project-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portfolio-filters > * { flex: 1 1 100%; }
  .portfolio-material-statuses { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-attention-grid { grid-template-columns: 1fr; }
  .task-attention-group { border-right: 0; border-bottom: 1px solid var(--line); }
  .task-attention-group:last-child { border-bottom: 0; }
  .portfolio-activity-list li { grid-template-columns: 1fr; gap: .1rem; }
}

.portfolio-heading { margin-bottom: .45rem; }
.portfolio-heading h1 { margin-bottom: 0; }
.portfolio-kpi-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0 0 .55rem; border: 1px solid var(--line); background: var(--surface); }
.portfolio-kpi-row > div { padding: .45rem .6rem; border-right: 1px solid var(--line); }
.portfolio-kpi-row > div:last-child { border: 0; }
.portfolio-kpi-row dt { color: var(--muted); font-size: .65rem; text-transform: uppercase; }
.portfolio-kpi-row dd { margin: .12rem 0 0; font-size: .95rem; font-weight: 800; }
.portfolio-schedule { margin-bottom: .55rem; }
.portfolio-team-form { grid-template-columns: minmax(160px, 1fr) minmax(130px, 1fr) auto; margin: 0; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.portfolio-project-list { border: 1px solid var(--line); background: var(--surface); }
.portfolio-project-row { display: grid; grid-template-columns: minmax(190px, 2fr) 105px 110px 110px repeat(3, minmax(90px, 1fr)) 54px; align-items: center; gap: .5rem; min-height: 42px; padding: .35rem .55rem; border-top: 1px solid var(--line); font-size: .73rem; }
.portfolio-project-row:first-child { border: 0; }
.portfolio-project-row > div:first-child { display: grid; min-width: 0; }
.portfolio-project-row small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portfolio-project-head { min-height: 30px; background: var(--color-subtle); color: var(--muted); font-size: .63rem; text-transform: uppercase; }

.schedule-scroll-shell { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-gutter: stable; }
.schedule-scroll-shell .schedule-frozen-pane { position: sticky; left: 0; box-shadow: 1px 0 0 var(--line); }
.schedule-grid-shell { display: grid; grid-template-columns: 150px minmax(900px, 1fr); max-width: 100%; margin-top: .5rem; overflow-x: auto; border: 1px solid var(--line); }
.schedule-grid-corner, .schedule-member-label { position: sticky; left: 0; z-index: 3; padding: .35rem .5rem; border-right: 1px solid var(--line); background: var(--surface); }
.schedule-grid-corner { top: 0; z-index: 5; background: var(--color-subtle); font-size: .65rem; font-weight: 700; text-transform: uppercase; }
.schedule-member-label { display: grid; align-content: center; min-height: 48px; border-top: 1px solid var(--line); }
.schedule-member-label span { color: var(--muted); font-size: .68rem; }
.schedule-date-grid { display: grid; grid-template-columns: repeat(var(--schedule-days), minmax(44px, 1fr)); min-width: 1232px; }
.schedule-date-header { position: sticky; top: 0; z-index: 4; }
.schedule-date { display: grid; place-items: center; min-width: 44px; padding: .2rem .1rem; border-left: 1px solid var(--line); background: var(--color-subtle); font-size: .6rem; }
.schedule-date span, .schedule-date small { color: var(--muted); }
.schedule-date strong { font-size: .72rem; }
.schedule-date.is-boundary { border-left: 2px solid var(--text, #1f2933); }
.schedule-date.schedule-today, .weekly-day-headings > .schedule-today { background: #d9f2ef; box-shadow: inset 3px 0 #168d84, inset -1px 0 #8bcac5; color: #0a4f4a; font-weight: 800; }
.schedule-cell.schedule-today, .schedule-group-heading-cell.schedule-today, .integrated-stage-cell.schedule-today, .integrated-task-cell.schedule-today, .integrated-add-task-cell.schedule-today, .weekly-date-cell.schedule-today { background-color: #eaf8f6; box-shadow: inset 3px 0 #17b2a6, inset -1px 0 #b7dfdc; }
.schedule-date .today-label { border-radius: 999px; background: #0d6f68; color: #fff; padding: .05rem .2rem; font-size: .5rem; font-weight: 800; letter-spacing: .03em; line-height: 1.25; text-transform: uppercase; }
.schedule-member-track { grid-template-rows: repeat(var(--schedule-lanes, 1), 34px); min-height: calc(var(--schedule-lanes, 1) * 34px + 6px); padding-block: 3px; border-top: 1px solid var(--line); }
.schedule-group-heading { position: sticky; left: 0; z-index: 3; min-height: 26px; padding: .3rem .5rem; border-top: 1px solid var(--line); background: #e7e7e7; font-size: .7rem; font-weight: 800; }
.schedule-group-heading a, .schedule-member-label a, .weekly-row-label a, .materials-group h2 a { color: inherit; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 2px; }
.schedule-group-heading a:hover, .schedule-member-label a:hover, .weekly-row-label a:hover, .materials-group h2 a:hover { text-decoration-color: currentColor; }
.schedule-group-heading a:focus-visible, .schedule-member-label a:focus-visible, .weekly-row-label a:focus-visible, .materials-group h2 a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; text-decoration-color: currentColor; }
.schedule-group-heading-track { min-height: 26px; border-top: 1px solid var(--line); background: #e7e7e7; }
.schedule-group-heading-cell { min-width: 44px; border-left: 1px solid var(--line); }
.schedule-cell { position: relative; z-index: 0; grid-column: var(--day); grid-row: 1 / span var(--schedule-lanes, 1); min-width: 44px; border-left: 1px solid var(--line); }
.schedule-cell.is-weekend, .schedule-date.is-weekend, .integrated-task-cell.is-weekend { background: repeating-linear-gradient(135deg, #f7f7f7, #f7f7f7 4px, #eee 4px, #eee 5px); }
.schedule-cell.is-nonworking, .schedule-date.is-nonworking, .integrated-task-cell.is-nonworking, .integrated-add-task-cell.is-nonworking { background-color: #f2f2f2; background-image: repeating-linear-gradient(135deg, transparent, transparent 5px, rgb(0 0 0 / 4%) 5px, rgb(0 0 0 / 4%) 7px); }
.schedule-add-task { position: absolute; inset: 50% auto auto 50%; z-index: 2; display: grid; place-items: center; width: 20px; height: 20px; padding: 0; transform: translate(-50%, -50%); border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--text); font-size: .82rem; font-weight: 800; line-height: 1; opacity: 0; cursor: pointer; }
.schedule-cell:hover > .schedule-add-task, .schedule-cell:focus-within > .schedule-add-task, .weekly-date-cell:hover > .schedule-add-task, .weekly-date-cell:focus-within > .schedule-add-task, .integrated-add-task-cell:hover > .schedule-add-task, .integrated-add-task-cell:focus-within > .schedule-add-task { opacity: .82; }
.schedule-add-task:hover { opacity: 1 !important; }
.schedule-add-task:focus-visible { opacity: 1 !important; outline: 3px solid var(--focus); outline-offset: 2px; }
.schedule-task-bar { position: relative; min-width: 16px; border: 1px solid var(--task-legacy-border, #6b737a); background-color: var(--task-legacy-bg, #e3e6e8); color: var(--task-legacy-text, #252a2e); }
.schedule-task-body { display: flex; flex-direction: column; justify-content: center; width: 100%; height: 100%; min-width: 0; padding: 3px 8px; overflow: hidden; border: 0; background: transparent; color: inherit; font: inherit; line-height: 1.08; text-align: left; cursor: grab; touch-action: none; }
.schedule-task-bar.is-moving .schedule-task-body { cursor: grabbing; }
.schedule-task-body, .schedule-task-meta { position: relative; z-index: 2; }
.schedule-task-body strong, .schedule-task-body span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schedule-task-bar.has-project-link .schedule-task-body { height: 52%; padding-bottom: 0; }
.schedule-task-meta { display: flex; align-items: baseline; height: 48%; min-width: 0; padding: 0 8px 2px; overflow: hidden; font-size: .9em; line-height: 1; white-space: nowrap; }
.schedule-task-meta a { flex: 0 1 auto; min-width: 0; overflow: hidden; color: inherit; font-weight: 700; text-decoration: underline; text-decoration-color: transparent; text-overflow: ellipsis; }
.schedule-task-meta a:hover, .schedule-task-meta a:focus-visible { text-decoration-color: currentColor; }
.schedule-task-body:focus-visible, .schedule-resize-handle:focus-visible { position: relative; z-index: 4; outline: 3px solid var(--focus, #335f91); outline-offset: 2px; }
.schedule-resize-handle { position: absolute; top: 0; bottom: 0; z-index: 3; width: 7px; min-width: 7px; padding: 0; border: 0; border-inline: 1px solid currentColor; background: color-mix(in srgb, currentColor 32%, transparent); color: inherit; opacity: .38; cursor: ew-resize; touch-action: none; }
.schedule-resize-start { left: 0; }
.schedule-resize-finish { right: 0; }
.schedule-task-bar:hover .schedule-resize-handle, .schedule-resize-handle:hover, .schedule-resize-handle:focus-visible, .schedule-task-bar.is-resizing .schedule-resize-handle { opacity: .9; }
.schedule-segment { z-index: 1; display: block; min-height: 31px; margin: 2px -1px; overflow: hidden; font-size: .6rem; line-height: 1.1; text-decoration: none; }
.continuous-schedule-segment { grid-column: var(--start) / span var(--span); grid-row: var(--lane); min-width: 0; margin: 2px; border-radius: 3px; }
.schedule-segment span, .schedule-segment small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schedule-task-bar.is-late { outline: 2px solid color-mix(in srgb, var(--task-overlap, #b42318) 78%, #5e2b20); outline-offset: -2px; }
.schedule-late-badge, .task-late-badge { display: inline-block; border: 1px solid #8f2f28; border-radius: 3px; background: #fff4f2; color: #8f2f28; font-size: .54rem; font-weight: 800; line-height: 1; text-transform: uppercase; }
.schedule-late-badge { position: absolute; top: 2px; right: 8px; z-index: 4; padding: 2px 3px; }
.task-late-badge { margin-left: .25rem; padding: 2px 4px; vertical-align: middle; }
.schedule-overlap-day { position: absolute; inset-block: 0; left: calc((var(--overlap-column) - 1) * (100% / var(--span))); z-index: 1; width: calc(100% / var(--span)); border-inline: 1px solid var(--task-overlap, #b42318); background: repeating-linear-gradient(135deg, transparent, transparent 4px, rgb(180 35 24 / 36%) 4px, rgb(180 35 24 / 36%) 7px); pointer-events: none; }
.schedule-cell.has-overlap::after, .weekly-date-cell.has-overlap::after, .integrated-task-cell.is-overlap::after { content: ""; position: absolute; inset: 0; z-index: 3; border-inline: 1px solid var(--task-overlap, #b42318); background: repeating-linear-gradient(135deg, transparent, transparent 4px, rgb(180 35 24 / 24%) 4px, rgb(180 35 24 / 24%) 7px); pointer-events: none; }
.overlap-key { display: flex; align-items: center; gap: .35rem; margin: .35rem 0 0; color: var(--muted); font-size: .68rem; }
.overlap-key > span { width: 18px; height: 9px; border: 2px solid var(--task-overlap, #b42318); background: repeating-linear-gradient(135deg, #fff, #fff 3px, #f4c7c3 3px, #f4c7c3 5px); }

.schedule-tasks-workspace { min-width: 0; padding: .55rem; }
.schedule-heading-actions { flex-wrap: wrap; }
.schedule-view-controls { display: inline-flex; align-items: center; gap: .2rem; }
.schedule-view-controls .button { min-height: 26px; }
.schedule-view-controls .is-active { border-color: var(--text); background: var(--color-subtle); font-weight: 800; }
.portfolio-schedule-region { padding-top: .55rem; border-top: 1px solid var(--line); }
.portfolio-schedule-region + .portfolio-schedule-region { margin-top: 2rem; }
.portfolio-schedule-region > h3 { margin: 0; font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; }
.integrated-schedule { display: grid; grid-template-columns: minmax(680px, .85fr) repeat(var(--schedule-days), 34px); max-width: 100%; margin-top: .3rem; overflow-x: auto; border: 1px solid var(--line); }
.integrated-schedule-header { position: sticky; top: 0; left: 0; z-index: 6; padding: .35rem .5rem; background: var(--color-subtle); color: var(--muted); font-size: .62rem; text-transform: uppercase; }
.integrated-schedule > .schedule-date { position: sticky; top: 0; z-index: 5; min-width: 34px; }
.integrated-stage-heading { position: sticky; left: 0; z-index: 4; grid-column: 1; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .7rem; min-height: 32px; padding: .15rem .4rem; border-block: 1px solid var(--line); background: #ececec; }
.integrated-stage-cell { min-width: 34px; min-height: 34px; border-block: 1px solid var(--line); border-left: 1px solid var(--line); background: #ececec; }
.integrated-stage-heading > span { color: var(--muted); font-size: .68rem; }
.stage-heading-actions { display: flex; align-items: center; gap: .15rem; margin-left: auto; }
.stage-heading-actions form { margin: 0; }
.stage-heading-actions .button { min-height: 23px; padding: .12rem .3rem; font-size: .62rem; }
.stage-heading-actions .button[disabled] { cursor: default; opacity: .35; }
.stage-action-error { flex-basis: 100%; margin: 0; font-size: .62rem; }
.stage-name-form { display: grid; gap: .55rem; }
.stage-name-form label { display: grid; gap: .2rem; }
.integrated-task-identity { position: sticky; left: 0; z-index: 3; min-height: 32px; padding: .1rem .35rem; border-top: 1px solid var(--line); background: var(--surface); }
.integrated-task-summary, .integrated-task-column-head { display: grid; grid-template-columns: 18px 18px minmax(118px,1.5fr) minmax(64px,.8fr) 52px 28px 52px 68px 50px 52px minmax(112px,1fr); align-items: center; gap: .16rem; }
.integrated-task-summary { min-height: 27px; font-size: .66rem; }
.integrated-task-column-head { min-height: 22px; font-size: .6rem; line-height: 1; }
.integrated-task-summary > span, .integrated-task-summary > strong, .integrated-task-summary > .task-name-action { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.integrated-task-summary form { margin: 0; }
.task-name-action, .weekly-task-name { min-width: 0; padding: 0; overflow: hidden; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 700; text-align: left; text-decoration: underline; text-decoration-color: transparent; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.task-name-action:hover, .weekly-task-name:hover { text-decoration-color: currentColor; }
.task-name-action:focus-visible, .weekly-task-name:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; text-decoration-color: currentColor; }
.task-check-button { width: 18px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.compact-task-actions { display: flex; align-items: center; gap: .12rem; }
.compact-task-actions button { min-height: 22px; padding: .12rem .24rem; border: 1px solid var(--line); background: var(--surface); color: var(--text, #1f2933); font: inherit; cursor: pointer; }
.integrated-task-identity.is-complete { border-left: 3px solid var(--task-complete-border); }
.integrated-task-identity.is-complete .task-name-action { color: inherit; }
.integrated-task-cell { position: relative; min-width: 34px; min-height: 34px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.integrated-task-cell.has-task { margin-top: 7px; height: 19px; min-height: 19px; border-block: 1px solid var(--task-legacy-border, #6b737a); background-color: var(--task-legacy-bg, #e3e6e8); }
.project-page .integrated-task-cell.task-status-not-started { border-color: var(--task-not-started-border); background-color: var(--task-not-started-bg); }
.project-page .integrated-task-cell.task-status-in-progress { border-color: var(--task-in-progress-border); background-color: var(--task-in-progress-bg); }
.project-page .integrated-task-cell.task-status-complete { border-color: var(--task-complete-border); background-color: var(--task-complete-bg); }
.project-page .integrated-task-cell.task-status-legacy { border-color: var(--task-legacy-border); background-color: var(--task-legacy-bg); }
.integrated-task-segment { position: absolute; inset: 0 auto 0 0; z-index: 2; width: calc(var(--span) * 34px); min-width: 34px; overflow: hidden; border: 0; background: transparent; color: inherit; }
.integrated-task-segment .schedule-task-body { padding: 1px 7px; color: inherit; font-size: .58rem; line-height: 17px; }
.integrated-task-segment .schedule-task-body span { display: none; }
.integrated-task-identity.has-overlap { border-left: 3px solid var(--task-overlap, #b42318); }
.overlap-badge, .past-finish-label { display: inline-block; margin: .1rem 0; color: var(--task-overlap, #b42318); font-size: .62rem; font-weight: 700; }
.past-finish-label { color: var(--task-overlap, #b42318); }
.edit-label { color: var(--muted); font-size: .62rem; }
.integrated-add-task { position: sticky; left: 0; z-index: 3; grid-column: 1; display: flex; align-items: center; gap: .35rem; min-width: 0; min-height: 27px; padding: .12rem .4rem; border-top: 1px solid var(--line); background: var(--surface); font-size: .65rem; }
.integrated-add-task > .integrated-add-task-button { position: static; display: inline-flex; width: auto; height: auto; min-height: 24px; padding: .15rem .45rem; transform: none; border-radius: var(--radius); opacity: 1; }
.integrated-add-task-cell { position: relative; min-width: 34px; min-height: 27px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: var(--surface); }
.task-forecast-value { display: grid; line-height: 1.05; }
.task-forecast-value small { margin-top: .1rem; color: var(--muted); font-size: .55rem; font-weight: 500; white-space: nowrap; }
.archived-tasks-section { padding: .45rem .55rem; }
.archived-tasks-section > details > summary { display: flex; align-items: center; gap: .45rem; cursor: pointer; }
.archived-tasks-section > details > summary h2 { margin: 0; font-size: .85rem; }
.archived-task-list { margin-top: .35rem; border: 1px solid var(--line); }
.archived-task-row { display: grid; grid-template-columns: minmax(220px, 1fr) 100px 90px auto; align-items: center; gap: .5rem; min-height: 38px; padding: .28rem .4rem; border-top: 1px solid var(--line); font-size: .7rem; }
.archived-task-row:first-child { border-top: 0; }
.archived-task-row > div:first-child { display: grid; gap: .08rem; }
.archived-task-row small, .archived-task-row > span { color: var(--muted); }
.archived-task-row form { margin: 0; }
.archived-task-view { position: relative; }
.archived-task-view > summary { list-style: none; cursor: pointer; }
.archived-task-view > div { position: absolute; right: 0; z-index: 5; display: grid; gap: .2rem; width: max-content; min-width: 190px; padding: .4rem .5rem; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 2px 8px rgb(0 0 0 / 8%); }
.project-detail-page .project-trash-dialog { box-sizing: border-box; width: min(760px, calc(100vw - 32px)); max-width: min(760px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 48px)); }
.project-detail-page .project-trash-dialog .app-dialog-panel { grid-template-rows: auto minmax(0, 1fr); width: 100%; max-height: inherit; overflow: hidden; }
.project-detail-page .project-trash-dialog .app-dialog-header { position: sticky; top: 0; z-index: 2; background: var(--surface); }
.project-detail-page .project-trash-dialog .app-dialog-body { min-height: 0; padding: .55rem; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.trash-help { margin: 0 0 .45rem; color: var(--muted); font-size: .7rem; }
.trash-group + .trash-group { margin-top: .7rem; }
.trash-group h3 { margin: 0; padding: .3rem .4rem; border: 1px solid var(--line); background: var(--color-subtle); font-size: .7rem; text-transform: uppercase; }
.trash-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .2rem .55rem; min-height: 38px; padding: .3rem .4rem; border: 1px solid var(--line); border-top: 0; font-size: .68rem; }
.trash-row.bulk-selectable-row { grid-template-columns: 20px minmax(0, 1fr); }
.trash-item-summary { display: grid; gap: .05rem; min-width: 0; overflow-wrap: anywhere; }
.trash-row small { color: var(--muted); }
.trash-item-type { color: var(--text); font-weight: 750; }
.trash-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .2rem; }
.trash-actions form { margin: 0; }
.trash-rule { grid-column: 1 / -1; color: var(--task-overlap, #b42318) !important; }
.trash-actions .button[disabled] { cursor: not-allowed; opacity: .5; }
@media (max-width: 620px) {
  .project-detail-page .project-trash-dialog .trash-row { grid-template-columns: minmax(0, 1fr); }
  .project-detail-page .project-trash-dialog .trash-actions { justify-content: flex-start; }
}
.schedule-workspace-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: .4rem; }
.archived-stages-section { margin-top: .4rem; border-top: 1px solid var(--line); font-size: .7rem; }
.archived-stages-section > summary { display: flex; gap: .35rem; width: max-content; padding: .35rem 0; cursor: pointer; font-weight: 700; }
.archived-stage-list { border: 1px solid var(--line); }
.archived-stage-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 34px; padding: .25rem .4rem; border-top: 1px solid var(--line); }
.archived-stage-row:first-child { border-top: 0; }
.archived-stage-row > span { display: grid; gap: .05rem; }
.archived-stage-row small { color: var(--muted); }
.archived-stage-row form { margin: 0; }
.team-members-panel, .full-team-schedule { margin-bottom: .55rem; }
.compact-team-list { border: 1px solid var(--line); }
.compact-team-row { display: grid; grid-template-columns: minmax(220px, 1fr) auto; align-items: center; gap: .4rem; min-height: 36px; padding: .3rem .45rem; border-top: 1px solid var(--line); }
.compact-team-row:first-child { border-top: 0; }
.compact-team-row > div { display: flex; align-items: baseline; gap: .5rem; }
.compact-team-row span, .compact-task-name span { color: var(--muted); font-size: .68rem; }
.compact-team-list > div { grid-template-columns: minmax(300px, 1fr) auto; }
.compact-team-list details > summary { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(120px, 1fr) 40px; align-items: center; cursor: pointer; list-style: none; }
.compact-team-list details .compact-team-form { margin-top: .25rem; }
.team-quick-schedule-form { grid-template-columns: minmax(220px, 1.5fr) minmax(150px, 1fr) 125px 70px auto; }
.compact-task-name { display: grid; align-content: center; }
.modal-stack-form { display: grid; gap: .55rem; }
.modal-stack-form label { display: grid; gap: .2rem; }
.schedule-tasks-workspace .compact-task-form { grid-template-columns: minmax(170px, 2fr) minmax(135px, 1.4fr) 120px 62px 115px auto; gap: .3rem; margin: .15rem 0; padding: .2rem 0; background: transparent; }
.schedule-tasks-workspace .compact-task-form label { gap: .1rem; font-size: .66rem; }
.schedule-tasks-workspace .compact-task-form input, .schedule-tasks-workspace .compact-task-form select { min-height: 30px; padding: .25rem .35rem; }
.schedule-tasks-workspace .compact-task-form select[multiple] { min-height: 38px; height: 38px; }
.schedule-tasks-workspace .add-task-compact-form { width: 100%; max-width: 680px; grid-template-columns: minmax(145px, 2fr) minmax(110px, 1.25fr) 112px 54px 100px auto; }
.task-edit-dialog .task-edit-form { display: grid; grid-template-columns: minmax(130px, 1.5fr) minmax(100px, 1fr) minmax(125px, 1.2fr) 105px 55px 100px; align-items: end; gap: .3rem; margin: 0; }
.task-edit-dialog .task-edit-form label { display: grid; gap: .1rem; min-width: 0; font-size: .66rem; }
.task-edit-dialog .task-edit-form input, .task-edit-dialog .task-edit-form select { min-height: 30px; padding: .25rem .35rem; }
.task-edit-dialog .task-edit-form select[multiple] { min-height: 38px; height: 38px; }
.task-edit-dialog .task-edit-form .modal-form-actions { grid-column: 1 / -1; }
.schedule-add-task-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: .45rem; }
.schedule-add-task-form label { display: grid; gap: .15rem; min-width: 0; font-size: .68rem; }
.schedule-add-task-form label[hidden] { display: none; }
.schedule-add-task-form input, .schedule-add-task-form select { min-height: 32px; padding: .3rem .4rem; }
.schedule-add-task-form .task-title-field, .schedule-add-task-form .modal-form-actions { grid-column: 1 / -1; }
.schedule-tasks-workspace .task-row-actions { margin: .12rem 0; }
.compact-commercial { padding: .55rem; }
.compact-commercial .commercial-kpi-row { margin-top: .35rem; }
.commercial-table-shell { max-width: 100%; overflow-x: auto; }
.project-detail-page .commercial-table-head,
.project-detail-page .commercial-table-row {
  grid-template-columns: 22px minmax(160px, 1.6fr) minmax(105px, .9fr) minmax(92px, .72fr) minmax(92px, .72fr) minmax(110px, .82fr) minmax(110px, .82fr) minmax(92px, .72fr) 58px;
  min-width: 940px;
  padding: .3rem .4rem;
}
.commercial-table-row { min-height: 34px; }
.project-page { max-width: none; margin: 0; padding: 1rem 20px 3rem; }
.project-detail-page .project-workspace-compact { max-width: none; margin: 0; }
.project-primary-workspace { gap: .5rem; }
.project-detail-page .compact-project-header { margin: 0 0 .4rem; padding: .25rem 0 .45rem; }
.project-detail-page .compact-project-header .back-link { margin-bottom: .1rem; }
.project-detail-page .compact-project-header h1 { font-size: 1.5rem; }
.project-detail-page .project-title-line { gap: .4rem; }
.project-quick-actions { display: flex; flex-wrap: wrap; gap: .35rem; padding: .4rem .5rem; border: 1px solid var(--line); background: var(--surface); }
.project-overview { display: grid; grid-template-columns: minmax(125px, .75fr) minmax(0, 5fr); align-items: stretch; padding: .35rem .5rem; }
.project-overview > header { align-items: center; margin: 0; padding-right: .5rem; border-right: 1px solid var(--line); }
.project-overview > header > div { display: grid; align-content: center; gap: .08rem; }
.project-overview > header > div > span { color: var(--muted); font-size: .65rem; font-weight: 750; }
.project-focus-panel > header { display: flex; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: .35rem; }
.project-overview > header h2, .project-focus-panel > header h2 { margin: 0; }
.project-overview > header .eyebrow, .project-focus-panel > header .eyebrow { margin-bottom: .08rem; }
.project-overview > header > span, .project-focus-panel > header > span { color: var(--muted); font-size: .68rem; font-weight: 750; }
.project-overview-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 0; }
.project-overview-kpis > div { min-width: 0; padding: .22rem .45rem; border-left: 1px solid var(--line); }
.project-overview-kpis dt { color: var(--muted); font-size: .6rem; font-weight: 750; text-transform: uppercase; }
.project-overview-kpis dd { margin: .08rem 0 0; overflow-wrap: anywhere; font-size: .8rem; font-weight: 850; }
.project-overview-kpis dd small { display: block; color: var(--muted); font-size: .58rem; font-weight: 600; }
.project-focus-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.project-focus-alerts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: .35rem; border: 1px solid var(--line); }
.project-focus-alerts > * { display: grid; min-width: 0; padding: .35rem .45rem; border-left: 1px solid var(--line); color: inherit; text-decoration: none; }
.project-focus-alerts > :first-child { border-left: 0; }
.project-focus-alerts strong { font-size: .9rem; }
.project-focus-alerts span { color: var(--muted); font-size: .6rem; }
.project-focus-alerts .has-attention { background: #fff4f2; }
.project-focus-alerts .has-attention strong { color: var(--danger); }
.project-focus-list { display: grid; margin: 0; padding: 0; list-style: none; }
.project-focus-list li { border-top: 1px solid var(--line); }
.project-focus-list button { display: grid; width: 100%; padding: .34rem .2rem; border: 0; background: transparent; color: inherit; text-align: left; }
.project-focus-list button:hover { background: var(--color-subtle); }
.project-focus-list button:focus-visible { outline: 3px solid var(--focus); outline-offset: -2px; }
.project-focus-list strong { font-size: .72rem; }
.project-focus-list span { color: var(--muted); font-size: .62rem; }
.project-focus-list .is-overdue strong { color: var(--danger); }
.project-focus-list .compact-empty { padding: .55rem .2rem; color: var(--muted); font-size: .68rem; }
.project-notes-section > details > summary, .completed-tasks-section > details > summary { cursor: pointer; }
.project-notes-section details > p { margin: .5rem 0; white-space: pre-wrap; font-size: .76rem; line-height: 1.45; }
.notes-summary-state { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .68rem; }
.notes-summary-state small { font-size: .62rem; }
.completed-task-list { display: grid; margin-top: .35rem; border-top: 1px solid var(--line); }
.completed-task-row { display: grid; grid-template-columns: 20px minmax(180px, 1fr) 90px 80px auto; align-items: center; gap: .45rem; min-height: 34px; padding: .25rem .15rem; border-bottom: 1px solid var(--line); font-size: .68rem; }
.completed-task-row > div:nth-child(2) { display: grid; min-width: 0; }
.completed-task-row strong, .completed-task-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.completed-task-row small { color: var(--muted); font-size: .6rem; }
.completed-task-row .button-row { justify-content: flex-end; gap: .2rem; }
.completed-task-row .button { min-height: 28px; padding: .25rem .4rem; font-size: .64rem; }
@media (max-width: 1000px) {
  .project-overview { grid-template-columns: minmax(110px, .65fr) minmax(0, 3fr); }
  .project-overview-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .project-overview-kpis > div:nth-child(n+4) { border-top: 1px solid var(--line); }
  .project-focus-layout { grid-template-columns: 1fr; }
  .completed-task-row { grid-template-columns: 20px minmax(150px, 1fr) 80px auto; }
  .completed-task-row > span:nth-child(4) { display: none; }
}
@media (max-width: 700px) {
  .project-overview { grid-template-columns: 1fr; }
  .project-overview > header { padding: 0 0 .28rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .project-overview > header > div { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; width: 100%; }
  .project-overview-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-overview-kpis > div { border-top: 1px solid var(--line); }
  .project-overview-kpis > div:nth-child(odd) { border-left: 0; }
  .project-focus-alerts { grid-template-columns: 1fr; }
  .project-focus-alerts > * { border-top: 1px solid var(--line); border-left: 0; }
  .project-focus-alerts > :first-child { border-top: 0; }
  .completed-task-row { grid-template-columns: 20px minmax(0, 1fr); }
  .completed-task-row > span:nth-child(3), .completed-task-row > span:nth-child(4) { display: none; }
  .completed-task-row .button-row { grid-column: 2; justify-content: flex-start; }
  .project-detail-page .commercial-table { min-width: 0; }
  .project-detail-page .commercial-table-head { display: none; }
  .project-detail-page .commercial-table-row { grid-template-columns: 22px repeat(2, minmax(0, 1fr)); min-width: 0; gap: .2rem .5rem; padding: .4rem; }
  .project-detail-page .commercial-table-row > .bulk-row-select { grid-column: 1; grid-row: 1 / span 6; align-self: start; }
  .project-detail-page .commercial-table-row > span:nth-child(2),
  .project-detail-page .commercial-table-row > span:nth-child(3),
  .project-detail-page .commercial-table-row > .button-row { grid-column: 2 / -1; }
  .project-detail-page .commercial-table-row > span[data-label] { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .3rem; }
  .project-detail-page .commercial-table-row > span[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .58rem; font-weight: 700; text-transform: uppercase; }
}
.project-source-options { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; padding: .55rem .7rem; border: 1px solid var(--line); }
.project-source-options details { margin-left: auto; }
.project-source-options ul { display: grid; gap: .3rem; min-width: 420px; margin: .4rem 0 0; padding: .4rem; list-style: none; border: 1px solid var(--line); }
.project-source-options li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.project-filters { margin: .45rem 0; }
.schedule-heading-actions { display: flex; align-items: center; gap: .6rem; }
.grouped-schedule .schedule-group-heading { font-size: .68rem; }
.grouped-schedule .schedule-member-label strong { font-size: .72rem; }
.grouped-schedule .schedule-member-label span { font-size: .62rem; }

.app-dialog { width: min(620px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; overflow: hidden; border: 1px solid var(--text, #1f2933); border-radius: var(--radius); background: var(--surface); color: var(--text, #1f2933); }
.app-dialog-wide { width: min(880px, calc(100vw - 2rem)); }
.task-edit-dialog { width: min(780px, calc(100vw - 48px)); }
.task-edit-context { margin: 0 0 .45rem; color: var(--muted); font-size: .72rem; }
.app-dialog.app-dialog-fallback[open] { position: fixed; inset: 0; z-index: 1000; display: block; margin: auto; }
.app-dialog::backdrop { background: rgb(0 0 0 / 42%); }
.app-dialog-panel { display: grid; max-height: calc(100vh - 2rem); }
.app-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .65rem .75rem; border-bottom: 1px solid var(--line); }
.app-dialog-header h2 { margin: 0; font-size: 1rem; }
.app-dialog-body { padding: .75rem; overflow: auto; }
.modal-form-actions { display: flex; align-items: center; justify-content: flex-end; gap: .35rem; }
.modal-danger-action { margin-top: .65rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.task-cost-form { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .55rem; }
.task-cost-form label, .material-add-form label, .other-cost-form label { display: grid; gap: .2rem; min-width: 0; }
.task-cost-form .span-all { grid-column: 1 / -1; }
.task-cost-result { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem .55rem; border: 1px solid var(--line); background: var(--color-subtle); }
.advanced-link { display: inline-block; margin-top: .55rem; font-size: .75rem; }
.task-material-list { border: 1px solid var(--line); }
.task-material-head, .task-material-row { display: grid; grid-template-columns: minmax(125px,1.3fr) minmax(80px,.7fr) 48px 48px 70px minmax(135px,1fr) 68px 68px 44px; align-items: center; gap: .2rem; min-height: 30px; padding: .16rem .25rem; border-top: 1px solid var(--line); font-size: .68rem; }
.task-material-head { min-height: 26px; border-top: 0; background: var(--color-subtle); color: var(--muted); font-size: .62rem; text-transform: uppercase; }
.task-material-row.is-purchased > strong { color: var(--muted); text-decoration: line-through; }
.task-material-row form { margin: 0; }
.task-material-row details { position: relative; }
.material-inline-form { display: grid; grid-template-columns: repeat(4,minmax(110px,1fr)); gap: .22rem; margin-top: .25rem; }
.material-add-form { display: grid; grid-template-columns: repeat(4,minmax(110px,1fr)); align-items: end; gap: .3rem; margin-top: .4rem; }
.material-procurement-form .span-all { grid-column: 1 / -1; }
.material-procurement-form .modal-form-actions { grid-column: 1 / -1; }
.compact-material-status { display: flex; align-items: center; gap: .15rem; }
.compact-material-status select { min-width: 0; padding: .18rem .24rem; font-size: .67rem; }
.material-unit-control { display: flex; min-width: 0; gap: .2rem; }
.material-unit-control select, .material-unit-control input { min-width: 0; }
.material-custom-unit { flex: 1 1 90px; }
.material-custom-unit[hidden] { display: none; }
.material-filter { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .55rem; }
.project-material-groups { display: grid; gap: .65rem; }
.project-material-groups section { border: 1px solid var(--line); }
.project-material-groups h3 { margin: 0; padding: .3rem .45rem; background: var(--color-subtle); font-size: .76rem; }
.project-material-row { display: grid; grid-template-columns: 18px minmax(145px,1fr) minmax(130px,1.25fr) 80px minmax(100px,.8fr) 75px 75px minmax(110px,1fr) 90px; align-items: center; gap: .3rem; padding: .24rem .38rem; border-top: 1px solid var(--line); font-size: .7rem; }
.project-material-summary, .materials-cost-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); margin: 0 0 .45rem; border: 1px solid var(--line); background: var(--surface); }
.project-material-summary > div, .materials-cost-summary > div { padding: .3rem .42rem; border-right: 1px solid var(--line); }
.project-material-summary dt, .materials-cost-summary dt { color: var(--muted); font-size: .59rem; font-weight: 700; text-transform: uppercase; }
.project-material-summary dd, .materials-cost-summary dd { margin: .05rem 0 0; font-size: .78rem; font-weight: 800; }
.project-material-summary > p, .materials-cost-summary > p { grid-column: 1 / -1; margin: 0; padding: .2rem .42rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .62rem; }

/* Materials checklist: keep filter contrast independent of undefined project variables. */
.material-filter .button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}
.material-filter .button.is-active {
  border-color: var(--text);
  background: var(--text);
  color: var(--surface);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.material-filter-marker { margin-right: .25rem; font-weight: 900; }
.material-filter .button:focus-visible,
.project-material-actions .button:focus-visible,
.materials-controls :focus-visible,
.materials-status-form :focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 2px;
}
.project-material-actions { display: flex; flex-wrap: wrap; gap: .35rem; margin: -.15rem 0 .6rem; }
.project-material-row form { margin: 0; }
.project-material-row form button,
.materials-purchase-form button {
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.project-material-row.is-purchased strong { color: var(--muted); text-decoration: line-through; }

.materials-workspace { width: min(1440px, 100%); }
.materials-page { width: 100%; }
.materials-page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .6rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--line);
}
.materials-page-header h1 { margin: .05rem 0 0; font-size: 1.5rem; }
.materials-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(5, minmax(110px, .8fr)) auto;
  align-items: end;
  gap: .4rem;
  margin-bottom: .65rem;
  padding: .55rem;
  border: 1px solid var(--line);
  background: var(--surface);
}
.materials-controls label { display: grid; gap: .18rem; color: var(--muted); font-size: .68rem; font-weight: 700; }
.materials-controls select { min-width: 0; padding: .4rem .45rem; color: var(--text); background: var(--surface); }
.materials-controls select[multiple] { min-height: 5.6rem; padding: .2rem; }
.materials-cost-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.materials-total-guidance { font-weight: 650; }
.materials-print-meta {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0 0 .65rem;
  border: 1px solid var(--line);
  background: var(--surface);
}
.materials-print-meta > div { padding: .35rem .5rem; border-right: 1px solid var(--line); }
.materials-print-meta > div:last-child { border-right: 0; }
.materials-print-meta dt { color: var(--muted); font-size: .6rem; font-weight: 700; text-transform: uppercase; }
.materials-print-meta dd { margin: .08rem 0 0; font-size: .72rem; font-weight: 700; }
.materials-list { display: grid; gap: .6rem; }
.materials-group { overflow-x: auto; break-inside: avoid; border: 1px solid var(--line); background: var(--surface); }
.materials-group h2 { margin: 0; padding: .36rem .5rem; border-bottom: 1px solid var(--line); background: var(--color-subtle); font-size: .82rem; }
.materials-row {
  display: grid;
  grid-template-columns: 22px minmax(105px,.85fr) minmax(130px,1.3fr) minmax(80px,.65fr) 56px 50px 82px minmax(95px,.8fr) 72px 72px minmax(105px,.9fr) minmax(85px,.75fr) minmax(105px,.9fr) 44px;
  align-items: center;
  gap: .4rem;
  min-height: 36px;
  padding: .28rem .45rem;
  border-top: 1px solid var(--line);
  font-size: .72rem;
}
.materials-row-head { min-height: 27px; border-top: 0; color: var(--muted); font-size: .6rem; font-weight: 700; text-transform: uppercase; }
.materials-row a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.materials-row.is-purchased > strong { color: var(--muted); text-decoration: line-through; }
.materials-status-form { display: flex; align-items: center; gap: .12rem; margin: 0; }
.materials-status-form select { width: 100%; min-width: 0; padding: .18rem .2rem; font-size: .65rem; }
.materials-status-form .button { min-width: 26px; padding: .16rem .2rem; font-size: .6rem; }
.materials-print-state { display: none; }
.materials-open-action { font-size: .67rem; }
.materials-procurement-edit { position: relative; }
.materials-procurement-edit > summary { list-style: none; cursor: pointer; }
.materials-procurement-edit > summary::-webkit-details-marker { display: none; }
.materials-procurement-edit > form { position: absolute; z-index: 25; top: calc(100% + .15rem); right: 0; display: grid; grid-template-columns: repeat(4,minmax(120px,1fr)); gap: .25rem; width: min(760px,calc(100vw - 48px)); padding: .4rem; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.materials-procurement-edit label { display: grid; gap: .12rem; color: var(--muted); font-size: .63rem; font-weight: 700; }
.materials-procurement-edit .span-all { grid-column: 1 / -1; }
.materials-empty-state { padding: 1.5rem; border: 1px dashed var(--line); text-align: center; }
.materials-empty-state p { margin: 0 0 .45rem; }

@media (max-width: 1050px) {
  .materials-controls { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .materials-row { grid-template-columns: 20px minmax(100px,.8fr) minmax(125px,1.3fr) minmax(72px,.6fr) 52px 48px 76px minmax(90px,.8fr) 68px 68px minmax(95px,.9fr) minmax(80px,.7fr) minmax(95px,.9fr) 40px; min-width: 1120px; }
}

@media (max-width: 760px) {
  .materials-page-header { align-items: stretch; flex-direction: column; }
  .materials-page-header .button-row { flex-wrap: wrap; justify-content: flex-end; }
  .materials-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .materials-controls > button { grid-column: 1 / -1; }
  .materials-print-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .materials-print-meta > div { border-bottom: 1px solid var(--line); }
  .materials-row-head { display: none; }
  .materials-row { grid-template-columns: 20px 34px minmax(0, 1fr); min-width: 0; gap: .25rem .45rem; }
  .materials-row > * { grid-column: 2; }
  .materials-row > .bulk-row-checkbox { grid-column: 1; grid-row: 1; }
  .materials-row > .materials-status-form { grid-column: 2; grid-row: 1 / span 3; }
  .materials-row > :not(.bulk-row-checkbox):not(.materials-status-form) { grid-column: 3; }
  .materials-row > strong { font-size: .8rem; }
  .materials-row > span::before,
  .materials-row > a:not(.materials-open-action)::before { content: attr(data-label); color: var(--muted); }
}

@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body { background: #fff !important; color: #000 !important; }
  .screen-only { display: none !important; }
  .print-only { display: inline !important; }
  .site-header,
  .materials-controls,
  .materials-print-button,
  .bulk-toolbar,
  .bulk-row-checkbox,
  .materials-status-form,
  .materials-procurement-edit { display: none !important; }
  main.materials-workspace { width: 100%; max-width: none; margin: 0; padding: 0; }
  .materials-page-header { margin-bottom: 5mm; border-color: #000; }
  .materials-page-header .eyebrow { display: none; }
  .materials-page-header h1 { color: #000; font-size: 18pt; }
  .materials-print-meta { grid-template-columns: repeat(3, 1fr); border-color: #000; }
  .materials-print-meta > div { border-color: #000; }
  .materials-print-meta dt,
  .materials-print-meta dd { color: #000; }
  .materials-list { display: none !important; }
  .materials-group { break-inside: auto; border-color: #000; box-shadow: none; }
  .materials-group h2 { color: #000; background: transparent; border-color: #000; }
  .materials-row { grid-template-columns: 24mm minmax(30mm,1.4fr) 18mm 12mm 10mm minmax(24mm,1fr) 18mm 18mm minmax(27mm,1fr) minmax(24mm,1fr); min-height: 7mm; border-color: #999; color: #000; break-inside: avoid; }
  .materials-row a { color: #000; text-decoration: none; }
  .materials-row.is-purchased > strong { color: #000; }
  .materials-print-state { display: inline; }
  .materials-empty-state { border-color: #000; }
  .items-print-table { display: table !important; width: 100%; border-collapse: collapse; table-layout: fixed; color: #000; font-size: 7.5pt; }
  .items-print-table th, .items-print-table td { padding: 1.6mm 1mm; border: 1px solid #999; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
  .items-print-table th { border-color: #000; background: #eee; font-weight: 800; }
  .items-print-table th:first-child { width: 20%; }
  .items-print-table .currency { text-align: right; white-space: nowrap; }
}

/* Weekly planning workspace */
.weekly-planner-page { width: min(1500px, 100%); }
.weekly-planner { display: grid; gap: .55rem; }
.weekly-planner > *, .weekly-section { min-width: 0; max-width: 100%; }
.weekly-planner-header { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
.weekly-planner-header h1 { margin: .05rem 0 0; font-size: 1.45rem; }
.weekly-navigation { display: flex; flex-wrap: wrap; gap: .3rem; }
.weekly-selected-date { display: flex; align-items: baseline; gap: .45rem; margin: -.15rem 0 0; font-size: .72rem; }
.weekly-selected-date span { color: var(--muted); text-transform: uppercase; }
.weekly-selected-date strong { font-size: .9rem; }
.weekly-section { border: 1px solid var(--line); background: var(--surface); }
.weekly-section > header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 34px; padding: .3rem .5rem; border-bottom: 1px solid var(--line); }
.weekly-section > header > div { display: flex; align-items: baseline; gap: .5rem; }
.weekly-section h2 { margin: 0; font-size: .88rem; }
.weekly-section > header span { color: var(--muted); font-size: .65rem; }
.weekly-grid { display: grid; grid-template-columns: 165px minmax(650px, 1fr); width: 100%; min-width: 0; overflow-x: auto; }
.weekly-grid-corner { z-index: 4; display: flex; align-items: center; padding: .25rem .45rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .6rem; font-weight: 700; text-transform: uppercase; }
.weekly-day-headings { display: grid; grid-template-columns: repeat(var(--week-days, 5), minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.weekly-day-headings > div { display: flex; align-items: baseline; justify-content: center; gap: .25rem; padding: .2rem; border-right: 1px solid var(--line); font-size: .62rem; }
.weekly-day-headings > div:last-child { border-right: 0; }
.weekly-day-headings span { color: var(--muted); font-size: .58rem; }
.weekly-row-label { z-index: 3; display: flex; flex-direction: column; justify-content: center; min-height: calc(var(--lanes, 1) * 38px + 6px); padding: .3rem .45rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); font-size: .7rem; }
.weekly-row-label span { color: var(--muted); font-size: .61rem; }
.weekly-task-track { position: relative; display: grid; grid-template-columns: repeat(var(--week-days, 5), minmax(0, 1fr)); grid-template-rows: repeat(var(--lanes), 36px); gap: 2px 0; min-height: calc(var(--lanes) * 38px + 6px); padding: 3px 0; border-bottom: 1px solid var(--line); }
.weekly-date-cell { position: relative; z-index: 0; grid-column: var(--day); grid-row: 1 / -1; border-right: 1px solid var(--line); }
.weekly-date-cell.is-weekend { background: #f6f6f6; }
.schedule-date.is-weekend.schedule-today,
.weekly-day-headings > .schedule-today { background: #d9f2ef; }
.schedule-cell.is-weekend.schedule-today,
.integrated-task-cell.is-weekend.schedule-today,
.weekly-date-cell.is-weekend.schedule-today { background: #eaf8f6; }
.weekly-task-bar { z-index: 1; grid-column: var(--start) / span var(--span); grid-row: var(--lane); min-width: 0; margin: 0 2px; overflow: hidden; border-radius: 3px; text-align: left; }
.weekly-task-bar .schedule-task-body { padding: .16rem .5rem; line-height: 1.08; }
.weekly-task-bar .schedule-task-meta { padding: 0 .5rem .12rem; font-size: .56rem; line-height: 1.05; }
.weekly-task-bar strong, .weekly-task-bar span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weekly-task-bar strong { font-size: .66rem; }
.weekly-task-bar span { opacity: .82; font-size: .56rem; }
.weekly-task-bar .schedule-task-body:focus-visible { outline-color: var(--text); z-index: 2; }
.weekly-row-empty { z-index: 0; grid-column: 1 / -1; align-self: center; padding-left: .45rem; color: var(--muted); font-size: .63rem; pointer-events: none; }
.weekly-grid-empty, .weekly-empty-week { grid-column: 1 / -1; margin: 0; padding: .5rem; color: var(--muted); font-size: .7rem; }
.weekly-empty-week { border-bottom: 1px solid var(--line); }
.weekly-material-groups { display: grid; }
.weekly-material-group { min-width: 0; overflow-x: auto; break-inside: avoid; }
.weekly-material-group h3 { margin: 0; padding: .28rem .5rem; border-bottom: 1px solid var(--line); background: var(--color-subtle); font-size: .72rem; }
.weekly-material-row { display: grid; grid-template-columns: 70px minmax(160px, 1.4fr) 85px minmax(140px, 1fr) minmax(140px, 1fr); align-items: center; gap: .35rem; min-height: 29px; padding: .2rem .45rem; border-bottom: 1px solid var(--line); font-size: .68rem; }
.weekly-material-head { min-height: 24px; color: var(--muted); font-size: .58rem; font-weight: 700; text-transform: uppercase; }
.weekly-material-row.is-purchased > strong { color: var(--muted); text-decoration: line-through; }
.weekly-material-action { margin: 0; }
.weekly-material-action button { min-width: 28px; min-height: 24px; padding: 0; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.weekly-material-action button:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.weekly-material-row > a { min-width: 0; overflow: hidden; color: inherit; text-decoration: underline; text-decoration-color: transparent; text-overflow: ellipsis; white-space: nowrap; }
.weekly-material-row > a:hover, .weekly-material-row > a:focus-visible { text-decoration-color: currentColor; }
.weekly-print-state, .weekly-print-heading { display: none; }
.weekly-compact-empty { margin: 0; padding: .65rem; color: var(--muted); font-size: .7rem; }
.weekly-readiness { display: flex; align-items: flex-start; gap: .65rem; padding: .4rem .5rem; border: 1px solid var(--line); background: var(--surface); }
.weekly-readiness h2 { flex: 0 0 auto; margin: .15rem 0 0; font-size: .72rem; }
.weekly-readiness > div { display: flex; flex-wrap: wrap; gap: .25rem; }
.weekly-readiness a { display: flex; gap: .35rem; padding: .18rem .35rem; border: 1px solid var(--line); color: var(--text); font-size: .62rem; text-decoration: none; }
.weekly-readiness a span { color: var(--muted); }
.schedule-drag-preview { outline: 2px solid var(--text, #1f2933); outline-offset: -2px; }
.schedule-cell.schedule-drag-preview { background-image: repeating-linear-gradient(135deg, transparent, transparent 5px, rgb(17 17 17 / 14%) 5px, rgb(17 17 17 / 14%) 7px); }
.weekly-date-cell.schedule-drag-preview { opacity: .35; }
.schedule-drag-invalid { outline: 2px dashed var(--text, #1f2933) !important; }
.schedule-drag-overlap { outline-color: var(--task-overlap, #b42318); }
.schedule-drag-live { position: fixed; z-index: 1200; max-width: min(360px, calc(100vw - 24px)); padding: .32rem .48rem; border: 1px solid var(--text, #1f2933); border-radius: 4px; background: var(--surface, #fff); color: var(--text, #1f2933); box-shadow: var(--shadow); font-size: .7rem; font-weight: 700; pointer-events: none; }
@media (max-width: 800px) {
  .weekly-planner-header { align-items: flex-start; flex-direction: column; }
  .weekly-grid { grid-template-columns: 115px minmax(550px, 1fr); }
  .weekly-day-headings span { display: none; }
  .weekly-material-row { grid-template-columns: 48px minmax(130px, 1.2fr) 65px minmax(105px, 1fr) minmax(105px, 1fr); min-width: 550px; }
  .task-edit-dialog .task-edit-form { grid-template-columns: 1fr; }
  .task-edit-dialog .task-edit-form > * { grid-column: 1; }
}

@media print {
  .schedule-segment,
  .weekly-task-bar,
  .task-status-badge,
  .integrated-task-cell.has-task {
    border-color: #000 !important;
    background-color: #fff !important;
    color: #000 !important;
    box-shadow: none;
  }
  .task-status-not-started { border-style: solid !important; }
  .task-status-in-progress { border-style: double !important; border-width: 3px !important; }
  .task-status-complete { border-style: solid !important; border-width: 3px !important; }
  .task-status-complete strong { text-decoration: line-through; }
  .task-status-legacy { border-style: dashed !important; }
  .schedule-resize-handle, .schedule-drag-live, .schedule-add-task, .schedule-add-task-dialog { display: none !important; }
  .schedule-overlap-day,
  .schedule-cell.has-overlap::after,
  .weekly-date-cell.has-overlap::after,
  .integrated-task-cell.is-overlap::after {
    box-shadow: inset 0 0 0 2px #000;
    background-image: repeating-linear-gradient(135deg, transparent, transparent 3px, #aaa 3px, #aaa 5px) !important;
  }
  .schedule-today { background: transparent !important; box-shadow: inset 1px 0 #000 !important; }
  .schedule-late-badge, .task-late-badge { border-color: #000 !important; background: #fff !important; color: #000 !important; }
  .schedule-view-controls { display: none; }
  body[data-print-section="weekly-materials"] .site-header,
  body[data-print-section="weekly-materials"] .weekly-planner > :not(.weekly-procurement),
  body[data-print-section="weekly-materials"] .weekly-procurement > header,
  body[data-print-section="weekly-materials"] .weekly-material-action { display: none !important; }
  body[data-print-section="weekly-materials"] main.weekly-planner-page { width: 100%; max-width: none; margin: 0; padding: 0; }
  body[data-print-section="weekly-materials"] .weekly-procurement { border: 0; }
  body[data-print-section="weekly-materials"] .weekly-print-heading { display: block; margin-bottom: 5mm; border-bottom: 1px solid #000; }
  body[data-print-section="weekly-materials"] .weekly-print-heading h1 { margin: 0 0 2mm; font-size: 18pt; }
  body[data-print-section="weekly-materials"] .weekly-print-heading p { margin: 0 0 3mm; font-size: 9pt; }
  body[data-print-section="weekly-materials"] .weekly-material-group h3 { color: #000; background: transparent; border-color: #000; }
  body[data-print-section="weekly-materials"] .weekly-material-row { grid-template-columns: 25mm minmax(42mm, 1.4fr) 22mm minmax(38mm, 1fr) minmax(38mm, 1fr); color: #000; border-color: #999; break-inside: avoid; }
  body[data-print-section="weekly-materials"] .weekly-print-state { display: inline; }
  body[data-print-section="weekly-materials"] .weekly-material-row.is-purchased > strong { color: #000; }
}
.simple-commercial-kpis { grid-template-columns: repeat(5,minmax(0,1fr)); }
.other-project-costs > details > summary { display: flex; align-items: center; gap: .5rem; }
.other-cost-form { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .55rem; }
.other-cost-form .modal-form-actions { grid-column: 1/-1; }
.settings-page { width: min(1180px, 100%); }
.settings-page .page-heading { margin-bottom: .4rem; }
.settings-page .workspace-card { margin-top: .45rem; padding: .55rem .65rem; }
.settings-page .workspace-card h2 { margin: 0; font-size: .95rem; }
.settings-page .workspace-card p { margin: .15rem 0 .35rem; font-size: .72rem; }
.settings-category-actions { display: flex; align-items: end; justify-content: space-between; gap: .45rem; }
.settings-category-form { display: grid; grid-template-columns: minmax(180px,1fr) 72px auto; align-items: end; gap: .28rem; }
.settings-category-form label { display: grid; gap: .2rem; }
.settings-category-list { margin-top: .35rem; border: 1px solid var(--line); }
.settings-category-row { display: grid; grid-template-columns: minmax(180px,1fr) 75px 60px auto auto; align-items: center; gap: .25rem; min-height: 30px; padding: .2rem .35rem; border-top: 1px solid var(--line); font-size: .72rem; }
.settings-category-row:first-child { border-top: 0; }
.settings-category-row.is-archived { color: var(--muted); }
.settings-category-row form { margin: 0; }
.settings-working-days { padding: .65rem .75rem; }
.settings-working-days .renovation-budget-heading { margin-bottom: .35rem; }
.working-days-form { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem 1rem; }
.working-days-form label { display: inline-flex; align-items: center; gap: .35rem; }
.working-days-form label > span { margin: 0; font-size: .74rem; }
.working-days-form input[type="checkbox"] { width: auto; }
.settings-working-days .fine-print { margin: .35rem 0 0; }

@media (max-width: 760px) {
  .settings-category-actions { align-items: stretch; flex-direction: column; }
  .settings-category-actions > form:last-child,
  .settings-category-actions > form:last-child .button { width: 100%; }
  .settings-category-form { grid-template-columns: minmax(0, 1fr) 72px; }
  .settings-category-form > .button { grid-column: 1 / -1; }
  .settings-category-row { grid-template-columns: minmax(0, 1fr) auto; }
  .settings-category-row details,
  .settings-category-row > form { justify-self: end; }
  .settings-category-row details[open] { grid-column: 1 / -1; width: 100%; }
}

.advanced-commercial-page { width: min(1160px, 100%); margin: 0 auto; }
.advanced-commercial-page .back-link { display: inline-block; margin-bottom: .3rem; }
.advanced-commercial-header { margin-bottom: .45rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
.advanced-commercial-header h1 { margin: .05rem 0; font-size: 1.45rem; }
.advanced-commercial-header p { margin: 0; color: var(--muted); font-size: .75rem; }
.advanced-cost-kpis { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); margin: 0 0 .55rem; border: 1px solid var(--line); background: var(--surface); }
.advanced-cost-kpis > div { min-width: 0; padding: .45rem .6rem; border-right: 1px solid var(--line); }
.advanced-cost-kpis > div:last-child { border-right: 0; }
.advanced-cost-kpis dt { color: var(--muted); font-size: .64rem; text-transform: uppercase; }
.advanced-cost-kpis dd { margin: .12rem 0 0; font-size: .95rem; font-weight: 800; }
.advanced-accounting-disclosure { border: 1px solid var(--line); background: var(--surface); }
.advanced-accounting-disclosure > summary { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: .55rem .7rem; cursor: pointer; list-style: none; font-weight: 800; }
.advanced-accounting-disclosure > summary small { color: var(--muted); font-size: .68rem; font-weight: 400; }
.advanced-accounting-body { border-top: 1px solid var(--line); }
.advanced-managed-note, .advanced-cost-warnings { margin: 0; padding: .5rem .7rem; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .72rem; }
.advanced-cost-warnings summary { cursor: pointer; font-weight: 700; }
.advanced-accounting-section { padding: .55rem .7rem; border-top: 1px solid var(--line); }
.advanced-accounting-section:first-child { border-top: 0; }
.advanced-accounting-section > header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .35rem; }
.advanced-accounting-section h2 { margin: 0; font-size: .82rem; }
.advanced-accounting-section > header > span { color: var(--muted); font-size: .68rem; }
.accounting-add-form > summary, .advanced-item-settings > details > summary { cursor: pointer; list-style: none; }
.advanced-commercial-page .commercial-form.compact { grid-template-columns: repeat(2,minmax(0,1fr)); gap: .45rem; margin-top: .4rem; padding: .55rem; }
.advanced-commercial-page .commercial-form label { gap: .15rem; font-size: .7rem; }
.advanced-commercial-page .commercial-form textarea { min-height: 56px; }
.advanced-record-list { margin-top: .4rem; border: 1px solid var(--line); }
.advanced-record-list > article { display: grid; grid-template-columns: minmax(180px,1fr) auto; align-items: center; gap: .5rem; min-height: 38px; padding: .3rem .45rem; border-top: 1px solid var(--line); font-size: .72rem; }
.advanced-record-list > article:first-child { border-top: 0; }
.advanced-record-list article > div:first-child { display: grid; gap: .1rem; }
.advanced-record-list article span { color: var(--muted); }
.advanced-record-list form { margin: 0; }
.advanced-invoice-row .payment-details { grid-column: 1 / -1; padding-top: .2rem; }
.payment-details > summary { cursor: pointer; font-size: .7rem; font-weight: 700; }
.payment-list { margin: .3rem 0 0; padding: 0; list-style: none; }
.payment-list li { display: flex; align-items: center; justify-content: space-between; min-height: 28px; border-top: 1px solid var(--line); }
.accounting-empty-row, .accounting-empty-stack { margin: .3rem 0 0; padding: .35rem .45rem; border: 1px solid var(--line); color: var(--muted); font-size: .72rem; }
.accounting-empty-stack { display: flex; gap: 1rem; }
.accounting-empty-stack p { margin: 0; }
.advanced-section-help { margin: -.1rem 0 .35rem; color: var(--muted); font-size: .68rem; }
.advanced-archive-form { margin: .4rem 0 0; }
@media (max-width: 1000px) { .portfolio-project-row { grid-template-columns: minmax(180px, 2fr) 100px 100px 90px repeat(3, 90px) 50px; } .portfolio-kpi-row { grid-template-columns: repeat(5, minmax(120px, 1fr)); overflow: auto; } .integrated-schedule { grid-template-columns: minmax(500px, 1fr) repeat(var(--schedule-days), 34px); } .archived-task-row { grid-template-columns: minmax(180px, 1fr) 90px 80px auto; } }
@media (max-width: 700px) { .advanced-cost-kpis { grid-template-columns: repeat(2,minmax(0,1fr)); } .advanced-cost-kpis > div { border-bottom: 1px solid var(--line); } .advanced-accounting-disclosure > summary { align-items: flex-start; flex-direction: column; gap: .15rem; } .advanced-commercial-page .commercial-form.compact, .advanced-record-list > article { grid-template-columns: 1fr; } .advanced-invoice-row .payment-details { grid-column: auto; } }

/* Generic reusable Project and Task Templates. */
.bulk-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: .2rem; min-height: 30px; margin: .25rem 0; padding: .2rem .3rem; border: 1px solid var(--line); background: var(--color-subtle); font-size: .68rem; }
.bulk-toolbar .button { min-height: 24px; padding: .15rem .35rem; font-size: .65rem; }
.bulk-toolbar .button[disabled], .bulk-toolbar select[disabled] { cursor: not-allowed; opacity: .45; }
.bulk-selected-count { min-width: 66px; color: var(--muted); }
.bulk-selected-count strong { color: var(--text); }
.bulk-toolbar-actions { display: flex; align-items: center; flex: 1 1 auto; flex-wrap: wrap; gap: .2rem; }
.bulk-toolbar-actions select { width: auto; min-width: 118px; min-height: 24px; padding: .12rem .3rem; font-size: .66rem; }
.bulk-row-checkbox { box-sizing: border-box; width: 15px; height: 15px; margin: 0; accent-color: var(--color-text); }
.bulk-row-select { display: inline-flex; align-items: center; justify-content: center; width: 18px; min-width: 18px; }
.bulk-selectable-row.is-selected { background: color-mix(in srgb, var(--color-subtle) 72%, var(--surface)); box-shadow: inset 2px 0 0 var(--color-text); }
.bulk-row-checkbox:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.project-bulk-toolbars { display: grid; grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr); gap: .25rem; margin-top: .25rem; }
.project-bulk-group { min-width: 0; }
.project-bulk-label { margin: 0 0 .12rem; color: var(--muted); font-size: .65rem; font-weight: 800; letter-spacing: .06em; line-height: 1; text-transform: uppercase; }
.project-bulk-toolbars .bulk-toolbar { margin: 0; }
.bulk-action-error { margin: .25rem 0 0; }
.templates-page .templates-workspace { display: grid; min-width: 0; gap: .26rem; }
.templates-page .templates-heading { align-items: end; margin: 0; padding-bottom: .08rem; }
.templates-page .templates-heading h1, .templates-page .template-detail-header h1 { margin: .03rem 0; font-size: 1.25rem; line-height: 1.12; }
.templates-page .template-tabs { display: flex; flex-wrap: wrap; gap: .16rem; border-bottom: 1px solid var(--line); padding-bottom: .2rem; }
.templates-page .template-tabs .is-active { background: var(--color-text); color: var(--surface); }
.templates-page .template-list-section, .templates-page .template-editor-panel { min-width: 0; border: 1px solid var(--line); background: var(--surface); padding: .3rem .38rem; }
.templates-page .template-list-section > header, .templates-page .template-structure > header { display: flex; align-items: center; justify-content: space-between; gap: .3rem; margin: 0 0 .18rem; }
.templates-page .template-list-section h2, .templates-page .template-structure h2 { margin: 0; font-size: .82rem; }
.templates-page .template-preview-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: .3rem; border: 0; }
.templates-page .template-list-row { min-width: 0; border: 1px solid var(--line); padding: .28rem .32rem; }
.templates-page .template-preview-row { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: start; gap: .24rem; height: 100%; }
.templates-page .template-preview-content { min-width: 0; }
.templates-page .template-preview-header { display: flex; align-items: start; justify-content: space-between; gap: .4rem; }
.templates-page .template-preview-header h3 { margin: 0; font-size: .84rem; line-height: 1.2; }
.templates-page .template-preview-header small { display: block; margin-top: .02rem; color: var(--muted); font-size: .68rem; line-height: 1.25; }
.templates-page .template-open-link { flex: none; font-size: .69rem; font-weight: 700; }
.templates-page .template-outline { margin: .18rem 0 0 .18rem; padding-left: .46rem; border-left: 1px solid var(--line); }
.templates-page .template-outline-stage { margin: 0 0 .12rem; break-inside: avoid; }
.templates-page .template-outline-stage:last-child { margin-bottom: 0; }
.templates-page .template-outline-stage h4 { margin: 0; font-size: .74rem; line-height: 1.22; }
.templates-page .template-outline ul, .templates-page .template-material-preview { margin: .02rem 0 0; padding-left: .85rem; }
.templates-page .template-outline li { margin: 0; font-size: .71rem; line-height: 1.28; }
.templates-page .template-material-preview { columns: 2; column-gap: .8rem; }
.templates-page .template-material-preview li { break-inside: avoid; padding-right: .2rem; }
.templates-page .template-material-preview small { margin-left: .18rem; color: var(--muted); }
.templates-page .template-preview-empty { margin: .12rem 0 0; color: var(--muted); font-size: .72rem; }
.templates-page .template-detail-header { display: flex; align-items: end; justify-content: space-between; gap: .4rem; border-bottom: 1px solid var(--line); padding-bottom: .2rem; }
.templates-page .template-detail-header p { margin: .02rem 0 0; color: var(--muted); font-size: .7rem; }
.templates-page .template-detail-toolbar, .templates-page .template-row-actions { display: flex; align-items: center; flex-wrap: nowrap; gap: .12rem; }
.templates-page .template-detail-toolbar form, .templates-page .template-row-actions form { margin: 0; }
.templates-page .template-editor-panel > summary { cursor: pointer; font-size: .75rem; font-weight: 700; }
.templates-page .template-editor-panel[open] > summary { margin-bottom: .2rem; }
.templates-page .template-compact-form { display: grid; gap: .24rem; }
.templates-page .template-compact-form label:not(.template-check) { display: grid; gap: .08rem; }
.templates-page .template-header-form { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.templates-page .template-header-form textarea { min-height: 42px; }
.templates-page .template-check { display: flex; align-items: center; gap: .25rem; }
.templates-page .template-check input { width: auto; }
.templates-page .template-inline-form { display: flex; align-items: center; flex-wrap: nowrap; gap: .16rem; margin: 0; }
.templates-page .template-inline-form input, .templates-page .template-inline-form select { min-width: 105px; min-height: 27px; padding: .2rem .3rem; font-size: .72rem; }
.templates-page .template-stage-list, .templates-page .template-task-list { display: grid; min-width: 0; gap: .14rem; }
.templates-page .template-stage { min-width: 0; border: 1px solid var(--line); }
.templates-page .template-stage:nth-child(odd) { background: var(--surface); }
.templates-page .template-stage:nth-child(even) { background: var(--color-subtle); }
.templates-page .template-stage-header, .templates-page .template-task-header { display: flex; align-items: center; justify-content: space-between; min-width: 0; gap: .35rem; padding: .2rem .28rem; }
.templates-page .template-stage-header { background: var(--color-subtle); }
.templates-page .template-row-identity { display: flex; align-items: center; min-width: 0; gap: .28rem; font-size: .78rem; font-weight: 700; }
.templates-page .template-row-identity a { min-width: 0; overflow-wrap: anywhere; }
.templates-page .template-row-identity small { flex: none; color: var(--muted); font-size: .66rem; font-weight: 400; }
.templates-page .template-stage-body { min-width: 0; border-top: 1px solid var(--line); padding: .1rem .2rem .14rem; }
.templates-page .template-task { min-width: 0; border-top: 1px solid var(--line); }
.templates-page .template-task:first-child { border-top: 0; }
.templates-page .template-task-header { padding: .11rem .1rem; }
.templates-page .template-task-body { display: grid; min-width: 0; gap: .08rem; padding: 0 .1rem .1rem .85rem; }
.templates-page .template-material-list { min-width: 0; margin: 0; }
.templates-page .template-material-row { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; min-width: 0; gap: .18rem; border-top: 1px solid var(--line); padding: .09rem .06rem; }
.templates-page .template-material-data { display: grid; grid-template-columns: minmax(120px,1.3fr) minmax(80px,.7fr) minmax(80px,.55fr) 80px minmax(90px,.7fr); align-items: center; min-width: 0; gap: .2rem; font-size: .7rem; line-height: 1.12; }
.templates-page .template-material-data > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.templates-page .template-material-data span { color: var(--muted); }
.templates-page .template-detail-materials { margin-left: 0; }
.templates-page .template-task-materials-section > header > div { display: flex; align-items: baseline; gap: .4rem; }
.templates-page .template-task-materials-section > header small { color: var(--muted); font-size: .68rem; }
.templates-page .template-row-editor { position: relative; flex: none; }
.templates-page .template-row-editor > summary { width: max-content; list-style: none; cursor: pointer; }
.templates-page .template-row-editor > summary::-webkit-details-marker { display: none; }
.templates-page .template-row-editor > .template-inline-form { position: absolute; z-index: 30; top: calc(100% + .12rem); right: 0; width: max-content; max-width: min(680px, calc(100vw - 48px)); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); padding: .28rem; }
.templates-page .template-add-control { width: max-content; max-width: 100%; margin-top: .12rem; }
.templates-page .template-add-control > .template-inline-form { right: auto; left: 0; }
.templates-page .template-structure > header .template-add-control > .template-inline-form { right: 0; left: auto; }
.templates-page .template-empty { margin: 0; color: var(--muted); padding: .24rem 0; font-size: .73rem; }
.templates-trash-dialog { width: min(760px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 48px)); }
.project-detail-page .project-template-menu { position: relative; }
.project-detail-page .project-template-menu > summary { list-style: none; cursor: pointer; }
.project-detail-page .project-template-menu > summary::-webkit-details-marker { display: none; }
.project-detail-page .project-template-menu > summary::after { content: " ▾"; font-size: .7em; }
.project-detail-page .project-template-menu[open] > summary { background: var(--surface-muted); }
.project-detail-page .project-template-menu-items { position: absolute; z-index: 20; top: calc(100% + .2rem); right: 0; display: grid; min-width: 205px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); padding: .2rem; }
.project-detail-page .project-template-menu-items button,
.project-detail-page .project-template-menu-items a { display: block; width: 100%; border: 0; background: transparent; padding: .4rem .48rem; color: var(--color-text); text-align: left; text-decoration: none; cursor: pointer; font: inherit; font-size: .78rem; }
.project-detail-page .project-template-menu-items button:hover,
.project-detail-page .project-template-menu-items button:focus-visible,
.project-detail-page .project-template-menu-items a:hover,
.project-detail-page .project-template-menu-items a:focus-visible { background: var(--surface-muted); outline: 2px solid var(--focus); outline-offset: -2px; }
@media (max-width: 960px) { .project-bulk-toolbars { grid-template-columns: 1fr; } .templates-page .template-preview-list { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .templates-page .template-detail-header, .templates-page .template-stage-header, .templates-page .template-task-header { align-items: flex-start; flex-direction: column; } .templates-page .template-row-actions { align-self: flex-end; } .templates-page .template-material-data { grid-template-columns: minmax(0, 1fr) auto; } .templates-page .template-material-data strong { grid-column: 1 / -1; white-space: normal; } .templates-page .template-material-preview { columns: 1; } .templates-page .template-row-editor > .template-inline-form, .templates-page .template-add-control > .template-inline-form, .templates-page .template-structure > header .template-add-control > .template-inline-form { position: static; flex-direction: column; align-items: stretch; width: min(100%, calc(100vw - 48px)); margin-top: .12rem; } .templates-page .template-task-body { padding-left: .3rem; } .project-detail-page .project-template-menu-items { left: 0; right: auto; } .bulk-toolbar-actions { flex-basis: 100%; } }

@media (max-width: 700px) {
  .project-trash-row { align-items: flex-start; flex-direction: column; }
  .project-trash-row .button-row { width: 100%; }
}

/* Focused project/template UI polish: flexible actions and compact dialog forms. */
.schedule-tasks-workspace .integrated-schedule {
  grid-template-columns: minmax(700px, .9fr) repeat(var(--schedule-days), 34px);
}
.schedule-tasks-workspace .integrated-task-summary,
.schedule-tasks-workspace .integrated-task-column-head {
  grid-template-columns: 18px 18px minmax(105px, 1.35fr) minmax(54px, .68fr) 48px 28px 48px 62px 46px 48px minmax(154px, 1.15fr);
}
.schedule-tasks-workspace .integrated-task-identity { min-height: 42px; }
.schedule-tasks-workspace .compact-task-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 2px;
  min-width: 0;
}
.schedule-tasks-workspace .compact-task-actions button {
  min-width: 0;
  min-height: 18px;
  padding: 2px 3px;
  overflow: visible;
  font-size: .58rem;
  line-height: 1.05;
  white-space: nowrap;
}
.schedule-tasks-workspace .stage-heading-actions { flex-wrap: wrap; justify-content: flex-end; }

.task-materials-dialog { width: min(1040px, calc(100vw - 32px)); }
.task-cost-dialog { width: min(760px, calc(100vw - 32px)); }
.task-materials-dialog .app-dialog-body,
.task-cost-dialog .app-dialog-body { padding: .5rem; }
.task-materials-dialog .task-material-list { overflow-x: auto; }
.task-materials-dialog .task-material-head,
.task-materials-dialog .task-material-row { min-width: 880px; }
.task-materials-dialog .task-material-procurement-form {
  grid-template-columns: minmax(150px, 1.45fr) minmax(115px, 1fr) minmax(72px, .55fr) minmax(125px, 1fr) minmax(125px, 1fr);
  gap: .25rem;
  margin-top: .35rem;
}
.task-materials-dialog .task-material-procurement-form label { gap: .1rem; font-size: .66rem; }
.task-materials-dialog .task-material-procurement-form input,
.task-materials-dialog .task-material-procurement-form select { min-height: 29px; padding: .22rem .3rem; }
.task-materials-dialog .task-material-procurement-form .procurement-notes { grid-column: 1 / 5; }
.task-materials-dialog .task-material-procurement-form textarea { min-height: 42px; max-height: 72px; padding: .3rem; resize: vertical; }
.task-materials-dialog .task-material-procurement-form .procurement-submit { grid-column: 5; align-self: end; }
.task-cost-dialog .fine-print { margin: 0 0 .35rem; line-height: 1.3; }
.task-cost-dialog .task-cost-form {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: .3rem;
}
.task-cost-dialog .task-cost-form label { gap: .1rem; font-size: .68rem; }
.task-cost-dialog .task-cost-form input,
.task-cost-dialog .task-cost-form select { min-height: 30px; padding: .25rem .35rem; }
.task-cost-dialog .task-cost-result { padding: .32rem .45rem; }

.templates-page .template-row-actions { flex-wrap: wrap; justify-content: flex-end; }
.templates-page .template-stage {
  border-left: 3px solid var(--color-border-strong);
  background: var(--surface);
}
.templates-page .template-stage-header {
  min-height: 28px;
  padding: .12rem .24rem;
  background: #e9edf1;
  border-bottom: 1px solid var(--color-border-strong);
}
.templates-page .template-stage-header .template-row-identity {
  font-size: .84rem;
  font-weight: 800;
}
.templates-page .template-stage-body { padding: .04rem .1rem .08rem .3rem; }
.templates-page .template-stage-body > .bulk-toolbar { margin-left: .24rem; }
.templates-page .template-task-list {
  margin-left: .24rem;
  gap: .06rem;
  border-left: 2px solid var(--line);
}
.templates-page .template-task { border-top: 1px solid var(--line); background: var(--surface); }
.templates-page .template-task-header { min-height: 25px; padding: .06rem .12rem .06rem .24rem; background: #f7f8fa; }
.templates-page .template-task-header .template-row-identity { font-size: .76rem; }
.templates-page .template-task-body {
  gap: .03rem;
  margin-left: .42rem;
  padding: 0 .05rem .06rem .3rem;
  border-left: 1px solid var(--line);
}
.templates-page .template-task-body > .bulk-toolbar { margin: .04rem 0; }
.templates-page .template-material-row {
  min-height: 23px;
  padding: .03rem .05rem .03rem .14rem;
  background: #fbfcfd;
}
.templates-page .template-task-materials-section .template-material-list {
  margin-left: .26rem;
  border-left: 2px solid var(--line);
  padding-left: .2rem;
}
.templates-page .template-stage-list { gap: .07rem; }
.templates-page .template-row-actions .button-small,
.templates-page .template-row-actions button,
.templates-page .bulk-toolbar .button-small {
  min-height: 24px;
  padding: .1rem .28rem;
  font-size: .64rem;
}

.project-trash-panel > details > summary { display: flex; align-items: center; justify-content: space-between; gap: .5rem; cursor: pointer; }
.project-trash-panel > details > summary > span:first-child { display: grid; gap: .05rem; }
.project-trash-panel > details > summary small { color: var(--muted); font-weight: 400; }
.project-trash-list { display: grid; margin-top: .45rem; border-top: 1px solid var(--line); }
.project-trash-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; min-height: 42px; padding: .3rem .1rem; border-bottom: 1px solid var(--line); }
.project-trash-row > div:first-child { display: grid; min-width: 0; gap: .03rem; }
.project-trash-row span, .project-trash-row small { color: var(--muted); font-size: .68rem; }
.project-trash-row form { margin: 0; }

@media (max-width: 820px) {
  .task-materials-dialog .task-material-procurement-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-materials-dialog .task-material-procurement-form .procurement-notes,
  .task-materials-dialog .task-material-procurement-form .procurement-submit { grid-column: 1 / -1; }
  .task-cost-dialog .task-cost-form { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
}
@media (max-width: 620px) {
  .task-materials-dialog .task-material-procurement-form,
  .task-cost-dialog .task-cost-form { grid-template-columns: minmax(0, 1fr); }
  .task-materials-dialog .task-material-procurement-form .procurement-notes,
  .task-materials-dialog .task-material-procurement-form .procurement-submit,
  .task-cost-dialog .task-cost-form .span-all { grid-column: 1; }
}

/* Final corrective overrides. Keep below all legacy Project workspace rules. */
.templates-page .template-structure > .bulk-toolbar,
.templates-page .template-stage-body > .bulk-toolbar,
.templates-page .template-task-body > .bulk-toolbar { min-height: 19px; margin: 1px 0; padding: 0 2px; gap: 2px; line-height: 1; }
.templates-page .bulk-toolbar .button,
.templates-page .template-row-actions .button,
.templates-page .template-material-row > .template-row-editor > summary.button,
.templates-page .template-add-control > summary.button { min-height: 19px; padding: 1px 4px; font-size: .59rem; line-height: 1; }
.templates-page .bulk-selected-count { min-width: 52px; font-size: .59rem; }
.templates-page .bulk-toolbar-actions select { min-height: 19px; padding-block: 0; }
.templates-page .template-stage-list { gap: 1px; }
.templates-page .template-stage-header { min-height: 23px; padding: 1px 4px; }
.templates-page .template-stage-header .template-row-identity { font-size: .77rem; }
.templates-page .template-stage-body { padding: 0 1px 1px 4px; }
.templates-page .template-stage-body > .bulk-toolbar { margin-left: 2px; }
.templates-page .template-task-list { gap: 0; margin-left: 3px; }
.templates-page .template-task-header { min-height: 21px; padding: 0 2px 0 4px; }
.templates-page .template-task-header .template-row-identity { font-size: .71rem; line-height: 1; }
.templates-page .template-row-identity small { font-size: .59rem; }
.templates-page .template-task-body { gap: 0; margin-left: 4px; padding: 0 1px 0 3px; }
.templates-page .template-task-body > .bulk-toolbar { margin: 0; }
.templates-page .template-material-row { min-height: 21px; gap: 2px; padding: 0 1px 0 3px; }
.templates-page .template-material-data { font-size: .66rem; line-height: 1; }
.templates-page .template-add-control { margin-top: 0; }

.task-materials-dialog .task-material-editor[open] { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr; width: 100%; padding: 3px 0 4px; border-block: 1px solid var(--line); }
.task-materials-dialog .task-material-editor[open] > summary { justify-self: end; margin-bottom: 3px; }
.task-materials-dialog .task-material-editor-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 4px; }
.task-materials-dialog .task-material-edit-form { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px; width: 100%; margin: 0; }
.task-materials-dialog .task-material-edit-form label { display: grid; min-width: 0; gap: 1px; color: var(--muted); font-size: .61rem; font-weight: 700; }
.task-materials-dialog .task-material-edit-form input,
.task-materials-dialog .task-material-edit-form select { min-width: 0; min-height: 27px; padding: 2px 4px; font-size: .69rem; }
.task-materials-dialog .task-material-edit-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.task-materials-dialog .task-material-remove-form { margin: 0; }
.task-materials-dialog .task-material-add-section { margin-top: 8px; padding: 5px 3px 3px; border-top: 2px solid var(--line); background: color-mix(in srgb, var(--color-subtle) 45%, transparent); }
.task-materials-dialog .task-material-add-section > h3 { margin: 0 0 3px; font-size: .72rem; }
.task-materials-dialog .task-material-procurement-form { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px; margin: 0; }
.task-materials-dialog .task-material-procurement-form .procurement-notes { grid-column: 1 / 6; }
.task-materials-dialog .task-material-procurement-form .procurement-submit { grid-column: 6; align-self: end; }
.task-materials-dialog .task-material-procurement-form textarea { min-height: 31px; max-height: 48px; }

.schedule-tasks-workspace .integrated-schedule,
.integrated-schedule { --integrated-day-width: 42px; grid-template-columns: minmax(700px, .9fr) repeat(var(--schedule-days), var(--integrated-day-width)); }
.integrated-schedule > .schedule-date,
.integrated-stage-cell,
.integrated-task-cell,
.integrated-add-task-cell { min-width: var(--integrated-day-width); }
.integrated-task-cell { min-height: 42px; }
.integrated-task-cell.has-task { height: 36px; min-height: 36px; margin-top: 3px; }
.integrated-task-segment { width: calc(var(--span) * var(--integrated-day-width)); min-width: var(--integrated-day-width); }
.integrated-task-segment .schedule-task-body { padding: 3px 8px; font-size: .62rem; line-height: 1.08; }
.integrated-task-segment .schedule-task-body strong { font-size: .66rem; line-height: 1.08; }
.integrated-task-segment .schedule-task-body span { display: block; margin-top: 2px; font-size: .56rem; line-height: 1.05; opacity: .82; }
.integrated-schedule > .schedule-date .today-label { padding-inline: 3px; font-size: .48rem; }

@media (max-width: 820px) {
  .task-materials-dialog .task-material-edit-form,
  .task-materials-dialog .task-material-procurement-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-materials-dialog .task-material-edit-actions,
  .task-materials-dialog .task-material-procurement-form .procurement-notes,
  .task-materials-dialog .task-material-procurement-form .procurement-submit { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .task-materials-dialog .task-material-editor-body,
  .task-materials-dialog .task-material-edit-form,
  .task-materials-dialog .task-material-procurement-form { grid-template-columns: minmax(0, 1fr); }
  .task-materials-dialog .task-material-edit-actions,
  .task-materials-dialog .task-material-procurement-form .procurement-notes,
  .task-materials-dialog .task-material-procurement-form .procurement-submit { grid-column: 1; }
}

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  .materials-page-header .button-row,
  .materials-controls,
  .materials-cost-summary,
  .materials-list,
  .bulk-toolbar { display: none !important; }
  .materials-page-header { margin-bottom: 3mm; padding-bottom: 2mm; }
  .materials-page-header h1 { margin: 0; font-size: 15pt; }
  .materials-print-meta { grid-template-columns: repeat(5, 1fr); margin-bottom: 3mm; }
  .materials-print-meta > div { padding: 1.2mm 2mm; }
  .items-print-table { display: table !important; width: 100%; border-collapse: collapse; table-layout: fixed; color: #000; font-size: 6.8pt; line-height: 1.15; }
  .items-print-table thead { display: table-header-group; }
  .items-print-table tr { break-inside: avoid; }
  .items-print-table th,
  .items-print-table td { padding: 1mm 1.1mm; border: .25mm solid #999; vertical-align: top; overflow-wrap: anywhere; }
  .items-print-table th { border-color: #555; background: #e8e8e8 !important; font-weight: 800; text-align: left; }
  .items-print-table th:nth-child(1) { width: 17%; }
  .items-print-table th:nth-child(2) { width: 12%; }
  .items-print-table th:nth-child(3), .items-print-table th:nth-child(4) { width: 10%; }
  .items-print-table th:nth-child(5), .items-print-table th:nth-child(6) { width: 5%; }
  .items-print-table th:nth-child(7) { width: 8%; }
  .items-print-table th:nth-child(8) { width: 10%; }
  .items-print-table th:nth-child(9) { width: 8%; }
  .items-print-table th:nth-child(10), .items-print-table th:nth-child(11) { width: 7.5%; text-align: right; }
  .items-print-table .currency { text-align: right; white-space: nowrap; }
}

.templates-page .template-material-row > .template-row-editor:not([open]),
.templates-page .template-row-actions > .template-row-editor:not([open]),
.templates-page .template-add-control:not([open]) {
  height: 19px;
  min-height: 19px;
  line-height: 1;
}

.task-materials-dialog .task-material-editor[open] > summary { display: none; }
.task-materials-dialog .task-material-edit-form label,
.task-materials-dialog .task-material-procurement-form label { gap: 0; font-size: .6rem; line-height: 1; }
.task-materials-dialog .task-material-edit-form input,
.task-materials-dialog .task-material-edit-form select,
.task-materials-dialog .task-material-procurement-form input,
.task-materials-dialog .task-material-procurement-form select { min-height: 25px; padding: 1px 3px; }
.task-materials-dialog .task-material-edit-notes { grid-column: 1 / 5; }
.task-materials-dialog .task-material-edit-actions { grid-column: 5 / 7; align-self: end; }
.task-materials-dialog .task-material-procurement-form .procurement-notes {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: 4px;
}
.task-materials-dialog .task-material-procurement-form textarea { min-height: 29px; max-height: 36px; padding: 2px 3px; }
