/* Insights: the customer picker, the top five, the failure-mode list and the comparison. */
/* Insights, master and detail: failure modes on the left select the comparison on the right */
.lead { margin: -8px 0 20px; max-width: 80ch; }
.ins-split { display: grid; grid-template-columns: minmax(0, 290px) minmax(0, 1fr); gap: 20px; align-items: start; }
.ins-split > .section { margin-bottom: 0; }
.ins-list { position: sticky; top: calc(var(--bar-h) + 12px); display: flex; flex-direction: column; max-height: calc(100vh - var(--bar-h) - 24px); }
.ins-list ol { margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.fm-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; width: 100%; padding: 10px 16px; border: 0; border-bottom: 1px solid var(--line);
  background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.fm-item:hover { background: var(--sunken); }
.fm-item[aria-current="true"] { background: var(--accent-soft); }
.fm-name { font-weight: 600; }
.fm-rate { font-weight: 600; text-align: right; }
.fm-meta { grid-column: 1 / -1; color: var(--ink-3); font-size: var(--fs-sm); }
.ins-detail > header { display: grid; gap: 10px; }
.ins-totals { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 0; font-size: var(--fs-sm); }
.ins-totals div { display: flex; gap: 6px; }
.ins-totals dt { color: var(--ink-3); }
.ins-totals dd { margin: 0; font-weight: 600; }
.cmp { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 20px 24px; margin-bottom: 12px; }  /* one column per customer, side by side */
/* more than three customers: one row each, ranked by failures, opening to the customer's own matrix */
.cmp-rows { margin-bottom: 12px; border-top: 1px solid var(--line); }
.cmp-row-head, .cmp-row > summary { display: grid; grid-template-columns: 10px minmax(0, 1.1fr) minmax(0, 1.5fr) 64px 84px minmax(0, 1fr); gap: 12px; align-items: center; }
.cmp-row-head { padding: 8px; border-bottom: 1px solid var(--line); color: var(--ink-3); font-size: var(--fs-xs); font-weight: 600; }
.cmp-row { border-bottom: 1px solid var(--line); }
.cmp-row > summary { padding: 10px 8px; border-radius: 0; color: var(--ink); font-weight: 400; transition: background-color var(--t); }
.cmp-row > summary::before { color: var(--ink-3); }
.cmp-row > summary:hover { background: var(--sunken); }
.cmp-row[open] > summary { background: var(--sunken); }
.cmp-open { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 24px; padding: 12px 8px 18px 28px; }
.cmp-open > svg { width: 260px; max-width: 100%; }
.cmp-col { display: grid; align-content: start; gap: 10px; min-width: 0; }
.cmp-col header { display: grid; gap: 4px; }
.cmp-col h3 { margin: 0; }
.cmp-col > svg { max-width: 260px; width: 100%; }
.cmp-facts { display: grid; gap: 6px; margin: 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.cmp-facts div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.cmp-facts dt { color: var(--ink-3); }
.cmp-facts dd { margin: 0; text-align: right; }
/* the customers being compared: chips that remove, a searchable list that adds, at least two always stay */
.picker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); }
.picker-k { color: var(--ink-3); font-size: var(--fs-sm); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chip { display: inline-flex; align-items: center; gap: 2px; min-height: 30px; padding: 0 3px 0 12px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-strong); font-size: var(--fs-sm); font-weight: 550; }
.chip-x { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: var(--r-pill); background: none; color: inherit; cursor: pointer; transition: background-color var(--t); }
.chip-x:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.chip-x[aria-disabled="true"] { opacity: .35; cursor: not-allowed; }
.chip-x[aria-disabled="true"]:hover { background: none; }
.chip-x svg, .btn.add svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; }
.btn.add { gap: 6px; }
.picker-menu { inset: auto; width: 260px; max-height: min(340px, 60vh); overflow-y: auto; }
.picker-menu input { width: 100%; margin-bottom: 6px; }
.picker-menu ul { margin: 0; padding: 0; list-style: none; }
.picker-menu p { margin: 6px 10px; }
/* top five: one ranked column per customer; bars compare a customer's own failures, the shared failure lights up across */
.t5 { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); }
.t5-col { min-width: 0; padding: 16px 18px 14px; }
.t5-col + .t5-col { border-left: 1px solid var(--line); }
.t5-col h3 { margin: 0 0 8px; font-size: var(--fs-md); }
.t5-col ol { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.t5-item { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; align-items: baseline; gap: 6px 10px; width: calc(100% + 16px); margin: 0 -8px; padding: 8px;
  border: 0; border-radius: var(--r); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: background-color var(--t); }
.t5-rank { color: var(--ink-3); font-size: var(--fs-sm); }
.t5-name { min-width: 0; }
.t5-n { font-weight: 650; }
.t5-bar { grid-column: 2 / -1; position: relative; height: 6px; border-radius: var(--r-pill); background: var(--sunken); overflow: hidden; }
.t5-bar::before { content: ""; position: absolute; inset: 0; transform: scaleX(var(--w)); transform-origin: left; border-radius: inherit; background: color-mix(in srgb, var(--ink) 40%, transparent); }
/* four or more customers: one row per customer, the five ranked failures across it */
.t5.rows { grid-template-columns: 1fr; }
.t5.rows .t5-col { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px 20px; align-items: start; padding: 12px 18px; }
.t5.rows .t5-col + .t5-col { border-left: 0; border-top: 1px solid var(--line); }
.t5.rows .t5-col h3 { margin: 8px 0 0; font-size: var(--fs-md); }
.t5.rows ol { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.t5.rows .t5-item { width: 100%; margin: 0; grid-template-columns: 14px minmax(0, 1fr) auto; font-size: var(--fs-sm); }
.t5-more { border-top: 1px solid var(--line); }
.t5-more > summary { padding: 12px 18px; }
.t5-item:is(:hover, .hl) { background: var(--sunken); }
.t5-item:is(:hover, .hl) .t5-bar { background: var(--panel); }
.t5-item:is(:hover, .hl) .t5-bar::before { background: var(--ink-2); }
.t5-item[aria-current="true"] { background: var(--accent-soft); }
.t5-item[aria-current="true"] .t5-name { color: var(--accent-strong); font-weight: 600; }
.t5-item[aria-current="true"] .t5-bar { background: var(--panel); }
.t5-item[aria-current="true"] .t5-bar::before { background: var(--accent); }
.strong { font-weight: 600; }
.group-title { margin: 24px 0 4px; }
@media (max-width: 600px) {
  .ins-split, .cmp, .t5 { grid-template-columns: 1fr; }
  .cmp-row-head { display: none; }
  .cmp-row > summary { grid-template-columns: 10px minmax(0, 1fr) auto; }
  .cmp-row > summary > :nth-child(n+2) { grid-column: 3; justify-self: end; }
  .t5-col + .t5-col { border-left: 0; border-top: 1px solid var(--line); }
  .t5.rows .t5-col { grid-template-columns: 1fr; }
  .t5.rows ol { grid-template-columns: 1fr; }
  .ins-detail { order: -1; }  /* the comparison first; the list under it picks the next mode */
  .ins-list { position: static; max-height: none; }
}
