/* Customer profiles: the Customers tab and one customer's page.
   Tokens come from site.css; nothing here sets a color of its own. */

.cu-page {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

/* ---------- list ---------- */

.cu-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.cu-search {
  display: flex;
  flex: 1 1 320px;
  gap: 8px;
  max-width: 520px;
}

.cu-search .field-input {
  flex: 1 1 auto;
  min-width: 0;
}

.cu-filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.cu-filter {
  position: relative;
}

.cu-filter summary {
  list-style: none;
}

.cu-filter summary::-webkit-details-marker {
  display: none;
}

.cu-count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
}

.cu-filter-form {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  display: grid;
  gap: 12px;
  width: min(340px, calc(100vw - 32px));
  padding: 16px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-menu, var(--shadow-card));
}

.cu-by {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 0;
  padding: 0;
  border: none;
}

.cu-by legend {
  width: 100%;
  margin-bottom: 6px;
}

.cu-filterbar .chip svg {
  width: 14px;
  height: 14px;
}

.cu-csv {
  margin-left: auto;
}

.cu-table td {
  vertical-align: top;
}

.cu-table th:first-child {
  width: 30%;
}

.cu-who a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
}

.cu-who a:hover strong {
  color: var(--accent);
}

.cu-who-text {
  display: grid;
  min-width: 0;
}

.cu-who-text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cu-sub {
  display: block;
  overflow: hidden;
  font-size: 12.5px;
  color: var(--text-dim);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cu-avatar {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 32px;
  height: 32px;
  font-size: 13px;
  font-weight: 650;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
}

.cu-avatar-lg {
  width: 52px;
  height: 52px;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
}

.cu-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cu-foot {
  margin: 0;
  font-size: 13px;
}

.cu-empty .empty-mark svg {
  width: 24px;
  height: 24px;
}

.cu-snippets .code {
  font-size: 12.5px;
}

.cu-inline {
  display: flex;
  gap: 8px;
}

.cu-inline .field-input {
  flex: 1 1 auto;
  min-width: 0;
}

/* Collapsible cards (privacy, delete): the summary is the title, with a turning chevron. */
.cu-privacy,
.cu-delete {
  padding: 0;
}

.cu-privacy summary,
.cu-delete summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 0 16px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.cu-privacy summary::-webkit-details-marker,
.cu-delete summary::-webkit-details-marker {
  display: none;
}

.cu-privacy summary svg,
.cu-delete summary svg {
  width: 18px;
  height: 18px;
  color: var(--text-faint);
  transition: transform 0.15s ease;
}

.cu-privacy[open] summary svg,
.cu-delete[open] summary svg {
  transform: rotate(180deg);
}

.cu-privacy > .stack,
.cu-delete > form {
  padding: 0 16px 16px;
}

.cu-delete summary {
  color: var(--danger-fg);
}

/* ---------- one customer ---------- */

.cu-head {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.cu-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-self: start;
  min-height: 32px;
  font-size: 14px;
  color: var(--text-dim);
}

.cu-back-icon {
  width: 16px;
  height: 16px;
  transform: rotate(180deg);
}

.cu-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.cu-title {
  min-width: 0;
}

.cu-title h1 {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cu-title .app-page-sub {
  margin-top: 2px;
  color: var(--text-dim);
}

.cu-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cu-kpi-date {
  font-family: inherit;
  font-size: 20px;
  line-height: 1.5;
}

.cu-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}

.cu-side {
  display: grid;
  gap: 14px;
}

.cu-label {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.cu-touch,
.cu-facts {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.cu-touch-main {
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.cu-touch-none {
  font-size: 14px;
}

.cu-dl {
  display: grid;
  gap: 6px;
  margin: 0;
  font-size: 13.5px;
}

.cu-dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.cu-dl dt {
  flex: 0 0 auto;
  color: var(--text-dim);
}

.cu-dl dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.cu-merges {
  display: grid;
  gap: 4px;
  margin: 4px 0 0;
  padding-top: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
  border-top: 1px solid var(--line);
}

.cu-stream {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.cu-stream-head {
  align-items: baseline;
}

.cu-stream-count {
  font-size: 13px;
}

.cu-stream-filters {
  display: grid;
  gap: 8px;
}

.cu-timeline,
.cu-items {
  margin: 0;
  padding: 0;
  list-style: none;
}

.cu-timeline {
  display: grid;
  gap: 18px;
}

.cu-day-label {
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* The vertical line runs through the dots; each item draws its own piece. */
.cu-item {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 14px;
}

.cu-item::before {
  content: '';
  position: absolute;
  top: 32px;
  bottom: 0;
  left: 15.5px;
  width: 1px;
  background: var(--line-strong);
}

.cu-items > .cu-item:last-child {
  padding-bottom: 0;
}

.cu-items > .cu-item:last-child::before {
  display: none;
}

.cu-dot {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--text-dim);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.cu-dot svg {
  width: 15px;
  height: 15px;
}

/* Money and ad clicks stand out; everything else stays quiet. */
.cu-k-order .cu-dot,
.cu-k-click .cu-dot {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

.cu-k-refund .cu-dot {
  color: var(--danger-fg);
}

.cu-item-body {
  min-width: 0;
  padding-top: 5px;
}

.cu-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.cu-item-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.cu-value {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--found);
}

.cu-k-refund .cu-value {
  color: var(--lost);
}

.cu-item-detail {
  margin-top: 2px;
  font-size: 13.5px;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

.cu-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.cu-src {
  color: var(--text-dim);
}

.cu-none {
  margin: 0;
  font-size: 14px;
}

.cu-retention {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-dim);
  background: var(--bg-tint);
  border-radius: var(--radius);
}

.cu-retention svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

/* ---------- phones ---------- */

@media (max-width: 960px) {
  .cu-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .cu-side {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
}

@media (max-width: 720px) {
  .cu-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .cu-kpis .tr-kpi:nth-child(2) {
    border-right: none;
  }
  .cu-kpis .tr-kpi:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
  .cu-search {
    max-width: none;
  }
  .cu-csv {
    margin-left: 0;
  }

  /* The table becomes one card per customer. */
  .cu-table-wrap {
    overflow: visible;
    background: transparent;
    border: none;
  }
  .cu-table,
  .cu-table tbody,
  .cu-table tr,
  .cu-table td {
    display: block;
    width: 100%;
  }
  .cu-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .cu-table tbody {
    display: grid;
    gap: 10px;
  }
  /* Sources take half a row each; orders, revenue and last seen share the next row. */
  .cu-table tr {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px 12px;
    padding: 14px;
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }
  .cu-table td {
    grid-column: span 3;
    padding: 0;
    border: none;
    text-align: left;
  }
  .cu-table td.num {
    grid-column: span 2;
  }
  .cu-table .num {
    text-align: left;
  }
  .cu-table td.cu-who {
    grid-column: 1 / -1;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
  }
  .cu-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
  }
  .cu-table tbody tr:hover td {
    background: transparent;
  }
  .cu-title h1 {
    font-size: 24px;
  }
  .cu-stream {
    padding: 14px;
  }
  /* Filter chips scroll sideways instead of stacking up. */
  .cu-stream-filters .chips {
    flex-wrap: nowrap;
    margin-inline: -14px;
    padding-inline: 14px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .cu-stream-filters .chips::-webkit-scrollbar {
    display: none;
  }
}
