/* ═══ 14. PROJECT MANAGER ════════════════════════════════════════════ */

.pm-list { flex: 1; overflow-y: auto; min-height: 0; }
.pm-row-wrap { border-bottom: 1px solid var(--line); }
.pm-row {
  display: grid;
  grid-template-columns: 24px 70px minmax(160px, 1.4fr) 1fr 90px 90px 90px 110px 44px 14px;
  align-items: center; gap: 10px;
  padding: 9px 4px;
  transition: background var(--dur-fast), opacity var(--dur-fast) ease-out;
  cursor: pointer;
}
.pm-row:hover { background: var(--hover-bg); }
.pm-row.dragging { opacity: .4; }
/* .pm-top/.pm-sub (mobile.css) group fields for the two-row card reflow;
   here on desktop they're pure DOM grouping with no visual effect —
   display:contents flattens their children straight into this grid, exactly
   as if .pm-row still had 10 flat children. Grouping moved .pm-ring/
   .pm-chevron out of trailing DOM position (next to the name now, for
   mobile's benefit) — order reasserts their original last-place position for
   this grid's own auto-placement, which is order-aware, not just DOM-order. */
.pm-top, .pm-sub { display: contents; }
.pm-ring { order: 1; }
.pm-chevron { order: 2; }
/* Custom setDragImage() target (project-manager.js) — rendered off-screen
   just long enough for the browser to snapshot it as the drag preview. */
.pm-drag-ghost {
  position: fixed; top: -9999px; left: -9999px;
  background: var(--panel-bg); border: 1px solid var(--hairline);
  border-radius: var(--radius-md); padding: 4px 10px;
  font-size: var(--text-base); color: var(--ink);
  box-shadow: var(--shadow-float);
  white-space: nowrap;
}
.pm-handle {
  color: var(--ink-faint); cursor: grab;
  padding: 4px 6px; border-radius: var(--radius-md);
}
.pm-handle:hover { color: var(--fg); background: var(--hover-bg); }
.pm-num { font-size: var(--text-base); color: var(--ink-faint); letter-spacing: .08em; }
.pm-name-cell { display: flex; align-items: center; gap: 4px; min-width: 0; }
/* flex:0 1 auto (not 1) — the name only takes its own content width, so the
   pencil sits right next to the text instead of at the far edge of the cell;
   min-width:0 still lets it shrink+ellipsis if the name itself is too long. */
.pm-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Pencil sits right after the title, invisible until the row is hovered or
   the icon itself gets keyboard focus (so it's still reachable by Tab). */
.pm-edit-icon {
  flex: none; opacity: 0;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius-md);
  color: var(--ink-soft);
  transition: opacity var(--dur-fast), background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.pm-row:hover .pm-edit-icon, .pm-edit-icon:focus-visible { opacity: 1; }
.pm-edit-icon:hover { background: var(--hover-bg); border-color: var(--fg); color: var(--fg); }
.pm-loc, .pm-date { font-size: var(--text-sm); color: var(--ink-soft); }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--chip-bg);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-size: var(--text-sm); color: var(--ink-soft);
  white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.chip .dot.fast { background: var(--ok); }
.chip .dot.moderate { background: var(--warn); }
.chip .dot.slow { background: var(--bad); }
.pm-ring { justify-self: end; position: relative; width: 32px; height: 32px; }
.pm-ring svg { display: block; }
.pm-ring .track { stroke: var(--line-strong); }
.pm-ring .arc { stroke: var(--fg); }
.pm-ring .pct {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 8px; color: var(--ink-soft);
}
/* Persistent expand affordance — was previously signalled only by
   aria-expanded, which sighted mouse users have no way to perceive. */
.pm-chevron {
  justify-self: center; color: var(--ink-faint);
  transition: transform var(--dur-fast), color var(--dur-fast);
}
.pm-row:hover .pm-chevron { color: var(--fg); }
.pm-row[aria-expanded="true"] .pm-chevron { transform: rotate(180deg); }

/* project-manager.js's render() fully rebuilds #pmList's innerHTML on every
   toggle (and again moments later once the lazily-loaded history data
   actually arrives, swapping the "Loading…" placeholder for the real table)
   — so this node is always a brand-new element, never a mutated existing
   one, which is exactly the case a CSS transition can't animate but a CSS
   *animation* can (it plays on insertion regardless). That turns what read
   as an instant double-pop ("on off on off") into two soft fades. */
.pm-history { padding: 4px 4px 14px 68px; animation: pm-history-in var(--dur-base) ease-out; }
@keyframes pm-history-in { from { opacity: 0; transform: translateY(-6px); } }
.pm-history table { border-collapse: collapse; font-size: var(--text-sm); }
.pm-history th, .pm-history td {
  border: 1px solid var(--line);
  padding: 4px 9px; text-align: right;
  color: var(--ink-soft); font-weight: 400;
}
.pm-history th { color: var(--ink-faint); font-size: var(--text-xs); letter-spacing: .05em; }
.pm-history th.rowhead, .pm-history td.rowhead { text-align: left; }
.pm-history td.up { color: var(--ok-text); }
.pm-history td.stall2 { color: var(--warn-text); }
.pm-history td.stall3 { color: var(--bad-text); }

/* Export bar in the history drop-down (plan doc 12 §6). */
.pm-export {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.pm-export-lbl {
  font-size: var(--text-xs); color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .06em;
}

/* Phase-owner matrix in the New/Edit modal (plan doc 12 §3.3). The label sits
   on its own line; the rows form a compact two-column list under it. */
.frow-owners { align-items: start; }
.frow-owners > label { padding-top: 6px; }
.pm-owners { display: flex; flex-direction: column; gap: 6px; }
.pm-owner-row {
  display: grid; grid-template-columns: 1fr 120px;
  align-items: center; gap: 10px;
}
.pm-owner-row > span { font-size: var(--text-base); color: var(--ink-soft); }

/* ── lifecycle stage: list sections + the stage badge ─────────────────────
   Stage is set by hand and is orthogonal to progress (a project can be under
   construction while its DED is still open), so nothing here is tinted by a
   percentage — only by the stage itself. */

.pm-section {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 4px 5px;
  border-bottom: 1px solid var(--line);
}
.pm-section-lbl {
  font-size: var(--text-xs); color: var(--ink-faint);
  letter-spacing: .1em; text-transform: uppercase;
}
.pm-section-count {
  font-size: var(--text-xs); color: var(--ink-faint);
  background: var(--chip-bg); border-radius: var(--radius-sm);
  padding: 1px 6px;
}

/* Sits inside .pm-name-cell, so the row's 10-column grid is untouched. */
.pm-badge {
  flex: none;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--text-xs); letter-spacing: .04em;
  border-radius: var(--radius-sm); padding: 1px 6px;
  border: 1px solid var(--line-strong); color: var(--ink-soft);
  background: var(--chip-bg);
  white-space: nowrap;
}
.pm-badge.construction { color: var(--warn-text); border-color: var(--warn); }
.pm-badge.done { color: var(--ok-text); border-color: var(--ok); }
/* The date is a quieter fact than the stage it hangs off — it never computes
   anything, it just says when the site started moving. */
.pm-badge-date {
  color: var(--ink-faint); letter-spacing: 0;
  padding-left: 5px; border-left: 1px solid var(--line-strong);
}

/* ── schedule adjustment (phase pins) — docs/deadline-math.md ──────────────
   A pinned phase is an explicit override of a derived date, so it is marked
   plainly rather than blending in: the point of this screen is to see at a
   glance which dates the app worked out and which ones a person insisted on. */
.pm-adjust-cell { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pm-adjust-note { font-size: var(--text-sm); color: var(--ink-faint); }
.pm-adjust-note.is-pinned { color: var(--warn-text); }

.modal.plan-modal { width: min(92vw, 560px); }
.plan-intro {
  font-size: var(--text-sm); color: var(--ink-soft);
  margin-bottom: 14px;
}
.plan-rows { display: flex; flex-direction: column; }
.plan-row {
  display: grid;
  grid-template-columns: 1fr auto minmax(130px, auto) auto;
  align-items: center; gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--line);
}
.plan-phase { font-size: var(--text-sm); }
.plan-window {
  font-size: var(--text-xs); color: var(--ink-faint);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.plan-row.pinned .plan-phase { font-weight: 500; }
.plan-row.pinned .plan-window { color: var(--warn-text); }
.plan-pin { height: var(--control-h-sm); }
.plan-unpin { flex: none; }

.plan-summary { margin-top: 16px; }
.plan-sum-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 2px;
  font-size: var(--text-sm); color: var(--ink-soft);
}
.plan-sum-row b { color: var(--ink); font-variant-numeric: tabular-nums; }
.plan-sum-row b.is-late { color: var(--bad-text); }
.plan-sum-row b.is-ok { color: var(--ok-text); }
.plan-sum-note {
  font-size: var(--text-xs); color: var(--ink-faint);
  padding: 2px 2px 10px;
}
.plan-sum-note.is-late { color: var(--bad-text); }

/* ── single-project Gantt (gantt.js) ──────────────────────────────────────
   Fit-to-width by construction: the JS derives a fractional day width from the
   available space, so there is no horizontal scrolling to hide anything. */
/* Matches .pvp-modal (progress-insight.css) so the two chart modals read
   as one pair rather than two sizes. */
.modal.gantt-modal { width: 1320px; max-width: calc(100% - 64px); }
.gt-sub {
  flex: 1; min-width: 0;
  font-size: var(--text-sm); color: var(--ink-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gt-body { overflow-y: auto; }
/* --gt-label-w is the ONE definition of the label column's width; gantt.js
   reads it back with getComputedStyle so JS and CSS can never disagree. */
.gt-chart {
  --gt-label-w: 104px;
  display: flex; align-items: flex-start;
  overflow-x: auto;            /* safety valve on very narrow phones only */
}
.gt-labels { flex: none; width: var(--gt-label-w); }
.gt-label-head { height: 18px; }        /* clears the month ruler */
.gt-label {
  height: 34px; display: flex; align-items: center; gap: 5px;
  font-size: var(--text-xs); color: var(--ink-soft);
  padding-right: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gt-label.muted { color: var(--ink-faint); }
.gt-label.pinned { color: var(--warn-text); font-weight: 500; }
.gt-pin-dot {
  flex: none; width: 5px; height: 5px; border-radius: 50%;
  background: var(--warn);
}

.gt-surface { flex: none; position: relative; }
.gt-ruler { display: flex; height: 18px; }
.gt-month {
  flex: none; overflow: hidden; white-space: nowrap;
  font-size: var(--text-xs); color: var(--ink-faint);
  border-left: 1px solid var(--line);
  padding-left: 3px;
}
.gt-grid { position: relative; }
.gt-row { position: relative; height: 34px; }

.gt-bar {
  position: absolute; top: 5px; height: 20px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex; align-items: center;
  padding: 0 5px;
  border: none;
}
.gt-bar-txt {
  font-size: var(--text-xs); color: var(--bg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  position: relative; z-index: 1;
}
.gt-bar.ph-1 { background: var(--phase-1); }
.gt-bar.ph-2 { background: var(--phase-2); }
.gt-bar.ph-3 { background: var(--phase-3); }
.gt-bar.ph-4 { background: var(--phase-4); }
.gt-bar.ph-5 { background: var(--phase-5); }
.gt-bar.ph-6 { background: var(--phase-6); }
/* A pinned phase is an overridden date, so it is outlined rather than tinted —
   the phase colour still has to read as the phase it is. */
.gt-bar.pinned { outline: 1.5px solid var(--warn); outline-offset: 1px; }
.gt-bar.dragging { opacity: .75; }
.gt-bar.editable { cursor: grab; }
.gt-bar.editable.dragging { cursor: grabbing; }

/* Edge grips: resize the phase (change its length). Invisible until the bar is
   hovered or focused, so a read-only glance stays clean. */
.gt-grip {
  position: absolute; top: 0; bottom: 0; width: 7px;
  cursor: ew-resize; opacity: 0;
  transition: opacity var(--dur-fast);
}
.gt-grip-l { left: 0; }
.gt-grip-r { right: 0; }
.gt-grip::after {
  content: ""; position: absolute; top: 4px; bottom: 4px;
  left: 2px; width: 2px; border-radius: 1px;
  background: var(--bg);
}
.gt-bar.editable:hover .gt-grip, .gt-bar.editable:focus-visible .gt-grip { opacity: .85; }

/* The untouched plan. It sits in its own slim track UNDER the bar rather than
   behind it: a lengthened phase starts at the same day, so an outline drawn
   behind would be completely hidden by the bar that replaced it — the one case
   the reference exists for. Never interactive; it is a memory, not a control. */
.gt-ghost {
  position: absolute; top: 27px; height: 4px;
  border-radius: 2px;
  background: repeating-linear-gradient(to right,
    var(--ink-faint) 0 4px, transparent 4px 7px);
  opacity: .75;
  pointer-events: none;
}
.gt-bar:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

.gt-review, .gt-rev { position: absolute; top: 0; bottom: 0; }
.gt-review {
  background: repeating-linear-gradient(45deg,
    transparent 0 3px, var(--weekend-tint) 3px 6px);
}
.gt-rev { border-left: 1px dashed var(--bg); opacity: .55; }

.gt-gate {
  position: absolute; top: 10px; height: 14px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--ink-faint); border-radius: var(--radius-sm);
  font-size: var(--text-xs); color: var(--ink-soft);
  background: var(--bg);
}

.gt-today { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--today); }
.gt-mark { position: absolute; top: 0; bottom: 0; width: 1px; }
.gt-hard { background: var(--ink-faint); }
.gt-plan { background: var(--ok); }
.gt-plan.is-late { background: var(--bad); }

.gt-legend {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin-top: 14px; padding-top: 10px;
  border-top: 1px solid var(--line);
}
.gt-key {
  display: flex; align-items: center; gap: 5px;
  font-size: var(--text-xs); color: var(--ink-faint);
}
.gt-key i { width: 10px; height: 10px; flex: none; border-radius: 2px; }
.gt-key .k-today { background: var(--today); }
.gt-key .k-hard { background: var(--ink-faint); }
.gt-key .k-plan { background: var(--ok); }
.gt-key .k-plan.is-late { background: var(--bad); }
.gt-key .k-review { background: repeating-linear-gradient(45deg,
  var(--ink-faint) 0 2px, transparent 2px 4px); }
.gt-key .k-rev { border: 1px dashed var(--ink-faint); background: transparent; }
.gt-key .k-ghost {
  height: 4px; border-radius: 2px;
  background: repeating-linear-gradient(to right,
    var(--ink-faint) 0 4px, transparent 4px 7px);
}

.gt-foot { flex-wrap: wrap; gap: 8px; }
.gt-status { font-size: var(--text-sm); color: var(--ink-soft); }
.gt-status b { color: var(--ink); font-variant-numeric: tabular-nums; }
.gt-status b.is-late { color: var(--bad-text); }
.gt-status b.is-ok { color: var(--ok-text); }

/* ── custom phase/task authoring (docs/feature-custom-projects.md) ───────── */
.modal.shape-modal { width: min(92vw, 600px); }
.sh-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.sh-opt {
  display: flex; flex-direction: column; gap: 4px;
  text-align: left; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-md);
  background: transparent; color: var(--ink-soft);
}
.sh-opt:hover { background: var(--hover-bg); }
.sh-opt.active { border-color: var(--fg); color: var(--ink); }
.sh-opt b { font-weight: 500; color: var(--ink); }
.sh-opt span { font-size: var(--text-xs); color: var(--ink-faint); }
.sh-note { font-size: var(--text-sm); color: var(--ink-soft); margin-bottom: 12px; }

.sh-phases { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.sh-phase {
  border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 8px 10px;
}
.sh-phase-head { display: flex; align-items: center; gap: 6px; }
.sh-pname { flex: 1; min-width: 0; height: var(--control-h-sm); }
.sh-gate {
  display: flex; align-items: center; gap: 4px; flex: none;
  font-size: var(--text-xs); color: var(--ink-soft); white-space: nowrap;
}
/* Tasks are inset under their phase and tethered, the same nesting language
   the to-do list uses for subtasks. */
.sh-tasks {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  margin: 8px 0 2px 10px; padding-left: 10px;
  border-left: 1px solid var(--line-strong);
}
.sh-task { display: flex; align-items: center; gap: 6px; width: 100%; }
.sh-tname { flex: 1; min-width: 0; height: var(--control-h-sm); }
.sh-status { font-size: var(--text-sm); color: var(--ink-faint); }

/* Overlapping phases are legal but must never pass unnoticed — see gantt.js. */
.gt-bar.overlap { outline: 1.5px solid var(--bad); outline-offset: 1px; }
.gt-bar.overlap.pinned { outline-color: var(--bad); }

/* Hover readout: a guide line under the pointer plus the date it stands on.
   pointer-events:none throughout — it reports, it never intercepts a drag. */
.gt-cursor {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: var(--fg); opacity: .3;
  pointer-events: none; z-index: 3;
}
.gt-cursor-lbl {
  /* Sits just BELOW the 18px month ruler — at top:0 it landed on the month
     names and the two read as one garbled string. */
  position: absolute; top: 20px; left: 4px;
  white-space: nowrap;
  font-size: var(--text-xs); color: var(--ink);
  background: var(--panel-bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 0 5px;
  font-variant-numeric: tabular-nums;
}
/* Near the right edge the label would spill off the surface — flip it left. */
.gt-cursor-lbl.flip { left: auto; right: 4px; }

/* Edit mode is a visible state, not just a behavioural one: the bars become
   grabbable, so the chart should look different from the read-only view. */
.gt-surface.is-editing .gt-row { background: var(--hover-bg); }
