/* KPI page (apps.js › kpiPage). Black and white like the rest of Acter; colour only for the goal:
   green = meets the goal, red = misses it, always with a ✓ / ✕ and words. Every class starts with kp-. */
.kp {
  --kp-good: #0CA30C; --kp-good-rgb: 12, 163, 12; --kp-good-text: #067647;
  --kp-bad: #D92D20; --kp-bad-rgb: 217, 45, 32; --kp-bad-text: #B42318;
  --kp-ink: #344054; --kp-wash: rgba(16, 24, 40, .05);
}
[data-theme="dark"] .kp {
  --kp-good-text: #75E0A7;
  --kp-bad: #F04438; --kp-bad-rgb: 240, 68, 56; --kp-bad-text: #FDA29B;
  --kp-ink: #D4D4D4; --kp-wash: rgba(255, 255, 255, .06);
}

/* filter row: one row above everything it scopes */
.kp-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.kp-chip { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); font-size: 13px; cursor: pointer; }
.kp-chip:hover { border-color: var(--muted); }
.kp-chip b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.kp-chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--surface); }
.kp-chip[aria-pressed="true"] b { color: var(--surface); }
.kp-ic { flex: none; }
.kp-ic.good { color: var(--kp-good); }
.kp-ic.bad { color: var(--kp-bad); }
.kp-chip[aria-pressed="true"] .kp-ic { color: inherit; }

/* areas */
.kp-area { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.kp-area-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.kp-area-head h2 { font-size: 16px; }
.kp-area-sum { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.kp-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.kp-dot.good { background: var(--kp-good); }
.kp-dot.bad { background: var(--kp-bad); }
/* cards never narrower than ~300 px (audit 2026-11-28 #15: at 800 px the labels read "S…"); a wide card spans two
   columns only when the grid itself has room for two, whatever the window size (the sidebar takes part of it) */
.kp-grid { display: grid; gap: 14px; grid-auto-flow: dense; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  align-items: start; container: kpgrid / inline-size; }
@container kpgrid (min-width: 614px) { .kp-wide { grid-column: span 2; } }
@container kpgrid (max-width: 613px) { .kp-grid.kp-grid > .vw-s-wide { grid-column: auto; } }

/* the card, and its glow when there's a goal */
.kp-card { position: relative; padding: 15px 16px 12px; display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  transition: box-shadow .35s ease, border-color .35s ease; }
.kp-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: transparent; }
.kp-card.is-good { border-color: rgba(var(--kp-good-rgb), .55);
  box-shadow: 0 0 0 1px rgba(var(--kp-good-rgb), .25), 0 12px 30px -14px rgba(var(--kp-good-rgb), .6);
  background-image: linear-gradient(180deg, rgba(var(--kp-good-rgb), .08), rgba(var(--kp-good-rgb), 0) 150px); }
.kp-card.is-good::before { background: var(--kp-good); }
.kp-card.is-bad { border-color: rgba(var(--kp-bad-rgb), .55);
  box-shadow: 0 0 0 1px rgba(var(--kp-bad-rgb), .25), 0 12px 30px -14px rgba(var(--kp-bad-rgb), .65);
  background-image: linear-gradient(180deg, rgba(var(--kp-bad-rgb), .08), rgba(var(--kp-bad-rgb), 0) 150px); }
.kp-card.is-bad::before { background: var(--kp-bad); }
@media (prefers-reduced-motion: reduce) { .kp-card, .kp-meter-fill, .kp-bar { transition: none; } }

.kp-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; min-height: 24px; }
.kp-title { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.kp-name { font-size: 13px; font-weight: 600; color: var(--text-2); margin-top: 2px; }
/* the time the number covers: "Right now", "Last 30 days", "All time" (audit 2026-11-28 #9) */
.kp-window { font-size: 11.5px; color: var(--muted); }
.kp-pill { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px 0 7px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; flex: none; }
.kp-pill.good { color: var(--kp-good-text); background: rgba(var(--kp-good-rgb), .14); }
.kp-pill.bad { color: var(--kp-bad-text); background: rgba(var(--kp-bad-rgb), .13); }
.kp-pill .kp-ic { color: inherit; width: 13px; height: 13px; }

.kp-main { min-width: 0; }
.kp-value-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin: 6px 0 0; }
.kp-value { font-size: 32px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; color: var(--text); }
.kp-unit { font-size: 14px; font-weight: 500; color: var(--text-2); }
.kp-sub { margin: 3px 0 0; font-size: 12px; color: var(--muted); }

/* goal meter */
.kp-meter { margin-top: 12px; }
.kp-meter-track { position: relative; display: block; height: 8px; border-radius: 999px; }
.kp-meter-track.good { background: rgba(var(--kp-good-rgb), .2); }
.kp-meter-track.bad { background: rgba(var(--kp-bad-rgb), .18); }
.kp-meter-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; transition: width .45s ease; }
.kp-meter-fill.good { background: var(--kp-good); }
.kp-meter-fill.bad { background: var(--kp-bad); }
.kp-meter-goal { position: absolute; top: -5px; width: 2px; height: 18px; margin-left: -1px; border-radius: 1px; background: var(--text);
  box-shadow: 0 0 0 2px var(--surface); }
.kp-meter-legend { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 7px; font-size: 12px; color: var(--text-2); }
.kp-meter-legend b { color: var(--text); font-weight: 600; }
.kp-gap { font-weight: 650; }
.kp-gap.good { color: var(--kp-good-text); }
.kp-gap.bad { color: var(--kp-bad-text); }

/* week-by-week line */
.kp-chart { margin-top: 12px; position: relative; }
.kp-chart svg { display: block; width: 100%; height: 96px; overflow: visible; border-radius: 4px; }
.kp-chart-cap { display: flex; justify-content: space-between; gap: 8px; margin-top: 2px; font-size: 11px; color: var(--muted); }
.kp-c-zone { fill: var(--kp-good); opacity: .09; }
.kp-c-line { fill: none; stroke: var(--kp-ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.kp-c-pt { fill: var(--kp-ink); stroke: var(--surface); stroke-width: 2; }
.kp-c-goal { stroke: var(--text-2); stroke-width: 1; opacity: .75; }
.kp-c-goal-l { fill: var(--text-2); font-size: 10.5px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.kp-c-dot { fill: var(--kp-ink); stroke: var(--surface); stroke-width: 2; }
.kp-c-dot.good { fill: var(--kp-good); }
.kp-c-dot.bad { fill: var(--kp-bad); }
.kp-c-cross { stroke: var(--muted); stroke-width: 1; }
.kp-c-hit { fill: transparent; cursor: crosshair; }

/* bars by station / order / reason */
.kp-bars { margin-top: 12px; min-width: 0; }
.kp-wide-body .kp-bars { margin-top: 4px; }
.kp-bars-head { display: flex; align-items: center; gap: 6px; margin: 0 0 14px; font-size: 12px; color: var(--text-2); font-weight: 500; }
.kp-bars-head.bad .kp-ic { color: var(--kp-bad); }
.kp-bars-head.good .kp-ic { color: var(--kp-good); }
/* one grid for the whole list (rows are subgrids), so every bar starts at the same x whatever the names */
/* the name column never shrinks below a station id (7ch) and grows to the longest name, up to 16em */
.kp-bar-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(7ch, max-content) minmax(48px, 1fr) auto;
  column-gap: 10px; row-gap: 2px; }
.kp-bar-row { display: grid; grid-template-columns: subgrid; grid-column: 1 / -1; align-items: center;
  min-height: 24px; padding: 0 4px; border-radius: 4px; }
.kp-bar-row:hover { background: var(--kp-wash); }
.kp-bar-name { display: flex; align-items: center; gap: 5px; min-width: 7ch; max-width: 16em; font-size: 12px; font-weight: 600; color: var(--text-2); }
.kp-bar-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kp-bar-name .ap-tag { flex: none; font-size: 10.5px; padding: 0 6px; }
.kp-bar-track { position: relative; display: block; height: 24px; }
.kp-bar { position: absolute; left: 0; top: 7px; height: 10px; border-radius: 0 4px 4px 0; background: var(--kp-ink); transition: width .45s ease; }
.kp-bar.good { background: var(--kp-good); }
.kp-bar.bad { background: var(--kp-bad); }
.kp-bar-goal { position: absolute; top: -1px; bottom: -1px; width: 1px; background: var(--text-2); opacity: .75; }
.kp-bar-goal-l { position: absolute; top: -13px; transform: translateX(-50%); font-size: 10.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.kp-bar-val { font-size: 12px; color: var(--text-2); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* number and bars side by side when the card has room, stacked when it doesn't */
.kp-wide-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 4px 24px; }

/* footer: the goal, and how it's calculated */
.kp-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap;
  margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.kp-card > .kp-main, .kp-card > .kp-wide-body { margin-bottom: 14px; }
.kp-goal-text { font-size: 12px; color: var(--text-2); }
.kp-goal-text b { color: var(--text); font-weight: 600; }
.kp-link { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 4px 6px; margin: -4px -6px;
  border-radius: 4px; font-size: 12px; color: var(--text-2); cursor: pointer; }
.kp-link:hover { background: var(--kp-wash); color: var(--text); }
.kp-link.strong { color: var(--text); font-weight: 600; }
.kp-goal-text .kp-link { margin-left: 4px; text-decoration: underline; text-underline-offset: 2px; }
.kp-chev { width: 12px; height: 12px; transition: transform .2s; }
.kp-link[aria-expanded="true"] .kp-chev { transform: rotate(180deg); }

.kp-goal-form { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; width: 100%; }
.kp-goal-form label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.kp-goal-input { width: 84px; height: 30px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 4px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.kp-goal-unit { font-size: 12px; color: var(--text-2); margin-right: 2px; }
.kp-btn { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.kp-btn.primary { background: var(--text); color: var(--surface); border-color: var(--text); }
.kp-btn.primary:hover { opacity: .9; background: var(--text); }
.kp-err { width: 100%; margin: 2px 0 0; font-size: 12px; color: var(--kp-bad-text); }

.kp-how { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--text-2); }
.kp-how p { margin: 0 0 4px; }
.kp-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kp-table th, .kp-table td { padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 12px; text-align: left; }
.kp-table th { color: var(--muted); font-weight: 500; }
.kp-table .num { text-align: right; }

/* KPIs still waiting for data: small, quiet, and they say what's missing */
.kp-wait { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.kp-area-head .kp-wait-title { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
.kp-wait-area { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kp-wait-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.kp-wait-card { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.kp-wait-card strong { font-size: 12.5px; color: var(--text); font-weight: 600; }

/* tooltip (one for the page, outside the app root) */
.kp-tip { position: fixed; z-index: 60; pointer-events: none; min-width: 130px; padding: 7px 10px; border-radius: 6px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(16, 24, 40, .16);
  font-size: 12px; opacity: 0; transition: opacity .1s; }
.kp-tip.on { opacity: 1; }
.kp-tip-v { font-size: 14px; font-weight: 650; }
.kp-tip-l { color: var(--muted); }
.kp-tip-g { margin-top: 3px; font-weight: 600; }
.kp-tip-g.good { color: #067647; }
.kp-tip-g.bad { color: #B42318; }
[data-theme="dark"] .kp-tip-g.good { color: #75E0A7; }
[data-theme="dark"] .kp-tip-g.bad { color: #FDA29B; }

/* Four on the page, the rest templates, new ones from the Ask box (apps.js › kpDraft, kpTemplates). Landon, 2026-11-18. */
.kp-made { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; height: 20px; padding: 0 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--kp-wash); white-space: nowrap; }
.kp-made + .kp-pill { margin-left: 0; }
.kp-off { margin-left: auto; color: var(--muted); }
.kp-card.kp-new { animation: kp-new 2.4s ease-out; }
@keyframes kp-new { 0%, 30% { box-shadow: 0 0 0 3px var(--text); } 100% { box-shadow: 0 0 0 3px transparent; } }
.kp-draft { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; border-left: 3px solid var(--text); }
.kp-draft .ap-ask-q { margin: 0; }
.kp-draft-eyebrow { display: flex; align-items: center; gap: 6px; margin: 4px 0 0; font-size: 11.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; }
.kp-draft-name { font-size: 18px; }
.kp-draft .kp-value-row { margin: 0; }
.kp-draft .kp-sub { margin: 0 0 0 6px; }
.kp-draft-what { margin: 0; font-size: 13px; color: var(--text-2); }
.kp-draft .meta { margin: 0; }
.kp-draft .ap-row { margin-top: 6px; }
.kp-draft-warn { margin: 2px 0 0; padding: 8px 10px; border-radius: 6px; background: var(--amber-bg); color: var(--amber); font-size: 12.5px; }
.kp-draft-help { border-left-color: var(--line-strong); }
.kp-tpls { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 14px; }
.kp-tpl-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 12px 14px; font: inherit;
  text-align: left; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.kp-tpl-toggle:hover { border-color: var(--line-strong); }
.kp-tpl-toggle strong { font-size: 14px; }
.kp-tpl-toggle[aria-expanded="true"] .kp-chev { transform: rotate(180deg); }
.kp-tpl-body { display: flex; flex-direction: column; gap: 16px; }
.kp-tpl-group h3 { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.kp-tpl-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.kp-tpl { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.kp-tpl.made { border-style: dashed; border-color: var(--line-strong); }
.kp-tpl-area { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kp-tpl strong { font-size: 13.5px; }
.kp-tpl-def { font-size: 12px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kp-tpl-now { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text); margin-top: 2px; }
.kp-tpl-now.wait { color: var(--muted); font-weight: 500; }
.kp-tpl-act { display: flex; gap: 6px; margin-top: 8px; }
.kp-btn.kp-sure { color: var(--kp-bad-text); border-color: var(--kp-bad); }
@media (prefers-reduced-motion: reduce) { .kp-card.kp-new { animation: none; box-shadow: 0 0 0 3px var(--text); } }

/* ---- Production Dashboard tables and tags (apps.js › production). Here, not app.css, so the dashboard's audit fixes
   (2026-11-28 #3, #8, #11, #16) stay in one file. ap- classes, like the rest of the dashboard. */
.ap-tag.ex { border-color: transparent; background: var(--subtle); color: var(--muted); font-weight: 600; }   /* grey: Example, iPad not set up */
.ap-tag.done { border-color: var(--text-2); color: var(--text); }
.ap-id { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ap-mt-line .ap-tag.ex, .ap-mp-pb strong .ap-tag.ex { margin-left: 6px; vertical-align: 1px; }
.ap-table .ap-c-id { white-space: nowrap; }
.ap-trunc { display: block; max-width: 16em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the Order column stays put when a wide table scrolls sideways */
.ap-table .ap-sticky { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
.ap-table thead .ap-sticky { z-index: 2; }
.ap-table tr.click:hover > .ap-sticky, .ap-table tr.click:focus-visible > .ap-sticky { background: var(--subtle); }
.ap-progress { display: block; min-width: 96px; }   /* not .ap-done: pick.css owns that name (a dark "Done" button), 2026-11-29 */
.ap-done-group { margin-top: 4px; }
.ap-group-h { margin: 0 0 6px; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ap-method { margin: 0; font-size: 12px; }
/* "Right now" beside each widget's title: everything on the dashboard is this minute's */
.ap-w-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ap-w-head .vw-title { margin-bottom: 0; }
.ap-when { font-size: 12px; color: var(--muted); }
/* Logic switched an alert off: said plainly, with the way back */
.ap-off { margin: 0; padding: 8px 10px; border-radius: 6px; background: var(--subtle); color: var(--text-2); font-size: 12.5px; }
.ap-off a { color: var(--text); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
