/* usage.css - admin Usage dashboard and run drill-in. Colors come from tokens.css. */

/* ---------- filter bar ---------- */
.u-filters { overflow: visible; padding: 14px 18px; }
.u-filter-row { display: flex; align-items: flex-end; gap: 14px 16px; flex-wrap: wrap; }
.u-fgroup { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.u-flabel { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); line-height: 16px; }
/* Every control in the bar is 40px tall so the labels and controls line up. */
.u-fgroup select { width: auto; min-width: 150px; height: 40px; padding-top: 0; padding-bottom: 0; font-size: 13px; }
.u-filters .segmented { height: 40px; }
.u-filters .segmented .seg { padding: 0 12px; height: 32px; }
.u-people { position: relative; }
.u-picker-btn {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 190px; max-width: 260px;
  height: 40px; padding: 0 12px; font: inherit; font-size: 13px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); cursor: pointer;
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.u-picker-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-picker-btn .ic { width: 15px; height: 15px; color: var(--muted); }
.u-picker-btn:hover { border-color: var(--faint); }
.u-picker-btn[aria-expanded="true"] { border-color: var(--info); box-shadow: var(--ring); }
.u-reset { margin-left: auto; align-self: flex-end; height: 40px; }
.u-reset .ic { width: 14px; height: 14px; }

.u-picker {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: 340px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-3);
  overflow: hidden; animation: u-pop var(--dur-2) var(--ease);
}
@keyframes u-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.u-picker-search { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.u-picker-search .ic { width: 16px; height: 16px; color: var(--muted); }
.u-picker-search input { border: none; padding: 4px 0; box-shadow: none; font-size: 13.5px; background: transparent; }
.u-picker-search input:focus { box-shadow: none; }
.u-picker-actions { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.u-picker-actions button { font: inherit; font-size: 12px; font-weight: 600; color: var(--primary-text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-xs); padding: 3px 10px; cursor: pointer; }
.u-picker-actions button:hover { border-color: var(--primary); }
.u-picker-count { margin-left: auto; font-size: 12px; color: var(--muted); }
.u-picker-list { max-height: 320px; overflow-y: auto; padding: 4px; }
.u-pick { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r-sm); cursor: pointer; }
.u-pick:hover { background: var(--surface-2); }
.u-pick input { width: 15px; height: 15px; flex: none; margin: 0; }
.u-pick-main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.u-pick-name { font-size: 13px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-pick-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-pick-n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.u-pick-empty { padding: 16px; font-size: 13px; color: var(--muted); text-align: center; }

.u-custom { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line-strong); }
.u-cfield { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.u-cfield input { font: inherit; font-size: 13px; color: var(--ink); padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); }
.u-cto { font-size: 13px; color: var(--muted); padding-bottom: 8px; }
.u-cnote { font-size: 12px; color: var(--muted); padding-bottom: 9px; }
.u-cnote.bad { color: var(--danger-text); font-weight: 600; }

.u-scope { margin: -8px 0 14px; font-size: 13px; color: var(--muted); }
[data-body].u-loading > :not([data-runs-section]), [data-body].u-loading [data-runs], [data-body].u-loading [data-more] { opacity: .55; transition: opacity var(--dur-2) var(--ease); pointer-events: none; }

/* ---------- KPI tiles: a lead tile beside a 4 x 2 grid ---------- */
.u-kpis { display: grid; grid-template-columns: minmax(0, 1.35fr) repeat(4, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 12px; }
.u-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-1); padding: 14px 16px; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.u-kpi .l { font-size: 12px; font-weight: 600; color: var(--muted); line-height: 1.3; }
.u-kpi .v { font-size: 22px; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.25; }
.u-kpi .s { font-size: 12px; color: var(--muted); line-height: 1.4; }
.u-kpi.lead { grid-row: span 2; background: linear-gradient(160deg, var(--brand-tint), var(--surface) 70%); border-color: var(--line-strong); padding: 18px 20px; }
.u-kpi.lead .v { font-size: 34px; margin-top: 2px; }
.u-spark { margin-top: auto; padding-top: 12px; }
.u-spark svg { display: block; }

/* ---------- chart ---------- */
.u-chart-tools { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: flex-end; }
.u-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.u-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.u-sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.u-sw-package { background: var(--chart-1); }
.u-sw-summary { background: var(--chart-2); }
.u-sw-benefit_table { background: var(--chart-3); }
.u-chart { width: 100%; min-height: 250px; }
.u-chart svg { display: block; width: 100%; height: auto; }
.u-chart .bar:hover rect:not([fill="transparent"]) { opacity: .82; }
.u-chart-empty { height: 250px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 13.5px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--r-sm); padding: 0 16px; }

/* ---------- top users, then outcomes / modes / offices ---------- */
.u-trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: stretch; }
.u-office-c { white-space: nowrap; color: var(--ink-2); }
.u-narrow-sub { display: none !important; }
.u-office { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.u-office-bar { background: var(--prism-band); }
.u-when { white-space: nowrap; color: var(--ink-2); }
.u-top-wrap { overflow-x: auto; }
.u-top-table thead th { background: transparent; padding: 10px 16px; }
.u-top-table tbody td { padding: 10px 16px; }
.u-top-table tbody tr:hover { background: transparent; }
.u-person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.u-rank { width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--bg-tint); color: var(--ink-2); font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.u-pmain { display: flex; flex-direction: column; min-width: 0; }
.u-pname { font-weight: 600; color: var(--ink); white-space: nowrap; }
.u-pname .badge { margin-left: 6px; padding: 1px 7px; font-size: 10.5px; vertical-align: 1px; }
.u-psub { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.u-top-more { padding: 6px 12px 12px; border-top: 1px solid var(--line); text-align: center; }
.u-top-more .btn { margin-top: 6px; }
.u-none { font-size: 13px; color: var(--muted); padding: 6px 0; }

.u-share { margin-bottom: 14px; }
.u-share svg { display: block; border-radius: 6px; }
.u-rows { display: flex; flex-direction: column; gap: 9px; }
.u-row { display: grid; grid-template-columns: 12px 1fr auto 46px; align-items: center; gap: 10px; font-size: 13px; }
.u-dot { width: 10px; height: 10px; border-radius: 50%; }
.u-dot-ready { background: var(--ok); }
.u-dot-failed { background: var(--danger); }
.u-dot-stopped { background: var(--faint); }
.u-dot-working { background: var(--info); }
.u-row-l { color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.u-row-v { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.u-row-p, .u-row-c { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; font-size: 12.5px; }
.u-side-note { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); }
.u-mode-top { display: grid; grid-template-columns: minmax(0, 1fr) auto 76px; align-items: center; gap: 10px; font-size: 13px; }
.u-mode-bar { height: 6px; border-radius: var(--r-pill); background: var(--bg-tint); margin-top: 6px; overflow: hidden; }
.u-mode-bar span { display: block; height: 100%; border-radius: var(--r-pill); }
.u-mode + .u-mode { margin-top: 4px; }

/* ---------- all runs ---------- */
.u-runs-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 12px; }
.u-runs-h .section-h { margin-bottom: 0; flex-wrap: wrap; }
.u-search { position: relative; width: 320px; max-width: 100%; }
.u-search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.u-search input { padding: 9px 12px 9px 34px; font-size: 13px; }
.u-table { max-height: none; }
.u-runs-table thead th { position: sticky; top: 0; z-index: 1; padding: 0; }
.u-th { display: inline-flex; align-items: center; gap: 4px; width: 100%; padding: 11px 14px; font: inherit; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; color: var(--ink-2); background: none; border: none; cursor: pointer; text-align: left; white-space: nowrap; }
th.num .u-th { justify-content: flex-end; }
.u-th:hover { color: var(--ink); }
.u-sort-ic { width: 13px; height: 13px; color: var(--primary-text); }
.u-runs-table tbody td { padding: 10px 14px; vertical-align: top; }
.u-runs-table tbody tr { cursor: pointer; }
.u-runs-table tbody tr:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--info); border-radius: 0; }
.u-date { display: block; color: var(--ink); font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.u-time { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; }
.u-c-person .u-pname { display: block; }
.u-c-person .u-psub { max-width: 230px; }
.u-client { display: block; color: var(--ink); font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-err { display: block; max-width: 260px; font-size: 12px; color: var(--danger-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-muted { color: var(--faint); }
.u-c-mode { white-space: nowrap; }
.u-c-status { white-space: nowrap; }
.u-checks { display: inline-block; margin-left: 8px; font-size: 11.5px; color: var(--warn-text); font-weight: 600; vertical-align: middle; }
.u-c-dur, .u-c-files { white-space: nowrap; }
.u-c-cost { white-space: nowrap; color: var(--ink); font-weight: 600; }
.u-go { width: 34px; padding-left: 0 !important; color: var(--faint); vertical-align: middle !important; }
.u-go .ic { width: 16px; height: 16px; transition: transform var(--dur-2) var(--ease), color var(--dur-2) var(--ease); }
.u-runs-table tbody tr:hover .u-go .ic { color: var(--primary); transform: translateX(2px); }
.u-go-h { width: 34px; }
/* Wide screens: the runs table header sticks under the top bar while the list scrolls. */
@media (min-width: 1200px) {
  .u-table { overflow: visible; }
  .u-runs-table thead th { top: var(--topbar-h); }
  .u-runs-table thead th:first-child { border-top-left-radius: var(--r-md); }
  .u-runs-table thead th:last-child { border-top-right-radius: var(--r-md); }
  .u-runs-table tbody tr:last-child td:first-child { border-bottom-left-radius: var(--r-md); }
  .u-runs-table tbody tr:last-child td:last-child { border-bottom-right-radius: var(--r-md); }
  /* The card does not clip here (the header must stick to the page), so the table must fit it:
     fixed columns, with Person and Client taking the rest and trimming long names (10/03/2026,
     the header and chevrons spilled past the card's right edge). */
  .u-runs-table { width: 100%; table-layout: fixed; }
  .u-runs-table thead th:nth-child(1) { width: 104px; }
  .u-runs-table thead th:nth-child(2) { width: 224px; }
  .u-runs-table thead th:nth-child(4) { width: 140px; }
  .u-runs-table thead th:nth-child(5) { width: 60px; }
  .u-runs-table thead th:nth-child(6) { width: 172px; }
  .u-runs-table thead th:nth-child(7) { width: 90px; }
  .u-runs-table thead th:nth-child(8) { width: 82px; }
  .u-runs-table thead th:nth-child(9) { width: 34px; }
  .u-runs-table .u-c-person, .u-runs-table .u-c-client { overflow: hidden; }
  .u-runs-table .u-pname { overflow: hidden; text-overflow: ellipsis; }
  .u-runs-table .u-c-person .u-psub, .u-runs-table .u-client, .u-runs-table .u-err { max-width: 100%; }
  .u-runs-table .u-c-status { white-space: normal; }
}
.u-more { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; min-height: 8px; }
.u-more-note { font-size: 12.5px; color: var(--muted); }
.u-runs-empty { border-radius: var(--r-md); border: none; }

/* ---------- drill-in ---------- */
.ur-back { margin: -6px 0 14px -8px; }
.ur-back .ic { width: 16px; height: 16px; }
.ur-head-pills { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ur-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 22px; }
.ur-item { min-width: 0; }
.ur-item .k { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ur-item .v { margin-top: 3px; font-size: 14px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.ur-item .v .s { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.ur-quote { margin: 0; padding: 12px 14px; background: var(--surface-2); border-left: 3px solid var(--prism-band); border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: 13.5px; color: var(--ink); white-space: pre-wrap; }
.ur-files-stack { display: flex; flex-direction: column; gap: 18px; }
.ur-files { table-layout: fixed; }
.ur-files td { vertical-align: middle; }
.ur-fname { display: block; font-family: var(--mono); font-size: 12.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ur-files span.ur-kind { display: block; }
.ur-email { font-size: 13px; font-weight: 500; }
.ur-bad { background: var(--danger-bg); color: var(--danger-text); }
.ur-kind { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ur-avail { font-size: 12px; font-weight: 600; white-space: nowrap; }
.ur-avail.on { color: var(--ok-text); }
.ur-avail.off { color: var(--muted); }
.ur-actions { display: flex; gap: 6px; justify-content: flex-end; }
.ur-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ur-list li { display: flex; gap: 10px; font-size: 13.5px; color: var(--ink); line-height: 1.5; }
.ur-list li .ic { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--warn); }
.ur-list.ok li .ic { color: var(--ok); }
.ur-sub { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; }
.ur-notes .rn-file + .rn-file { margin-top: 10px; }
.ur-notes .rn-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.ur-notes .rn-name span { font-weight: 500; color: var(--muted); }
.ur-notes ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); }
.ur-rev { display: grid; grid-template-columns: 92px 1fr auto; gap: 12px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.ur-rev:last-child { border-bottom: none; }
.ur-rev .n { font-weight: 700; color: var(--ink); }
.ur-rev .t { color: var(--ink-2); }
.ur-rev .w { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ur-log { max-height: 420px; }
.ur-log .t { color: var(--faint); }
.ur-tech { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; font-size: 13px; }
.ur-tech dt { color: var(--muted); font-weight: 600; }
.ur-tech dd { margin: 0; font-family: var(--mono); font-size: 12.5px; color: var(--ink); overflow-wrap: anywhere; }
.ur-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.ur-error { margin-bottom: 18px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .u-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: auto; }
  .u-kpi.lead { grid-row: auto; grid-column: 1 / -1; }
  .u-spark { max-width: 420px; }
  .u-reset { margin-left: 0; }
}
@media (max-width: 900px) {
  .u-trio, .ur-two { grid-template-columns: 1fr; }
  .ur-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .u-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .u-kpi { padding: 12px 14px; }
  .u-kpi .v { font-size: 20px; }
  .u-kpi.lead .v { font-size: 28px; }
  .u-filters { padding: 12px 14px; }
  .u-filter-row { gap: 12px; }
  .u-fgroup { flex: 1 1 140px; }
  .u-fgroup:first-child { flex-basis: 100%; }
  .u-filters .segmented { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); height: auto; border-radius: var(--r-md); }
  .u-filters .segmented .seg { padding: 0 8px; border-radius: var(--r-sm); }
  .u-wide { display: none; }
  .u-wide-sub { display: none !important; }
  .u-narrow-sub { display: block !important; }
  .u-top-table thead th, .u-top-table tbody td { padding-left: 12px; padding-right: 12px; }
  .u-picker-btn { min-width: 0; max-width: none; width: 100%; }
  .u-fgroup select { min-width: 0; width: 100%; }
  .u-reset { flex: 1 1 100%; justify-content: center; }
  .u-chart-tools { justify-content: flex-start; }
  .card-h:has(.u-chart-tools) { flex-wrap: wrap; }
  .u-search { width: 100%; }
  .u-psub { max-width: 180px; }

  /* All runs: each row becomes a compact card. */
  .u-runs-table thead { display: none; }
  .u-runs-table, .u-runs-table tbody { display: block; }
  .u-runs-table tbody tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas:
      "person cost" "client client" "date status" "meta meta";
    gap: 2px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line);
  }
  .u-runs-table tbody tr:last-child { border-bottom: none; }
  .u-runs-table tbody td { padding: 0; border: none; }
  .u-c-person { grid-area: person; min-width: 0; }
  .u-c-cost { grid-area: cost; text-align: right; font-weight: 700; }
  .u-c-client { grid-area: client; min-width: 0; }
  .u-c-date { grid-area: date; display: flex; gap: 6px; align-items: baseline; margin-top: 4px; }
  .u-c-date .u-date, .u-c-date .u-time { display: inline; }
  .u-c-status { grid-area: status; text-align: right; margin-top: 4px; }
  .u-c-status .u-checks { display: none; }
  .u-c-mode, .u-c-files, .u-c-dur { grid-area: meta; display: none; }
  .u-go { display: none; }
  .u-client, .u-err { max-width: 100%; }
  .u-c-person .u-psub { max-width: 100%; }

  .ur-grid { gap: 12px 16px; }
  .ur-span { grid-column: 1 / -1; }
  .ur-files thead, .ur-files colgroup { display: none; }
  .ur-files, .ur-files tbody { display: block; }
  .ur-files tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .ur-files tr:last-child { border-bottom: none; }
  .ur-files td { display: block; padding: 0 !important; border: none !important; }
  .ur-files td:first-child { grid-column: 1 / -1; }
  .u-top-table .u-narrow-sub { white-space: normal; }
  .ur-tech { grid-template-columns: 1fr; gap: 2px; }
  .ur-tech dd { margin-bottom: 8px; }
  .ur-fname { white-space: normal; overflow-wrap: anywhere; }
}
@media (max-width: 420px) {
  .u-kpi .s { font-size: 11.5px; }
}
