/*
  Billing Runs pages. Palette variables and --tip-* tokens only
  (LiteralColorRuleTests); status by shape plus a word or a text list, never color alone.
*/

/* Running chip: the sync icon turns; it holds still for reduced motion. */
.billing-spin {
    animation: billing-turn 1.2s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
    .billing-spin {
        animation: none;
    }
}

@keyframes billing-turn {
    to {
        transform: rotate(360deg);
    }
}

/* Summary list (run detail, held review): a two-column definition grid. */
.billing-dl {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px 24px;
    margin: 0;
}

.billing-dl > div {
    min-width: 0;
}

.billing-dl dt {
    font-size: 12px;
    color: var(--mud-palette-text-secondary);
    margin-bottom: 2px;
}

.billing-dl dd {
    margin: 0;
    color: var(--mud-palette-text-primary);
    overflow-wrap: anywhere;
}

/* Status words set inline (deviation rows, short coverage, failed counts). */
.billing-warn-text {
    color: var(--tip-status-warn-fg);
}

.billing-err-text {
    color: var(--tip-status-fail-fg);
}

.billing-dev-up {
    color: var(--tip-status-info-fg);
    display: inline-flex;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
}

.billing-dev-down {
    color: var(--tip-status-warn-fg);
    display: inline-flex;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
}

/* Day strip: six shapes, so a state never rests on color. The strip is aria-hidden;
   the gap list under it is the accessible version. */
.billing-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin: 4px 0 8px;
}

.billing-day {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 24px;
    padding: 0 3px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--mud-palette-text-primary);
    border: 1px solid transparent;
    box-sizing: border-box;
    text-decoration: none;
}

.billing-day-collected {
    background: color-mix(in srgb, var(--mud-palette-success) 18%, transparent);
}

.billing-day-held {
    background: var(--mud-palette-warning);
    color: var(--tip-on-primary);
    box-shadow: inset 0 0 0 2px var(--mud-palette-surface);
    border-color: var(--mud-palette-warning);
    cursor: pointer;
}

.billing-day-excluded {
    background: var(--tip-neutral-tile);
    text-decoration: line-through;
}

.billing-day-missing {
    border: 1px dashed var(--mud-palette-lines-inputs);
}

.billing-day-failed {
    background: var(--mud-palette-error);
    color: var(--tip-on-primary);
}

.billing-day-aged {
    background: repeating-linear-gradient(45deg, var(--tip-neutral-tile) 0 3px, transparent 3px 6px);
    border-color: var(--mud-palette-lines-inputs);
}

.billing-day-progress {
    border: 1px solid var(--mud-palette-info);
}

.billing-day-wide {
    min-width: 72px;
}

.billing-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 12px;
    color: var(--mud-palette-text-secondary);
}

.billing-legend > li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.billing-legend .billing-day {
    min-width: 16px;
    height: 14px;
    font-size: 9px;
}

/* Source table group headings and expanded rows. */
.billing-group-row td {
    background: var(--mud-palette-background-gray);
    font-weight: 600;
}

.billing-sub-row td {
    background: var(--tip-row-stripe);
}

/* Deviation notes. */
.billing-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    border-left: 3px solid var(--mud-palette-lines-inputs);
    background: var(--tip-neutral-tile);
    border-radius: 4px;
    min-width: 220px;
}

/* Check settings origins: the value on top, where it came from underneath. */
.billing-origin {
    display: block;
    font-size: 11px;
    color: var(--mud-palette-text-secondary);
}

.billing-origin-source {
    color: var(--mud-palette-text-primary);
    font-weight: 600;
}

.billing-origin-bad {
    color: var(--tip-status-warn-fg);
}

/* Backfill grid cells: text in every cell plus a shape. */
.billing-bf {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    font-style: normal;
    white-space: nowrap;
    border: 1px solid transparent;
    color: var(--mud-palette-text-primary);
}

.billing-bf-collected {
    background: color-mix(in srgb, var(--mud-palette-success) 18%, transparent);
}

.billing-bf-backfilled {
    background: color-mix(in srgb, var(--mud-palette-info) 16%, transparent);
}

.billing-bf-legacy {
    background: color-mix(in srgb, var(--mud-palette-info) 16%, transparent);
    border-style: dashed;
    border-color: var(--mud-palette-lines-inputs);
}

.billing-bf-nofile {
    border: 1px dashed var(--mud-palette-lines-inputs);
    color: var(--tip-status-warn-fg);
}

.billing-bf-rejected {
    background: var(--mud-palette-error);
    color: var(--tip-on-primary);
}

.billing-bf-none {
    color: var(--mud-palette-text-secondary);
}

/* Tables that scroll sideways inside their card keep the first column in place. */
.billing-scroll {
    overflow-x: auto;
}

.billing-sticky-first th:first-child,
.billing-sticky-first td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--mud-palette-surface);
}

/* Volume Trends chart. */
.billing-chart {
    width: 100%;
    height: auto;
    display: block;
}

/* Empty blocks. */
.billing-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 32px 16px;
    text-align: center;
    color: var(--mud-palette-text-secondary);
}

.billing-empty strong {
    color: var(--mud-palette-text-primary);
}

/* The review dialog's "Recorded as" row. */
.billing-who {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--mud-palette-text-secondary);
}

/* "N days need review" (header menu and the run list column): neutral label, warning icon. */
.billing-nr-menu .mud-button-icon-start,
.billing-nr .mud-button-icon-start {
    color: var(--tip-status-warn-fg);
}

/* Volume Trends note markers: buttons over the SVG, so they take a tooltip and keyboard focus. */
.billing-note-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background: var(--mud-palette-warning);
    color: var(--tip-on-primary);
}
