/* =====================================================================
 * HOMECARE — CR-MAINT-OWNER-APPROVAL-01 PART 05 BM Monitoring
 * Token-driven, 44px targets, 320px stacking, no horizontal overflow.
 * BM-only dashboard for monitoring owner approvals, work permits and
 * follow-up actions.
 * =================================================================== */

.hc-shell[data-hc-workspace="BuildingManagement"] {
  max-width: 1440px;
}

.hc-bm-page {
  width: min(100%, 1320px);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: var(--hc-space-4);
  padding-bottom: var(--hc-space-6);
}

.hc-bm-heading h2 {
  color: var(--hc-text-strong);
  font-size: var(--hc-font-size-2xl);
  font-weight: var(--hc-font-weight-bold);
  letter-spacing: var(--hc-letter-tight);
}

.hc-bm-heading p {
  margin-top: var(--hc-space-1);
  color: var(--hc-text-muted);
  font-size: var(--hc-font-size-sm);
}

.hc-bm-view,
.hc-bm-loading,
.hc-bm-section {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: var(--hc-space-3);
}

.hc-bm-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.hc-bm-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--hc-space-2);
  width: 100%;
  min-height: var(--hc-touch-target, 44px);
  padding: var(--hc-space-3);
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--hc-border);
  cursor: pointer;
}

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

.hc-bm-row:focus-visible {
  outline: 2px solid var(--hc-border-focus);
  outline-offset: -2px;
}

.hc-bm-row__main {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.hc-bm-row__ref {
  color: var(--hc-text-strong);
  font-weight: var(--hc-font-weight-semibold);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.hc-bm-row__meta,
.hc-bm-row__time {
  color: var(--hc-text-muted);
  font-size: var(--hc-font-size-xs);
  overflow-wrap: anywhere;
}

.hc-bm-row__side {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--hc-space-1);
  max-width: 11rem;
}

.hc-bm-row__chevron {
  display: inline-flex;
  color: var(--hc-text-faint);
}

.hc-bm-approval-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--hc-space-2);
  padding: var(--hc-space-3);
  border-bottom: 1px solid var(--hc-border);
}

.hc-bm-approval-item:last-child {
  border-bottom: 0;
}

.hc-bm-approval-item__main {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.hc-bm-approval-item__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--hc-space-2);
}

.hc-bm-approval-item__actions .hc-btn {
  min-height: var(--hc-touch-target, 44px);
}

.hc-bm-permit-card {
  display: grid;
  min-width: 0;
  gap: var(--hc-space-4);
}

.hc-bm-permit__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-width: 0;
  gap: var(--hc-space-3);
}

.hc-bm-permit__head h3 {
  color: var(--hc-text-strong);
  overflow-wrap: anywhere;
}

.hc-bm-permit__eyebrow {
  color: var(--hc-text-faint);
  font-size: var(--hc-font-size-xs);
  font-weight: var(--hc-font-weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hc-bm-permit__linkage {
  margin-top: var(--hc-space-1);
  color: var(--hc-text-muted);
  font-size: var(--hc-font-size-sm);
  overflow-wrap: anywhere;
}

.hc-bm-detail {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--hc-border);
  border-bottom: 1px solid var(--hc-border);
}

.hc-bm-detail > div {
  display: grid;
  grid-template-columns: minmax(104px, 0.85fr) minmax(0, 1.5fr);
  gap: var(--hc-space-3);
  padding: var(--hc-space-3) 0;
  border-bottom: 1px solid var(--hc-border);
}

.hc-bm-detail > div:last-child {
  border-bottom: 0;
}

.hc-bm-detail dt {
  color: var(--hc-text-muted);
  font-size: var(--hc-font-size-xs);
}

.hc-bm-detail dd {
  min-width: 0;
  color: var(--hc-text-strong);
  font-size: var(--hc-font-size-sm);
  overflow-wrap: anywhere;
}

.hc-bm-permit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--hc-space-2);
}

.hc-bm-permit-actions .hc-btn {
  flex: 1 1 8rem;
  min-height: var(--hc-touch-target, 44px);
}

.hc-bm-subsection {
  display: grid;
  min-width: 0;
  gap: var(--hc-space-2);
}

.hc-bm-subsection h4 {
  color: var(--hc-text-strong);
  overflow-wrap: anywhere;
}

.hc-bm-timeline {
  display: grid;
  min-width: 0;
  gap: var(--hc-space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.hc-bm-timeline__item {
  display: grid;
  min-width: 0;
  gap: 2px;
  padding: var(--hc-space-3);
  background: var(--hc-bg-subtle);
  border: 1px solid var(--hc-border);
  border-radius: var(--hc-radius-md);
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  column-gap: var(--hc-space-2);
}

.hc-bm-timeline__note,
.hc-bm-timeline__actor,
.hc-bm-timeline__time {
  grid-column: 1 / -1;
  color: var(--hc-text-muted);
  font-size: var(--hc-font-size-xs);
  overflow-wrap: anywhere;
}

.hc-bm-detail-back {
  align-self: flex-start;
}

.hc-bm-back {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: var(--hc-space-2);
  min-height: var(--hc-touch-target, 44px);
  padding: 0 var(--hc-space-2);
  color: var(--hc-color-accent);
  font-size: var(--hc-font-size-sm);
  font-weight: var(--hc-font-weight-semibold);
  text-decoration: none;
  border-radius: var(--hc-radius-sm);
}

.hc-bm-back__icon {
  width: 18px;
  height: 18px;
  transform: rotate(180deg);
}

.hc-bm-back:focus-visible,
.hc-bm-detail-back:focus-visible,
.hc-bm-permit-actions .hc-btn:focus-visible,
.hc-bm-approval-item__actions .hc-btn:focus-visible {
  outline: 2px solid var(--hc-border-focus);
  outline-offset: 2px;
  box-shadow: var(--hc-focus-ring);
}

.hc-bm-modal {
  display: grid;
  gap: var(--hc-space-3);
  min-width: 0;
}

@media (max-width: 359px) {
  .hc-bm-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .hc-bm-row__side {
    justify-content: flex-start;
    max-width: none;
  }

  .hc-bm-row__chevron {
    display: none;
  }

  .hc-bm-detail > div {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--hc-space-1);
  }

  .hc-bm-permit-actions,
  .hc-bm-approval-item__actions {
    flex-direction: column;
  }

  .hc-bm-permit__head,
  .hc-bm-timeline__item {
    grid-template-columns: minmax(0, 1fr);
  }

  .hc-bm-permit__head {
    display: grid;
  }
}
