/* The shell's own layout (openspec change design-system-and-shell, design D8): only what the carried components
   lack. Design tokens only; no colour or font literal. */

/* The module list sits in a <nav> landmark inside the sidebar: the landmark takes the list's place in the sidebar's
   column, so the list still fills it and scrolls, and the foot stays at the bottom. */
.nav > nav { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* The development identity banner sits under the top bar, inside the page's gutter. */
.main > .banner { margin: 12px var(--gutter) 0; }

/* The Not found page's Go to Home link sits apart from the page header. */
#view .page-header + p { margin-top: 16px; }

/* ----------------------------------------------------------------- Home --- */
/* Home (openspec change home, design D11): a grid of 4 equal columns filled row by row in the saved order, one row
   height and one gap from the tokens. Spans: S 1×1, M 2×1, L 2×2, XL 4×2. The row height comes from the spacing
   token --gutter × 6 (144px, 192px from 1600px wide), never --stick, which the page rewrites at runtime. */
.home-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-flow: row;
  grid-auto-rows: calc(var(--gutter) * 6);
  gap: calc(var(--gutter) / 2);
}
.home-tile { display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; overflow: hidden; }
.home-tile[hidden] { display: none; }
.home-tile[data-size="S"] { grid-column: span 1; grid-row: span 1; }
.home-tile[data-size="M"] { grid-column: span 2; grid-row: span 1; }
.home-tile[data-size="L"] { grid-column: span 2; grid-row: span 2; }
.home-tile[data-size="XL"] { grid-column: span 4; grid-row: span 2; }
.home-tile-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.home-tile-title { font-size: 14px; margin: 0; min-width: 0; flex: 1; }
.home-tile-body { flex: 1; min-height: 0; overflow: auto; }

/* The Customise controls sit in the tile's header: move up and down, one button per size, and hide. */
.home-tile-controls { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.home-tile-controls .btn { min-width: 26px; justify-content: center; }
.home-tile-controls .btn[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent-strong); border-color: var(--accent); }

/* A refusal banner holds its message and, for the stale-tab refusal, the Reload button. */
.home-banner { align-items: center; }
.home-banner > span { flex: 1; }

/* Add a panel: the draft's addable tiles, each with its description and an Add button. */
.home-add-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.home-add-list > li { display: flex; align-items: flex-start; gap: 12px; }
.home-add-text { flex: 1; min-width: 0; }
.home-add-text p { margin: 2px 0 0; }

/* Recently viewed: the label (a link to the object, on one line with an ellipsis, its full text in `title`), then the
   module name in a small muted line. */
.home-recent { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.home-recent > li { display: flex; flex-direction: column; min-width: 0; }
.home-recent-label { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Below 720 px wide the grid is one column: every tile spans it, at its own height. */
@media (max-width: 719.98px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; }
  .home-tile[data-size] { grid-column: span 1; grid-row: auto; }
}

/* ------------------------------------------------------------- Programs --- */
/* The Programs screens (openspec change programs-screens, design D11): the carried .programs-* classes, .pill, .chip,
   .banner, .form-field, .meter and .table-wrap draw them; these rules add only what those lack. */
.programs-page { display: flex; flex-direction: column; }
.programs-page > .page-header { margin-bottom: 0; }
.programs-back { margin: 0; }
.programs-list { display: flex; flex-direction: column; gap: 12px; }
.programs-banner { align-items: center; }
.programs-banner > span { flex: 1; }
.programs-more { margin: 0; display: flex; justify-content: center; }

/* The tags cell holds its chips; the action cell its action and, for an administrator, Copy. */
.programs-action-cell { white-space: nowrap; }
.programs-action-cell > * + * { margin-left: 8px; }

/* Request to join opens its form in a full-width row under the program's row. */
table.data.programs-table td[colspan] { height: auto; max-width: none; white-space: normal; padding: 12px; background: var(--surface-2); }
.programs-join-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.programs-join-form .form-field { margin-bottom: 0; min-width: 0; }
.programs-join-form .form-field:nth-child(2) { flex: 1 1 280px; }

/* New program and Copy: the form, its fieldsets (Visibility, Tags, Members) and the errors under the fields. */
.programs-form { max-width: 560px; }
.programs-fieldset { border: 0; margin: 0 0 16px; padding: 0; min-width: 0; }
.programs-fieldset > legend {
  padding: 0; margin-bottom: 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3);
}
.programs-choice { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.programs-choice > input { margin: 3px 0 0; accent-color: var(--accent-strong); }
.programs-fieldset .programs-choice label {
  display: flex; flex-direction: column; gap: 2px; margin: 0; font-size: 13px; font-weight: 400; letter-spacing: normal;
  text-transform: none; color: var(--text-1);
}
.programs-member { align-items: center; }
.programs-member > label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.programs-fieldset .programs-member > select {
  flex: none; width: auto; height: 30px; padding: 0 8px; border: 1px solid var(--line-control); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-1); font: inherit; font-size: 12px;
}
.programs-field-error { margin: 4px 0 0; font-size: 12px; color: var(--red-text); }
.programs-form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.programs-form > .banner { margin-bottom: 16px; }

/* The copy job's progress meter fills with the accent. */
.programs-page .meter .bar > span { background: var(--accent); }

/* Below 720 px wide each row of the Programs table is a card: the header row hidden, each cell on its own line; the
   filters wrap (the filter bar wraps at any width) and the search box takes the bar's width. */
@media (max-width: 719.98px) {
  .programs-table-wrap { overflow-x: visible; }
  table.data.programs-table, table.data.programs-table tbody { display: block; width: 100%; }
  table.data.programs-table thead { display: none; }
  table.data.programs-table tbody tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  table.data.programs-table tbody tr:last-child { border-bottom: 0; }
  table.data.programs-table td, table.data.programs-table td:first-child {
    display: block; width: auto; height: auto; max-width: none; padding: 2px 0; border: 0; white-space: normal;
    overflow: visible; text-align: left;
  }
  table.data.programs-table td.programs-action-cell { white-space: normal; }
  .programs-filters input[type="search"] { flex: 1 1 100%; max-width: none; min-width: 0; }
}

/* ------------------------------------------------------------ Module UIs --- */
/* module-ui-pages D6: the organisation entries and, inside a program, its navigation scroll together in the <nav>. */
.nav > nav { overflow-y: auto; }
.nav > nav > .nav-list { flex: none; overflow-y: visible; }
.shell-program-nav { border-top: 1px solid var(--nav-2); padding-top: 8px; }
.shell-program-nav[hidden] { display: none; }

/* shell-sections-navigation: the top bar's section tabs, a row under the bar's title that stays with the bar while the
   page scrolls; on a narrow screen the row scrolls sideways inside itself (.tabs), never wrapping or widening the page. Its offset is the design's --topbar-h, as the provenance strip's (the shell sets
   none, so the bar's 48px applies). */
.main > .shell-section-tabs {
  position: sticky; top: var(--topbar-h, 48px); z-index: 39; flex: none; min-width: 0; padding: 0 var(--gutter); background: var(--surface);
}
.shell-section-tabs[hidden] { display: none; }

/* shell-sections-navigation: the single program's sidebar block is headed by its code, with its name under it. */
.shell-single-program { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.shell-single-program-name {
  font-size: 12px; font-weight: 600; letter-spacing: normal; text-transform: none; color: var(--nav-ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* shell-sections-navigation: My work, one full-width section per work panel under its label. */
.shell-work { display: flex; flex-direction: column; gap: calc(var(--gutter) / 2); }
.shell-work-panel { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.shell-work-title { font-size: 14px; margin: 0; }
.shell-work-body { min-width: 0; }
.shell-work-body .empty { padding: 16px; }

/* D8, D12: a module page while its code loads, and the unavailable panel's buttons. */
.module-loading { margin: 16px 0 0; }
.module-unavailable .empty-actions { display: flex; gap: 8px; justify-content: center; }

/* D13: the toast stack is a manual popover; the browser's popover box is undone so .toast-host places it. */
.shell-toasts[popover] {
  inset: auto; left: 50%; bottom: 24px; margin: 0; padding: 0; border: 0; background: transparent; color: inherit;
  overflow: visible;
}
.shell-toasts:not(:popover-open) { display: none; }
.shell-toast > svg { flex: none; }

/* Error references (module-ui "Showing a fault"): "Reference: <ref>" and Copy, on their own line under a fault. */
.error-ref { margin: 4px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; }
.error-ref-value { font-family: var(--mono); overflow-wrap: anywhere; }
.shell-toast-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.shell-toast-body > .error-ref { margin: 0; }

/* module-ui-tiles-and-versions D7: the reload banner sits under the top bar like the development banner. */
.main > .shell-version-banner { align-items: center; }
.shell-version-banner > span { flex: 1; }

/* shell-staging-first-look D5: the Programs edition, a small tag at the right of its sidebar link (none in the rail). */
.nav-edition {
  flex: none; margin-left: auto; padding: 0 7px; border: 1px solid var(--nav-ink-2); border-radius: var(--radius-xs);
  font-size: 11px; line-height: 16px; color: var(--nav-ink-2);
}
.nav.collapsed .nav-edition { display: none; }

/* shell-staging-first-look D6: the drawer's Close button shows only while the sidebar is a drawer (at most 900 px wide
   and signed in, as the Menu button), at the drawer's top right beside the logo, at least 32 x 32 px. */
.shell-nav-close { display: none; }
@media (max-width: 900px) {
  #app[data-shell-signed-in] .shell-nav-close {
    display: inline-flex; justify-content: center; position: absolute; top: 8px; right: 8px;
    min-width: 32px; min-height: 32px; color: var(--nav-ink);
  }
  #app[data-shell-signed-in] .shell-nav-close:hover { background: var(--nav-2); }
}

/* module-ui-pdf-viewer D6: the PDF viewer, a large dialog.modal in the top layer. */
dialog.modal.shell-pdf-viewer { width: min(1100px, calc(100vw - 32px)); height: calc(100vh - 96px); max-width: none; }
.shell-pdf-head { align-items: center; flex-wrap: wrap; }
.shell-pdf-title { flex: 1; min-width: 0; margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-pdf-tools { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.shell-pdf-body {
  flex: 1; min-height: 0; overflow: auto; scrollbar-gutter: stable; padding: 16px; background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.shell-pdf-canvas { display: block; box-shadow: var(--shadow); }
.shell-pdf-message { margin: auto 0 0; max-width: 420px; text-align: center; color: var(--text-2); }
.shell-pdf-message + .empty-actions { display: flex; gap: 8px; margin-bottom: auto; }

/* Sign-in (openspec change shell-sign-in, design D3): one column, centred in the content area. */
.sign-in { max-width: 420px; margin: 48px auto 0; }
.sign-in-card { display: flex; flex-direction: column; gap: 16px; }
.sign-in-form .form-field:last-of-type { margin-bottom: 0; }
.sign-in-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.sign-in-field-error { margin: 4px 0 0; font-size: 12px; color: var(--red-text); }
.sign-in-qr { margin: 0; display: flex; justify-content: center; }
.sign-in-qr img { width: 200px; height: 200px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.sign-in-secret { font-family: var(--mono); font-size: 14px; letter-spacing: 0.05em; overflow-wrap: anywhere; user-select: all; }
.sign-in-codes { margin: 0; padding-left: 24px; columns: 2; column-gap: 32px; font-family: var(--mono); font-size: 14px; }
.sign-in-codes li { padding: 2px 0; }
.sign-in-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-1); }
/* Single sign-on (openspec change shell-single-sign-on, design D3). */
.sign-in-sources { display: flex; flex-direction: column; gap: 8px; }
.sign-in-source { width: 100%; justify-content: center; }
.sign-in-divider { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; font-size: 12px; color: var(--text-2); }
.sign-in-divider::before, .sign-in-divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.sign-in-reference { margin: -8px 0 0; font-family: var(--mono); overflow-wrap: anywhere; }
@media (max-width: 479.98px) { .sign-in { margin-top: 16px; } .sign-in-codes { columns: 1; } }
/* At phone width, while a sign-in screen shows, the sidebar (empty when signed out) becomes a 56 px rail keeping only
   the theme button, the QR code scales down (keeping its square) and the top bar's title ends in an ellipsis. */
@media (max-width: 479.98px) {
  #app:has(.sign-in) > .nav { width: 56px; flex-basis: 56px; }
  #app:has(.sign-in) > .nav .nav-brand { display: none; }
  .sign-in-qr img { width: 100%; max-width: 200px; height: auto; aspect-ratio: 1; }
  .main:has(.sign-in) .topbar-where { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
}

/* Person menu and two-factor settings (openspec change shell-two-factor-settings, design D3). */
.shell-person { position: relative; min-width: 0; }
.shell-person-button { max-width: 240px; }
.shell-person-button [data-shell-user] { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-person-button:disabled { opacity: 1; cursor: default; }
.shell-person-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 200px; display: flex; flex-direction: column; gap: 2px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.shell-person-menu[hidden] { display: none; }
/* The menu's z-index only counts inside the top bar's stacking context (sticky, z-index 40), which sits under the
   sidebar's (sticky, z-index 45): while the menu is open the top bar is lifted above the sidebar (still under the row
   menus at 55, the scrims at 60 and the toasts at 80), so a narrow column's menu never slides under the sidebar. */
.topbar:has(> .shell-person > .shell-person-menu:not([hidden])) { z-index: 46; }
.shell-person-item { display: block; width: 100%; padding: 8px 12px; border: 0; border-radius: var(--radius-xs); background: none; color: var(--text-1); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.shell-person-item:hover, .shell-person-item:focus-visible { background: var(--surface-2); outline: none; box-shadow: inset 0 0 0 2px var(--focus); }
.shell-person-item:disabled { color: var(--text-3); cursor: default; }
.two-factor { max-width: 560px; }
.two-factor-card { display: flex; flex-direction: column; gap: 16px; }
.two-factor-state { display: flex; align-items: center; gap: 8px; margin: 0; }
.two-factor-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sign-in-card [data-sign-in-link-account], .two-factor-card p { overflow-wrap: anywhere; }
@media (max-width: 479.98px) { .shell-person-button { max-width: 140px; } .two-factor-actions .btn { width: 100%; justify-content: center; } }
/* At phone width the signed-in column is narrow (the Menu button, the title and the name share the bar): the top
   bar's title gives way, ending in an ellipsis, so the name button stays whole, and a long word in a two-factor title
   wraps, so the page never scrolls sideways (design D12 M13). */
@media (max-width: 479.98px) {
  .shell-person { flex: none; }
  .topbar-where { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .two-factor-card .page-title { overflow-wrap: anywhere; }
}

/* App connections (openspec change shell-mcp-consent): one card, centred in the content area like sign-in; the details
   as a two-column list whose values wrap anywhere (a client id can be a long URL), the client id in the mono font. */
.connect { max-width: 560px; margin: 48px auto 0; }
.connect-card { display: flex; flex-direction: column; gap: 16px; }
.connect-card p { margin: 0; overflow-wrap: anywhere; }
.connect-details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.connect-details dt { color: var(--text-2); }
.connect-details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.connect-client-id { font-family: var(--mono); }
.connect-notes { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.connect-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 479.98px) {
  .connect { margin-top: 16px; }
  .connect-details { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .connect-details dd + dt { margin-top: 8px; }
  .connect-actions .btn { width: 100%; justify-content: center; }
  .connect-card .page-title { overflow-wrap: anywhere; }
}

/* ------------------------------------------------- Narrow screens --- */
/* shell-narrow-navigation D5: at most 900 px wide and signed in (the design language's fix-32 drawer), the sidebar
   leaves the page and the top bar's Menu button opens it over a scrim. Hidden, it is out of the tab order too:
   visibility waits for the slide out before it hides, and shows at once on the way in. Wider, or signed out, the
   Menu button and the scrim never show. */
.shell-nav-menu, .nav-scrim { display: none; }
@media (max-width: 900px) {
  #app[data-shell-signed-in] { display: block; }
  #app[data-shell-signed-in] > .nav {
    position: fixed; top: 0; left: 0; bottom: 0; height: auto;
    transform: translateX(-100%); visibility: hidden;
    transition: transform var(--fast), visibility 0s var(--fast);
  }
  #app[data-shell-signed-in].nav-open > .nav { transform: none; visibility: visible; transition: transform var(--fast); box-shadow: var(--shadow); }
  #app[data-shell-signed-in].nav-open > .nav-scrim { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 44; }
  #app[data-shell-signed-in] .shell-nav-menu { display: inline-flex; flex: none; }
}
@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
  #app[data-shell-signed-in] > .nav, #app[data-shell-signed-in].nav-open > .nav { transition: none; }
}

/* ------------------------------------------------- Organisation people --- */
/* shell-org-admin-people D12: the People list, Add a person, a person's page and the one-time link panel. */
.org-people { max-width: 1100px; }
.org-people-card { max-width: 640px; display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.org-people-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.org-people-more { margin-top: 12px; }
td.org-people-email, .org-people-card p, .org-people-details dd { overflow-wrap: anywhere; }
.org-people-table-wrap { overflow-x: auto; }
.org-people-details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.org-people-details dt { color: var(--text-2); }
.org-people-details dd { margin: 0; }
.org-people-link { display: flex; flex-direction: column; gap: 8px; }
.org-people-link input[readonly] { width: 100%; font-family: var(--mono); }
.org-people-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.org-people-field-error { margin: 4px 0 0; font-size: 12px; color: var(--red-text); }
.org-people-field-error:empty { display: none; }
.org-people-form fieldset label { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
/* PR B: the inline confirmation that replaces an action section's body (D8.3). */
.org-people-confirm {
  display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line);
  background: var(--surface-2);
}
/* Below 720 px wide each row of the People table is a card, as the Programs table's rows are; the search box takes
   the bar's width and a person's details take one column (each term above its value). */
@media (max-width: 719.98px) {
  .org-people-table-wrap { overflow-x: visible; }
  table.data.org-people-table, table.data.org-people-table tbody { display: block; width: 100%; }
  table.data.org-people-table thead { display: none; }
  table.data.org-people-table tbody tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  table.data.org-people-table tbody tr:last-child { border-bottom: 0; }
  table.data.org-people-table td, table.data.org-people-table td:first-child {
    display: block; width: auto; height: auto; max-width: none; padding: 2px 0; border: 0; white-space: normal;
    overflow: visible; text-align: left;
  }
  .org-people-filters input[type="search"] { flex: 1 1 100%; max-width: none; min-width: 0; }
  .org-people-details { grid-template-columns: 1fr; }
}
@media (max-width: 479.98px) {
  .org-people-actions .btn, .org-people-sign-in-controls .btn { width: 100%; justify-content: center; }
  .org-people-sign-in-controls select { display: block; width: 100%; }
}

/* -------------------------------------------------- Organisation teams --- */
/* shell-org-teams: the People | Teams switch, the Teams list, New team, a team's page and a person's Teams card. The
   design system draws the parts (.segmented, .toolbar, the compact table, .callout, .confirm-inline, .count-badge,
   .avatar); these rules only lay them out. */
.org-sections { margin-bottom: 12px; }
.org-teams .org-sections { margin-bottom: 0; align-self: flex-start; }
.org-teams { max-width: 1100px; }
.org-teams-toolbar input[type="search"] { flex: 0 1 260px; }
.org-teams-card { display: flex; flex-direction: column; gap: 12px; }
.org-teams-card h2 { margin: 0; font-size: 16px; }
.org-teams-form { max-width: 640px; display: flex; flex-direction: column; }
.org-teams-form textarea { width: 100%; }
.org-teams-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.org-teams-field-error { margin: 4px 0 0; font-size: 12px; color: var(--red-text); }
.org-teams-field-error:empty { display: none; }
.org-teams-more { margin: 0; }
table.org-teams-table td.org-teams-description { white-space: normal; min-width: 200px; }
table.org-teams-table td.org-teams-email { overflow-wrap: anywhere; }
table.org-teams-table td.org-teams-remove { width: 1%; text-align: right; }
.org-teams-table td.name .avatar { margin-right: 6px; vertical-align: middle; }
.org-teams-panel {
  display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface-2);
}
.org-teams-panel label[for] { font-size: 13px; font-weight: 600; }
.org-teams-panel input[type="search"] { width: 100%; max-width: 420px; }
.org-teams-choices {
  list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 280px;
  overflow-y: auto;
}
.org-teams-choices label { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; overflow-wrap: anywhere; }
.org-person-teams { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
/* Below 720 px wide each row of a Teams table is a card, as the People table's rows are. */
@media (max-width: 719.98px) {
  .org-teams-table-wrap { overflow: visible; }
  table.org-teams-table, table.org-teams-table tbody { display: block; width: 100%; }
  table.org-teams-table thead { display: none; }
  table.org-teams-table tbody tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  table.org-teams-table tbody tr:last-child { border-bottom: 0; }
  table.org-teams-table td, table.org-teams-table td.name {
    display: block; width: auto; height: auto; min-width: 0; max-width: none; padding: 2px 0; border: 0;
    white-space: normal; overflow: visible; text-align: left;
  }
  .org-teams-toolbar input[type="search"] { flex: 1 1 100%; }
  .org-teams-toolbar .toolbar-spacer { display: none; }
}
@media (max-width: 479.98px) {
  .org-teams .page-head-actions { width: 100%; margin-left: 0; }
  .org-teams .page-head-actions .btn, .org-teams-actions .btn, .org-teams-panel .btn, .org-teams .confirm-actions .btn,
  .org-teams-table td .btn { width: 100%; justify-content: center; }
  .org-teams .confirm-actions { width: 100%; flex-direction: column; }
}

/* ------------------------------------------------------ Organisation audit --- */
/* shell-org-audit D8: the Audit page's tabs, filters, logs and checks. The design system draws the parts (.segmented,
   .toolbar, the compact table, .callout, .chip); these rules only lay them out. */
.org-audit { max-width: 1280px; }
.org-audit .org-sections { margin-bottom: 0; align-self: flex-start; }
.org-audit-tabs { align-self: flex-start; }
.org-audit-panel { display: flex; flex-direction: column; gap: 12px; }
.org-audit-toolbar { flex-wrap: wrap; align-items: flex-end; }
.org-audit-date, .org-audit-program-field { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.org-audit-to { display: flex; flex-direction: column; }
.org-audit-address input { width: 220px; max-width: 100%; }
.org-audit-field-error { margin: 4px 0 0; font-size: 12px; color: var(--red-text); }
.org-audit-field-error:empty { display: none; }
.org-audit-person:empty { display: none; }
.org-audit-person .chip .x { background: none; border: 0; padding: 0 2px; font: inherit; }
.org-audit-check { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.org-audit-check[hidden] { display: none; }
.org-audit-check-result:empty { display: none; }
.org-audit-more { margin: 0; }
table.org-audit-table td.org-audit-wrap { white-space: normal; overflow-wrap: anywhere; min-width: 80px; }
table.org-audit-table td.org-audit-when { white-space: nowrap; }
/* Below 720 px wide each row of an Audit table is a card, each cell labelled; below 480 px the filters stack. */
@media (max-width: 719.98px) {
  .org-audit-table-wrap { overflow: visible; }
  table.org-audit-table, table.org-audit-table tbody { display: block; width: 100%; }
  table.org-audit-table thead { display: none; }
  table.org-audit-table tbody tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  table.org-audit-table tbody tr:last-child { border-bottom: 0; }
  table.org-audit-table td, table.org-audit-table td.org-audit-wrap, table.org-audit-table td.org-audit-when {
    display: block; width: auto; height: auto; min-width: 0; max-width: none; padding: 2px 0; border: 0;
    white-space: normal; overflow: visible; overflow-wrap: anywhere; text-align: left;
  }
  table.org-audit-table td[data-label]::before {
    content: attr(data-label); display: block; font-size: 11px; color: var(--text-3);
  }
  .org-audit-tabs { flex-wrap: wrap; }
}
@media (max-width: 479.98px) {
  .org-audit-toolbar { flex-direction: column; align-items: stretch; }
  .org-audit-toolbar > *, .org-audit-toolbar input, .org-audit-toolbar select, .org-audit-toolbar .segmented {
    width: 100%; max-width: none; flex: none;
  }
  .org-audit-toolbar .segmented { flex-wrap: wrap; }
  .org-audit-check .btn, .org-audit-more .btn { width: 100%; justify-content: center; }
}

/* ------------------------------------------------- MCP clients, connected apps --- */
/* shell-mcp-clients D8: the MCP client list, Add client and a client's page, and a person's Connected apps. The design
   system draws the parts (.page-head-compact, .toolbar, the compact table, .callout, .confirm-inline, .pill); these
   rules only lay them out. A client id or redirect URI wraps anywhere, so the page never scrolls sideways. */
.mcp-clients, .connected-apps { max-width: 1100px; }
.mcp-clients .org-sections { margin-bottom: 0; align-self: flex-start; }
.mcp-clients-card { display: flex; flex-direction: column; gap: 12px; }
.mcp-clients-card h2 { margin: 0; font-size: 16px; }
.mcp-clients-form { max-width: 640px; display: flex; flex-direction: column; }
.mcp-clients-form input[type="text"], .mcp-clients-form textarea { width: 100%; }
.mcp-clients-uris-input { font-family: var(--mono); }
.mcp-clients-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mcp-clients-field-error { margin: 4px 0 0; font-size: 12px; color: var(--red-text); }
.mcp-clients-field-error:empty { display: none; }
.mcp-clients-id, .mcp-clients-uris, .mcp-clients-details dd { overflow-wrap: anywhere; }
.mcp-clients-uris { list-style: none; margin: 4px 0 0; padding: 0; font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.mcp-clients-details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.mcp-clients-details dt { color: var(--text-2); }
.mcp-clients-details dd { margin: 0; min-width: 0; }
.mcp-clients-details .mcp-clients-uris { margin: 0; }
table.mcp-clients-table td.mcp-clients-id { white-space: normal; min-width: 200px; }
table.mcp-clients-table td.mcp-clients-action, table.connected-apps-table td.connected-apps-end { width: 1%; text-align: right; }
/* Below 720 px wide each row is a card, each cell labelled, as the People and Audit tables' rows are. */
@media (max-width: 719.98px) {
  .mcp-clients-table-wrap, .connected-apps-table-wrap { overflow: visible; }
  table.mcp-clients-table, table.mcp-clients-table tbody, table.connected-apps-table, table.connected-apps-table tbody {
    display: block; width: 100%;
  }
  table.mcp-clients-table thead, table.connected-apps-table thead { display: none; }
  table.mcp-clients-table tbody tr, table.connected-apps-table tbody tr {
    display: block; padding: 10px 12px; border-bottom: 1px solid var(--line);
  }
  table.mcp-clients-table tbody tr:last-child, table.connected-apps-table tbody tr:last-child { border-bottom: 0; }
  table.mcp-clients-table td, table.mcp-clients-table td.name, table.mcp-clients-table td.mcp-clients-id,
  table.mcp-clients-table td.mcp-clients-action, table.connected-apps-table td, table.connected-apps-table td.name,
  table.connected-apps-table td.connected-apps-end {
    display: block; width: auto; height: auto; min-width: 0; max-width: none; padding: 2px 0; border: 0;
    white-space: normal; overflow: visible; overflow-wrap: anywhere; text-align: left;
  }
  table.mcp-clients-table td[data-label]::before, table.connected-apps-table td[data-label]::before {
    content: attr(data-label); display: block; font-size: 11px; color: var(--text-3);
  }
  .mcp-clients-details { grid-template-columns: 1fr; }
}
@media (max-width: 479.98px) {
  .mcp-clients .page-head-actions { width: 100%; margin-left: 0; }
  .mcp-clients .page-head-actions .btn, .mcp-clients-actions .btn, .mcp-clients .confirm-actions .btn,
  .connected-apps .confirm-actions .btn, .mcp-clients-table td .btn, .connected-apps-table td .btn {
    width: 100%; justify-content: center;
  }
  .mcp-clients .confirm-actions, .connected-apps .confirm-actions { width: 100%; flex-direction: column; }
}

/* ------------------------------------------------------------ Help centre --- */
/* shell-help-centre D6, D10, D11: the top bar's Help button, and the Help centre's home, results and articles. The
   design system draws the parts (.btn, .page-title, .empty); these rules only lay them out. A long word wraps, so the
   page never scrolls sideways. */
.shell-help-button { flex: none; }
.help { max-width: 960px; display: flex; flex-direction: column; gap: 12px; overflow-wrap: anywhere; }
.help .help-title { margin: 0; }
.help-title:focus, .help-section h2:focus { outline: none; }
.help-title:focus-visible, .help-section h2:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.help-search { display: flex; flex-direction: column; gap: 4px; }
.help-search-label { font-size: 13px; font-weight: 600; }
.help-search-row { display: flex; gap: 8px; }
.help-search-input { flex: 1 1 auto; min-width: 0; max-width: 480px; }
.help-module { display: flex; flex-direction: column; gap: 4px; }
.help-module-name { margin: 12px 0 0; font-size: 18px; }
.help-kind { margin: 8px 0 0; font-size: 14px; color: var(--text-2); }
.help-articles, .help-results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.help-summary { margin: 2px 0 0; color: var(--text-2); font-size: 13px; }
.help-result-head { margin: 0; }
.help-result-module { color: var(--text-3); font-size: 13px; }
.help-count { margin: 0; }
.help-breadcrumb { font-size: 13px; color: var(--text-2); }
.help-lead { margin: 0; font-size: 15px; color: var(--text-2); }
.help-section { display: flex; flex-direction: column; gap: 8px; scroll-margin-top: calc(var(--topbar-h, 48px) + 12px); }
.help-section h2 { margin: 12px 0 0; font-size: 18px; scroll-margin-top: calc(var(--topbar-h, 48px) + 12px); }
.help-section p, .help-section ul, .help-section ol { margin: 0; }
.help-section ul, .help-section ol { padding-left: 20px; }
.help-figure { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.help-figure figcaption { font-size: 13px; color: var(--text-2); }
.help-picture { display: block; width: 100%; max-width: 960px; height: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.help-missing-picture { margin: 0; padding: 8px 12px; border: 1px dashed var(--line); border-radius: var(--radius-sm); color: var(--text-2); }
