/* Pane-aware layout (nav/cx-layout.js).
 * Module pages were written with viewport @media rules, but they live in
 * panes that are much narrower than the window. These container queries
 * size them by the pane they're actually in. */
#paneB > .pb, #paneC > .pb { container-type: inline-size; container-name: cxpane; }
.colB.cx-anim, .colC.cx-anim { transition: flex-basis .22s ease, width .22s ease; }
.workspace[data-roomy] .colB { flex-basis: var(--paneBRoomy) !important; width: var(--paneBRoomy) !important; }

/* KPI strips: 6 across only when there's room for 6. */
@container cxpane (max-width: 900px) {
  #paneB .cx-pa-list .kpi-strip, #paneB .cx-sov .kpi-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #paneB .cx-contracts .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #paneB .cx-pa-list .pa-charts, #paneB .cx-sov .charts-row, #paneB .cx-contracts .charts { grid-template-columns: 1fr; }
}
@container cxpane (max-width: 520px) {
  #paneB .cx-pa-list .kpi-strip, #paneB .cx-sov .kpi-strip, #paneB .cx-contracts .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container cxpane (max-width: 1200px) and (min-width: 901px) {
  #paneB .cx-pa-list .kpi-strip, #paneB .cx-sov .kpi-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Undo the viewport rules when the pane is wide (e.g. focus mode on a laptop). */
@container cxpane (min-width: 1201px) {
  #paneB .cx-pa-list .kpi-strip, #paneB .cx-sov .kpi-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
#paneB .cx-pa-list .kpi, #paneB .cx-sov .kpi { min-width: 0; }
#paneB .cx-pa-list .kpi .val, #paneB .cx-sov .kpi .val { font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Submittal log: keep the title visible in a narrow pane. */
@container cxpane (max-width: 560px) {
  #paneB .cx-row { grid-template-columns: 4px minmax(0, 1fr) auto; row-gap: 3px; column-gap: 10px; align-items: start; }
  #paneB .cx-row .cx-strip { grid-row: 1 / span 3; grid-column: 1; align-self: stretch; height: auto; }
  #paneB .cx-row .col-id { grid-column: 2; grid-row: 1; }
  #paneB .cx-row .col-main { grid-column: 2 / span 2; grid-row: 2; }
  #paneB .cx-row .col-status { grid-column: 3; grid-row: 1; flex-direction: row; align-items: center; gap: 6px; }
  #paneB .cx-row .col-bic { grid-column: 2 / span 2; grid-row: 3; flex-direction: row; align-items: center; gap: 6px; }
  #paneB .cx-row .col-bic .badge { max-width: 70%; }
}

/* Submittal editor: one column when the workspace is narrow. */
@container cxpane (max-width: 820px) {
  #paneC .cx-layout { display: block; overflow-y: auto; }
  #paneC .cx-layout .cx-sidebar { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; border-right: 0; border-bottom: 1px solid var(--border, #e2e8f0); overflow: visible; }
  #paneC .cx-layout .cx-sidebar > .cx-hint { grid-column: 1 / -1; margin-top: 6px; }
  #paneC .cx-layout .cx-main { height: auto; overflow: visible; }
  #paneC .cx-layout .cx-timeline-container { overflow: visible; flex: none; }
}
@container cxpane (min-width: 821px) and (max-width: 1100px) {
  #paneC .cx-layout { grid-template-columns: 270px minmax(0, 1fr); }
  #paneC .cx-layout .cx-sidebar { padding: 16px; gap: 14px; }
}

/* Contracts toolbar: search drops to its own row when the pane is narrow */
@container cxpane (max-width: 640px) {
  #paneB .cx-contracts .toolbar { flex-wrap: wrap; row-gap: 8px; }
  #paneB .cx-contracts .toolbar .search-wrap { order: 5; flex: 1 1 100%; max-width: none; }
  #paneB .cx-contracts .toolbar .title { flex: 1 1 auto; }
}

/* Budget list beside an open workspace: the forecast lives in pane C, so the list
   keeps code, description, budget, forecast and over/under and drops the rest. */
#paneB .cx-bud-table .c-code { white-space: nowrap; }
@container cxpane (max-width: 640px) {
  #paneB .cx-budget .cxb-kpis, #paneB .cx-budget .cxb-info { display: none !important; }
  #paneB .cx-bud-table :is(th, td):nth-child(n+4):nth-child(-n+7) { display: none !important; }
  #paneB .cx-bud-table :is(th, td) { padding: 7px 8px !important; }
  #paneB .cx-bud-table td.c-desc { max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@container cxpane (max-width: 440px) {
  #paneB .cx-bud-table :is(th, td):nth-child(9) { display: none !important; }
  #paneB .cx-bud-table td.c-desc { max-width: 120px; }
}

/* Pay apps beside an open pay app: the list comes first and the charts step aside. */
@container cxpane (max-width: 640px) {
  #paneB .cx-pa-list .pa-table-wrap { order: -1; }
  #paneB .cx-pa-list .header { order: -2; }
  #paneB .cx-pa-list .pa-charts { display: none; }
  #paneB .cx-pa-list .kpi-strip { gap: 8px; }
  #paneB .cx-pa-list .kpi { padding: 10px 12px; }
  #paneB .cx-pa-list .kpi .val { font-size: 17px; }
  #paneB .cx-pa-list .data-grid td { padding: 9px 8px; }
}
@container cxpane (max-width: 640px) {
  #paneB .cx-pa-list .data-grid :is(th, td):nth-child(4), #paneB .cx-pa-list .data-grid :is(th, td):nth-child(6) { display: none; }
}

/* Room for the body (nav/cx-room.js): toolbars tuck away while scrolling down. */
#paneB, #paneC { position: relative; }
.cx-room-tucked { display: none !important; }
.cx-unstick { position: relative !important; top: auto !important; }
.cx-room-tab {
  position: absolute; z-index: 40; left: 50%; top: 46px; transform: translate(-50%, -2px);
  display: none; align-items: center; gap: 4px; height: 22px; padding: 0 10px 0 8px;
  border: 1px solid var(--line, #d8dce4); border-top: 0; border-radius: 0 0 9px 9px;
  background: var(--panel, #fff); color: var(--muted, #64748b);
  font: 600 11px/1 Inter, system-ui, sans-serif; cursor: pointer;
  box-shadow: 0 3px 8px rgba(16, 24, 40, .08);
}
.cx-room-tab:hover { color: var(--text, #0f172a); }
.cx-room-on > .cx-room-tab { display: inline-flex; animation: cxRoomTab .18s ease; }
@keyframes cxRoomTab { from { opacity: 0; transform: translate(-50%, -8px); } }
@media (prefers-reduced-motion: reduce) { .cx-room-on > .cx-room-tab { animation: none; } }
@media print { .cx-room-tab { display: none !important; } .cx-room-tucked { display: revert !important; } }
