/* [2026-10-12, SPEC 161, DESIGN PROTOTYPE] Task references on records: the row chip, its floating
   hover card, and the record page's Tasks card. Tokens only, square corners (brand). Loaded by
   _base.html so it works on CRM, Orders and White Glove pages alike. */
.tref-cell { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.tref { position: relative; display: inline-flex; }
.tref-chip {
  display: inline-flex; align-items: center; height: 22px; padding: 0 7px;
  font-size: var(--fs-2xs); font-weight: 600; letter-spacing: 0.02em; font-variant-numeric: tabular-nums;
  color: var(--ag-dark-sage); background: var(--ag-sage-10); border: 1px solid var(--ag-hairline-strong);
  text-decoration: none; white-space: nowrap;
}
.tref-chip:hover, .tref-chip:focus-visible { border-color: var(--ag-dark-sage); background: var(--bg-hover-subtle); }
.tref-chip:focus-visible { outline: 2px solid var(--ag-dark-sage); outline-offset: 1px; }
.tref-chip.is-overdue { color: var(--ag-danger-fg); background: var(--ag-danger-bg); border-color: var(--ag-danger-fg); }
.tref-chip.is-awaiting { color: var(--ag-pending-fg); background: var(--ag-pending-bg); }
.tref-chip.is-done { color: var(--fg-2); background: transparent; text-decoration: line-through; }
.tref-more, .tref-done { font-size: var(--fs-2xs); color: var(--fg-2); white-space: nowrap; }
.tref-more { font-weight: 600; color: var(--fg-1); }
.tref-none { color: var(--ag-hairline-strong); }

/* The floating card (task-refs.js puts one of these on <body>). */
.tref-float {
  position: fixed; z-index: 2000; width: 280px; max-width: calc(100vw - 24px);
  background: var(--ag-white); color: var(--fg-1); border: 1px solid var(--border-strong);
  box-shadow: 0 6px 24px rgba(36, 43, 38, 0.16); padding: 12px 14px;
  display: grid; gap: 6px; font-size: var(--fs-sm); line-height: 1.4; pointer-events: none;
}
.tref-float[hidden] { display: none; }
.tref-card-head { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-xs); color: var(--fg-2); }
.tref-card-head b { color: var(--fg-1); }
.tref-card-title { font-weight: 600; font-size: var(--fs-sm); color: var(--fg-1); }
.tref-card-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--fg-2); font-size: var(--fs-xs); }
.tref-card-meta i { margin-right: 4px; }
.tref-card-meta .is-overdue, .tref-row-meta .is-overdue { color: var(--ag-danger-fg); font-weight: 600; }
.tref-card-tags, .tref-row-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tref-card-foot { font-size: var(--fs-2xs); color: var(--fg-2); border-top: 1px solid var(--border-soft); padding-top: 6px; }
.tref-via { font-size: var(--fs-2xs); color: var(--fg-2); }
.tref-status, .tref-urg {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px; font-size: var(--fs-2xs);
  text-transform: uppercase; letter-spacing: 0.06em; border: 1px solid var(--border-soft); color: var(--fg-2);
}
.tref-status.is-open { color: var(--ag-dark-sage); border-color: var(--ag-hairline-strong); }
.tref-status.is-awaiting { color: var(--ag-pending-fg); background: var(--ag-pending-bg); border-color: transparent; }
.tref-urg.is-priority { color: var(--ag-prio-high); border-color: var(--ag-prio-high); }
.tref-urg.is-urgent, .tref-urg.is-rush { color: var(--ag-danger-fg); background: var(--ag-danger-bg); border-color: transparent; }

/* The record page's Tasks card. */
.tref-panel { display: grid; gap: var(--sp-3); container-type: inline-size; }
.tref-panel-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); }
.tref-h { margin: 0; font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-1); }
.tref-count { font-weight: 400; letter-spacing: 0.04em; color: var(--fg-2); margin-left: 6px; }
.tref-list { list-style: none; margin: 0; padding: 0; display: grid; }
.tref-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border-soft);
}
.tref-row-main { display: grid; gap: 2px; min-width: 0; }
.tref-row-title { color: var(--fg-1); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.tref-row-title:hover { text-decoration: underline; }
.tref-row-meta { font-size: var(--fs-xs); color: var(--fg-2); }
.tref-row.is-done .tref-row-title { color: var(--fg-2); font-weight: 400; }
.tref-donefold summary { cursor: pointer; font-size: var(--fs-xs); color: var(--fg-link); }
/* A narrow home (the lead's related rail, the workflow rail, the quote's side column, a phone):
   chip and tags on one line, then the title, then who and when. */
@container (max-width: 480px) {
  .tref-row { grid-template-columns: auto minmax(0, 1fr); gap: 6px 8px; }
  .tref-row > .tref { grid-column: 1; grid-row: 1; }
  .tref-row-tags { grid-column: 2; grid-row: 1; justify-content: flex-end; }
  .tref-row-main { grid-column: 1 / -1; grid-row: 2; }
}

/* Samples: its five widths sum to 100% in srm.css; with the Tasks column present they are
   re-dealt so the locked Next press keeps its words ("Open the lead", "Send"). */
.srm-main--crm .crm-samples-table:has(th[data-col="tasks"]) th[data-col="ref"] { width: 26%; }
.srm-main--crm .crm-samples-table:has(th[data-col="tasks"]) th[data-col="stage"] { width: 17%; }
.srm-main--crm .crm-samples-table:has(th[data-col="tasks"]) th[data-col="timing"] { width: 14%; }
.srm-main--crm .crm-samples-table:has(th[data-col="tasks"]) th[data-col="invoice"] { width: 11%; }
.srm-main--crm .crm-samples-table:has(th[data-col="tasks"]) th[data-col="tasks"] { width: 12%; }
.srm-main--crm .crm-samples-table:has(th[data-col="tasks"]) th[data-col-lock] { width: 20%; }

/* [2026-10-19, SPEC 192a2, A's rulings on the double to-dos]
   "3 open tasks" beside the bell: my own open tasks, a quiet link. */
.srm-opentasks {
  display: inline-flex; align-items: center; white-space: nowrap;
  font: 400 var(--fs-xs)/1.2 var(--ff-ui); color: var(--fg-2);
  text-decoration: underline; text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}
.srm-opentasks:hover { color: var(--fg-link-hover); }

/* The + Task nudges: shown by what is ticked, never by script. */
.crm-taskform-nudge { display: none; margin: 0; }
.crm-taskform-who:has(input[name="assignee_id"]:checked:not([data-me])) .crm-taskform-nudge[data-task-nudge] { display: block; }
.crm-taskform-who:has(input[name="assignee_id"][data-me]:checked):has(input[name="assignee_id"]:checked:not([data-me])) .crm-taskform-nudge[data-task-selfcopy] { display: block; }
