/* Screen layout is independent of saved worksheet and export dimensions. */
@media screen {
  .customer-sheet > .table-wrap,
  #managerApp .user-panel > .table-wrap,
  body.admin-screen .supplier-settlement-table-wrap {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: auto;
    overscroll-behavior-x: contain;
  }

  .customer-sheet .public-table {
    width: 100%;
    min-width: var(--public-table-min-width, 1000px);
  }

  body.admin-screen :is(#quoteTableWrap, #materialList, #projectRunbookBuilder, #projectDesignListBuilder, #projectPersonnelBuilder, #personnelTableArea) {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  body.admin-screen :is(#quoteTableWrap, .material-group > .table-wrap, .design-list-scroll, .personnel-table-wrap) {
    min-width: 0;
    max-width: 100%;
    overflow: auto;
    overscroll-behavior-x: contain;
  }

  body.admin-screen #quoteTableWrap .admin-table {
    width: 100%;
    max-width: none;
  }

  body.admin-screen .quote-table.material-table {
    width: 100%;
    min-width: var(--material-table-min-width, 1016px);
  }

  body.admin-screen .quote-table.design-list-table {
    width: 100%;
    min-width: var(--design-table-width, 1164px);
  }

  body.admin-screen .personnel-table {
    width: 100%;
    min-width: var(--personnel-table-min-width, 1257px);
  }

  body.admin-screen .runbook-table-wrap {
    min-width: 0;
    max-width: 100%;
  }

  body.admin-screen .runbook-table-scroll {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    max-height: max(240px, calc(var(--display-viewport-height, 100dvh) - var(--runbook-sticky-toolbar-height, 110px) - 250px));
    overflow: auto;
    overscroll-behavior-x: contain;
    zoom: 1;
  }

  body.admin-screen .quote-table.runbook-table {
    width: 100%;
    min-width: var(--runbook-table-min-width, 1276px);
    table-layout: fixed;
  }

  /* The worksheet scrolls below the toolbar, so sticky rows start at zero. */
  body.admin-screen .runbook-table :is(.runbook-header-row-chinese th, .runbook-actions-header) {
    top: 0;
  }

  body.admin-screen .runbook-table textarea {
    height: auto;
    min-height: 52px;
    overflow-y: hidden;
    resize: vertical;
  }

  body.admin-screen .runbook-table textarea:focus {
    min-height: 52px;
  }

  body.admin-screen :is(.quote-table, .personnel-table) :is(th, td) {
    overflow-wrap: anywhere;
  }

  body.admin-screen :is(.quote-table, .personnel-table) :is(input:not([type="checkbox"]), textarea, select) {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* Runbook groups use independent worksheet cards on screen. */
@media screen {
  body.admin-screen #projectRunbookBuilder {
    padding: 16px;
    box-sizing: border-box;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, .76);
    box-shadow: none;
  }

  body.admin-screen #projectRunbookBuilder > .runbook-table-wrap {
    gap: 14px;
    min-width: 0;
    max-height: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  body.admin-screen #projectRunbookBuilder > .runbook-table-wrap > .runbook-toolbar {
    order: 0;
  }

  body.admin-screen #projectRunbookBuilder :is(.runbook-sheet-header-card, .runbook-list-groups, .runbook-list-group) {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  body.admin-screen #projectRunbookBuilder .runbook-list-groups {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  body.admin-screen #projectRunbookBuilder :is(.runbook-sheet-header-card, .runbook-list-group) {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, .76);
    box-shadow: 0 10px 26px rgba(42, 97, 154, .08);
  }

  body.admin-screen #projectRunbookBuilder .runbook-list-group:focus-within,
  body.admin-screen #projectRunbookBuilder .runbook-list-group:has(> .runbook-group-title.selected-line) {
    border-color: rgba(0, 122, 255, .62);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, .12), 0 10px 26px rgba(42, 97, 154, .08);
  }

  body.admin-screen #projectRunbookBuilder .runbook-sheet-header-card .runbook-sheet-header-table {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  body.admin-screen #projectRunbookBuilder .runbook-sheet-header-card td {
    border-color: var(--line);
  }

  body.admin-screen #projectRunbookBuilder .runbook-sheet-meta-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
    height: auto;
  }

  body.admin-screen #projectRunbookBuilder .runbook-sheet-meta-row label {
    min-height: 42px;
    padding: 8px 12px;
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-title {
    position: relative;
    display: grid;
    grid-template-columns: minmax(110px, 160px) minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px 12px;
    padding: 10px 14px;
    background: linear-gradient(180deg, #edf7ff, #dfeeff);
    color: #0b3d78;
    font-weight: 700;
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-title > .runbook-section-fields {
    display: contents;
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-title > span.runbook-group-name {
    grid-column: 1 / 3;
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-title.dragging-row {
    opacity: .55;
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-title.drag-over-before {
    box-shadow: inset 0 3px 0 var(--accent);
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-title.drag-over-after {
    box-shadow: inset 0 -3px 0 var(--accent);
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-title :is([data-runbook-section-date], [data-runbook-section-title], .runbook-group-name) {
    width: 100%;
    min-width: 0;
    min-height: 36px;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, .82);
    color: #0b3d78;
    font: inherit;
    text-align: center;
    overflow-wrap: anywhere;
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-count {
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-controls {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 4px;
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-controls .quote-line-select {
    display: inline-flex;
    width: auto;
    min-width: 0;
    align-items: center;
    margin: 0;
    padding: 4px;
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-controls input[type="checkbox"] {
    width: 16px;
    min-width: 16px;
    height: 16px;
    min-height: 0;
    margin: 0;
    padding: 0;
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-controls button {
    min-width: 30px;
    min-height: 30px;
    padding: 4px;
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-scroll {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    max-height: none;
    overflow: auto;
    overscroll-behavior-x: contain;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-table {
    width: 100%;
    min-width: var(--runbook-table-min-width, 1276px);
    table-layout: fixed;
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-table :is(th, td) {
    border-color: var(--runbook-screen-border, var(--line));
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-table thead th {
    position: relative;
    top: auto;
    z-index: auto;
    padding-inline: 10px;
    background: linear-gradient(135deg, #317fff, #42baff);
    color: #fff;
    box-shadow: none;
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-table tbody tr:not(.selected-line) td {
    background: rgba(255, 255, 255, .92);
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-table tbody tr:nth-child(even):not(.selected-line) td {
    background: rgba(246, 251, 255, .94);
  }

  body.admin-screen #projectRunbookBuilder [data-runbook-resize-column] {
    position: absolute;
    inset: 0 0 0 auto;
    z-index: 9;
    width: 8px;
    cursor: col-resize;
    pointer-events: auto;
    touch-action: none;
    user-select: none;
  }

  body.admin-screen #projectRunbookBuilder [data-runbook-resize-column]::after {
    content: "";
    position: absolute;
    top: 4px;
    right: 3px;
    bottom: 4px;
    width: 2px;
    background: rgba(255, 255, 255, .3);
  }

  body.admin-screen #projectRunbookBuilder .runbook-group-table th:hover [data-runbook-resize-column]::after,
  body.admin-screen #projectRunbookBuilder [data-runbook-resize-column]:is(:hover, :focus-visible, :active)::after {
    background: #fff;
  }

  body.admin-screen #projectRunbookBuilder [data-runbook-resize-column]:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -2px;
  }

  @container workbench (max-width: 620px) {
    body.admin-screen #projectRunbookBuilder {
      padding: 10px;
    }

    body.admin-screen #projectRunbookBuilder .runbook-toolbar {
      flex-wrap: wrap;
    }

    body.admin-screen #projectRunbookBuilder :is(.unified-editor-tools, .unified-editor-actions, .matched-tool-cluster) {
      min-width: 0;
      max-width: 100%;
    }

    body.admin-screen #projectRunbookBuilder :is(.unified-editor-tools, .unified-editor-actions) {
      width: 100%;
      flex-basis: 100%;
    }

    body.admin-screen #projectRunbookBuilder .unified-editor-actions {
      grid-auto-rows: minmax(48px, auto);
    }

    body.admin-screen #projectRunbookBuilder .unified-editor-actions button {
      flex-direction: column;
      gap: 2px;
      padding: 2px 4px;
      white-space: normal;
    }

    body.admin-screen #projectRunbookBuilder .runbook-group-title {
      grid-template-columns: minmax(0, 1fr) auto;
    }

    body.admin-screen #projectRunbookBuilder [data-runbook-section-date] {
      grid-column: 1;
      grid-row: 1;
    }

    body.admin-screen #projectRunbookBuilder .runbook-group-count {
      grid-column: 2;
      grid-row: 1;
    }

    body.admin-screen #projectRunbookBuilder :is([data-runbook-section-title], .runbook-group-name) {
      grid-column: 1 / -1;
      grid-row: 2;
    }

    body.admin-screen #projectRunbookBuilder .runbook-group-controls {
      grid-column: 1 / -1;
      grid-row: 3;
    }

    body.admin-screen #projectRunbookBuilder .runbook-sheet-header-card :is(.runbook-sheet-header-table, tbody, tr, td) {
      display: block;
      width: 100%;
      min-width: 0;
      height: auto;
    }

    body.admin-screen #projectRunbookBuilder .runbook-sheet-header-card :is(colgroup, .runbook-sheet-spacer) {
      display: none;
    }

    body.admin-screen #projectRunbookBuilder .runbook-sheet-header-card .runbook-sheet-duty-row {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body.admin-screen #projectRunbookBuilder .runbook-sheet-title-row input {
      font-size: 20px;
    }
  }
}

/* Personnel and design worksheets share the material-list screen surfaces.
   Stored document formatting and print/export colors remain independent. */
@media screen {
  body.admin-screen .project-detail-section:is([data-project-panel="personnel"], [data-project-panel="design"]) {
    width: 100%;
    max-width: none;
    margin-inline: 0;
  }

  body.admin-screen :is(#projectPersonnelBuilder, #projectDesignListBuilder) {
    padding: 16px;
    box-sizing: border-box;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, .76);
  }

  body.admin-screen :is(#projectPersonnelBuilder, #projectDesignListBuilder) .design-ribbon {
    border-color: #c6ddf7;
    box-shadow: none;
  }

  body.admin-screen #projectDesignListBuilder .design-list-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  body.admin-screen :is(#projectPersonnelBuilder, #projectDesignListBuilder) .design-ribbon-actions .design-ribbon-controls {
    max-width: 100%;
  }

  body.admin-screen #projectPersonnelBuilder .design-ribbon-actions .design-ribbon-controls {
    width: 288px;
    max-width: 100%;
    grid-auto-rows: 48px;
  }

  body.admin-screen :is(#projectPersonnelBuilder, #projectDesignListBuilder) .design-ribbon .design-ribbon-actions {
    min-width: 0;
    max-width: 100%;
  }

  body.admin-screen #projectPersonnelBuilder .design-ribbon-actions button {
    height: 48px;
    font-size: 11px;
  }

  body.admin-screen #projectPersonnelBuilder .design-ribbon-actions [data-personnel-action="save"] {
    background: #0767f9;
    color: #fff;
    box-shadow: 0 4px 12px #0867f922;
  }

  body.admin-screen #projectPersonnelBuilder .design-ribbon-actions [data-personnel-action="save"]:hover:not(:disabled) {
    background: #0059dc;
  }

  body.admin-screen #projectPersonnelBuilder .personnel-sheet-title {
    padding: 14px;
    border-color: var(--line);
    border-radius: 18px 18px 0 0;
    background: linear-gradient(180deg, #edf7ff, #dfeeff);
    color: #0b3d78;
  }

  body.admin-screen #projectPersonnelBuilder .personnel-project-info {
    border-color: var(--line);
    border-radius: 0 0 18px 18px;
    overflow: hidden;
    background: rgba(255, 255, 255, .92);
  }

  body.admin-screen #projectPersonnelBuilder .personnel-project-info dt {
    background: #edf7ff;
    color: #355778;
  }

  body.admin-screen #projectDesignListBuilder .design-main-visual {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, .76);
  }

  body.admin-screen #projectDesignListBuilder .design-main-visual > h3 {
    margin: 0;
    padding: 12px 14px;
    color: #0b3d78;
  }

  body.admin-screen #projectDesignListBuilder .design-brief-table :is(th, td) {
    border-color: var(--line);
  }

  body.admin-screen #projectDesignListBuilder .design-brief-table .design-brief-band th {
    background: linear-gradient(180deg, #edf7ff, #dfeeff);
    color: #0b3d78;
  }

  body.admin-screen #projectDesignListBuilder .design-list-caption {
    padding: 10px 14px;
    margin-bottom: -14px;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    background: linear-gradient(180deg, #edf7ff, #dfeeff);
    color: #0b3d78;
    flex-wrap: wrap;
  }

  body.admin-screen #projectDesignListBuilder .design-list-caption input {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    border: 0;
    background: rgba(255, 255, 255, .82);
    color: #0b3d78;
    font-weight: 700;
    text-align: center;
  }

  body.admin-screen #projectDesignListBuilder .design-list-caption small {
    font-size: 12px;
    overflow-wrap: anywhere;
  }

  body.admin-screen :is(.personnel-table-wrap, #projectDesignListBuilder .design-list-scroll) {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, .76);
    box-shadow: 0 10px 26px rgba(42, 97, 154, .08);
  }

  body.admin-screen #projectDesignListBuilder .design-list-caption + .design-list-scroll {
    border-radius: 0 0 18px 18px;
  }

  body.admin-screen #projectDesignListBuilder .design-list-caption:has(+ .design-list-groups) {
    margin-bottom: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 18px;
  }

  body.admin-screen #projectDesignListBuilder .design-list-groups {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    min-width: 0;
  }

  body.admin-screen #projectDesignListBuilder .design-list-group {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, .76);
    box-shadow: 0 10px 26px rgba(42, 97, 154, .08);
  }

  body.admin-screen #projectDesignListBuilder .design-list-group:focus-within {
    border-color: rgba(0, 122, 255, .62);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, .12), 0 10px 26px rgba(42, 97, 154, .08);
  }

  body.admin-screen #projectDesignListBuilder .design-group-title {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: linear-gradient(180deg, #edf7ff, #dfeeff);
    color: #0b3d78;
    font-weight: 700;
  }

  body.admin-screen #projectDesignListBuilder .design-group-controls {
    position: relative;
    display: flex;
    flex: 0 0 24px;
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }

  body.admin-screen #projectDesignListBuilder .design-group-controls input[type="checkbox"] {
    width: 14px;
    height: 14px;
    min-height: 0;
    margin: 0;
    padding: 0;
  }

  body.admin-screen #projectDesignListBuilder .design-group-title :is(input[data-design-section], .design-group-name) {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 36px;
    border: 0;
    border-radius: 14px;
    background: rgba(255, 255, 255, .82);
    color: #0b3d78;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
  }

  body.admin-screen #projectDesignListBuilder .design-group-count {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
  }

  body.admin-screen #projectDesignListBuilder .design-group-name:not(input) {
    display: grid;
    place-items: center;
    padding: 8px;
    overflow-wrap: anywhere;
  }

  body.admin-screen #projectDesignListBuilder .design-list-group > .design-list-scroll {
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
  }

  body.admin-screen #projectPersonnelBuilder .personnel-table :is(th, td) {
    border: 1px solid var(--line);
  }

  body.admin-screen #projectDesignListBuilder .design-list-table :is(th, td) {
    border-color: var(--design-screen-border, var(--line));
  }

  body.admin-screen :is(#projectPersonnelBuilder .personnel-table, #projectDesignListBuilder .design-list-table) thead th {
    padding: 8px 6px;
    background: linear-gradient(135deg, #317fff, #42baff);
    color: #fff;
    font-weight: 700;
    text-align: center;
    box-shadow: none;
  }

  body.admin-screen :is(#projectPersonnelBuilder .personnel-table, #projectDesignListBuilder .design-list-table) tbody tr:not(.personnel-section):not(.design-section) td {
    background: rgba(255, 255, 255, .92);
  }

  body.admin-screen :is(#projectPersonnelBuilder .personnel-table, #projectDesignListBuilder .design-list-table) tbody tr:nth-child(even):not(.personnel-section):not(.design-section) td {
    background: rgba(246, 251, 255, .94);
  }

  body.admin-screen :is(#projectPersonnelBuilder .personnel-table, #projectDesignListBuilder .design-list-table) :is(.personnel-section, .design-section) td {
    background: linear-gradient(180deg, #edf7ff, #dfeeff);
    color: #0b3d78;
    font-weight: 700;
  }

  @container workbench (max-width: 620px) {
    body.admin-screen :is(#projectPersonnelBuilder, #projectDesignListBuilder) {
      padding: 10px;
    }

    body.admin-screen :is(#projectPersonnelBuilder, #projectDesignListBuilder) :is(.design-ribbon-tools .design-ribbon-controls, .design-ribbon-fonts) {
      min-width: 0;
      max-width: 100%;
      flex-wrap: wrap;
    }

    body.admin-screen #projectPersonnelBuilder [data-personnel-format="fontSize"] {
      width: 68px;
      min-width: 68px;
    }

    body.admin-screen #projectPersonnelBuilder .personnel-collaboration-help > span {
      min-width: 0;
      flex-basis: 100%;
      overflow-wrap: anywhere;
    }

    body.admin-screen :is(#projectPersonnelBuilder, #projectDesignListBuilder) .design-ribbon-actions button {
      flex-direction: column;
      gap: 2px;
      white-space: normal;
    }
  }
}

/* Match the existing alignment icon sizes in all shared table toolbars. */
@media screen {
  :is(#quotePane, #materialsPane, #projectRunbookBuilder) [data-project-format="verticalAlign"] .ph {
    font-size: 24px;
    line-height: 26px;
  }
}

/* Keep material editing actions flush with the scroll viewport, with an opaque mask. */
@media screen {
  body.admin-screen #materialsPane > .material-actions {
    position: sticky;
    top: 0;
    z-index: 30;
    background: #edf5ff;
  }
  body.admin-screen #materialsPane > .material-actions::before {
    content: "";
    position: absolute;
    inset: -20px -26px 0;
    z-index: -1;
    pointer-events: none;
    background: #edf5ff;
  }
}

@media screen {
  body.admin-screen .project-detail-content:has(#materialsPane.project-inline-pane:not(.hidden)) {
    padding-top: 0;
  }
  body.admin-screen .project-detail-content #materialsPane.project-inline-pane {
    border-top: 0;
  }
}

/* All project worksheets use the quote toolbar's control sizes and wrapping. */
@media screen {
  body.admin-screen :is(#quotePane,#materialsPane,#projectPersonnelBuilder,#projectRunbookBuilder,#projectProgressBuilder) :is(.quote-editor-toolbar,.unified-editor-toolbar) {
    display:flex;flex-wrap:wrap;align-items:flex-start;gap:16px;
  }
  body.admin-screen :is(#quotePane,#materialsPane,#projectPersonnelBuilder,#projectRunbookBuilder,#projectProgressBuilder) :is(.quote-editor-tools,.unified-editor-tools) {
    display:flex;flex:1 1 0;min-width:0;gap:8px;align-items:center;flex-wrap:wrap;
  }
  body.admin-screen :is(#quotePane,#materialsPane,#projectPersonnelBuilder,#projectRunbookBuilder,#projectProgressBuilder) :is(.quote-editor-tools,.unified-editor-tools) > .matched-tool-cluster {
    display:flex;flex:0 0 auto;flex-wrap:nowrap;gap:4px;max-width:100%;
  }
  body.admin-screen :is(#quotePane,#materialsPane,#projectPersonnelBuilder,#projectRunbookBuilder,#projectProgressBuilder) .project-format-buttons {
    flex-wrap:nowrap;gap:4px;
  }
  body.admin-screen :is(#quotePane,#materialsPane,#projectPersonnelBuilder,#projectRunbookBuilder,#projectProgressBuilder) :is(.quote-editor-toolbar,.unified-editor-toolbar) .ph {
    font-size:24px;line-height:26px;
  }
  body.admin-screen #projectPersonnelBuilder .unified-editor-toolbar [data-personnel-format="fontFamily"] { width:105px;min-width:105px;max-width:105px; }
  body.admin-screen #projectPersonnelBuilder .unified-editor-toolbar [data-personnel-format="fontSize"] { width:68px;min-width:68px; }
  body.admin-screen #projectPersonnelBuilder .quote-select-control { display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;min-width:35px;font-size:11px;font-weight:400; }
  body.admin-screen #projectPersonnelBuilder .quote-select-control input { width:18px;height:18px;accent-color:#1677ff; }
  body.admin-screen #projectPersonnelBuilder [data-personnel-action="save"] { grid-column:3;grid-row:1;background:#0767f9;color:#fff; }
  body.admin-screen #projectPersonnelBuilder [data-personnel-action="export"] { grid-column:2;grid-row:1; }
  body.admin-screen #projectPersonnelBuilder [data-personnel-action="preview"] { grid-column:1;grid-row:1; }
  body.admin-screen #projectPersonnelBuilder [data-personnel-action="template"] { grid-column:1 / -1;grid-row:2; }
  body.admin-screen #projectPersonnelBuilder [data-personnel-format="bold"] { font-weight:700; }
  body.admin-screen #projectPersonnelBuilder [data-personnel-format="italic"] { font-style:italic; }
  body.admin-screen #projectPersonnelBuilder [data-personnel-format="underline"] { text-decoration:underline; }
  @container workbench (max-width:620px) {
    body.admin-screen :is(#quotePane,#materialsPane,#projectPersonnelBuilder,#projectRunbookBuilder,#projectProgressBuilder) :is(.quote-editor-tools,.unified-editor-tools,.quote-editor-actions,.unified-editor-actions) { flex-basis:100%;width:100%;min-width:0; }
    body.admin-screen :is(#quotePane,#materialsPane,#projectPersonnelBuilder,#projectRunbookBuilder,#projectProgressBuilder) :is(.quote-editor-tools,.unified-editor-tools) > .matched-tool-cluster { flex-wrap:wrap; }
  }
}

/* Schedule actions stay inside the pinned toolbar. */
@media screen {
  body.admin-screen #projectProgressBuilder [data-progress-table-toolbar] { position:sticky;top:0;z-index:30;background:#edf5ff;padding:10px 0; }
  body.admin-screen #projectProgressBuilder [data-progress-table-toolbar]::before { content:"";position:absolute;inset:0 -24px;z-index:-1;background:#edf5ff;pointer-events:none; }
  body.admin-screen .project-detail-content:has(#projectProgressBuilder:not(.hidden)):has([data-project-panel="progress"]:not(.hidden)) { padding-top:0; }
  body.admin-screen #projectProgressBuilder .pp-sheet-toolbar { margin-bottom:0; }
  body.admin-screen #projectProgressBuilder .pp-sheet-toolbar .quote-editor-actions { grid-template-columns:repeat(3,minmax(0,1fr));width:288px;flex-basis:288px; }
  body.admin-screen #projectProgressBuilder [data-progress-table-action="preview"] { grid-column:1;grid-row:1; }
  body.admin-screen #projectProgressBuilder [data-progress-table-action="export"] { grid-column:2;grid-row:1; }
  body.admin-screen #projectProgressBuilder [data-progress-table-action="save"] { grid-column:3;grid-row:1; }
  body.admin-screen #projectProgressBuilder [data-progress-template] { grid-column:1;grid-row:2; }
  body.admin-screen #projectProgressBuilder [data-progress-table-action="template"] { grid-column:2;grid-row:2; }
  body.admin-screen #projectProgressBuilder [data-progress-table-action="refresh-members"] { grid-column:3;grid-row:3; }
  body.admin-screen #projectProgressBuilder [data-progress-table-action="new-template"] { grid-column:3;grid-row:2; }
  body.admin-screen #projectProgressBuilder .pp-sheet-toolbar [data-progress-table-action][aria-pressed="true"] { background:#dceaff;color:#0755bc;border-color:#b6d4ff;font-weight:700; }
  @container workbench (max-width:620px) {
    body.admin-screen #projectProgressBuilder .pp-sheet-toolbar .quote-editor-actions { width:100%;flex-basis:100%; }
  }
}

/* Canonical quote controls first; module-only operations stay in the second-row menu. */
@media screen {
  body.admin-screen :is(#materialsPane,#projectPersonnelBuilder,#projectRunbookBuilder) .editor-more-tools { position:static;grid-column:1;grid-row:2;min-width:0; }
  body.admin-screen :is(#materialsPane,#projectPersonnelBuilder,#projectRunbookBuilder) .unified-editor-actions { position:relative; }
  body.admin-screen #projectPersonnelBuilder .editor-more-tools { grid-column:2; }
  body.admin-screen :is(#materialsPane,#projectPersonnelBuilder,#projectRunbookBuilder) .editor-more-tools > summary {
    display:flex;align-items:center;justify-content:center;width:100%;height:48px;padding:5px 7px;border-radius:6px;border:1px solid transparent;background:#fff;color:#16355b;cursor:pointer;list-style:none;font:400 11px/16px "Microsoft YaHei","PingFang SC",Arial,sans-serif;
  }
  body.admin-screen :is(#materialsPane,#projectPersonnelBuilder,#projectRunbookBuilder) .editor-more-tools > summary::-webkit-details-marker { display:none; }
  body.admin-screen :is(#materialsPane,#projectPersonnelBuilder,#projectRunbookBuilder) .editor-more-tools[open] > .matched-tool-extras {
    position:absolute;right:0;top:calc(100% + 6px);z-index:45;display:flex;gap:6px;flex-wrap:wrap;width:320px;max-width:calc(100vw - 48px);padding:12px;border:1px solid #c6ddf7;border-radius:10px;background:#edf5ff;color:#16355b;box-shadow:0 8px 25px #173b6630;
  }
  body.admin-screen #projectPersonnelBuilder [data-personnel-action="template"] { grid-column:1;grid-row:2; }
  body.admin-screen #materialsPane #materialFontSize { width:68px;min-width:68px; }
  body.admin-screen #materialsPane .quote-select-control { display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;min-width:35px;font-size:11px;font-weight:400; }
  body.admin-screen #materialsPane .quote-select-control input { width:18px;height:18px;accent-color:#1677ff; }
  body.admin-screen #materialsPane #configureMaterialFields::before { content:"\e476"; }
  body.admin-screen #materialsPane #deleteSelectedMaterials::before { content:"\e4a6"; }
  body.admin-screen #projectRunbookBuilder #redoRunbookChange::before { content:"\e08c"; }
  body.admin-screen .material-fields-dialog { width:680px;max-width:calc(100vw - 32px); }
  .material-field-row { display:grid;grid-template-columns:24px minmax(0,1fr) 34px 34px 52px;align-items:center;gap:6px;padding:5px 0; }
  .material-field-row > input { min-width:0; }
  .material-field-row > label { display:flex;align-items:center;justify-content:center; }
  .material-field-row input[type=checkbox] { width:18px;height:18px;min-height:18px; }
  .material-field-row button { min-width:0;padding:5px; }
}
