.crm-projects-access-layout {
  display: grid;
  gap: 18px;
  padding: 0 18px 24px;
}

[data-panel="staff"] .crm-main-col { min-width: 0; }

.crm-projects-access-section {
  border-top: 1px solid var(--crm-border, #e5e7eb);
  padding-top: 16px;
}

.crm-projects-access-table-wrap { overflow-x: auto; }
.crm-projects-access-table { min-width: 720px; }
.crm-projects-access-table td { vertical-align: middle; }
.crm-projects-account-table { min-width: 980px; }
.crm-projects-access-column { vertical-align: middle; }
.crm-projects-account-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 300px; }
.crm-projects-grant-toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.crm-projects-account-status { min-width: 132px; }
.crm-projects-allowance-value { white-space: nowrap; font-variant-numeric: tabular-nums; }
.crm-projects-access-form { display: grid; gap: 8px; max-width: 720px; }
.crm-projects-access-form label { font-size: .86rem; color: var(--crm-text-muted, #64748b); }
.crm-projects-access-form textarea { resize: vertical; }

/* Phase 3 board: a bright, flat working surface with one table hierarchy. */
.crm-projects-board-section {
  padding: 4px 18px 28px;
  color: var(--pj-ink);
}
.crm-projects-board-toolbar,
.crm-projects-board-controls,
.crm-projects-board-detail-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.crm-projects-board-heading h3 { margin: 2px 0 4px; font-size: 1.28rem; }
.crm-projects-board-heading p { margin: 0; }
.crm-eyebrow {
  display: block;
  color: var(--pj-accent-ink);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.crm-projects-board-actions,
.crm-projects-board-controls .crm-inline-fields { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crm-projects-board-picker select { min-width: 220px; }
.crm-projects-board-form {
  display: grid;
  grid-template-columns: minmax(120px, .35fr) minmax(180px, 1fr);
  align-items: center;
  gap: 8px 12px;
  max-width: 720px;
  margin: 18px 0;
  padding: 14px 16px;
  border: 1px solid var(--pj-line);
  border-radius: 8px;
  background: var(--pj-raised);
}
.crm-projects-board-form textarea { resize: vertical; }
.crm-projects-board-form .crm-inline-fields { grid-column: 2; }
.crm-projects-board-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding: 18px;
  border: 1px dashed var(--pj-accent-line);
  border-radius: 8px;
  background: var(--pj-accent-soft);
}
.crm-projects-board-empty span { color: var(--pj-ink-2); }
.crm-projects-board-empty button { margin-left: auto; }
.crm-projects-board-workspace { margin-top: 18px; }
.crm-projects-board-controls { align-items: center; margin-bottom: 10px; }
.crm-projects-board-count { margin-left: auto; }
.crm-projects-board-table-wrap {
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--pj-line);
  border-radius: 8px;
  background: var(--pj-surface);
  outline: none;
}
.crm-projects-board-table {
  --crm-project-grid-template: minmax(300px, 2.4fr) minmax(130px, .85fr) minmax(150px, 1fr) minmax(145px, .95fr) minmax(280px, 1.35fr);
  min-width: 1005px;
}
.crm-projects-board-header,
.crm-projects-board-row {
  display: grid;
  grid-template-columns: var(--crm-project-grid-template);
  grid-template-rows: minmax(0, 1fr);
  align-items: center;
  min-height: 46px;
  box-sizing: border-box;
}
.crm-projects-board-header {
  position: sticky;
  top: 0;
  z-index: 4;
  color: var(--pj-ink-2);
  border-bottom: 1px solid var(--pj-line-strong);
  background: var(--pj-raised);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.crm-projects-board-header > div,
.crm-projects-board-row > div { min-width: 0; min-height: 0; box-sizing: border-box; padding: 8px 10px; }
.crm-projects-board-header > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-projects-board-header > .crm-projects-board-column-editable { display: flex; align-items: center; gap: 6px; }
.crm-projects-board-column-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.crm-projects-board-column-editable > button { flex: none; }
.crm-projects-board-scroll {
  position: relative;
  max-height: min(62vh, 720px);
  min-height: 160px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.crm-projects-board-rows { position: relative; }
.crm-projects-board-row {
  position: absolute;
  left: 0;
  right: 0;
  min-height: 46px;
  border-bottom: 1px solid var(--pj-line);
  background: var(--pj-surface);
  transition: background .15s ease, box-shadow .15s ease;
}
.crm-projects-board-row:hover,
.crm-projects-board-row:focus-within { background: var(--pj-raised); }
.crm-projects-board-row.is-selected { background: var(--pj-accent-soft); box-shadow: inset 3px 0 var(--pj-accent); }
.crm-projects-board-row.is-pending { background: var(--st-ip-bg); }
.crm-projects-board-row.is-drop-target { box-shadow: inset 0 -3px var(--pj-accent); }
.crm-projects-board-row.is-drop-parent { box-shadow: inset 0 0 0 2px var(--pj-accent-line); }
.crm-projects-board-task-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.crm-projects-board-task-title .crm-board-indent { flex: 0 0 auto; }
.crm-projects-board-task-title .crm-board-title-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-board-expander,
.crm-board-drag-handle { flex: 0 0 auto; width: 24px; height: 26px; padding: 0; border: 0; background: transparent; color: var(--pj-muted); cursor: pointer; }
.crm-board-drag-handle { cursor: grab; color: var(--pj-faint); }
.crm-board-drag-handle:active { cursor: grabbing; }
.crm-board-title-input { width: 100%; min-width: 0; }
.crm-projects-board-row input,
.crm-projects-board-row select { width: 100%; min-width: 0; min-height: 0; box-sizing: border-box; }
.crm-projects-board-cell { min-width: 0; }
.crm-board-date-cell { display: flex; align-items: center; gap: 4px; }
.crm-board-date-cell input { min-width: 0; width: 50%; height: 30px; padding-left: 4px; padding-right: 4px; font-size: .72rem; }
.crm-board-people-field { height: 28px; max-height: 28px; min-height: 0; overflow-y: auto; white-space: nowrap; }
.crm-board-people-field option { white-space: nowrap; }
.crm-projects-board-cell .crm-board-null { color: var(--pj-faint); }
.crm-projects-board-detail,
.crm-projects-board-settings {
  margin-top: 16px;
  border-top: 1px solid var(--pj-line);
  padding-top: 16px;
}
.crm-projects-board-detail-body { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.crm-projects-board-detail-body dl { margin: 0; }
.crm-projects-board-detail-body dt { color: var(--pj-muted); font-size: .76rem; }
.crm-projects-board-detail-body dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.crm-projects-board-settings-grid { display: grid; grid-template-columns: 180px minmax(0, 720px); align-items: center; gap: 8px 12px; max-width: 920px; }
.crm-projects-board-settings-grid textarea { resize: vertical; }
.crm-projects-board-settings-subheading { grid-column: 1 / -1; margin-top: 8px; color: var(--pj-ink-2); font-size: .76rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.crm-projects-board-settings-grid button { grid-column: 2; justify-self: start; }
.crm-projects-board-loading { padding: 26px; color: var(--pj-muted); text-align: center; }
.crm-projects-board-error { padding: 18px; color: var(--sig-over-fg); background: var(--sig-over-bg); }
.crm-projects-board-row [aria-busy="true"] { opacity: .65; }

/* Phase 4 keeps conversation and recovery on the detail surface so drafts
   survive board row refreshes without adding nested card chrome. */
.crm-projects-board-discussion,
.crm-projects-board-recovery { margin-top: 18px; border-top: 1px solid var(--pj-line); padding-top: 14px; }
.crm-projects-board-discussion-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.crm-projects-board-discussion-head h5 { margin: 2px 0 0; font-size: 1rem; }
.crm-projects-board-discussion-list { display: grid; gap: 10px; margin-top: 12px; }
.crm-projects-discussion-message { border-left: 3px solid var(--pj-accent-line); padding: 7px 0 7px 12px; }
.crm-projects-discussion-message.is-moderated { border-left-color: var(--st-ip-fg); color: var(--pj-muted); }
.crm-projects-discussion-message header { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: .8rem; }
.crm-projects-discussion-message header time { color: var(--pj-faint); font-size: .72rem; }
.crm-projects-discussion-message p { margin: 5px 0 8px; white-space: normal; overflow-wrap: anywhere; }
.crm-projects-discussion-attachments { display: flex; gap: 6px; flex-wrap: wrap; margin: 5px 0 8px; }
.crm-projects-board-discussion-form { display: grid; gap: 8px; margin-top: 12px; }
.crm-projects-recovery-history-row { display: block; margin-top: 3px; font-size: .76rem; }

/* Reduced motion is handled once, at the end of this file. */
@media (max-width: 760px) {
  .crm-projects-board-section { padding-left: 12px; padding-right: 12px; }
  .crm-projects-board-form,
  .crm-projects-board-settings-grid { grid-template-columns: 1fr; }
  .crm-projects-board-form .crm-inline-fields,
  .crm-projects-board-settings-grid button { grid-column: 1; }
  .crm-projects-board-empty button { margin-left: 0; }
}

@media (min-width: 980px) {
  .crm-projects-access-layout { grid-template-columns: minmax(0, 1fr) minmax(260px, .42fr); }
  .crm-projects-access-section:first-child { grid-column: 1 / -1; }
}

/* Flat recovery catalog; remains outside the selected task detail. */
.crm-projects-board-recovery { display: block; padding: 16px 0; border-top: 1px solid var(--pj-line); }
.crm-projects-board-recovery[hidden] { display: none; }
.crm-projects-board-recovery [data-recovery-toggle] { cursor: pointer; font-weight: 600; padding: 4px 0; }
.crm-projects-recovery-content { padding-top: 12px; }
.crm-projects-recovery-list { list-style: none; padding: 0; margin: 12px 0; }
.crm-projects-recovery-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--pj-line); flex-wrap: wrap; }
.crm-projects-recovery-row > div:first-of-type { flex: 1; min-width: 160px; display: grid; gap: 4px; }
[data-recovery-preview] { padding: 16px 0; }
[data-recovery-preview] label { display: block; margin: 8px 0; }
/* Shared project projections keep the workspace flat and the task identity visible. */
.crm-projects-view-tabs { display:flex; gap:8px; border-bottom:1px solid var(--pj-line-strong); margin:16px 0; padding-bottom:8px; flex-wrap:wrap; }
.crm-projects-view-tabs button { background:transparent; color:var(--pj-ink-2); border:0; border-radius:8px; padding:8px 16px; font:inherit; cursor:pointer; }
.crm-projects-view-tabs button[aria-pressed="true"] { background:var(--pj-accent-soft); color:var(--pj-accent-ink); font-weight:700; }
.crm-projects-view-filters { display:flex; flex-wrap:wrap; gap:12px; align-items:end; }
.crm-projects-view-filters label { display:flex; flex-direction:column; gap:4px; font-size:13px; min-width:130px; flex:1; }
.crm-projects-view-filters .crm-input { min-width:0; width:100%; }
/* Kanban is styled by the .crm-projects-kanban-col rules below. */
.crm-projects-view-row { display:flex; flex-direction:column; gap:8px; padding:16px 0; border-bottom:1px solid var(--pj-line-strong); }
.crm-projects-task-open { border:0; padding:0; background:transparent; color:var(--pj-accent-ink); font:inherit; font-weight:600; cursor:pointer; text-align:left; overflow-wrap:anywhere; }
.crm-projects-derived { display:block; border-left:3px solid var(--pj-faint); padding-left:8px; color:var(--pj-ink-2); line-height:1.5; }
.crm-projects-context { color:var(--pj-ink-2); background:var(--pj-sunken); font-size:11px; padding:2px 4px; }
.crm-projects-warnings { color:var(--st-ip-fg); padding-left:20px; overflow-wrap:anywhere; }
.crm-projects-calendar-grid { display:grid; grid-template-columns:repeat(7,minmax(120px,1fr)); overflow:auto; margin:16px 0; }
.crm-projects-calendar-day { padding:8px; border-bottom:1px solid var(--pj-line-strong); min-height:110px; display:flex; flex-direction:column; gap:8px; }
.crm-projects-calendar-day h5 { margin:0; color:var(--pj-ink-2); }
.crm-projects-chart { margin:24px 0; max-width:850px; }
.crm-projects-chart > div { display:grid; grid-template-columns:minmax(130px,1fr) 3fr 60px; gap:16px; align-items:center; margin:8px 0; }
.crm-projects-chart meter { width:100%; height:24px; accent-color:var(--pj-accent); }
#projects-task-planning { border-top:1px solid var(--pj-line-strong); padding-top:16px; }
#projects-task-planning form, #projects-calendar-holiday-choices { margin:16px 0; }
#projects-calendar-holiday-choices { border:0; padding:0; display:flex; flex-wrap:wrap; gap:12px; }
#projects-calendar-holiday-choices label { display:flex; gap:8px; align-items:center; }
#projects-project-links { border-bottom:1px solid var(--pj-line-strong); padding-bottom:16px; }
#projects-view-content button:focus-visible, #projects-view-tabs button:focus-visible, #projects-task-planning button:focus-visible { outline:3px solid var(--pj-accent); outline-offset:3px; }
@media (max-width:700px) { .crm-projects-view-filters label { min-width:140px; } .crm-projects-kanban { grid-template-columns:repeat(4,240px); } .crm-projects-chart > div { grid-template-columns:120px 1fr 35px; } }
.crm-projects-gantt { overflow:auto; margin:16px 0; }
.crm-projects-gantt-axis, .crm-projects-gantt-row { display:grid; grid-template-columns:260px minmax(500px,1fr); gap:24px; min-width:850px; }
.crm-projects-gantt-axis { height:40px; padding-right:45px; color:var(--pj-ink-2); }
.crm-projects-gantt-axis > div { position:relative; }
.crm-projects-gantt-axis time { position:absolute; font-size:11px; transform:translateX(-50%); white-space:nowrap; }
.crm-projects-gantt-axis time:first-child { transform:none; }
.crm-projects-gantt-row { border-bottom:1px solid var(--pj-line-strong); padding:12px 45px 12px 0; }
.crm-projects-gantt-row small { display:block; margin-top:4px; }
.crm-projects-gantt-track { position:relative; min-height:40px; overflow:hidden; background:repeating-linear-gradient(to right,transparent 0,transparent calc(25% - 1px),var(--pj-line) calc(25% - 1px),var(--pj-line) 25%); }
.crm-projects-gantt-track.has-derived-span { min-height:76px; }
.crm-projects-gantt-bar { position:absolute; top:8px; height:16px; background:var(--pj-accent); border-radius:3px; overflow:hidden; white-space:nowrap; box-sizing:border-box; }
.crm-projects-gantt-bar.is-derived { top:44px; background:transparent; border:2px dashed var(--pj-muted); height:12px; }

/* Flat notification feed: shared Projects surface, visible keyboard controls. */
.crm-projects-notifications { margin-block: 18px; padding-block: 14px; border-block: 1px solid var(--pj-line); color: var(--pj-ink); }
.crm-projects-notification-filters { display: flex; flex-direction: column; align-items: stretch; gap: 10px; margin-block: 12px; width: 100%; }
.crm-projects-notification-filters label { display: flex; flex-direction: column; gap: 5px; width: 100%; font-size: 0.82rem; font-weight: 600; color: var(--pj-ink-2); }
.crm-projects-notification-filters select,
.crm-projects-notification-filters button { width: 100%; box-sizing: border-box; }
.crm-projects-notifications .crm-inline-fields { display: flex; flex-direction: column; align-items: stretch; gap: 10px; width: 100%; }
.crm-projects-notifications .crm-inline-fields select,
.crm-projects-notifications .crm-inline-fields button { width: 100%; box-sizing: border-box; }
.crm-projects-notifications label { display: grid; gap: 5px; }
.crm-projects-notification-list { list-style: none; padding: 0; margin: 10px 0; }
.crm-projects-notification-row { display: flex; justify-content: space-between; gap: 20px; padding: 14px 8px; border-bottom: 1px solid var(--pj-line); }
.crm-projects-notification-row.is-unread { border-left: 3px solid var(--pj-accent); background: var(--pj-accent-soft); }
.crm-projects-notification-row p { margin: 5px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.crm-projects-notifications button:focus-visible, .crm-projects-notifications summary:focus-visible { outline: 2px solid var(--pj-accent); outline-offset: 3px; }
@media (max-width: 700px) { .crm-projects-notification-row { flex-direction: column; gap: 10px; } }

/* Automations use the shared bright workspace and a single connected rule line. */
.crm-projects-automations { margin-block: 24px; padding-block: 24px; border-block: 1px solid var(--pj-line-strong); color: var(--pj-ink); }
.crm-auto-heading { display: flex; justify-content: space-between; align-items: start; gap: 24px; margin-bottom: 16px; }
.crm-auto-heading h3 { margin: 4px 0 8px; font-size: 1.4rem; }
.crm-auto-heading p { margin: 0; color: var(--pj-ink-2); }
.crm-auto-surface, .crm-auto-definition { border: 0; padding: 0; margin: 16px 0; min-width: 0; }
.crm-auto-definition > legend { font-weight: 700; font-size: 1.1rem; margin-block: 16px; }
.crm-auto-fields { display: flex; flex-wrap: wrap; align-items: start; gap: 16px; margin-block: 16px; }
.crm-projects-automations label { display: grid; gap: 6px; flex: 1 1 180px; min-width: 0; max-width: 480px; color: var(--pj-ink-2); }
.crm-projects-automations textarea { min-height: 80px; resize: vertical; }
.crm-auto-manage-list { padding: 0; list-style: none; }
.crm-auto-manage-list > li { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px 0; border-bottom: 1px solid var(--pj-line); }
.crm-auto-manage-list p { margin: 6px 0; }
.crm-auto-representations, .crm-auto-actions, .crm-auto-step-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 16px; }
.crm-projects-automations [aria-pressed="true"] { background: var(--pj-accent-soft); color: var(--pj-accent-ink); border-color: var(--pj-accent); }
.crm-auto-steps { list-style: none; padding: 0 0 0 20px; margin: 24px 0; border-left: 2px solid var(--pj-accent-line); }
.crm-auto-step { position: relative; padding: 0 0 24px; margin-bottom: 16px; border-bottom: 1px solid var(--pj-line); }
.crm-auto-step::before { content: ''; position: absolute; left: -27px; top: 10px; width: 12px; height: 12px; border-radius: 50%; background: var(--pj-accent); box-shadow: 0 0 0 4px var(--pj-raised); }
.crm-auto-step > header { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.crm-auto-step-index { color: var(--pj-accent-ink); font-weight: 700; min-width: 48px; }
.crm-auto-step > header .crm-auto-step-tools { margin: 0; }
.crm-auto-step-tools button { font-size: .8rem; padding: 6px 8px; }
.crm-auto-condition { margin: 12px 0; }
.crm-auto-condition-line { margin-left: 16px; padding-left: 12px; border-left: 1px solid var(--pj-line-strong); }
.crm-auto-condition-line .crm-auto-fields { margin-block: 8px; }
.crm-auto-target { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin-block: 16px; }
.crm-auto-target span { color: var(--pj-ink-2); padding-block: 8px; overflow-wrap: anywhere; }
.crm-auto-field-value { flex: 1 1 200px; display: grid; gap: 6px; }
.crm-auto-field-value > button { justify-self: start; font-size: .8rem; padding: 4px 8px; }
.crm-auto-blocks > .crm-auto-step > header { border-bottom: 2px solid var(--pj-accent-soft); padding-bottom: 12px; }
.crm-auto-recipe > .crm-auto-step > header .crm-auto-step-index { font-style: italic; }
.crm-auto-warning { color: var(--st-ip-fg); background: var(--st-ip-bg); border-left: 3px solid var(--st-ip-fg); padding: 8px 12px; }
.crm-auto-task-search, .crm-auto-history, [data-auto-preview]:not(:empty) { border-top: 1px solid var(--pj-line-strong); margin-top: 24px; padding-top: 16px; }
.crm-auto-task-search li, .crm-auto-history li { margin-block: 8px; }
.crm-projects-automations :focus-visible { outline: 2px solid var(--pj-accent-ink); outline-offset: 3px; }
@media (max-width: 700px) { .crm-auto-heading, .crm-auto-manage-list > li { flex-direction: column; } .crm-auto-steps { padding-left: 12px; } .crm-auto-step::before { left: -19px; } .crm-auto-condition-line { margin-left: 4px; padding-left: 8px; } }

/* One account balance, outside project virtual rows and editor controls. */
.crm-ai-budget { padding: 24px 0; margin: 0 0 24px; border-bottom: 1px solid var(--pj-line-strong); color: var(--pj-ink); }
.crm-ai-budget[hidden] { display: none; }
.crm-projects-assistant { margin: 0 0 20px; padding: 16px 20px; border: 1px solid var(--pj-line-strong); border-radius: 10px; color: var(--pj-ink); background: var(--pj-raised); }
.crm-projects-assistant summary { cursor: pointer; font-weight: 650; }
.crm-projects-assistant p { margin: 10px 0; line-height: 1.5; }
.crm-projects-assistant label { display: block; margin: 12px 0; font-weight: 500; }
.crm-projects-assistant textarea, .crm-projects-assistant select { display: block; width: 100%; margin-top: 6px; padding: 10px; border: 1px solid var(--pj-faint); border-radius: 6px; font: inherit; background: white; color: var(--pj-ink); }
.crm-projects-assistant textarea { min-height: 100px; resize: vertical; }
.crm-projects-assistant button { margin: 4px 8px 4px 0; padding: 8px 12px; border: 1px solid var(--pj-faint); border-radius: 6px; color: var(--pj-ink); background: white; font: inherit; cursor: pointer; }
.crm-projects-assistant button:disabled { opacity: .55; cursor: default; }
.crm-projects-assistant :focus-visible { outline: 3px solid var(--pj-accent-ink); outline-offset: 3px; }
.crm-projects-assistant li { padding: 4px 0; overflow-wrap: anywhere; }
.crm-ai-budget-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.crm-ai-budget-heading h3 { margin: 0; font-size: 1rem; }
.crm-ai-budget p { margin: 8px 0 0; font-size: .875rem; }
.crm-ai-budget-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 24px; margin: 16px 0 0; }
.crm-ai-budget-totals dt { color: var(--pj-ink-2); font-size: .8125rem; }
.crm-ai-budget-totals dd { margin: 4px 0 0; font-weight: 650; font-size: 1.125rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.crm-ai-budget-totals .crm-ai-budget-exhausted { color: var(--sig-over-fg); }
.crm-ai-budget [data-ai-budget-refresh]:focus-visible { outline: 3px solid var(--pj-accent); outline-offset: 3px; }
@media (max-width: 540px) {
  .crm-ai-budget-heading { align-items: flex-start; flex-wrap: wrap; }
  .crm-ai-budget-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Approved Projects workspace: flat board canvas; existing controllers own state. */
/* Approved Projects workspace: flat board canvas; existing controllers own state. */
[data-panel="projects"] {
  --pj-ground: var(--crm-bg-subtle, #f6f8fb);
  --pj-surface: var(--crm-card-bg, #ffffff);
  --pj-raised: #fbfcfe;
  --pj-sunken: #eef2f8;
  --pj-line: var(--crm-border, #e6ebf2);
  --pj-line-strong: #cfd7e4;
  --pj-ink: var(--crm-text-main, #121826);
  --pj-ink-2: #42506a;
  --pj-muted: var(--crm-text-muted, #748095);
  --pj-faint: #66707e;
  --pj-accent: var(--crm-primary, #177a44);
  --pj-accent-soft: var(--crm-primary-light, #f0fdf4);
  --pj-accent-ink: var(--green-800, #166534);

  --st-ns-bg: #eef1f6;  --st-ns-fg: #65728a;
  --st-ip-bg: #fff2d3;  --st-ip-fg: #8a6212;
  --st-bl-bg: #ffe3e9;  --st-bl-fg: #a83a58;
  --st-dn-bg: #dbf3e5;  --st-dn-fg: #1c7048;

  --sig-over-bg: #ffe3e9; --sig-over-fg: #a83a58;
  --sig-soon-bg: #fff2d3; --sig-soon-fg: #8a6212;

  --g1: #3b82f6; --g2: #8b5cf6; --g3: #12876a; --g4: #d9770a;

  --pj-radius-sm: 4px;
  --pj-radius-md: 6px;
  --pj-radius-pill: 99px;
  --pj-shadow-pop: 0 14px 40px -12px rgba(20, 30, 50, 0.22);
  --pj-row-h: 44px;
  --pj-motion-fast: 120ms;
  --pj-motion: 180ms;
  --pj-motion-slow: 260ms;
  --pj-ease: var(--ease-smooth, cubic-bezier(0.2, 0.9, 0.2, 1));
  --pj-shadow-rail: 0 1px 2px rgba(20, 30, 50, 0.05);

  /* roles the Option B components introduced */
  --pj-accent-line: var(--green-200, #bbf7d0);
  --pj-on-accent: #ffffff;
  --pj-depth-1: #fafbfc;
  --pj-depth-2: #f6f8fa;
  --pj-depth-3: #f1f4f8;
  --pj-depth-4: #edf1f6;
  --pj-inverse-bg: #1e293b;
  --pj-inverse-raised: #334155;
  --pj-inverse-line: #475569;
  --pj-inverse-fg: #ffffff;

  /* Saturated fills for the Monday-style full-cell status blocks. Each clears
     4.5:1 against its own white text -- monday's own #FFCC00 on white is ~1.5:1
     and is a long-standing accessibility complaint, so amber goes deeper. */
  /* direction to push a group hue for legible text, per theme */
  --pj-hue-toward: #0b1020;
  --pj-hue-amount: 50%;
  --st-ns-solid: #94a3b8;  --st-ns-on: #333b4a;
  --st-ip-solid: #f59e0b;  --st-ip-on: #4a2e00;
  --st-bl-solid: #ef4444;  --st-bl-on: #ffffff;
  --st-dn-solid: var(--green-600, #1b8a4f);  --st-dn-on: #00351f;

  /* Legacy aliases for backward compatibility */
  --projects-ink: var(--pj-ink);
  --projects-muted: var(--pj-muted);
  --projects-line: var(--pj-line);
  --projects-blue: var(--pj-accent);

  color: var(--pj-ink);
  color-scheme: light;
}
.crm-projects-workspace-shell {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr) auto;
  min-height: calc(100vh - 150px);
  background: var(--pj-surface);
  border: 1px solid var(--pj-line);
  border-radius: 9px;
  overflow: clip;
}
#projects-workspace-rail {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 24px 13px;
  background: var(--pj-raised);
  border-right: 1px solid var(--pj-line);
}
.crm-projects-workspace-brand { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 650; margin: 0 7px 20px; }
.crm-projects-workspace-brand > span { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 7px; background: var(--pj-accent-soft); color: var(--pj-accent-ink); }
.crm-projects-workspace-rail-heading { padding: 0 10px; color: var(--pj-faint); font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: 1.3px; }
#projects-workspace-projects { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
#projects-workspace-projects button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  border-radius: var(--pj-radius-md);
  padding: 11px 10px;
  background: transparent;
  color: var(--pj-ink-2);
  font: inherit;
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}
#projects-workspace-projects button::before { content: ''; flex: 0 0 8px; width: 8px; height: 8px; border-radius: 3px; background: var(--crm-project-group-color, var(--g1)); }
#projects-workspace-projects button:nth-child(3n + 2)::before { background: var(--g2); }
#projects-workspace-projects button:nth-child(3n)::before { background: var(--g3); }
#projects-workspace-projects button:hover { background: var(--pj-sunken); }
#projects-workspace-projects button[aria-current="page"],
#projects-workspace-projects button[aria-selected="true"],
#projects-workspace-projects button.is-selected { color: var(--pj-accent-ink); background: var(--pj-accent-soft); font-weight: 650; }
#projects-workspace-rail #btn-projects-board-create-project { margin: 4px 8px; background: transparent; border: 1px dashed var(--pj-line-strong); color: var(--pj-accent-ink); box-shadow: none; }
.crm-projects-workspace-rail-footer { margin-top: auto; padding: 24px 8px 0; }
#projects-workspace-main { min-width: 0; padding: 14px 28px 36px; }
.crm-projects-workspace-breadcrumb { display: flex; align-items: center; gap: 10px; color: var(--pj-faint); font-size: 11px; margin-bottom: 4px; }
#projects-workspace-rail-toggle { display: none; }
.crm-projects-workspace-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 2px; padding: 0; border: 0; }
.crm-projects-workspace-heading > div:first-child { min-width: 0; }
[data-panel="projects"] #projects-workspace-name { margin: 0; color: var(--pj-ink); font-size: 22px; line-height: 1.3; letter-spacing: -.5px; font-weight: 700; overflow-wrap: anywhere; }
#projects-workspace-description { color: var(--pj-muted); font-size: 11px; line-height: 1.5; margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere;  }
.crm-projects-workspace-heading-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; flex: 0 0 auto; }
[data-panel="projects"] :is(.crm-btn-primary, .crm-btn-secondary) { min-height: 32px; border-radius: var(--pj-radius-md); font-size: 12px; padding: 6px 11px; box-shadow: none; font-weight: 550; }
[data-panel="projects"] .crm-btn-primary { background: var(--pj-accent); border-color: var(--pj-accent); color: var(--pj-on-accent); }
[data-panel="projects"] .crm-btn-primary:hover:not(:disabled) { background: var(--pj-accent-ink); }
[data-panel="projects"] .crm-btn-secondary { background: var(--pj-surface); border: 1px solid var(--pj-line); color: var(--pj-muted); }
[data-panel="projects"] .crm-btn-secondary:hover:not(:disabled) { background: var(--pj-sunken); color: var(--pj-accent-ink); }
[data-panel="projects"] button:disabled { cursor: not-allowed; opacity: .55; }
[data-panel="projects"] :is(button, summary, input, select, textarea):focus-visible { outline: 2px solid var(--pj-accent); outline-offset: 3px; }
[data-panel="projects"] .crm-projects-board-section { padding: 0; min-width: 0; }
#projects-board-status { font-size: 11px; color: var(--pj-faint); line-height: 1.5; margin: 0 0 6px; }
#projects-board-workspace { margin-top: 4px; min-width: 0; }
#projects-views { min-width: 0; }
.crm-projects-view-tabs { display: flex; flex-wrap: nowrap; gap: 24px; padding: 0; margin: 0 0 8px; border-bottom: 1px solid var(--pj-line); min-height: 38px; overflow-x: auto; }
.crm-projects-view-tabs button { flex: 0 0 auto; padding: 10px 1px; font-size: 12px; border-radius: 0; color: var(--pj-muted); border-bottom: 2px solid transparent; }
.crm-projects-view-tabs button[aria-pressed="true"] { border-bottom-color: var(--pj-accent); color: var(--pj-accent-ink); background: transparent; font-weight: 650; }
.crm-projects-view-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.crm-projects-view-filters > .crm-projects-workspace-search { flex: 1 1 150px; min-width: 110px; max-width: 260px; }
.crm-projects-workspace-search input.crm-input { border-color: transparent; background: transparent; padding: 7px 9px; font-size: 12px; min-height: 32px; border-radius: var(--pj-radius-md); }
.crm-projects-workspace-search input.crm-input:hover { background: var(--pj-raised); border-color: var(--pj-line); }
.crm-projects-workspace-filter { position: relative; flex: 0 0 auto; }
.crm-projects-workspace-filter > summary { display: flex; align-items: center; gap: 7px; list-style: none; cursor: pointer; color: var(--pj-muted); font-size: 12px; padding: 7px 10px; border-radius: var(--pj-radius-md); }
.crm-projects-workspace-filter > summary::before { content: '☷'; font-size: 15px; color: var(--pj-faint); }
.crm-projects-workspace-filter > summary::-webkit-details-marker { display: none; }
.crm-projects-workspace-filter[open] > summary { color: var(--pj-accent-ink); background: var(--pj-accent-soft); }
.crm-projects-workspace-filter-popover { position: absolute; z-index: 15; top: calc(100% + 8px); right: 0; width: min(408px, calc(100vw - 64px)); padding: 14px 16px 12px; border: 1px solid var(--pj-line); border-radius: 12px; background: var(--pj-surface); box-shadow: var(--pj-shadow-pop); display: flex; flex-direction: column; gap: 13px; max-height: min(560px, calc(100dvh - 190px)); overflow-y: auto; overscroll-behavior: contain; }
.crm-projects-workspace-filter-popover label { min-width: 0; font-size: 11px; color: var(--pj-muted); }
.crm-projects-workspace-filter-popover .crm-input { padding: 7px 9px; min-height: 32px; font-size: 12px; }
.crm-projects-workspace-filter-popover p { font-size: 10px; line-height: 1.55; margin: 0; }
#btn-projects-board-add-column { margin-left: auto; }
.crm-projects-board-controls { margin: 0; min-height: 0; justify-content: flex-end; }
#projects-board-count, #projects-view-summary, #projects-view-status { font-size: 10px; color: var(--pj-faint); margin: 1px 0 3px; line-height: 1.5; }
#projects-board-status:empty, #projects-board-count:empty, #projects-view-summary:empty, #projects-view-status:empty { display: none; }
.crm-projects-board-table-wrap { position: relative; border: 1px solid var(--pj-line); border-radius: 6px; overflow-x: auto; overscroll-behavior-x: contain; width: 100%; max-width: 100%; }
.crm-projects-board-header { min-height: 36px; height: 36px; font-size: 11px; font-weight: 450; text-transform: none; letter-spacing: 0; background: var(--pj-raised); color: var(--pj-muted); border-bottom-color: var(--pj-line); }
.crm-projects-board-header > div { border-right: 1px solid transparent; height: 100%; padding: 8px 10px; display: flex; align-items: center; }
.crm-projects-board-header > div button { border: 0; background: transparent; color: var(--pj-faint); font-size: 10px; padding: 2px; }
.crm-projects-board-row { height: var(--pj-row-h); min-height: var(--pj-row-h); border-bottom-color: var(--pj-line); box-shadow: inset 3px 0 var(--crm-project-group-color, var(--pj-accent)); }
.crm-projects-board-row > div { height: 100%; border-right: 1px solid transparent; padding: 7px 9px; }
.crm-projects-board-row:hover, .crm-projects-board-row:focus-within { background: var(--pj-raised); }
.crm-projects-board-row.is-selected { background: var(--pj-accent-soft); box-shadow: inset 3px 0 var(--crm-project-group-color, var(--pj-accent)); }
.crm-projects-board-row.is-pending { background: var(--st-ip-bg); }
.crm-projects-board-row.is-drop-target { box-shadow: inset 0 -3px var(--pj-accent); }
.crm-projects-board-row.is-drop-parent { box-shadow: inset 0 0 0 2px var(--pj-accent-line); }
.crm-projects-board-row :is(input:not([type="checkbox"]), select) { height: 30px; border: 1px solid transparent; border-radius: var(--pj-radius-sm); padding: 4px 6px; font: inherit; font-size: 12px; color: var(--pj-ink-2); background-color: transparent; box-shadow: none; }
.crm-projects-board-row :is(input:not([type="checkbox"]), select):hover { border-color: var(--pj-line-strong); }
.crm-projects-board-row :is(input:not([type="checkbox"]), select):focus { border-color: var(--pj-accent); background-color: var(--pj-surface); outline-offset: 1px; }
.crm-projects-board-row input[type="checkbox"] { flex: 0 0 13px; width: 13px; height: 13px; accent-color: var(--pj-accent); margin: 0 2px 0 0; }
.crm-projects-board-task-title { gap: 3px; font-size: 12px; position: relative; }
.crm-board-tree-elbow {
  display: inline-block;
  width: 14px;
  height: 20px;
  margin-right: 4px;
  margin-left: -16px;
  border-left: 1.5px solid var(--pj-faint);
  border-bottom: 1.5px solid var(--pj-faint);
  border-bottom-left-radius: 4px;
  flex: 0 0 14px;
  vertical-align: middle;
  pointer-events: none;
  opacity: 0.75;
}
.crm-board-depth-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  height: 16px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--pj-line);
  color: var(--pj-ink-2);
  margin-right: 4px;
  flex: 0 0 auto;
  pointer-events: none;
}
.crm-projects-board-row[data-depth="1"]:not(:hover):not(:focus-within):not(.is-selected):not(.is-pending) { background: var(--pj-depth-1); }
.crm-projects-board-row[data-depth="2"]:not(:hover):not(:focus-within):not(.is-selected):not(.is-pending) { background: var(--pj-depth-2); }
.crm-projects-board-row[data-depth="3"]:not(:hover):not(:focus-within):not(.is-selected):not(.is-pending) { background: var(--pj-depth-3); }
.crm-projects-board-row[data-depth="4"]:not(:hover):not(:focus-within):not(.is-selected):not(.is-pending) { background: var(--pj-depth-4); }
/* Depth already reads from the indent, the elbow and the L-number; a third
   per-level hue only added noise, so every chip shares one quiet tone. */
.crm-board-expander { width: 18px; color: var(--pj-faint); border: 0; background: transparent; cursor: pointer; padding: 0; }
.crm-board-expander:hover { color: var(--pj-ink); }
.crm-board-drag-handle { width: 17px; color: var(--pj-line-strong); font-size: 13px; opacity: 0.6; cursor: grab; transition: opacity .16s ease; }
.crm-board-detail-button { flex: 0 0 24px; border: 0; background: none; color: var(--pj-faint); padding: 3px; font-size: 12px; cursor: pointer; opacity: 0.65; transition: opacity .16s ease, color .16s ease; }
/* Creating a subtask used to be Ctrl+N only, with no visible control anywhere.
   This is the affordance; it follows the drag handle's reveal-on-approach idiom. */
.crm-board-add-subtask {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--pj-radius-sm);
  background: none;
  color: var(--pj-faint);
  padding: 0;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--pj-motion-fast) var(--pj-ease), background-color var(--pj-motion-fast) var(--pj-ease), color var(--pj-motion-fast) var(--pj-ease);
}
.crm-projects-board-row:hover .crm-board-add-subtask,
.crm-projects-board-row:focus-within .crm-board-add-subtask,
.crm-board-add-subtask:focus-visible { opacity: 1; }
.crm-board-add-subtask:hover { background: var(--pj-accent-soft); color: var(--pj-accent-ink); }
.crm-board-add-subtask:disabled { opacity: 0; pointer-events: none; }
.crm-board-detail-button:hover { color: var(--pj-accent); }
.crm-projects-board-row:hover .crm-board-drag-handle,
.crm-projects-board-row:focus-within .crm-board-drag-handle,
.crm-projects-board-row:hover .crm-board-detail-button,
.crm-projects-board-row:focus-within .crm-board-detail-button,
.crm-projects-board-row.is-selected .crm-board-detail-button { opacity: 1; }

.crm-board-progress-ring {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: conic-gradient(var(--st-dn-fg, #1c7048) var(--pj-pct, 0%), var(--pj-line, #e4e9f1) var(--pj-pct, 0%) 100%);
  position: relative;
  vertical-align: middle;
  flex: 0 0 14px;
  margin-right: 4px;
  pointer-events: none;
}
.crm-board-progress-ring::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--pj-surface, #fff);
}

.crm-projects-board-section-row { position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding-right: 12px; min-height: var(--pj-row-h); height: var(--pj-row-h); text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 650; background: var(--pj-surface); color: var(--crm-project-group-color, var(--pj-accent)); border-left: 3px solid var(--crm-project-group-color, var(--pj-accent)); border-bottom: 1px solid var(--pj-line); }
.crm-projects-board-section-row > div { display: flex; align-items: center; gap: 6px; min-width: 0; }
.crm-board-group-expander { flex: 0 0 22px; color: inherit; padding: 2px; border: 0; background: none; cursor: pointer; }
.crm-board-group-title { color: inherit; font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-projects-board-section-row input { min-width: 0; width: 100%; border: 1px solid transparent; background: transparent; border-radius: var(--pj-radius-sm); color: inherit; font: inherit; padding: 4px 5px; }
.crm-projects-board-section-row input:hover { border-color: var(--pj-line-strong); }
.crm-projects-board-section-row .crm-muted { color: var(--pj-faint); font-size: 10px; font-weight: 400; }

/* Compact status pills retain the native, keyboard-editable select. */
.crm-projects-board-row .crm-board-status-cell { display: flex; align-items: center; position: relative; padding: 6px 8px; }
.crm-projects-board-row select.crm-board-field[data-status] {
  appearance: none; -webkit-appearance: none; width: 100%; max-width: 100%;
  height: 28px; border: 0; border-radius: var(--pj-radius-pill);
  padding: 0 12px 0 22px; font-size: 11px; font-weight: 600;
  text-align: left; text-align-last: left; cursor: pointer;
  transition: filter var(--pj-motion-fast) var(--pj-ease);
}
.crm-projects-board-row .crm-board-status-cell select:hover { filter: brightness(1.07); }
.crm-projects-board-row .crm-board-status-cell::after {
  content: "";
  position: absolute;
  right: 7px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -5px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--pj-motion-fast) var(--pj-ease);
}
.crm-projects-board-row:hover .crm-board-status-cell::after,
.crm-board-status-cell:focus-within::after { opacity: .75; }
.crm-board-status-cell[data-status="not_started"] { color: var(--st-ns-fg); }
.crm-board-status-cell[data-status="in_progress"] { color: var(--st-ip-fg); }
.crm-board-status-cell[data-status="blocked"] { color: var(--st-bl-fg); }
.crm-board-status-cell[data-status="done"] { color: var(--st-dn-fg); }
/* Status pills: soft background with colored indicator dot */
.crm-board-status-cell[data-status="not_started"] select,
select.crm-board-field[data-status="not_started"] { background: var(--st-ns-bg); color: var(--st-ns-fg); border-radius: var(--pj-radius-pill); font-weight: 600; font-size: 11px; padding-left: 22px; }
.crm-board-status-cell[data-status="in_progress"] select,
select.crm-board-field[data-status="in_progress"] { background: var(--st-ip-bg); color: var(--st-ip-fg); border-radius: var(--pj-radius-pill); font-weight: 600; font-size: 11px; padding-left: 22px; }
.crm-board-status-cell[data-status="blocked"] select,
select.crm-board-field[data-status="blocked"] { background: var(--st-bl-bg); color: var(--st-bl-fg); border-radius: var(--pj-radius-pill); font-weight: 600; font-size: 11px; padding-left: 22px; }
.crm-board-status-cell[data-status="done"] select,
select.crm-board-field[data-status="done"] { background: var(--st-dn-bg); color: var(--st-dn-fg); border-radius: var(--pj-radius-pill); font-weight: 600; font-size: 11px; padding-left: 22px; }
/* Colored indicator dot inside status pills */
.crm-board-status-cell[data-status]::before {
  content: ""; position: absolute; left: 16px; top: 50%; width: 8px; height: 8px;
  border-radius: 50%; transform: translateY(-50%); z-index: 1; pointer-events: none;
}
.crm-board-status-cell[data-status="not_started"]::before { background: var(--st-ns-solid); }
.crm-board-status-cell[data-status="in_progress"]::before { background: var(--st-ip-solid); }
.crm-board-status-cell[data-status="blocked"]::before { background: var(--st-bl-solid); }
.crm-board-status-cell[data-status="done"]::before { background: var(--st-dn-solid); }
/* Native option lists inherit the fill otherwise, which is unreadable. */
.crm-projects-board-row .crm-board-status-cell select option { background: var(--pj-surface); color: var(--pj-ink); }
/* The rollup battery has to read on top of a saturated fill. */
.crm-board-status-cell[data-status] .crm-board-status-battery {
  background: color-mix(in srgb, currentColor 22%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, currentColor 18%, transparent);
}

select.crm-board-field[data-value="urgent"] { background: var(--sig-over-bg); color: var(--sig-over-fg); border-radius: 6px; font-weight: 600; font-size: 11px; appearance: none; -webkit-appearance: none; }
select.crm-board-field[data-value="high"] { background: var(--sig-soon-bg); color: var(--sig-soon-fg); border-radius: 6px; font-weight: 600; font-size: 11px; appearance: none; -webkit-appearance: none; }
select.crm-board-field[data-value="medium"] { background: var(--pj-accent-soft); color: var(--pj-accent-ink); border-radius: 6px; font-weight: 600; font-size: 11px; appearance: none; -webkit-appearance: none; }
select.crm-board-field[data-value="low"] { background: var(--pj-sunken); color: var(--pj-muted); border-radius: 6px; font-weight: 600; font-size: 11px; appearance: none; -webkit-appearance: none; }
select.crm-board-field[data-value="none"] { color: var(--pj-faint); }

.crm-board-owner-cell { display: flex; align-items: center; gap: 4px; }
.crm-board-owner-avatar { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 24px; width: 24px; height: 24px; border-radius: 50%; background: var(--pj-accent-soft); color: var(--pj-accent-ink); font-size: 9.5px; font-weight: 700; border: 2px solid var(--pj-surface); pointer-events: none; }
.crm-board-owner-cell select { flex: 1 1 auto; min-width: 0; appearance: none; -webkit-appearance: none; cursor: pointer; }

.crm-board-assignees-cell { position: relative; display: flex; align-items: center; }
.crm-board-people-stack { display: inline-flex; align-items: center; pointer-events: none; z-index: 1; }
.crm-board-avatar { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--pj-sunken); color: var(--pj-ink-2); font-size: 9.5px; font-weight: 700; border: 2px solid var(--pj-surface); margin-left: -7px; }
.crm-board-avatar:first-child { margin-left: 0; }
.crm-board-avatar-more { background: transparent; color: var(--pj-faint); font-weight: 600; border: 1.5px dashed var(--pj-line-strong); }
.crm-board-assignees-cell .crm-board-people-field { position: absolute; inset: 2px 4px; width: calc(100% - 8px); height: calc(100% - 4px); opacity: 0; background: transparent; border: 1px solid transparent; cursor: pointer; z-index: 2; transition: opacity var(--pj-motion-fast, 120ms) var(--pj-ease, ease); }
.crm-board-assignees-cell:hover .crm-board-people-field,
.crm-board-assignees-cell:focus-within .crm-board-people-field { opacity: 1; color: var(--pj-ink); background: var(--pj-surface); border-color: var(--pj-line-strong); box-shadow: var(--pj-shadow-pop); z-index: 10; height: auto; min-height: 56px; }
.crm-board-assignees-cell:hover .crm-board-people-stack,
.crm-board-assignees-cell:focus-within .crm-board-people-stack { opacity: 0; }

.crm-board-date-cell { display: flex; align-items: center; gap: 4px; }
.crm-board-date-cell input[type="date"] { font-size: 11px; font-variant-numeric: tabular-nums; padding: 3px 5px; color: var(--pj-muted); width: calc(50% - 2px); border: 1px solid transparent; background: transparent; }
.crm-board-date-cell input[type="date"]::-webkit-calendar-picker-indicator { opacity: 0; cursor: pointer; }
.crm-board-date-cell:hover input[type="date"]::-webkit-calendar-picker-indicator,
.crm-board-date-cell:focus-within input[type="date"]::-webkit-calendar-picker-indicator { opacity: 0.7; }
/* Badges trail the date inputs; leading them made the inputs a different
   width on every row depending on whether a due state was present. */
.crm-board-date-cell .crm-board-due-badge,
.crm-board-date-cell .crm-board-duration-badge { order: 2; margin-left: auto; }
.crm-board-date-cell input[type="date"] { flex: 0 1 auto; min-width: 0; }
.crm-board-due-badge { display: inline-flex; align-items: center; padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 600; pointer-events: none; white-space: nowrap; flex: 0 0 auto; }
.crm-board-due-overdue { background: var(--sig-over-bg); color: var(--sig-over-fg); }
.crm-board-due-soon { background: var(--sig-soon-bg); color: var(--sig-soon-fg); }
.crm-projects-workspace-utility { margin: 15px 0 0; min-width: 0; }
.crm-projects-workspace-utility > summary { cursor: pointer; font-size: 11px; color: var(--pj-muted); padding: 8px 0; }
.crm-projects-workspace-utility > :is(section, .crm-projects-assistant) { border-radius: 0; box-shadow: none; padding: 14px 0; margin: 8px 0; border-width: 1px 0 0; background: transparent; }
.crm-projects-workspace-onboarding, .crm-projects-board-empty { padding: 48px 22px; margin: 18px 0; border: 1px dashed var(--pj-line-strong); border-radius: 8px; background: var(--pj-surface); text-align: center; }
.crm-projects-board-empty { flex-direction: column; justify-content: center; }
.crm-projects-board-empty button { margin-left: 0; }
.crm-projects-workspace-onboarding h3 { font-size: 20px; color: var(--pj-ink); margin: 0 0 10px; }
.crm-projects-workspace-onboarding p, .crm-projects-board-empty span { font-size: 13px; color: var(--pj-muted); line-height: 1.6; }
[data-panel="projects"] dialog[data-projects-dialog] { box-sizing: border-box; position: fixed; inset: 0 0 0 auto; width: min(620px, 94vw); max-width: 94vw; height: 100dvh; max-height: 100dvh; margin: 0; padding: 26px; border: 0; border-left: 1px solid var(--pj-line); border-radius: 0; background: var(--pj-surface); color: var(--pj-ink); box-shadow: -15px 0 60px rgba(25, 43, 69, 0.11); overflow: auto; }
[data-panel="projects"] dialog[data-projects-dialog]::backdrop { background: rgba(24, 42, 66, 0.22); }
[data-panel="projects"] dialog[data-projects-dialog]:not([open]), [data-panel="projects"] [hidden] { display: none !important; }
[data-panel="projects"] dialog.crm-projects-board-form[open] { display: grid; grid-template-columns: 1fr; align-content: start; align-items: start; gap: 12px; }
[data-panel="projects"] dialog.crm-projects-board-form .crm-inline-fields { grid-column: 1; margin-top: 10px; }
[data-panel="projects"] dialog label { color: var(--pj-muted); font-size: 12px; }
[data-panel="projects"] dialog .crm-input { min-width: 0; max-width: 100%; border-radius: var(--pj-radius-md); border-color: var(--pj-line); font-size: 13px; }
[data-panel="projects"] dialog :is(.crm-projects-board-settings, .crm-projects-access-section) { padding-top: 8px; margin-top: 0; border-top: 0; }
.crm-projects-workspace-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.crm-projects-workspace-dialog-heading h3 { font-size: 19px; margin: 0; }
.crm-projects-workspace-settings-tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--pj-line); margin-bottom: 22px; overflow-x: auto; }
.crm-projects-workspace-settings-tabs button { border: 0; border-bottom: 2px solid transparent; background: none; color: var(--pj-muted); padding: 10px 0; font: inherit; font-size: 12px; cursor: pointer; }
.crm-projects-workspace-settings-tabs button[aria-selected="true"] { color: var(--pj-accent); border-bottom-color: var(--pj-accent); }
[data-panel="projects"] dialog .crm-section-header h3, [data-panel="projects"] dialog .crm-section-header h4 { font-size: 15px; margin: 3px 0 8px; }
[data-panel="projects"] dialog .crm-muted { font-size: 12px; line-height: 1.6; }
[data-panel="projects"] dialog .crm-projects-board-settings-grid { grid-template-columns: 1fr; gap: 9px; }
[data-panel="projects"] dialog .crm-projects-board-settings-grid button { grid-column: 1; justify-self: start; }
[data-panel="projects"] dialog .crm-table-container { max-width: 100%; overflow: auto; }
[data-panel="projects"] dialog .crm-ai-budget { margin: 0 0 20px; padding: 0 0 16px; }
[data-panel="projects"] dialog .crm-projects-board-detail-head { align-items: flex-start; }
[data-panel="projects"] dialog .crm-projects-board-detail-head h4 { font-size: 20px; margin: 5px 0; overflow-wrap: anywhere; }
#projects-board-section-form { padding: 12px 0; border-radius: 0; border-width: 1px 0; background: var(--pj-surface); }
/* ---------- Responsive ladder ----------
   >=1700  three columns, utility rail inline
   <1700   utility rail overlays the board instead of squeezing it
   <1100   project rail overlays behind the hamburger
   <700    single column; dialogs and popovers go full width
   Below 1700 the board reclaims ~310px, which is the difference between
   "all base columns visible" and "horizontal scroll on a laptop". */
@media (max-width: 1700px) {
  .crm-projects-workspace-shell { position: relative; grid-template-columns: 216px minmax(0, 1fr); padding-right: 49px; }
  .crm-projects-utility-rail { position: absolute; top: 0; right: 0; height: 100%; width: 49px; z-index: 30; }
  .crm-projects-utility-rail:not(.collapsed) { width: 312px; box-shadow: -14px 0 34px rgba(25, 43, 69, 0.13); }
  #projects-workspace-main { padding: 14px 22px 32px; }
}
@media (max-width: 1100px) {
  .crm-projects-workspace-shell { grid-template-columns: minmax(0, 1fr); }
  #projects-workspace-rail { display: none; position: absolute; z-index: 40; inset: 0 auto 0 0; width: 220px; box-shadow: 10px 0 30px rgba(37, 57, 80, 0.14); }
  #projects-workspace-rail.is-open, .crm-projects-workspace-shell.is-rail-open #projects-workspace-rail, #projects-workspace-rail[data-open="true"] { display: flex; }
  #projects-workspace-rail-toggle { display: inline-flex; padding: 3px 7px; min-height: 26px; }
  #projects-workspace-main { padding: 20px 18px 30px; }
  .crm-projects-workspace-heading { flex-wrap: wrap; }
  .crm-projects-workspace-heading-actions { justify-content: flex-start; }
}
@media (max-width: 700px) {
  .crm-projects-workspace-shell { margin-inline: -20px; border-radius: 0; min-height: calc(100vh - 130px); }
  .crm-projects-utility-rail:not(.collapsed) { width: min(312px, calc(100vw - 40px)); }
  #projects-workspace-main { padding: 12px 10px 26px; }
  [data-panel="projects"] #projects-workspace-name { font-size: 22px; }
  .crm-projects-workspace-heading { gap: 8px; }
  .crm-projects-workspace-heading-actions { gap: 4px; flex: 1 1 100%; min-width: 0; max-width: 100%; }
  .crm-projects-workspace-heading-actions .crm-btn-secondary { font-size: 11px; padding: 5px 8px; }
  #projects-workspace-description { font-size: 11px; margin-bottom: 5px; }
  .crm-projects-view-tabs { gap: 20px; }
  .crm-projects-view-filters { gap: 6px; }
  .crm-projects-view-filters > .crm-projects-workspace-search { min-width: 100px; flex: 1 1 100px; }
  #btn-projects-board-add-section, #btn-projects-board-add-column { margin-left: 0; }
  .crm-projects-workspace-filter-popover { position: fixed; inset: 160px 16px auto; width: auto; max-height: calc(100dvh - 190px); overflow: auto; grid-template-columns: 1fr; }
  .crm-projects-workspace-filter-popover label { min-width: 0; }
  [data-panel="projects"] dialog[data-projects-dialog] { width: 100vw; max-width: 100vw; padding: 22px 18px; }
  .crm-projects-workspace-settings-tabs { gap: 20px; }
}

/* Keep semantic labels available without adding toolbar or heading rows. */
[data-panel="projects"] .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[data-panel="projects"] #projects-workspace-name { text-align: left; margin-left: 0; }

[data-panel="projects"].crm-projects-access-needed #projects-board-section { display: none; }
[data-panel="projects"] .crm-projects-rail-empty { font-size: 12px; color: var(--pj-muted); line-height: 1.6; padding: 0 10px; }
[data-panel="projects"] .crm-board-people-field { padding-top: 0; padding-bottom: 0; }
[data-panel="projects"] .crm-board-people-field option { min-height: 28px; }

/* ---------- Theme & Density Modes ---------- */
[data-panel="projects"].projects-dark {
  color-scheme: dark;
  --pj-ground: #0d1117;
  --pj-surface: #141a22;
  --pj-raised: #1a212b;
  --pj-sunken: #1e2733;
  --pj-line: #242e3b;
  --pj-line-strong: #33404f;
  --pj-ink: #e7ecf4;
  --pj-ink-2: #b3c0d2;
  --pj-muted: #9dabc0;
  --pj-faint: #8e9bb0;
  --pj-accent: #4ade80;
  --pj-accent-soft: #052e16;
  --pj-accent-ink: #86efac;
  --st-ns-bg: #232c39;
  --st-ns-fg: #93a1b6;
  --st-ip-bg: #3a2f13;
  --st-ip-fg: #f0c264;
  --st-bl-bg: #3d1d26;
  --st-bl-fg: #ff9bad;
  --st-dn-bg: #12321f;
  --st-dn-fg: #6bd79b;
  --sig-over-bg: #3d1d26;
  --sig-over-fg: #ff9bad;
  --sig-soon-bg: #3a2f13;
  --sig-soon-fg: #f0c264;
  --g1: #5b9bff;
  --g2: #a78bfa;
  --g3: #34d3a4;
  --g4: #f5a742;
  --pj-shadow-pop: 0 18px 46px -14px rgba(0, 0, 0, 0.7);
  --pj-shadow-rail: 0 1px 2px rgba(0, 0, 0, 0.4);
  --pj-accent-line: #2c4570;
  --pj-on-accent: #08111f;
  --pj-depth-1: #171e27;
  --pj-depth-2: #1a212b;
  --pj-depth-3: #1d2530;
  --pj-depth-4: #202935;
  --pj-inverse-bg: #e7ecf4;
  --pj-inverse-raised: #cfd8e6;
  --pj-inverse-line: #aebbcd;
  --pj-inverse-fg: #0d1117;
  --pj-hue-toward: #ffffff;
  --pj-hue-amount: 42%;
  --st-ns-solid: #59637a;  --st-ns-on: #eef2f8;
  --st-ip-solid: #f0a53c;  --st-ip-on: #3d2400;
  --st-bl-solid: #e2445f;  --st-bl-on: #ffffff;
  --st-dn-solid: #12b06a;  --st-dn-on: #00301b;

  /* Rules in style.css and crm-admin.css reach into this panel, one of them
     with !important. Remap the tokens they read so they resolve to this
     panel's dark palette instead of the app's light one. */
  --text-primary: var(--pj-ink);
  --text-secondary: var(--pj-ink-2);
  --text-muted: var(--pj-muted);
  --text-main: var(--pj-ink);
  --crm-text: var(--pj-ink);
  --crm-text-main: var(--pj-ink);
  --crm-text-dark: var(--pj-ink);
  --crm-text-muted: var(--pj-muted);
  --crm-border: var(--pj-line);
  --crm-border-light: var(--pj-line);
  --crm-surface: var(--pj-surface);
  --crm-surface-dim: var(--pj-raised);
  --crm-surface-input: var(--pj-sunken);
  --crm-bg: var(--pj-ground);
  --bg-card: var(--pj-surface);
  --bg-input: var(--pj-sunken);
  --bg-surface: var(--pj-surface);
  --bg-main: var(--pj-ground);
  --border-default: var(--pj-line);
  --border-light: var(--pj-line);
  background: var(--pj-ground);
  color: var(--pj-ink);
}

.crm-projects-board-table-wrap.is-compact {
  --pj-row-h: 36px;
}
.crm-projects-board-table-wrap.is-compact .crm-projects-board-row :is(input:not([type="checkbox"]), select) {
  height: 24px;
  font-size: 11px;
  padding: 2px 4px;
}
.crm-projects-board-table-wrap.is-compact .crm-board-owner-avatar,
.crm-projects-board-table-wrap.is-compact .crm-board-avatar {
  width: 20px;
  height: 20px;
  font-size: 8px;
}

/* Subtle loading progress bar across the top of the board */
.crm-projects-board-table-wrap.is-loading::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--pj-accent), transparent);
  background-size: 200% 100%;
  animation: pj-shimmer 1.2s infinite;
  z-index: 10;
}
/* Initial placeholders are outside the authorization-gated workspace. */
.crm-projects-initial-loading:not([hidden]) { display: grid; gap: 1px; padding-top: 12px; }
.crm-projects-initial-loading > span { height: var(--pj-row-h); border-bottom: 1px solid var(--pj-line); background: linear-gradient(90deg, var(--pj-raised), var(--pj-surface), var(--pj-raised)); background-size: 200% 100%; animation: pj-shimmer 1.5s infinite; }
@media (prefers-reduced-motion: reduce) {
  .crm-projects-initial-loading > span, .crm-projects-board-table-wrap.is-loading::before { animation: none !important; }
}
@keyframes pj-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.crm-projects-filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--pj-accent);
  color: var(--pj-on-accent);
  font-size: 10px;
  font-weight: 700;
  margin-left: 4px;
  line-height: 1;
}

/* ---------- KANBAN ---------- */
.crm-projects-kanban { display: grid; grid-template-columns: repeat(4, minmax(232px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.crm-projects-kanban-col { display: flex; flex-direction: column; gap: 9px; min-height: 330px; border-radius: 9px; padding: 10px; background: var(--pj-raised); border: 1px solid transparent; transition: background .16s var(--pj-ease), border-color .16s var(--pj-ease); }
.crm-projects-kanban-col.over { background: var(--pj-accent-soft); border-color: var(--pj-accent); border-style: dashed; }
.crm-projects-kanban-col > header > header { display: flex; align-items: center; gap: 8px; padding: 2px 4px 8px; border-bottom: 1px solid var(--pj-line); }
.crm-projects-kanban-col > header .crm-projects-status-pill > header .crm-projects-status-pill { padding: 2px 8px; }
.crm-projects-kanban-col > header b > header b { margin-left: auto; font-size: 10.5px; color: var(--pj-faint); font-variant-numeric: tabular-nums; }
.crm-projects-kanban-cards { display: flex; flex-direction: column; gap: 9px; flex: 1; }
.crm-projects-kanban-card { border: 1px solid var(--pj-line); border-radius: 8px; background: var(--pj-surface); padding: 10px 11px; display: flex; flex-direction: column; gap: 8px; cursor: grab; box-shadow: var(--pj-shadow-rail, 0 1px 2px rgba(0,0,0,0.05)); transition: box-shadow .16s var(--pj-ease), transform .16s var(--pj-ease), opacity .16s var(--pj-ease); }
.crm-projects-kanban-card:hover { box-shadow: var(--pj-shadow-pop, 0 14px 30px -10px rgba(0,0,0,0.15)); transform: translateY(-1px); }
.crm-projects-kanban-card.drag { opacity: .4; }
.crm-projects-kanban-card .crm-projects-kanban-title { font-size: 12.5px; line-height: 1.4; font-weight: 500; }
.crm-projects-kanban-card .crm-projects-task-open { background: none; border: none; padding: 0; font: inherit; font-size: 12.5px; line-height: 1.4; font-weight: 500; color: var(--pj-ink); text-align: left; cursor: pointer; width: 100%; }
.crm-projects-kanban-card .crm-projects-task-open:hover { color: var(--pj-accent); text-decoration: underline; }
.crm-projects-kanban-card .crm-projects-kanban-sec { font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--pj-accent-ink); font-weight: 600; }
.crm-projects-kanban-card .crm-projects-kanban-progress { display: flex; align-items: center; gap: 7px; width: 100%; }
.crm-projects-kanban-card .crm-projects-kanban-progress .track { flex: 1; height: 4px; border-radius: 99px; background: var(--pj-sunken); overflow: hidden; }
.crm-projects-kanban-card .crm-projects-kanban-progress .track i { display: block; height: 100%; background: var(--pj-accent); border-radius: 99px; transition: width .4s var(--pj-ease); }
.crm-projects-kanban-card .crm-projects-kanban-progress b { font-size: 10.5px; font-weight: 600; color: var(--pj-faint); font-variant-numeric: tabular-nums; }
.crm-projects-kanban-card .crm-projects-kanban-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crm-projects-kanban-card .crm-projects-kanban-foot .crm-board-date-chip { margin-left: auto; }
.crm-projects-kanban-empty { border: 1px dashed var(--pj-line); border-radius: 8px; padding: 16px; text-align: center; font-size: 11.5px; color: var(--pj-faint); }

.crm-projects-status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; letter-spacing: .02em; white-space: nowrap; }
.crm-projects-status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.s-not_started { background: var(--st-ns-bg); color: var(--st-ns-fg); }
.s-in_progress { background: var(--st-ip-bg); color: var(--st-ip-fg); }
.s-blocked { background: var(--st-bl-bg); color: var(--st-bl-fg); }
.s-done { background: var(--st-dn-bg); color: var(--st-dn-fg); }

.crm-board-prio-chip { border-radius: 5px; padding: 2px 7px; font-size: 10px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.crm-prio-urgent, .p-urgent { background: var(--sig-over-bg); color: var(--sig-over-fg); }
.crm-prio-high, .p-high { background: var(--sig-soon-bg); color: var(--sig-soon-fg); }
.crm-prio-medium, .p-medium { background: var(--pj-accent-soft); color: var(--pj-accent-ink); }
.crm-prio-low, .p-low { background: var(--pj-sunken); color: var(--pj-muted); }

.crm-board-date-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-variant-numeric: tabular-nums; }
.crm-board-date-chip.is-overdue { color: var(--sig-over-fg); font-weight: 600; }
.crm-board-date-chip.is-soon { color: var(--sig-soon-fg); font-weight: 600; }

/* ---------- GANTT EXTRAS ---------- */
.crm-projects-gantt-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.crm-projects-gantt-tools .seg { display: inline-flex; border: 1px solid var(--pj-line-strong); border-radius: 6px; overflow: hidden; background: var(--pj-raised); }
.crm-projects-gantt-tools .seg button { border: none; border-radius: 0; padding: 4px 10px; font-size: 11px; background: transparent; color: var(--pj-muted); cursor: pointer; }
.crm-projects-gantt-tools .seg button + button { border-left: 1px solid var(--pj-line); }
.crm-projects-gantt-tools .seg button.is-active,
.crm-projects-gantt-tools .seg button[aria-pressed="true"] { background: var(--pj-accent-soft); color: var(--pj-accent-ink); font-weight: 600; }
.crm-projects-gantt-weekend { position: absolute; top: 0; bottom: 0; background: var(--pj-sunken); opacity: 0.5; pointer-events: none; }
.crm-projects-gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--sig-over-fg); z-index: 2; pointer-events: none; }
.crm-projects-gantt-axis .crm-projects-gantt-today { z-index: 4; }
.crm-projects-gantt-axis .crm-projects-gantt-today::after { content: "Today"; position: absolute; top: 1px; left: 5px; font-size: 9px; font-weight: 700; color: var(--sig-over-fg); letter-spacing: .04em; white-space: nowrap; }
.crm-projects-gantt-milestone { position: absolute; top: 9px; width: 14px; height: 14px; transform: rotate(45deg) translateX(-7px); border-radius: 3px; background: var(--pj-accent); box-shadow: 0 0 0 2px var(--pj-surface); z-index: 3; }
.crm-projects-gantt-legend { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 14px 2px 0; font-size: 10.5px; color: var(--pj-faint); }
.crm-projects-gantt-legend span { display: inline-flex; align-items: center; gap: 6px; }
.crm-projects-gantt-legend i { display: block; width: 16px; height: 8px; border-radius: 3px; background: var(--pj-accent); }
.crm-projects-gantt-legend i.crm-projects-gantt-key-derived { background: transparent; border: 1.5px dashed var(--pj-line-strong); }
.crm-projects-gantt-legend i.crm-projects-gantt-key-dep { height: 0; border-top: 1.5px dashed var(--pj-faint); border-radius: 0; }
.crm-projects-gantt-legend i.crm-projects-gantt-key-milestone { width: 9px; height: 9px; border-radius: 2px; transform: rotate(45deg); background: var(--pj-accent); }

/* ---------- CHARTS ---------- */
.crm-projects-charts-grid { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 28px; align-items: start; margin-top: 18px; }
@media (max-width: 820px) { .crm-projects-charts-grid { grid-template-columns: minmax(0, 1fr); } }
.crm-projects-chart-donut { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.crm-projects-chart-donut p { margin: 0; font-size: 10.5px; color: var(--pj-faint); text-align: center; letter-spacing: .05em; text-transform: uppercase; }
.crm-projects-chart-set h4 { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--pj-faint); margin-bottom: 12px; font-weight: 600; }
.crm-projects-chart-set + .crm-projects-chart-set { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--pj-line); }
.crm-projects-chart-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 44px; gap: 12px; align-items: center; margin-bottom: 9px; }
.crm-projects-chart-row span { font-size: 11.5px; color: var(--pj-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-projects-chart-row .crm-projects-chart-track { height: 9px; border-radius: 99px; background: var(--pj-sunken); overflow: hidden; position: relative; }
.crm-projects-chart-row .crm-projects-chart-track i { display: block; height: 100%; border-radius: 99px; transition: width .5s var(--pj-ease); }
.crm-projects-chart-row b { font-size: 11.5px; font-variant-numeric: tabular-nums; text-align: right; color: var(--pj-ink); }

/* ---------- CALENDAR EXTRAS ---------- */
.crm-projects-calendar-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.crm-projects-calendar-day.off { background: var(--pj-raised); }
.crm-projects-calendar-day.is-today { box-shadow: inset 0 0 0 2px var(--pj-accent); }
.crm-projects-calendar-day.is-today h5 { color: var(--pj-accent); font-weight: 700; }

/* ---------- UTILITY RAIL ---------- */
.crm-projects-utility-rail {
  display: flex;
  border-left: 1px solid var(--pj-line);
  background: var(--pj-raised);
  width: 312px;
  transition: width .22s var(--pj-motion, ease);
  min-height: 100%;
}
.crm-projects-utility-rail.collapsed { width: 49px; }
.crm-projects-utility-tabs {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 16px 8px;
  border-right: 1px solid var(--pj-line);
  flex: 0 0 49px;
  box-sizing: border-box;
}
.crm-projects-utility-tabs button {
  position: relative;
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--pj-faint);
  cursor: pointer;
  transition: background .16s var(--pj-motion, ease), color .16s var(--pj-motion, ease);
  padding: 0;
}
.crm-projects-utility-tabs button:hover { background: var(--pj-sunken); color: var(--pj-ink); }
.crm-projects-utility-tabs button[aria-selected="true"] { background: var(--pj-accent-soft); color: var(--pj-accent-ink); }
.crm-projects-utility-tabs svg { width: 16px; height: 16px; }
.crm-projects-utility-tabs .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 99px;
  background: var(--sig-over-fg);
  color: var(--pj-surface);
  font-size: 9px;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}
.crm-projects-utility-panes {
  flex: 1;
  min-width: 0;
  padding: 16px 15px;
  overflow-y: auto;
  min-height: 0;
  box-sizing: border-box;
}
.crm-projects-utility-rail.collapsed .crm-projects-utility-panes { display: none; }
.crm-projects-utility-pane { display: none; flex-direction: column; gap: 12px; }
.crm-projects-utility-pane.on { display: flex; }
.crm-projects-utility-pane > header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.crm-projects-utility-pane > header h3 { font-size: 13.5px; font-weight: 600; margin: 0; color: var(--pj-ink); }
.crm-projects-utility-pane > header small { margin-left: auto; font-size: 10.5px; color: var(--pj-faint); }
.crm-projects-utility-pane p.lead { margin: 0; font-size: 11.5px; color: var(--pj-muted); line-height: 1.6; }
.crm-projects-utility-pane textarea { width: 100%; border: 1px solid var(--pj-line-strong); border-radius: 7px; background: var(--pj-surface); padding: 8px 9px; font-size: 11.5px; resize: vertical; min-height: 64px; }
.crm-projects-utility-pane .row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- KEYBOARD HINTS ---------- */
.crm-projects-board-hints {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  font-size: 10.5px;
  color: var(--pj-faint);
  background: var(--pj-raised);
  border-top: 1px solid var(--pj-line);
}
.crm-projects-board-hints kbd {
  font-family: inherit;
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--pj-surface);
  border: 1px solid var(--pj-line-strong);
  margin-right: 4px;
}

/* ---------- BATCH ACTIONS DOCK ---------- */

@keyframes slideUpDock {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
.crm-projects-batch-dock[hidden] {
  display: none !important;
}





/* ---------- STATUS BATTERY & ROLLUPS ---------- */
.crm-board-status-battery {
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: 4px;
  display: flex;
  height: 3px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--pj-line);
  pointer-events: none;
}
.crm-battery-segment {
  height: 100%;
  transition: width 0.2s ease;
}
.crm-battery-segment.is-done { background: var(--st-dn-fg); }
.crm-battery-segment.is-in-progress { background: var(--pj-accent); }
.crm-battery-segment.is-blocked { background: var(--st-bl-fg); }
.crm-battery-segment.is-not-started { background: var(--pj-line-strong); }

.crm-board-sum-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--pj-sunken);
  border: 1px solid var(--pj-line-strong);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--pj-ink-2);
  margin-right: 4px;
  white-space: nowrap;
}

.crm-board-duration-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--pj-accent-soft);
  border: 1px solid var(--pj-accent-line);
  font-size: 10px;
  font-weight: 600;
  color: var(--pj-accent-ink);
  margin-right: 4px;
  white-space: nowrap;
}

/* ---------- SUMMARY FOOTER ROW ---------- */
.crm-board-summary-row {
  background: var(--pj-raised);
  border-top: 1px dashed var(--pj-line-strong);
  border-bottom: 2px solid var(--pj-line-strong);
  font-size: 11.5px;
  color: var(--pj-ink-2);
  cursor: default;
  user-select: none;
}
.crm-board-summary-row:hover {
  background: var(--pj-raised);
}
.crm-board-summary-tag {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--pj-line);
  color: var(--pj-ink-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-right: 6px;
}
.crm-board-summary-cell {
  display: flex;
  align-items: center;
  font-weight: 550;
  font-size: 11px;
}
.crm-board-summary-stat {
  font-variant-numeric: tabular-nums;
  color: var(--pj-muted);
}

/* ---------- WORKSPACE GROUP IN LEFT RAIL ---------- */
.crm-rail-workspace-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 12px;
}
.crm-rail-workspace-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--pj-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.crm-rail-workspace-count {
  font-size: 9px;
  font-weight: 600;
  background: var(--pj-sunken);
  padding: 1px 5px;
  border-radius: 99px;
}


/* ==========================================================================
   Motion. One scale, one curve, compositor-friendly properties only.
   Board rows stay on background-color/color/opacity/transform so the
   interaction-latency trace over ~20 mounted rows does not regress.
   ========================================================================== */
[data-panel="projects"] .crm-projects-board-row {
  transition: background-color var(--pj-motion-fast) var(--pj-ease),
              box-shadow var(--pj-motion-fast) var(--pj-ease);
}
[data-panel="projects"] .crm-board-expander,
[data-panel="projects"] .crm-board-group-expander {
  transition: transform var(--pj-motion) var(--pj-ease),
              color var(--pj-motion-fast) var(--pj-ease);
}

/* Cells lift their editor affordance in rather than snapping it in. */
[data-panel="projects"] .crm-projects-board-row :is(input:not([type="checkbox"]), select) {
  transition: border-color var(--pj-motion-fast) var(--pj-ease),
              background-color var(--pj-motion-fast) var(--pj-ease);
}

/* View switches get continuity instead of a hard cut. */
#projects-view-content,
#projects-board-table-wrap {
  transition: opacity var(--pj-motion) var(--pj-ease),
              transform var(--pj-motion) var(--pj-ease);
}
#projects-view-content.is-view-entering,
#projects-board-table-wrap.is-view-entering {
  opacity: 0;
  transform: translateY(4px);
}


/* Optimistic writes: a left-edge pulse instead of washing the whole row amber. */
[data-panel="projects"] .crm-projects-board-row.is-pending {
  background: var(--pj-surface);
  box-shadow: inset 3px 0 var(--st-ip-fg);
  animation: pj-pending 1.1s var(--pj-ease) infinite;
}
@keyframes pj-pending {
  0%, 100% { box-shadow: inset 3px 0 var(--st-ip-fg); }
  50%      { box-shadow: inset 3px 0 var(--st-ip-bg); }
}
/* Newly created task: brief highlight-and-fade entrance */
[data-panel="projects"] .crm-projects-board-row.is-new {
  animation: pj-row-enter .18s var(--pj-ease) both;
}
@keyframes pj-row-enter {
  0% { opacity: 0; transform: translateY(-4px); background: var(--pj-accent-soft); }
  100% { opacity: 1; transform: translateY(0); background: transparent; }
}

/* Kanban drag: lift on grab, settle on drop. */
[data-panel="projects"] .crm-projects-kanban-card { will-change: transform; }
[data-panel="projects"] .crm-projects-kanban-card:active { cursor: grabbing; transform: scale(1.015); }
[data-panel="projects"] .crm-projects-kanban-card.drag { opacity: .45; transform: scale(1.02); }
[data-panel="projects"] .crm-projects-kanban-col { transition: background-color var(--pj-motion) var(--pj-ease), border-color var(--pj-motion) var(--pj-ease); }

/* Utility rail and dock. */
.crm-projects-utility-rail { transition: width var(--pj-motion-slow) var(--pj-ease); }
.crm-projects-batch-dock { animation: slideUpDock var(--pj-motion) var(--pj-ease); }

/* Buttons and tabs pick up the same curve. */
[data-panel="projects"] :is(.crm-btn-primary, .crm-btn-secondary),
.crm-projects-view-tabs button,
.crm-projects-workspace-settings-tabs button,
#projects-workspace-projects button {
  transition: background-color var(--pj-motion-fast) var(--pj-ease),
              border-color var(--pj-motion-fast) var(--pj-ease),
              color var(--pj-motion-fast) var(--pj-ease);
}


/* ---------- View options popover + Group By pivot ---------- */
.crm-projects-view-options { position: relative; }
.crm-projects-view-options > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  cursor: pointer;
  min-height: 32px;
  padding: 6px 11px;
  border-radius: var(--pj-radius-md);
  font-size: 12px;
  font-weight: 550;
}
.crm-projects-view-options > summary::-webkit-details-marker { display: none; }
.crm-projects-view-options[open] > summary { background: var(--pj-accent-soft); color: var(--pj-accent-ink); border-color: var(--pj-accent-line); }
.crm-projects-view-options-popover {
  position: absolute;
  z-index: 15;
  top: calc(100% + 6px);
  right: 0;
  display: grid;
  gap: 6px;
  min-width: 168px;
  padding: 8px;
  border: 1px solid var(--pj-line);
  border-radius: 9px;
  background: var(--pj-surface);
  box-shadow: var(--pj-shadow-pop);
}
.crm-projects-view-options-popover button { justify-content: flex-start; text-align: left; width: 100%; }
[data-panel="projects"] .crm-projects-view-options-popover button[aria-pressed="true"] {
  background: var(--pj-accent-soft);
  color: var(--pj-accent-ink);
  border-color: var(--pj-accent-line);
}

.crm-projects-view-pivot { margin-left: auto; display: flex; align-items: center; padding-bottom: 6px; }
.crm-projects-view-pivot .crm-projects-group-by-label { display: inline-flex; }
.crm-projects-view-pivot select.crm-input {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 11.5px;
  color: var(--pj-muted);
  background: transparent;
  border-color: transparent;
  border-radius: var(--pj-radius-md);
  cursor: pointer;
}
.crm-projects-view-pivot select.crm-input:hover { background: var(--pj-raised); border-color: var(--pj-line); color: var(--pj-ink); }
.crm-projects-view-tabs { align-items: flex-end; }

/* Keyboard hints belong to keyboard users: reveal them when focus is on the
   board and keep the vertical space otherwise. */
.crm-projects-board-hints {
  max-height: 0;
  padding-block: 0;
  opacity: 0;
  overflow: hidden;
  border-top-color: transparent;
  transition: max-height var(--pj-motion) var(--pj-ease),
              opacity var(--pj-motion) var(--pj-ease),
              padding var(--pj-motion) var(--pj-ease);
}
#projects-board-table-wrap:focus-within .crm-projects-board-hints {
  max-height: 44px;
  padding-block: 8px;
  opacity: 1;
  border-top-color: var(--pj-line);
}

/* The section summary footer reads as data, not as another row of controls. */
.crm-board-summary-row > div { justify-content: flex-end; }
.crm-board-summary-row > div:first-child { justify-content: flex-start; }
.crm-board-summary-stat { font-variant-numeric: tabular-nums; color: var(--pj-muted); }
.crm-board-summary-row:hover .crm-board-summary-stat { color: var(--pj-ink-2); }


/* Shared form controls inherit the app's palette by default; bind them to the
   panel's instead. Board-row editors use .crm-board-field and are unaffected. */
[data-panel="projects"] :is(input, select, textarea).crm-input {
  background-color: var(--pj-surface);
  color: var(--pj-ink);
  border-color: var(--pj-line);
}
[data-panel="projects"] :is(input, select, textarea).crm-input::placeholder { color: var(--pj-faint); }
[data-panel="projects"] .crm-input option { background: var(--pj-surface); color: var(--pj-ink); }


/* ==========================================================================
   Icons. Emoji replaced with 16x16 stroke SVG matching the utility-rail set.
   ========================================================================== */
.crm-pj-icon { width: 14px; height: 14px; flex: 0 0 auto; display: block; }
.crm-chip-icon,
.crm-copy-icon,
.crm-tech-icon,
.crm-field-icon,
.crm-btn-icon,
.crm-hint-icon,
.crm-progress-icon,
.crm-dep-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: var(--pj-muted);
}
.crm-hint-icon { color: var(--pj-accent); align-self: flex-start; margin-top: 1px; }
.crm-btn-icon { color: inherit; }
.crm-progress-icon { color: var(--crm-project-group-color, var(--pj-accent)); }
.crm-prio-flag { display: inline-flex; align-items: center; }
.crm-prio-flag .crm-pj-icon { width: 11px; height: 11px; }
.crm-detail-copy-id .crm-pj-icon { width: 12px; height: 12px; }
.crm-projects-gantt-legend i.crm-projects-gantt-key-today {
  width: 3px;
  height: 12px;
  border-radius: 1px;
  background: var(--sig-over-fg);
}
.crm-auto-warning.is-competing {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: var(--pj-radius-md);
  background: var(--st-ip-bg);
  border: 1px solid var(--st-ip-fg);
  border-left-width: 3px;
  color: var(--st-ip-fg);
}
.crm-auto-warning.is-competing strong { display: inline-flex; align-items: center; gap: 7px; }

/* ==========================================================================
   Group colour identity. groupColor() already hashes each section onto
   GROUP_COLORS and pushes it onto every row as --crm-project-group-color;
   until now it drove a single 3px shadow. This spends it.
   ========================================================================== */
.crm-projects-board-section-row {
  background: color-mix(in srgb, var(--crm-project-group-color) 9%, var(--pj-surface));
  border-left: 4px solid var(--crm-project-group-color);
  border-bottom-color: color-mix(in srgb, var(--crm-project-group-color) 22%, var(--pj-line));
}
.crm-projects-board-section-row:hover {
  background: color-mix(in srgb, var(--crm-project-group-color) 14%, var(--pj-surface));
}
/* The raw group hue on its own tint is only ~3.5:1 at 14px; deepen the title
   toward ink so it clears AA while still reading as the group colour. */
.crm-board-group-title,
.crm-board-group-expander { color: color-mix(in srgb, var(--crm-project-group-color) var(--pj-hue-amount), var(--pj-hue-toward)); }
.crm-projects-board-section-row .crm-muted {
  padding: 2px 8px;
  border-radius: var(--pj-radius-pill);
  background: color-mix(in srgb, var(--crm-project-group-color) 16%, var(--pj-surface));
  color: color-mix(in srgb, var(--crm-project-group-color) var(--pj-hue-amount), var(--pj-hue-toward));
  font-size: 10px;
  font-weight: 650;
}
.crm-projects-board-section-row input:hover {
  border-color: color-mix(in srgb, var(--crm-project-group-color) 45%, transparent);
}

/* Task rows carry a softened version of their group's hue on the left edge. */
.crm-projects-board-row {
  box-shadow: inset 3px 0 color-mix(in srgb, var(--crm-project-group-color) 58%, transparent);
}
.crm-projects-board-row.is-selected {
  box-shadow: inset 3px 0 var(--crm-project-group-color);
}

/* Rollups and progress read in the group's hue rather than a generic green. */
.crm-board-progress-ring {
  background: conic-gradient(var(--crm-project-group-color) var(--pj-pct, 0%), var(--pj-line) var(--pj-pct, 0%) 100%);
}
.crm-board-summary-row {
  background: color-mix(in srgb, var(--crm-project-group-color) 5%, var(--pj-raised));
  border-top: 1px dashed color-mix(in srgb, var(--crm-project-group-color) 30%, var(--pj-line));
  border-bottom: 2px solid color-mix(in srgb, var(--crm-project-group-color) 24%, var(--pj-line));
}
.crm-board-summary-row:hover {
  background: color-mix(in srgb, var(--crm-project-group-color) 8%, var(--pj-raised));
}
.crm-board-summary-tag {
  background: color-mix(in srgb, var(--crm-project-group-color) 18%, var(--pj-surface));
  color: color-mix(in srgb, var(--crm-project-group-color) var(--pj-hue-amount), var(--pj-hue-toward));
}


/* ==========================================================================
   Controls. The native elements all stay -- every one of them is driven by a
   pinned unit test or Playwright check -- they are just styled out of their
   OS defaults.
   ========================================================================== */

/* Board date fields. No added glyph and no height change: the browser check
   asserts elementFromPoint at the cell's top-left +10px resolves to the
   startDate input, and that the cell is no taller than the row. */
.crm-board-date-cell input[type="date"] {
  border-radius: var(--pj-radius-sm);
  font-variant-numeric: tabular-nums;
  transition: background-color var(--pj-motion-fast) var(--pj-ease),
              border-color var(--pj-motion-fast) var(--pj-ease);
}
.crm-board-date-cell input[type="date"]:hover { background: var(--pj-sunken); }
.crm-board-date-cell input[type="date"]:focus { background: var(--pj-surface); border-color: var(--pj-accent); }

/* Drawer date fields can afford the icon. */
.crm-detail-field-label { display: inline-flex; align-items: center; gap: 6px; }
#projects-task-schedule input[type="date"],
#projects-task-planning input[type="date"] {
  font-variant-numeric: tabular-nums;
  border-radius: var(--pj-radius-md);
  border: 1px solid var(--pj-line);
  background: var(--pj-surface);
  padding: 7px 9px;
  color: var(--pj-ink);
}
#projects-task-schedule input[type="date"]:focus,
#projects-task-planning input[type="date"]:focus { border-color: var(--pj-accent); }
#projects-task-schedule input[type="date"]::-webkit-calendar-picker-indicator,
#projects-task-planning input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: .5;
  cursor: pointer;
  transition: opacity var(--pj-motion-fast) var(--pj-ease);
}
#projects-task-schedule input[type="date"]:hover::-webkit-calendar-picker-indicator { opacity: .9; }

/* File input: ::file-selector-button turns "Choose File | No file chosen" into a
   real control without touching the DOM, so setInputFiles() keeps working. */
[data-panel="projects"] input[type="file"] {
  font-size: 11.5px;
  color: var(--pj-muted);
  max-width: 100%;
}
[data-panel="projects"] input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 6px 12px;
  border: 1px solid var(--pj-line-strong);
  border-radius: var(--pj-radius-md);
  background: var(--pj-surface);
  color: var(--pj-ink-2);
  font: inherit;
  font-size: 11.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background-color var(--pj-motion-fast) var(--pj-ease),
              border-color var(--pj-motion-fast) var(--pj-ease);
}
[data-panel="projects"] input[type="file"]::file-selector-button:hover {
  background: var(--pj-accent-soft);
  border-color: var(--pj-accent);
  color: var(--pj-accent-ink);
}

/* Mention members: still a native <select multiple> because the discussion
   browser check drives it with selectOption() and counts option:checked --
   but it no longer has to look like an OS listbox. */
#projects-board-discussion-mention {
  width: 100%;
  min-height: 84px;
  padding: 4px;
  border: 1px solid var(--pj-line);
  border-radius: var(--pj-radius-md);
  background: var(--pj-surface);
  color: var(--pj-ink);
  font-size: 12px;
  scrollbar-width: thin;
}
#projects-board-discussion-mention:focus { border-color: var(--pj-accent); }
#projects-board-discussion-mention option {
  padding: 6px 9px;
  border-radius: var(--pj-radius-sm);
  color: var(--pj-ink);
}
#projects-board-discussion-mention option:checked {
  background: var(--pj-accent-soft) linear-gradient(0deg, var(--pj-accent-soft), var(--pj-accent-soft));
  color: var(--pj-accent-ink);
  font-weight: 600;
}

/* Every remaining select in the panel loses its OS chrome for a drawn chevron. */
[data-panel="projects"] select.crm-input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) calc(50% + 1px), calc(100% - 10px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* ==========================================================================
   Detail drawer. Sections gain an icon slot, real surfaces and colour.
   ========================================================================== */
.crm-detail-section-head h5 { display: inline-flex; align-items: center; gap: 8px; }
.crm-detail-section + .crm-detail-section { padding-top: 20px; }

.crm-detail-progress-card {
  background: color-mix(in srgb, var(--crm-project-group-color, var(--pj-accent)) 6%, var(--pj-surface));
  border-color: color-mix(in srgb, var(--crm-project-group-color, var(--pj-accent)) 22%, var(--pj-line));
  border-radius: var(--pj-radius-md);
}
.crm-detail-progress-label { display: inline-flex; align-items: center; gap: 7px; }

/* The old lightbulb callout was an untinted grey band; make it read as help. */
.crm-detail-hint {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--pj-accent-line);
  border-left-width: 3px;
  border-radius: var(--pj-radius-md);
  background: var(--pj-accent-soft);
  color: var(--pj-accent-ink);
  font-size: 11.5px;
  line-height: 1.55;
}

.crm-detail-tech-drawer { border-radius: var(--pj-radius-md); overflow: hidden; }
.crm-detail-tech-summary { display: flex; align-items: center; gap: 8px; }
.crm-detail-tech-summary::-webkit-details-marker { display: none; }

.crm-detail-path-chip { display: inline-flex; align-items: center; gap: 7px; }
.crm-detail-copy-id { display: inline-flex; align-items: center; gap: 6px; }

/* Discussion reads as a conversation rather than a stack of rules. */
.crm-projects-discussion-message {
  padding: 10px 0 10px 13px;
  border-left: 3px solid var(--pj-accent-line);
  border-radius: 0 var(--pj-radius-sm) var(--pj-radius-sm) 0;
  transition: background-color var(--pj-motion-fast) var(--pj-ease);
}
.crm-projects-discussion-message:hover { background: var(--pj-raised); }
.crm-projects-board-discussion-form textarea {
  border-radius: var(--pj-radius-md);
  border: 1px solid var(--pj-line);
  background: var(--pj-surface);
  padding: 10px 11px;
  transition: border-color var(--pj-motion-fast) var(--pj-ease);
}
.crm-projects-board-discussion-form textarea:focus { border-color: var(--pj-accent); }

/* #ucollapse shipped with prototype class names and an inline style block. */
.crm-projects-utility-collapse {
  margin-top: auto;
  border: 0;
  background: transparent;
  color: var(--pj-muted);
  padding: 8px;
  font-size: 14px;
  line-height: 1;
  border-radius: var(--pj-radius-md);
  cursor: pointer;
  transition: background-color var(--pj-motion-fast) var(--pj-ease), color var(--pj-motion-fast) var(--pj-ease);
}
.crm-projects-utility-collapse:hover { background: var(--pj-sunken); color: var(--pj-ink); }


/* ==========================================================================
   People picker. The native <select> stays in the cell as the value store --
   stub tests click it and saveTaskField reads it -- but it is no longer the
   visible control, so nobody has to pick a teammate out of an OS listbox
   showing a raw email address.
   ========================================================================== */
.crm-board-owner-cell .crm-board-field,
.crm-board-assignees-cell .crm-board-people-field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  border: 0;
}
.crm-board-owner-cell { position: relative; }
.crm-board-assignees-cell:hover .crm-board-people-field,
.crm-board-assignees-cell:focus-within .crm-board-people-field {
  opacity: 0;
  box-shadow: none;
  min-height: 0;
  height: 100%;
}

.crm-people-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--pj-radius-sm);
  background: transparent;
  color: var(--pj-ink-2);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: background-color var(--pj-motion-fast) var(--pj-ease), border-color var(--pj-motion-fast) var(--pj-ease);
}
.crm-people-trigger:hover { background: var(--pj-surface); border-color: var(--pj-line-strong); }
.crm-people-trigger:disabled { cursor: default; }
.crm-people-trigger:disabled:hover { background: transparent; border-color: transparent; }
.crm-people-trigger.is-stack { gap: 0; }
.crm-people-trigger-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-people-popover {
  position: fixed;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  padding: 8px;
  border: 1px solid var(--pj-line);
  border-radius: 10px;
  background: var(--pj-surface);
  box-shadow: var(--pj-shadow-pop);
  color: var(--pj-ink);
}
.crm-people-search {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid var(--pj-line-strong);
  border-radius: var(--pj-radius-md);
  background: var(--pj-surface);
  color: var(--pj-ink);
  font: inherit;
  font-size: 12px;
}
.crm-people-search:focus { border-color: var(--pj-accent); outline: none; }
.crm-people-list { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 2px; }
.crm-people-option {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--pj-radius-md);
  background: transparent;
  color: var(--pj-ink);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--pj-motion-fast) var(--pj-ease);
}
.crm-people-option:hover { background: var(--pj-sunken); }
.crm-people-option.is-chosen { background: var(--pj-accent-soft); color: var(--pj-accent-ink); }
.crm-people-option-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.crm-people-option-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.crm-people-option-mail { font-size: 10.5px; color: var(--pj-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-people-option-tick { margin-left: auto; width: 14px; height: 14px; flex: 0 0 14px; position: relative; }
.crm-people-option.is-chosen .crm-people-option-tick::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.crm-people-empty { margin: 0; padding: 10px 8px; font-size: 11.5px; color: var(--pj-muted); }


/* ==========================================================================
   Selection dock. Was a dark pill of native dropdowns; now a light card with
   icon-over-label actions. The two <select>s stay -- they are the working
   control -- but sit invisibly over their tile, so clicking the tile opens
   them in place. Nothing in either test suite references this dock.
   ========================================================================== */
.crm-projects-batch-dock {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom) + 12px);
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: calc(100vw - 32px);
  padding: 10px 14px 10px 18px;
  border: 1px solid var(--pj-line);
  border-radius: 14px;
  background: var(--pj-surface);
  color: var(--pj-ink);
  box-shadow: 0 18px 44px -12px rgba(20, 30, 50, .28), 0 2px 6px rgba(20, 30, 50, .08);
  animation: slideUpDock var(--pj-motion) var(--pj-ease);
}
.crm-projects-batch-dock[hidden] { display: none !important; }
.crm-batch-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--pj-ink);
}
.crm-batch-badge {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--pj-accent);
  color: var(--pj-on-accent);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.crm-batch-dock-actions { display: flex; align-items: center; gap: 4px; }
.crm-batch-action {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 62px;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--pj-radius-md);
  background: transparent;
  color: var(--pj-ink-2);
  font: inherit;
  font-size: 10.5px;
  cursor: pointer;
  transition: background-color var(--pj-motion-fast) var(--pj-ease), color var(--pj-motion-fast) var(--pj-ease);
}
.crm-batch-action:hover { background: var(--pj-sunken); color: var(--pj-ink); }
.crm-batch-action .crm-pj-icon { width: 17px; height: 17px; }
.crm-batch-action:disabled { color: var(--pj-faint); cursor: not-allowed; }
.crm-batch-action:disabled:hover { background: transparent; }
/* the real control, invisible but exactly over its tile */
.crm-batch-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  cursor: pointer;
  font: inherit;
}
.crm-batch-divider { width: 1px; height: 26px; margin: 0 4px; background: var(--pj-line); }
.crm-batch-close {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--pj-radius-md);
  background: transparent;
  color: var(--pj-muted);
  cursor: pointer;
  transition: background-color var(--pj-motion-fast) var(--pj-ease), color var(--pj-motion-fast) var(--pj-ease);
}
.crm-batch-close:hover { background: var(--pj-sunken); color: var(--pj-ink); }
@media (max-width: 700px) {
  .crm-projects-batch-dock { gap: 10px; padding: 8px 10px 8px 12px; }
  .crm-batch-action { min-width: 52px; padding: 6px; }
  .crm-batch-count-badge span:last-child { display: none; }
}


/* Task drawer tabs: Updates is the landing panel, details live behind them. */
.crm-detail-tabs {
  display: flex;
  gap: 20px;
  margin: 14px 0 4px;
  border-bottom: 1px solid var(--pj-line);
}
.crm-detail-tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--pj-muted);
  padding: 9px 1px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: color var(--pj-motion-fast) var(--pj-ease), border-color var(--pj-motion-fast) var(--pj-ease);
}
.crm-detail-tabs button:hover { color: var(--pj-ink); }
.crm-detail-tabs button[aria-selected="true"] {
  color: var(--pj-accent-ink);
  border-bottom-color: var(--pj-accent);
  font-weight: 650;
}
[data-detail-panel][hidden] { display: none !important; }


/* ==========================================================================
   Filter chips. Status / owner / assignee / section are one-click chips with
   live counts from the same aggregates the summary line reads. The native
   <select>s stay in the form as the value store -- FormData, requestSubmit and
   every pinned selector keep working -- but they are no longer the control.
   ========================================================================== */
.crm-filter-block { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.crm-filter-legend {
  margin: 0;
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--pj-faint);
}
.crm-filter-chips { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.crm-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 10px 5px 8px;
  border: 1px solid var(--pj-line);
  border-radius: 99px;
  background: var(--pj-surface);
  color: var(--pj-ink-2);
  font: inherit;
  font-size: 11.5px;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color var(--pj-motion-fast) var(--pj-ease),
              border-color var(--pj-motion-fast) var(--pj-ease),
              color var(--pj-motion-fast) var(--pj-ease);
}
.crm-filter-chip:hover { background: var(--pj-sunken); border-color: var(--pj-line-strong); color: var(--pj-ink); }
.crm-filter-chip.is-on {
  background: var(--pj-accent-soft);
  border-color: var(--pj-accent);
  color: var(--pj-accent-ink);
  font-weight: 600;
}
.crm-filter-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.crm-filter-chip-dot { width: 9px; height: 9px; border-radius: 99px; flex: 0 0 9px; background: var(--pj-faint); }
.crm-filter-chip-dot[data-status="not_started"] { background: var(--st-ns-solid); }
.crm-filter-chip-dot[data-status="in_progress"] { background: var(--st-ip-solid); }
.crm-filter-chip-dot[data-status="blocked"]     { background: var(--st-bl-solid); }
.crm-filter-chip-dot[data-status="done"]        { background: var(--st-dn-solid); }
.crm-filter-chip-avatar {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  border-radius: 99px;
  background: var(--pj-sunken);
  color: var(--pj-muted);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: .01em;
}
.crm-filter-chip.is-on .crm-filter-chip-avatar { background: var(--pj-accent); color: var(--pj-on-accent); }
.crm-filter-chip-count {
  min-width: 15px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--pj-sunken);
  color: var(--pj-muted);
  font-size: 9.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.crm-filter-chip.is-on .crm-filter-chip-count { background: var(--pj-accent); color: var(--pj-on-accent); }

.crm-filter-dates .crm-filter-date-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.crm-filter-dates label { display: flex; flex-direction: column; gap: 4px; font-size: 10.5px; color: var(--pj-muted); min-width: 0; }

/* The value store: no ink, no pointer target, but a real box so programmatic
   and automated value setting still resolves the control. */
.crm-filter-natives {
  position: relative;
  height: 1px;
  margin: -1px 0 0;
  opacity: 0;
  pointer-events: none;
}
.crm-filter-natives label { position: absolute; left: 0; top: 0; width: 160px; font-size: 10px; }
.crm-filter-natives select { width: 160px; min-height: 24px; }

.crm-filter-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 11px;
  border-top: 1px solid var(--pj-line);
}
.crm-filter-footer .crm-inline-fields { margin: 0 0 0 auto; display: flex; gap: 7px; }
.crm-filter-footer .crm-btn-primary,
.crm-filter-footer .crm-btn-secondary { padding: 6px 13px; font-size: 11.5px; }
.crm-filter-note {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  border-radius: 99px;
  border: 1px solid var(--pj-line-strong);
  background: var(--pj-surface);
  color: var(--pj-muted);
  font-size: 10px;
  font-weight: 700;
  font-style: italic;
  cursor: help;
  position: relative;
}
.crm-filter-note::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 4;
  width: 250px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--pj-ink);
  color: var(--pj-surface);
  font-size: 10.5px;
  font-style: normal;
  font-weight: 450;
  line-height: 1.5;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--pj-motion-fast) var(--pj-ease), visibility var(--pj-motion-fast) var(--pj-ease);
}
.crm-filter-note:hover::after,
.crm-filter-note:focus-visible::after { opacity: 1; visibility: visible; }

@media (max-width: 700px) {
  .crm-filter-dates .crm-filter-date-fields { grid-template-columns: 1fr; }
}


/* ==========================================================================
   Date picker. The native <input type="date"> stays as the value store, so
   fills, validation and every pinned selector are unchanged -- but Chrome's own
   calendar no longer opens, and the field reads as part of the board instead of
   part of the operating system.
   ========================================================================== */
[data-panel="projects"] input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0;
  cursor: pointer;
}
[data-panel="projects"] input[type="date"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236b7488' stroke-width='1.5' stroke-linecap='round'%3E%3Crect x='2.4' y='3.4' width='11.2' height='10.2' rx='1.6'/%3E%3Cpath d='M2.4 6.5h11.2M5.5 2.1v2.6M10.5 2.1v2.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  background-size: 13px 13px;
  padding-right: 24px;
}
.crm-projects-board-row input[type="date"] { background-position: right 4px center; padding-right: 19px; }

.crm-datepick {
  position: fixed;
  z-index: 1300;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 11px;
  border: 1px solid var(--pj-line);
  border-radius: 12px;
  background: var(--pj-surface);
  color: var(--pj-ink);
  box-shadow: var(--pj-shadow-pop);
  font-size: 12px;
}
.crm-datepick-head { display: flex; align-items: center; gap: 5px; }
.crm-datepick-nav {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  border: 0;
  border-radius: var(--pj-radius-md);
  background: transparent;
  color: var(--pj-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--pj-motion-fast) var(--pj-ease), color var(--pj-motion-fast) var(--pj-ease);
}
.crm-datepick-nav:hover { background: var(--pj-sunken); color: var(--pj-ink); }
.crm-datepick-select {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 5px;
  border: 1px solid transparent;
  border-radius: var(--pj-radius-sm);
  background: transparent;
  color: var(--pj-ink);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.crm-datepick-select:hover { background: var(--pj-sunken); }
.crm-datepick-select:focus-visible { border-color: var(--pj-accent); outline: none; }
.crm-datepick-select option { background: var(--pj-surface); color: var(--pj-ink); font-weight: 450; }

.crm-datepick-weekdays,
.crm-datepick-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.crm-datepick-weekdays span {
  display: grid;
  place-items: center;
  height: 20px;
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: .04em;
  color: var(--pj-faint);
}
.crm-datepick-blank { display: block; }
.crm-datepick-day {
  display: grid;
  place-items: center;
  height: 28px;
  border: 1px solid transparent;
  border-radius: var(--pj-radius-sm);
  background: transparent;
  color: var(--pj-ink-2);
  font: inherit;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color var(--pj-motion-fast) var(--pj-ease), color var(--pj-motion-fast) var(--pj-ease);
}
.crm-datepick-day:hover:not(:disabled) { background: var(--pj-sunken); color: var(--pj-ink); }
.crm-datepick-day.is-today { border-color: var(--pj-accent); color: var(--pj-accent-ink); font-weight: 650; }
.crm-datepick-day.is-selected {
  background: var(--pj-accent);
  border-color: var(--pj-accent);
  color: var(--pj-on-accent);
  font-weight: 650;
}
.crm-datepick-day:disabled { color: var(--pj-faint); cursor: not-allowed; }

.crm-datepick-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--pj-line);
}
.crm-datepick-text {
  border: 0;
  border-radius: var(--pj-radius-md);
  background: transparent;
  color: var(--pj-accent-ink);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
  transition: background-color var(--pj-motion-fast) var(--pj-ease);
}
.crm-datepick-text:hover { background: var(--pj-accent-soft); }
.crm-datepick-text[data-datepick-clear] { color: var(--pj-muted); }
.crm-datepick-text[data-datepick-clear]:hover { background: var(--pj-sunken); color: var(--pj-ink); }


/* Dark theme needs a lighter glyph; a data URI cannot read currentColor. */
[data-panel="projects"].projects-dark input[type="date"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23aeb7c9' stroke-width='1.5' stroke-linecap='round'%3E%3Crect x='2.4' y='3.4' width='11.2' height='10.2' rx='1.6'/%3E%3Cpath d='M2.4 6.5h11.2M5.5 2.1v2.6M10.5 2.1v2.6'/%3E%3C/svg%3E");
}

@media (prefers-reduced-motion: reduce) {
  [data-panel="projects"] *,
  [data-panel="projects"] *::before,
  [data-panel="projects"] *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Modern SaaS Task Details Panel Redesign (Linear / Asana Style)
   ========================================================================== */

/* Drawer Container */
[data-panel="projects"] dialog#projects-board-detail {
  padding: 24px 28px;
  background: var(--pj-surface, #ffffff);
  color: var(--pj-ink, #0f172a);
  box-shadow: -16px 0 48px rgba(15, 23, 42, 0.12);
  border-left: 1px solid var(--pj-line, #e2e8f0);
}

/* Header */
[data-panel="projects"] dialog .crm-projects-board-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--pj-line, #e2e8f0);
}

[data-panel="projects"] dialog .crm-projects-board-detail-head h4 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--pj-ink, #0f172a);
  margin: 3px 0 0;
  letter-spacing: -0.015em;
  word-break: break-word;
}

/* Detail Property Bar */
.crm-detail-property-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0 6px;
}

.crm-detail-path-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--pj-muted, #64748b);
  background: var(--pj-sunken, #f8fafc);
  border: 1px solid var(--pj-line, #e2e8f0);
  border-radius: 6px;
  padding: 4px 10px;
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-detail-meta-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.crm-detail-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
}

.crm-pill-status {
  background: var(--pj-accent-soft, #eff6ff);
  color: var(--pj-accent-ink, #1d4ed8);
  border: 1px solid var(--pj-accent-line);
}
.crm-pill-status[data-status="done"] {
  background: var(--st-dn-bg);
  color: var(--st-dn-fg);
  border-color: var(--st-dn-bg);
}
.crm-pill-status[data-status="in_progress"] {
  background: var(--pj-accent-soft);
  color: var(--pj-accent-ink);
  border-color: var(--pj-accent-line);
}
.crm-pill-status[data-status="blocked"] {
  background: var(--sig-over-bg);
  color: var(--sig-over-fg);
  border-color: var(--sig-over-bg);
}
.crm-pill-status[data-status="not_started"] {
  background: var(--pj-sunken);
  color: var(--pj-ink-2);
  border-color: var(--pj-line-strong);
}

.crm-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.crm-pill-lifecycle {
  background: var(--pj-sunken, #f8fafc);
  color: var(--pj-muted, #64748b);
  border: 1px solid var(--pj-line, #e2e8f0);
  text-transform: capitalize;
}

.crm-pill-owner {
  background: var(--pj-sunken, #f8fafc);
  color: var(--pj-ink, #1e293b);
  border: 1px solid var(--pj-line, #e2e8f0);
}

.crm-pill-owner .crm-board-owner-avatar {
  width: 18px;
  height: 18px;
  font-size: 0.62rem;
  border-radius: 50%;
  background: var(--pj-accent);
  color: var(--pj-on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.crm-pill-priority {
  border: 1px solid transparent;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
}

.crm-prio-flag {
  font-size: 0.72rem;
}

/* Copy ID button */
.crm-detail-copy-id {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--pj-line, #e2e8f0);
  border-radius: 6px;
  background: var(--pj-sunken, #f8fafc);
  color: var(--pj-muted, #64748b);
  cursor: pointer;
  font-size: 0.74rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  transition: all 0.15s ease;
}

.crm-detail-copy-id:hover {
  background: var(--pj-surface, #ffffff);
  border-color: var(--pj-line-strong);
  color: var(--pj-ink, #0f172a);
}

.crm-id-code {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-copy-feedback {
  font-size: 0.68rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--pj-accent-ink);
  padding-left: 2px;
}

.crm-detail-copy-id.is-copied {
  background: var(--st-dn-bg);
  border-color: var(--st-dn-fg);
  color: var(--st-dn-fg);
}

/* Collapsible Technical Drawer */
.crm-detail-tech-drawer {
  margin: 6px 0 10px;
  border: 1px solid var(--pj-line, #e2e8f0);
  border-radius: 8px;
  background: var(--pj-sunken, #f8fafc);
  overflow: hidden;
}

.crm-detail-tech-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--pj-muted, #64748b);
  cursor: pointer;
  user-select: none;
}

.crm-detail-tech-summary:hover {
  color: var(--pj-ink, #0f172a);
}

.crm-tech-rev {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--pj-faint);
  font-family: monospace;
}

.crm-detail-tech-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--pj-line, #e2e8f0);
  background: var(--pj-surface, #ffffff);
}

.crm-detail-tech-content dl {
  margin: 0;
}

.crm-detail-tech-content dt {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pj-faint);
}

.crm-detail-tech-content dd {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--pj-ink, #1e293b);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  overflow-wrap: anywhere;
}

/* Planning Sections */
#projects-task-planning {
  border-top: 1px solid var(--pj-line, #e2e8f0);
  padding-top: 0;
}

.crm-detail-section {
  padding: 18px 0;
  border-bottom: 1px solid var(--pj-line, #e2e8f0);
}
.crm-detail-section:last-child {
  border-bottom: 0;
}

.crm-detail-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.crm-detail-section-head h5 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--pj-ink, #1e293b);
  margin: 0;
}

.crm-detail-section-subtitle {
  font-size: 0.74rem;
  color: var(--pj-muted, #64748b);
}

/* Subtasks Metric Card */
.crm-detail-progress-card {
  background: var(--pj-surface, #ffffff);
  border: 1px solid var(--pj-line, #e2e8f0);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.crm-detail-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.crm-detail-progress-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--pj-ink, #1e293b);
}

.crm-detail-progress-stat {
  font-size: 0.76rem;
  color: var(--pj-muted, #64748b);
}

.crm-detail-progress-stat.is-complete {
  color: var(--st-dn-fg);
  font-weight: 600;
}

.crm-detail-progress-track {
  width: 100%;
  height: 6px;
  background: var(--pj-sunken, #e2e8f0);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}

.crm-detail-progress-track.crm-battery-track {
  display: flex;
  gap: 1px;
}

.crm-detail-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pj-accent) 0%, var(--st-dn-fg) 100%);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.crm-detail-progress-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.crm-detail-span-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--pj-muted, #64748b);
}

/* Date Grid */
.crm-detail-date-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 10px;
}

.crm-detail-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.crm-detail-field-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--pj-muted, #475569);
}

.crm-detail-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

/* Dependencies UI */
.crm-detail-dep-picker-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.crm-detail-dep-select-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.crm-detail-chips-wrapper {
  margin: 8px 0;
}

.crm-detail-chips-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--pj-muted, #64748b);
  margin-bottom: 6px;
}

.crm-detail-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
  padding: 2px 0;
}

.crm-dep-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: var(--pj-accent-soft);
  border: 1px solid var(--pj-accent-line);
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--pj-accent-ink);
  max-width: 100%;
}

.crm-dep-title {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-dep-id {
  font-size: 0.68rem;
  color: var(--pj-accent-line);
  font-family: monospace;
}

.crm-dep-remove {
  background: none;
  border: none;
  color: var(--pj-accent-line);
  font-size: 14px;
  line-height: 1;
  padding: 0 3px;
  cursor: pointer;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}

.crm-dep-remove:hover {
  color: var(--pj-accent-ink);
  background: rgba(29, 78, 216, 0.1);
}

.crm-detail-no-deps {
  font-size: 0.76rem;
  color: var(--pj-muted, #94a3b8);
  font-style: italic;
}

.crm-detail-hint {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 0.74rem;
  color: var(--pj-muted, #64748b);
  line-height: 1.4;
  margin: 8px 0;
  padding: 6px 10px;
  background: var(--pj-sunken, #f8fafc);
  border-radius: 6px;
  border: 1px solid var(--pj-line, #e2e8f0);
}

.crm-detail-advanced-dep {
  margin: 10px 0;
  border: 1px dashed var(--pj-line, #cbd5e1);
  border-radius: 6px;
  padding: 6px 10px;
  background: var(--pj-sunken, #f8fafc);
}

.crm-detail-advanced-summary {
  font-size: 0.72rem;
  color: var(--pj-muted, #64748b);
  cursor: pointer;
  user-select: none;
}

.crm-detail-advanced-content {
  margin-top: 6px;
}

.crm-dep-textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.74rem;
  width: 100%;
}

.crm-task-status-banner {
  font-size: 0.78rem;
  margin: 6px 0 0;
}

/* CRM Links Modernization */
#projects-task-links ul {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#projects-task-links li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--pj-sunken, #f8fafc);
  border: 1px solid var(--pj-line, #e2e8f0);
  border-radius: 6px;
  font-size: 0.78rem;
}

#projects-task-links li button {
  padding: 3px 8px;
  font-size: 0.72rem;
  border-radius: 4px;
  cursor: pointer;
}

/* Date Preview Card */
.crm-detail-preview-card {
  margin-top: 10px;
  padding: 12px;
  background: var(--pj-sunken, #f8fafc);
  border: 1px solid var(--pj-line, #e2e8f0);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.crm-preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.crm-preview-tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--pj-accent-soft);
  color: var(--pj-accent-ink);
}

.crm-preview-task-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--pj-ink, #0f172a);
}

.crm-preview-comparison {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--pj-surface, #ffffff);
  border: 1px solid var(--pj-line, #e2e8f0);
  border-radius: 6px;
  font-size: 0.78rem;
}

.crm-preview-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.crm-preview-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--pj-muted, #64748b);
  text-transform: uppercase;
}

.crm-preview-dates {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  color: var(--pj-ink, #0f172a);
}

.crm-preview-col.is-after .crm-preview-dates {
  font-weight: 700;
  color: var(--pj-accent-ink);
}

.crm-preview-arrow {
  color: var(--pj-muted, #94a3b8);
  font-size: 0.85rem;
}

.crm-preview-meta {
  display: flex;
  gap: 8px;
}

.crm-preview-pill {
  font-size: 0.72rem;
  padding: 2px 8px;
  background: var(--pj-surface, #ffffff);
  border: 1px solid var(--pj-line, #e2e8f0);
  border-radius: 999px;
  color: var(--pj-muted, #475569);
}

.crm-preview-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 2px;
}

.crm-preview-tech {
  margin-top: 4px;
  font-size: 0.72rem;
}

.crm-preview-tech summary {
  cursor: pointer;
  user-select: none;
}

.crm-preview-details {
  font-size: 0.74rem;
}

/* Dark mode needs no overrides here: every rule above now reads its colours
   from the [data-panel="projects"] token block, which .projects-dark redefines. */




/* Empty dates and people are visible actions, with the original field contracts. */
.crm-board-date-control { position: relative; flex: 1 1 0; min-width: 0; }
.crm-board-date-control > input.crm-board-field { position: absolute; width: 1px; height: 1px; opacity: 0; padding: 0; border: 0; }
.crm-board-date-trigger { width: 100%; min-height: 28px; padding: 3px 4px; border: 0; border-radius: var(--pj-radius-sm); background: transparent; color: var(--pj-muted); font: inherit; font-size: 11px; white-space: nowrap; cursor: pointer; }
.crm-board-date-trigger:hover { background: var(--pj-sunken); color: var(--pj-ink); }
.crm-projects-board-row .crm-board-title-input { font-size: 13px; }
.crm-projects-board-row .crm-board-drag-handle, .crm-projects-board-row .crm-board-detail-button { color: var(--pj-muted); }
#projects-view-summary { font-size: 11px; color: var(--pj-muted); }
