/* Step 5: executive summary (step-summary.js). Calm one-pager for the S&OP review: three columns without page scroll
   from ~1400 px of window, two or one column with page scroll below (0.62, F-58); prints as one A4 landscape sheet.
   All rules prefixed .sum- */
.sum-page {
  --sum-fin: var(--orange); --sum-prev: var(--navy); --sum-ly: #CDD5E3;
  --sum-up: #5F84C6; --sum-down: #C9604B;
  flex: 1; min-height: 0; display: flex; flex-direction: column; background: #fff; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.sum-grow { flex: 1; }
.sum-t { font-size: 11px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; color: var(--navy-3); white-space: nowrap; }
.sum-meta { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sum-sec-h { display: flex; align-items: center; gap: 10px; min-height: 22px; }
.sum-empty { font-size: 12.5px; color: var(--ink-3); padding: 6px 0; }

/* step bar: one 44px row (wraps on a narrow window instead of cutting the numbers) */
.sum-bar { flex: none; min-height: 44px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 6px 16px 6px 20px; border-bottom: 1px solid var(--line); background: #fff; min-width: 0; }
.sum-bar h1 { font-size: 16.5px; font-weight: 720; white-space: nowrap; letter-spacing: -.01em; }
.sum-status { flex: none; }
.sum-status svg { margin-right: -1px; }
.sum-counters { display: flex; align-items: baseline; gap: 7px; min-width: 0; overflow: hidden; white-space: nowrap; font-size: 13px; color: var(--ink-2); }
.sum-counters b { color: var(--navy-3); font-weight: 750; font-size: 14px; }
.sum-dot { color: var(--ink-3); }
.sum-printmeta { display: none; }
/* 0.62 (F-60): "w zakresie: …" when the page shows a scope */
.sum-scope-w { display: inline-flex; align-items: center; gap: 2px; min-width: 0; max-width: 460px; }
.sum-scope-w:empty { display: none; }
.sum-scope { display: inline-block; min-width: 0; max-width: 100%; height: 24px; line-height: 24px; padding: 0 10px; border-radius: 12px; background: var(--navy-soft); color: var(--navy-3); font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum-x { flex: none; width: 22px; height: 22px; border: 0; border-radius: 11px; background: none; color: var(--ink-3); font-size: 15px; line-height: 1; cursor: pointer; }
.sum-x:hover { background: var(--line-2); color: var(--navy); }
.sum-scopebar { flex: none; }
.sum-btns { display: flex; align-items: center; gap: 8px; flex: none; }
.sum-btns .btn.small { height: 32px; gap: 6px; }
.sum-primary { padding: 0 16px; }

/* body: three zones. 0.62 (F-58): the middle never scrolls sideways (that hid the start of its titles and the first
   bar under the left column); below ~1400 px of window the changes go under the middle, below ~1000 px one column */
.sum-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 270px minmax(0, 1fr) 370px; }
.sum-left, .sum-mid, .sum-right { min-height: 0; overflow: auto; }
.sum-mid { overflow-x: hidden; }

/* left: readiness */
.sum-left { background: #FAFBFD; border-right: 1px solid var(--line); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.sum-segs { display: flex; gap: 3px; }
.sum-seg { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.sum-seg.ok { background: var(--ok); } .sum-seg.warn { background: #E2A93B; }
.sum-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sum-check { width: 100%; display: grid; grid-template-columns: 20px minmax(0, 1fr) 16px; gap: 9px; align-items: center; text-align: left; border: 1px solid transparent;
  background: none; border-radius: 9px; padding: 6px 8px 6px 6px; cursor: pointer; font: inherit; color: inherit; }
.sum-check:hover { background: #fff; border-color: var(--line); box-shadow: 0 1px 3px rgba(18,37,90,.06); }
.sum-mark { width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; font-style: normal; font-size: 12px; font-weight: 800; }
.sum-check.ok .sum-mark { background: var(--ok-soft); color: var(--ok); }
.sum-check.warn .sum-mark { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px rgba(168,117,8,.25); }
.sum-check.na .sum-mark { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.sum-check-tx { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.sum-check-tx b { font-size: 13px; font-weight: 650; color: var(--navy-3); }
.sum-check.warn .sum-check-tx b { color: #7A5506; }
.sum-check.na .sum-check-tx b { color: var(--ink-3); font-weight: 600; }
.sum-check-tx small { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum-go { color: var(--ink-3); opacity: 0; transition: opacity .15s, transform .15s; display: grid; }
.sum-check:hover .sum-go { opacity: 1; transform: translateX(2px); color: var(--orange-d); }
.sum-note { font-size: 11.5px; color: var(--ink-3); line-height: 1.4; padding: 0 2px; }
.sum-version { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); line-height: 1.4; }
.sum-version b { color: var(--navy-3); }
.sum-privacy { display: flex; gap: 6px; align-items: flex-start; color: var(--ink-3); font-size: 11px; }
.sum-privacy svg { flex: none; margin-top: 2px; }

/* middle */
.sum-mid { padding: 12px 18px; display: flex; flex-direction: column; gap: 10px; }
.sum-card { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 6px; display: flex; flex-direction: column; min-height: 0; background: #fff; }
.sum-wfsec { flex: 1.15 1 0; min-height: 170px; }
.sum-wf-help { margin: 6px 2px 0; }
.sum-mbsec { flex: 1 1 0; min-height: 130px; }
/* 0.63: the middle column also holds the "Według" table now, so on screen the charts keep a fixed height and the
   column scrolls (shared flex height squeezed the bridge labels into each other at 1920 px); print keeps the flex */
@media screen { .sum-wfsec { flex: none; height: 270px; } .sum-mbsec { flex: none; height: 230px; } }
.sum-toggle { padding: 2px; border-radius: 8px; }
.sum-toggle button { height: 22px; padding: 0 9px; font-size: 11.5px; border-radius: 6px; white-space: nowrap; }
.sum-first { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

/* waterfall */
.sum-wf { flex: 1; min-height: 0; display: flex; margin-top: 4px; }
.sum-wf-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sum-wf-plot { position: relative; flex: 1; min-height: 40px; margin-top: 28px; border-bottom: 1px solid var(--line); }
.sum-wf-bar { position: absolute; left: 22%; width: 56%; border-radius: 3px 3px 0 0; min-height: 2px; }
.sum-wf-bar.base { background: var(--sum-prev); }
.sum-wf-bar.end { background: var(--sum-fin); }
.sum-wf-bar.up { background: var(--sum-up); border-radius: 3px; }
.sum-wf-bar.down { background: var(--sum-down); border-radius: 3px; }
.sum-wf-bar.zero { background: var(--ink-3); opacity: .35; height: 2px !important; border-radius: 1px; }
.sum-wf-bar.cut::after { content: ''; position: absolute; left: -1px; right: -1px; bottom: 7px; height: 5px; background: #fff; transform: skewY(-8deg); }
.sum-wf-link { position: absolute; left: 78%; width: 44%; border-top: 1px dashed #AEB8CA; z-index: 1; pointer-events: none; }
.sum-wf-val { position: absolute; left: 0; right: 0; text-align: center; font-size: 12.5px; font-weight: 750; color: var(--navy-3); line-height: 1.15; white-space: nowrap; }
.sum-wf-val small { display: block; font-size: 10.5px; font-weight: 600; color: var(--ink-3); }
.sum-wf-col.up .sum-wf-val { color: #3E61A3; } .sum-wf-col.down .sum-wf-val { color: #A9452F; }
.sum-wf-col.zero .sum-wf-val { color: var(--ink-3); font-weight: 600; }
.sum-wf-col.end .sum-wf-val { color: var(--orange-d); }
.sum-wf-lab { height: 31px; padding: 4px 2px 0; font-size: 11px; line-height: 1.2; color: var(--ink-2); text-align: center; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.sum-wf-col.base .sum-wf-lab, .sum-wf-col.end .sum-wf-lab { font-weight: 650; color: var(--navy-3); }

/* monthly bars */
.sum-legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--ink-2); }
.sum-lg { display: inline-flex; align-items: center; gap: 5px; }
.sum-lg i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.sum-lg i.fin, .sum-mb-bars i.fin { background: var(--sum-fin); }
.sum-lg i.prev, .sum-mb-bars i.prev { background: var(--sum-prev); }
.sum-lg i.ly, .sum-mb-bars i.ly { background: var(--sum-ly); }
.sum-mb { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 6px 0 0 54px; }
.sum-mb-grid { position: absolute; left: 0; right: 0; top: 0; bottom: 18px; pointer-events: none; }
.sum-mb-gl { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line-2); }
.sum-mb-gl:last-child { border-top-color: var(--line); }
.sum-mb-gl span { position: absolute; right: calc(100% + 6px); top: -7px; font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
.sum-mb-cols { position: relative; flex: 1; min-height: 0; display: flex; }
.sum-mb-col { flex: 1; min-width: 0; display: flex; flex-direction: column; transition: opacity .2s; }
.sum-mb-col.dim { opacity: .38; }
.sum-mb-col:hover .sum-mb-bars { background: rgba(18,37,90,.035); }
.sum-mb-bars { flex: 1; min-height: 0; display: flex; align-items: flex-end; justify-content: center; gap: 2px; padding: 0 12%; border-radius: 4px 4px 0 0; }
.sum-mb-bars i { flex: 1; max-width: 12px; border-radius: 2px 2px 0 0; display: block; }
.sum-mb-lab { height: 18px; padding-top: 3px; font-size: 10.5px; color: var(--ink-3); text-align: center; white-space: nowrap; }

/* accuracy stairs: one line */
.sum-acc { flex: none; display: flex; flex-direction: column; gap: 3px; padding: 6px 12px 7px; border-radius: 10px; background: var(--navy-soft); }
.sum-acc.empty { display: flex; flex-direction: row; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; background: var(--line-2); }
.sum-acc-h { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sum-lowpill { height: 18px; font-size: 10.5px; background: #fff; }
.sum-stairs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.sum-acc-wait { white-space: normal; min-width: 0; flex: 1 1 200px; }
.sum-stair { display: grid; grid-template-columns: auto auto; column-gap: 7px; align-items: baseline; line-height: 1.15; white-space: nowrap; }
.sum-stair small { grid-column: 1 / -1; }
.sum-stair small { font-size: 11px; color: var(--ink-2); }
.sum-stair b { font-size: 18px; font-weight: 780; color: var(--navy-3); letter-spacing: -.01em; }
.sum-stair.fin b { color: var(--orange-d); }
.sum-stair em { font-style: normal; font-size: 11px; font-weight: 650; color: var(--ink-3); }
.sum-stair em.pos { color: var(--ok); } .sum-stair em.neg { color: var(--bad); }
.sum-arrow { color: #9AA7BD; display: grid; }
.sum-acc-side { margin-left: auto; display: grid; gap: 1px; font-size: 12px; color: var(--ink-2); text-align: right; white-space: nowrap; }
.sum-acc-side b { color: var(--navy-3); }
.sum-acc.low .sum-stair b, .sum-acc.low .sum-acc-side b { color: var(--ink-3); }

/* top reasons */
.sum-rsn { flex: none; }
.sum-link { margin-left: auto; border: 0; background: none; padding: 0; font: 600 11.5px var(--font); color: var(--blue); cursor: pointer; white-space: nowrap; }
.sum-link:hover { text-decoration: underline; }
.sum-rsn-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 3px; }
.sum-rsn-list li { display: grid; grid-template-columns: minmax(0, 210px) minmax(0, 1fr) 42px 74px; gap: 10px; align-items: center; height: 20px; font-size: 12.5px; }
.sum-rsn-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.sum-rsn-bar { height: 7px; border-radius: 4px; background: var(--line-2); overflow: hidden; }
.sum-rsn-bar i { display: block; height: 100%; border-radius: 4px; background: var(--navy); opacity: .8; }
.sum-rsn-v { text-align: right; color: var(--navy-3); }
.sum-rsn-a { font-size: 11.5px; color: var(--navy); font-weight: 600; text-align: right; }
.sum-rsn-a.none { color: var(--warn); font-weight: 600; }

/* 0.62 (F-60): "Według" with a perspective switch and drill down to the items */
.sum-pv { flex: none; gap: 4px; padding-bottom: 8px; }
.sum-pv-h { flex-wrap: wrap; row-gap: 4px; }
.sum-pv-sw { flex-wrap: wrap; max-width: 100%; }
.sum-pv-print { display: none; }
.sum-pv-crumb { display: flex; align-items: baseline; gap: 10px; min-width: 0; font-size: 12.5px; color: var(--ink-2); }
.sum-pv-crumb .sum-link { margin-left: 0; }
.sum-pv-path { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum-pv-path b { color: var(--navy-3); }
.sum-pv-tbl { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12.5px; }
.sum-pv-tbl th { font-size: 11px; font-weight: 600; color: var(--ink-3); text-align: left; padding: 3px 8px 4px 0; border-bottom: 1px solid var(--line-2); line-height: 1.2; vertical-align: bottom; }
.sum-pv-tbl th.n { width: 76px; text-align: right; }
.sum-pv-tbl th.share { width: 50px; } /* not .sh: that is the Arkusz grid (sheet.css, display: flex) */
.sum-pv-tbl td { padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum-pv-tbl td.n { text-align: right; font-variant-numeric: tabular-nums; }
.sum-pv-tbl td.n b { color: var(--navy-3); font-weight: 700; }
.sum-pv-tbl td.up { color: #3E61A3; } .sum-pv-tbl td.down { color: #A9452F; }
.sum-pv-tbl tr.clickable { cursor: pointer; }
.sum-pv-tbl tr.clickable:hover td { background: #FAFBFD; }
.sum-pv-tbl tr.clickable:hover .sum-pv-nm { color: var(--orange-d); }
.sum-pv-nm { color: var(--navy-3); font-weight: 600; }
.sum-pv-nm .sum-loc { font-weight: 500; color: var(--ink-3); font-size: 11.5px; margin-left: 6px; }
.sum-pv-cnt { font-weight: 500; color: var(--ink-3); font-size: 11px; }
.sum-pv-tbl tfoot td { border-bottom: 0; border-top: 1px solid var(--line); font-weight: 650; color: var(--navy-3); }
.sum-pv-foot { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.sum-pv-foot .sum-link { margin-left: 0; }
.sum-none { flex: none; gap: 8px; padding: 14px; font-size: 13px; color: var(--ink-2); }

/* right: biggest changes */
.sum-right { border-left: 1px solid var(--line); padding: 12px 14px 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.sum-right > .sum-sec-h { flex: none; }
.sum-right-meta { flex: none; margin-top: -4px; }
.sum-top { list-style: none; margin: 0; padding: 0; overflow: auto; min-height: 0; }
.sum-top li { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 8px; padding: 7px 4px 7px 0; border-bottom: 1px solid var(--line-2); cursor: pointer; border-radius: 6px; }
.sum-top li:hover { background: #FAFBFD; }
.sum-top li:last-child { border-bottom: 0; }
.sum-rank { font-size: 11px; font-weight: 750; color: var(--ink-3); padding-top: 2px; text-align: right; }
.sum-top-main { min-width: 0; display: grid; gap: 3px; }
.sum-top-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.sum-top-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 650; color: var(--navy-3); }
.sum-top-name .sum-loc { font-weight: 500; color: var(--ink-3); font-size: 11.5px; margin-left: 6px; }
.sum-top-d { font-weight: 750; font-size: 13px; white-space: nowrap; }
.sum-top-d.up { color: #3E61A3; } .sum-top-d.down { color: #A9452F; }
.sum-top-p { width: 44px; text-align: right; font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.sum-top-mag { height: 3px; border-radius: 2px; background: var(--line-2); overflow: hidden; }
.sum-top-mag i { display: block; height: 100%; border-radius: 2px; }
.sum-top-mag i.up { background: var(--sum-up); } .sum-top-mag i.down { background: var(--sum-down); }
.sum-why { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum-src { height: 18px; font-size: 10.5px; padding: 0 7px; flex: none; }
.sum-src.app { background: #EEF0FB; color: #4B4FA6; }
.sum-src.sales { background: var(--ok-soft); color: var(--ok); }
.sum-src.planner { background: var(--orange-soft); color: var(--orange-d); }
.sum-src.other, .sum-src.stat { background: var(--line-2); color: var(--ink-2); }
.sum-noreason { color: var(--warn); font-weight: 600; }
.sum-assume { font-size: 11.5px; color: var(--ink-2); font-style: italic; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* print-only footer */
.sum-foot { display: none; }

/* approved: a quiet confirmation tint on the bar */
.sum-page.is-approved .sum-bar { background: linear-gradient(90deg, var(--ok-soft), #fff 40%); }

/* 0.62 (F-58): widths of the window (with the side menu of 248 px). Three columns only where the middle keeps at
   least ~500 px; below ~1400 px two columns (the 10 biggest changes under the middle, the page scrolls); below ~1000 px
   one column. Print keeps its own three columns (below). */
@media screen and (min-width: 1600px) {
  .sum-body { grid-template-columns: 290px minmax(0, 1fr) 400px; }
  .sum-mid { padding: 14px 22px; gap: 12px; }
}
@media screen and (max-width: 1499px) {
  .sum-body { grid-template-columns: 250px minmax(0, 1fr) 340px; }
  .sum-mid { padding: 12px 14px; }
}
@media screen and (max-width: 1399px) {
  .sum-body { grid-template-columns: 250px minmax(0, 1fr); grid-template-rows: auto auto; align-items: start; overflow-y: auto; }
  .sum-left { grid-row: 1 / span 2; align-self: stretch; }
  .sum-version { margin-top: 10px; }
  /* overflow-x: hidden would turn overflow-y: visible into auto (a scroll box sized to 0 in the grid row, the next
     block then lies over it); clip keeps the sideways cut without that */
  .sum-mid, .sum-right { grid-column: 2; overflow: visible; min-height: auto; }
  .sum-mid { overflow-x: clip; }
  .sum-right { border-left: 0; border-top: 1px solid var(--line); padding: 12px 14px 16px; }
  .sum-top { overflow: visible; }
  .sum-wfsec { flex: none; height: 270px; }
  .sum-mbsec { flex: none; height: 220px; }
}
@media screen and (max-width: 999px) {
  .sum-body { grid-template-columns: minmax(0, 1fr); }
  .sum-left { grid-row: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sum-mid, .sum-right { grid-column: 1; }
  .sum-btns { flex-wrap: wrap; }
  .sum-scopebar { overflow-x: auto; }
}

/* ---------- print: one A4 landscape page ---------- */
@media print {
  @page { size: A4 landscape; margin: 8mm 9mm; }
  html, body { height: 100% !important; overflow: hidden !important; background: #fff !important; }
  body * { visibility: hidden; }
  .sum-page, .sum-page * { visibility: visible; }
  .side, .topbar, .cyc-steps, .fb-btn, #toasts, .chart-tip, .sum-btns, .sum-toggle, .sum-go, .sum-link, .modal-back, .sum-scopebar, .sum-x, .search-pop, .picker-pop { display: none !important; }
  .sum-page {
    position: fixed; left: 0; top: 0; width: 279mm; height: 193mm; overflow: hidden; z-index: 9999;
    -webkit-print-color-adjust: exact; print-color-adjust: exact; font-size: 12px;
  }
  .sum-bar { min-height: 34px; padding: 0 2px 6px; background: #fff !important; border-bottom: 2px solid var(--navy); }
  .sum-scope-w { max-width: 120mm; }
  .sum-pv-print { display: inline; font-size: 11px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; color: var(--navy-3); }
  .sum-pv-tbl { font-size: 11px; }
  .sum-pv-tbl tbody tr:nth-child(n+7) { display: none; }
  .sum-pv-tbl th.n { width: 62px; }
  .sum-wf-help { display: none; }
  .sum-bar h1 { font-size: 17px; }
  .sum-counters { overflow: visible; }
  .sum-printmeta { display: block; margin-left: auto; font-size: 11px; color: var(--ink-3); white-space: nowrap; }
  .sum-body { grid-template-columns: 52mm minmax(0, 1fr) 80mm; }
  .sum-mb-lab { font-size: 9.5px; }
  .sum-stair b { font-size: 16px; }
  .sum-stairs { gap: 6px; }
  .sum-acc-side { font-size: 11px; }
  .sum-left, .sum-mid, .sum-right { overflow: hidden; }
  .sum-left { background: #fff; padding: 10px 10px 6px 2px; }
  .sum-mid { padding: 10px 12px; gap: 8px; }
  .sum-right { padding: 10px 2px 6px 12px; }
  .sum-top { overflow: hidden; }
  .sum-top li { padding: 5px 0; }
  .sum-check { padding: 4px 4px 4px 0; }
  .sum-wfsec { min-height: 0; }
  .sum-mbsec { min-height: 0; }
  .sum-mb-col.dim { opacity: 1; }
  .sum-acc-side { display: grid !important; }
  .sum-foot { display: flex; justify-content: space-between; flex: none; padding-top: 4px; border-top: 1px solid var(--line); font-size: 10px; color: var(--ink-3); }
}

/* sections below the charts keep their height; the column scrolls instead of overlapping (short windows) */
.sum-mid > :not(.sum-wfsec):not(.sum-mbsec) { flex-shrink: 0; }
