/*
 * Processes under way.
 *
 * "it should be simple and display active processes so user can easily see where its up
 *  to and also see archived/completed processes" (2026-09-14)
 *
 * This was a six-column table: name, slug, status, version, started, last activity. Every
 * column was narrow, the widest fact on the page was a machine slug, and the one thing
 * somebody tracking their work needs — the step it is waiting on and who has it — was in
 * none of them. A row of cells cannot carry a step name and a person's name legibly at
 * 10px in a 110px column, so this is a list of pieces of work instead, each with room for
 * the sentence that answers "where is it up to".
 *
 * Colour, type and the rail come from theme.css. Nothing here redefines a brand token:
 * theme.css loads second and per-tenant colour has to win.
 */
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
  font-family: var(--tenant-font, Inter, "Segoe UI", system-ui, sans-serif);
  color: var(--ink, #27272a);
  background: #fff;
}
button,
input {
  font: inherit;
}
:root {
  --muted: #667085;
  --line: #e4e7ec;
  /* The four states a piece of work is in, each with its own colour and its own word.
     Running is the brand; waiting-too-long borrows the accent; finished is deliberately
     quiet, because a finished list is for looking things up, not for watching. */
  --running: var(--brand, #007b77);
  --running-tint: var(--brand-tint, #eaf8f7);
  --late: #b3600f;
  --late-tint: #fdf3e7;
  --done: #5b6472;
  --done-tint: #f1f3f6;
  --stopped: #a01f2a;
  --stopped-tint: #fdf0f1;
}

/* ---- the page ---- */
/* THE PRODUCT'S ONE PAGE DESIGN (Sam, 2026-11-24: "every page should be the same"): the Documents page's
   shell (library.css .library-shell, header.library-head, nav.documents-status-tabs, documents.css), with
   the process open beside the list as a third column where there is room, over the page where there is not.
   .case-shell is the same element: cases.js opens and closes the detail through it. */
body[data-master-page="cases"] .library-shell.case-shell {
  grid-template-columns: var(--bb-rail-w) minmax(0, 1fr) 360px;
  /* The frame the detail drawer slides inside of. Fixed to the viewport it covered the
     shared TheBridge header, which is in normal flow above this shell. */
  position: relative;
}
body[data-master-page="cases"] .library-shell > main {
  min-width: 0;
  overflow: auto;
  background: #fff;
}
.case-heading-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
/* How many, of what is on screen — a caption directly above the list it counts. */
#case-count {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.case-tabs button:focus-visible {
  outline: 2px solid var(--brand, #007b77);
  outline-offset: 2px;
  border-radius: 4px;
}
/* The fields behind Filters: Who has it and Include archived, side by side. */
.case-filters { margin: 0 0 14px; }
.case-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px 18px;
}
.case-filter-bar[hidden] { display: none; }
.case-include-archived {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: #34425a;
  font-size: 12px;
}

/* ---- one piece of work ---- */
/* Documents-style rows: one bordered table (documents.css .documents-table), a line between rows. */
#case-rows {
  display: flex;
  flex-direction: column;
}
.case-row {
  position: relative;
  display: grid;
  gap: 9px;
  border: 0;
  border-top: 1px solid #e4e7ec;
  border-radius: 0;
  padding: 14px 16px 13px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.case-row:first-child {
  border-top: 0;
}
.case-row:hover {
  background: #f8fafb;
  box-shadow: inset 3px 0 var(--state, var(--brand, #007b77));
}
.case-row.selected {
  background: var(--brand-tint, #eaf8f7);
  box-shadow: inset 3px 0 var(--brand, #007b77);
}
/* Nothing to list, inside the table: no second box. */
#case-rows > .empty {
  border: 0;
}
/* The band has to stay a band. Selected, its own tint and the card's were the same
   colour, so the one line the page exists for stopped standing out on the row a person
   had just clicked. */
.case-row.selected .case-now {
  --tint: #fff;
}
.case-row:focus-visible {
  outline: 2px solid var(--brand, #007b77);
  outline-offset: -2px;
}
.case-row[data-state="running"] {
  --state: var(--running);
}
.case-row[data-state="late"] {
  --state: var(--late);
}
.case-row[data-state="done"] {
  --state: var(--done);
}
.case-row[data-state="stopped"] {
  --state: var(--stopped);
}

/* line 1: what this piece of work is, and when it last moved */
.case-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}
.case-title b {
  font-size: 14px;
  font-weight: 650;
  line-height: 1.3;
}
.case-title time {
  flex: none;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
/* line 2: the process it follows, by its name — never its slug */
.case-process {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: -4px;
}

/* line 3: WHERE IT IS UP TO. The reason the page exists, so it is the one thing with a
   fill behind it. */
.case-now {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--tint, var(--soft, #f4f7f7));
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 12.5px;
}
.case-row[data-state="running"] .case-now {
  --tint: var(--running-tint);
}
.case-row[data-state="late"] .case-now {
  --tint: var(--late-tint);
}
.case-row[data-state="done"] .case-now {
  --tint: var(--done-tint);
}
.case-row[data-state="stopped"] .case-now {
  --tint: var(--stopped-tint);
}
.case-now .at {
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--state, var(--muted));
}
.case-now strong {
  font-weight: 650;
}
.case-now .who {
  color: var(--muted);
}
.case-now .who:before {
  content: "·";
  margin-right: 7px;
}
/* Yours, and late: the two things worth spotting from across the list. */
.flag {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 99px;
  white-space: nowrap;
}
.flag.yours {
  background: var(--brand, #007b77);
  color: #fff;
}
.flag.late {
  background: var(--late);
  color: #fff;
}
.case-now .more {
  color: var(--muted);
  font-size: 11px;
}

/* line 4: how far it has come, and nothing claiming to know how far is left */
.case-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---- the one being looked at ---- */
#case-detail {
  grid-column: 3;
  grid-row: 1;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: #fafbfc;
  padding: 18px;
  overflow: auto;
}
.detail-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 15px;
  margin-bottom: 12px;
}
.detail-card h2 {
  font-size: 17px;
  line-height: 1.25;
  margin: 0 0 5px;
  letter-spacing: -0.01em;
}
.detail-card h3 {
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 11px;
}
.detail-card > p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11.5px;
}
.detail-card dl {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 7px 10px;
  font-size: 11.5px;
  margin: 12px 0 0;
}
.detail-card dt {
  color: var(--muted);
}
.detail-card dd {
  margin: 0;
}
.step-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: baseline;
  border-top: 1px solid var(--line);
  padding: 9px 0;
  font-size: 12px;
  width: 100%;
  background: transparent;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  text-align: left;
  color: inherit;
  font-family: inherit;
}
.step-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}
.step-row small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 10.5px;
}
.step-row .state {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.step-row .state.open {
  color: var(--running);
}
.step-row .state.done {
  color: var(--done);
}
.step-row .state.stopped {
  color: var(--stopped);
}
/* A step of the reader's own is a way in to doing it, so it is coloured and captioned
   like a link. Styled the same as the plain rows it sits among, it read as text. */
button.step-row {
  cursor: pointer;
}
button.step-row strong {
  color: var(--brand, #007b77);
}
/* Each kind of row says what it opens. One shared caption put "Open this step" under a
   sub-process, which is not a step. */
button.step-row:after {
  grid-column: 1 / -1;
  color: var(--brand, #007b77);
  font-size: 10.5px;
  font-weight: 650;
}
button.step-row[data-open-task]:after {
  content: "Open this step →";
}
button.step-row[data-linked-case]:after {
  content: "Open this process →";
}
button.step-row:hover strong,
button.step-row:hover:after {
  text-decoration: underline;
}
button.step-row:focus-visible {
  outline: 2px solid var(--brand, #007b77);
  outline-offset: 2px;
  border-radius: 6px;
}
.detail-action {
  display: block;
  width: 100%;
  margin-top: 11px;
  padding: 9px 12px;
  border: 1px solid var(--brand, #007b77);
  border-radius: 8px;
  background: var(--brand, #007b77);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.detail-action.quiet {
  background: #fff;
  color: var(--brand, #007b77);
}
.detail-action:hover {
  filter: brightness(0.95);
}
/* The way back out of the drawer. On a wide screen the panel sits beside the list and
     there is nothing to go back from, so it is not there. */
.detail-back {
  display: none;
}
@media (max-width: 1000px) {
  .detail-back {
    display: block;
    width: 100%;
    min-height: 44px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink, #27272a);
    font-size: 12px;
    font-weight: 650;
    text-align: left;
    padding: 0 12px;
    cursor: pointer;
  }
}
.activity {
  border-left: 1px solid #cfd5df;
  padding: 0 0 14px 16px;
  position: relative;
  font-size: 11px;
}
.activity:last-child {
  padding-bottom: 0;
  border-left-color: transparent;
}
.activity:before {
  content: "";
  position: absolute;
  left: -4px;
  top: 3px;
  width: 7px;
  height: 7px;
  background: var(--running);
  border-radius: 50%;
}
.activity strong {
  display: block;
  font-weight: 600;
}
.activity time {
  color: var(--muted);
}

/* ---- nothing here ---- */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 46px 18px;
  font-size: 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.empty h2 {
  color: var(--ink, #27272a);
  font-size: 15px;
  margin: 0 0 6px;
}
.empty p {
  margin: 0;
  max-width: 34em;
  margin-inline: auto;
  line-height: 1.55;
}
#case-detail .empty {
  border: 0;
}
#case-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  opacity: 0;
  background: #142033;
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 11px;
  transform: translate(-50%, 15px);
  transition: 0.2s;
  pointer-events: none;
}
#case-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1000px) {
  body[data-master-page="cases"] .library-shell.case-shell {
    grid-template-columns: var(--bb-rail-w) minmax(0, 1fr);
  }
  #case-detail {
    position: absolute;
    inset: 0 0 0 auto;
    width: min(380px, 94vw);
    transform: translateX(100%);
    transition: 0.18s;
    box-shadow: -10px 0 30px #0002;
    z-index: 4;
  }
  .case-shell.detail-open #case-detail {
    transform: none;
  }
}
@media (max-width: 760px) {
  .case-title {
    flex-direction: column;
    gap: 3px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .case-row,
  #case-toast,
  #case-detail {
    transition: none;
  }
}

/* ORANGE BEFORE RED. A case whose open step is inside its warning window; past due stays red. */
.flag.soon{background:#fff3df;color:var(--warning,#b45309)}
.step-row .state.open.soon{background:#fff3df;color:var(--warning,#b45309)}
.step-row .state.open.late{background:#fff0f1;color:var(--danger,#b42318)}

/* ---- where everything is up to (the customer's review, 2026-11-03) ---- */
/* Whose list, in one line under the heading. */
.case-lead {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.case-lead:empty {
  display: none;
}
/* One person's work: who has it, beside the search. */
.case-holder {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.case-holder[hidden] {
  display: none;
}
.case-holder select {
  height: 40px;
  max-width: 260px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  color: var(--ink, #27272a);
  background: #fff;
}
/* The stage a step is in, by the map's own name. */
.case-now .stage,
.step-row .step-stage {
  font-size: 10.5px;
  font-weight: 650;
  color: var(--running);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 2px 8px;
  white-space: nowrap;
}
.step-row .step-stage {
  grid-column: 1 / -1;
  justify-self: start;
}
/* The administrator's help on one step, under it. */
.step-help {
  padding: 0 0 9px;
}
.link-action {
  border: 0;
  background: none;
  padding: 0;
  color: var(--brand, #007b77);
  font: inherit;
  font-size: 11.5px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: underline;
}
.step-help .link-action + .link-action {
  margin-left: 14px;
}
/* Why the administrator cannot take this check themselves, and who can (stepInWhy). */
.step-why {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.hand-over,
.take-over,
.case-move {
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft, #f7f8fa);
  font-size: 12px;
}
.hand-over[hidden],
.take-over[hidden],
.case-move[hidden] {
  display: none;
}
.take-over p {
  margin: 0 0 8px;
  color: var(--ink, #27272a);
  line-height: 1.45;
}
.hand-over label,
.case-move label {
  display: grid;
  gap: 4px;
  color: var(--muted);
}
.hand-over select,
.case-move select {
  height: 36px;
  border: 1px solid #d0d5dd;
  border-radius: 7px;
  padding: 0 8px;
  font: inherit;
  color: var(--ink, #27272a);
  background: #fff;
  width: 100%;
}
.case-move p {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.45;
}
.case-move .move-plan {
  margin: 8px 0 0;
  color: var(--ink, #27272a);
}
.hand-over-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.hand-over-actions .detail-action {
  width: auto;
}
.hand-over-actions .detail-action[hidden] {
  display: none;
}
@media (max-width: 760px) {
  .case-holder select {
    max-width: 100%;
  }
}
/* The links sent from a case's record (cases.js loadRecordShares, #11788). */
.case-record-sent ul { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.case-record-sent li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12.5px; }
.case-record-sent-who { flex: 1 1 100%; overflow-wrap: anywhere; }

/* Export the Record (cases.js): each label above its field, fields full width and 16px (no iOS zoom), and a
   Send button a thumb can hit. It had no styles: labels ran into their boxes ("Their / name") and the boxes were
   bare 28px inputs (phone sweep, 25 Nov). */
.case-record-share { display: grid; gap: 10px; margin-top: 8px; }
.case-record-share label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink, #171b26); }
.case-record-share input { box-sizing: border-box; width: 100%; min-height: 40px; padding: 0 10px; border: 1px solid #d0d5dd; border-radius: 8px; font: inherit; font-size: 14px; }
.case-record-share [data-case-record-send] { justify-self: start; }
@media (max-width: 640px) {
  .case-record-share input { min-height: 44px; font-size: 16px; }
  .case-record-share [data-case-record-send] { min-height: 44px; }
}
