/* Usage: the bill at a chosen grain, the month's projection against its budget, then the
   same by worker. Each worker keeps one colour, in the charts, the legends and the table. */

article.usage {
  display: grid;
  gap: 1.75rem;
  max-width: 64rem;
}

article.usage h1,
article.usage h2,
article.usage h3 {
  margin: 0;
}

article.usage section {
  display: grid;
  gap: 0.6rem;
  min-width: 0;
}

article.usage .meta {
  margin: 0;
}

.worker-ingest { --worker: var(--in); }
.worker-work { --worker: var(--good); }
.worker-review { --worker: var(--out); }
.worker-upkeep { --worker: var(--muted); }
.worker-search { --worker: color-mix(in srgb, var(--good) 55%, var(--paper)); }
.worker-embedding { --worker: color-mix(in srgb, var(--in) 45%, var(--paper)); }
.worker-summary { --worker: color-mix(in srgb, var(--out) 40%, var(--paper)); }
.worker-reading { --worker: var(--warn); }

article.usage i[class^="worker-"],
article.usage .legend i.open {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 0.45rem;
  border-radius: 2px;
  background: var(--worker);
}

article.usage .legend i.open {
  background: none;
  border: 1px dashed var(--muted);
}

header.usage-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

nav.grains {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

nav.grains a {
  padding: 0.3rem 0.85rem;
  color: var(--muted);
  font-size: var(--text-sm);
  text-decoration: none;
}

nav.grains a + a {
  border-left: 1px solid var(--line);
}

nav.grains a[aria-current="true"] {
  background: var(--wash);
  color: var(--ink);
  font-weight: 600;
}

section.figures {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.figure {
  display: grid;
  gap: 0.15rem;
  align-content: start;
  padding: 0.8rem 0.9rem;
  background: var(--sheet);
  min-width: 0;
}

.figure .label,
.figure .context {
  color: var(--muted);
  font-size: var(--text-sm);
}

.figure .context b {
  color: var(--ink);
  font-weight: 600;
}

.figure .amount {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.figure .amount small {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0;
}

.figure .over { color: var(--bad); font-weight: 600; }
.figure .under { color: var(--good); font-weight: 600; }

/* The projection against twice the budget, so the budget is the middle mark. */
.budget-bar {
  position: relative;
  height: 6px;
  margin: 0.35rem 0 0.2rem;
  border-radius: 3px;
  background: var(--wash);
}

.budget-bar::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -4px;
  width: 2px;
  height: 14px;
  background: var(--ink);
}

.budget-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 3px;
  background: var(--good);
}

.budget-bar i.over {
  background: var(--bad);
}

article.usage .chart-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.4rem 1rem;
}

article.usage .legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

svg.usage-chart {
  display: block;
  width: 100%;
  height: auto;
}

svg.usage-chart rect {
  fill: var(--worker);
}

svg.usage-chart rect.open {
  fill: none;
  stroke: var(--muted);
  stroke-dasharray: 3 2;
}

svg.usage-chart text {
  fill: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

svg.usage-chart text.total,
svg.usage-chart text.budget {
  fill: var(--ink);
}

svg.usage-chart line.grid {
  stroke: var(--line);
}

svg.usage-chart line.budget {
  stroke: var(--ink);
  stroke-dasharray: 5 4;
  opacity: 0.7;
}

article.usage .table-scroll {
  overflow-x: auto;
}

article.usage table.list {
  width: 100%;
  min-width: 46rem;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

article.usage table.list th,
article.usage table.list td {
  padding: 0.45rem 0.75rem 0.45rem 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

article.usage table.list .num {
  text-align: right;
  white-space: nowrap;
  padding-right: 0;
  padding-left: 0.75rem;
}

article.usage table.list tr.total td {
  font-weight: 600;
  border-bottom: 0;
}

article.usage table.list .unreported {
  color: var(--muted);
  font-size: var(--text-sm);
}

article.usage table.list .context {
  display: block;
  color: var(--muted);
  font-size: var(--text-sm);
}

section.workers {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

section.workers .worker {
  display: grid;
  gap: 0.4rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}

@media (max-width: 760px) {
  section.figures,
  section.workers {
    grid-template-columns: minmax(0, 1fr);
  }
}
