/* Feature: Triage console (staff overview, case queue, case detail).
   Owner: Wei Ye
   Layout first, then the Clarity look. Clarity's rules come last and win. */

/* ---------- Layout (from base.css) ---------- */

.kpis { display: grid; gap: 1rem; margin-bottom: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); }
.kpi {
  display: flex; flex-direction: column; gap: .25rem; padding: 1.25rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.kpi-label { font-size: 1rem; font-weight: 600; line-height: 1.3; }
.kpi-value { font-family: var(--font-head); font-size: 2.5rem; font-weight: 700; line-height: 1.1; }
.kpi-note { color: var(--muted); font-size: 1rem; line-height: 1.35; }
.kpi--alert { border-top: 4px solid var(--accent); }

.staff-grid { display: grid; gap: 1.5rem; }
@media (min-width: 64rem) {
  .staff-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
  .panel-queue { grid-column: 1 / -1; }
}
.panel-chart { overflow: hidden; }   /* keeps hover labels inside the card */
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.panel-head h2 { margin: 0; }

/* Bar chart: thin bars with rounded tops, faint grid lines, one colour */
.chart { display: grid; grid-template-columns: 2rem minmax(0, 1fr); grid-template-rows: 13rem auto; column-gap: .5rem; margin: 1.5rem 0 1rem; }
.chart-scale { position: relative; }
.chart-scale span {
  position: absolute; right: 0; top: calc(var(--y) * 100%); transform: translateY(-50%);
  color: var(--muted); font-size: .9375rem; line-height: 1;
}
.bars {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px;
  border-bottom: 2px solid var(--muted);
  background: repeating-linear-gradient(to bottom, var(--grid-line) 0 1px, transparent 1px 33.333%);
}
.bar-col { display: flex; align-items: flex-end; justify-content: center; height: 100%; }
.bar {
  position: relative; display: block; width: min(2.5rem, 70%); height: var(--h);
  background: var(--bar); border-radius: 4px 4px 0 0;
}
.bar:hover, .bar:focus-visible { filter: brightness(.82); }
.bar-value, .bar-tip {
  position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  font-size: .9375rem; font-weight: 700; line-height: 1.3; white-space: nowrap; pointer-events: none;
}
.bar-value { color: var(--text); }
.bar-tip {
  padding: .125rem .5rem; border-radius: 4px; background: var(--text); color: var(--bg);
  opacity: 0; transition: opacity .15s;
}
.bar:hover .bar-tip, .bar:focus-visible .bar-tip { opacity: 1; }
.bar:hover .bar-value, .bar:focus-visible .bar-value { opacity: 0; }
/* Labels near the edges line up with the edge, so they never stick out of the card */
.bar-col:nth-child(-n+2) .bar-tip { left: 0; transform: none; }
.bar-col:nth-last-child(-n+2) .bar-tip { left: auto; right: 0; transform: none; }
.bar-days {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px;
  padding-top: .4rem; color: var(--muted); font-size: .9375rem; text-align: center;
}
.bar-days .is-today { color: var(--text); font-weight: 700; }
.chart-table summary { min-height: 48px; display: flex; align-items: center; color: var(--muted); font-weight: 600; cursor: pointer; }
.chart-table table { margin-top: .5rem; }

/* Results this week: the badge names each bar */
.mix { display: grid; gap: .875rem; }
.mix li { display: grid; grid-template-columns: 12rem minmax(0, 1fr) 2.5rem; align-items: center; gap: .75rem; }
.mix-track { height: .875rem; overflow: hidden; background: var(--surface-2); border-radius: 4px; }
.mix-fill { display: block; width: var(--w); height: 100%; background: var(--bar-2); border-radius: 0 4px 4px 0; }
.mix-n { font-weight: 700; text-align: right; }
.mix-total { margin: 1.25rem 0 0; color: var(--muted); font-size: 1rem; }
/* In a narrow card, each bar goes under its badge so it keeps a useful length */
.panel-mix { container-type: inline-size; }
@container (max-width: 30rem) {
  .mix li { grid-template-columns: minmax(0, 1fr) auto; gap: .375rem .75rem; }
  .mix-track { grid-column: 1 / -1; grid-row: 2; }
}

/* The "check these first" table */
.queue { min-width: 50rem; }
.queue th, .queue td { white-space: nowrap; }
.queue .queue-what { min-width: 18rem; white-space: normal; }
/* Case numbers are links now; inline-flex lets them keep the 44px tap height */
.case-link {
  display: inline-flex; align-items: center;
  min-height: 44px; padding: 0; background: none; border: 0; cursor: pointer;
  color: var(--text); font-weight: 700; text-decoration: underline; text-underline-offset: 3px;
}
.status { font-weight: 700; }
.status--new::before {
  content: ""; display: inline-block; width: .625rem; height: .625rem; margin-right: .4rem;
  border-radius: 50%; background: var(--red);
}
.status--new { color: var(--accent-text); }
.status--in-review { color: var(--muted); }

.honesty { display: flex; gap: .625rem; align-items: flex-start; margin: 1.5rem 0 0; color: var(--muted); font-size: 1rem; }
.honesty .icon { width: 1.375rem; height: 1.375rem; }

/* ---------- Clarity look (from clarity.css) ---------- */

.kpi-value { font-weight: 800; letter-spacing: -.02em; }
.kpi { border: 0; }
.kpi--alert { background: var(--red-dark); color: var(--white); }
.kpi--alert .kpi-note { color: var(--white); }

/* ======================================================================================
   Flagged activity and case detail, in the order they appear on screen: queue, then case detail.
   Owner: Wei Ye
   Uses only Clarity's variables (var(--red), var(--surface), ...), no new colour codes.
   ====================================================================================== */

/* ---------- Flagged activity: the "how does activity get here" box ---------- */

.how-raised { margin-bottom: 1.5rem; }
.how-raised summary { min-height: 48px; display: flex; align-items: center; font-weight: 700; cursor: pointer; }
.how-list { display: grid; gap: .875rem; margin: .75rem 0 1rem; }
.how-list li { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: .5rem 1rem; align-items: start; }
.how-note { display: flex; gap: .625rem; margin: 0; color: var(--muted); font-size: 1rem; }
.how-note .icon { flex: none; width: 1.375rem; height: 1.375rem; }
@media (max-width: 47.99rem) { .how-list li { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Case queue: tabs, search and menus ---------- */

.qf { margin-bottom: 1rem; }

.qf-row { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }

/* base.css styles text boxes only, so the menu and the notes box get the same look here */
.screen-staff-queue .field input[type="search"], .screen-staff-queue .field select {
  display: block; width: 100%; min-height: 56px; padding: .75rem 1rem;
  background: var(--surface); color: var(--text); font: inherit;
  border: 2px solid var(--field-border); border-radius: var(--radius);
}

.qt-count { margin: 0 0 .5rem; color: var(--muted); font-size: 1rem; }
.qt-empty { display: flex; gap: .625rem; align-items: center; padding: 1.5rem .5rem; margin: 0; color: var(--muted); }
.qt-empty .icon { flex: none; width: 1.5rem; height: 1.5rem; }

/* ---------- Case queue: the table ---------- */

.case-table { min-width: 56rem; }
.source { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; }
.source .icon { flex: none; width: 1.25rem; height: 1.25rem; }
.risk-score { margin-left: .5rem; color: var(--muted); font-weight: 600; }
.money-flag {
  display: flex; align-items: center; gap: .4rem; margin-top: .375rem;
  color: var(--accent-text); font-weight: 700; font-size: 1rem;
}
.money-flag .icon { flex: none; width: 1.25rem; height: 1.25rem; }
.live-flag { display: block; margin-top: .375rem; color: var(--muted); font-size: .9375rem; font-style: italic; }
/* Outcomes: a small mark and words. Paused = square, Released = tick, Cancelled = cross,
   Sent to investigators = arrow, Recorded = dot. */
.status--paused, .status--sent-to-investigators { color: var(--accent-text); }
.status--paused::before {
  content: ""; display: inline-block; width: .625rem; height: .625rem; margin-right: .4rem;
  border: 2px solid var(--red-dark); border-radius: 2px;
}
.status--sent-to-investigators::before { content: "\2192"; margin-right: .4rem; }
.status--released { color: var(--muted); }
.status--released::before { content: "\2713"; margin-right: .4rem; }
.status--cancelled { color: var(--muted); }
.status--cancelled::before { content: "\2715"; margin-right: .4rem; }
.status--recorded { color: var(--muted); }
.status--recorded::before {
  content: ""; display: inline-block; width: .5rem; height: .5rem; margin-right: .5rem;
  border-radius: 50%; background: var(--muted);
}

/* ---------- Case detail ---------- */

.case-title { margin-top: 1.25rem; }
.muted { color: var(--muted); }
.case-alert {
  display: flex; gap: .75rem; align-items: flex-start; margin: 0 0 1.25rem; padding: 1rem 1.25rem;
  background: var(--red-dark); color: var(--white); border-radius: var(--radius-lg);
}
.case-alert .icon { flex: none; width: 1.5rem; height: 1.5rem; }

.case-grid { display: grid; gap: 1.5rem; margin-top: 1.5rem; }
.case-main, .case-side { display: grid; gap: 1.5rem; align-content: start; min-width: 0; }
.case-pair { display: grid; gap: 1.5rem; }
@media (min-width: 64rem) {
  .case-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
}

/* "Label: value" lists */
.facts { display: grid; gap: .75rem; margin: 0; }
.facts div { display: grid; grid-template-columns: 10rem minmax(0, 1fr); gap: .25rem 1rem; align-items: center; }
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; font-weight: 600; }
@media (max-width: 47.99rem) { .facts div { grid-template-columns: minmax(0, 1fr); } }
.qa { display: grid; gap: .875rem; margin: 0 0 1rem; }
.qa dt { color: var(--muted); font-weight: 600; }
.qa dd { margin: 0; font-weight: 700; }

/* Why it was raised */
.why-source { display: grid; gap: .375rem; margin: 0 0 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); color: var(--muted); }
.why-source .source { color: var(--text); }
.why-list { display: grid; gap: 1rem; }
.why-list li { display: grid; grid-template-columns: 3rem minmax(0, 1fr); gap: .75rem; align-items: start; }
.why-pts {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.25rem;
  background: var(--surface-2); border-radius: var(--radius); font-weight: 800;
}
.why-pts .icon { width: 1.25rem; height: 1.25rem; }
.why-total { margin: 1.25rem 0 .5rem; }
.why-track { height: .875rem; overflow: hidden; background: var(--surface-2); border-radius: 4px; }
.why-fill { display: block; width: var(--w); height: 100%; background: var(--bar-2); border-radius: 0 4px 4px 0; }

.voice-line { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; margin: 0 0 .5rem; }
.evidence { display: grid; gap: .875rem; }
.evidence li { display: flex; gap: .75rem; align-items: flex-start; }
.evidence .icon { flex: none; width: 1.5rem; height: 1.5rem; }

/* Timeline: a plain list with a thin line down the side */
.timeline { display: grid; gap: 1rem; padding-left: 1rem; border-left: 3px solid var(--border); }
.timeline li { display: grid; gap: .125rem; }
.tl-time { color: var(--muted); font-size: 1rem; font-weight: 600; }

/* "Where this stands" (view only, no buttons) */
.standing-outcome { margin: 0 0 .75rem; font-size: 1.25rem; }
.standing .honesty { margin-top: 1.25rem; }

/* The receiver warning */
.receiver-alert {
  display: flex; gap: .75rem; align-items: flex-start; margin: 0 0 1rem; padding: .875rem 1rem;
  background: var(--red-tint); color: var(--red-dark); border: 2px solid var(--red); border-radius: var(--radius); font-weight: 700;
}
.receiver-alert .icon { flex: none; width: 1.5rem; height: 1.5rem; }

/* ---------- Small screens: tables become cards ----------
   Under 48rem a wide table would need sideways scrolling, so each row turns into a small card:
   the case number on top, then "label: value" lines. The labels come from the columns' names
   (written below, because the header row is hidden visually but kept for screen readers).
   This covers the overview's "Latest flagged activity" table and the Flagged activity table. */
@media (max-width: 47.99rem) {
  .queue, .queue tbody, .queue tr, .queue th, .queue td { display: block; }
  .queue { min-width: 0; }
  .queue thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .queue tbody tr { margin-bottom: .875rem; padding: .75rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
  .queue th, .queue td { padding: .3rem 0; border: 0; white-space: normal; }
  .queue tbody tr:last-child > * { border-bottom: 0; }
  .queue th[scope="row"] { margin-bottom: .25rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
  .queue td { position: relative; padding-left: 7rem; min-height: 2.25rem; }
  .queue td::before { position: absolute; left: 0; top: .3rem; width: 6.25rem; color: var(--muted); font-size: .9375rem; font-weight: 700; line-height: 1.4; }
  .queue .queue-what { min-width: 0; }

  /* The overview table: Case, Received, Result, What happened, Outcome */
  .queue td:nth-child(2)::before { content: "Received"; }
  .queue td:nth-child(3)::before { content: "Result"; }
  .queue td:nth-child(4)::before { content: "What happened"; }
  .queue td:nth-child(5)::before { content: "Outcome"; }

  /* The Flagged activity table: Case, Received, Raised by, Risk, What happened, Outcome */
  .case-table td:nth-child(3)::before { content: "Raised by"; }
  .case-table td:nth-child(4)::before { content: "Risk"; }
  .case-table td:nth-child(5)::before { content: "What happened"; }
  .case-table td:nth-child(6)::before { content: "Outcome"; }

  /* Tighter page edges and a stacked filter row */
  .qf-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qf-row .field:first-child, .qf-row .field:last-child { grid-column: 1 / -1; }
  .panel { padding: 1.125rem; }
  .why-list li { grid-template-columns: 2.75rem minmax(0, 1fr); gap: .625rem; }
}

/* ======================================================================================
   Flagged activity: the two mini tabs and the Insights tab.
   Class names start with "ins-" or "subtab" so they can't clash with the overview's chart
   (.chart, .bars and .bar).
   ====================================================================================== */

/* ---------- The two mini tabs (Insights, Cases) ---------- */

.subtabs { display: flex; flex-wrap: wrap; gap: .25rem; width: fit-content; max-width: 100%; margin: 0 0 1.5rem; padding: .25rem; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow); }
.subtabs a { display: inline-flex; align-items: center; gap: .5rem; min-height: 48px; padding: .5rem 1.25rem; border-radius: 999px; color: var(--text); font-weight: 700; text-decoration: none; }
.subtabs a:hover { background: var(--surface-2); }
.subtabs [aria-current="page"] { background: var(--red-tint); color: var(--red-dark); }
.subtabs .icon { flex: none; width: 1.25rem; height: 1.25rem; }
.subtab-n { min-width: 1.5rem; padding: 0 .4rem; text-align: center; background: var(--surface-2); border-radius: 999px; font-size: .9375rem; }

/* ---------- The Daily / Weekly switch ---------- */

.ins-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: 1.5rem; }
.ins-period-label { font-weight: 700; }
.ins-period { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  display: inline-flex; align-items: center; min-height: 48px; padding: .5rem 1.25rem; cursor: pointer;
  background: var(--surface); color: var(--text); font-weight: 700;
  border: 2px solid var(--field-border); border-radius: 999px;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- The Insights tab ---------- */

#ins-body { display: grid; gap: 1.5rem; }
#ins-body > * { margin: 0; }
.ins-kpis { margin-bottom: 0; }
.ins-pair { display: grid; gap: 1.5rem; }
.ins-pair > .panel { min-width: 0; }
@media (min-width: 64rem) { .ins-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ins-pair .muted, #ins-body .muted { margin-top: 0; }

.ins-glance { display: grid; gap: .875rem; }
.ins-glance li { display: flex; gap: .75rem; align-items: flex-start; }
.ins-glance .icon { flex: none; width: 1.375rem; height: 1.375rem; margin-top: .125rem; }

/* The stacked bar chart: one bar per day or week, split into three pieces */
.ins-chart { display: grid; grid-template-columns: 2.25rem minmax(0, 1fr); grid-template-rows: 14rem auto; column-gap: .5rem; margin: 1.5rem 0 1rem; }
.ins-scale { position: relative; }
.ins-scale span { position: absolute; right: 0; bottom: calc(var(--y) * 100%); transform: translateY(50%); color: var(--muted); font-size: .8125rem; }
.ins-plot {
  position: relative; height: 100%; border-bottom: 2px solid var(--border);
  background-image: linear-gradient(var(--border) 1px, transparent 1px); background-size: 100% 33.3333%;
}
.ins-cols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; align-items: end; height: 100%; margin: 0; padding: 0; list-style: none; }
.ins-cols--line { gap: 0; }
.ins-col { position: relative; display: flex; align-items: flex-end; justify-content: center; height: 100%; }
.ins-total { position: absolute; bottom: calc(var(--h) + 3px); color: var(--muted); font-size: .8125rem; font-weight: 700; }
.ins-col.is-now .ins-total { color: var(--text); }
.ins-stack { display: flex; flex-direction: column-reverse; width: 100%; max-width: 2.5rem; height: var(--h); overflow: hidden; border-radius: 6px 6px 0 0; }
.ins-stack:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.seg { display: block; min-width: 0; border-top: 1px solid var(--surface); }
/* Three different fills (solid red, red stripes, slate), so the pieces differ by pattern and not only colour */
.seg--auto { background: var(--red-dark); }
.seg--pause { background: repeating-linear-gradient(135deg, var(--red) 0 5px, var(--red-tint) 5px 10px); }
.seg--report { background: var(--bar-2); }
.ins-days { grid-column: 2; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; margin: .5rem 0 0; padding: 0; list-style: none; }
.ins-days li { display: grid; text-align: center; color: var(--muted); font-size: .8125rem; line-height: 1.25; overflow-wrap: anywhere; }
.ins-days .is-now { color: var(--text); font-weight: 800; }
.ins-legend { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin: 1rem 0; }
.ins-legend li { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.swatch { display: inline-block; flex: none; width: 1.125rem; height: 1.125rem; border-radius: 4px; border-top: 0; }

/* Lists of bars: what happened, when, which warning signs */
.ins-rows { display: grid; gap: 1.125rem; }
.ins-rows li { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label n" "track track"; gap: .375rem .75rem; align-items: start; }
.ins-row-label { grid-area: label; font-weight: 700; }
.ins-row-label small { display: block; color: var(--muted); font-size: .9375rem; font-weight: 400; }
.ins-row-n { grid-area: n; font-weight: 800; white-space: nowrap; text-align: right; }
.ins-row-n small { color: var(--muted); font-size: .9375rem; font-weight: 600; }
.ins-track { grid-area: track; height: .75rem; overflow: hidden; background: var(--surface-2); border-radius: 6px; }
.ins-fill { display: block; width: var(--w); height: 100%; background: var(--bar-2); border-radius: 0 6px 6px 0; }
.ins-mark { margin-left: .5rem; padding: .05rem .5rem; border: 2px solid var(--text); border-radius: 999px; font-size: .8125rem; font-weight: 700; white-space: nowrap; }

/* The receivers list */
.ins-receivers { display: grid; gap: .875rem; margin-bottom: 1rem; }
.ins-receivers li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem .75rem; align-items: start; padding-bottom: .875rem; border-bottom: 1px solid var(--border); }
.ins-receivers li:last-child { padding-bottom: 0; border-bottom: 0; }
.rc-top { display: flex; flex-wrap: wrap; gap: .125rem .75rem; align-items: baseline; }
.rc-acct { color: var(--muted); }
.rc-meta { grid-column: 1 / -1; color: var(--muted); }

@media (max-width: 47.99rem) {
  .subtabs { width: 100%; }
  .subtabs a { flex: 1; justify-content: center; padding: .5rem .75rem; }
  .ins-chart { grid-template-columns: 1.75rem minmax(0, 1fr); grid-template-rows: 12rem auto; column-gap: .375rem; }
  .ins-cols, .ins-days { gap: 2px; }
  .ins-stack { max-width: 1.75rem; }
  .ins-total, .ins-days li, .ins-scale span { font-size: .6875rem; }
  .ins-wd, .ins-mo { display: none; }
}


/* ---------- Chart styles: the switch, side-by-side bars and lines ---------- */

.ins-modes-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: .75rem 0 .5rem; }
.ins-modes { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Side by side: three thin bars per day or week */
.ins-group { display: flex; align-items: flex-end; justify-content: center; gap: 2px; width: 100%; max-width: 3.75rem; height: 100%; }
.ins-group:focus-visible, .ins-hit:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.gbar { position: relative; flex: 1 1 0; min-width: 0; max-width: 1.125rem; height: var(--h); border-radius: 4px 4px 0 0; }
.gval { position: absolute; bottom: 100%; left: 50%; margin-bottom: 2px; transform: translateX(-50%); color: var(--text); font-size: .75rem; font-weight: 700; }

/* Lines: one line per source. The lines differ by dash pattern and by the shape of their points
   (circle, diamond, triangle), so colour is never the only way to tell them apart. */
.ins-hit { display: block; width: 100%; height: 100%; }
.ins-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.ln { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.ln--auto { stroke: var(--red-dark); }
.ln--pause { stroke: var(--red); stroke-dasharray: 9 6; }
.ln--report { stroke: var(--bar-2); stroke-dasharray: 1 6; stroke-width: 4; }
.pt { position: absolute; width: .8125rem; height: .8125rem; transform: translate(-50%, 50%); pointer-events: none; }
.pt--auto { background: var(--red-dark); border-radius: 50%; }
.pt--pause { background: var(--red); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.pt--report { background: var(--bar-2); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.pt-val { position: absolute; margin-left: .625rem; transform: translateY(50%); color: var(--text); font-size: .75rem; font-weight: 700; pointer-events: none; }
.ins-key { position: relative; display: inline-block; flex: none; width: 2.5rem; height: 1rem; }
.ins-key::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 3px solid var(--red-dark); }
.ins-key--pause::before { border-top-style: dashed; border-color: var(--red); }
.ins-key--report::before { border-top-style: dotted; border-top-width: 4px; border-color: var(--bar-2); }
.ins-key .pt { left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%); }

/* ---------- Four-number cards: the arrow and words are coloured by what they mean ---------- */

.delta { font-weight: 700; }
.delta--bad { color: var(--red-dark); }      /* more flags: worse */
.delta--good { color: #1B6E3F; }             /* fewer flags: better */
.delta--flat { color: var(--muted); }

/* ---------- "Show as a table" looks like the button it is ---------- */

#ins-body .chart-table summary {
  display: inline-flex; align-items: center; gap: .5rem; min-height: 48px; padding: 0 1.25rem; cursor: pointer; list-style: none;
  background: var(--surface); color: var(--text); font-weight: 700;
  border: 2px solid var(--field-border); border-radius: 999px;
}
#ins-body .chart-table summary::-webkit-details-marker { display: none; }
#ins-body .chart-table summary::after { content: "\25BE"; transition: transform .15s; }
#ins-body .chart-table[open] summary::after { transform: rotate(180deg); }
#ins-body .chart-table summary:hover { background: var(--surface-2); }
#ins-body .chart-table .table-wrap { margin-top: .75rem; }

.th-short { display: none; }   /* short table headings only show on narrow screens (see below) */

/* ---------- Small screens, part two ---------- */

@media (max-width: 47.99rem) {
  /* The shared staff menu normally slides sideways on phones, which hides Trends, Scam types and
     Settings. On these screens it wraps into two columns instead, so every link is visible. */
  .screen-staff .side-nav, .screen-staff-queue .side-nav, .screen-staff-case .side-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow-x: visible; }
  .screen-staff .side-nav a, .screen-staff-queue .side-nav a, .screen-staff-case .side-nav a { white-space: normal; }

  /* The table behind the chart: smaller padding and wrapping headings, so it fits without sideways scrolling */
  #ins-body .chart-table .data-table { min-width: 0; width: 100%; }
  #ins-body .chart-table th, #ins-body .chart-table td { padding: .5rem .3rem; font-size: .875rem; white-space: normal; }
  .th-full { display: none; }
  .th-short { display: inline; }

  .ins-key { width: 2rem; }
  .ins-modes .chip { padding: .5rem 1rem; }
}

/* Big numbers shrink to fit their card (so "$21,300" never spills out of a narrow card) */
.ins-kpis .kpi { container-type: inline-size; }
.ins-kpis .kpi-value { font-size: clamp(1.5rem, 19cqi, 2.5rem); overflow-wrap: anywhere; }

/* ---------- Flagged activity: pressable panels, summary, one-line charts ---------- */

/* The four panels reuse the pressable look from triage-overview.css. The red "money sent" panel is only
   filled when picked, like the others, and keeps its red top edge so it still stands out. */
.ins-kpis .ov-kpi.kpi--alert:not([aria-pressed="true"]) { background: var(--surface); color: var(--text); border-top: 4px solid var(--accent); }
.ins-kpis .ov-kpi.kpi--alert:not([aria-pressed="true"]) .kpi-note { color: var(--muted); }

/* Summary: the title with the Short / Detailed buttons on the right (under it on a phone) */
.ins-glance-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin-bottom: .75rem; }
.ins-glance-head h2 { margin: 0; }
.ins-glance--short { gap: 1rem; font-size: 1.1875rem; }
.ins-glance--short .icon { width: 1.5rem; height: 1.5rem; }

/* One-line charts (Cancelled by customers, Money already sent) */
.seg--one { background: var(--red-dark); }
.ln--one { stroke: var(--red-dark); }
.pt--one { background: var(--red-dark); border-radius: 50%; }
/* A long last value (like $21,300) sits above its point so it never runs off the card */
.pt-val--above { margin-left: 0; transform: translate(-50%, -.75rem); }

/* On the filled (picked) panel the up/down words turn white so they stay readable */
.ins-kpis .ov-kpi[aria-pressed="true"] .delta { color: var(--white); }