@import "./project-report.css";

.billing-kpis {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 144px), 1fr));
  gap: 14px;
  margin: 0 0 24px;
}

.billing-kpis .project-kpi {
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--surface);
}

.billing-kpis h3 {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 0 0 5px;
  font-size: .78rem;
  line-height: 1.35;
}

.billing-kpis h3::before {
  content: "";
  flex: 0 0 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--billing-kpi-marker, var(--bar));
}

.billing-kpis .billing-kpi-error { --billing-kpi-marker: #d17a11; }
.billing-kpis .billing-kpi-rate { --billing-kpi-marker: #2c62ad; }
.billing-kpis strong { font-size: clamp(1.65rem, 2.2vw, 2rem); }
.billing-kpis p { margin-top: 4px; font-size: .75rem; line-height: 1.4; }

.billing-report .pct { color: var(--muted); font-size: .72rem; }
.billing-report .pct.zero { opacity: .6; }

.billing-chart-grid {
  --billing-chart-track: #e5ebf6;
  --billing-chart-delivered: #2c62ad;
  --billing-chart-answered: #4a79bc;
  --billing-chart-attention: #d17a11;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 14px;
  margin-bottom: 24px;
}

.project-report .billing-chart-grid > .panel {
  margin: 0;
  padding: 18px;
  border-radius: 12px;
}

.billing-delivery-status {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
}

.billing-funnel, .billing-delivery-status-legend {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.billing-funnel-step {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 4px 8px;
  font-size: .82rem;
}

.billing-funnel-label { font-weight: 650; }
.billing-funnel-value { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.billing-funnel-value strong, .billing-delivery-status-legend strong { color: var(--bar); }

.billing-funnel-track {
  grid-column: 1 / -1;
  height: 10px;
  border-radius: 5px;
  background: var(--billing-chart-track);
}

.billing-funnel-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--billing-funnel-color, var(--bar));
}

.billing-funnel-delivered { --billing-funnel-color: var(--billing-chart-delivered); }
.billing-funnel-answered { --billing-funnel-color: var(--billing-chart-answered); }
.billing-funnel-transferred { --billing-funnel-color: var(--billing-chart-attention); }

.billing-delivery-status-bar {
  display: flex;
  height: 22px;
  margin-bottom: 12px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--billing-chart-track);
}

.billing-delivery-status-bar > span {
  flex: var(--delivery-count) 1 0px;
  background: var(--billing-delivery-color);
}

.billing-delivery-answered { --billing-delivery-color: var(--bar); }
.billing-delivery-waiting { --billing-delivery-color: var(--billing-chart-attention); }
.billing-delivery-inactive { --billing-delivery-color: #b6c4da; }

.billing-delivery-status-legend {
  align-content: space-between;
  gap: 8px;
}

.billing-delivery-status-legend li {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto 44px;
  align-items: center;
  gap: 8px;
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
}

.billing-delivery-key {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--billing-delivery-color);
}

.billing-delivery-status-legend strong, .billing-delivery-share { text-align: right; }
.billing-delivery-share { color: var(--muted); }

.project-report .billing-hsm-map { padding: 18px; border-radius: 12px; }
.project-report .billing-hsm-map .table-scroll { max-height: min(56vh, 420px); }
.project-report .billing-hsm-map table { min-width: 1040px; font-size: .8rem; }

.project-report .billing-hsm-map :is(th, td) {
  padding: 8px 10px;
  vertical-align: middle;
}

.project-report .billing-hsm-map thead th {
  z-index: 3;
  background: #e5ebf6;
  white-space: normal;
}

.project-report .billing-hsm-map th:first-child { left: 0; min-width: 124px; }
.project-report .billing-hsm-map thead th:first-child { z-index: 4; }

.project-report .billing-hsm-map tbody th {
  top: auto;
  z-index: 2;
  padding: 0;
  background: var(--surface);
}

.project-report .billing-hsm-map tfoot :is(th, td) {
  position: sticky;
  top: auto;
  bottom: 0;
  z-index: 3;
  border-top: 1px solid var(--border);
  background: #f2f5fa;
}

.project-report .billing-hsm-map tfoot th {
  z-index: 4;
  padding: 0;
}

.project-report .billing-hsm-map .billing-hsm-filter {
  display: block;
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--bar);
  text-align: left;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
}

.billing-hsm-filter small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 500;
}

.project-report .billing-hsm-map .billing-hsm-filter:is(:hover, [aria-pressed="true"]) {
  background: #e8f0ff;
  color: var(--bar);
}

.project-report .billing-hsm-map .billing-hsm-filter[aria-pressed="true"] {
  box-shadow: inset 3px 0 var(--accent);
}

.project-report .billing-hsm-map .billing-hsm-filter:focus-visible { outline-offset: -3px; }

.billing-hsm-rate { color: var(--text); font-weight: 700; }
.billing-hsm-error { background: rgb(209 122 17 / calc(var(--billing-rate-strength) * .72)); }
.billing-hsm-answer { background: rgb(44 98 173 / min(.46, calc(var(--billing-rate-strength) * 1.55))); }

.billing-hsm-filter-status, .billing-hsm-map-note {
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.5;
}

.billing-hsm-filter-status { margin: 0; }
.billing-hsm-filter-status:not(:empty) { margin-bottom: 10px; color: var(--bar); }
.billing-hsm-map-note { margin: 12px 0 0; }

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

@media (max-width: 400px) {
  .billing-funnel-step { grid-template-columns: minmax(0, 1fr); }
  .billing-funnel-value { text-align: left; }
}
