/* Project overview page (/Projects/{id}) — header, two-column detail grid, fee table, timeline. */

/* ── Header ─────────────────────────────────────────────────────────────────── */
.project-detail__head { align-items: flex-start; }
.project-detail__back {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-1);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    text-decoration: none;
    margin-bottom: var(--spacing-2);
}
.project-detail__back:hover { color: var(--color-text); }
/* The project name with its status badge beside it. */
.project-detail__title-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    flex-wrap: wrap;
}
.project-detail__title-row .page-title { margin: 0; }
.project-detail__meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    margin-top: var(--spacing-2);
    flex-wrap: wrap;
}
.project-detail__ref {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-bold, 700);
    letter-spacing: 0.04em;
    color: var(--color-text-primary);
    padding: var(--spacing-1) var(--spacing-3);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
}
.project-detail__value { text-align: right; flex-shrink: 0; }
.project-detail__value-label {
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-secondary);
}
.project-detail__value-amount {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    line-height: 1.1;
    margin-top: var(--spacing-05);
}

/* ── Two-column layout ──────────────────────────────────────────────────────── */
.project-detail__grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
    gap: var(--spacing-6);
    align-items: start;
    margin-top: var(--spacing-2);
}
.project-detail__main, .project-detail__side {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-6);
}
@media (max-width: 1024px) {
    .project-detail__grid { grid-template-columns: 1fr; }
    .project-detail__value { text-align: left; }
}

/* ── Project Details list ───────────────────────────────────────────────────── */
.detail-list { margin: var(--spacing-4) 0 0; }
.detail-list__row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: var(--spacing-4);
    padding: var(--spacing-3) 0;
    border-bottom: 1px solid var(--color-border);
}
.detail-list__row:last-child { border-bottom: 0; }
.detail-list dt { font-size: var(--font-size-sm); color: var(--color-text-secondary); }
.detail-list dd { margin: 0; font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); color: var(--color-text); }

/* A detail row that can be edited in place (the project address): value, a muted note, a pencil. */
.detail-edit__view { display: flex; align-items: flex-start; gap: var(--spacing-2); }
.detail-edit__view[hidden] { display: none; }
.detail-edit__value { white-space: pre-line; }
.detail-edit__note {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-regular);
    color: var(--color-text-muted);
    align-self: center;
}
.detail-edit__pencil {
    margin-left: auto; /* far right of the row, clear of the value */
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    padding: var(--spacing-05) var(--spacing-1);
    border-radius: var(--radius-sm);
    cursor: pointer;
    line-height: 0;
}
.detail-edit__pencil:hover { color: var(--color-primary); background: var(--color-surface-alt); }
.detail-edit__form { display: flex; flex-direction: column; gap: var(--spacing-2); }
.detail-edit__form[hidden] { display: none; }
.detail-edit__actions { display: flex; gap: var(--spacing-2); flex-wrap: wrap; }
.project-detail__desc {
    margin-top: var(--spacing-4);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    line-height: 1.6;
}

/* ── Financial breakdown (fee milestones) ───────────────────────────────────── */
.fee-table { margin-top: var(--spacing-3); }
.fee-table__label { display: block; font-weight: var(--font-weight-medium); color: var(--color-text); }
.fee-table__hint { display: block; font-size: var(--font-size-xs); color: var(--color-text-secondary); margin-top: 1px; }
.num .fee-table__hint { display: inline; margin-left: var(--spacing-1); }
.fee-table tfoot td { border-top: 2px solid var(--color-border); padding-top: var(--spacing-3); }
/* A row that drills into a modal (e.g. Staff expenses → claim lines). Row hover shading comes from the
   shared .data-table rule; this adds the pointer + keyboard focus ring. */
.fee-table__row--drill { cursor: pointer; }
.fee-table__row--drill:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.fee-table__val--over { color: var(--color-success); font-weight: var(--font-weight-semibold); }
.fee-table__val--under { color: var(--color-danger); font-weight: var(--font-weight-semibold); }
.fee-table__val--strong { font-weight: var(--font-weight-bold); color: var(--color-text); }

/* ── Milestone timeline ─────────────────────────────────────────────────────── */
.timeline { list-style: none; margin: var(--spacing-4) 0 0; padding: 0; position: relative; }
.timeline::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--color-border);
}
.timeline__item {
    position: relative;
    display: flex;
    gap: var(--spacing-4);
    padding: 0 0 var(--spacing-4) var(--spacing-5);
}
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot {
    position: absolute;
    left: 0;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    box-shadow: 0 0 0 3px var(--color-surface);
}
.timeline__dot--past { background: var(--color-primary); border-color: var(--color-primary); }
.timeline__dot--today { background: var(--color-success); border-color: var(--color-success); }
.timeline__dot--upcoming { background: var(--color-surface); border-color: var(--color-border-strong); }
.timeline__label { font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); color: var(--color-text); }
.timeline__date { font-size: var(--font-size-xs); color: var(--color-text-secondary); margin-top: 1px; }

/* ── Documents folder browser (SharePoint via Graph) ────────────────────────── */
/* Card header: title on the left, action buttons (provision / refresh) on the right */
.doc-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-2);
}
.doc-card__actions { display: flex; align-items: center; gap: var(--spacing-2); }
.doc-browser__refresh {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-1);
    flex-shrink: 0;
    padding: var(--spacing-1) var(--spacing-2);
    color: var(--color-text-secondary);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
}
.doc-browser__refresh:hover { color: var(--color-text); border-color: var(--color-border-strong); }
.doc-browser__refresh:disabled { opacity: 0.6; cursor: default; }

.doc-browser { margin-top: var(--spacing-4); }

/* Toolbar: up button · breadcrumbs · open-in-SharePoint */
.doc-browser__bar {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    padding-bottom: var(--spacing-3);
    margin-bottom: var(--spacing-2);
    border-bottom: 1px solid var(--color-border);
}
.doc-browser__up {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    color: var(--color-text-secondary);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.doc-browser__up:hover { color: var(--color-text); border-color: var(--color-border-strong); }
.doc-browser__crumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-05);
    flex: 1;
    min-width: 0;
    font-size: var(--font-size-xs);
}
.doc-crumb {
    padding: 1px 4px;
    color: var(--color-text-secondary);
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font: inherit;
}
.doc-crumb:hover { color: var(--color-primary); text-decoration: underline; }
.doc-crumb--current { color: var(--color-text); font-weight: var(--font-weight-semibold); cursor: default; }
.doc-crumb--current:hover { text-decoration: none; }
.doc-crumb__sep { color: var(--color-border-strong); }
.doc-browser__open {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}
.doc-browser__open:hover { color: var(--color-primary); border-color: var(--color-primary); }

/* Rows */
.doc-browser__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.doc-row { margin: 0; display: flex; align-items: center; }
.doc-row__btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    flex: 1;
    min-width: 0;
    padding: var(--spacing-2) var(--spacing-2);
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
    text-align: left;
    text-decoration: none;
    color: var(--color-text);
    font: inherit;
    cursor: pointer;
}
.doc-row__btn:hover { background: var(--color-surface-alt); }

/* Per-file "use as fee letter" action, sitting to the right of the row. */
.doc-row__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    margin-left: var(--spacing-1);
    color: var(--color-text-muted);
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.doc-row__action:hover { color: var(--color-primary); background: var(--color-surface-alt); }

/* "Fee letter on file" summary above the browser. */
.fee-on-file {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-3);
    margin-bottom: var(--spacing-3);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}
.fee-on-file__icon { display: inline-flex; flex-shrink: 0; color: var(--color-primary); }
.fee-on-file__meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.fee-on-file__label {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-label);
    color: var(--color-text-muted);
}
.fee-on-file__name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fee-on-file__actions { display: flex; align-items: center; gap: var(--spacing-1); flex-shrink: 0; }
.fee-on-file__unlink { margin: 0; }
.doc-row__icon { display: inline-flex; flex-shrink: 0; }
.doc-row__icon--folder { color: var(--color-primary); }
.doc-row__icon--file { color: var(--color-text-secondary); }
.doc-row__name {
    flex: 1;
    min-width: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.doc-row__meta { font-size: var(--font-size-xs); color: var(--color-text-secondary); flex-shrink: 0; }
.doc-row__chevron { display: inline-flex; flex-shrink: 0; color: var(--color-text-secondary); }

/* States: loading / empty / disabled / not-provisioned / error */
.doc-browser__state {
    padding: var(--spacing-6) var(--spacing-4);
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-md);
}
.doc-browser__state--ok, .doc-browser__state--loading { border-style: solid; border-color: var(--color-border); }
.doc-browser__state--error { color: var(--color-danger); border-color: var(--color-danger); }

/* ── Action bar ─────────────────────────────────────────────────────────────── */
.project-detail__actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--spacing-3);
    margin-top: var(--spacing-6);
}

/* ── Status switch bar ──────────────────────────────────────────────────────── */
.project-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-4);
    margin-top: var(--spacing-4);
    flex-wrap: wrap;
    /* A one-line action bar, so slimmer than a content card's padding. */
    padding-block: var(--spacing-3);
}
/* The status bar sits outside the grid, so match the grid's own card gap below it. */
.project-status-bar + .project-detail__grid {
    margin-top: var(--spacing-6);
}
.project-status-bar__label {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-2);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}
.project-status-bar__label .text-secondary { font-weight: var(--font-weight-regular); }
.project-status-bar__form { display: flex; align-items: center; gap: var(--spacing-3); flex-wrap: wrap; }
/* Sized, not full-width (.select's default), so "Change to…", the go-live Delivery Team picker and the button
   sit on one line; the row only wraps when the screen is too narrow for them. */
/* A fixed width, not a flex-basis: the form sizes itself from its children's widths, and a basis wider than
   the select's content made the button wrap underneath. */
.project-status-bar__form .select { width: 15rem; max-width: 100%; flex: none; }
.project-status-bar__form .btn { flex: none; }
/* The go-live Delivery Team picker is toggled with hidden=""; .select's display would otherwise beat it. */
.project-status-bar__form .select[hidden] { display: none; }
/* Full-width line under the bar explaining what going Live does to the job's folder (ADR-030). */
.project-status-bar__note {
    flex-basis: 100%;
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    text-align: right;
}
.project-status-bar__note[hidden] { display: none; }

/* ── Clickable register / dashboard rows ────────────────────────────────────── */
.row-link { cursor: pointer; transition: background 0.12s ease; }
.row-link:hover { background: var(--color-surface-alt); }
.cell-primary__link { color: inherit; text-decoration: none; }
.cell-primary__link:hover { color: var(--color-primary); text-decoration: underline; }

/* ── Time logged against this job (imported timesheets) ─────────────────────── */
.timelog-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--spacing-3);
}
@media (max-width: 720px) {
    .timelog-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.timelog-stat {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-05);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-3);
}
.timelog-stat__label {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.timelog-stat__value {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
}
.timelog-stat__hint {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
}

/* Breakdown tables under the time card — scoped polish. Does NOT affect .data-table or .section-title
   anywhere else. Goals: sub-headings sit clearly below the card title, and the figures group compactly
   under their headers instead of spreading across the full card width. */
/* A little breathing room below the final table so the card matches the spacing of the cards above it. */
.timelog { padding-bottom: var(--spacing-4); }
.timelog .section-title {
    font-size: var(--font-size-md);
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-2);
}
.timelog .data-table thead th,
.timelog .data-table tbody td,
.timelog .data-table tfoot td {
    padding-top: var(--spacing-3);
    padding-bottom: var(--spacing-3);
}
/* Flush the outer columns to the card edges so the table lines up with the stat tiles above. */
.timelog .data-table th:first-child,
.timelog .data-table td:first-child { padding-left: 0; }
.timelog .data-table th:last-child,
.timelog .data-table td:last-child { padding-right: 0; }
/* Fixed-width numeric columns, centre-aligned so each value sits directly under its header (these are
   small whole-number summaries, not a long ledger, so centring reads cleaner than right-alignment). */
.timelog .data-table th.num,
.timelog .data-table td.num { width: 7rem; text-align: center; }
/* Clean separator above the Total row instead of a heavy footer block. */
.timelog .data-table tfoot td {
    border-top: 1px solid var(--color-border);
    background: transparent;
}

/* Lessons learnt on a job (ADR-063): append-only, newest first. */
.lesson-list { list-style: none; margin: var(--spacing-3) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--spacing-3); }
.lesson-list__item {
    display: flex; flex-direction: column; gap: var(--spacing-1);
    padding: var(--spacing-3); border: 1px solid var(--color-border); border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
}

.fee-row__prefix--static { position: static; }
