/*
 * Customers — everyone the store knows, one person per row, and the merge
 * bar that says two rows are one person. The table is the channel table's:
 * same head, same row height, mono figures on the right. What is new is the
 * first column of ticks and the list of identities under each name.
 */

.directory-panel {
  display: flex;
  flex-direction: column;
  margin-top: 14px;
}

.merge-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.merge-bar__count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--k-color-muted);
}

.merge-bar__submit[disabled] {
  cursor: default;
  opacity: 0.45;
}

.directory-table {
  min-width: 720px;
}

/* The ticks: the one column that is neither a name nor a figure, so it takes
   no more room than the box. */
.directory-table__tick {
  width: 28px;
  padding-inline-end: 8px !important;
  text-align: start !important;
}

.directory-table__tick input {
  width: 15px;
  height: 15px;
  margin: 0;
  vertical-align: middle;
  accent-color: var(--k-color-violet);
  cursor: pointer;
}

/* The name column is the second, behind the ticks, so the channel table's
   first-child rule does not reach it. */
.directory-table thead th:nth-child(2) {
  text-align: start;
}

/* A name over a list of identities is taller than a figure, so the row grows
   past the channel table's fixed height and the cells pad it instead. */
.directory-table tbody th,
.directory-table tbody td {
  height: auto;
  padding: 12px 0;
  vertical-align: top;
}

.directory-table tbody td {
  padding-top: 15px;
}

.directory-table tbody th {
  padding-inline-end: 24px;
  white-space: normal;
}

/* The name is the way into the person's page; it reads as a name until it
   is pointed at, so the table stays a table of people and not of links. */
.directory-table__name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.directory-table__name:hover {
  color: var(--k-color-violet-deep);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* A merged person is one the merchant made; the tag marks the rows that
   would not exist without a decision, so that a mistaken one is findable. */
.directory-table__merged .directory-table__name::after {
  content: "merged";
  margin-inline-start: 8px;
  padding: 1px 7px;
  font-size: 12px;
  font-weight: 700;
  vertical-align: 1px;
  color: var(--k-color-violet-deep);
  background: var(--k-color-lavender);
  border-radius: var(--k-radius-pill);
}

.identity-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.identity {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--k-color-ink-soft);
}

.identity .source-mark {
  width: 18px;
  height: 18px;
  margin-inline-end: 0;
  font-size: 9px;
}

.identity__detail {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--k-color-muted);
}

.identity__separate-form {
  display: inline;
}

/* Separating is the undo, and reads as a quiet link rather than a button so
   the row is still a row of names and not a row of controls. */
.identity__separate {
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--k-color-error);
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  border: 0;
  cursor: pointer;
}

.identity__separate:hover {
  color: color-mix(in srgb, var(--k-color-error) 75%, var(--k-color-ink));
}

.directory-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--k-color-line);
}

.directory-pagination__controls {
  display: flex;
  gap: 16px;
}

.directory-pagination__link {
  font-size: 12px;
  font-weight: 700;
  color: var(--k-color-ink-soft);
  text-decoration: none;
}

.directory-pagination__link:hover {
  color: var(--k-color-violet-deep);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.identity-list--page {
  margin-top: 12px;
}

.identity-list--page .identity {
  font-size: 13px;
}

/* An order is a short record rather than a table row: the main column is
   narrow beside the side panels, and six columns there either squeezed the
   product names into the next column or pushed the total under a scrollbar.
   Number and date lead, the total holds the right edge, the products take the
   full width beneath and wrap, and status and channel close the record. */
.order-list {
  margin: 0;
  padding: 0 20px 4px;
  list-style: none;
}

.order-list__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 16px;
  row-gap: 6px;
  padding: 14px 0;
}

.order-list__row + .order-list__row {
  border-top: 1px solid var(--k-color-line);
}

.order-list__row p {
  margin: 0;
}

.order-list__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--k-color-muted);
}

.order-list__number {
  font-size: 13px;
  font-weight: 600;
  color: var(--k-color-ink);
}

/* The one figure, set to the right and aligned like one. */
.order-list__total {
  text-align: end;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.order-list__refund {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--k-color-muted);
}

.order-list__items {
  grid-column: 1 / -1;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.order-list__meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--k-color-muted);
}

.order-list__status {
  color: var(--k-color-ink-soft);
}

/* A cancelled or test order is on the list, since it happened, and faded,
   since it counts for nothing. */
.order-list__row--void,
.order-list__row--void .order-list__number,
.order-list__row--void .order-list__status {
  color: var(--k-color-muted);
}

.order-list__row--void .order-list__number {
  text-decoration: line-through;
}

/* The day, said once across the thread rather than under every bubble. */
.thread-day {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--k-color-muted);
}

.thread-day::before,
.thread-day::after {
  flex: 1;
  height: 1px;
  content: "";
  background: var(--k-color-line);
}

@media (width <= 720px) {
  .merge-bar {
    width: 100%;
    justify-content: space-between;
  }
}

/* Relating is the merge bar's second verb: its label field and button sit
   together so the field reads as belonging to the relationship. */
.merge-bar__relate {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.merge-bar__label {
  width: min(180px, 40vw);
  min-height: 32px;
  padding: 4px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--k-color-ink);
  background: var(--k-color-paper);
  border: 1px solid var(--k-color-control-border);
  border-radius: var(--k-radius-control);
}

/* Who a person goes with, under their identities: quieter than the chips,
   since it is someone else. */
.relation-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.relation {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  color: var(--k-color-muted);
}

.relation__mark {
  font-family: var(--mono);
}

.relation__name {
  font-weight: 500;
  color: var(--k-color-ink-soft);
}

.relation__label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--k-color-muted);
}

/* --- The Related card, on a person's page ------------------------------------
   Who the person goes with, then a way to link someone else without leaving
   the page: search, pick, and relate or merge. One column, dense, because it
   sits in the side rail beside the orders. */
.related-card__head {
  align-items: center;
}

.related-card__count {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--k-color-violet-deep);
  background: var(--k-color-lavender);
  border-radius: var(--k-radius-pill);
}

.related-card__empty {
  margin: 0;
  padding: 16px 20px 4px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--k-color-muted);
}

.related-list,
.related-matches {
  display: grid;
  margin: 0;
  padding: 8px 12px;
  list-style: none;
}

.related-person,
.related-match {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 8px;
  border-radius: var(--k-radius-control);
}

.person-mark {
  display: inline-grid;
  flex-shrink: 0;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 0;
  font-size: 14px;
  font-style: normal;
  font-weight: 700;
  border-radius: 50%;
}

/* An initial on lavender; a source's letter keeps the source's own colour,
   which `.source-mark--*` sets. */
.person-mark:not(.person-mark--source) {
  color: var(--k-color-violet-deep);
  background: var(--k-color-lavender);
}

.person-mark--source {
  font-size: 13px;
  color: var(--k-color-paper);
}

.related-person__text {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.related-person__name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  color: var(--k-color-ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.related-person__name:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.related-person__label {
  justify-self: start;
  padding: 1px 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--k-color-ink-soft);
  background: var(--k-color-lavender-soft);
  border: 1px solid var(--k-color-lavender);
  border-radius: var(--k-radius-pill);
}

.related-person__meta {
  overflow: hidden;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--k-color-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.related-person__remove-form {
  display: inline;
}

/* Removing is the undo: quiet until the row is pointed at. */
.related-person__remove {
  padding: 4px 6px;
  font: inherit;
  font-size: 12px;
  color: var(--k-color-muted);
  background: none;
  border: 0;
  border-radius: var(--k-radius-control);
  cursor: pointer;
}

.related-person:hover .related-person__remove,
.related-person__remove:focus-visible {
  color: var(--k-color-error);
}

.related-person__remove:hover {
  background: var(--k-color-error-bg);
}

.related-find {
  display: grid;
  gap: 12px;
  margin-top: 8px;
  padding: 16px 20px 20px;
  background: var(--k-color-lavender-soft);
  border-top: 1px solid var(--k-color-line);
  border-radius: 0 0 var(--k-radius-panel) var(--k-radius-panel);
}

.related-find__title {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--k-color-muted);
}

.related-find__search {
  display: flex;
  gap: 8px;
}

.related-find__input,
.related-card .related-pick__field input {
  flex: 1;
  box-sizing: border-box;
  min-width: 0;
  height: 36px;
  min-height: 0;
  margin: 0;
  padding: 6px 10px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--k-color-ink);
  background: var(--k-color-paper);
  border: 1px solid var(--k-color-control-border);
  border-radius: var(--k-radius-control);
}

.related-find__hint,
.related-find__none,
.related-find__more,
.related-pick__note {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--k-color-muted);
}

.related-matches {
  gap: 2px;
  padding: 0;
}

.related-match {
  text-decoration: none;
  background: var(--k-color-paper);
  border: 1px solid transparent;
}

.related-match:hover,
.related-match:focus-visible {
  border-color: var(--k-color-lavender);
}

.related-match__go {
  color: var(--k-color-violet);
}

.related-match__tag {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--k-color-success);
}

/* One person picked: who, then relate (the card's verb) and merge (the
   heavier one, set apart below a rule). */
.related-pick {
  display: grid;
  gap: 12px;
  padding: 12px;
  background: var(--k-color-paper);
  border: 1px solid var(--k-color-lavender);
  border-radius: var(--k-radius-control);
}

.related-person--pick {
  padding: 0;
}

.related-pick__relate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.related-pick__field {
  display: grid;
  gap: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--k-color-muted);
}

.related-pick__hint {
  grid-column: 1 / -1;
  font-size: 12px;
  line-height: 1.45;
  color: var(--k-color-muted);
}

.related-pick__merge {
  display: grid;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--k-color-line);
}

.related-pick__merge-button {
  justify-self: start;
  padding: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--k-color-ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  border: 0;
  cursor: pointer;
}

.related-pick__merge-button:hover {
  color: var(--k-color-ink);
}

.related-pick__back {
  justify-self: start;
  font-size: 12px;
  color: var(--k-color-muted);
}

/* Suggested merges (customers/_matches, customers/_suggested_matches): the
   two people, why they were put together, and the two answers. */
.match-count {
  margin-left: 6px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--k-color-muted);
}

.match-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.match-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 16px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--k-color-line);
}

.match-row:first-child {
  border-top: 0;
}

.match-row__people {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
}

.match-row__person {
  padding: 0;
}

.match-row__names {
  overflow: hidden;
  font-size: 12px;
  color: var(--k-color-ink-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-row__why {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--k-color-violet-deep);
}

.match-row__actions {
  display: flex;
  grid-row: 1 / span 2;
  grid-column: 2;
  gap: 8px;
  align-items: center;
}

.match-row--single .match-row__actions {
  grid-row: 1;
}

.match-panel__more {
  margin: 0;
  padding: 10px 16px;
  border-top: 1px solid var(--k-color-line);
}

.cp-matches .match-row {
  padding: 10px 0;
}

@media (width <= 720px) {
  .match-row,
  .match-row__people {
    grid-template-columns: minmax(0, 1fr);
  }

  .match-row__actions {
    grid-row: auto;
    grid-column: 1;
  }
}
