/* bc-kit — faithful recreations of the Business Central web client (2025–26) for "before" screens.
   Spec: research/06-bc-screen-spec.md. Everything scales with the container (cqw), so a recreation
   looks the same at any stage size. Root element: .bck (desktop) or .bckp (phone app).
   Pieces: .bck-top .bck-head .bck-acts .bck-ft (FastTab) .bck-lines (grid part) .bck-grid .bck-hscroll
           .bck-fb (FactBox pane) .bck-tot .bck-note (notification bar) .bck-modal (+ .bck-dim)
           .bck-itl (Item Tracking Lines) .bck-menu (dropdown) .bck-opt (option dialog)
           .bck-itl.bck-win (any page window: Assembly Availability Check, Item Tracking Summary; .back = behind another)
           .bck-fields.cm (column-major fields, --rows) .bck-tg (toggle) .bck-sumft (Selectable/Selected/Undefined)
           .bck-hscroll.hend (--hend: thumb travel when --hmax stops short of the far end)
           Menus placed inside .bck-lines anchor to its toolbar (top in em) so they line up at every stage size.
           Phone: .bckp-note (notification) .bckp-dim .bckp-sheet.dlg (raised so it shows inside a 4:3 peek tile)
   Animation hooks (set by story.js / cut.js): --hx (0..1 horizontal scroll of grids), .is-menu, .is-dialog */

.bck {
  position: absolute; inset: 0; overflow: hidden; container-type: inline-size;
  font-family: "Segoe UI", "Segoe WP", Segoe, Tahoma, Helvetica, Arial, sans-serif;
  font-size: 1.02cqw; line-height: 1.32; color: #212121; background: #fff;
  --teal: #008089; --sel: #e6f2f3; --line: #e1e1e1; --grey: #505c6d; --ro: #f3f3f3;
}
.bck * { box-sizing: border-box; }

/* app bar */
.bck-top { height: 3em; display: flex; align-items: center; gap: 1.1em; padding: 0 1.2em; background: #1b5a96; color: #fff; font-size: 1.04em; }
.bck-top .wf { width: 1.05em; height: 1.05em; background: radial-gradient(circle, #fff 22%, transparent 24%) 0 0 / .35em .35em; opacity: .9; flex: none; }
.bck-top .co { font-size: .9em; }
.bck-top .sp { flex: 1; }
.bck-top .srch { width: 13em; height: 1.9em; border-radius: .25em; background: rgba(255,255,255,.16); font-size: .82em; display: flex; align-items: center; padding: 0 .7em; color: rgba(255,255,255,.75); }
.bck-top .ic { width: 1.05em; height: 1.05em; border: .11em solid rgba(255,255,255,.85); border-radius: 50%; flex: none; }

/* page body layout: main + factbox */
.bck-body { position: absolute; top: 3em; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: minmax(0, 1fr) 24%; gap: .9em; padding: .7em 1.1em 0; }
.bck-main { min-width: 0; overflow: hidden; }

/* document header */
.bck-head { display: flex; align-items: flex-start; gap: .8em; }
.bck-head .back { width: 1.9em; height: 1.9em; border-radius: 50%; background: #eef3f8; color: var(--teal); display: grid; place-items: center; font-size: .9em; flex: none; margin-top: .3em; }
.bck-head .cap { font-size: .82em; color: var(--grey); }
.bck-head .ttl { font-size: 1.75em; font-weight: 300; letter-spacing: -.005em; line-height: 1.15; white-space: nowrap; }
.bck-head .icons { margin-left: auto; display: flex; gap: .9em; color: var(--teal); font-size: .95em; padding-top: .4em; white-space: nowrap; }
.bck-head .saved { color: var(--grey); font-size: .85em; }

/* action bar */
.bck-acts { display: flex; gap: 1.25em; margin-top: .55em; padding-bottom: .4em; border-bottom: 1px solid var(--line); font-size: .9em; white-space: nowrap; overflow: hidden; }
.bck-acts span:first-child { font-weight: 600; box-shadow: inset 0 -.16em 0 var(--teal); padding-bottom: .25em; }
.bck-acts .dim { color: var(--grey); }

/* FastTab */
.bck-ft { margin-top: .75em; }
.bck-ft-h { display: flex; justify-content: flex-start; align-items: baseline; gap: 1em; font-weight: 600; font-size: 1.05em; padding-bottom: .3em; border-bottom: 1px solid var(--line); }
.bck-ft-h::before { content: "⌄"; font-weight: 400; color: var(--grey); margin-right: .45em; font-size: .8em; }
.bck-ft-h .pv { font-weight: 400; color: var(--grey); font-size: .82em; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bck-ft.col .bck-ft-h::before { content: "›"; }
.bck-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .18em 2.4em; padding: .55em 0 .2em; font-size: .86em; }
.bck-f { display: grid; grid-template-columns: 11em 1fr; align-items: center; gap: .5em; min-width: 0; }
.bck-f > span:first-child { color: var(--grey); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
.bck-f > span:first-child::after { content: ""; position: absolute; left: 100%; right: -.5em; bottom: .3em; border-bottom: 1px dotted #c4c4c4; }
.bck-f > span:last-child { border-bottom: 1px solid #c9c9c9; padding: .12em .3em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1.6em; }
.bck-f.ro > span:last-child { background: var(--ro); border-bottom-color: transparent; }
.bck-f .req::after { content: " *"; color: #c42b1c; }
.bck-more { text-align: right; font-size: .82em; color: var(--teal); padding: .15em 0 .3em; }

/* lines part */
.bck-lines { margin-top: .7em; }
.bck-ltb { display: flex; align-items: center; gap: 1.1em; font-size: .86em; padding: .35em 0; }
.bck-ltb b { font-weight: 600; font-size: 1.2em; margin-right: .4em; }
.bck-ltb .on { box-shadow: inset 0 -.14em 0 var(--teal); }
.bck-ltb .sp { flex: 1; }
.bck-ltb .ico { color: var(--grey); }
.bck-gridwrap { position: relative; overflow: hidden; border-top: 1px solid var(--line); }
.bck-grid { border-collapse: collapse; table-layout: fixed; font-size: .84em; transform: translateX(calc(var(--hx, 0) * var(--hmax, -60%))); transition: transform .1s linear; }
.bck-grid th { text-align: left; font-weight: 600; color: var(--grey); padding: .45em .5em; vertical-align: bottom; line-height: 1.2; border-bottom: 1px solid #c8c8c8; white-space: normal; }
.bck-grid th.n { text-align: right; }
.bck-grid td { padding: .5em .5em; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 2.45em; }
.bck-grid td.n { text-align: right; }
.bck-grid tr.cur td { background: var(--sel); }
.bck-grid td.foc { box-shadow: inset 0 0 0 .14em #212121; background: #fff; }
.bck-grid td.sel0 { width: 1.6em; padding: 0; text-align: center; color: var(--grey); }
.bck-grid td.link { color: var(--teal); }
.bck-grid td.warn { color: #c42b1c; font-weight: 600; }
.bck-hscroll { position: relative; height: .7em; background: #f3f3f3; border-radius: .35em; margin: .3em 0 .1em; }
.bck-hscroll i { position: absolute; top: .1em; bottom: .1em; left: calc(var(--hx, 0) * (100% - var(--thumb, 38%))); width: var(--thumb, 38%); background: #b9b9b9; border-radius: .3em; transition: left .1s linear; }
.bck-tot { display: grid; grid-template-columns: 1fr 1fr; gap: .2em 2.4em; font-size: .82em; padding: .45em 0; }
.bck-tot div { display: flex; justify-content: space-between; color: var(--grey); }
.bck-tot div b { font-weight: 600; color: #212121; }

/* FactBox pane (rounded since BC26) */
.bck-fb { border: 1px solid var(--line); border-radius: .6em; padding: .7em .8em; font-size: .8em; overflow: hidden; align-self: start; margin-top: 3.2em; background: #fff; }
.bck-fbh { font-weight: 600; display: flex; justify-content: space-between; margin: .9em 0 .35em; }
.bck-fbh:first-child { margin-top: 0; }
.bck-fbh::after { content: "⋯"; color: var(--grey); font-weight: 400; }
.bck-fbr { display: flex; justify-content: space-between; gap: .6em; padding: .14em 0; color: var(--grey); }
.bck-fbr span:last-child { color: var(--teal); }

/* notification bar */
.bck-note { display: flex; gap: .6em; align-items: center; background: #fff4ce; border: 1px solid #f2dd9b; padding: .45em .7em; font-size: .84em; margin-top: .6em; border-radius: .2em; }
.bck-note::before { content: "!"; width: 1.3em; height: 1.3em; border-radius: 50%; background: #8a6d00; color: #fff; display: grid; place-items: center; font-size: .8em; font-weight: 700; flex: none; }
.bck-note u { color: var(--teal); text-decoration: none; margin-left: auto; white-space: nowrap; }

/* dropdown menu (e.g. Line ▸ Item Tracking Lines ▸ Shipment / Receipt) */
.bck-menu { position: absolute; z-index: 6; background: #fff; border: 1px solid #c8c8c8; box-shadow: 0 .5em 1.4em rgba(0,0,0,.18); font-size: .86em; min-width: 15em; padding: .3em 0; opacity: 0; transform: translateY(-.4em); transition: opacity .25s, transform .25s; pointer-events: none; }
.bck-menu div { padding: .4em 1em; display: flex; justify-content: space-between; gap: 1.5em; white-space: nowrap; }
.bck-menu div.hl { background: var(--sel); }
.bck-menu div.sub::after { content: "›"; color: var(--grey); }
.bck-menu .kbd { color: var(--grey); font-size: .9em; }
.is-menu .bck-menu { opacity: 1; transform: none; }

/* modal + dim */
.bck-dim { position: absolute; inset: 0; z-index: 7; background: rgba(0,0,0,.28); opacity: 0; transition: opacity .3s; pointer-events: none; }
.bck-modal { position: absolute; z-index: 8; background: #fff; border: 1px solid #c8c8c8; box-shadow: 0 1em 2.6em rgba(0,0,0,.25); opacity: 0; transform: scale(.97); transition: opacity .3s, transform .3s; pointer-events: none; }
.is-dialog .bck-dim, .is-dialog .bck-modal { opacity: 1; transform: none; }
.bck-modal .mh { font-size: 1.25em; font-weight: 600; padding: .9em 1.1em .3em; }
.bck-modal .mb { padding: .3em 1.1em; font-size: .9em; }
.bck-modal .mf { display: flex; justify-content: flex-end; gap: .6em; padding: .8em 1.1em 1em; }
.bck-btn { display: inline-block; padding: .35em 1.6em; border: 1px solid #8a8a8a; font-size: .9em; }
.bck-btn.pri { background: #1b5a96; border-color: #1b5a96; color: #fff; }
.bck-opt label { display: flex; align-items: center; gap: .6em; padding: .3em 0; }
.bck-opt label i { width: 1.1em; height: 1.1em; border: .1em solid #555; border-radius: 50%; position: relative; flex: none; }
.bck-opt label i.on::after { content: ""; position: absolute; inset: .2em; border-radius: 50%; background: #212121; }

/* Item Tracking Lines page (opens as a large window over the document) */
.bck-itl { position: absolute; z-index: 8; left: 9%; right: 9%; top: 7%; bottom: 6%; background: #fff; border: 1px solid #c8c8c8; box-shadow: 0 1.2em 3em rgba(0,0,0,.28); padding: .9em 1.2em; overflow: hidden; opacity: 0; transform: scale(.97); transition: opacity .3s, transform .3s; }
.is-dialog .bck-itl { opacity: 1; transform: none; }
.bck-itl .wt { font-size: 1.45em; font-weight: 300; }
.bck-itl .wc { font-size: .8em; color: var(--grey); }
.bck-blocks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.6em; margin-top: .7em; font-size: .82em; }
.bck-blocks h5 { margin: 0 0 .3em; font-size: 1em; font-weight: 600; }
.bck-blocks .bck-fbr span:last-child { color: #212121; }
.bck-blocks .bad span:last-child { color: #c42b1c; font-weight: 700; }

/* phone app (BC mobile) */
.bckp { position: absolute; inset: 0; overflow: hidden; container-type: inline-size; font-family: "Segoe UI", Segoe, Tahoma, Arial, sans-serif; font-size: 4.1cqw; line-height: 1.32; color: #212121; background: #f3f3f3; }
.bckp * { box-sizing: border-box; }
.bckp-top { background: #1b5a96; color: #fff; padding: 2.4em 1em .8em; display: flex; align-items: center; gap: .8em; }
.bckp-top b { flex: 1; font-weight: 600; }
.bckp-acts { display: flex; gap: 1.1em; padding: .55em 1em; background: #fff; border-bottom: 1px solid #ddd; font-size: .86em; color: var(--teal, #008089); }
.bckp-sec { background: #fff; margin-top: .55em; padding: .6em 1em; }
.bckp-sec h6 { margin: 0 0 .35em; font-size: .95em; font-weight: 600; display: flex; justify-content: space-between; }
.bckp-sec h6 small { font-weight: 400; color: #008089; }
.bckp-f { display: flex; justify-content: space-between; font-size: .84em; padding: .28em 0; border-bottom: 1px solid #eee; gap: 1em; }
.bckp-f span:first-child { color: #505c6d; }
.bckp-tile { border: 1px solid #e3e3e3; border-radius: .25em; padding: .5em .65em; margin-top: .45em; position: relative; }
.bckp-tile small { display: block; font-size: .78em; color: #505c6d; }
.bckp-tile b { display: block; font-weight: 600; font-size: .95em; }
.bckp-tile span { display: block; font-size: .8em; color: #505c6d; }
.bckp-tile::after { content: "⋯"; position: absolute; top: .3em; right: .5em; color: #505c6d; }
.bckp-sheet { position: absolute; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid #d0d0d0; box-shadow: 0 -.8em 2em rgba(0,0,0,.18); padding: 1em 1em 1.2em; font-size: .85em; display: grid; gap: .5em; }
.bckp-sheet b { font-weight: 600; color: #a4262c; }
.bckp-sheet i { font-style: normal; justify-self: end; background: #1b5a96; color: #fff; padding: .3em 1.4em; border-radius: .2em; }

/* variant: Item Tracking Lines docked over the right side (hero, static) */
.bck-itl.bck-itl-r { left: 39%; right: 1.4%; top: 8%; bottom: auto; opacity: 1; transform: none; font-size: 1.12em; padding-bottom: 1.1em; }
.bck-itl-r .bck-acts { gap: .9em; font-size: .82em; }

/* ---------- additions: assembly order + sales order chapters ---------- */
/* FastTab fields that flow down the left column first, as BC lays them out (set --rows) */
.bck-fields.cm { grid-auto-flow: column; grid-template-rows: repeat(var(--rows, 7), auto); }
/* boolean toggle (card pages); .ro greys it */
.bck-tg { display: inline-block; width: 2.2em; height: 1.1em; border-radius: .55em; border: .1em solid #6b6b6b; position: relative; vertical-align: middle; }
.bck-tg::after { content: ""; position: absolute; left: .16em; top: .14em; width: .62em; height: .62em; border-radius: 50%; background: #6b6b6b; }
.bck-f.ro .bck-tg { border-color: #b3b3b3; }
.bck-f.ro .bck-tg::after { background: #b3b3b3; }
.bck-f.tg > span:last-child { border-bottom-color: transparent; }
/* notification bar with two actions and a close */
.bck-note u + u { margin-left: 1.2em; }
.bck-note .x { color: var(--grey); margin-left: 1.1em; }
/* horizontal scroll that stops short of the far end: thumb travel = --hend (0..1) */
.bck-hscroll.hend i { left: calc(var(--hx, 0) * var(--hend, 1) * (100% - var(--thumb, 38%))); }
/* grid cell styles: Strong, Unfavorable, wrapped link */
.bck-grid td.str { font-weight: 700; }
.bck-grid td.unf { color: #c42b1c; }
.bck-grid td.lk { color: var(--teal); text-decoration: underline; text-underline-offset: .15em; }
/* menu entry that is a separator */
.bck-menu hr { border: 0; border-top: 1px solid #e3e3e3; margin: .25em 0; }
/* generic page window (opened over the document): positioned inline; heading line in Unfavorable red */
.bck-win .unfh { color: #c42b1c; font-size: .86em; margin-top: .5em; }
.bck-win .bck-ft { margin-top: .6em; }
.bck-win .bck-fields { font-size: .8em; }
.bck-win .bck-f { grid-template-columns: 12em 1fr; }
.bck-win .bck-f.unf > span:last-child { color: #c42b1c; font-weight: 700; }
.bck-win .bck-grid { font-size: .8em; }
.bck-win .bck-ltb { font-size: .82em; }
.bck-win .bck-acts { font-size: .82em; gap: 1em; }
.bck-win .wbtns { position: absolute; right: 1.2em; bottom: .9em; display: flex; gap: .6em; }
.bck-win .wx { position: absolute; right: 1.1em; top: .8em; color: var(--grey); font-size: .9em; display: flex; gap: 1em; }
/* a window that sits behind another one (dimmed slightly) */
.bck-itl.back { filter: brightness(.94); }
/* Item Tracking Summary footer: Selectable / Selected / Undefined */
.bck-sumft { display: flex; gap: 3.2em; margin-top: .8em; font-size: .8em; }
.bck-sumft div { display: grid; gap: .15em; }
.bck-sumft div span:first-child { font-weight: 600; }
.bck-sumft div span:last-child { color: var(--grey); }

/* phone: notification banner and a sheet with a heading */
.bckp-sheet h6 { margin: 0; font-size: 1.05em; font-weight: 600; display: flex; justify-content: space-between; }
.bckp-sheet h6 small { font-weight: 400; color: #505c6d; }
.bckp-sheet .bckp-f { font-size: .95em; }
.bckp-sheet .bad span:last-child { color: #a4262c; font-weight: 700; }
.bckp-sheet .lnk { color: #008089; display: flex; gap: 1.4em; }
.bckp-note { background: #fff4ce; border-bottom: 1px solid #f2dd9b; padding: .6em 1em; font-size: .8em; display: grid; grid-template-columns: auto 1fr; gap: .2em .6em; }
.bckp-note::before { content: "!"; width: 1.3em; height: 1.3em; border-radius: 50%; background: #8a6d00; color: #fff; display: grid; place-items: center; font-size: .8em; font-weight: 700; grid-row: span 2; margin-top: .15em; }
.bckp-note span { color: #008089; display: flex; gap: 1.4em; }
.bckp-tile.cur { border-color: #008089; box-shadow: inset .22em 0 0 #008089; }
.bckp-dim { position: absolute; inset: 0; background: rgba(0,0,0,.25); }
/* menus can live inside a lines part so they anchor to its toolbar at any stage size */
.bck-lines { position: relative; }
.bck-main .bck-lines .bck-menu { top: 2.3em; }
/* phone: sheet raised into the upper part of the screen so it shows inside a 4:3 peek tile */
.bckp-sheet.dlg { top: var(--sheet-top, 14%); bottom: auto; left: .7em; right: .7em; border: 1px solid #d0d0d0; border-radius: .45em; box-shadow: 0 .8em 2.4em rgba(0,0,0,.28); }
