/* /features/job-cost/ only: the body of the hero's live instrument (a year of one job's costs
   replaying: budget vs actual by cost code, cash flow, financial overview and cost breakdown;
   js/pages/job-cost.js). The instrument's shell (stage, board header, activity footer) is
   .site-instrument in css/public-site.css. */

.jc-board {
    --jc-cost: var(--site-accent);
    --jc-claimed: #15803D;
    --jc-over: #C2410C;
    --jc-loss: #B91C1C;
    --jc-labour: #15803D;
    --jc-subbie: #C2410C;
    --jc-equipment: #0E7490;
}

/* The status pill turns amber while a cost code is forecast over budget. */
.jc-board .site-instrument__status.is-watch { background: #FDF0E3; color: #9A3C07; }

.jc-board__body {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-rows: 196px 186px;
    gap: 14px;
}

.jc-panel {
    position: relative;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 10px 14px 12px;
    overflow: hidden;
    border: 1px solid var(--site-line);
    border-radius: 10px;
    background: #fff;
}
.jc-panel__head {
    flex: none;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--site-text);
    white-space: nowrap;
}
.jc-panel__side { overflow: hidden; text-overflow: ellipsis; font-family: var(--site-font-mono); font-size: 10.5px; font-weight: 400; letter-spacing: .04em; color: var(--site-subtle); }

/* ---------- Budget vs actual ---------- */
.jc-bars { flex: 1; min-height: 0; display: flex; align-items: flex-end; justify-content: space-around; gap: 6px; padding-top: 20px; }
.jc-bar { flex: 1; max-width: 72px; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; cursor: pointer; }
.jc-bar__track {
    position: relative;
    width: 28px;
    height: var(--jc-track, 100%);
    border: 1px solid var(--site-line);
    border-radius: 6px 6px 3px 3px;
    background: #F4F2F8;
    transition: box-shadow .2s ease;
}
.jc-bar:hover .jc-bar__track, .jc-bar.is-hot .jc-bar__track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--jc-cost) 25%, transparent); }
.jc-bar__fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; border-radius: 0 0 2px 2px; background: var(--jc-cost); }
.jc-bar.is-over .jc-bar__fill { background: var(--jc-over); }
.jc-bar.is-over .jc-bar__track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--jc-over) 25%, transparent); }
.jc-bar__forecast { position: absolute; left: -5px; right: -5px; bottom: 0; border-top: 2px dashed var(--jc-claimed); pointer-events: none; }
.jc-bar.is-over .jc-bar__forecast { border-top-color: var(--jc-loss); }
.jc-bar__value { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 10.5px; font-weight: 600; color: var(--site-text); white-space: nowrap; }
.jc-bar__name { margin-top: 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 11px; color: var(--site-muted); white-space: nowrap; }

/* ---------- Cash flow ---------- */
.jc-panel--cashflow { cursor: ew-resize; }
.jc-cashflow__chart { position: relative; flex: 1; min-height: 0; touch-action: pan-y; }
.jc-cashflow__chart svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.jc-cashflow__playhead { position: absolute; top: 0; bottom: 0; left: 0; border-left: 2px solid var(--site-text-2); opacity: .55; pointer-events: none; }
.jc-cashflow__dot { position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; box-shadow: 0 0 0 2px #fff; pointer-events: none; }
.jc-cashflow__dot--cost { background: var(--jc-cost); }
.jc-cashflow__dot--claimed { background: var(--jc-claimed); }
.jc-cashflow__months { flex: none; display: flex; justify-content: space-between; padding-top: 6px; font-family: var(--site-font-mono); font-size: 9.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--site-subtle); }
.jc-cashflow__months span.is-current { color: var(--site-accent); font-weight: 600; }
.jc-legend { display: flex; gap: 12px; font-size: 11px; font-weight: 400; color: var(--site-muted); }
.jc-legend__item::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; vertical-align: 0; }
.jc-legend__item--cost::before { background: var(--jc-cost); }
.jc-legend__item--claimed::before { background: var(--jc-claimed); }

/* ---------- Financial overview ---------- */
.jc-overview { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.jc-overview__row { display: flex; align-items: center; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid #ECEAF1; font-size: 12.5px; color: var(--site-muted); }
.jc-overview__value { font-weight: 600; color: var(--site-text); }
.jc-overview__row--profit { margin-top: 2px; padding-top: 8px; border-top: 1px solid var(--site-line); border-bottom: 0; font-weight: 600; color: var(--site-text); }
.jc-overview__row--profit .jc-overview__value { font-size: 15px; color: var(--jc-claimed); }
.jc-chip { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: #E7F5EC; color: #146C43; font-family: var(--site-font-mono); font-size: 10.5px; font-weight: 500; }
.jc-chip.is-thin { background: #FDF0E3; color: #9A3C07; }

/* ---------- Cost breakdown ---------- */
.jc-breakdown { flex: 1; min-height: 0; display: flex; align-items: center; gap: 16px; }
.jc-donut { flex: none; width: 124px; height: 124px; }
.jc-donut__track { fill: none; stroke: #F1EFF6; stroke-width: 13; }
.jc-donut__seg { fill: none; stroke-width: 13; transform: rotate(-90deg); transform-origin: 50% 50%; }
.jc-donut__value { font-family: var(--site-font-body); font-size: 14px; font-weight: 600; fill: var(--site-text); }
.jc-donut__label { font-family: var(--site-font-mono); font-size: 6.5px; letter-spacing: .08em; text-transform: uppercase; fill: var(--site-subtle); }
.jc-breakdown__legend { flex: 1; min-width: 0; }
.jc-legend-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; font-size: 12px; color: var(--site-muted); }
.jc-legend-row__name { min-width: 0; display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.jc-legend-row__dot { flex: none; width: 9px; height: 9px; border-radius: 2px; background: currentColor; }
.jc-legend-row__value { font-weight: 600; color: var(--site-text); }

/* ---------- Tablet: two columns still, a little tighter ---------- */
@media (max-width: 1024px) {
    .jc-panel--bars .jc-panel__side, .jc-panel--breakdown .jc-panel__side { display: none; }
    .jc-donut { width: 104px; height: 104px; }
}

/* ---------- Narrow: budget vs actual, then the cash flow (the margin is in the header) ---------- */
@media (max-width: 760px) {
    .jc-board__body { grid-template-columns: minmax(0, 1fr); grid-template-rows: 186px 176px; }
    .jc-panel--overview, .jc-panel--breakdown { display: none; }
    .jc-bars { gap: 2px; }
    .jc-bar__track { width: 22px; }
    .jc-bar__name { font-size: 10px; }
    .jc-bar__value { font-size: 9.5px; }
    .jc-cashflow__months span:nth-child(even) { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
    .jc-bar__track { transition: none; }
}
