/* Other > Procurement > Dashboard (public/js/dash-proc.js). Reuses the Performance Marketing tile, filter
   and table classes (pm-*), the dsum queue list, gpill and bx-badge; everything below is the page's own.
   Every hard-coded colour has a [data-theme="dark"] twin at the end. */

.proc-filters { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 2px 0 10px; }
.proc-chk { cursor: pointer; }
.proc-chk input { margin: 0; accent-color: var(--accent); }
.proc-chk input:disabled + span { opacity: .6; }
.proc-qsum { font-size: 12.5px; margin: 0 0 12px; color: var(--muted); line-height: 1.6; }
.proc-qsum a { color: var(--text); text-decoration: none; border-bottom: 1px dotted var(--muted); }
.proc-qsum a:hover { border-bottom-style: solid; }

/* the four tiles: four across at 1280 px, the same five blocks in each so they stay one height */
.proc-tiles { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); align-items: stretch; }
@media (min-width: 1100px) { .proc-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.proc-tile { display: flex; flex-direction: column; gap: 0; }
.proc-tile .pm-tile-head { flex-wrap: nowrap; min-width: 0; }
.proc-tile .pm-place { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.proc-badges { margin-left: auto; display: inline-flex; gap: 4px; flex: none; }
.proc-badges .bx-badge { margin-left: 0; vertical-align: 0; padding: 1px 7px; font-size: 10.5px; }
.proc-k1 { cursor: pointer; margin-top: 4px; }
.proc-hero-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.proc-hero-row .pm-hero { margin-top: 4px; font-size: 30px; }
.proc-vs { font-size: 12px; display: inline-flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.proc-vs .gpill { padding: 1px 7px; font-size: 11.5px; }
.proc-money { font-size: 12px; margin-top: 5px; line-height: 1.4; }
.proc-kpis { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; flex: 1; }
.proc-krow { display: grid; grid-template-columns: 12px minmax(0, 1fr); column-gap: 7px; font-size: 12px; line-height: 1.35; cursor: pointer; align-items: baseline; }
.proc-krow .proc-light { align-self: center; }
.proc-kl { color: var(--muted); }
.proc-kv { grid-column: 2; min-width: 0; overflow-wrap: anywhere; }
/* the footnote wraps (every fact and link stays visible and clickable); margin-top:auto keeps the tiles one height */
.proc-foot { margin-top: auto; padding-top: 7px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted);
  white-space: normal; line-height: 1.35; min-height: 2.7em; overflow-wrap: anywhere; }
.proc-tile > .proc-kpis, .proc-tile > .proc-krow { margin-bottom: 9px; }
.proc-foot a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--muted); }
.proc-rise { color: #8f5507; font-weight: 700; }
.proc-capped { color: #8f5507; font-weight: 600; }
.proc-copy-text { width: 100%; font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; margin: 0 0 10px; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text); resize: vertical; box-sizing: border-box; }
#proc-week a { color: inherit; text-decoration: underline dotted; }
#dash-sub-proc [role="button"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.proc-tile-off { background: #f3f4f6; }
.proc-tile-off .proc-hero-l { margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
.proc-hero-l { font-size: 12px; color: var(--muted); }
.pm-tile-group .proc-kl, .pm-tile-group .proc-foot { color: #5c6573; }
[data-theme="dark"] .pm-tile-group .proc-kl, [data-theme="dark"] .pm-tile-group .proc-foot { color: var(--muted); }

/* lights: 9 px dots; "within noise" is green with a ring */
.proc-light { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #c3c2b7; flex: none; }
.proc-light.green { background: var(--pos); }
.proc-light.noise { background: var(--pos); box-shadow: 0 0 0 1px var(--panel), 0 0 0 2px var(--pos); }
.proc-light.amber { background: #c98a1b; }
.proc-light.red { background: var(--neg); }
.proc-light.none { background: transparent; border: 1px solid #b6b4ab; }

/* badges: performance and data, side by side */
.bx-badge.proc-perf.ok { background: #dcf3e4; color: #136f36; }
.bx-badge.proc-perf.watch { background: #fff1d6; color: #8f5507; }
.bx-badge.proc-perf.warn { background: #fbe3e3; color: #a61b1b; }
.bx-badge.proc-perf.none { background: #eceff3; color: #52606f; }
.bx-badge.data-ok { background: #eef2f7; color: #3b4a5c; }
.bx-badge.data-est { background: #fff1d6; color: #8f5507; }
.bx-badge.data-over { background: #fbe3e3; color: #a61b1b; }

/* P3: diverging bars (KepCharts draws no negatives) */
.proc-div { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 4px; }
.proc-div-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 110px; gap: 10px; align-items: center; font-size: 12.5px; cursor: pointer; }
.proc-div-l { display: inline-flex; gap: 6px; align-items: center; }
.proc-div-l i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.proc-div-bar { position: relative; height: 16px; }
.proc-div-axis { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: #c3c2b7; }
.proc-div-fill { position: absolute; top: 2px; bottom: 2px; border-radius: 3px; }
.proc-div-fill.good { background: #59a14f; }
.proc-div-fill.bad { background: #e15759; }
.proc-div-v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.proc-div-v.good { color: var(--pos); }
.proc-div-v.bad { color: var(--neg); }
.proc-div-tot { border-top: 1px solid var(--border); padding-top: 6px; cursor: default; }
.proc-div-tot .proc-div-bar { height: auto; text-align: center; }

/* owners and queue states */
.proc-own { display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 10.5px; font-weight: 700; background: #e7eef9; color: #1f3a67; vertical-align: 1px; }
.proc-own.fin { background: #eceff3; color: #52606f; }
.proc-own.omer { background: #f3e8f7; color: #6b3a86; }
.proc-queuebox { margin-top: 4px; }
.dsum li.dsum-info { border-left-color: #8b96a5; background: #f5f7fa; } .dsum-info .dsum-chip { background: #6b7482; color: #fff; }
.proc-week td { font-size: 12.5px; }
.proc-week td.proc-amber { background: #fff4dc; }
#proc-restated summary { cursor: pointer; margin-top: 8px; }

/* tables */
.proc-click { cursor: pointer; }
.proc-click:hover td { background: rgba(20, 83, 45, .05); }
.proc-flag td:first-child { box-shadow: inset 3px 0 0 #c98a1b; }
/* a company's heading row inside a multi-company table */
tr.proc-co-row td { background: var(--bg, #f6f7f9); border-top: 2px solid var(--border); padding-top: 7px; padding-bottom: 7px; font-size: 12.5px; }
tr.proc-co-row .pm-sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--co); margin-right: 6px; vertical-align: -1px; }
.proc-bad { color: var(--neg); }
.pm-tbl td.proc-note { white-space: normal; min-width: 140px; max-width: 260px; font-size: 12px; color: var(--muted); }
/* table footnotes and long explanation cells wrap (pm-tbl cells are nowrap), so no table outgrows its box at 1280 px */
#dash-sub-proc .pm-tbl tfoot td, #dash-sub-proc .pm-tbl td.proc-wrap { white-space: normal; }
#dash-sub-proc .pm-tbl td.proc-wrap { min-width: 220px; }
.proc-mst { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 999px; font-size: 10px; font-weight: 700; font-style: normal; background: #eceff3; color: #52606f; }
.proc-mst.scored { background: #dcf3e4; color: #136f36; }
.proc-mst.provisional, .proc-mst.not-covered { background: #fff1d6; color: #8f5507; }
.proc-cell { cursor: pointer; }
.proc-st.overdue { color: var(--neg); }
.proc-st.due { color: #b7791f; }
.proc-dd td { vertical-align: top; }
/* the Procurement drill (#dd-table.proc-dd-rows): every column sized so nothing
   runs into its neighbour — the supplier and its note take the slack and wrap */
#dd-table.proc-dd th, #dd-table.proc-dd td { overflow-wrap: anywhere; word-break: normal; }
/* fixed columns: the supplier keeps >= ~180 px in a 900 px popup; Co. and Line are left out when every row shares
   them, and the extra column takes the width its caller gives it */
#dd-table.proc-dd-rows .c-n { width: 50px; }
#dd-table.proc-dd-rows .c-co { width: 56px; }
#dd-table.proc-dd-rows .c-dt { width: 88px; }
#dd-table.proc-dd-rows .c-sv { width: 62px; }
#dd-table.proc-dd-rows .c-sup { width: auto; }
#dd-table.proc-dd-rows .c-ln { width: 100px; }
#dd-table.proc-dd-rows .c-dp { width: 104px; }
#dd-table.proc-dd-rows .c-ex { width: 96px; }
#dd-table.proc-dd-rows .c-amt { width: 118px; }
#dd-table.proc-dd-rows .c-usd { width: 64px; }
#dd-table.proc-dd-rows .c-lk { width: 58px; }
#dd-table.proc-dd-rows .c-inv { width: 64px; text-align: center; }
#dd-table.proc-dd-rows .t-inv { text-align: center; white-space: nowrap; }
#dd-table.proc-dd-rows .t-inv a { text-decoration: none; } /* the drill's Invoice column (migration 422) */
/* text columns wrap inside their own width (the Ledger drill's cells are nowrap); dates, months, numbers stay on one line */
#dd-table.proc-dd-rows td, #dd-table.proc-dd-rows th { white-space: normal; }
#dd-table.proc-dd-rows td.t-co, #dd-table.proc-dd-rows td.t-dt, #dd-table.proc-dd-rows td.t-sv, #dd-table.proc-dd-rows td.num, #dd-table.proc-dd-rows td.t-lk { white-space: nowrap; }
/* words break only between words; a long unbroken token (an IBAN, a URL) may still break so it cannot overflow */
#dd-table.proc-dd-rows td { overflow-wrap: break-word; }
/* Why it moved popup: four figures above the table, then Now and Before as sections */
#dd-sub .proc-dd-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
#dd-sub .proc-dd-t { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2, transparent); }
#dd-sub .proc-dd-tl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
#dd-sub .proc-dd-t b { font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums; }
#dd-sub .proc-dd-t.bad b, .dd-total .bad { color: var(--neg); }
#dd-sub .proc-dd-t.good b, .dd-total .good { color: var(--pos); }
@media (max-width: 720px) { #dd-sub .proc-dd-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
#dd-table.proc-dd-rows tr.proc-sec-h td { white-space: normal; padding-top: 14px; background: var(--surface-2, rgba(127,127,127,.06)); border-top: 2px solid var(--border); font-size: 13px; }
#dd-table.proc-dd-rows tr.proc-sec-h td b { margin-right: 6px; }
#dd-table.proc-dd-rows .proc-dd-exnote { color: var(--text); font-style: italic; }
/* a queue's own list: no fixed columns, cells wrap */
#dd-table.proc-dd-list { table-layout: auto; }
#dd-table.proc-dd-list td { white-space: normal; }
/* auto layout: words never break mid-word (anywhere would let a column shrink to one letter), numbers, links
   and buttons stay on one line and take only their own width */
#dd-table.proc-dd-list th, #dd-table.proc-dd-list td { overflow-wrap: normal; }
#dd-table.proc-dd-list td.num, #dd-table.proc-dd-list td:has(> a.proc-led-ids), #dd-table.proc-dd-list td:has(> button) { white-space: nowrap; }
#dd-table.proc-dd-list td:has(> a.proc-led-ids), #dd-table.proc-dd-list td:has(> button) { width: 1%; }
#dd-table.proc-dd-list th { vertical-align: bottom; white-space: normal; }

/* the closed panels: a details whose summary carries the panel heading */
details.proc-fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.proc-fold > summary::-webkit-details-marker { display: none; }
details.proc-fold > summary::before { content: '▸'; color: var(--muted); font-size: 13px; }
details.proc-fold[open] > summary::before { content: '▾'; }
details.proc-fold > summary h2 { margin: 0; display: inline; }
details.proc-fold[open] > summary { margin-bottom: 10px; }

@media (max-width: 700px) {
  .proc-div-row { grid-template-columns: 100px minmax(0, 1fr) 80px; gap: 6px; }
  .proc-badges { flex-wrap: wrap; }
  .proc-tile .pm-tile-head { flex-wrap: wrap; }
}

/* ---- dark theme twins ---- */
[data-theme="dark"] .proc-rise, [data-theme="dark"] .proc-capped { color: var(--d-warn-fg); }
/* app.css darkens only the good-news pill's background: its #136f36 text would be 2.3:1 on #17301f */
[data-theme="dark"] #dash-sub-proc .gpill.up, [data-theme="dark"] #dd-modal .proc-dd .gpill.up { color: var(--d-ok-fg); }
[data-theme="dark"] .proc-tile-off { background: var(--d-sunk); }
[data-theme="dark"] .proc-light { background: #4a525e; }
[data-theme="dark"] .proc-light.green, [data-theme="dark"] .proc-light.noise { background: var(--pos); }
[data-theme="dark"] .proc-light.amber { background: #e0a33b; }
[data-theme="dark"] .proc-light.red { background: var(--neg); }
[data-theme="dark"] .proc-light.none { background: transparent; border-color: var(--d-border-strong); }
[data-theme="dark"] .bx-badge.proc-perf.ok { background: var(--d-ok-bg); color: var(--d-ok-fg); }
[data-theme="dark"] .bx-badge.proc-perf.watch, [data-theme="dark"] .bx-badge.data-est { background: var(--d-warn-bg); color: var(--d-warn-fg); }
[data-theme="dark"] .bx-badge.proc-perf.warn, [data-theme="dark"] .bx-badge.data-over { background: var(--d-bad-bg); color: var(--neg); }
[data-theme="dark"] .bx-badge.proc-perf.none, [data-theme="dark"] .bx-badge.data-ok { background: var(--d-hover); color: var(--d-text-2); }
[data-theme="dark"] .proc-div-axis { background: #4a525e; }
[data-theme="dark"] .proc-div-fill.good { background: #4f9a47; }
[data-theme="dark"] .proc-div-fill.bad { background: #d9534f; }
[data-theme="dark"] .proc-own { background: var(--d-info-bg); color: var(--d-info-fg); }
[data-theme="dark"] .proc-own.fin { background: var(--d-hover); color: var(--d-text-2); }
[data-theme="dark"] .proc-own.omer { background: #2e2238; color: #d3b2e6; }
[data-theme="dark"] .dsum li.dsum-info { background: var(--d-raised); border-left-color: var(--d-border-strong); }
[data-theme="dark"] .proc-week td.proc-amber { background: var(--d-warn-bg); }
[data-theme="dark"] .proc-click:hover td { background: rgba(87, 201, 138, .07); }
[data-theme="dark"] .proc-flag td:first-child { box-shadow: inset 3px 0 0 #e0a33b; }
[data-theme="dark"] .proc-mst { background: var(--d-hover); color: var(--d-text-2); }
[data-theme="dark"] .proc-mst.scored { background: var(--d-ok-bg); color: var(--d-ok-fg); }
[data-theme="dark"] .proc-mst.provisional, [data-theme="dark"] .proc-mst.not-covered { background: var(--d-warn-bg); color: var(--d-warn-fg); }
[data-theme="dark"] .proc-st.due { color: var(--d-warn-fg); }
[data-theme="dark"] #dash-sub-proc .dsum-advice { color: var(--muted); }
[data-theme="dark"] #dash-sub-proc .dsum-advice a { color: var(--text); }

/* Price steps: grouped headers, whole words (no hyphenation), each window's months under its name */
#proc-steps thead th { hyphens: manual !important; vertical-align: bottom; }
#proc-steps thead tr.grp th.proc-grp { text-align: center; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: none; letter-spacing: 0; border-bottom: 1px solid var(--border); padding-bottom: 3px; }
#proc-steps thead th .proc-th-m { display: block; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); }
