/* ===========================================================================
 * admin.css — branded super-admin theme (Story 5.3 / BIMERGE-57).
 * ---------------------------------------------------------------------------
 * Consumes the shared OKLCH design tokens (tokens.css — the single :root source,
 * also inlined into the React dashboard's application.css). Light app surface,
 * dark-cyan sidebar chrome (sidebar-* tokens), cyan-primary actions, amber
 * focus ring, destructive-red errors.
 *
 * This is "classless" CSS: it targets bare HTML elements so the admin ERB views
 * need no markup classes (the exceptions are the .admin-shell / .admin-sidebar
 * nav classes in app/views/layouts/admin.html.erb). Colors are driven by
 * var(--token); the only
 * non-token colors left are the documented green success-flash exception (no
 * "success" token exists in the brand set yet — see Story 5.3 Decisions).
 *
 * tokens.css is linked alongside this file in app/views/layouts/admin.html.erb
 * and registered in app/assets/config/manifest.js.
 * =========================================================================== */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-ui, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
  line-height: 1.5;
  color: var(--foreground);
  background: var(--background);
  padding: 0;
}

/* Single page container: `main` (added to the admin layout) centers the whole
   page; top-level content (h1, p, dl, table, section, form) aligns to its left
   edge instead of each block centering itself — fixes the h1-left/table-centred
   misalignment. Forms/sections stay readably narrow; tables use the full width. */
main { width: 100%; max-width: 64rem; margin-inline: auto; }
form, section, article { max-width: 60rem; margin-block: 1rem; margin-inline: 0; }

h1, h2, h3 { font-family: var(--font-display, inherit); line-height: 1.2; margin: 1.25rem 0 0.5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; color: var(--muted-foreground); }

p { margin: 0.5rem 0; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
small { color: var(--muted-foreground); }

/* App shell + collapsible sidebar now live in the shared admin_sidebar.css
 * (.admin-shell / .admin-sidebar), used by both this layout and the Dashboard
 * board via app/views/admin/shared/_sidebar.html.erb. Only the admin layout's
 * content column stays here. */
.admin-content { flex: 1 1 auto; min-width: 0; padding: 2rem clamp(1rem, 5vw, 3rem); }

/* Forms */
form { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem 1.5rem; margin: 1rem auto; }
label { display: block; font-weight: 600; font-size: 0.9rem; margin: 0.75rem 0 0.25rem; }
input[type="text"], input[type="email"], input[type="password"],
input[type="url"], input[type="search"], select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 40%, transparent);
}

/* Buttons (incl. Rails button_to → <button>/<input type=submit>) */
button, input[type="submit"], input[type="button"], .button, a[role="button"] {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: var(--primary-foreground);
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  cursor: pointer;
}
button:hover, input[type="submit"]:hover, input[type="button"]:hover { filter: brightness(1.07); }

/* Tables (tenants / tenant-admins index) */
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin: 1rem 0; }
th, td { text-align: left; padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted-foreground); background: var(--muted); }
tbody tr:hover, table.people tbody tr[data-current] { background: color-mix(in oklab, var(--muted) 55%, transparent); }
tr:last-child td { border-bottom: 0; }
/* Right-aligned action cell: View link + Become button sit inline (the button_to
   neutraliser below keeps the button from rendering as a card). */
td.actions { white-space: nowrap; text-align: right; }
/* Flex an inner wrapper (not the <td> itself — flexing a table-cell wraps it in an
   anonymous cell and breaks centring). The td stays a table-cell so vertical-align
   centres the row; the flex row centres "View" against the padded Become button. */
td.actions .action-row { display: flex; align-items: center; justify-content: flex-end; gap: 0.9rem; }
/* The button_to <form> renders a hair low against "View"/the badges. A small
   bottom margin on the form raises the button by ~half that amount in the flex row,
   landing it on the same centreline. (Verified value.) */
td.actions .action-row form.button_to { display: flex; margin-bottom: 10px; }
td.actions a { text-underline-offset: 2px; }
table form.button_to button { margin-top: 0; padding: 0.32rem 0.8rem; font-size: 0.85rem; }

/* Flash / validation messaging (best-effort, since markup is classless) */
[role="alert"], .notice, .alert, .flash { max-width: 60rem; margin: 1rem auto; padding: 0.7rem 1rem; border-radius: var(--radius); }
/* Success flash now uses the brand --success token (added in the Engineered
   Precision refresh), so it adapts to light/dark instead of the old fixed green. */
.notice, [role="alert"] {
  background: color-mix(in oklab, var(--success) 14%, transparent);
  border: 1px solid color-mix(in oklab, var(--success) 40%, transparent);
  color: var(--success);
}
.alert, .error {
  background: color-mix(in oklab, var(--destructive) 12%, transparent);
  border: 1px solid color-mix(in oklab, var(--destructive) 40%, transparent);
  color: var(--destructive);
}
ul.errors, .field_with_errors { color: var(--destructive); }

/* Tenant detail: a single centered column (title, metadata, provisioning,
   footer all stacked) — symmetric whitespace, no lopsided short/tall columns. */
.tenant-detail { max-width: 46rem; margin-inline: auto; }
.tenant-detail > dl, .tenant-detail .provisioning { max-width: none; }
.tenant-detail h1 { margin-top: 0; }
.tenant-detail .provisioning h2 { margin-top: 1.75rem; }
.tenant-detail .detail-footer { margin-top: 1.25rem; }

/* Provisioning (Story 2.5b → 5.3 polish). The checklist + the contextual state
   action live in one card so the block matches the metadata card above it. */
.provisioning { max-width: 44rem; }
.provisioning-card {
  margin: 1rem 0;
  padding: 0.5rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.provisioning .checklist { list-style: none; padding: 0; margin: 0; }
.provisioning .step { display: flex; align-items: center; gap: 0.75rem; padding: 0.8rem 0; border-bottom: 1px solid var(--border); }
.provisioning .step:last-child { border-bottom: 0; }
/* Circular step marker: filled teal + white tick when done, hollow ring when pending. */
.provisioning .step-marker {
  display: inline-flex; align-items: center; justify-content: center;
  flex: none; width: 1.5rem; height: 1.5rem;
  font-size: 0.8rem; font-weight: 700; line-height: 1;
  border-radius: 999px;
  color: var(--muted-foreground);
  background: var(--muted);
  border: 1px solid var(--border);
}
/* Done → soft green tick. A completed step is a success state (reserved
   --success token, matching the Connected badge), but a stack of solid fills
   reads as a wall of green — so it's a light tint with a green tick instead.
   The bold solid fill is reserved for the .current step that needs to stand out. */
.provisioning .step.done .step-marker {
  color: var(--success-foreground);
  background: color-mix(in oklab, var(--success) 20%, transparent);
  border-color: color-mix(in oklab, var(--success) 42%, transparent);
}
.provisioning .step.current .step-marker { color: var(--accent-foreground); background: var(--accent); border-color: var(--accent); }
.provisioning .step.current .step-label { font-weight: 600; }
.provisioning .step-action { margin-left: auto; font-size: 0.9rem; }

/* Contextual state action (credentials form / connect / connected), sits under
   the checklist inside the card, separated by a rule. */
.provisioning-action { border-top: 1px solid var(--border); margin: 0 -1.25rem; padding: 1rem 1.25rem 0.5rem; }
.provisioning-action h3 { margin-top: 0; color: var(--foreground); }
.provisioning .connected { border-left: 3px solid var(--primary); padding-left: 0.9rem; }
.provisioning .credential-status code { background: var(--muted); padding: 0.1rem 0.35rem; border-radius: 4px; }
/* Forms/details inside the card shed the standalone-card chrome. */
.provisioning-action form { max-width: none; margin: 0.5rem 0 0; padding: 0; background: none; border: 0; }
.provisioning-action details { margin-top: 1rem; }
.provisioning-action summary { cursor: pointer; color: var(--primary); font-weight: 600; }

/* ---------------------------------------------------------------------------
 * Branded components (Story 5.3 polish). Classless where possible; framework-
 * generated classes (form.button_to) and a few admin-only hooks (.page-head,
 * .admin-stats, .badge) carry the rest. All colors come from var(--token).
 * ------------------------------------------------------------------------- */

/* Inline button_to micro-forms. Rails button_to wraps its <button> in a
   <form class="button_to">; without this the generic form-card rule above turns
   every inline action (Become, Sign out) into a bordered box. Strip the wrapper
   so only the button shows. */
form.button_to {
  display: inline-block;
  max-width: none;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
}
form.button_to button { margin-top: 0; }

/* Page header: title/subtitle on the left, a primary action on the right. */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 0.5rem; }
.page-head h1 { margin-top: 0; }
.page-head .subtitle { margin: 0.15rem 0 0; color: var(--muted-foreground); }
.page-head .button { margin-top: 0; text-decoration: none; }

/* Definition list (tenant metadata) → compact two-column card. */
dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.45rem 1.5rem;
  align-items: center;
  max-width: 44rem;
  margin: 1rem 0;
  padding: 1rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
dl dt { margin: 0; font-size: 0.76rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted-foreground); }
dl dd { margin: 0; font-weight: 500; }

/* Stat cards (dashboard summary). */
.admin-stats { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1.25rem 0; padding: 0; list-style: none; max-width: none; }
.admin-stats li { flex: 1 1 11rem; padding: 0.85rem 1.1rem; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.admin-stats .stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1; color: var(--primary); }
.admin-stats .stat-label { margin-top: 0.3rem; font-size: 0.76rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted-foreground); }

/* Status badges / pills. */
.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.45;
  border: 1px solid transparent;
  border-radius: 999px;
}
/* Canonical status palette (mirrors the Figma source of truth).
   Active is a low-emphasis positive → soft cream (brand accent, faint tint).
   Pending is the attention state → saturated solar-yellow with amber text. */
.badge.is-active {
  color: var(--accent-foreground);
  background: color-mix(in oklab, var(--accent) 22%, transparent);
  border-color: color-mix(in oklab, var(--accent) 40%, transparent);
}
.badge.is-pending {
  color: var(--signal-foreground);
  background: color-mix(in oklab, var(--accent) 58%, transparent);
  border-color: color-mix(in oklab, var(--accent) 78%, transparent);
}
.badge.is-invited {
  color: var(--muted-foreground);
  background: var(--muted);
  border-color: var(--border);
}
/* Connected → green. A live Autodesk link is a true success signal, so it
   carries the reserved --success token rather than the brand accent. */
.badge.is-yes {
  color: var(--success-foreground);
  background: color-mix(in oklab, var(--success) 20%, transparent);
  border-color: color-mix(in oklab, var(--success) 42%, transparent);
}
.badge.is-no, .badge.is-muted {
  color: var(--muted-foreground);
  background: var(--muted);
  border-color: var(--border);
}
/* Autodesk connection health (spec-autodesk-connection-health). Lost → red:
   the connection died and nobody reconnected. Warning → the amber "pending"
   treatment: the token is kept but the last keep-alive failed. */
.badge.is-lost {
  color: var(--destructive);
  background: color-mix(in oklab, var(--destructive) 12%, transparent);
  border-color: color-mix(in oklab, var(--destructive) 35%, transparent);
}
.badge.is-warning {
  color: var(--signal-foreground);
  background: color-mix(in oklab, var(--accent) 58%, transparent);
  border-color: color-mix(in oklab, var(--accent) 78%, transparent);
}
.stat-value.is-lost { color: var(--destructive); }
.connection-health { margin: 0.5rem 0 1rem; }
.connection-health .health-line { margin: 0 0 0.5rem; }
.badge.is-suspended {
  color: var(--destructive);
  background: color-mix(in oklab, var(--destructive) 12%, transparent);
  border-color: color-mix(in oklab, var(--destructive) 35%, transparent);
}

/* Provisioning check marks reused inline in the dashboard table. */
.check { font-weight: 700; color: var(--muted-foreground); }
.check.done { color: var(--success); }

/* ---------------------------------------------------------------------------
 * People console (console grid slice 1): the person page (profile, the role ×
 * project grid, "Can use", the sticky save bar, the danger zone) and the
 * people table — shared by /admin's client-user screens and the client
 * console (both layouts load this file). Every colour is a token.
 * ------------------------------------------------------------------------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted-foreground); }

/* A page's flash sits on the content column, not a narrower centred box. */
main > .notice, main > .alert { max-width: none; margin: 0 0 1rem; }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; font-size: 0.85rem; color: var(--muted-foreground); }
.crumbs a { color: var(--muted-foreground); text-decoration: none; }
.crumbs a:hover { color: var(--foreground); text-decoration: underline; }
.crumbs-sep { opacity: 0.5; }

/* Person header: avatar, name + status, email · job title · joined, quiet actions. */
.person-head { display: flex; align-items: center; gap: 1rem; margin: 1rem 0 1.25rem; }
.person-head h1 { margin: 0; font-size: 1.5rem; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.person-head .badge { font-family: var(--font-ui, inherit); }
.person-meta { margin: 0.15rem 0 0; color: var(--muted-foreground); font-size: 0.92rem; }
.person-meta-dot { opacity: 0.5; margin: 0 0.4rem; }
.person-head-actions { margin-left: auto; display: flex; align-items: center; gap: 1rem; font-size: 0.9rem; white-space: nowrap; }
.person-avatar {
  flex: none; width: 48px; height: 48px; border-radius: 999px; display: grid; place-items: center;
  font-family: var(--font-display, inherit); font-weight: 600; font-size: 1.05rem;
  color: var(--secondary-foreground); background: var(--secondary); border: 1px solid var(--border);
}
.person-avatar.is-small { width: 32px; height: 32px; font-size: 0.78rem; }
.person-avatar.is-empty { color: var(--muted-foreground); background: transparent; border-style: dashed; }

/* A quiet text button (button_to's <button>): Resend invite. */
button.link-button {
  margin: 0; padding: 0; background: none; border: 0; color: var(--primary);
  font-weight: 600; font-size: 0.9rem; text-decoration: underline; text-underline-offset: 2px;
}
button.link-button:hover { filter: none; }

/* Cards. */
.console-card { max-width: none; margin: 0 0 1rem; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.console-card-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.25rem 0.75rem; padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--border); }
.console-card-head h2 { margin: 0; font-size: 1rem; }
.console-card-head .hint { margin: 0; font-size: 0.85rem; color: var(--muted-foreground); }
.console-card-body { padding: 1rem 1.25rem; }
.console-card-body.is-tight { padding-block: 0.35rem; }
.console-card.is-bimerge { border-style: dashed; }
.console-card.is-danger { border-color: color-mix(in oklab, var(--destructive) 30%, var(--border)); }

/* The page's one form: the cards are the chrome, not the generic form card. */
form.person-access-form { max-width: none; margin: 0; padding: 0; background: none; border: 0; border-radius: 0; }

/* Profile. */
.console-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.console-fields label { margin-top: 0; font-size: 0.82rem; }
.console-fields .opt { font-weight: 400; color: var(--muted-foreground); }
.switch-row {
  display: flex; align-items: center; gap: 0.85rem; margin: 1rem 0 0; padding: 0.8rem 1rem;
  font-weight: 400; font-size: 0.92rem; cursor: pointer;
  background: var(--elevated); border: 1px solid var(--border); border-radius: var(--radius);
}
.switch-row strong { font-weight: 600; }
.switch-row .sub { color: var(--muted-foreground); }
.switch-row.is-locked { cursor: default; }
.switch-lock { display: block; margin-top: 0.2rem; font-size: 0.84rem; color: var(--muted-foreground); }
input.toggle-switch {
  appearance: none; flex: none; position: relative; width: 36px; height: 20px; margin: 0;
  border-radius: 999px; background: var(--input); cursor: pointer; transition: background 0.15s ease;
}
input.toggle-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 999px;
  background: var(--card); box-shadow: 0 1px 2px color-mix(in oklab, var(--foreground) 25%, transparent);
  transition: transform 0.15s ease;
}
input.toggle-switch:checked { background: var(--primary); }
input.toggle-switch:checked::after { transform: translateX(16px); }
input.toggle-switch:disabled { opacity: 0.55; cursor: default; }
input.toggle-switch:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.console-card input[type="checkbox"]:not(.toggle-switch) { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; cursor: pointer; flex: none; }
.console-card input[type="checkbox"]:disabled { cursor: default; }

.role-tag {
  display: inline-block; margin-left: 0.35rem; padding: 0.05rem 0.4rem; border-radius: 4px; vertical-align: 1px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--muted-foreground); background: var(--muted); border: 1px solid var(--border);
}
.role-tag.is-bimerge { color: var(--accent-foreground); background: color-mix(in oklab, var(--accent) 22%, transparent); border-color: color-mix(in oklab, var(--accent) 45%, transparent); }

/* The role × project grid. */
table.access-grid { margin: 0; border: 0; border-radius: 0; table-layout: fixed; }
table.access-grid th, table.access-grid td { padding: 0.5rem 0.75rem; }
table.access-grid col.access-grid-rolecol { width: 15.5rem; }
table.access-grid thead th { vertical-align: bottom; background: var(--muted); }
table.access-grid thead th.col { text-align: center; text-transform: none; letter-spacing: 0; font-size: 0.8rem; font-weight: 600; line-height: 1.25; color: var(--foreground); }
table.access-grid thead th.col.is-all { color: var(--primary); }
table.access-grid thead th .n { display: block; margin-top: 0.15rem; font-size: 0.72rem; font-weight: 400; color: var(--muted-foreground); }
table.access-grid td.role { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.access-grid tr.has td.role { font-weight: 600; }
table.access-grid td.c { text-align: center; }
table.access-grid td.c label { display: inline-flex; margin: 0; padding: 0.3rem; border-radius: 6px; cursor: pointer; }
table.access-grid td.c label:hover { background: var(--muted); }
table.access-grid td.is-all { background: color-mix(in oklab, var(--secondary) 70%, transparent); border-right: 1px solid var(--border); }
table.access-grid thead th.is-all { background: color-mix(in oklab, var(--muted) 100%, var(--border) 25%); border-right: 1px solid var(--border); }
table.access-grid td.c.is-covered input { opacity: 0.45; }
table.access-grid td.c.is-covered label { cursor: default; }
table.access-grid tbody tr:hover td { background: color-mix(in oklab, var(--muted) 55%, transparent); }
table.access-grid tbody tr:hover td.is-all { background: color-mix(in oklab, var(--muted) 85%, transparent); }
.access-grid-wrap { overflow-x: auto; }
.access-legend { display: flex; align-items: center; gap: 1.25rem; padding: 0.6rem 1.25rem; font-size: 0.8rem; color: var(--muted-foreground); border-top: 1px solid var(--border); }
.access-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.console-card .access-legend input.is-sample { pointer-events: none; opacity: 1; }
.console-card .access-legend input.is-covered { opacity: 0.45; }

/* BIMerge only: the Operator tools box. */
label.operator-row { display: flex; align-items: flex-start; gap: 0.75rem; margin: 0; font-weight: 400; font-size: 0.92rem; cursor: pointer; }
label.operator-row input { margin-top: 3px !important; }
.operator-row .t { font-weight: 600; }
.operator-row .d { display: block; margin-top: 0.1rem; font-size: 0.86rem; color: var(--muted-foreground); }

/* Can use. */
.can-use-row { display: grid; grid-template-columns: minmax(10rem, 21rem) 1fr; gap: 1rem; align-items: center; padding: 0.55rem 0; border-bottom: 1px solid var(--border); }
.can-use-row:last-child { border-bottom: 0; }
.can-use-project { font-weight: 600; font-size: 0.9rem; }
.feature-chips, .role-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.feature-chip { padding: 0.12rem 0.55rem; font-size: 0.8rem; white-space: nowrap; color: var(--foreground); background: var(--muted); border: 1px solid var(--border); border-radius: 999px; }
.feature-chip.is-none, .role-chip.is-none { color: var(--muted-foreground); background: transparent; border-style: dashed; }

/* Danger zone. */
.danger-row { display: flex; align-items: center; gap: 1rem; }
.danger-row .t { font-weight: 600; font-size: 0.92rem; }
.danger-row .d { font-size: 0.86rem; color: var(--muted-foreground); }
.danger-row form.button_to { margin-left: auto; }
button.danger-button { margin: 0; white-space: nowrap; color: var(--destructive); background: transparent; border-color: color-mix(in oklab, var(--destructive) 45%, transparent); }
button.danger-button:hover { filter: none; background: color-mix(in oklab, var(--destructive) 8%, transparent); }
button.danger-button.is-quiet { color: var(--primary); border-color: var(--border); }
button.danger-button:disabled { opacity: 0.5; cursor: default; background: transparent; }

/* The sticky save bar. */
.save-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 1rem;
  margin: 1.25rem 0 0; padding: 0.75rem 1.25rem;
  background: color-mix(in oklab, var(--card) 92%, transparent); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 -4px 16px color-mix(in oklab, var(--foreground) 6%, transparent);
}
.save-state { font-size: 0.88rem; color: var(--muted-foreground); }
.save-state.is-dirty { color: var(--foreground); }
.save-state.is-dirty::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 0.5rem; vertical-align: 1px; border-radius: 999px; background: var(--accent); }
.save-spacer { flex: 1; }
.save-bar a { font-weight: 600; text-decoration: none; }
.save-bar button { margin: 0; }
.save-bar button:disabled { opacity: 0.5; cursor: default; filter: none; }

/* The invite page (slice 2): the Person card's email row and the
 * initial-password fallback; the page head without an action. */
.console-field-email { margin-bottom: 1rem; }
.console-field-email label { margin-top: 0; font-size: 0.82rem; }
.console-field-email input { margin-bottom: 0; }
.console-card .req { color: var(--destructive); }
.list-head.is-page { margin-top: 0.9rem; }
details.initial-password { margin: 1rem 0 0; font-size: 0.9rem; }
details.initial-password summary { cursor: pointer; font-weight: 600; color: var(--primary); }
details.initial-password .hint { margin: 0.5rem 0 0.75rem; font-size: 0.84rem; color: var(--muted-foreground); }

/* The people table. */
.list-head { display: flex; align-items: flex-end; gap: 1rem; margin: 1rem 0 1.25rem; }
.list-head h1 { margin: 0; font-size: 1.5rem; }
.list-head .sub { margin: 0.2rem 0 0; font-size: 0.92rem; color: var(--muted-foreground); }
.list-head .act { margin-left: auto; }
.list-head .act .button { margin: 0; display: inline-flex; align-items: center; gap: 0.45rem; text-decoration: none; white-space: nowrap; }
.list-head .act svg { width: 16px; height: 16px; }
.list-toolbar { display: flex; align-items: center; gap: 1rem; padding: 0.7rem 1.25rem; border-bottom: 1px solid var(--border); }
.list-search { position: relative; width: 18rem; margin: 0; }
.list-search svg { position: absolute; left: 0.6rem; top: 50%; translate: 0 -50%; width: 15px; height: 15px; color: var(--muted-foreground); }
.list-search input { padding: 0.4rem 0.6rem 0.4rem 2rem; font-size: 0.88rem; font-weight: 400; }
label.list-check { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-weight: 400; font-size: 0.92rem; cursor: pointer; }
label.list-check[hidden] { display: none; }
.list-counts { margin: 0 0 0 auto; font-size: 0.85rem; color: var(--muted-foreground); }
.list-counts b { color: var(--foreground); font-weight: 600; }
.list-counts .dot { opacity: 0.5; margin: 0 0.4rem; }
.list-foot { margin: 0; padding: 0.6rem 1.25rem; font-size: 0.8rem; color: var(--muted-foreground); border-top: 1px solid var(--border); }
table.people { margin: 0; border: 0; border-radius: 0; table-layout: fixed; }
table.people col.c-person { width: 22rem; }
table.people col.c-status { width: 7rem; }
table.people col.c-act { width: 9.5rem; }
table.people th { padding: 0.55rem 1rem; }
table.people td { padding: 0.7rem 1rem; }
table.people th:first-child, table.people td:first-child { padding-left: 1.25rem; }
table.people th:last-child, table.people td:last-child { padding-right: 1.25rem; }
table.people tbody tr[data-href] { cursor: pointer; }
.person-cell { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.person-cell-text { min-width: 0; }
.person-name { display: flex; align-items: center; gap: 0.45rem; max-width: 100%; font-weight: 600; font-size: 0.93rem; color: var(--foreground); text-decoration: none; white-space: nowrap; }
.person-name:hover { text-decoration: underline; }
.person-name.is-noname { font-weight: 500; }
.person-name-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.person-sub { font-size: 0.82rem; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-sub .dot { opacity: 0.5; margin: 0 0.35rem; }
.client-admin-badge, .you-badge { flex: none; padding: 0.04rem 0.42rem; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; border-radius: 999px; }
.client-admin-badge { color: var(--primary); background: color-mix(in oklab, var(--primary) 8%, transparent); border: 1px solid color-mix(in oklab, var(--primary) 22%, transparent); }
.you-badge { color: var(--muted-foreground); background: var(--muted); border: 1px solid var(--border); }
.role-chip { padding: 0.1rem 0.55rem; font-size: 0.8rem; white-space: nowrap; background: var(--muted); border: 1px solid var(--border); border-radius: 999px; }
.role-chip .w { color: var(--muted-foreground); }
.role-chip .w::before { content: "\00b7"; margin: 0 0.3rem; opacity: 0.7; }
.role-chip.is-operator { font-size: 0.74rem; color: var(--muted-foreground); background: transparent; border-style: dashed; }
td.row-actions { text-align: right; white-space: nowrap; }
td.row-actions .inner { display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; }
td.row-actions button.link-button { padding: 0; font-size: 0.84rem; text-decoration: none; }
td.row-actions button.link-button:hover { text-decoration: underline; }
td.row-actions .go { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; color: var(--muted-foreground); }
td.row-actions .go svg { width: 16px; height: 16px; }
tbody tr:hover td.row-actions .go { color: var(--foreground); background: var(--muted); }

@media (max-width: 720px) {
  .console-fields { grid-template-columns: 1fr; }
  .person-head { flex-wrap: wrap; }
  .person-head-actions { margin-left: 0; }
  .can-use-row { grid-template-columns: 1fr; gap: 0.35rem; }
  .list-toolbar { flex-wrap: wrap; }
  .list-search { width: 100%; }
  .danger-row { flex-wrap: wrap; }
}

/* ---- Responsive: narrow screens ----------------------------------------
   Pairs with the icon-rail breakpoint in admin_sidebar.css. The page chrome
   (.page-head, .admin-stats) already reflows via flex-wrap; this handles the
   data tables and tightens the content gutters. */
@media (max-width: 720px) {
  .admin-content { padding: 1.25rem 1rem; }
  /* Wide data tables (dashboard 7-col, tenants) scroll horizontally rather than
     squeezing columns to unreadable widths or overflowing the viewport. */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  /* Keep single-column layouts (detail, provisioning) full-width on small screens. */
  .tenant-detail, .provisioning, .provisioning-card { max-width: none; }
}

/* ---------------------------------------------------------------------------
 * Console grid slice 3 — Projects: the project × module grid, shared by the
 * super-admin's editable grid and the client console's read-only one
 * (spec-licensing-to-operator moved these rules here from client_admin.css),
 * over the access-grid, cards, chips and save bar above. Every colour is a token.
 * ------------------------------------------------------------------------- */
.list-head.is-page .sub { max-width: 46rem; }
table.access-grid col.modules-grid-projcol { width: 23rem; }
table.access-grid.is-modules thead th:first-child { text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.72rem; color: var(--muted-foreground); }
table.access-grid.is-modules thead th.col .ic { display: block; margin: 0 auto 0.3rem; width: 18px; height: 18px; color: var(--muted-foreground); }
table.access-grid.is-modules tbody th.proj {
  padding-block: 0.7rem; text-align: left; font-size: inherit; font-weight: 400; letter-spacing: 0; text-transform: none;
  color: var(--foreground); background: transparent;
}
table.access-grid.is-modules .proj .links .is-off { color: var(--muted-foreground); opacity: 0.8; }
table.access-grid.is-modules .proj .pn { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 0.95rem; }
table.access-grid.is-modules .proj .pn .badge { font-size: 0.7rem; }
table.access-grid.is-modules .proj .links { display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; margin-top: 0.25rem; font-size: 0.82rem; }
table.access-grid.is-modules .proj .links a { color: var(--muted-foreground); text-decoration: none; }
table.access-grid.is-modules .proj .links a:hover { color: var(--primary); text-decoration: underline; }
table.access-grid.is-modules .proj .links b { color: var(--foreground); font-weight: 600; }
table.access-grid.is-modules td.c.is-auto label { box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--accent) 75%, transparent); }
table.access-grid.is-modules td.c label:has(input:disabled) { cursor: not-allowed; }
.modules-rule svg { width: 14px; height: 14px; flex: none; }
.modules-later { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin: 0.9rem 0 0; font-size: 0.82rem; color: var(--muted-foreground); }
.modules-later .role-chip { font-size: 0.74rem; }
@media (max-width: 720px) {
  /* Phone width: every module column keeps a readable width and the grid
   * scrolls sideways inside its card (.access-grid-wrap), never the page. */
  table.access-grid.is-modules { display: table; white-space: normal; overflow: visible; width: max-content; min-width: 100%; }
  table.access-grid col.modules-grid-projcol { width: 13rem; }
  table.access-grid.is-modules col:not(.modules-grid-projcol) { width: 6.5rem; }
}
table.access-grid.is-modules tbody tr:hover th.proj { background: color-mix(in oklab, var(--muted) 55%, transparent); }
table.access-grid.is-modules tbody tr:last-child th.proj { border-bottom: 0; }

/* The inline confirm: "Remove this logo? [Remove] [Keep]" (console_guard.ts).
   Moved here from client_admin.css unchanged so /admin's destructive buttons
   share it (spec-admin-ux-back-paths); placements stay with their pages. */
.ps-confirm {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.4rem 0.6rem; font-size: 0.84rem;
  color: var(--foreground); background: color-mix(in oklab, var(--destructive) 7%, var(--card));
  border: 1px solid color-mix(in oklab, var(--destructive) 35%, var(--border)); border-radius: 8px;
}
.ps-confirm[hidden] { display: none; }
.ps-confirm button { margin: 0; padding: 0.3rem 0.75rem; font-size: 0.84rem; }
.ps-confirm button.ps-confirm-yes { color: var(--destructive-foreground, #fff); background: var(--destructive); border-color: var(--destructive); }
.ps-confirm button.ps-confirm-no { color: var(--foreground); background: var(--card); border-color: var(--border); }

/* spec-company-connection-account-switch — the refused "Change account" report
   (Console → Integrations and the admin tenant page). */
.reach-report { margin: 1rem 0; padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--foreground); }
.reach-report-title { margin: 0 0 0.5rem; font-size: 1rem; font-weight: 600; }
.reach-report p { margin: 0.35rem 0; font-size: 0.9rem; overflow-wrap: anywhere; }
.reach-report-meta, .reach-report-totals { color: var(--muted-foreground); }
.reach-report h4 { margin: 0.9rem 0 0.35rem; font-size: 0.9rem; font-weight: 600; }
.reach-report-lines { margin: 0; padding-left: 1.1rem; }
.reach-report-lines li { margin: 0 0 0.6rem; font-size: 0.88rem; }
.reach-report-lines span { display: block; overflow-wrap: anywhere; }
.reach-what { font-weight: 600; }
.reach-where, .reach-fix { color: var(--muted-foreground); }
.reach-report-steps { margin: 0.2rem 0 0.5rem; padding-left: 1.3rem; font-size: 0.88rem; }
.reach-report-copy summary { cursor: pointer; font-size: 0.88rem; }
.reach-report-copy textarea { display: block; width: 100%; margin-top: 0.4rem; font: 0.8rem/1.4 ui-monospace, monospace; }
