/* Admin dashboard, activity feed and analytics. */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Overview metrics */
.overview-metrics {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.overview-primary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.engagement-card {
  display: flex;
  min-height: 132px;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  color: inherit;
  text-decoration: none;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.engagement-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.engagement-card:active {
  transform: translateY(1px);
}

.engagement-card:focus-visible,
.support-stat:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.engagement-head {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.engagement-icon {
  display: inline-flex;
  width: 28px;
  height: 28px;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.engagement-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.engagement-arrow {
  display: inline-flex;
  flex: none;
  align-items: center;
  margin-left: auto;
  color: var(--muted-light);
  transition:
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.engagement-card:hover .engagement-arrow {
  color: var(--ink);
  transform: translateX(2px);
}

.engagement-value {
  margin-top: 14px;
  color: var(--ink);
  font-size: clamp(32px, 5vw, 40px);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1;
}

.overview-support {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: stretch;
  margin: 0;
  padding: 8px 20px;
}

.support-stat {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 8px 0;
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
}

.support-top {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

.support-arrow {
  display: inline-flex;
  flex: none;
  align-items: center;
  margin-left: auto;
  color: var(--muted-light);
  opacity: 0.55;
  transition:
    color var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.support-stat:hover .support-arrow,
.support-stat:focus-visible .support-arrow {
  color: var(--ink);
  opacity: 1;
  transform: translateX(2px);
}

.support-stat:hover .support-value {
  color: var(--ink);
}

.support-stat:nth-child(even) {
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.support-stat:nth-child(n + 3) {
  border-top: 1px solid var(--line);
}

.support-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.support-value {
  margin: 0;
  color: var(--ink-soft);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.overview-refresh,
.activity-refresh {
  min-width: 96px;
}

/* First run */
.onboarding {
  display: flex;
  max-width: 620px;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  padding: 30px 28px;
}

.onboarding-mark {
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand);
}

.onboarding-copy h2 {
  font-size: 20px;
  letter-spacing: -0.02em;
}

.onboarding-copy p {
  max-width: 46ch;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
}

.onboarding .btn {
  margin-top: 2px;
}

/* Loading skeletons */
.skeleton-icon {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
}

.skeleton-label {
  width: 72px;
  height: 11px;
  border-radius: 5px;
}

.skeleton-value {
  width: 96px;
  height: 34px;
  margin-top: 20px;
  border-radius: 8px;
}

.skeleton-support-value {
  width: 34px;
  height: 22px;
  border-radius: 6px;
}

.skeleton-heading {
  width: 118px;
  height: 13px;
  border-radius: 6px;
}

.skeleton-title {
  width: 64%;
  height: 11px;
  border-radius: 5px;
}

.skeleton-meta {
  width: 40%;
  height: 9px;
  border-radius: 5px;
}

.skeleton-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.skeleton-row:last-child {
  border-bottom: 0;
}

.skeleton-row-lines {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 7px;
}

.overview-panel-skeleton {
  overflow: hidden;
}

.room-skeleton {
  display: flex;
  min-height: 132px;
  flex-direction: column;
  gap: 9px;
  padding: 18px;
}

.room-skeleton .skeleton-title {
  width: 60%;
  height: 14px;
}

.room-skeleton .skeleton-meta {
  width: 80%;
  height: 10px;
}

.room-skeleton .skeleton-meta.short {
  width: 45%;
}

/* Activity */
.activity-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  margin-bottom: 16px;
  padding: 12px;
}

.activity-toolbar .filter-chip {
  height: 32px;
  padding: 0 11px;
  cursor: pointer;
  transition: background 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out), transform 120ms var(--ease-out);
}

.activity-toolbar .filter-chip:active {
  transform: scale(0.97);
}

.activity-toolbar .filter-chip:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.activity-selects {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 8px;
}

.activity-select {
  display: flex;
  min-width: 0;
}

.activity-selects .select {
  width: auto;
  min-width: 150px;
  min-height: 36px;
  height: 36px;
  padding: 5px 10px;
  font-size: 12px;
}

.activity-card .activity-list {
  max-height: 70vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.activity-day-label {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.activity-day:not(:first-child) .activity-day-label {
  border-top: 1px solid var(--line);
}

.overview-page .event-title,
.activity-page .event-title {
  font-size: 13px;
}

.overview-page .event-meta,
.activity-page .event-meta {
  font-size: 12px;
}

.overview-page .event-agent,
.activity-page .event-agent {
  font-size: 12px;
}

.activity-card .event-meta {
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}

.activity-card .event-meta .event-kind,
.activity-card .event-meta .event-time,
.activity-card .event-meta .event-dot {
  flex: none;
}

.activity-card .event-meta > span:not(.event-dot):not(.event-kind):not(.event-time) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-card .event-agent {
  max-width: 72px;
  flex: none;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
}

.activity-skeleton-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.activity-skeleton-row:last-child {
  border-bottom: 0;
}

.activity-skeleton-body {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 7px;
  padding-top: 2px;
}

.activity-skeleton .skeleton-title {
  width: 58%;
}

.activity-skeleton .skeleton-meta {
  width: 38%;
}

.tone-blue {
  background: var(--brand-soft);
  color: var(--brand);
}

.tone-violet {
  background: var(--violet-soft);
  color: var(--violet);
}

.tone-green {
  background: var(--green-soft);
  color: var(--green);
}

.tone-red {
  background: var(--red-soft);
  color: var(--red);
}

.tone-slate {
  background: var(--surface-tint);
  color: var(--muted);
}

/* Dashboard lists */
.top-doc-list {
  display: flex;
  flex-direction: column;
}

.top-doc {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 11px;
  padding: 12px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
  transition: background 140ms var(--ease-out);
}

.top-doc:last-child {
  border-bottom: 0;
}

.top-doc:active {
  background: var(--surface-tint);
}

.top-doc:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  background: var(--surface-soft);
}

.top-doc-rank {
  width: 20px;
  flex: none;
  color: var(--muted-light);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
}

.top-doc .name {
  display: block;
  font-size: 13px;
  font-weight: 550;
}

.top-doc .sub {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
}

.top-doc-stat {
  display: flex;
  min-width: 54px;
  flex-direction: column;
  align-items: flex-end;
  color: var(--muted-light);
  font-size: 12px;
}

.top-doc-stat strong {
  color: var(--ink-soft);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.top-doc-open {
  display: inline-flex;
  flex: none;
  color: var(--muted-light);
}

.section-heading-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 26px 0 12px;
}

.section-heading-row h2 {
  font-size: 16px;
}

.section-heading-row .hint {
  margin-top: 2px;
}

.empty-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat-icon {
  display: inline-flex;
  color: var(--muted-light);
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.stat-value {
  margin-top: 6px;
  font-size: 25px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.stat-sub {
  margin-top: 3px;
  color: var(--muted-light);
  font-size: 12px;
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.card-header h2 {
  font-size: 14px;
}

@media (hover: hover) and (pointer: fine) {
  .top-doc:hover {
    background: var(--surface-soft);
  }

  .activity-toolbar .filter-chip:not(.active):hover {
    border-color: var(--line-strong);
    background: var(--surface-soft);
    color: var(--ink-soft);
  }
}

@media (prefers-reduced-motion: reduce) {
  .top-doc,
  .activity-toolbar .filter-chip {
    transition: none;
  }

  .activity-toolbar .filter-chip:active {
    transform: none;
  }
}

@media (max-width: 1050px) {
  .content-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1000px) {
  .overview-metrics {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .support-stat:nth-child(even) {
    padding-left: 0;
    border-left: 0;
  }

  .support-stat:nth-child(n + 3) {
    border-top: 0;
  }

  .support-stat + .support-stat {
    padding-left: 16px;
    border-left: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .overview-page .page-actions .btn,
  .overview-page .btn-sm,
  .activity-page .btn-sm {
    min-height: 40px;
  }

  .overview-page .card-header .linkish {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    padding: 0 4px;
    margin-right: -4px;
  }

  .activity-toolbar {
    align-items: stretch;
  }

  .activity-toolbar .filter-chip {
    height: 40px;
    padding: 0 13px;
  }

  .activity-selects {
    width: 100%;
  }

  .activity-select {
    flex: 1 1 150px;
  }

  .activity-selects .select {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    height: 40px;
  }

  .room-grid,
  .stat-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .overview-primary {
    grid-template-columns: minmax(0, 1fr);
  }

  .overview-support {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .support-stat + .support-stat {
    padding-left: 0;
    border-left: 0;
  }

  .support-stat:nth-child(even) {
    padding-left: 18px;
    border-left: 1px solid var(--line);
  }

  .support-stat:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .activity-foot .btn {
    width: 100%;
  }

  .activity-card .event-row {
    gap: 9px;
    padding: 11px 13px;
  }

  .activity-card .event-agent {
    max-width: 56px;
  }

  .onboarding {
    padding: 24px 20px;
  }
}
