/* Job cost and profit: the panel on the job and quote pages, the Job activity page, the gross profit report and
   the job costing page. See docs/job-cost-and-profit.md. */

.job-cost-header,
.job-activity-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.job-cost-figures {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.job-cost-figure {
    display: flex;
    flex-direction: column;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--mud-palette-background-gray);
    min-width: 0;
}

.job-cost-label {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
}

.job-cost-value {
    font-size: 1.05rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.job-cost-lines {
    width: 100%;
    margin-top: 12px;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.job-cost-lines th {
    text-align: left;
    font-weight: 500;
    color: var(--mud-palette-text-secondary);
    border-bottom: 1px solid var(--mud-palette-lines-default);
    padding: 4px 4px;
}

.job-cost-lines td {
    padding: 6px 4px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    vertical-align: top;
}

.job-cost-lines .num {
    text-align: right;
    white-space: nowrap;
}

.job-cost-lines .actions {
    width: 36px;
    text-align: right;
}

.job-cost-source,
.job-cost-replaced {
    display: block;
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
}

.job-cost-replaced {
    text-decoration: line-through;
}

.job-cost-extras,
.job-cost-actuals {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    font-size: 0.875rem;
}

.job-cost-extra,
.job-cost-actual {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 4px 0;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.job-cost-extra-name {
    flex: 1 1 140px;
}

.job-cost-extra-amount {
    font-weight: 600;
    white-space: nowrap;
}

/* Narrow panel (the job page's right column, a phone): the line table drops its unit cost and line profit. */
@media (max-width: 599px) {
    .job-cost-lines th:nth-child(3), .job-cost-lines td:nth-child(3),
    .job-cost-lines th:nth-child(5), .job-cost-lines td:nth-child(5) {
        display: none;
    }
}

.job-activity-tools,
.gross-profit-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.job-activity-day {
    max-width: 210px;
}

.job-activity-branch {
    min-width: 180px;
    max-width: 260px;
}

.job-activity-totals {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.job-costing-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.job-costing-name {
    flex: 1 1 160px;
}

.job-costing-company,
.job-costing-fitter {
    max-width: 200px;
}
