/* The statistics view (stats-view.js): a dialog with the filters, the tree of busy time and the
   waiting for the user beside it. A bar is a <progress>, an indent a class: the page has no
   inline style. */
#stats-dialog { --k-api: #6d5bd0; --k-tools: #2f7fb8; --k-mcp: #1f8a70; --k-sub: #b07a1f; --k-wait: #8f8a82; --k-all: var(--accent); width: min(1120px, 96vw); }
html[data-theme="dark"] #stats-dialog { --k-api: #a596ff; --k-tools: #6fb6ea; --k-mcp: #5fc4a6; --k-sub: #e3ad55; --k-wait: #8a8780; }
#stats-dialog .st-sum { color: var(--muted); font-size: .86rem; font-weight: 400; margin-left: 8px; }
.st-body { display: flex; flex-direction: column; gap: 10px; }
/* The body scrolls, not a panel: a panel keeps its full height. */
.st-body > * { flex: none; }

.st-filters { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.st-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.st-seg button { border: 0; background: none; padding: 3px 10px; font: inherit; font-size: .8rem; color: var(--muted); cursor: pointer; }
.st-seg button + button { border-left: 1px solid var(--line); }
.st-seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.st-fl { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); }
.st-fl select { background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 2px 6px; font: inherit; font-size: .82rem; color: var(--ink); max-width: 200px; }
.st-reading { font-size: .82rem; color: var(--muted); margin: 0; }
.st-foot { font-size: .8rem; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; padding: 6px 10px; margin: 0; }

.st-panel { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.st-panel h3 { margin: 0; font-size: .74rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; padding: 8px 12px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.st-panel h3 .grow { flex: 1; }
.st-sub { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--muted); }
.st-legend { display: inline-flex; gap: 12px; flex-wrap: wrap; font-size: .76rem; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); }
.st-legend span { display: inline-flex; align-items: center; gap: 5px; }
.st-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; background: var(--k); }

.st-cols, .st-row { display: grid; grid-template-columns: minmax(200px, 1fr) 150px 92px 56px 66px 72px 84px 74px; align-items: center; gap: 8px; padding: 0 12px; }
.st-cols { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); height: 26px; border-bottom: 1px solid var(--line); }
.st-cols span:not(:first-child), .st-row .num { text-align: right; }
.st-row { min-height: 32px; border-bottom: 1px solid var(--line); cursor: default; }
.st-row:last-child { border-bottom: 0; }
.st-row:hover { background: var(--sunk); }
.st-row[aria-selected="true"] { background: var(--accent-soft); }
.st-row[aria-expanded] { cursor: pointer; }
.st-row .name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.st-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-row .chev { width: 14px; flex: none; color: var(--muted); font-size: .7rem; text-align: center; transition: transform .12s; }
.st-row[aria-expanded] .chev::before { content: "\25B6"; }
.st-row[aria-expanded="true"] .chev { transform: rotate(90deg); }
.st-row .sw { width: 8px; height: 8px; border-radius: 2px; flex: none; background: var(--k); }
.st-est { font-size: .64rem; font-weight: 700; color: var(--warn); border: 1px solid var(--warn); border-radius: 4px; padding: 0 4px; text-transform: uppercase; letter-spacing: .04em; flex: none; }
.st-note-in { color: var(--muted); font-size: .74rem; flex: none; }
.st-ref { color: var(--muted); font-size: .74rem; white-space: nowrap; flex: none; }
.st-row .num { font-variant-numeric: tabular-nums; font-size: .84rem; white-space: nowrap; }
.st-row .num.dim { color: var(--muted); }
.st-row.top { font-weight: 600; }
.st-row.total { background: var(--sunk); font-weight: 700; }
.st-row.plain .lbl { color: var(--muted); font-style: italic; }
.st-row.call { font-size: .82rem; cursor: pointer; }
.st-row.call .lbl { font-family: var(--f-mono, Consolas, monospace); font-size: .78rem; }
.st-row.call:hover .lbl { text-decoration: underline; }
/* The row that reads the next children of a node. */
.st-row.more { cursor: pointer; font-size: .82rem; }
.st-row.more .lbl { color: var(--accent); font-style: normal; }
.st-row.more:hover .lbl { text-decoration: underline; }
.st-row.more[aria-busy="true"] { cursor: progress; }
.st-row.more[aria-busy="true"] .lbl { color: var(--muted); }

.st-row.k-api, .st-legend .k-api { --k: var(--k-api); }
.st-row.k-tools, .st-legend .k-tools { --k: var(--k-tools); }
.st-row.k-mcp, .st-legend .k-mcp { --k: var(--k-mcp); }
.st-row.k-sub, .st-legend .k-sub { --k: var(--k-sub); }
.st-row.k-wait { --k: var(--k-wait); }
.st-row.k-all { --k: var(--k-all); }

/* The bar: a <progress> in the colour of its kind. */
.st-bar { appearance: none; -webkit-appearance: none; width: 100%; height: 8px; border: 0; border-radius: 4px; background: var(--sunk); overflow: hidden; }
.st-bar::-webkit-progress-bar { background: var(--sunk); border-radius: 4px; }
.st-bar::-webkit-progress-value { background: var(--k); border-radius: 4px; }
.st-bar::-moz-progress-bar { background: var(--k); border-radius: 4px; }

/* The indent of a level. */
.st-row.lvl-1 .name { padding-left: 18px; }
.st-row.lvl-2 .name { padding-left: 36px; }
.st-row.lvl-3 .name { padding-left: 54px; }
.st-row.lvl-4 .name { padding-left: 72px; }
.st-row.lvl-5 .name { padding-left: 90px; }
.st-row.lvl-6 .name { padding-left: 108px; }

/* A narrow screen: the name and the time, the bar under the name. */
@media (max-width: 720px) {
  .st-cols, .st-row { grid-template-columns: minmax(0, 1fr) 96px; }
  .st-cols .c-calls, .st-cols .c-avg, .st-cols .c-slow, .st-cols .c-cost, .st-cols .c-share, .st-cols .c-bar,
  .st-row .c-calls, .st-row .c-avg, .st-row .c-slow, .st-row .c-cost, .st-row .c-share { display: none; }
  .st-row { grid-template-rows: auto auto; padding-top: 4px; }
  .st-row .c-bar { grid-column: 1 / -1; grid-row: 2; margin: -4px 0 6px 20px; }
  .st-row.call .c-bar, .st-row.plain .c-bar, .st-row.total .c-bar { display: none; }
  .st-row .c-time { grid-column: 2; grid-row: 1; }
  .st-filters { flex-direction: column; align-items: stretch; }
}
