/* Team page styles aligned to the refactored tenant list-page system. */

.team-page .inspections-proto {
  margin-inline: calc(var(--ipi-page-gutter) * -1);
}

.team-page-header {
  position: relative;
}

.team-page-header .ipi-ph-right {
  gap: 10px;
}

.team-stats-strip {
  padding-top: 18px;
}

.team-page .ipi-filter-rail__actions {
  flex-wrap: wrap;
}

.team-page .ipi-filter-railbtn span[data-team-filters-count] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ipi-accent-bg);
  color: var(--ipi-accent);
  font-size: 10px;
  font-weight: 700;
}

.team-filter-bar {
  grid-template-columns: minmax(200px, 1fr) repeat(2, minmax(0, 0.8fr)) auto repeat(3, auto) auto;
}

.team-filter-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--ipi-rule-h);
  background: var(--ipi-bg);
  color: var(--ipi-ink-3);
  font-size: 12.5px;
  font-weight: 500;
}

.team-filter-checkbox input {
  margin: 0;
}

.team-filter-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.team-bulk-bar[hidden] {
  display: none !important;
}

.team-bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--ipi-bg-card);
  box-shadow: var(--ipi-shadow-card);
}

.team-bulk-bar__left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.team-bulk-bar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.team-bulk-bar__note {
  color: #7c2d12;
  margin: 0;
}

.team-bulk-bar__danger {
  border-color: rgba(17, 24, 39, 0.18);
}

.team-empty-state {
  padding: 0;
}

.team-empty-state__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 28px;
}

.team-empty-state__body h3 {
  margin: 0;
  color: var(--ipi-ink);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
}

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

.team-table thead th:first-child,
.team-table tbody td:first-child {
  width: 48px;
}

.team-table thead th:last-child,
.team-table tbody td:last-child {
  width: 104px;
  text-align: right;
}

.team-col-select {
  width: 48px;
}

.team-col-select input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.team-row-identity {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.team-row-identity__copy {
  min-width: 0;
}

.team-row-identity__copy strong {
  display: block;
  color: var(--ipi-ink);
  font-size: 13.5px;
  font-weight: 600;
}

.team-role-pill {
  text-transform: capitalize;
}

.team-table .ipi-status-pill {
  white-space: nowrap;
}

.team-access-cell {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px;
}

.team-activity-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.team-row--inactive {
  opacity: 0.62;
}

.team-table .table-actions {
  justify-content: flex-end;
  align-items: center;
  flex-wrap: nowrap;
}

.team-filtered-empty[hidden] {
  display: none !important;
}

/* ============================================================================
   .team-modal — canonical modal language (4 team modals)
   Mirrors .set-modal / .qbm-modal / .ivm-modal / .bil-modal / .clients-modal
   exactly: identical HTML shell, identical CSS values, identical mobile
   bottom-sheet behaviour, --ipi-* token aliases for canonical primitives.
   ============================================================================ */

.team-modal {
    /* --ipi-* token aliases so canonical primitives (.ipi-tabs, .ipi-tab,
       .ipi-filter-search, .ipi-filter-select) render correctly inside the
       modal scope. */
    --ipi-bg: var(--canvas, #f7f5f0);
    --ipi-bg-inset: var(--surface-inset, #edeae3);
    --ipi-bg-card: var(--surface-card, #ffffff);
    --ipi-bg-hover: rgba(26, 24, 21, 0.04);
    --ipi-rule: var(--rule, rgba(26, 24, 21, 0.08));
    --ipi-rule-h: rgba(26, 24, 21, 0.11);
    --ipi-ink: var(--ink, #1a1815);
    --ipi-ink-2: #3d3a34;
    --ipi-ink-3: var(--ink-3, #6b6458);
    --ipi-ink-4: var(--ink-4, #9a9188);
    --ipi-accent: var(--accent, #c49510);
    --ipi-accent-bg: rgba(196, 149, 16, 0.08);
    --ipi-accent-border: rgba(196, 149, 16, 0.34);
    --ipi-shadow-sm: 0 1px 3px rgba(26, 24, 21, 0.06), 0 1px 2px rgba(26, 24, 21, 0.04);
    --ipi-shadow-card: 0 1px 4px rgba(26, 24, 21, 0.06), 0 0 0 1px rgba(26, 24, 21, 0.05);
}

.team-modal .modal__dialog {
  width: min(880px, calc(100vw - 32px));
  height: min(85vh, 760px);
  max-height: min(90vh, 960px);
  min-height: min(60vh, 520px);
  border-radius: 16px;
  border: 1px solid rgba(26, 24, 21, 0.08);
  background: var(--surface-card, #ffffff);
  box-shadow: 0 20px 60px rgba(26, 24, 21, 0.18), 0 4px 16px rgba(26, 24, 21, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.team-modal__dialog {
  width: min(880px, calc(100vw - 32px));
}

.team-modal__dialog--narrow {
  width: min(560px, calc(100vw - 32px));
  height: auto;
  min-height: min(50vh, 380px);
}

.team-modal__dialog--confirm {
  width: min(560px, calc(100vw - 32px));
  height: auto;
  min-height: min(50vh, 380px);
}

.team-modal__dialog--stacked {
  display: flex;
  flex-direction: column;
}

.team-modal__dialog--stacked .team-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Forms that wrap modal__body + modal__footer must flex so the body's
   `flex: 1; overflow-y: auto` rule has a constrained parent. */
.team-modal form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    width: 100%;
}

/* Details form: Name + Email side-by-side in two-col grid */
#team-panel-details > label:first-of-type,
#team-panel-details > label:nth-of-type(2) {
  grid-column: auto;
}

/* Parent-scoped to beat base .modal__footer specificity */
.team-modal .modal__footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 22px 14px;
  border-top: 1px solid rgba(26, 24, 21, 0.07);
  background: var(--surface-card, #ffffff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.team-modal__footer-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.team-modal__footer-copy strong {
  font-family: var(--font-display, 'Space Grotesk', system-ui, sans-serif);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink, #1a1815);
}

.team-modal__footer-copy p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-4, #9a9188);
}

.team-modal__footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.team-modal__footer-actions .btn {
  min-height: 40px;
  padding: 8px 18px;
}

.team-invite-form.form-grid.two-col {
  gap: 12px 14px;
}

/* --- Form controls: canonical pattern matching .set-modal / .qbm-modal ---
   Parent-scoped to beat base element selectors (0,1,1 > 0,0,1)
   Labels: 10px uppercase 600 weight per canonical */
.team-modal label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4, #9a9188);
}

/* Sub-element overrides for descriptive labels (notify items, prose) */
.team-modal .team-member-pane__hint,
.team-modal label.checkbox-inline {
  text-transform: none;
  letter-spacing: normal;
}

.team-modal input,
.team-modal textarea,
.team-modal select {
  width: 100%;
  min-height: 40px;
  padding: 10px 13px;
  border-radius: 9px;
  border: 1px solid rgba(26, 24, 21, 0.11);
  background: var(--surface-card, #ffffff);
  color: var(--ink-2, #3d3a34);
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.team-modal input:focus,
.team-modal textarea:focus,
.team-modal select:focus {
  border-color: rgba(196, 149, 16, 0.22);
  box-shadow: 0 0 0 3px rgba(196, 149, 16, 0.08);
}

.team-modal input[type="checkbox"],
.team-modal input[type="radio"] {
  width: auto;
  min-height: auto;
  padding: 0;
}

.team-modal input[type="file"] {
  min-height: auto;
  padding: 8px 10px;
  font-size: 12.5px;
}

.team-modal textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.55;
}

.team-modal select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='none' stroke='%239a9188' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 3.5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 10px;
}

.team-modal .form-hint {
  font-size: 11px;
  color: var(--ink-4, #9a9188);
  margin-top: 3px;
}

.team-modal fieldset {
  border: none;
  margin: 0;
  padding: 0;
}

.team-modal fieldset legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink, #1a1815);
  margin-bottom: 8px;
}

.team-modal__prose {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.team-modal__prose p {
  margin: 0;
  line-height: 1.55;
  color: var(--ipi-ink);
}

/* Parent-scoped to beat base .modal__header specificity (0,2,0 > 0,1,0) */
.team-modal .modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid rgba(26, 24, 21, 0.07);
  background: var(--surface-card, #ffffff);
  flex-shrink: 0;
}

.team-modal .modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: var(--surface-inset, #edeae3);
  color: var(--ink-4, #9a9188);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s ease, color 0.12s ease;
}

.team-modal .modal__close:hover {
  background: var(--surface-subtle, #f2efe9);
  color: var(--ink, #1a1815);
}

.team-modal .modal__close:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.team-modal__header-copy {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.team-modal__eyebrow {
  margin: 0;
  color: var(--ipi-accent);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.team-modal__header-copy .modal__title {
  margin: 0;
  color: var(--ipi-ink);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.team-modal__subcopy {
  display: none;
}

/* Parent-scoped to beat base .modal__body specificity */
.team-modal .modal__body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 22px 22px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--canvas, #f7f5f0);
}

.team-modal__surface {
  border-radius: 16px;
  padding: 16px;
  background: var(--ipi-bg-card);
  box-shadow: var(--ipi-shadow-card);
}

.team-modal__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.team-member-modal__dialog {
  width: min(740px, calc(100vw - 48px));
  max-height: min(90vh, 960px);
}

.team-member-modal__subhead {
  flex-shrink: 0;
  padding: 0 22px;
  background: var(--surface-card, #ffffff);
  border-bottom: 1px solid rgba(26, 24, 21, 0.07);
}

.team-member-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 10px 0 8px;
  border-bottom: 1px solid rgba(26, 24, 21, 0.07);
}

.team-member-context__name {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--ipi-ink);
  line-height: 1.2;
}

.team-member-context__sep {
  color: var(--ipi-ink-4);
  user-select: none;
}

.team-member-context__line {
  flex: 1 1 10rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-member-context__pill {
  flex: 0 0 auto;
  margin-left: auto;
}

.team-member-tabs {
  padding: 8px 0 10px;
}

/* .team-member-tabs__track has been replaced by canonical .ipi-tabs in the
   HTML — see inspections_shell.css for the .ipi-tabs primitive definition. */

.team-member-modal__body {
  gap: 0;
  padding: 14px 22px 16px;
}

.team-member-pane {
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.team-member-pane .form-grid.two-col {
  gap: 12px 14px;
}

.team-member-pane--stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.team-member-modal__footer-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.team-member-modal__footer-group[hidden] {
  display: none !important;
}

.team-member-status-pill {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  border: 1px solid rgba(26, 24, 21, 0.12);
  background: var(--surface-inset, #edeae3);
  color: var(--ink-3, #6b6458);
}

.team-member-status-pill--active {
  border-color: rgba(15, 118, 110, 0.18);
  background: rgba(15, 118, 110, 0.08);
  color: #115e59;
}

.team-member-status-pill--removed {
  border-color: rgba(148, 163, 184, 0.45);
  background: rgba(226, 232, 240, 0.7);
  color: #475569;
}

/* The bespoke .team-member-tab class has been replaced by canonical
   .ipi-tab in the HTML. The .ipi-tabs block in inspections_shell.css owns
   the tab styling and resolves correctly inside .team-modal because the
   modal block above imports the --ipi-* token aliases.

   The danger variant for "Remove access" tab is preserved as a modifier
   on top of .ipi-tab. */
.team-modal .ipi-tab--danger {
  color: #b91c1c;
}

.team-modal .ipi-tab--danger:hover {
  background: rgba(220, 38, 38, 0.08);
  color: #991b1b;
}

.team-modal .ipi-tab--danger.is-active,
.team-modal .ipi-tab--danger[aria-selected="true"] {
  background: rgba(254, 226, 226, 0.92);
  color: #991b1b;
  box-shadow: 0 1px 4px rgba(185, 28, 28, 0.15);
}

[data-team-tab-panel] {
  display: none !important;
}

.team-member-tabpanel.is-active {
  display: flex !important;
  flex-direction: column;
  gap: 14px;
}

form[data-team-tab-panel].is-active {
  display: grid !important;
}

[data-team-tab-panel].is-active.team-member-pane--stack,
[data-team-tab-panel].is-active.team-history {
  display: flex !important;
  flex-direction: column;
  gap: 16px;
}

[data-team-tab-panel].is-active.team-history {
  gap: 12px;
}

.team-member-panel-divider {
  border: 0;
  border-top: 1px solid rgba(26, 24, 21, 0.07);
  margin: 14px 0 12px;
}

.team-member-panel-eyebrow {
  margin: 0 0 6px;
}

.team-history__list {
  display: grid;
  gap: 10px;
}

.team-history-item {
  border-radius: 12px;
  border: 1px solid rgba(210, 198, 181, 0.9);
  background: rgba(250, 246, 239, 0.95);
  padding: 10px 12px;
}

.team-history-item__meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}

.team-history-item__meta strong {
  font-size: 0.9rem;
}

.signature-preview,
.profile-photo-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.signature-preview__image,
.profile-photo-preview__image {
  border-radius: 14px;
  border: 1px dashed rgba(210, 198, 181, 0.95);
  background: rgba(250, 246, 239, 0.9);
  padding: 18px;
}

.signature-preview__image img,
.profile-photo-preview__image img {
  display: block;
  max-width: 100%;
  max-height: 180px;
}

.signature-preview canvas {
  width: 100%;
  max-width: 420px;
  border-radius: 14px;
  border: 1px dashed rgba(210, 198, 181, 0.95);
  background: var(--canvas, #f7f5f0);
}

.signature-preview__hint,
.profile-photo-preview__hint {
  margin: 0;
  color: var(--ipi-ink-3);
}

.danger-panel {
  border-radius: 14px;
  border: 1px solid rgba(210, 198, 181, 0.9);
  background: rgba(250, 246, 239, 0.9);
  padding: 12px 14px;
  /* `<fieldset>` gets default `margin-inline: 2px`; reset so the card width
     matches its container's content box (see style.css:5189 equivalent fix). */
  margin: 0;
}

.danger-panel legend {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ipi-ink);
}

.danger-panel--neutral {
  background: var(--canvas, #f7f5f0);
}

@media (max-width: 1180px) {
  .team-filter-bar {
    grid-template-columns: minmax(240px, 1fr) repeat(2, minmax(0, 1fr));
  }

  .team-filter-actions {
    justify-content: flex-start;
    grid-column: 1 / -1;
  }
}


@media (max-width: 900px) {

  /* --- Container chain overflow fix ---
     NOTE: .inspections-proto excluded — its negative margin-inline makes it
     full-bleed; max-width: 100% would cancel that and break the layout. */
  .team-page,
  .team-page .ipi-list-area,
  .team-page .ipi-tabs-row,
  .team-page .ipi-filter-shell {
    min-width: 0;
    max-width: 100%;
  }

  .team-page .ipi-list-area {
    overflow-x: hidden;
  }

  /* --- Stats strip: horizontal scroll carousel ---
     Shell applies this at 768px; triggering earlier at 900px prevents
     4 cramped stat cards on tablets (769–900px). */
  .team-page .ipi-stats-strip {
    flex-direction: row;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-snap-type: x proximity;
    scroll-padding-left: var(--ipi-page-gutter);
    scroll-padding-right: var(--ipi-page-gutter);
    padding-bottom: 20px;
  }

  .team-page .ipi-stats-strip::-webkit-scrollbar {
    display: none;
  }

  .team-page .ipi-stat {
    flex: 0 0 min(240px, 76vw);
    scroll-snap-align: start;
  }

  .team-page .ipi-stats-strip > .ipi-stat:first-child {
    margin-left: var(--ipi-page-gutter);
  }

  .team-page .ipi-stats-strip > .ipi-stat:last-child {
    margin-right: var(--ipi-page-gutter);
  }

  /* --- Page header: expand action buttons --- */
  .team-page-header .ipi-ph-right {
    width: 100%;
  }

  .team-page-header .ipi-ph-right > * {
    flex: 1 1 0;
    justify-content: center;
  }

  /* --- Tab row + pills: horizontal scroll ---
     Override inline-flex → flex so overflow-x: auto works in iOS Safari. */
  .team-page .ipi-tabs-row {
    width: 100%;
  }

  .team-page .ipi-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-snap-type: x proximity;
    scroll-padding-left: 4px;
    scroll-padding-right: 4px;
    width: 100%;
  }

  .team-page .ipi-tabs::-webkit-scrollbar {
    display: none;
  }

  .team-page .ipi-tab {
    flex: 0 0 auto;
    scroll-snap-align: start;
    white-space: nowrap;
  }

  .team-page .ipi-tabs-meta {
    display: none;
  }

  /* --- Filter rail: visible at 900px ---
     Shell hides .ipi-filter-rail globally; column layout keeps buttons
     from overflowing narrow screens. */
  .team-page .ipi-filter-rail {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 16px;
    background: var(--ipi-bg-card);
    border-radius: 12px;
    box-shadow: var(--ipi-shadow-card);
  }

  .team-page .ipi-filter-rail__copy {
    min-width: 0;
  }

  .team-page .ipi-filter-rail__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }

  .team-page .ipi-filter-rail__actions .ipi-filter-railbtn {
    flex: 1 1 auto;
    min-height: 40px;
    justify-content: center;
  }

  /* Collapse filter grid to single column */
  .team-page .team-filter-bar {
    grid-template-columns: 1fr;
  }

  /* Filter actions: full-width 2-col grid */
  .team-page .team-filter-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    margin-top: 4px;
    justify-content: unset;
  }

  .team-page .team-filter-actions > *:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .team-page .team-filter-actions .ipi-filter-railbtn {
    width: 100%;
    min-height: 40px;
    justify-content: center;
  }

  /* --- Bulk bar: stack vertically --- */
  .team-bulk-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }

  .team-bulk-bar__actions {
    flex-wrap: wrap;
  }

  .team-bulk-bar__actions .ipi-filter-railbtn {
    flex: 1 1 auto;
    min-height: 40px;
    justify-content: center;
  }

  /* --- Table card-ification --- */
  .team-page .team-table,
  .team-page .team-table thead,
  .team-page .team-table tbody,
  .team-page .team-table tr,
  .team-page .team-table th,
  .team-page .team-table td {
    display: block;
    width: 100%;
  }

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

  .team-page .team-table tbody {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .team-page .team-table tr {
    border: 1px solid rgba(26, 24, 21, 0.1);
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    padding: 6px 0;
  }

  .team-page .team-table td {
    position: relative;
    padding: 7px 14px 7px 110px;
    border-bottom: 1px solid rgba(26, 24, 21, 0.06);
    text-align: left !important;
    white-space: normal;
  }

  .team-page .team-table td:last-child {
    border-bottom: none;
  }

  .team-page .team-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 14px;
    top: 7px;
    width: 82px;
    color: #9a9188;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  /* Hide select column on mobile */
  .team-page .team-table td.team-col-select,
  .team-page .team-table th.team-col-select {
    display: none;
  }

  /* Actions cell: no pseudo-label, right-align */
  .team-page .team-table td.ipi-actions {
    padding-left: 14px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }

  .team-page .team-table td.ipi-actions::before {
    display: none;
  }

  /* Override ipi-table min-width for card layout */
  .team-page .ipi-table-wrap {
    overflow-x: visible;
  }

  .team-page .ipi-table.team-table {
    min-width: 0;
  }

  .team-table .table-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  /* Container, dialog size, transform, header padding, body/footer padding,
     footer-copy visibility — all owned by canonical + gold-spec in style.css.
     Team-specific content layout below. */

  .team-modal .team-modal__footer-actions,
  .team-modal .team-member-modal__footer-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .team-modal .team-modal__footer-actions > *:last-child:nth-child(odd),
  .team-modal .team-member-modal__footer-group > *:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .team-modal .team-modal__footer-actions .btn,
  .team-modal .team-member-modal__footer-group .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
    font-size: 13px;
    padding-left: 6px;
    padding-right: 6px;
  }

  /* Button order follows HTML source order in flex column layout.
     HTML source is secondary first, primary last → primary naturally at bottom (thumb reach). */

  /* Member modal: body must scroll within bottom-sheet height */
  .team-modal__dialog--stacked .team-member-modal__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .team-member-modal__subhead {
    flex-shrink: 0;
    padding-inline: 16px;
    min-width: 0;
  }

  /* --- Member modal context bar collapse ---
     flex-basis: 10rem on desktop = 10rem HEIGHT in column direction → dead space.
     Reset to auto so the element only takes height of its text content. */
  .team-member-context {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .team-member-context__line {
    flex: 0 0 auto;
  }

  .team-member-context__sep {
    display: none;
  }

  .team-member-context__pill {
    margin-left: 0;
  }

  /* --- Member modal tabs: canonical .ipi-tabs scrolls horizontally on mobile --- */
  .team-modal .ipi-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  .team-modal .ipi-tabs::-webkit-scrollbar {
    display: none;
  }

  .team-modal .ipi-tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  /* --- Edit modal: form grids collapse --- */
  .team-modal .form-grid.two-col {
    grid-template-columns: 1fr;
  }

  /* --- Modal buttons: full-width + touch targets --- */
  .team-modal__footer .btn,
  .team-member-modal__footer-group .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
    font-size: 13px;
  }

  .team-member-modal__footer-group {
    justify-content: stretch;
  }

  .team-modal .modal__header,
  .team-modal .modal__body {
    padding-inline: 16px;
  }
}

/* --- Dark mode: desktop --- */
html[data-theme="dark"] .team-modal {
    /* Dark-mode --ipi-* token overrides for canonical primitives */
    --ipi-bg: rgba(15, 23, 42, 0.55);
    --ipi-bg-inset: rgba(15, 23, 42, 0.62);
    --ipi-bg-card: rgba(15, 23, 42, 0.7);
    --ipi-bg-hover: rgba(148, 163, 184, 0.08);
    --ipi-rule: rgba(148, 163, 184, 0.22);
    --ipi-rule-h: rgba(148, 163, 184, 0.28);
    --ipi-ink: #e2e8f0;
    --ipi-ink-2: #cbd5e1;
    --ipi-ink-3: #94a3b8;
    --ipi-ink-4: #94a3b8;
    --ipi-accent: #e3b008;
    --ipi-accent-bg: rgba(227, 176, 8, 0.18);
    --ipi-accent-border: rgba(244, 217, 139, 0.5);
    --ipi-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --ipi-shadow-card: 0 1px 4px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(148, 163, 184, 0.1);
}

html[data-theme="dark"] .team-modal .modal__dialog {
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.97);
  box-shadow: 0 28px 64px rgba(2, 6, 23, 0.62);
}

html[data-theme="dark"] .team-modal .modal__close {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(71, 85, 105, 0.55);
  color: rgba(148, 163, 184, 0.8);
}

html[data-theme="dark"] .team-modal .modal__close:hover {
  background: rgba(51, 65, 85, 0.9);
  color: #f8fafc;
}

html[data-theme="dark"] .team-modal__header {
  border-bottom-color: rgba(71, 85, 105, 0.55);
}

html[data-theme="dark"] .team-modal__body {
  background: rgba(2, 6, 23, 0.42);
}

html[data-theme="dark"] .team-modal__footer {
  border-top-color: rgba(71, 85, 105, 0.55);
  background: rgba(15, 23, 42, 0.95);
}

html[data-theme="dark"] .team-modal__prose p {
  color: rgba(226, 232, 240, 0.92);
}

html[data-theme="dark"] .team-modal__prose p.text-muted.small-text {
  color: rgba(148, 163, 184, 0.88);
}

html[data-theme="dark"] .team-member-modal__subhead {
  background: rgba(15, 23, 42, 0.95);
  border-bottom-color: rgba(71, 85, 105, 0.55);
}

html[data-theme="dark"] .team-member-context {
  border-bottom-color: rgba(71, 85, 105, 0.42);
}

html[data-theme="dark"] .team-member-tabs__track {
  border-color: rgba(71, 85, 105, 0.55);
  background: rgba(15, 23, 42, 0.72);
}

html[data-theme="dark"] .team-member-tab {
  color: rgba(226, 232, 240, 0.8);
}

html[data-theme="dark"] .team-member-tab:hover {
  background: rgba(30, 41, 59, 0.75);
  color: #f8fafc;
}

html[data-theme="dark"] .team-member-tab.is-active {
  background: rgba(30, 41, 59, 0.96);
  color: #f8fafc;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .team-member-tab--danger {
  color: #fca5a5;
}

html[data-theme="dark"] .team-member-tab.team-member-tab--danger:hover {
  background: rgba(220, 38, 38, 0.18);
  color: #fecaca;
}

html[data-theme="dark"] .team-member-tab.team-member-tab--danger.is-active {
  background: rgba(127, 29, 29, 0.45);
  color: #fecaca;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .team-member-panel-divider {
  border-top-color: rgba(71, 85, 105, 0.55);
}

html[data-theme="dark"] .team-member-status-pill {
  border-color: rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.55);
  color: rgba(226, 232, 240, 0.8);
}

/* --- Dark mode: mobile table cards + drawer + modals --- */
@media (max-width: 900px) {
  html[data-theme="dark"] .team-page .team-table tr {
    background: var(--card);
    border-color: var(--border);
    box-shadow: none;
  }

  html[data-theme="dark"] .team-page .team-table td {
    border-bottom-color: rgba(71, 85, 105, 0.4);
  }

  html[data-theme="dark"] .team-page .team-table td::before {
    color: var(--text-muted);
  }

}

/* Inspector role-gated empty state */
.team-page .rpi-empty-state {
  margin-top: 32px;
  text-align: center;
}

.team-page .rpi-empty-state p {
  margin: 0 0 8px;
}

.team-page .rpi-empty-state p.text-muted {
  margin: 0 0 16px;
}
