/* Admin directory only; diary history and client meal pages retain their styles. */
.client-directory {
  --dir-ink: #203641;
  --dir-green: #20534e;
  --dir-muted: #647b8c;
  color: var(--dir-ink);
  font: var(--ui-caption)/var(--ui-leading) var(--ui-font);
  padding: 0 0 12px;
  min-width: 0;
}
.client-directory * {
  box-sizing: border-box;
}
.client-directory svg {
  width: 20px;
  height: 20px;
  flex: none;
  vertical-align: middle;
}
.client-directory button,
.client-directory select,
.client-directory input {
  font: inherit;
  min-width: 0;
}
.client-directory button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #d7e1df;
  border-radius: 9px;
  padding: 10px 13px;
  background: white;
  color: var(--dir-green);
  cursor: pointer;
  line-height: var(--ui-leading);
}
.client-directory button:hover {
  filter: brightness(0.97);
}
.client-directory button:focus-visible,
.client-directory summary:focus-visible,
.directory-table-wrap:focus-visible {
  outline: 2px solid #236f61;
  outline-offset: 3px;
}
.client-directory button:disabled {
  opacity: 0.4;
  cursor: default;
  filter: none;
}
.directory-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 4px 0 26px;
}
.directory-heading > div {
  display: flex;
  align-items: center;
  gap: 20px;
}
.directory-heading h1 {
  font: normal 48px/1.12 var(--ui-font);
  color: var(--dir-green);
  margin: 0;
}
.directory-total {
  font-weight: 600;
  white-space: nowrap;
  background: #eaf0ec;
  color: var(--dir-green);
  padding: 7px 13px;
  border-radius: 17px;
}
.client-directory .directory-primary {
  background: linear-gradient(125deg, #285b55, #174740);
  color: #fff;
  border-color: #174740;
  min-height: 44px;
  padding: 11px 19px;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px #ffffff13;
}
.directory-heading .directory-create {
  gap: 8px;
}
.directory-more {
  position: relative;
}
.directory-more summary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 38px;
  cursor: pointer;
  list-style: none;
  color: var(--dir-muted);
}
.directory-more summary::-webkit-details-marker {
  display: none;
}
.directory-more > div {
  position: absolute;
  top: 45px;
  right: 0;
  background: white;
  padding: 8px;
  border-radius: 10px;
  box-shadow: 0 5px 24px #1d383422;
  z-index: 5;
  min-width: 245px;
}
.directory-more button {
  width: 100%;
}
.directory-filters {
  display: grid;
  grid-template-columns:
    minmax(210px, 1.35fr) minmax(170px, 1.08fr) minmax(130px, 0.95fr) minmax(150px, 0.95fr) minmax(175px, 1fr)
    auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.directory-filters select,
.directory-search {
  margin: 0;
  height: 46px;
  border: 1px solid #d9e2e5;
  border-radius: 11px;
  background: #fff;
  color: #516f80;
  box-shadow: 0 1px 2px #1d383403;
}
.directory-filters select {
  width: 100%;
  padding: 10px 32px 10px 15px;
  text-overflow: ellipsis;
}
.directory-filters select[name='directory-status'] {
  color: var(--dir-green);
  font-weight: 600;
}
.directory-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
}
.directory-search input {
  border: 0;
  box-shadow: none !important;
  outline: none;
  width: 100%;
  padding: 10px 0;
  background: transparent;
  color: var(--dir-ink);
}
.directory-search:focus-within {
  outline: 2px solid #8db8ac;
  outline-offset: 1px;
}
.directory-search input::placeholder {
  color: var(--ui-muted);
  opacity: 1;
}
.client-directory .directory-reset {
  border: 0;
  padding: 8px 4px;
  background: transparent;
  white-space: nowrap;
  color: #486d81;
}
.directory-chips {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 6px;
  margin: 0 0 22px;
}
.client-directory .directory-chip {
  border: 1px solid transparent;
  border-radius: 28px;
  padding: 10px 13px;
  gap: 9px;
  font-weight: 500;
  white-space: nowrap;
  font-size: var(--ui-caption);
  flex: 1 0 auto;
}
.directory-chip b {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 29px;
  border-radius: 18px;
  padding: 0 9px;
  background: #ffffff48;
  font-size: var(--ui-caption);
  font-weight: 600;
}
.directory-chip.blue {
  color: #275d82;
  background: #e6f1ff;
}
.directory-chip.blue b {
  background: #cfe2fa;
}
.directory-chip.red {
  color: #cc1328;
  background: #ffe8ec;
}
.directory-chip.red b {
  background: #ffcbd2;
}
.directory-chip.orange {
  color: #ac4402;
  background: #fff0de;
}
.directory-chip.orange b {
  background: #ffdfbe;
}
.directory-chip.peach {
  color: #b84019;
  background: #ffede5;
}
.directory-chip.peach b {
  background: #ffddce;
}
.directory-chip.yellow {
  color: #905709;
  background: #fff5d7;
}
.directory-chip.yellow b {
  background: #ffebba;
}
.directory-chip.pink {
  color: #cc213f;
  background: #ffe6eb;
}
.directory-chip.pink b {
  background: #ffccd7;
}
.directory-chip.purple {
  color: #7040be;
  background: #f0e7ff;
}
.directory-chip.purple b {
  background: #e0ceff;
}
.client-directory .directory-chip[aria-pressed='true'] {
  box-shadow: inset 0 0 0 1px currentColor;
}
.directory-table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid #dce6e2;
  border-radius: 11px;
  background: #fff;
  overscroll-behavior-inline: contain;
}
.main:has(.client-directory) {
  max-width: none;
}
.directory-table {
  width: 100%;
  min-width: 1390px;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--ui-caption);
  line-height: var(--ui-leading);
}
.directory-table th {
  background: #eef2ef;
  font-weight: 500;
  color: #285156;
  text-align: left;
  padding: 19px 10px;
  vertical-align: middle;
  border: 0;
  border-bottom: 1px solid #dce6e2;
  white-space: nowrap;
}
.directory-table td {
  background: transparent;
  vertical-align: top;
  padding: 18px 9px;
  border: 0;
  border-bottom: 1px solid #e3e9e6;
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
  min-width: 0;
  max-width: none;
  color: var(--dir-ink);
}
.directory-table .directory-empty {
  white-space: normal;
}
.directory-access-remaining {
  font-weight: 500;
}
.directory-table tr:last-child td {
  border-bottom: 0;
}
.directory-table th:first-child,
.directory-table td:first-child {
  padding-left: 13px;
  padding-right: 3px;
}
.directory-heading-nowrap {
  white-space: nowrap;
  font-size: var(--ui-caption);
}
.directory-table tr.directory-attention {
  background: linear-gradient(110deg, #fff6f6, #fffafa);
}
.directory-table .directory-attention td {
  border-bottom-color: #efdddd;
}
.directory-avatar {
  position: relative;
  width: 56px;
  height: 56px;
  margin: 7px 0;
}
.directory-avatar img,
.directory-avatar > span {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e3eee8;
  color: #497768;
  font-size: 22px;
}
.directory-avatar b {
  position: absolute;
  right: -3px;
  top: -9px;
  border: 2px solid white;
  border-radius: 50%;
  width: 25px;
  height: 25px;
  background: #e73442;
  color: white;
  font: 600 var(--ui-body)/22px var(--ui-font);
  text-align: center;
}
.directory-name {
  display: block;
  font-size: var(--ui-caption);
  line-height: var(--ui-leading);
  font-weight: 600;
  margin: 5px 0;
}
.directory-name span {
  display: block;
  font-weight: 500;
}
.directory-contacts {
  display: grid;
  gap: 3px;
  color: var(--dir-muted);
  padding-top: 5px;
  font-size: var(--ui-caption);
}
.directory-subline {
  display: block;
  color: var(--dir-muted);
  margin-top: 4px;
}
.directory-nowrap {
  white-space: nowrap;
  display: inline-block;
  padding-top: 5px;
  font-variant-numeric: tabular-nums;
}
.directory-status {
  display: inline-block;
  padding: 6px 13px;
  border-radius: 10px;
  background: #e4f5eb;
  color: #04874e;
  font-weight: 600;
  margin-bottom: 7px;
}
.directory-status.incoming {
  background: #fff0d7;
  color: #96620a;
}
.directory-status.archived {
  background: #eef0f1;
  color: #62717b;
}
.directory-access {
  font-size: var(--ui-caption);
  line-height: var(--ui-leading);
  color: #5c7484;
  font-variant-numeric: tabular-nums;
}
.directory-access span {
  display: block;
}
.directory-summary {
  padding: 10px;
  border-radius: 13px;
  display: grid;
  align-content: start;
  gap: 5px;
  line-height: var(--ui-leading);
  font-size: var(--ui-caption);
  min-height: 84px;
}
.directory-summary strong {
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 5px;
}
.directory-summary svg {
  width: 17px;
  height: 17px;
}
.directory-summary > span {
  display: block;
}
.directory-summary small {
  font-size: var(--ui-caption);
  color: inherit;
  opacity: 0.85;
}
.directory-summary.mint {
  background: #eaf6ef;
  color: #22685c;
}
.directory-summary.amber {
  background: #fff0d5;
  color: #705720;
}
.directory-summary.rose {
  background: #ffe8e9;
  color: #704249;
}
.directory-summary.neutral {
  background: #f3f5f5;
  color: var(--ui-muted);
}
.directory-summary details {
  margin-top: 2px;
}
.directory-summary summary {
  cursor: pointer;
  color: var(--dir-green);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: var(--ui-caption);
}
.directory-medicine {
  line-height: var(--ui-leading);
}
.directory-medicine + .directory-medicine {
  margin-top: 3px;
}
.directory-medicine > span {
  display: block;
}
.directory-medicine small {
  display: block;
  font-size: var(--ui-caption);
}
.client-directory .directory-critical {
  color: #ce2435;
  font-weight: 600;
}
.directory-diary {
  display: grid;
  gap: 6px;
  padding-top: 5px;
  font-size: var(--ui-caption);
}
.directory-diary > span:first-child {
  font-size: var(--ui-caption);
  font-variant-numeric: tabular-nums;
}
.directory-diary strong,
.directory-diary span:not(:first-child) {
  display: flex;
  gap: 5px;
  align-items: flex-start;
}
.directory-diary svg {
  width: 16px;
  height: 16px;
  margin-top: 1px;
}
.directory-good {
  color: #1d8760;
  font-weight: 500;
}
.directory-muted {
  color: var(--dir-muted);
}
.directory-actions {
  display: grid;
  gap: 8px;
}
.directory-actions button {
  width: 100%;
  min-height: 39px;
  font-size: var(--ui-caption);
  padding: 9px 7px;
  white-space: nowrap;
}
.directory-actions svg {
  width: 17px;
  height: 17px;
}
.client-directory .directory-reply {
  background: linear-gradient(135deg, #e72e3c, #e74746);
  color: white;
  border-color: #e43a43;
  font-weight: 600;
}
.client-directory .directory-remind {
  background: #ffecd1;
  color: #b44705;
  border-color: transparent;
  font-weight: 600;
}
.client-directory .directory-sent:disabled {
  opacity: 1;
  background: #e7f5ed;
  color: #237052;
  border: 1px solid #c5e3d2;
  cursor: default;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  line-height: var(--ui-leading);
}
.directory-sent > span {
  font-size: var(--ui-caption);
  font-weight: 400;
}
.directory-sent strong {
  font-size: var(--ui-caption);
  display: flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
}
.directory-sent small {
  display: block;
  font-size: var(--ui-caption);
  font-weight: 400;
  color: #4a7867;
}
.directory-sent svg {
  width: 14px;
  height: 14px;
}
.directory-comment {
  border-radius: 12px;
  padding: 9px;
  background: #f2f5f3;
  font-size: var(--ui-caption);
  line-height: var(--ui-leading);
  white-space: pre-wrap;
  max-height: 150px;
  overflow: auto;
}
.directory-comment.rose {
  background: #ffe8ea;
  color: #8d3339;
}
.client-directory .directory-comment-link {
  display: flex;
  border: 0;
  background: transparent;
  padding: 7px 2px;
  color: #81494b;
  justify-content: flex-start;
  font-size: var(--ui-caption);
  text-align: left;
  gap: 5px;
}
.directory-comment-link svg {
  width: 17px;
  height: 17px;
}
.directory-footer {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 17px 4px 0;
  color: #5d7584;
  font-size: var(--ui-caption);
}
.directory-footer label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  white-space: nowrap;
}
.directory-footer select {
  border: 1px solid #d2deda;
  border-radius: 9px;
  padding: 9px 30px 9px 12px;
  background: white;
  color: #244550;
  min-width: 80px;
  width: auto;
}
.directory-footer nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.directory-footer nav button,
.directory-footer nav [aria-current] {
  height: 40px;
  min-width: 40px;
  padding: 9px;
  display: grid;
  place-items: center;
  border-radius: 9px;
}
.directory-footer nav [aria-current] {
  background: #277359;
  color: white;
  font-size: var(--ui-body);
}
.directory-footer .directory-empty,
.directory-table .directory-empty {
  text-align: center;
  padding: 45px 20px;
  color: var(--dir-muted);
}
@media (min-width: 1850px) {
  .directory-table {
    font-size: var(--ui-caption);
  }
  .directory-name,
  .directory-contacts,
  .directory-diary > span:first-child {
    font-size: var(--ui-caption);
  }
  .directory-summary,
  .directory-comment,
  .directory-access,
  .directory-diary {
    font-size: var(--ui-caption);
  }
  .directory-summary small,
  .directory-medicine small {
    font-size: var(--ui-caption);
  }
  .directory-table td {
    padding-top: 20px;
    padding-bottom: 20px;
  }
}
@media (max-width: 1550px) {
  .directory-filters {
    grid-template-columns: minmax(190px, 1.2fr) minmax(150px, 1fr) minmax(130px, 0.85fr) minmax(140px, 0.9fr) minmax(
        150px,
        1fr
      );
  }
  .client-directory .directory-reset {
    grid-column: 5;
    justify-self: end;
    padding-top: 0;
  }
  .directory-filters {
    row-gap: 7px;
    margin-bottom: 15px;
  }
  .directory-chips {
    gap: 7px;
  }
  .client-directory .directory-chip {
    font-size: var(--ui-caption);
    padding: 9px 10px;
    gap: 6px;
  }
}
@media (max-width: 1100px) {
  .directory-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .directory-search {
    grid-column: span 2;
  }
  .client-directory .directory-reset {
    grid-column: auto;
    justify-self: start;
    padding: 8px 0;
  }
  .directory-heading h1 {
    font-size: 39px;
  }
  .directory-chips {
    justify-content: flex-start;
  }
  .client-directory .directory-chip {
    flex: 0 0 auto;
  }
  .directory-heading {
    margin-bottom: 20px;
  }
}
@media (max-width: 650px) {
  .directory-heading {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 14px;
  }
  .directory-heading > div {
    gap: 12px;
  }
  .directory-heading h1 {
    font-size: 34px;
  }
  .directory-total {
    font-size: var(--ui-caption);
  }
  .directory-heading .directory-create {
    margin-left: auto;
  }
  .directory-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .directory-search {
    grid-column: 1/-1;
  }
  .directory-filters select {
    font-size: var(--ui-caption);
    padding-left: 10px;
  }
  .client-directory .directory-reset {
    grid-column: 1/-1;
  }
  .directory-chips {
    flex-wrap: nowrap;
    overflow: auto;
    padding: 3px 1px 10px;
    scrollbar-width: thin;
    max-width: 100%;
    margin-bottom: 10px;
  }
  .client-directory .directory-chip {
    flex-shrink: 0;
  }
  .directory-footer {
    flex-wrap: wrap;
    gap: 12px;
    font-size: var(--ui-caption);
  }
  .directory-footer nav {
    width: 100%;
    justify-content: flex-end;
  }
  .directory-table-wrap {
    border-radius: 8px;
  }
  .client-directory .directory-primary {
    font-size: var(--ui-caption);
    min-height: 40px;
  }
}

/* Long staff drafts have a proper editor, independent of the compact chat bar. */
.readable-message-modal {
  max-width: 820px;
  width: min(820px, calc(100vw - 40px));
  font-family: var(--ui-font);
}
.readable-message-modal .modalhead {
  gap: 12px;
  align-items: center;
}
.readable-message-modal .modalhead h2 {
  flex: 1;
  font-family: var(--ui-font);
  line-height: var(--ui-leading);
}
.readable-message-modal .message-size-toggle {
  font: var(--ui-caption) var(--ui-font);
  padding: 8px 12px;
  white-space: nowrap;
}
.readable-message-modal .compose-bar {
  display: grid;
  grid-template-columns: 40px 40px 40px 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
}
.readable-message-modal .compose-bar textarea {
  grid-column: 1/-1;
  grid-row: 1;
  width: 100%;
  min-height: 180px !important;
  height: 180px;
  max-height: 60vh;
  resize: vertical;
  overflow: auto;
  padding: 14px;
  margin: 0 0 8px;
  background: #fff;
  font: var(--ui-body)/var(--ui-leading) var(--ui-font);
  border-bottom: 1px solid #e0e7e2;
  border-radius: 0;
  box-sizing: border-box;
}
.readable-message-modal .compose-bar .compose-icon,
.readable-message-modal .compose-bar .emoji-picker {
  grid-row: 2;
  margin: 0;
}
.readable-message-modal .compose-bar .compose-send {
  grid-row: 2;
  grid-column: 5;
  width: auto;
  min-width: 136px;
  height: 42px;
  display: flex;
  gap: 8px;
  padding: 10px 15px;
  border-radius: 8px;
  font: 600 var(--ui-caption) var(--ui-font);
}
.readable-message-modal .compose-send:disabled {
  opacity: 0.65;
  cursor: wait;
}
.readable-message-modal .compose-send svg {
  width: 20px;
  height: 20px;
  flex: none;
}
.readable-message-modal.message-expanded {
  width: calc(100vw - 48px);
  max-width: 1300px;
  max-height: calc(100dvh - 48px);
}
.readable-message-modal.message-expanded .compose-bar textarea {
  min-height: 45vh !important;
}
.readable-message-modal .form-actions {
  margin-top: 15px;
}
@media (max-width: 650px) {
  .readable-message-modal {
    width: 100%;
    padding: 18px;
  }
  .readable-message-modal .modalhead {
    flex-wrap: wrap;
    gap: 8px;
  }
  .readable-message-modal .modalhead h2 {
    flex: 1 1 100%;
    font-size: 24px;
  }
  .readable-message-modal .message-size-toggle {
    margin-left: auto;
  }
  .readable-message-modal .compose-bar {
    grid-template-columns: 32px 32px 32px 1fr auto;
    gap: 2px;
    padding: 6px;
  }
  .readable-message-modal .compose-bar textarea {
    padding: 10px;
    min-height: 210px !important;
  }
  .readable-message-modal .compose-bar .compose-send {
    min-width: 115px;
    padding: 8px 10px;
    font-size: var(--ui-caption);
  }
  .readable-message-modal.message-expanded {
    width: 100%;
    max-height: calc(100dvh - 20px);
  }
}

/* Shared chain navigation and the single-row assignment journal. */
.chain-text-link,
.client-directory .chain-text-link,
.workspace-page .chain-text-link {
  display: inline;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #23695b;
  text-align: left;
  line-height: var(--ui-leading);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: #a6c7bc;
  text-underline-offset: 3px;
  cursor: pointer;
  box-shadow: none;
}
.directory-chain {
  display: grid;
  gap: 5px;
  font-size: var(--ui-caption);
  line-height: var(--ui-leading);
}
.directory-chain small {
  display: block;
  color: var(--ui-muted);
  font-size: var(--ui-caption);
}
.directory-table td.directory-chain-ending {
  background: #fff3d6;
  box-shadow: inset 3px 0 #d4a347;
}
.chain-ending-label {
  color: #8b5b12;
  font-weight: 600;
  font-size: var(--ui-caption);
}
.directory-filters {
  grid-template-columns:
    minmax(210px, 1.25fr) minmax(200px, 1.1fr) repeat(2, minmax(130px, 1fr)) repeat(2, minmax(145px, 1fr))
    minmax(180px, 1fr) auto;
}
.client-directory .directory-reset {
  grid-column: auto;
}
.chain-journal {
  font: var(--ui-caption)/var(--ui-leading) var(--ui-font);
  min-width: 0;
}
.chain-journal h1 {
  font: 32px/var(--ui-leading) var(--ui-font);
  margin: 0 0 24px;
  color: #204e44;
}
.chain-journal-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 18px;
  background: #f3f7f4;
  border: 1px solid #dce7e0;
  border-radius: 12px;
  margin-bottom: 20px;
}
.chain-journal-filters label {
  margin: 0;
  font-size: var(--ui-caption);
  color: #4d6860;
}
.chain-journal-filters input,
.chain-journal-filters select {
  display: block;
  width: 100%;
  margin-top: 6px;
  height: 42px;
  background: white;
  font: var(--ui-caption) var(--ui-font);
}
.chain-journal-filters > button {
  justify-self: start;
  align-self: end;
}
.chain-journal-table {
  min-width: 970px;
  width: 100%;
}
.chain-journal-table th {
  white-space: nowrap;
}
.chain-journal-table td {
  vertical-align: top;
  padding: 18px 12px;
}
.chain-journal-table small {
  display: block;
  color: var(--ui-muted);
  font-size: var(--ui-caption);
  margin-top: 6px;
}
.chain-journal-table td:first-child {
  width: 22%;
}
.chain-journal-table td:nth-child(2) {
  width: 23%;
}
.chain-journal-table td:nth-child(3) {
  white-space: nowrap;
}
.chain-state {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 7px;
  background: #eef1f0;
  color: #63726a;
  white-space: nowrap;
}
.chain-state.active {
  background: #e3f3e9;
  color: #1f7351;
}
.chain-state.scheduled {
  background: #eaf0fd;
  color: #4c68a1;
}
.chain-state.cancelled,
.chain-deletion {
  color: #916245;
}
.chain-deletion {
  display: block;
  font-size: var(--ui-caption);
  line-height: var(--ui-leading);
  margin: 6px 0;
}
.chain-preview-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 16px 20px;
  margin: 10px 0 22px;
  border: 1px solid #c9dfd3;
  border-radius: 12px;
  background: #edf6f0;
  color: #245b47;
}
.chain-preview-banner p {
  margin: 5px 0 0;
  font-size: var(--ui-caption);
}
.chain-preview-banner button {
  flex: none;
  background: #fff;
}
.ws-history-link {
  margin: 0 0 16px;
}
.ws-chain-head .ws-tools {
  max-width: 52%;
  flex-wrap: wrap;
}
.ws-chain-head h2 .chain-text-link {
  font-size: inherit;
}
.ws-chain[data-assignment] {
  scroll-margin-top: 20px;
}
@media (max-width: 1600px) {
  .directory-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .directory-search {
    grid-column: auto;
  }
  .client-directory .directory-reset {
    justify-self: start;
    grid-column: auto;
  }
}
@media (max-width: 900px) {
  .chain-journal-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ws-chain-head .ws-tools {
    max-width: 100%;
  }
}
@media (max-width: 650px) {
  .directory-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .directory-search {
    grid-column: 1/-1;
  }
  .chain-journal-filters {
    padding: 12px;
    gap: 10px;
  }
  .chain-preview-banner {
    align-items: flex-start;
    flex-direction: column;
  }
  .chain-journal h1 {
    font-size: 26px;
  }
}

/* Access expiry and name navigation in the client directory. */
.directory-days-filter {
  position: relative;
  margin: 0;
  min-width: 0;
}
.directory-days-filter > span {
  position: absolute;
  top: -9px;
  left: 12px;
  padding: 0 4px;
  background: #fff;
  color: var(--dir-green);
  font-size: 12px;
  line-height: 18px;
  border-radius: 4px;
  z-index: 1;
}
.client-directory .directory-name-link {
  display: block;
  border: 0;
  border-radius: 2px;
  padding: 0;
  margin: 5px 0;
  background: transparent;
  box-shadow: none;
  color: var(--dir-green);
  text-align: left;
  font-weight: 600;
  line-height: var(--ui-leading);
  text-decoration: underline;
  text-decoration-color: #a6c7bc;
  text-underline-offset: 3px;
  white-space: nowrap;
}
.client-directory .directory-name-link:hover {
  color: #14735f;
  text-decoration-color: currentColor;
}
.directory-access-remaining {
  display: block;
  margin-top: 5px;
  font-weight: 600;
  white-space: nowrap;
}
.directory-diary-actions {
  margin-top: 10px;
}

.chain-library-count {
  margin: 0 0 12px;
  color: var(--ui-muted);
}
.chain-journal-selection {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: #f3f7f4;
  border: 1px solid #dce7e0;
  border-radius: 10px;
}
.chain-journal-selection p {
  margin: 5px 0;
}
.chain-journal-selection .chain-tags {
  margin: 8px 0 0;
}
.chain-journal-selection button {
  flex-shrink: 0;
}
@media (max-width: 650px) {
  .chain-journal-selection {
    align-items: flex-start;
    flex-direction: column;
  }
}

.directory-table [data-column='tags'],
.directory-table [data-column='workMode'] {
  min-width: 170px;
  max-width: 260px;
  white-space: normal;
}
.directory-table [data-column='name'] {
  min-width: 180px;
}
.directory-column-dialog {
  width: min(620px, 94vw);
  max-height: 90dvh;
  border: 0;
  border-radius: 14px;
  padding: 24px;
  color: #203641;
  overflow: auto;
}
.directory-column-dialog::backdrop {
  background: #142c2566;
}
.directory-column-dialog h2 {
  margin-top: 0;
}
.directory-column-dialog p {
  line-height: var(--ui-leading);
}
.directory-column-list {
  display: grid;
  gap: 6px;
}
.directory-column-list > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px 38px;
  gap: 6px;
  align-items: center;
  border-bottom: 1px solid #e0e8e2;
  padding: 5px 0;
}
.directory-column-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  overflow-wrap: anywhere;
}
.directory-column-list input {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin: 0;
}
.directory-column-list button {
  padding: 5px;
  min-height: 34px;
}
.directory-column-dialog .form-actions {
  position: sticky;
  bottom: -24px;
  background: white;
  padding: 16px 0 4px;
  flex-wrap: wrap;
}
@media (max-width: 650px) {
  .directory-column-dialog {
    padding: 16px;
  }
  .directory-column-dialog .form-actions {
    bottom: -16px;
  }
}

.directory-table td.directory-editable {
  cursor: pointer;
}
.directory-table td.directory-editable:hover {
  background: #eaf2ed;
}
.directory-table td.directory-editable:focus-visible {
  outline: 2px solid #236f61;
  outline-offset: -3px;
  background: #eaf2ed;
}
.directory-table td[data-column='tags'] .client-tags {
  margin: 0;
}

.directory-journal-link {
  display: flex;
  justify-content: flex-end;
  margin: -7px 0 18px;
  min-width: 0;
}
.directory-journal-link a {
  color: #315e52;
  font-size: var(--ui-caption);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.directory-table th,
.directory-table td {
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 0;
  max-width: none;
}
.directory-table .directory-chain {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  max-width: 100%;
}
.directory-table .directory-chain .chain-text-link {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}
.directory-table .directory-contacts,
.directory-table .directory-summary,
.directory-table .directory-diary,
.directory-table .directory-access {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}
.directory-table .directory-summary strong {
  min-width: 0;
  overflow-wrap: anywhere;
}
.directory-table td[data-column='tags'],
.directory-table td[data-column='workMode'],
.directory-table td[data-column='name'] {
  min-width: 0;
  max-width: none;
}
.client-lifecycle-journal {
  min-width: 0;
}
.client-lifecycle-journal h1 {
  margin-top: 20px;
}
.client-lifecycle-journal table {
  min-width: 780px;
  width: 100%;
  table-layout: fixed;
}
.client-lifecycle-journal th,
.client-lifecycle-journal td {
  white-space: normal;
  overflow-wrap: anywhere;
  vertical-align: top;
}
.client-lifecycle-journal th:nth-child(1) {
  width: 18%;
}
.client-lifecycle-journal th:nth-child(2) {
  width: 20%;
}
.client-lifecycle-journal th:nth-child(3) {
  width: 18%;
}
.client-lifecycle-journal th:nth-child(4) {
  width: 18%;
}
@media (max-width: 650px) {
  .directory-journal-link {
    margin: 4px 0 16px;
  }
}

/* Calm quick filters; only an actionable count uses red. */
.client-directory .directory-chip {
  background: #edf2ef;
  color: #466358;
  border-color: transparent;
}
.client-directory .directory-chip b {
  background: transparent;
  color: inherit;
}
.client-directory .directory-chip b.needs-attention {
  background: #f8dfe1;
  color: #b82f3c;
}
.client-directory .directory-chip[aria-pressed='true'] {
  border-color: #90a99c;
  box-shadow: none;
}
.directory-table th {
  position: relative;
  white-space: normal;
  padding-right: 17px;
  overflow-wrap: anywhere;
}
.directory-table td {
  white-space: normal;
  overflow-wrap: anywhere;
  overflow: hidden;
}
.directory-table .directory-resize {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 10px;
  cursor: col-resize;
  touch-action: none;
  z-index: 2;
}
.directory-resize:after {
  content: '';
  position: absolute;
  right: 3px;
  top: 20%;
  height: 60%;
  width: 2px;
  background: #bbcfc3;
  border-radius: 2px;
}
.directory-resize:hover:after,
.directory-resize:focus:after {
  background: #3b6750;
  width: 3px;
}
.directory-resize:focus-visible {
  outline: 2px solid #3b6750;
  outline-offset: -2px;
}
.directory-resizing,
.directory-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}
.directory-table .directory-access-days {
  display: block;
  margin-top: 2px;
}

.directory-table [data-column] {
  min-width: 0;
  max-width: none;
}
.client-directory .directory-table .directory-name-link,
.directory-table .directory-actions button {
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Compact directory cells and independent quick-filter configuration. */
.client-directory .directory-filter-strip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  margin: 0 0 12px;
}
.client-directory .directory-filter-strip .directory-chips {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding-bottom: 6px;
}
.client-directory .directory-filter-columns {
  flex: none;
  min-height: 42px;
  white-space: nowrap;
}
.client-directory .directory-table td {
  text-align: left;
  vertical-align: top;
  padding-top: 10px;
  padding-bottom: 10px;
  line-height: var(--ui-leading);
}
.client-directory .directory-table :is(.directory-chain, .directory-diary, .directory-summary) {
  text-align: left;
  align-content: start;
  justify-items: start;
  gap: 3px;
  line-height: var(--ui-leading);
  padding-top: 0;
}
.client-directory .directory-table .directory-summary {
  padding: 8px;
}
.client-directory .directory-chain :is(button, span, small),
.client-directory .directory-diary :is(span, strong, a) {
  text-align: left;
  justify-content: flex-start;
  margin: 0;
}
.client-directory .directory-diary-actions {
  margin-top: 5px;
  gap: 5px;
  justify-items: start;
}
.client-directory .directory-sent:disabled {
  align-items: flex-start;
  justify-content: flex-start;
  text-align: left;
  padding: 7px 8px;
  gap: 2px;
  width: auto;
  max-width: 100%;
}
.client-directory .directory-sent .directory-sent-line {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  text-align: left;
}
.client-directory .directory-sent-line time {
  display: inline;
  font: inherit;
  font-weight: 400;
  white-space: nowrap;
}
.client-directory .directory-message-link {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  background: transparent;
  border: 0;
  padding: 5px 0;
  margin: 2px 0 0;
  text-align: left;
  color: #345f50;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: var(--ui-caption);
  min-height: 32px;
}
.client-directory .directory-message-link svg {
  width: 17px;
  height: 17px;
  flex: none;
}
.client-directory .directory-table td[data-column='diary'] {
  overflow-x: auto;
}

/* Keep filter actions inside the narrow viewport after all desktop overrides. */
@media (max-width: 650px) {
  .client-directory .directory-reset {
    grid-column: 1/-1;
    white-space: normal;
  }
  .client-directory .directory-filters > * {
    min-width: 0;
    max-width: 100%;
  }
  .client-directory .directory-create {
    flex-wrap: wrap;
    max-width: 100%;
  }
  .client-directory .directory-filter-strip {
    flex-wrap: wrap;
  }
  .client-directory .directory-filter-strip .directory-chips {
    flex-basis: 100%;
  }
}
