/* Claude usage reports.
   ------------------------------------------------------------
   The estate's design tokens (web/tokens/, the same copies every staff app serves)
   and the review console's layout rules, so this page reads as the same product as
   the launcher and the other consoles. Org colours: entirely = Moss, censhare = Teal,
   two hues far enough apart to tell bars apart at a glance. */

@import url('tokens/colors.css');
@import url('tokens/fonts.css');
@import url('tokens/spacing.css');
@import url('tokens/typography.css');

:root {
  --v-ok: #1b7f3b;
  --v-ok-bg: var(--color-sage);
  --v-bad: #b3261e;
  --v-bad-bg: #fbe9e7;
  --v-warn: #8a4b00;
  --v-warn-bg: #fdefd7;
}

/* [hidden] must outrank any later display rule, or an element the app hides by
   attribute stays on screen. The gate is position:fixed and inset:0, so when
   that happens the page sits on "Signing in…" for ever with the app rendered
   underneath and nothing in the console to say why. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-small);
  line-height: var(--lh-body);
  letter-spacing: var(--tracking-body);
}

/* ------------------------------------------------------------------ header */
.bar {
  background: var(--surface-moss);
  color: var(--text-on-dark);
  position: sticky;
  top: 0;
  z-index: 2;
}
.bar-in {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  min-height: 60px;
}
.brand { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.mark { width: var(--stroke-heavy); height: 34px; background: var(--accent); display: block; flex: none; }
.bar h1 {
  font-family: var(--font-display);
  font-weight: var(--weight-medium);
  font-size: var(--fs-h3);
  letter-spacing: var(--tracking-h3);
  margin: 0;
  min-width: 0;
}
.bar p { margin: 0; font-size: var(--fs-caption); color: rgba(255, 255, 255, 0.72); word-break: break-all; }
.who { display: flex; align-items: center; gap: var(--space-3); font-size: var(--fs-caption); color: rgba(255, 255, 255, 0.85); }
.tier {
  border: var(--stroke-thin) solid var(--border-on-dark);
  border-radius: var(--radius-capsule);
  padding: 2px var(--space-3);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caption);
  color: var(--accent);
}

main { max-width: 1180px; margin: 0 auto; padding: var(--space-5); }

/* ------------------------------------------------------------------ panels */
.panel {
  background: var(--surface-card);
  border: var(--stroke-thin) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.panel h2 {
  font-family: var(--font-display);
  font-weight: var(--weight-medium);
  font-size: var(--fs-h4);
  letter-spacing: var(--tracking-tight);
  margin: 0 0 var(--space-2);
}
p.lede { margin: 0 0 var(--space-4); color: var(--text-secondary); max-width: 78ch; }
.row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }

/* ------------------------------------------------------------------ inputs */
label { font-size: var(--fs-caption); color: var(--text-secondary); }
input[type="date"] {
  font: inherit;
  padding: var(--space-2) var(--space-3);
  border: var(--stroke-thin) solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--text-primary);
}
.check { display: flex; align-items: center; gap: var(--space-2); }
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Capsule CTAs, per the brand's pill UI. */
button.btn {
  font: inherit;
  font-weight: var(--weight-medium);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-capsule);
  border: var(--stroke-thin) solid var(--border-subtle);
  background: var(--surface-card);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
}
button.btn:hover:not(:disabled) { background: var(--color-sand); }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); }
button.btn.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
button.btn:disabled { opacity: 0.45; cursor: default; }
button.btn.small { padding: var(--space-1) var(--space-3); font-size: var(--fs-caption); }
.who button.btn { background: transparent; border-color: var(--border-on-dark); color: var(--text-on-dark); }
.who button.btn:hover { background: rgba(255, 255, 255, 0.1); }
button.linkish { background: none; border: none; color: var(--color-teal); cursor: pointer; padding: 0; font: inherit; font-size: var(--fs-caption); text-decoration: underline; }

.status { font-size: var(--fs-caption); color: var(--text-secondary); }

/* ------------------------------------------------------------------ tables */
.table-scroll { overflow-x: auto; border-radius: inherit; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: var(--space-3); border-bottom: var(--stroke-thin) solid var(--border-subtle); vertical-align: top; }
th {
  font-size: var(--fs-caption);
  color: var(--text-secondary);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caption);
  text-transform: uppercase;
  white-space: nowrap;
}
thead th { position: sticky; top: 0; background: var(--surface-card); z-index: 1; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.selected td, tr.clickable:hover td { background: var(--color-sand); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-caption); white-space: nowrap; }

/* ------------------------------------------------------------------- chips */
.chip {
  display: inline-block;
  font-size: var(--fs-caption);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caption);
  text-transform: uppercase;
  padding: 2px var(--space-2);
  border-radius: var(--radius-capsule);
  background: var(--color-heather);
  color: var(--text-secondary);
}
.chip.good { background: var(--v-ok-bg); color: var(--v-ok); }
.chip.warn { background: var(--v-warn-bg); color: var(--v-warn); }
.chip.bad { background: var(--v-bad-bg); color: var(--v-bad); }

.verdict {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin: 0 0 var(--space-4);
  font-weight: var(--weight-medium);
}
.verdict.ok { background: var(--v-ok-bg); color: var(--v-ok); }
.verdict.bad { background: var(--v-bad-bg); color: var(--v-bad); }
.verdict.pending { background: var(--color-heather); color: var(--text-secondary); }

details { margin-top: var(--space-4); }
summary { cursor: pointer; font-size: var(--fs-caption); color: var(--text-secondary); }
pre {
  background: var(--color-sand);
  border: var(--stroke-thin) solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--fs-caption);
  line-height: 1.5;
  max-height: 420px;
}
.empty { padding: var(--space-5); color: var(--text-muted); }

.detail-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
.detail-actions { display: flex; gap: var(--space-2); }

/* -------------------------------------------------------------------- gate */
.gate { position: fixed; inset: 0; background: var(--surface-page); display: grid; place-items: center; z-index: 10; padding: var(--space-5); }
.gate-card {
  background: var(--surface-card);
  border: var(--stroke-thin) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-7);
  max-width: 480px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.gate-card h2 { font-family: var(--font-display); font-weight: var(--weight-medium); margin: 0 0 var(--space-2); font-size: var(--fs-h4); }
.gate-card p { color: var(--text-secondary); margin: 0 0 var(--space-4); white-space: pre-wrap; text-align: left; }

@media (max-width: 640px) {
  main { padding: var(--space-4) var(--space-3); }
  .panel { padding: var(--space-4); }
}

/* ----------------------------------------------------------------- reports */
:root { --org-entirely: var(--color-moss); --org-censhare: var(--color-teal); }

.controls { display: flex; gap: var(--space-4); align-items: center; flex-wrap: wrap; margin-bottom: var(--space-5); }
.seg { display: inline-flex; border: var(--stroke-thin) solid var(--border-subtle); border-radius: var(--radius-capsule); overflow: hidden; background: var(--surface-card); }
.seg button { font: inherit; font-size: var(--fs-caption); border: 0; background: none; padding: var(--space-2) var(--space-3); cursor: pointer; color: var(--text-secondary); }
.seg button[aria-pressed="true"] { background: var(--surface-moss); color: var(--text-on-dark); }
.controls .status { margin-left: auto; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-5); }
.kpi { background: var(--surface-card); border: var(--stroke-thin) solid var(--border-subtle); border-radius: var(--radius-md); padding: var(--space-4); }
.kpi .label { font-size: var(--fs-caption); color: var(--text-secondary); text-transform: uppercase; letter-spacing: var(--tracking-caption); font-weight: var(--weight-semibold); }
.kpi .value { font-family: var(--font-display); font-size: var(--fs-h3); font-variant-numeric: tabular-nums; margin-top: var(--space-1); }
.kpi .split { font-size: var(--fs-caption); color: var(--text-muted); margin-top: var(--space-1); font-variant-numeric: tabular-nums; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: var(--space-5); }
.grid2 .panel { margin-bottom: 0; }
.grid2 + .panel, .panel + .grid2 { margin-top: var(--space-5); }

.legend { display: flex; gap: var(--space-4); font-size: var(--fs-caption); color: var(--text-secondary); margin: 0 0 var(--space-3); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: var(--space-1); vertical-align: middle; }
.chart { width: 100%; height: 220px; display: block; }
.chart text { font-size: 11px; fill: var(--text-muted); font-family: var(--font-body); }
.chart .axis { stroke: var(--border-subtle); stroke-width: 1; }

.bar-cell { display: flex; align-items: center; gap: var(--space-2); justify-content: flex-end; }
.bar-cell .bar-track { width: 80px; height: 6px; background: var(--color-sand); border-radius: 3px; overflow: hidden; }
.bar-cell .bar-fill { height: 100%; background: var(--accent-deep); }
.org-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: var(--space-2); vertical-align: middle; }
td.wrap { white-space: normal; word-break: break-all; }
.note { font-size: var(--fs-caption); color: var(--text-muted); margin: var(--space-3) 0 0; }

@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.nowrap { white-space: nowrap; }

.filters { display: flex; gap: var(--space-4); align-items: center; flex-wrap: wrap; margin-bottom: var(--space-4); }
.filters label { display: flex; align-items: center; gap: var(--space-2); }
.filters select {
  font: inherit; font-size: var(--fs-small); color: var(--text-primary); background: var(--surface-card);
  border: var(--stroke-thin) solid var(--border-subtle); border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2); max-width: 340px;
}
#people tbody tr { cursor: pointer; }
#people tbody tr:hover td { background: var(--color-sand); }
td.repo { white-space: normal; min-width: 260px; overflow-wrap: anywhere; word-break: normal; }

.costnote { font-size: var(--fs-caption); color: var(--text-secondary); background: var(--surface-card); border: var(--stroke-thin) solid var(--border-subtle); border-left: var(--stroke-heavy) solid var(--accent-deep); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-5); max-width: 100ch; }
.h-note { font-family: var(--font-body); font-size: var(--fs-caption); font-weight: var(--weight-regular); color: var(--text-muted); margin-left: var(--space-2); }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text-primary); }
.filters.groupby { margin-top: calc(-1 * var(--space-2)); }
#explore + .note, .panel .note { margin: 0 0 var(--space-3); }
