/* ─────────────────────────────────────────────────────────────────────────────
   PROJECTS
   Client detail card and the project portal grid.

   Part 8 of 11, cut from the 5,142-line app.css. THE ORDER OF THESE
   FILES IS LOAD-BEARING — they are one cascade, split for navigation only, and
   index.php links them in this sequence. Moving one changes which rule wins.
   ───────────────────────────────────────────────────────────────────────────── */
/* ====================================================================
   CLIENT DETAIL — quick-look card modal (opened from any list).
   ==================================================================== */
.cd-modal { width: 460px; max-width: calc(100vw - 32px); padding: 0; overflow: hidden; display: flex; flex-direction: column; max-height: 88vh; }
.cd-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: var(--space-6) var(--space-6) var(--space-4); }
.cd-head-titles { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cd-kicker { font-size: 10px; letter-spacing: var(--tracking-caps); text-transform: uppercase; font-weight: var(--fw-semibold); color: var(--text-muted); }
.cd-name { margin: 0; font-size: 20px; font-weight: var(--fw-bold); color: var(--text-main); letter-spacing: var(--tracking-display); line-height: 1.15; }
.cd-body { padding: 0 var(--space-6); overflow-y: auto; }
.cd-contact { display: flex; flex-direction: column; gap: 8px; padding: var(--space-4); margin-bottom: var(--space-5); background: var(--active-theme-bg); border-radius: var(--radius-board); }
.cd-contact-row { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-main); min-width: 0; }
.cd-contact-row .material-icons { font-size: 15px; color: var(--text-muted); flex-shrink: 0; }
.cd-contact-row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-figs { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--divider); border: 1px solid var(--divider); border-radius: var(--radius-board); overflow: hidden; margin-bottom: var(--space-5); }
.cd-fig { display: flex; flex-direction: column; gap: 5px; padding: 14px 16px; background: var(--bg-card); }
.cd-fig-cap { font-size: 9.5px; letter-spacing: var(--tracking-caps); text-transform: uppercase; font-weight: var(--fw-medium); color: var(--text-muted); }
.cd-fig-val { font-size: 17px; font-weight: var(--fw-bold); color: var(--text-main); font-variant-numeric: tabular-nums; line-height: 1; }
.cd-section-head { display: flex; align-items: center; gap: 8px; font-size: 11px; letter-spacing: var(--tracking-caps); text-transform: uppercase; font-weight: var(--fw-semibold); color: var(--text-muted); margin-bottom: 10px; }
.cd-section-n { font-size: 11px; font-weight: var(--fw-bold); color: var(--text-main); font-variant-numeric: tabular-nums; }
.cd-projects { display: flex; flex-direction: column; gap: 6px; padding-bottom: var(--space-4); }
.cd-proj { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 14px; border: 1px solid var(--divider); border-radius: var(--radius-md); background: var(--bg-card); cursor: pointer; text-align: left; transition: border-color 0.15s ease, background 0.15s ease; }
.cd-proj:hover { border-color: var(--divider-strong); background: var(--bg-hover); }
.cd-proj-name { flex: 1; min-width: 0; font-size: 13px; font-weight: var(--fw-medium); color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-proj-amt { font-size: 12.5px; font-weight: var(--fw-semibold); color: var(--text-main); font-variant-numeric: tabular-nums; }
.cd-proj .material-icons { font-size: 18px; color: var(--text-muted); flex-shrink: 0; }
.cd-empty { padding: 18px; text-align: center; color: var(--text-muted); font-size: 12.5px; }
.cd-foot { display: flex; justify-content: flex-end; gap: 10px; padding: var(--space-5) var(--space-6); margin-top: var(--space-2); }
.cd-foot .btn { border-radius: var(--radius-sm); padding: 9px 18px; }

/* PROJECTS sub-views — the headline switch reuses the shared .seg-tabs (see Transactions/People). */
.pj-subview.hidden { display: none; }

/* Projects controls — lifecycle stage tabs (left) + minimal sort icons & the
   grid/list toggle (right). */
/* Projects first row — 3-col grid mirroring the Overview: Performance/KPI board
   spans the first 2 columns, the adaptive Quick-Add / AI module is the 3rd. */
.projects-top-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-6); align-items: stretch; margin-bottom: var(--space-8); }
/* AI / Quick-Add feature cards stand tall globally (Overview #qa-card + the .sq-card
   document/smart toggle cards on Projects & Project-details). */
.sq-card, #qa-card { min-height: 560px; }
/* ADAPTIVE Quick-Add / AI module (col 3 of the Projects top grid). SINGLE = one card fills the
   column + its Document⇄Smart toggle shows; SPLIT (column tall, e.g. KPI board expanded) = both
   cards stacked independently, toggles hidden. window.updateQaMode (ResizeObserver) sets data-mode. */
.qa-stack { display: flex; flex-direction: column; gap: var(--space-6); min-width: 0; min-height: 0; }
.qa-stack-card { min-width: 0; }
.qa-stack[data-mode="single"] .qa-stack-card { flex: 1 1 auto; display: none; }
.qa-stack[data-mode="single"][data-view="document"] #qa-card-doc,
.qa-stack[data-mode="single"][data-view="smart"] #qa-card-smart { display: flex; }
.qa-stack[data-mode="split"] .qa-stack-card { display: flex; flex: 1 1 0; min-height: 240px; }
.qa-stack[data-mode="split"] .qa-view-mode { display: none; }
/* The Performance board fills its Projects slot so it's EQUAL-HEIGHT with the tall card
   beside it (no short floating board). Compact content sits vertically centred = balanced
   whitespace top/bottom (Swiss); expanded content flows naturally and grows the card. */
#perf-slot-projects { display: flex; }
#perf-slot-projects > .board { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
#perf-slot-projects .perf-body { flex: 1 1 auto; min-height: 0; }
#perf-slot-projects #performance-board.perf-compact .perf-body { display: flex; flex-direction: column; justify-content: center; }

.pj-controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: var(--space-6); }
.pj-stages { display: flex; gap: 4px; flex-wrap: wrap; }
.pj-stage { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; background: transparent; color: var(--text-muted); font-size: 12.5px; }
.pj-stage:hover { background: var(--active-theme-bg); color: var(--text-main); }
.pj-stage-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.pj-stage-n { font-size: 11px; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; opacity: 0.65; }
.pj-stage-n:empty { display: none; }
.pj-tools { display: flex; align-items: center; gap: 10px; }
.pj-sort { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-pill); background: transparent; }
.pj-sort-btn { width: 32px; height: 32px; color: var(--text-muted); transition: background 0.16s ease, color 0.16s ease; }
.pj-sort-btn .material-icons { font-size: 18px; }
.pj-sort-btn:hover { color: var(--text-main); }
.pj-sort-btn.active { background: var(--bg-card); color: var(--text-main); box-shadow: 0 1px 3px rgba(0,0,0,0.10); }
.pj-view-toggle { padding: 7px !important; border-radius: 50% !important; }

/* One board wraps the controls + the grid / list. */
.pj-board { padding: var(--space-6); }
.pj-board .pj-controls { margin-bottom: var(--space-6); }

/* SLIDING PILL on the filter + sort — both become inset segmented controls so the
   shared .pill-glider reads on top (the active item drops its own fill via .has-glider). */
.pill-pad { position: relative; }
.pj-stages { gap: 3px; flex-wrap: nowrap; padding: 4px; border-radius: var(--radius-pill); background: transparent; }
.pj-stage { position: relative; z-index: 1; }
.pj-stages.has-glider .pj-stage.active { background: transparent; color: var(--text-main); box-shadow: none; }
.pj-sort-btn { position: relative; z-index: 1; }
.pj-sort.has-glider .pj-sort-btn.active { background: transparent; color: var(--text-main); box-shadow: none; }

/* ====================================================================
   PROJECT PORTAL CARDS — a scannable status grid; each card is a PORTAL
   into the project detail page. Status pill · Net Profit figure · margin
   health bar · action chips (what the project needs next).
   ==================================================================== */
.pj-card {
    position: relative; display: flex; flex-direction: column;
    padding: 18px 20px 16px;
    background: var(--bg-card); border-radius: var(--radius-board);
    box-shadow: var(--shadow-2); overflow: hidden;   /* NOT a button — enter via the title link / View */
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.26s ease;
    border:1px solid var(--divider);
}
@media (hover: hover) { .pj-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-3); } }

/* The project title is the entry point (the card itself is no longer one big button). */
.pj-name-link { color: inherit; text-decoration: none; cursor: pointer; display: inline; border-bottom: 1px solid transparent; transition: border-color 0.15s ease; }
.pj-name-link:hover { border-bottom-color: currentColor; }
.pj-name-link:focus-visible { outline: 2px solid var(--chart-blue); outline-offset: 2px; border-radius: 2px; }

.pj-top { display: flex; align-items: center; gap: 8px; margin-bottom: 15px; min-height: 28px; }
/* THE STATUS PILL (shared recipe) — outlined caps word + glowing neon dot, text
   in a READABLE ink. One element for every state anywhere: project/client/team
   cards, the Documents rail + command bar, and every table status column.
   Semantic variants: --good (settled/paid/cleared) · --warn (pending/sent) ·
   --risk (lost/overdue/written-off) · --neutral. Join these — don't mint. */
.pj-status { display: inline-flex; align-items: center; gap: 7px; font-size: 10px; letter-spacing: var(--tracking-caps); text-transform: uppercase; font-weight: var(--fw-semibold); padding: 4px 11px 4px 9px; border-radius: var(--radius-pill); border: 1px solid; }
.pj-status-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.pj-status--good { color: var(--neon-green); border-color: color-mix(in srgb, var(--neon-green) 42%, transparent); }
.pj-status--good .pj-status-dot { background: var(--neon-green); box-shadow: 0 0 6px var(--neon-green-glow); }
.pj-status--risk { color: var(--neon-red); border-color: color-mix(in srgb, var(--neon-red) 46%, transparent); }
.pj-status--risk .pj-status-dot { background: var(--neon-red); box-shadow: 0 0 6px var(--neon-red-glow); }
.pj-status--quote { color: var(--quote-ink); border-color: color-mix(in srgb, var(--chart-cyan) 48%, transparent); }
.pj-status--quote .pj-status-dot { background: var(--chart-cyan); box-shadow: 0 0 6px color-mix(in srgb, var(--chart-cyan) 55%, transparent); }
.pj-status--neutral { color: var(--text-muted); border-color: var(--divider-strong); }
.pj-status--neutral .pj-status-dot { background: var(--text-muted); }
/* Lifecycle-stage pills: text in a readable ink (quote teal · invoice gold), bright dot. */
.pj-status--quoting { color: var(--quote-ink); border-color: color-mix(in srgb, var(--chart-cyan) 48%, transparent); }
.pj-status--quoting .pj-status-dot { background: var(--chart-cyan); box-shadow: 0 0 6px color-mix(in srgb, var(--chart-cyan) 55%, transparent); }
.pj-status--invoicing, .pj-status--warn { color: #b8860b; border-color: color-mix(in srgb, var(--warning-yellow) 60%, transparent); }
.pj-status--invoicing .pj-status-dot, .pj-status--warn .pj-status-dot { background: var(--warning-yellow); box-shadow: 0 0 6px color-mix(in srgb, var(--warning-yellow) 60%, transparent); }
.pj-status--settled { color: var(--neon-green); border-color: color-mix(in srgb, var(--neon-green) 42%, transparent); }
.pj-status--settled .pj-status-dot { background: var(--neon-green); box-shadow: 0 0 6px var(--neon-green-glow); }
.pj-status--archived { color: var(--text-muted); border-color: var(--divider-strong); }
.pj-status--archived .pj-status-dot { background: var(--text-muted); }
.pj-menu { margin-left: auto; }
.pj-menu .action-btn { opacity: 0.5; transition: opacity 0.16s ease; }
.pj-menu .action-btn:hover { opacity: 1; }

/* WHO'S IN CHARGE — the project owner, anchored bottom-left of the card footer
   (avatar + name), squared off against the View button on the right. */
.pj-lead { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.pj-lead-av { width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%; background: var(--text-main); display: inline-flex; align-items: center; justify-content: center; }
.pj-lead-av > span { font-size: 10px; font-weight: var(--fw-bold); color: var(--bg-main); letter-spacing: 0.02em; }
.pj-lead-av--none { background: var(--active-theme-bg); }
.pj-lead-av--none .material-icons { font-size: 15px; color: var(--text-muted); }
.pj-lead-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.pj-lead-cap { font-size: 8.5px; letter-spacing: var(--tracking-caps); text-transform: uppercase; font-weight: var(--fw-medium); color: var(--text-muted); }
.pj-lead-name { font-size: 12.5px; font-weight: var(--fw-semibold); color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.pj-lead--none .pj-lead-name { color: var(--text-muted); font-weight: var(--fw-medium); }

.pj-name { font-size: 17px; font-weight: var(--fw-semibold); color: var(--text-main); line-height: 1.25; letter-spacing: 0; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pj-meta { margin-top: 5px; font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* start date + running day counter */
.pj-timeline { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 11.5px; color: var(--text-muted); }
.pj-timeline .material-icons { font-size: 14px; color: var(--text-muted); }
.pj-timeline-date { letter-spacing: 0.01em; white-space: nowrap; }
.pj-timeline-day { padding: 2px 8px; border-radius: var(--radius-pill); background: var(--active-theme-bg); color: var(--text-main); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; font-size: 10.5px; letter-spacing: 0.01em; }
/* People card utilisation line (hours logged · billable %) — the timeline row tinted
   with the brand accent so the working-hours stat reads as its own thing. */
.pj-util { margin-top: 6px; }
.pj-util .material-icons { color: var(--text-main); }
.pj-util .pj-timeline-date { color: var(--text-main); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }

/* ── WORKING-HOURS (project Time tab) ─────────────────────────────────────────── */
/* Summary bar above the entries table: total / billable hours + logged value on the
   left, the "Log time" button on the right. */
.pd-time-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    padding: 0 0 16px; margin-bottom: 4px; border-bottom: 1px solid var(--divider); }
.pd-time-figs { display: flex; align-items: flex-end; gap: 28px; flex-wrap: wrap; }
.pd-time-fig { display: flex; flex-direction: column; gap: 6px; }
.pd-time-log { flex: 0 0 auto; border-radius: var(--radius-sm); font-weight: var(--fw-semibold);
    display: inline-flex; align-items: center; gap: 6px; }

/* Billable / Internal pill in the entries table */
.time-pill { display: inline-block; font-size: 9.5px; letter-spacing: var(--tracking-caps); text-transform: uppercase;
    font-weight: var(--fw-bold); padding: 3px 9px; border-radius: var(--radius-pill); white-space: nowrap; }
.time-pill--bill { color: var(--success-green); background: color-mix(in srgb, var(--success-green) 14%, transparent); }
.time-pill--int  { color: var(--text-muted); background: var(--divider); }

/* Modal: billable checkbox row + the "(optional)" hint on a field label */
.time-billable-row { display: flex; align-items: center; gap: 10px; cursor: pointer; margin-top: 4px;
    font-size: 13px; color: var(--text-main); user-select: none; }
.time-billable-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--text-main); cursor: pointer; }
.time-billable-text { font-weight: var(--fw-medium); }
.form-label-opt { font-weight: var(--fw-regular); color: var(--text-muted); text-transform: none; letter-spacing: 0; }

.pj-fig { margin-top: 18px; }
.pj-fig-cap { font-size: 9px; letter-spacing: var(--tracking-caps); text-transform: uppercase; font-weight: var(--fw-medium); color: var(--text-muted); }
.pj-fig-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 4px; }
.pj-fig-val { font-size: 24px; font-weight: var(--fw-bold); color: var(--text-main); font-variant-numeric: tabular-nums; line-height: 1; letter-spacing: 0; }
.pj-fig-val.is-pos { color: var(--neon-green); }
.pj-fig-val.is-neg { color: var(--neon-red); }
.pj-margin { font-size: 12px; font-weight: var(--fw-semibold); color: var(--text-muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.pj-bar { margin-top: 12px; height: 5px; background: var(--divider); }
.pj-bar-fill { background: var(--neon-green); }
.pj-bar-fill.is-neg { background: var(--neon-red); }

/* Footer = the project OWNER (left) squared against the View button (right), with a
   hairline rule separating it from the billing chips above. */
.pj-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 13px; border-top: 1px solid var(--divider); }
.pj-card .pj-fig { margin-bottom: 16px; }   /* push the chips/foot down so cards align */
.pj-chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; margin-bottom: 13px; }
.pj-chips:empty { display: none; }
.pj-chip { font-size: 10px; letter-spacing: 0.01em; font-weight: var(--fw-semibold); color: var(--text-main); padding: 4px 9px; border-radius: var(--radius-pill); white-space: nowrap; }
.pj-chip--bill { background: color-mix(in srgb, var(--chart-cyan) 24%, transparent); }
.pj-chip--collect { background: color-mix(in srgb, var(--warning-yellow) 32%, transparent); }
.pj-chip--ar { background: color-mix(in srgb, var(--neon-pink) 18%, transparent); }
.pj-chip--done { color: var(--text-muted); background: var(--active-theme-bg); }
.pj-ar { display: inline-flex; align-items: baseline; gap: 6px; flex-shrink: 0; }
.pj-ar-cap { font-size: 9px; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-muted); font-weight: var(--fw-medium); }
.pj-ar-val { font-size: 13px; font-weight: var(--fw-semibold); color: var(--text-main); }

/* the explicit View → button — the portal action made visible (the whole card is
   also clickable, but this gives an unmistakable affordance). */
/* Card CTA (project "View", client/team "Edit") — WHITE pill: it reads as a quiet
   secondary action on the white card via a hairline border + faint lift, not a heavy
   black slab. (Was background:var(--text-main)/colour:var(--bg-card) — a dark pill.) */
.pj-view-btn { display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; padding: 6px 10px 6px 13px; border: 1px solid var(--divider-strong); border-radius: var(--radius-sm); background: var(--bg-card); color: var(--text-main); font-size: 11.5px; font-weight: var(--fw-semibold); letter-spacing: 0.01em; cursor: pointer; transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease; }
.pj-view-btn:hover { background: var(--divider); border-color: var(--text-muted); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08); }
.pj-view-btn:active { transform: scale(0.96); }
.pj-view-btn .material-icons { font-size: 15px; }
/* archived cards/rows read as parked-away — dimmed, no bright pills */
.pj-card.is-archived { opacity: 0.72; background: var(--active-theme-bg); box-shadow: none; }
.pj-card.is-archived:hover { opacity: 1; }
.pj-row.is-archived { opacity: 0.66; }

/* PEOPLE CARDS (Clients · Team) — reuse the Project grid card. The avatar moves up into
   the title row; clients show a line-broken contact block (easy copy); the figure is the
   project-style Net-Profit value + proportion bar; the foot pairs the pill with Edit. */
.pj-card.pj-card--people .pj-fig { margin-bottom: 0; }
.pj-titlerow { display: flex; align-items: center; gap: 11px; min-width: 0; }
.pj-titlerow .pj-lead-av { flex-shrink: 0; }
.pj-titlerow .pj-name { flex: 1 1 auto; min-width: 0; margin: 0; }
.pj-contact { margin-top: 11px; display: flex; flex-direction: column; gap: 3px; }
.pj-contact-row { font-size: 12px; color: var(--text-muted); line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: text; }
.pj-contact-row--muted { font-style: italic; }
.pj-foot--people { gap: 10px; }
.pj-foot--people .pj-chip { white-space: nowrap; }
/* the count label on the left of the People board controls */
.pj-count { font-size: 11px; letter-spacing: var(--tracking-caps); text-transform: uppercase; font-weight: var(--fw-medium); color: var(--text-muted); }

/* PROJECT CARD colour avatar (a button) — reuses .pj-lead-av sizing; its background is
   the project's accent. Click → opens the project modal where the colour is chosen. */
.pj-card-av { border: none; padding: 0; cursor: pointer; transition: transform 0.14s ease, box-shadow 0.14s ease; }
.pj-card-av > span { color: #fff; }
@media (hover: hover) { .pj-card-av:hover { transform: scale(1.07); box-shadow: 0 2px 9px rgba(17,19,28,0.22); } }

/* PROJECT MODAL — colour picker. The avatar sits left of the name; clicking it drops a
   swatch popover (preset palette + a native colour input for fully custom). */
.prj-name-row { display: flex; align-items: center; gap: 12px; position: relative; }
.prj-name-row > .modal-input-lg { flex: 1; min-width: 0; }
.prj-avatar-pick { position: relative; flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; background: var(--text-main); transition: transform 0.14s ease, box-shadow 0.14s ease; }
.prj-avatar-pick > span { font-size: 15px; font-weight: var(--fw-bold); color: #fff; letter-spacing: 0.02em; }
.prj-avatar-pick:hover { transform: scale(1.04); box-shadow: 0 2px 10px rgba(17,19,28,0.22); }
.prj-avatar-edit { position: absolute; right: -3px; bottom: -3px; font-size: 13px !important; color: var(--text-main); background: var(--bg-card); border-radius: 50%; padding: 2px; box-shadow: 0 1px 3px rgba(17,19,28,0.25); }
.prj-color-pop { position: absolute; top: calc(100% + 8px); left: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--radius-board); background: var(--bg-card); box-shadow: var(--shadow-3); }
.prj-color-pop.hidden { display: none; }
.prj-swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.prj-swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; transition: transform 0.12s ease; }
.prj-swatch:hover { transform: scale(1.14); }
.prj-swatch.is-sel { border-color: var(--bg-card); box-shadow: 0 0 0 2px var(--text-main); }
.prj-color-custom { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--bg-main); cursor: pointer; position: relative; flex-shrink: 0; border: 1px solid var(--divider-strong); }
.prj-color-custom .material-icons { font-size: 17px; color: var(--text-muted); }
.prj-color-custom input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: none; padding: 0; }

/* PROFIT-CALC TOOLTIP — on hovering a card's profit figure/bar: Revenue − Expenses =
   Net Profit (+ margin). A flat document module, like the rest of the UI. */
.pj-card .pj-fig { cursor: help; }
.profit-tip { position: fixed; z-index: 9999; pointer-events: none; min-width: 190px; padding: 12px 13px; background: var(--bg-card); border: 1px solid var(--divider); border-radius: var(--radius-board); box-shadow: var(--shadow-3); opacity: 0; transition: opacity 0.14s ease; }
.profit-tip.hidden { display: none; }
.ptip-name { font-size: 12.5px; font-weight: var(--fw-semibold); color: var(--text-main); margin-bottom: 8px; white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.ptip-row { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; padding: 3px 0; }
.ptip-k { font-size: 11.5px; color: var(--text-muted); letter-spacing: 0.01em; }
.ptip-v { font-size: 12.5px; font-weight: var(--fw-semibold); color: var(--text-main); font-variant-numeric: tabular-nums; }
.ptip-pos { color: var(--neon-green); }
.ptip-neg { color: var(--neon-red); }
.ptip-total { margin-top: 4px; padding-top: 7px; border-top: 1px solid var(--divider); }
.ptip-total .ptip-k { color: var(--text-main); font-weight: var(--fw-semibold); }
.ptip-total .ptip-v { font-size: 13.5px; }
.ptip-margin { margin-top: 6px; font-size: 10px; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-muted); text-align: right; }
.pj-row.is-archived:hover { opacity: 1; }
.pj-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 56px 20px; color: var(--text-muted); text-align: center; }
.pj-empty .material-icons { font-size: 30px; opacity: 0.5; }
.pj-empty span { font-size: 13px; font-weight: var(--fw-medium); }

/* PROJECT LIST (table view) — same status language as the grid; the whole row is
   a portal into the detail page. */
.pj-row { cursor: pointer; }
.pj-row td { vertical-align: middle; }
.pj-tbl-name { font-weight: var(--fw-semibold); color: var(--text-main); }
.pj-tbl-meta { font-size: 12.5px; color: var(--text-muted); }
.pj-tbl-profit.is-pos { color: var(--neon-green); font-weight: var(--fw-semibold); }
.pj-tbl-profit.is-neg { color: var(--neon-red); font-weight: var(--fw-semibold); }
.pj-tbl-margin { color: var(--text-muted); }
.pj-tbl-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pj-tbl-ar { font-size: 11.5px; font-weight: var(--fw-semibold); color: var(--text-main); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pj-tbl-ar .pj-ar-cap { margin-right: 1px; }

/* Write-off modal: the invoice summary chip + the "this is a loss" explainer. */
.wo-summary { font-size: 14px; font-weight: var(--fw-semibold); color: var(--text-main); font-variant-numeric: tabular-nums; padding: 12px 14px; background: var(--bg-main); border-radius: var(--radius-sm); margin-bottom: 14px; }
.wo-note { font-size: 12.5px; line-height: 1.55; color: var(--text-muted); margin: 0 0 18px; }

/* A/R AGING redesigned — a "receivables health spectrum": one segmented bar
   (current → late → overdue, sized by share) over a clean ledger legend. */
.cf-agebar { display: flex; flex-direction: column; gap: 16px; }
.cf-agebar-track {
    display: flex;
    height: 10px;
    border-radius: var(--radius-pill);
    overflow: hidden;
    background: var(--divider);
}
.cf-ageseg {
    height: 100%;
    min-width: 0;
    transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.cf-ageseg + .cf-ageseg { box-shadow: inset 2px 0 0 var(--bg-card); }   /* thin separator, no layout shift */
.cf-ageseg--good { background: var(--neon-green); }
.cf-ageseg--watch { background: var(--warning-yellow); }
.cf-ageseg--risk { background: var(--neon-pink); }   /* overdue A/R — neon-pink critical */

.cf-agelegend { display: flex; flex-direction: column; }
.cf-ageleg {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 0;
    border-bottom: 1px solid var(--divider);
}
.cf-ageleg:last-child { border-bottom: none; }
.cf-ageleg-dot { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; }
.cf-ageleg-dot.good { background: var(--neon-green); box-shadow: 0 0 5px var(--neon-green-glow); }
.cf-ageleg-dot.watch { background: var(--warning-yellow); box-shadow: 0 0 5px var(--warning-yellow); }
.cf-ageleg-dot.risk { background: var(--neon-pink); box-shadow: 0 0 6px var(--neon-pink-glow); }
.cf-ageleg-lbl {
    flex: 1;
    min-width: 0;
    font-size: 10.5px;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    font-weight: var(--fw-medium);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cf-ageleg-amt { font-size: 13.5px; font-weight: var(--fw-semibold); color: var(--text-main); font-variant-numeric: tabular-nums; }
.cf-ageleg-pct { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.cf-ar-clear { font-size: 12px; letter-spacing: var(--tracking-wide); text-transform: uppercase; font-weight: var(--fw-semibold); padding: 8px 0; }

/* responsive reflow — hero spans the top, figures form a 3-up row, then stack */
@media (max-width: 1024px) {
    .cf-grid { grid-template-columns: 1fr 1fr 1fr; }
    .cf-hero { grid-column: 1 / -1; border-right: none; border-bottom: 1px solid var(--divider); align-items: flex-start; }
}
@media (max-width: 600px) {
    .cf-grid { grid-template-columns: 1fr 1fr; }
    .cf-hero { grid-column: 1 / -1; }
    .cf-cell { border-right: 1px solid var(--divider); border-bottom: 1px solid var(--divider); }
    .cf-cell:nth-child(2n), .cf-cell:last-child { border-right: none; }
    .cf-aging { padding-inline: var(--space-4); }
}
/* PERFORMANCE board (3-col) gets its OWN reflow — hero (with Rev/Profit) spans full,
   then the avg-list + funnel sit side by side, then everything stacks. Placed after
   the .cf-grid rules so the column override wins. */
@media (max-width: 1024px) {
    .perf-grid { grid-template-columns: 1fr 1fr; }
    .perf-grid .cf-hero { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
    .perf-grid { grid-template-columns: 1fr; }
    .perf-grid .cf-cell { border-right: none; border-bottom: 1px solid var(--divider); }
    .perf-grid .cf-cell:last-child { border-bottom: none; }
}
