/* 卡片 · 记录 · 动态 (view agent 3: cards.js, records.js, activity.js). Built from design A's components
   (masthead, statement strip, filters, table / rlist, gallery + tile, segmented, badges); this file only
   adds the compositions those pages need. Tokens only, so the dark theme follows on its own. */

/* ---------------------------------------------------------------------------------------------
   Shared
   --------------------------------------------------------------------------------------------- */
.segmented__count:empty { display: none; }
/* the counts arrive after the first answer: keep their room so the filter row does not jump or re-wrap */
.records-filters .segmented__count:empty,
.cards-head .segmented__count:empty { display: inline-block; min-width: 1.25em; }

/* Records of another Link account (§13): muted chip with the account email */
.acct-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
  height: 20px;
  padding: 0 8px 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--text-3);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}
.acct-chip .icon { width: 12px; height: 12px; }
.acct-chip__text { min-width: 0; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; }

/* Account filter next to a segmented control: same height as the control */
.masthead__actions .account-filter .select {
  min-height: 42px;
  padding-top: 6px;
  padding-bottom: 6px;
  border-color: var(--border);
  border-radius: 12px;
  font-size: var(--text-sm);
}
@media (max-width: 1023px) { .masthead__actions .account-filter .select { font-size: 16px; } }

/* ---------------------------------------------------------------------------------------------
   记录 — masthead, filter bar, table, list
   --------------------------------------------------------------------------------------------- */
.records-head .masthead__actions,
.cards-head .masthead__actions { align-items: center; }

.records-filters .filters__toggle { flex: none; }
.filters__count:not(:empty) {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}
@media (min-width: 768px) {
  .records-filters .filters__toggle { display: none; }
  .records-filters .filters__more { display: contents; }
  .records-filters .filters__search { order: 1; }
}
@media (max-width: 599px) {
  /* phones: a compact statement so the list starts on the first screen */
  .records-statement .statement__cell { gap: var(--space-1); padding-top: var(--space-3); padding-bottom: var(--space-3); }
  .records-statement .statement__value { font-size: 20px; }
  .records-filters .segmented__btn { padding: 0 10px; }
}
@media (max-width: 767px) {
  .records-filters .segmented { flex: 1 1 100%; }
  .records-filters .filters__search { flex: 1 1 0; }
  .records-filters .filters__more { display: none; flex: 1 1 100%; flex-wrap: wrap; gap: var(--space-3); min-width: 0; }
  .records-filters .filters__more.is-open { display: flex; }
  .records-filters .filters__more > * { flex: 1 1 calc(50% - var(--space-3)); min-width: 0; }
  .records-filters .filters__more > .date-range { flex-basis: 100%; }
}

/* Status multi-select: a button dressed as .select that opens a checkbox popover */
.status-select { text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-select.is-set { border-color: var(--text-3); color: var(--text); font-weight: var(--weight-medium); }
.status-popover { min-width: 220px; }
.status-pop__list { display: flex; flex-direction: column; gap: 1px; margin: 0; padding: 2px 0 4px; border: 0; }
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--text-sm);
  cursor: pointer;
}
.check-row:hover { background: var(--surface-muted); }
.check-row input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.check-row .dot { margin: 0 1px; }
@media (pointer: coarse) { .check-row { min-height: var(--tap); } }
.status-pop__foot {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: 2px;
  padding: 8px 4px 2px;
  border-top: 1px solid var(--border);
}

/* Date range with native date inputs (browser zone) and a clear button */
.records-filters .date-range input[type="date"] { width: 8.6em; min-width: 0; padding: 0 4px; }
@media (max-width: 767px) {
  .records-filters .date-range { min-height: var(--tap); }
  .records-filters .date-range input[type="date"] { flex: 1 1 0; width: 0; min-width: 0; font-size: 16px; }
}
.date-range__clear {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  margin-left: 2px;
  border-radius: 6px;
  color: var(--text-3);
}
.date-range__clear:hover { background: var(--surface-muted); color: var(--text); }

/* Results panel */
.records-body { transition: opacity var(--dur-base) var(--ease-standard); }
.records-body.is-loading { opacity: 0.55; }
.records-body > .panel { border: 0; border-radius: 0; background: transparent; }

.th-sort {
  padding: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}
.th-sort:hover { color: var(--text); }
.th-sort:focus-visible { outline-offset: 3px; border-radius: 3px; }

.records-table tbody tr[data-href] { cursor: pointer; }
.records-table td.records-table__merchant { width: 100%; max-width: 0; }
.records-table tr.is-archived td { color: var(--text-3); }
.merchant__line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.merchant__line .merchant__name { min-width: 0; }
.merchant__line .test-badge { flex: none; }
.merchant__line .acct-chip { flex: 0 1 auto; }

.rlist__item > .acct-chip { grid-column: 2 / -1; justify-self: start; margin-top: 4px; }

/* ---------------------------------------------------------------------------------------------
   卡片 — gallery states, tiles, 加载更多
   --------------------------------------------------------------------------------------------- */
@media (max-width: 599px) {
  /* phones: the filter first and full width, the account filter under it */
  .cards-head .masthead__actions { width: 100%; }
  .cards-head .segmented { order: -1; flex: 1 1 100%; }
  .cards-head .segmented__btn { flex: 1 1 auto; padding: 0 8px; }
  .cards-head .account-filter { flex: 1 1 100%; }
}
.cards-gallery--state { display: block; }
.cards-empty .empty { padding-top: var(--space-9); padding-bottom: var(--space-9); }
.tile { border-radius: var(--radius-card); }
.tile:focus-visible { outline-offset: 6px; }
.tile__name { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.tile__row--acct { justify-content: flex-start; }
.tile .vcard__holder .countdown { letter-spacing: inherit; }
.gallery-more {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-3) var(--space-4);
  margin-top: var(--space-9);
  color: var(--text-3);
  font-size: var(--text-sm);
}

/* ---------------------------------------------------------------------------------------------
   动态 — audit list grouped by day
   --------------------------------------------------------------------------------------------- */
.audit-day + .audit-day { margin-top: var(--space-7); }
.audit-day__title {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  color: var(--text-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-heading);
  letter-spacing: var(--tracking-label);
}
.audit-day__count { color: var(--text-3); font-size: var(--text-xs); font-weight: var(--weight-regular); }
.audit { list-style: none; margin: 0; padding: 0; }
.audit__item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
}
.audit__item + .audit__item { border-top: 1px solid var(--border); }
.audit__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-2);
}
.audit__icon .icon { width: 16px; height: 16px; }
.audit__item[data-tone="danger"] .audit__icon { border-color: transparent; background: var(--danger-soft); color: var(--danger-text); }
.audit__item[data-tone="success"] .audit__icon { border-color: transparent; background: var(--accent-soft); color: var(--accent-text); }
.audit__item[data-tone="warning"] .audit__icon { border-color: transparent; background: var(--warning-soft); color: var(--warning-text); }
.audit__body { min-width: 0; padding-top: 5px; }
.audit__title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--space-2); font-size: var(--text-sm); line-height: 1.6; }
.audit__label { color: var(--text); font-weight: var(--weight-heading); }
.audit__summary { min-width: 0; color: var(--text-2); overflow-wrap: anywhere; }
.audit__summary .test-badge { margin-left: 2px; }
.audit__meta { margin-top: 2px; font-size: var(--text-xs); }
.audit__meta .mono { font-size: 0.95em; letter-spacing: 0; }
.activity-foot { margin-top: var(--space-6); }
@media (max-width: 599px) {
  .audit__item { gap: var(--space-3); padding: var(--space-4); }
}
