/* KPI dashboard styles (SD-013). Installed by skill/kpi-builder into src/Cqrs.Web/wwwroot/css. Every colour is a design token of
   the active theme (VisualDesign.md, SD-011), so the six themes apply without a change here. Do not write a hex colour in this file. */

.kpi-board { display: flex; flex-direction: column; gap: 18px; }
.kpi-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.kpi-head h1 { margin: 0; }
.kpi-asof { margin: 6px 0 0; font-size: .9rem; }
.kpi-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.kpi-tools[hidden], .kpi-tools [hidden] { display: none; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: 64px;
  gap: 14px;
}

.kpi-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(var(--glass-blur));
  padding: 10px 14px;
  min-width: 0;
  min-height: 0;
  justify-self: stretch;
  align-self: stretch;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-title { margin: 0; font-size: .9rem; font-weight: 600; color: var(--muted); }
.kpi-value { margin: 0; font-family: var(--font-mono); font-size: clamp(1.3rem, 1.9vw, 1.85rem); line-height: 1.1; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-note, .kpi-target { margin: 0; font-size: .82rem; color: var(--muted); }
.kpi-empty { margin: auto 0; color: var(--muted); font-size: .9rem; }

.kpi-pill { align-self: flex-start; font-size: .74rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; }
.kpi-track { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
/* A target card: its target and its status side by side, so the figure, target, status and bar fit two rows. */
.kind-kpi { flex-flow: row wrap; align-content: flex-start; column-gap: 10px; }
.kind-kpi > * { flex: 1 1 100%; }
.kind-kpi > .kpi-target { flex: 0 1 auto; align-self: center; }
.kind-kpi > .kpi-pill { flex: 0 0 auto; align-self: center; }
.kpi-fill { display: block; height: 100%; border-radius: inherit; background: currentColor; }
.kpi-tone-ok { color: var(--ok); }
.kpi-tone-warn { color: var(--warn); }
.kpi-tone-danger { color: var(--danger); }
.kpi-tone-muted { color: var(--muted); }

/* Series: the six colours a chart uses, in order. Each class sets the colour for a fill, a stroke and a background. */
.kpi-series-1 { color: var(--accent); fill: var(--accent); stroke: var(--accent); background: var(--accent); }
.kpi-series-2 { color: var(--accent-2); fill: var(--accent-2); stroke: var(--accent-2); background: var(--accent-2); }
.kpi-series-3 { color: var(--warn); fill: var(--warn); stroke: var(--warn); background: var(--warn); }
.kpi-series-4 { color: var(--ok); fill: var(--ok); stroke: var(--ok); background: var(--ok); }
.kpi-series-5 { color: var(--danger); fill: var(--danger); stroke: var(--danger); background: var(--danger); }
.kpi-series-6 { color: var(--muted); fill: var(--muted); stroke: var(--muted); background: var(--muted); }

.kpi-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.kpi-bar-row { display: grid; grid-template-columns: minmax(90px, 1.1fr) 3fr auto; gap: 10px; align-items: center; font-size: .88rem; }
.kpi-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.kpi-bar-track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.kpi-bar-fill { display: block; height: 100%; border-radius: inherit; }
.kpi-bar-value { font-family: var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }

.kpi-donut-wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; flex: 1 1 0; min-height: 0; }
/* The donut's chart is the svg only. The widget's own class is kind-donut, so the card still fills its cell. */
svg.kpi-donut { height: 100%; width: auto; max-width: 100%; aspect-ratio: 1; min-height: 0; flex: 0 1 auto; }
.kpi-donut-track { fill: none; stroke: var(--surface-2); stroke-width: 14; }
.kpi-donut-seg { fill: none; stroke-width: 14; }
.kpi-donut-total { font-family: var(--font-mono); font-size: 13px; font-weight: 700; fill: var(--text); }
.kpi-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: .88rem; flex: 1 1 120px; min-width: 0; }
.kpi-legend li { display: flex; align-items: center; gap: 8px; }
.kpi-legend-value { margin-left: auto; font-family: var(--font-mono); color: var(--muted); }
.kpi-swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }

.kpi-line-chart { width: 100%; height: auto; flex: 1 1 auto; min-height: 120px; }
.kpi-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.kpi-dot { stroke: var(--surface); stroke-width: 1.5; }
.kpi-axis { stroke: var(--border); stroke-width: 1; }
.kpi-svg-label { font-family: var(--font-mono); font-size: 13px; fill: var(--muted); }

.kpi-table-wrap { overflow-x: auto; }
.kpi-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.kpi-table th, .kpi-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); }
.kpi-table th { color: var(--muted); font-weight: 600; }
.kpi-table .kpi-num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.kpi-notes { margin: 0; padding-left: 18px; display: grid; gap: 8px; font-size: .92rem; color: var(--text); }

.kpi-status { margin: 0; min-height: 1.2em; color: var(--muted); }

/* Slicers and the time slider (SD-013 §4.3): the controls sit above the grid and filter the cube widgets. */
.kpi-filters { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; }
.kpi-slicer { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); min-width: 160px; }
.kpi-slicer select { font: inherit; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--input); color: var(--text); }
.kpi-time { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; flex: 1 1 360px; font-size: .85rem; color: var(--muted); }
.kpi-time-title { font-weight: 600; color: var(--text); }
.kpi-time label { display: inline-flex; gap: 8px; align-items: center; }
.kpi-time input[type="range"] { width: 160px; accent-color: var(--accent); }
.kpi-time-output { font-family: var(--font-mono); color: var(--text); }
.kpi-scope { margin: -4px 0 0; font-size: .75rem; color: var(--muted); font-style: italic; }

/* Move mode: the grid shows where each widget can go, and a widget under the pointer is outlined in the accent colour. */
/* The edit marks sit inside the widget's border box (a negative offset), so the boundary the person sees is the widget's own. */
.kpi-editing .kpi-widget { cursor: grab; outline: 1px dashed var(--accent); outline-offset: -3px; user-select: none; touch-action: none; }
.kpi-editing .kpi-widget:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.kpi-widget { position: relative; }
.kpi-resize { display: none; position: absolute; right: 4px; bottom: 4px; width: 14px; height: 14px; border-right: 3px solid var(--accent); border-bottom: 3px solid var(--accent); border-radius: 0 0 4px 0; cursor: nwse-resize; touch-action: none; }
.kpi-editing .kpi-resize { display: block; }
.kpi-ghost { border: 2px dashed var(--accent); border-radius: 14px; background: color-mix(in srgb, var(--accent) 12%, transparent); pointer-events: none; }
.kpi-ghost[hidden] { display: none; }
.kpi-widget.kpi-resizing { outline: 2px solid var(--accent); outline-offset: -2px; box-shadow: var(--shadow); z-index: 2; }
.kpi-widget.kpi-moving { cursor: grabbing; outline: 2px solid var(--accent); outline-offset: -2px; box-shadow: var(--shadow); z-index: 2; }

@media (max-width: 760px) {
  .kpi-grid { grid-template-columns: 1fr; grid-auto-rows: auto; }
  .kpi-widget { grid-column: auto !important; grid-row: auto !important; min-height: 140px; }
}

@media print {
  .kpi-tools, .kpi-status { display: none; }
  .kpi-widget { box-shadow: none; break-inside: avoid; }
}

/* Grouped bars (the compare kind): one thin bar per series for each label, with a zero line when a value is negative. */
.kpi-compare-legend { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 14px; font-size: .85rem; }
.kpi-compare-legend li { display: inline-flex; align-items: center; gap: 6px; }
.kpi-compare { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.kpi-compare-row { display: grid; grid-template-columns: minmax(110px, 1fr) 3fr; gap: 10px; align-items: start; font-size: .84rem; }
.kpi-compare-label { padding-top: 2px; }
.kpi-compare-bars { display: grid; gap: 3px; min-width: 0; }
.kpi-compare-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.kpi-compare-track { position: relative; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.kpi-compare-fill { position: absolute; top: 0; bottom: 0; border-radius: inherit; }
.kpi-compare-zero { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--muted); }
.kpi-compare-value { font-size: .76rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* The organogram (SD-022): units in rows joined by lines, each unit's people in a column under it, and each person's reports under them.
   It scrolls inside its widget when the group is wider than the page. */
.kind-organogram .kpi-org { flex: 1 1 auto; min-height: 0; overflow: auto; padding-bottom: 6px; }
.kpi-org-row { list-style: none; margin: 0; padding: 14px 0 0; display: flex; justify-content: center; position: relative; }
.kpi-org-row::before { content: ""; position: absolute; top: 0; left: 50%; height: 14px; border-left: 1px solid var(--muted); }
.kpi-org-row > li { position: relative; padding: 14px 6px 0; display: flex; flex-direction: column; align-items: center; }
.kpi-org-row > li::before, .kpi-org-row > li::after { content: ""; position: absolute; top: 0; width: 50%; height: 14px; border-top: 1px solid var(--muted); }
.kpi-org-row > li::before { right: 50%; }
.kpi-org-row > li::after { left: 50%; border-left: 1px solid var(--muted); }
.kpi-org-row > li:first-child::before, .kpi-org-row > li:last-child::after { border-top: 0; }
.kpi-org-row > li:only-child::before { display: none; }
.kpi-org-row > li:only-child { padding-top: 0; }
.kpi-org-row > li:only-child::after { border-top: 0; height: 0; }
/* The top row is as wide as the tree, so a group wider than the widget scrolls from its left edge instead of being cut off. */
.kpi-org-top { padding-top: 0; width: max-content; min-width: 100%; }
.kpi-org-top::before, .kpi-org-top > li::before, .kpi-org-top > li::after { display: none; }
.kpi-org-top > li { padding-top: 0; }
.kpi-org-node { display: grid; gap: 2px; min-width: 150px; max-width: 220px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); font-size: .8rem; text-align: left; color: var(--text); }
.kpi-org-node strong { font-size: .86rem; }
.kpi-org-node.is-group { border-color: var(--text); }
.kpi-org-node.is-division { border-color: var(--accent); }
.kpi-org-node.is-subsidiary { border-color: var(--accent-2); }
.kpi-org-node.is-person { background: var(--surface); }
.kpi-org-node.is-department { border-color: var(--ok); }
.kpi-org-node.is-section { border-style: dashed; border-color: var(--ok); }
.kpi-org-node.is-lead { border-color: var(--warn); }
.kpi-org-meta, .kpi-org-title { color: var(--muted); }
.kpi-org-role { font-size: .74rem; }
.kpi-org-logo { max-height: 24px; max-width: 96px; object-fit: contain; }
.kpi-org-team { list-style: none; margin: 6px 0 0; padding: 0 0 0 12px; border-left: 1px solid var(--muted); display: grid; gap: 6px; align-self: center; }
.kpi-org-team .kpi-org-team { margin-left: 8px; }
@media print { .kind-organogram .kpi-org { overflow: visible; } }

/* A web page embedded in a dashboard: the frame fills the widget below its title. While the layout is edited the frame takes no pointer,
   so the widget can be dragged by any part of it. */
.kind-embed { display: flex; flex-direction: column; }
.kind-embed .kpi-embed { flex: 1 1 auto; min-height: 120px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.kind-embed iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.kind-embed .kpi-note { margin: 6px 0 0; }
.kpi-editing .kind-embed iframe { pointer-events: none; }
@media print { .kind-embed .kpi-embed { display: none; } }

/* A value read with its legend: the series name is kept for a screen reader only (SD-023). */
.kpi-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Showing and hiding a widget (SD-023): hidden widgets are not drawn on the view; on the Edit dashboard screen they are faint, with the
   tick that shows them again. The display rule above would otherwise draw a widget the page has hidden. */
.kpi-widget[hidden] { display: none; }
.kpi-show { display: none; align-items: center; gap: 6px; font-size: .78rem; color: var(--text); cursor: pointer; white-space: nowrap;
  position: absolute; top: 8px; right: 10px; z-index: 3; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); }
.kpi-editing .kpi-show { display: inline-flex; }
.kpi-editing .kpi-widget.kpi-is-hidden { opacity: .45; outline-style: dotted; }
@media print { .kpi-widget.kpi-is-hidden { display: none; } }

/* Records, timelines, links and text widgets (SD-027 Phase 4d). A record shows the fields of the one row the slicers leave; a RAG is the
   status token with its word, never colour alone. A timeline is a bar a row on one scale with today marked. */
.kind-record, .kind-timeline { overflow: auto; }
.kpi-record { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 16px; }
.kpi-record-field { min-width: 0; }
.kpi-record dt { font-size: .78rem; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.kpi-record dd { margin: 0; color: var(--text); font-size: .92rem; overflow-wrap: anywhere; }
.kpi-record-text, .kpi-record-columns { grid-template-columns: 1fr; }
.kpi-record-columns { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.kpi-record-hero dd { font-family: var(--font-mono); font-size: clamp(1.6rem, 2.6vw, 2.4rem); font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-lines { white-space: pre-line; line-height: 1.45; }
.kpi-rag { display: block; padding: 6px 10px; border-radius: 8px; text-align: center; font-weight: 600; border: 1px solid var(--border); }
.kpi-rag-green { background: color-mix(in srgb, var(--ok) 30%, transparent); border-color: var(--ok); }
.kpi-rag-amber { background: color-mix(in srgb, var(--warn) 40%, transparent); border-color: var(--warn); }
.kpi-rag-red { background: color-mix(in srgb, var(--danger) 30%, transparent); border-color: var(--danger); }
.kpi-rag-none { background: var(--surface-2); }
.kpi-table a, .kpi-timeline a { color: var(--accent); text-decoration: none; }
.kpi-table a:hover, .kpi-table a:focus-visible, .kpi-timeline a:hover, .kpi-timeline a:focus-visible { text-decoration: underline; }
.kpi-timeline { display: flex; flex-direction: column; gap: 6px; }
.kpi-timeline-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.kpi-timeline-row { display: grid; grid-template-columns: minmax(120px, 28%) 1fr; gap: 10px; align-items: center; font-size: .86rem; }
.kpi-timeline-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-timeline-track { position: relative; height: 18px; border-radius: 6px; background: var(--surface-2); }
.kpi-timeline-bar { position: absolute; top: 2px; bottom: 2px; min-width: 3px; border-radius: 4px; border: 1px solid var(--border); }
.kpi-timeline-bar.kpi-rag-none { background: color-mix(in srgb, var(--muted) 35%, transparent); }
.kpi-timeline-today { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--accent); z-index: 1; }
.kpi-timeline-axis { margin: 0 0 0 calc(28% + 10px); display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); }
.kind-text { background: transparent; border-color: transparent; box-shadow: none; backdrop-filter: none; padding: 6px 4px; justify-content: center; }
.kpi-text-h1 { font-size: 1.45rem; color: var(--text); font-weight: 700; }
.kpi-text-h2 { font-size: 1.2rem; color: var(--text); font-weight: 700; }
.kpi-text-h3 { font-size: 1.02rem; color: var(--text); font-weight: 600; }
.kpi-text-h4 { font-size: .92rem; color: var(--text); font-weight: 600; }
.kpi-text-label { font-size: .74rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
/* A label sits on its row's foot, close to the widgets it names below it. */
.kind-text:has(.kpi-text-label), .kind-text:has(.kpi-text-h4) { justify-content: flex-end; padding-bottom: 2px; }
.kpi-text-body { margin: 0; white-space: pre-line; color: var(--text); }
.kpi-text-edit { display: none; position: absolute; top: 6px; left: 10px; z-index: 3; padding: 2px 10px; font-size: .78rem; }
.kpi-editing .kpi-text-edit { display: inline-flex; }
.kpi-editing .kind-text { border-color: var(--border); }
.kpi-text-form { position: absolute; inset: 36px 8px auto 8px; z-index: 4; display: flex; flex-direction: column; gap: 8px; padding: 10px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); cursor: auto; user-select: text; }
.kpi-text-form label { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; }
.kpi-text-actions { display: flex; gap: 8px; }
.kpi-editing .kind-text:has(.kpi-text-form) { overflow: visible; z-index: 5; }
@media (max-width: 700px) { .kpi-timeline-row { grid-template-columns: 1fr; } .kpi-timeline-axis { margin-left: 0; } }

/* Heat map (SD-029 Phase A4): one hue in five steps, light to dark, every figure written in its cell in the text colour. */
.kpi-heat-wrap { overflow-x: auto; }
.kpi-heat { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: .88rem; }
.kpi-heat th { font-weight: 600; text-align: left; color: var(--muted); padding: 4px 6px; white-space: nowrap; }
.kpi-heat thead th { text-align: center; }
.kpi-heat-cell, .kpi-heat-total { text-align: center; padding: 6px; border-radius: 4px; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-heat-total { font-weight: 600; }
.kpi-heat-0 { background: color-mix(in srgb, var(--muted) 6%, transparent); color: var(--muted); }
.kpi-heat-1 { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.kpi-heat-2 { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.kpi-heat-3 { background: color-mix(in srgb, var(--accent) 38%, transparent); }
.kpi-heat-4 { background: color-mix(in srgb, var(--accent) 54%, transparent); font-weight: 600; }
.kpi-heat-5 { background: color-mix(in srgb, var(--accent) 70%, transparent); font-weight: 700; }

/* The Experience plan (Q1 to Q4): a card's description in a pop-up, the designs an administrator cycles, and the new forms. Every colour is
   a theme token. A card lifts a little under the pointer; motion is off for those who ask their system for less. */
.kpi-widget { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.kpi-board:not(.kpi-editing) .kpi-widget:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.kpi-title { display: flex; align-items: center; gap: 6px; }
.kpi-info { flex: none; width: 17px; height: 17px; border-radius: 50%; border: 1px solid var(--border); background: transparent; color: var(--muted);
  font: 600 .66rem/1 var(--font-sans); font-style: italic; padding: 0; cursor: help; opacity: .55; transition: opacity .15s ease; }
.kpi-widget:hover .kpi-info, .kpi-info:focus-visible { opacity: 1; }
.kpi-info:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.kpi-tooltip { position: fixed; z-index: 1000; max-width: 280px; padding: 7px 10px; border-radius: 9px; pointer-events: none; font-size: .8rem; line-height: 1.35;
  color: var(--text); background: var(--bg); border: 1px solid var(--border); box-shadow: var(--shadow); }
.kpi-tooltip[hidden] { display: none; }
[data-tip] { cursor: default; }

/* The design control, on the Edit dashboard screen. */
.kpi-design { display: none; position: absolute; top: 8px; left: 10px; z-index: 3; align-items: center; gap: 4px; font-size: .74rem; }
.kpi-editing .kpi-design { display: inline-flex; }
.kpi-design-step, .kpi-design-swap { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 999px; padding: 2px 8px;
  font-size: .72rem; cursor: pointer; line-height: 1.3; }
.kpi-design-step:hover, .kpi-design-swap:hover { border-color: var(--accent); }
.kpi-design-name { color: var(--accent); font-weight: 600; white-space: nowrap; }

/* A figure with its change, sparkline or share. */
.kpi-metric-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.kpi-spark { width: 45%; max-width: 160px; height: 36px; flex: none; overflow: visible; }
.kpi-spark-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.kpi-spark-dot { fill: transparent; }
.kpi-spark-last { fill: var(--accent); }
.kpi-change { margin: 0; font-size: .82rem; font-weight: 600; }
.kpi-change-good { color: var(--ok); }
.kpi-change-bad { color: var(--danger); }
.kpi-change-flat { color: var(--muted); }
.kpi-ring { width: 64px; height: 64px; flex: none; }
.kpi-ring-track { fill: none; stroke: var(--surface-2); stroke-width: 12; }
.kpi-ring-fill { fill: none; stroke: var(--accent); stroke-width: 12; stroke-linecap: round; }
.kpi-ring-text { fill: var(--text); font: 700 20px var(--font-mono); }

/* The bullet: bands of the target's tones, the figure as a bar, the target as a line. */
.kpi-bullet { position: relative; height: 22px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.kpi-bullet-band { position: absolute; top: 0; bottom: 0; background: currentColor; opacity: .16; }
.kpi-bullet-bar { position: absolute; left: 0; top: 7px; height: 8px; border-radius: 4px; background: var(--text); }
.kpi-bullet-target { position: absolute; top: 2px; bottom: 2px; width: 3px; margin-left: -1px; border-radius: 2px; background: var(--text); }

/* Columns (an ageing histogram keeps its bands in order), the lollipop and the Pareto chart. */
.kpi-cols { list-style: none; margin: 0; padding: 0; flex: 1 1 auto; min-height: 110px; display: flex; align-items: stretch; gap: 6px; }
.kpi-cols li { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.kpi-col-track { flex: 1 1 auto; width: 100%; display: flex; align-items: flex-end; }
.kpi-col-fill { width: 100%; border-radius: 5px 5px 0 0; min-height: 2px; }
.kpi-col-value { font: 600 .78rem var(--font-mono); color: var(--text); }
.kpi-col-label { font-size: .72rem; color: var(--muted); text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-lollipop .kpi-bar-track { position: relative; background: none; }
.kpi-lolly-stick { position: absolute; left: 0; top: 50%; height: 2px; margin-top: -1px; background: var(--muted); }
.kpi-lolly-dot { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--accent); }
.kpi-pareto { width: 100%; height: auto; flex: 1 1 auto; min-height: 140px; }
.kpi-pareto-line { fill: none; stroke: var(--accent-2); stroke-width: 2; }
.kpi-pareto-dot { fill: var(--accent-2); }
.kpi-pareto-eighty { stroke: var(--muted); stroke-dasharray: 4 4; }

/* The 100% stacked bar, the waffle, the area and the dumbbell. */
.kpi-stack { display: flex; height: 18px; border-radius: 6px; overflow: hidden; gap: 2px; }
.kpi-stack-part { height: 100%; min-width: 2px; }
.kpi-stack-track { display: flex; gap: 2px; background: none; overflow: hidden; border-radius: 6px; }
.kpi-waffle-wrap { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.kpi-waffle { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; width: 120px; flex: none; }
.kpi-waffle-cell { aspect-ratio: 1; border-radius: 2px; }
.kpi-area { fill: var(--accent); opacity: .14; }
.kpi-dumbbell { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.kpi-dumbbell .kpi-bar-track { position: relative; background: none; height: 14px; }
.kpi-dumbbell-gap { position: absolute; top: 50%; height: 2px; margin-top: -1px; background: var(--muted); }
.kpi-dumbbell-dot { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; }

@media (prefers-reduced-motion: reduce) { .kpi-widget, .kpi-info { transition: none; } .kpi-board .kpi-widget:hover { transform: none; } }
@media print { .kpi-info, .kpi-design, .kpi-tooltip { display: none !important; } }

/* Home (the Experience plan, Q5): a card that opens its list, the wins in the success tone, and a nought that is good news. */
.kpi-linked { cursor: pointer; }
.kpi-linked:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kpi-editing .kpi-linked { cursor: grab; }
.kpi-widget.tone-good { background: linear-gradient(135deg, color-mix(in srgb, var(--ok) 10%, transparent), transparent 70%), var(--surface);
  border-color: color-mix(in srgb, var(--ok) 30%, var(--border)); }
.kpi-widget.tone-concern { border-color: color-mix(in srgb, var(--warn) 28%, var(--border)); }
.kpi-value.kpi-zero-good { color: var(--ok); }

/* A card is the same size on the Edit dashboard screen as on the view: its controls float over its top, shown when the pointer is on
   it or it has the keyboard's focus (always on a hidden card, so it can be shown again), instead of a strip added above its figures. */
.kpi-editing .kpi-show, .kpi-editing .kpi-design { display: none; top: 6px; box-shadow: var(--shadow); background: var(--surface); }
.kpi-editing .kpi-widget:hover .kpi-show, .kpi-editing .kpi-widget:focus-within .kpi-show, .kpi-editing .kpi-widget.kpi-is-hidden .kpi-show,
.kpi-editing .kpi-widget:hover .kpi-design, .kpi-editing .kpi-widget:focus-within .kpi-design { display: inline-flex; }
.kpi-editing .kpi-widget:hover, .kpi-editing .kpi-widget:focus-within { z-index: 4; }

/* A card one row tall: its title and its figure side by side, so a figure needs no more than a row. */
.kpi-widget[data-h="1"]:not(.kind-text) { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; padding-top: 6px; padding-bottom: 6px; }
.kpi-widget[data-h="1"] .kpi-title { font-size: .85rem; min-width: 0; }
.kpi-widget[data-h="1"] .kpi-value { font-size: clamp(1.15rem, 1.6vw, 1.5rem); }
.kpi-widget[data-h="1"] .kpi-change, .kpi-widget[data-h="1"] .kpi-target, .kpi-widget[data-h="1"] .kpi-scope { display: none; }
.kpi-widget[data-h="1"] .kpi-metric-row { flex: 0 1 auto; }
.kpi-widget[data-h="1"] .kpi-spark { width: 70px; height: 24px; }

/* Slide breaks and slide frames (Presentation options P2, P3). A break is a dashed line on the Edit screen and takes no room on the view;
   a frame outlines a slide at the presentation's proportions, so what lies inside it fits a slide at this size. */
.kind-break { background: transparent; border: none; box-shadow: none; backdrop-filter: none; padding: 0 12px; flex-direction: row; align-items: center; gap: 10px;
  align-self: start; height: 26px; margin-top: -20px; z-index: 5; overflow: visible; cursor: ns-resize; }
.kind-break[hidden] { display: none; }
.kpi-break-line { flex: 1 1 auto; border-top: 2px dashed var(--accent); }
.kpi-break-label { font-size: .78rem; font-weight: 600; color: var(--accent); white-space: nowrap; }
.kpi-break-remove { display: none; }
.kpi-editing .kind-break .kpi-break-remove { display: inline-flex; }
.kpi-slide-frame { pointer-events: none; z-index: 3; border: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent); border-radius: 14px;
  margin: -6px; position: relative; }
.kpi-slide-frame-scaled { border-color: color-mix(in srgb, var(--warn) 70%, transparent); }
.kpi-slide-label { position: absolute; top: -12px; right: 14px; font-size: .72rem; font-weight: 600; padding: 1px 8px; border-radius: 999px;
  background: var(--surface); color: var(--accent); border: 1px solid currentColor; }
.kpi-slide-frame-scaled .kpi-slide-label { color: var(--warn); }

/* A slide's top edge is a handle (above its frame, which lets the pointer through), and the guide shows the row it will start at. */
.kpi-slide-edge { pointer-events: auto; position: absolute; left: 0; right: 0; top: -9px; height: 16px; border: none; background: transparent;
  cursor: ns-resize; padding: 0; }
.kpi-slide-edge::after { content: ""; position: absolute; left: 50%; top: 4px; width: 56px; height: 8px; margin-left: -28px; border-radius: 999px;
  background: var(--accent); opacity: .7; }
.kpi-slide-edge:hover::after, .kpi-slide-edge:focus-visible::after { opacity: 1; }
.kpi-slide-edge:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kpi-slide-guide { pointer-events: none; z-index: 6; align-self: start; border-top: 3px solid var(--accent); margin-top: -8px; height: 0; }

/* The selected slide: a solid border and a light tint, the others faded, so the one being repositioned stands out. */
.kpi-slide-label { pointer-events: auto; cursor: pointer; font-family: inherit; }
.kpi-slide-label:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kpi-slide-selecting .kpi-slide-frame { opacity: .35; }
.kpi-slide-selecting .kpi-slide-frame.kpi-slide-frame-selected { opacity: 1; z-index: 4; border-style: solid; border-width: 3px; border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.kpi-slide-frame-selected .kpi-slide-label { background: var(--accent); color: var(--surface); border-color: var(--accent); }
.kpi-slide-frame-moving { transition: none; }

/* A slide's bottom edge is a handle too; the slide bar steps through the slides and adds or removes one. */
.kpi-slide-foot { top: auto; bottom: -9px; }
.kpi-slide-bar { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.kpi-slide-bar[hidden] { display: none; }
.kpi-slide-at { font-size: .82rem; font-weight: 600; min-width: 8.5em; text-align: center; }
