/* ── Team (user administration) modal ───────────────────────────────────
   Shares the Character dialog chrome (.char-* skeleton + the B2 tokens) and
   speaks the same grammar: neutral sunken surfaces for status/read, the cream
   (#F6F4EE) "agent surface" for the operator's own action (invite), mono
   micro-caps eyebrows, hairline tables, and no blue focus rings. Buttons reuse
   the global .tpl-btn family; team-only surfaces are styled here.

   Layout (2026-08-18 redesign): everything hangs off ONE left-aligned edge —
   section labels, invite card, count line, table. Seat usage is a quiet mono
   count on the Members label row, shown as "x / y" only when a cap is
   configured (uncapped roles never render an ∞). */

/* Wider than the 470px Character dialog — the members table needs the room.
   --team-alert is the Claude orange used for every alert/limit state on this
   card (seat-full count, seat-full guidance, invite errors) — warm, and
   lighter than the theme's reds/ambers. */
.char-dialog.team-dialog { width: 495px; --team-alert: #D97757; }

/* Invite — the operator's own action, so it wears the cream "agent surface"
   (same fill as .char-mine). Inputs sit on the neutral surface inside it. */
.team-invite {
    display: grid;
    grid-template-columns: 1fr auto auto;   /* email | role | Send — a single row */
    align-items: center;
    gap: 8px;
    background: #F6F4EE;
    border: 1px solid var(--b2-line-2, #D1D5DB);
    border-radius: 8px;
    padding: 6px;
    margin: 0 0 4px;                         /* full content width, left edge */
}
.team-invite input,
.team-invite select {
    width: 100%;
    box-sizing: border-box;
    height: 30px;                 /* match the Send button's 30px min-height */
    padding: 0 10px;
    background: var(--b2-surface, #fff);
    border: 1px solid var(--b2-line-2, #D1D5DB);
    border-radius: 6px;
    font-family: inherit;
    font-size: 12.5px;
    color: var(--b2-ink, #111216);
}
.team-invite input::placeholder { color: var(--b2-ink-4, #9CA3AF); }
/* Role reads centred inside its box; email stays left-aligned for typing. */
.team-invite select { text-align: center; text-align-last: center; }
/* Exempt from the theme's two global blue focus treatments (both !important),
   exactly like .char-mine — clicking in just darkens the hairline one step. */
.team-invite input:focus,
.team-invite input:focus-visible,
.team-invite select:focus,
.team-invite select:focus-visible {
    outline: none !important;
    outline-offset: 0 !important;
    box-shadow: none !important;
    border-color: var(--b2-line-strong, #9CA3AF) !important;
}
/* All invite guidance/errors on this card share the Claude orange accent. The
   error sits BELOW the single-row invite box and collapses to nothing when
   empty, so it never forces the box taller in the common (no-error) case. */
.team-err { font-size: 11.5px; color: var(--team-alert); overflow-wrap: anywhere; }
.team-err:not(:empty) { margin: 4px 2px 0; }

/* Members label row — the eyebrow on the left, seat usage on the right in the
   same mono micro-caps voice. Uncapped roles read "2 experts"; capped roles
   read "4 / 5 experts"; a full segment turns alert-colored (limit reached). */
.team-lab-row { display: flex; align-items: baseline; justify-content: space-between; margin: 14px 0 6px; }
.team-lab-row .char-lab { margin: 0; }
.team-count {
    font-family: var(--f-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--b2-ink-4, #9CA3AF);
}
.team-count .seg-full { color: var(--team-alert); font-weight: 700; }

/* Send-invite button — quiet white primary that reads on the cream card (the
   Character primary is cream, which would vanish here); no global gold stamp.
   Scoped to this dialog; out-specifies .tpl-btn.primary (0,3,0 > 0,2,0). */
.team-invite .tpl-btn.primary {
    background: var(--b2-surface, #fff);
    border-color: var(--b2-line-2, #D1D5DB);
    color: var(--b2-ink, #111216);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
}
.team-invite .tpl-btn.primary:hover:not(:disabled) {
    background: var(--b2-line, #E5E7EB);
    border-color: var(--b2-line-strong, #9CA3AF);
    color: var(--b2-ink, #111216);
}
.team-invite .tpl-btn.primary:disabled { opacity: 0.55; cursor: not-allowed; }

/* Role filter — segmented control in the table header's mono micro-caps
   voice (user decision 2026-08-18: grouping option D). "All" is the default
   every open; the active segment sits on the sunken surface. */
.team-seg {
    display: inline-flex;
    border: 1px solid var(--b2-line-2, #D1D5DB);
    border-radius: 6px;
    overflow: hidden;
    margin: 2px 0 6px;
}
.team-seg button {
    border: 0;
    background: var(--b2-surface, #fff);
    /* Relaxed 2026-08-19 ("字体逼仄" review, option S1): same mono micro-caps
       voice as the labels, but more air — padding 4→6px, size 10→10.5px,
       tracking .05→.09em. */
    padding: 6px 15px;
    font-family: var(--f-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--b2-ink-4, #9CA3AF);
    cursor: pointer;
    border-right: 1px solid var(--b2-line, #E5E7EB);
}
.team-seg button:last-child { border-right: 0; }
.team-seg button:hover { color: var(--b2-ink-2, #4B5563); }
.team-seg button.on {
    background: var(--b2-sunken, #F3F4F6);
    color: var(--b2-ink, #111216);
}
.team-seg button:focus,
.team-seg button:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

/* Members table — hairline rows, ink hierarchy, mono micro-caps header. Full
   content width (shares the dialog's single left edge); the User column takes
   all spare room, so long emails read comfortably. */
.team-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 4px 0 0; }
.team-table th {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--b2-line, #E5E7EB);
    font-family: var(--f-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--b2-ink-4, #9CA3AF);
}
.team-table td {
    padding: 5px 8px;        /* ~20% shorter rows (was 7px) */
    line-height: 1.25;       /* tighten the two-line User cell */
    vertical-align: middle;
    border-bottom: 1px solid var(--b2-line, #E5E7EB);
    color: var(--b2-ink, #111216);
}
.team-table tr:last-child td { border-bottom: 0; }
.team-table tr.inactive td { color: var(--b2-ink-4, #9CA3AF); }
/* Role and Status columns (selects, or the Operator badge) read centred under
   their headers. */
.team-table th:nth-child(2),
.team-table td:nth-child(2),
.team-table th:nth-child(3),
.team-table td:nth-child(3) { text-align: center; }
.team-sub-u { color: var(--b2-ink-4, #9CA3AF); font-size: 11px; margin-top: 1px; }
.team-table select {
    /* Snug fixed width — sized to the longest option (expert / unset) so the
       column edge stays crisp; the value sits CENTERED so a short word's
       slack splits evenly instead of pooling before the arrow (2026-08-21
       review: cure 2, same grammar as the invite's role select). */
    width: 66px;
    box-sizing: border-box;
    padding: 3px 6px;
    text-align: center;
    text-align-last: center;
    background: var(--b2-surface, #fff);
    border: 1px solid var(--b2-line-2, #D1D5DB);
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    color: var(--b2-ink, #111216);
}
.team-table select:focus,
.team-table select:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border-color: var(--b2-line-strong, #9CA3AF) !important;
}
/* Status control — a live Active/Inactive select (user decision 2026-08-18:
   "deactivate without deleting" as a real operator action). Slightly wider
   than the Role select so "inactive" fits; grays with its row when inactive. */
.team-table select.team-stat { width: 76px; }
.team-table tr.inactive select.team-stat { color: var(--b2-ink-4, #9CA3AF); }

/* Operator's Role cell — a fact, not a control (2026-08-21 review, option C:
   operators are platform-managed, nothing on the row is editable). The chip
   wears the role-select's exact geometry (width/padding/radius/type) so the
   column keeps one vertical rhythm; sunken fill + no arrow are the
   "non-interactive" cues. The Status cell shows a quiet dash. */
.team-role-fixed {
    display: inline-block;
    width: 66px;
    box-sizing: border-box;
    padding: 3px 6px;
    text-align: center;
    background: var(--b2-sunken, #F3F4F6);
    border: 1px solid var(--b2-line, #E5E7EB);
    border-radius: 6px;
    font-size: 12px;
    color: var(--b2-ink-3, #6B7280);
}
.team-stat-none { color: var(--b2-ink-4, #9CA3AF); font-size: 12px; }

/* Row action buttons (Deactivate / Reactivate) — quiet hairline buttons. */
.team-mini {
    background: var(--b2-surface, #fff);
    border: 1px solid var(--b2-line-2, #D1D5DB);
    border-radius: 6px;
    padding: 3px 10px;
    font-family: inherit;
    font-size: 11.5px;
    cursor: pointer;
    color: var(--b2-ink-2, #4B5563);
}
.team-mini:hover { border-color: var(--b2-line-strong, #9CA3AF); color: var(--b2-ink, #111216); }

/* Delete — a destructive action, so it reads red and asks once (two-click arm). */
.team-mini.danger { color: var(--team-alert); }
.team-mini.danger:hover {
    border-color: rgba(217, 119, 87, 0.5);
    background: rgba(217, 119, 87, 0.08);
    color: var(--team-alert);
}
.team-mini.is-armed,
.team-mini.is-armed:hover {
    background: var(--team-alert);
    border-color: var(--team-alert);
    color: #fff;
}

/* Selects (invite role + table role/status) — strip the native OS chrome so
   the closed control speaks the same hairline language as everything else:
   appearance:none + our own ink-4 chevron (inline SVG). The OPEN option list
   stays browser-native by platform limitation; option casing is lowercase to
   match (user decision 2026-08-18). */
.team-invite select,
.team-table select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M1 1l3 3 3-3' fill='none' stroke='%239CA3AF' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 22px !important;
    cursor: pointer;
}
.team-invite select:hover,
.team-table select:hover { border-color: var(--b2-line-strong, #9CA3AF); }
/* The snug table selects carry a tighter arrow gutter than the invite's
   (22px → 20px reserve, arrow inset 8px → 6px); must sit after the shared
   rule above to win its !important padding-right. */
.team-table select {
    background-position: right 6px center;
    padding-right: 20px !important;
}

/* The OPEN option list — square native popup clashed with the rounded
   closed control (user report 2026-08-18). Chromium 134+ exposes the popup
   to CSS via appearance:base-select + ::picker(select); style it as the
   same rounded hairline card the dialog speaks (radius, line-2 border, the
   op-toast shadow). @supports-guarded: every other browser keeps the native
   popup untouched. base-select draws its own caret (::picker-icon) — hide
   it, our SVG chevron on the closed control stays the single arrow. */
@supports selector(::picker(select)) {
    .team-invite select,
    .team-table select {
        appearance: base-select;
        -webkit-appearance: base-select;
    }
    /* base-select re-lays-out the closed control's content — the invite bar's
       fixed-height (30px) select top-aligned its text. Center it explicitly. */
    .team-invite select {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    /* Same centering exemption for the snug table selects (their value is
       centered by design, cure 2); inline-flex so the centered td still
       centers the control itself. */
    .team-table select {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .team-invite select::picker-icon,
    .team-table select::picker-icon { display: none; }
    .team-invite select::picker(select),
    .team-table select::picker(select) {
        appearance: base-select;
        background: var(--b2-surface, #fff);
        border: 1px solid var(--b2-line-2, #D1D5DB);
        border-radius: 8px;
        box-shadow: 0 8px 24px rgba(17, 18, 22, 0.10), 0 2px 6px rgba(17, 18, 22, 0.06);
        padding: 4px;
        /* Pin the popup BELOW its control. The UA default fallback chain was
           flipping some pickers upward with plenty of room below (Status
           opened up while Role opened down). block-end + a flip-block-only
           fallback keeps every popup dropping down unless it would truly
           leave the viewport. The 3px gap moves with the placement. */
        position-area: block-end span-inline-end;
        /* flip-inline ONLY: a popup near the dialog's right edge overflows
           horizontally, and the UA's default fallback "fixed" that by
           flipping VERTICALLY (Status opened upward). Horizontal flips keep
           every popup below its control; vertical flipping is never needed
           for a two-option list inside a centered dialog. */
        position-try-fallbacks: flip-inline;
        margin-block-start: 3px;
    }
    .team-invite select option,
    .team-table select option {
        padding: 4px 10px;
        border-radius: 5px;
        font-family: inherit;
        font-size: 12px;
        color: var(--b2-ink, #111216);
    }
    .team-invite select option:hover,
    .team-table select option:hover,
    .team-invite select option:focus,
    .team-table select option:focus {
        background: var(--b2-sunken, #F3F4F6);
    }
    /* Keyboard focus stays visible but in the hairline voice, not the UA's
       heavy black ring. */
    .team-invite select option:focus-visible,
    .team-table select option:focus-visible {
        outline: 1px solid var(--b2-line-strong, #9CA3AF);
        outline-offset: -1px;
    }
    /* Current value reads by weight, not by the UA checkmark. */
    .team-invite select option::checkmark,
    .team-table select option::checkmark { display: none; }
    .team-invite select option:checked,
    .team-table select option:checked { font-weight: 600; }
}

/* Pending invites (2026-08-19, review P3+R2): count segment, and the Pending
   tab's Invited column — full-word relative times ("2 hours ago"), expired
   flips to an alert mono flag. */
.team-count .seg-pend { color: var(--team-alert); font-weight: 700; }
.inv-cell { font-size: 12px; color: var(--b2-ink-2, #4B5563); white-space: nowrap; }
.inv-cell.expired {
    font-family: var(--f-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--team-alert);
}

/* ── A member's Team (everyone has Team, user 2026-10-21; review T2 at W1) ──
   Who is on the team + invite colleagues: no role, status or delete column,
   so nothing sits to the right of a member row and the card takes the
   400 px dlg-card width instead of the operator's 495 (user: 「普通人的team
   不需要像operator的那么宽」). The invite bar keeps the operator's surface
   and its .team-err line, minus the role select. */
.char-dialog.team-dialog.member { width: 400px; }
.team-invite.member { grid-template-columns: 1fr auto; }   /* email | Send */
.team-you { margin-left: 6px; font-size: 11px; color: var(--b2-ink-4, #9CA3AF); }
.team-table.team-people td:first-child,
.team-table.team-invited td:first-child { overflow-wrap: anywhere; }
.team-table.team-invited td:nth-child(2) { white-space: nowrap; }
.team-pend { display: block; font-size: 12px; font-weight: 600; color: var(--team-alert); }
.team-when { display: block; margin-top: 1px; font-size: 11px; color: var(--b2-ink-4, #9CA3AF); }
.team-when.expired {
    font-family: var(--f-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--team-alert);
}

/* Quiet row actions; existing labels, confirmation and roster behavior stay intact. */
.team-dialog .team-mini[data-resend],
.team-dialog .team-mini[data-delete] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 90px;
    min-height: 28px;
    padding: 4px 7px;
    gap: 5px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 6px;
    line-height: 1.2;
    font-weight: 500;
    transition: background-color .15s, border-color .15s;
}
.team-dialog .team-mini[data-resend]:hover {
    background: var(--b2-sunken, #F3F4F6);
    border-color: var(--b2-line, #E5E7EB);
}
.team-dialog .team-mini[data-delete]:hover {
    background: rgba(217, 119, 87, .08);
    border-color: rgba(217, 119, 87, .2);
}
.team-dialog .team-mini[data-delete].is-armed {
    color: var(--team-alert);
    background: rgba(217, 119, 87, .12);
    border-color: rgba(217, 119, 87, .4);
}
.team-dialog .team-mini[data-resend]:focus-visible,
.team-dialog .team-mini[data-delete]:focus-visible {
    outline: 2px solid var(--b2-ink-3, #6B7280);
    outline-offset: 2px;
}

/* Option D: icons accompany the original action labels. */
.team-dialog .team-mini[data-resend]::before,.team-dialog .team-mini[data-delete]::before{content:'';display:inline-block;flex-shrink:0;width:12px;height:12px;background:currentColor;mask-size:contain;mask-repeat:no-repeat;mask-position:center}
.team-dialog .team-mini[data-resend]::before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 7v5h-5M4 17v-5h5M6.1 6.1A8 8 0 0 1 19.6 10M4.4 14a8 8 0 0 0 13.5 3.9'/%3E%3C/svg%3E")}
.team-dialog .team-mini[data-delete]::before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6h16M9 6V3h6v3M6 6l1 15h10l1-15M10 10v7M14 10v7'/%3E%3C/svg%3E")}

/* Compact Team spacing, preserving the palette and right-aligned actions. */
.char-dialog.team-dialog {
    width: 450px;
    max-width: calc(100vw - 24px);
    box-sizing: border-box;
    padding: 14px 14px 12px;
}
.char-dialog.team-dialog.member { width: 380px; }
.team-dialog .char-sub { margin-bottom: 10px; }
.team-dialog .char-lab { margin-top: 10px; margin-bottom: 5px; }
.team-dialog .team-lab-row { margin: 10px 0 4px; }
.team-dialog .team-lab-row .char-lab { margin: 0; }
.team-dialog .team-invite { padding: 5px; gap: 6px; }
.team-dialog .team-invite input { min-width: 0; }
.team-dialog .team-seg { margin-bottom: 4px; }
.team-dialog .team-seg button { padding: 5px 12px; }
.team-dialog .team-table th { padding: 5px; }
.team-dialog .team-table td { padding: 4px 5px; }
.team-dialog .team-table :is(th, td):first-child { padding-left: 0; overflow-wrap: anywhere; }
.team-dialog .team-table :is(th, td):last-child { padding-right: 0; }
.team-dialog .team-mini[data-resend],
.team-dialog .team-mini[data-delete] {
    min-width: 82px;
    min-height: 26px;
    padding: 3px 4px;
    gap: 4px;
}
.team-dialog .char-foot { margin-top: 9px; }

/* A member's card is as wide as the operator's on every tab, so switching
   All ↔ Pending never resizes it; each person is one row, name left and
   email right (user 2026-11-03, option 4). */
.char-dialog.team-dialog.member { width: 450px; }
.team-table.team-people td { padding-top: 7px; padding-bottom: 7px; }
.team-table.team-people .team-nm { white-space: nowrap; }
.team-table.team-people th:nth-child(2),
.team-table.team-people .team-em { text-align: right; }
.team-table.team-people .team-em {
    max-width: 0;              /* take the rest of the row, ellipsize past it */
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow-wrap: normal;
    color: var(--b2-ink-3, #6B7280);
    font-size: 12px;
}
.team-dialog.member .team-invited td:first-child { width: 100%; }
.team-dialog.member .team-invited .act-cell { display: flex; justify-content: flex-end; }
@media (max-width: 440px) {
    .team-dialog.member .team-invited .act-cell { flex-direction: column; align-items: flex-end; }
}

/* Member directory navigation and identity rows. */
.team-dialog .team-member-tabs {
    display: flex;
    gap: 16px;
    margin: 14px 0 6px;
    border: 0;
    border-bottom: 1px solid var(--b2-line, #E5E7EB);
    border-radius: 0;
}
.team-member-tabs button {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    padding: 0 0 9px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--b2-ink-3, #6B7280);
}
.team-member-tabs button.on { background: transparent; border-bottom-color: var(--b2-ink, #111216); }
.team-member-tabs button span {
    min-width: 18px;
    padding: 1px 5px;
    box-sizing: border-box;
    border-radius: 5px;
    background: var(--b2-sunken, #F3F4F6);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}
.team-member-tabs button:focus-visible { outline: 2px solid var(--b2-ink-3, #6B7280) !important; outline-offset: -2px; }
.team-dialog.member .team-empty { padding: 18px 4px; color: var(--b2-ink-3, #6B7280); line-height: 1.6; text-align: left; }
.team-directory { list-style: none; margin: 0; padding: 0; }
.team-person { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--b2-line, #E5E7EB); }
.team-person:last-child { border-bottom: 0; }
.team-person-info { min-width: 0; }
.team-person-name { font-size: 12.5px; font-weight: 550; line-height: 1.4; overflow-wrap: anywhere; }
.team-person-email { margin-top: 1px; color: var(--b2-ink-3, #6B7280); font-size: 11.5px; line-height: 1.4; overflow-wrap: anywhere; }

/* Operator members share the directory identity, with management controls. */
.team-operator-table { table-layout: fixed; }
.team-operator-table .team-person { padding: 0; border: 0; gap: 8px; }
.team-operator-table .team-person-info { flex: 1; }
.team-operator-table .team-person-email { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-operator-members col:nth-child(2) { width: 78px; }
.team-operator-members col:nth-child(3) { width: 88px; }
.team-operator-table th:last-child { width: 64px; }
.team-operator-table .team-invitation-time { text-align: center; }
.team-dialog.operator .team-lab-row .char-lab { font-size: 11px; }
/* A single filter control leads straight into the member rows. */
.team-dialog.operator .team-role-filter { margin: 6px 0 7px; }
.team-dialog.operator .team-role-filter button {
    padding: 6px 13px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}
.team-role-filter button:focus-visible { outline: 2px solid var(--b2-ink-3, #6B7280) !important; outline-offset: -2px; }
.team-operator-members col:last-child { width: 64px; }
.team-operator-members thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.team-dialog .team-operator-table { margin-top: 0; }
.team-dialog .team-operator-table th { padding-top: 8px; padding-bottom: 6px; }
.team-dialog .team-operator-table td { padding-top: 7px; padding-bottom: 7px; }
.team-dialog .team-operator-table .team-mini[data-delete],
.team-dialog .team-operator-table .team-mini[data-resend] { min-width: 60px; padding: 3px 2px; }
.team-operator-table .act-cell { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
@media (max-width: 440px) {
    .team-operator-table, .team-operator-table tbody { display: block; }
    .team-operator-table thead { display: none; }
    .team-operator-table tr { display: grid; grid-template-columns: 1fr 1fr auto; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--b2-line, #E5E7EB); }
    .team-operator-table tr:last-child { border-bottom: 0; }
    .team-dialog .team-operator-table td { display: block; padding: 0; border: 0; text-align: left; }
    .team-operator-table td.team-identity-cell { grid-column: 1 / -1; }
    .team-operator-table .team-person { padding: 0 0 2px; }
    .team-operator-table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 4px; font-size: 10px; color: var(--b2-ink-3, #6B7280); }
    .team-operator-table td:last-child { align-self: end; }
    .team-operator-table td.team-invitation-time { grid-column: 1 / 3; }
    .team-dialog.operator .team-count { font-size: 9px; letter-spacing: 0; }
}

/* Member directory: one bounded section, with identity across each row. */
.team-member-roster {
    margin-top: 12px;
    border: 1px solid var(--b2-line, #E5E7EB);
    border-radius: 8px;
    overflow: hidden;
}
.team-dialog.member .team-member-roster .team-seg {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 6px;
    border: 0;
    border-bottom: 1px solid var(--b2-line, #E5E7EB);
    border-radius: 0;
    background: var(--b2-sunken, #F3F4F6);
}
.team-dialog.member .team-member-roster .team-seg button {
    padding: 4px 6px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--b2-ink-3, #6B7280);
}
.team-dialog.member .team-member-roster .team-seg button:last-child { margin-left: auto; }
.team-dialog.member .team-member-roster .team-seg button.on { color: var(--b2-ink, #111216); background: var(--b2-surface, #fff); }
.team-roster-content { padding: 0 12px; }
.team-dialog.member .team-directory .team-person { padding: 9px 0; }
.team-dialog.member .team-directory .team-person-info {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    align-items: center;
    gap: 12px;
    width: 100%;
}
.team-dialog.member .team-directory .team-person-name { font-weight: 500; font-size: 12px; }
.team-dialog.member .team-directory .team-person-email {
    margin: 0;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Departments (tenant switch `departments`; user 2026-11-10/11) ─────────
   The same dialog with the roster in one block per department. Everything
   hangs off .has-depts, so a tenant without the switch renders exactly as
   before. Only the platform's own B2 tokens. Look picked on
   static/_review_departments.html: block "B1" (a hairline card with a sunken
   header — the member roster's own frame, one per department) and row
   actions "B" (two equal icon buttons). */

/* A block's 12 px gutters cost 24 px; the dialog gives them back so the
   name / email column stays as wide as before. */
.char-dialog.team-dialog.has-depts { width: 474px; }

/* Invite strip: the role select's slot holds the department. */
.team-dialog.has-depts .team-invite { grid-template-columns: minmax(0, 1fr) auto auto; }
.team-dialog.has-depts .team-invite select { max-width: 158px; text-overflow: ellipsis; }

/* The All / Pending row carries New department on the right (company operator). */
.team-dept-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0 7px; }
.team-dialog.operator .team-dept-toolbar .team-role-filter { margin: 0; }
.team-dialog .team-dept-new { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; font-size: 11.5px; font-weight: 500; }
.team-dept-new::before {
    content: ''; width: 9px; height: 9px; background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M5 1v8M1 5h8' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* One department: a header (caret, name, head count) over its people. */
.team-depts { display: flex; flex-direction: column; gap: 8px; }
.team-dept { border: 1px solid var(--b2-line, #E5E7EB); border-radius: 8px; overflow: hidden; }
.team-dept-hd {
    display: flex; align-items: center; gap: 7px; min-height: 22px;
    padding: 6px 10px 6px 11px;
    background: var(--b2-sunken, #F3F4F6);
    cursor: pointer; user-select: none;
}
.team-dept:not(.shut) > .team-dept-hd { border-bottom: 1px solid var(--b2-line, #E5E7EB); }
.team-dept-hd:focus-visible { outline: 2px solid var(--b2-ink-3, #6B7280); outline-offset: -2px; }
.team-dept-caret {
    flex: none; width: 5px; height: 5px; margin: 0 2px 2px 1px;
    border-right: 1.5px solid var(--b2-ink-4, #9CA3AF); border-bottom: 1.5px solid var(--b2-ink-4, #9CA3AF);
    transform: rotate(45deg); transition: transform .12s;
}
.team-dept.shut .team-dept-caret { transform: rotate(-45deg); margin: 0 3px 0 0; }
.team-dept-name { font-size: 12.5px; font-weight: 600; color: var(--b2-ink, #111216); overflow-wrap: anywhere; }
.team-dept-n { margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--b2-ink-3, #6B7280); }
.team-dept-more {
    flex: none; display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 20px; margin-right: -4px; padding: 0;
    border: 0; border-radius: 5px; background: transparent; cursor: pointer;
}
.team-dept-more i {
    width: 3px; height: 3px; border-radius: 50%; background: var(--b2-ink-3, #6B7280);
    box-shadow: -5px 0 0 var(--b2-ink-3, #6B7280), 5px 0 0 var(--b2-ink-3, #6B7280);
}
.team-dept-more:hover { background: var(--b2-line, #E5E7EB); }
.team-dept-more:focus-visible { outline: 2px solid var(--b2-ink-3, #6B7280); outline-offset: 1px; }
.team-dept-body { padding: 0 12px; }
.team-dept-empty { padding: 9px 0; font-size: 12px; color: var(--b2-ink-4, #9CA3AF); }

/* New / Rename: the header turns into a field. */
.team-dept-hd.team-dept-editing { cursor: default; }
.team-dept-editing input {
    flex: 1; min-width: 0; height: 26px; padding: 0 8px; box-sizing: border-box;
    background: var(--b2-surface, #fff); border: 1px solid var(--b2-line-2, #D1D5DB); border-radius: 6px;
    font-family: inherit; font-size: 12.5px; color: var(--b2-ink, #111216);
}
.team-dept-editing input:focus,
.team-dept-editing input:focus-visible { outline: none !important; box-shadow: none !important; border-color: var(--b2-line-strong, #9CA3AF) !important; }
.team-dept-editing .team-mini { padding: 4px 9px; }
.team-dept-err:not(:empty) { margin: 5px 12px 7px; }

/* People in a block. A row the viewer manages is the operator table's row;
   every other row is the member directory's row (name left, email right). */
.team-dialog.has-depts .team-dept-body .team-table { margin: 0; }
.team-dialog.has-depts .team-operator-members col:nth-child(2) { width: 84px; }   /* role */
.team-dialog.has-depts .team-operator-members col:nth-child(3) { width: 96px; }   /* company operator: three icon buttons */
.team-dialog.has-depts .team-dept-own col:nth-child(3) { width: 64px; }           /* group operator: two */
.team-dialog.has-depts .team-table select[data-role2-for],
.team-dialog.has-depts .team-role-fixed { width: 76px; }
.team-dialog.has-depts .team-table select:disabled { color: var(--b2-ink-4, #9CA3AF); background-color: var(--b2-sunken, #F3F4F6); cursor: default; }
.team-dept-tag {
    margin-left: 6px; padding: 0 5px;
    border: 1px solid var(--b2-line, #E5E7EB); border-radius: 5px; background: var(--b2-sunken, #F3F4F6);
    font-size: 10.5px; font-weight: 500; color: var(--b2-ink-3, #6B7280);
    white-space: nowrap; vertical-align: 1px;
}
.team-dialog.has-depts .team-directory .team-person { padding: 9px 0; }
.team-dialog.has-depts .team-directory .team-person-info {
    display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); align-items: center; gap: 12px; width: 100%;
}
.team-dialog.has-depts .team-directory .team-person-name { font-weight: 500; font-size: 12px; }
.team-dialog.has-depts .team-directory .team-person-email { margin: 0; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Row actions: equal icon buttons, as tall as the select beside them —
   move to another group, off / on, delete. */
.team-dialog.has-depts .team-operator-members .act-cell.act-icons { flex-direction: row; align-items: center; justify-content: flex-end; gap: 5px; }
.team-ico, .team-ico-gap { flex: none; width: 27px; height: 24px; box-sizing: border-box; }
.team-ico {
    display: inline-flex; align-items: center; justify-content: center; padding: 0;
    background: var(--b2-surface, #fff); border: 1px solid var(--b2-line-2, #D1D5DB); border-radius: 6px;
    color: var(--b2-ink-3, #6B7280); cursor: pointer;
}
.team-ico::before { content: ''; width: 13px; height: 13px; background: currentColor; mask-size: contain; mask-repeat: no-repeat; mask-position: center; }
.team-ico[data-move]::before { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8h14M14 4l4 4-4 4M20 16H6M10 12l-4 4 4 4'/%3E%3C/svg%3E"); }
.team-ico[data-delete]::before { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6h16M9 6V3h6v3M6 6l1 15h10l1-15M10 10v7M14 10v7'/%3E%3C/svg%3E"); }
.team-ico:hover { border-color: var(--b2-line-strong, #9CA3AF); color: var(--b2-ink, #111216); }
.team-ico.danger { color: var(--team-alert, #D97757); }
.team-ico.danger:hover { border-color: rgba(217, 119, 87, .5); background: rgba(217, 119, 87, .08); color: var(--team-alert, #D97757); }
.team-ico:focus-visible { outline: 2px solid var(--b2-ink-3, #6B7280); outline-offset: 1px; }

/* A member's tabs (Members n / Your invites n) sit above the blocks. */
.team-dialog.has-depts .team-dept-tabs { margin: 12px 0 8px; }
.team-dialog.has-depts .team-dept-tabs button { padding: 0 0 7px; border-right: 0; }
.team-dialog.has-depts .team-dept-invites { margin-top: 0; }

/* Pending tab: the Invited column has a fixed width; the name takes the rest
   (it also carries the department tag). */
.team-dialog.has-depts .team-operator-table:not(.team-operator-members) th:nth-child(2) { width: 132px; }
.team-dialog.has-depts .team-operator-table:not(.team-operator-members) th:last-child { width: 70px; }

/* 2026-11-12 — expert / user back in the row, and the row's actions sit
   together at its end (review R1). The company operator's invite strip asks
   for the role again. (A deactivated account is in the Inactive tab only
   since 2026-11-13 — no grayed row in the group blocks.) */
.char-dialog.team-dialog.has-depts.company { width: 536px; }
.team-dialog.has-depts .team-invite.with-role { grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 6px; }
.team-dialog.has-depts .team-invite select { white-space: nowrap; }
/* Off / on — the same button as Move and Delete. */
.team-ico[data-toggle]::before { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='M6 6l12 12'/%3E%3C/svg%3E"); }
.team-ico[data-toggle].is-off::before { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12a8 8 0 1 0 2.6-5.9L4 8.5'/%3E%3Cpath d='M4 4v4.5h4.5'/%3E%3C/svg%3E"); }

/* Search (2026-11-12): people and groups, at the right end of the filter
   row (operators) or of the tabs (members). */
.team-dept-tools { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; flex: 1; }
.team-search { flex: 0 1 148px; min-width: 90px; }
.team-search input {
    width: 100%; height: 27px; box-sizing: border-box; padding: 0 8px 0 26px;
    background: var(--b2-surface, #fff) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M16 16l4.5 4.5'/%3E%3C/svg%3E") no-repeat 8px center / 12px 12px;
    border: 1px solid var(--b2-line-2, #D1D5DB); border-radius: 6px;
    font-family: inherit; font-size: 12px; color: var(--b2-ink, #111216);
}
.team-search input::placeholder { color: var(--b2-ink-4, #9CA3AF); }
.team-search input:focus,
.team-search input:focus-visible { outline: none !important; box-shadow: none !important; border-color: var(--b2-line-strong, #9CA3AF) !important; }
.team-member-tabs .team-search { margin: 0 0 6px auto; }
.team-search-none { padding: 12px 2px; font-size: 12px; color: var(--b2-ink-3, #6B7280); text-align: left; }

/* Move / department menu — the select popup's card. */
.team-pop {
    position: fixed; z-index: 1300; min-width: 150px; max-width: 240px; max-height: 300px; overflow-y: auto; padding: 4px;
    background: var(--b2-surface, #fff); border: 1px solid var(--b2-line-2, #D1D5DB); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(17, 18, 22, 0.10), 0 2px 6px rgba(17, 18, 22, 0.06);
    font-family: var(--f-sans, 'Geist', -apple-system, system-ui, sans-serif); font-size: 12px;
}
.team-pop button {
    display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%;
    padding: 5px 10px; border: 0; border-radius: 5px; background: transparent;
    font-family: inherit; font-size: 12px; text-align: left; color: var(--b2-ink, #111216); cursor: pointer;
}
.team-pop button:hover:not(:disabled),
.team-pop button:focus-visible { background: var(--b2-sunken, #F3F4F6); outline: none; }
.team-pop button.on { font-weight: 600; cursor: default; }
.team-pop button.on::after {
    content: ''; width: 10px; height: 10px; background: var(--b2-ink-2, #4B5563);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6.5l2.6 2.6L10 3.5' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
}
.team-pop button.danger { color: var(--team-alert, #D97757); }
.team-pop button:disabled:not(.on) { color: var(--b2-ink-4, #9CA3AF); cursor: default; }
.team-pop-lab {
    padding: 4px 10px 3px;
    font-family: var(--f-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
    font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--b2-ink-4, #9CA3AF);
}
.team-pop-note { padding: 3px 10px 5px; font-size: 11px; line-height: 1.4; color: var(--b2-ink-3, #6B7280); }
