/* Governance dashboard styles (Phase 3a-5, story #1104). Dependency-free. */
:root {
  --bg: #0f1420;
  --surface: #171d2b;
  --surface-2: #1f2738;
  --border: #2b3448;
  --text: #e6eaf2;
  --muted: #8a94a8;
  --accent: #5b8cff;
  --ok: #33c481;
  --warn: #e6a417;
  --err: #e5484d;
  --current: #33c481;
  --stale: #e6a417;
  --dark: #8a94a8;
  --walled: #7a5cff;
  /* Lighter than --err: as chip text on its own tint it keeps a 4.5:1 contrast on both surfaces. */
  --invalid: #ff969b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 0.875rem/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-bar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.app-bar-actions { margin-left: auto; min-width: 0; display: flex; align-items: center; gap: 8px; }
/* Who is signed in, "name · role" (story 2055), before the text-size toggle. On a phone it gives way to the rest of the
   bar and ends in an ellipsis, rather than widening the page. position: it contains its screen-reader-only "Signed in as". */
.session-identity {
  position: relative; color: var(--muted); font-size: 0.8125rem; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.logo { color: var(--accent); font-size: 1.375rem; }
.title { font-weight: 600; font-size: 0.9375rem; }
.subtitle { color: var(--muted); font-size: 0.75rem; }

/* Hamburger — hidden on desktop, revealed at the drawer breakpoint. */
.nav-toggle {
  display: none; background: none; border: none; color: var(--text);
  font-size: 1.25rem; line-height: 1; cursor: pointer; padding: 4px 8px;
}

/* Sidebar + content grid. The sidebar fills the column height so the profile card can pin
   to the bottom; main can shrink (min-width:0) so wide tables scroll inside it rather than
   the page. */
.layout { flex: 1 1 auto; display: grid; grid-template-columns: 240px 1fr; min-height: 0; }
.sidebar {
  display: flex; flex-direction: column; gap: 20px;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 12px; overflow-y: auto;
}
.nav { display: flex; flex-direction: column; gap: 20px; }
.nav-section { display: flex; flex-direction: column; gap: 4px; }
.nav-heading {
  margin: 0 0 4px; padding: 0 8px; color: var(--muted);
  font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
}
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: block; padding: 8px 10px; border-radius: 7px; text-decoration: none;
  color: var(--muted); font-size: 0.875rem; cursor: pointer;
}
a.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--text); background: var(--surface-2); font-weight: 600; }
.nav-link[aria-current="page"] { box-shadow: inset 3px 0 0 var(--accent); }
.nav-link.stub { color: var(--muted); opacity: 0.55; cursor: not-allowed; }
.nav-link.stub::after { content: " · coming soon"; font-size: 0.6875rem; }
.nav-refresh { margin-top: 8px; align-self: flex-start; }
/* The navigation while it is switched off (story 2055, app.mjs): on every page load while GET /api/me is out, and after
   the answer as well for a person whose access an Admin has switched off. */
.nav[inert] { opacity: 0.5; }

.profile-card {
  margin-top: auto; display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px; cursor: pointer; text-align: left;
}
.profile-card:hover { border-color: var(--accent); }
.profile-avatar { color: var(--accent); font-size: 1.25rem; line-height: 1; }
.profile-meta { display: flex; flex-direction: column; min-width: 0; }
.profile-name { font-weight: 600; font-size: 0.8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-sub { color: var(--muted); font-size: 0.6875rem; }

main { padding: 20px; min-width: 0; overflow-x: auto; }
.panel { animation: fade 0.15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.empty, .note { color: var(--muted); }
.note { font-size: 0.75rem; margin-top: 12px; }

.controls { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.filter { color: var(--muted); font-size: 0.8125rem; }
.filter select {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 8px; margin-left: 4px;
}
.count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

table.grid { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 8px; overflow: hidden; }
table.grid th, table.grid td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
table.grid th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
table.grid tbody tr:hover { background: var(--surface-2); }

.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
/* A state chip is the state's colour as text, on a tint of that colour. For current, dark and
   walled the text is the colour lightened with white: unlightened, it is below 4.5:1 against its
   own tint on one surface or both (#1353). Only the text is lightened; the tint is unchanged.
   tests/smoke/dashboard-state-chip-contrast.spec.mjs holds every state chip at 4.5:1. */
.state-current { background: color-mix(in srgb, var(--current) 22%, transparent); color: color-mix(in srgb, var(--current), white 7%); }
.state-stale { background: color-mix(in srgb, var(--stale) 22%, transparent); color: var(--stale); }
.state-dark { background: color-mix(in srgb, var(--dark) 25%, transparent); color: color-mix(in srgb, var(--dark), white 27%); }
.state-walled { background: color-mix(in srgb, var(--walled) 22%, transparent); color: color-mix(in srgb, var(--walled), white 34%); }
/* A stored pin or channel that cannot be read (#1340): the state of an install, or of an
   engagement none of whose installs can be read, and the count beside an engagement's installs. */
.state-invalid, .chip.invalid-count { background: color-mix(in srgb, var(--invalid) 22%, transparent); color: var(--invalid); }
.chip.invalid-count { margin-left: 6px; }
/* position: the cell contains its screen-reader-only text, so that scrolls with the table
   inside <main> instead of widening the page when the column is off-screen on a phone. */
.fleet-installs { white-space: nowrap; position: relative; }
/* Text for a screen reader only: in the accessibility tree, not on screen. */
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.chip.recommended { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.action-promote { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }
.action-rollback { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.action-release { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }

.ladder { display: flex; gap: 16px; flex-wrap: wrap; }
.ring-card {
  flex: 1 1 220px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.ring-head { display: flex; align-items: center; justify-content: space-between; }
/* The ring's name is its card's heading (h3), drawn as the plain label it was: no margin, the card's size, semibold. */
.ring-name { margin: 0; font-size: inherit; font-weight: 600; text-transform: capitalize; }
.ring-version { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.soak { font-size: 0.75rem; padding: 3px 8px; border-radius: 6px; align-self: flex-start; }
.soak.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.soak.gated { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.soak.terminal { background: var(--surface-2); color: var(--muted); }
.ring-actions { display: flex; gap: 8px; margin-top: auto; }

.canary-health { margin-top: 16px; padding: 10px 14px; border-radius: 8px; font-size: 0.8125rem; }
.canary-health.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.canary-health.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); }

.btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 7px 12px; cursor: pointer; font-size: 0.8125rem;
}
.btn:hover { border-color: var(--accent); }
.btn.primary, .btn.promote { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.rollback { color: var(--warn); }
.btn.primary:hover, .btn.promote:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:disabled:hover { border-color: var(--border); }

/* Whole-app text-size toggle (#1139) — A−/A/A+ group in the app-bar actions slot. */
.text-size-controls { display: inline-flex; align-items: center; gap: 4px; }
.btn.text-size { padding: 5px 8px; min-width: 30px; text-align: center; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; width: min(440px, 92vw); }
.modal h3 { margin: 0 0 6px; text-transform: capitalize; }
.modal p { color: var(--muted); font-size: 0.8125rem; margin: 0 0 12px; }
.modal textarea {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px; resize: vertical; font: inherit;
}
.modal textarea.invalid { border-color: var(--err); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* Profile modal (#1138) — reuses .modal-overlay / .modal; adds a close control, an
   identity line, and an inline notice (My Account stub / local-dev logout). */
.modal { position: relative; }
.modal-close {
  position: absolute; top: 10px; right: 12px; background: none; border: none;
  color: var(--muted); font-size: 1.375rem; line-height: 1; cursor: pointer; padding: 2px 6px;
}
.modal-close:hover { color: var(--text); }
.modal-identity { color: var(--text); font-weight: 600; font-size: 0.9375rem; margin: 0 0 10px; }
.modal-notice {
  margin: 4px 0 0; padding: 8px 10px; border-radius: 8px; font-size: 0.8125rem;
  background: var(--surface-2); color: var(--muted);
}
.modal-actions .btn { min-width: 96px; }

/* Sidebar collapses to an off-canvas drawer on phones; the hamburger toggles it and no
   horizontal page scroll appears (design D3, ≤640px). */
@media (max-width: 640px) {
  .nav-toggle { display: inline-flex; }
  .subtitle { display: none; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: 260px; max-width: 80vw; z-index: 45;
    transform: translateX(-100%); transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.5); }
  body { overflow-x: hidden; }
}

/* Engagement-detail overlay (#1140) */
.fleet-row { cursor: pointer; }
.fleet-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.detail-overlay { align-items: flex-start; padding: 4vh 16px; overflow-y: auto; }
.detail-modal { width: min(880px, 96vw); max-height: 92vh; overflow-y: auto; padding: 20px 24px; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.detail-head h3 { margin: 0; text-transform: none; }
.detail-close { padding: 4px 10px; line-height: 1; }
.detail-section { margin-top: 16px; }
.detail-section-title {
  margin: 0 0 8px; color: var(--muted); font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.detail-grid { margin: 0; display: grid; grid-template-columns: minmax(140px, max-content) 1fr; gap: 6px 16px; }
.detail-row { display: contents; }
.detail-label { color: var(--muted); font-size: 0.8125rem; }
.detail-value { color: var(--text); font-size: 0.8125rem; word-break: break-word; }
.chip.behind-yes { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.chip.behind-no { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }

/* Installs of an engagement (#1206) — a compact table inside the detail overlay. An install is
   shown by a short form of its random id, set in monospace so the hex is easy to compare; the
   legacy row has no id, so its label is styled as a note instead. On a narrow screen the table
   scrolls sideways inside its wrapper rather than widening the dialog. */
.installs-scroll { overflow-x: auto; }
table.grid.installs { background: var(--surface-2); font-size: 0.8125rem; }
table.grid.installs th, table.grid.installs td { padding: 6px 12px; white-space: nowrap; }
table.grid.installs tbody tr:last-child td { border-bottom: none; }
.install-id { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; }
.install-legacy { color: var(--muted); font-style: italic; }
.detail-section .note { margin: 8px 0 0; font-size: 0.75rem; }

/* Terminology tooltips (#1141) — an info affordance beside the six fleet terms on the Fleet
   table headers and in the detail overlay. The button is a real focusable control; the
   definition bubble is position:fixed so it escapes the table's overflow clip / dialog
   scroll box. */
.term-tip { display: inline-flex; align-items: center; gap: 4px; }
.term-info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; padding: 0; flex: 0 0 auto;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
  font-size: 0.625rem; font-weight: 700; font-style: normal; line-height: 1;
  text-transform: none; cursor: pointer;
}
.term-info:hover { color: var(--text); border-color: var(--accent); }
.term-info:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.term-desc {
  position: fixed; z-index: 70; width: max-content; max-width: 280px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: 0.75rem; font-weight: 400; line-height: 1.45;
  text-transform: none; letter-spacing: normal;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
}
.term-desc[hidden] { display: none; }

.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { padding: 10px 16px; border-radius: 8px; font-size: 0.8125rem; box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.toast.ok { background: var(--ok); color: #04120b; }
.toast.warn { background: var(--warn); color: #1a1200; }
.toast.err { background: var(--err); color: #fff; }

/* Delivery view (story 1718): tables of numbers, right-aligned in tabular figures. Each table scrolls sideways in its
   own box on a narrow screen, so the page itself never does. Plain text throughout: no new chip, so no new colour
   pair for tests/smoke/dashboard-state-chip-contrast.spec.mjs to hold. */
.delivery-section { margin-top: 20px; }
.delivery-title {
  margin: 0 0 8px; color: var(--muted); font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.delivery-meta { color: var(--muted); font-size: 0.8125rem; margin: 0 0 8px; }
.table-scroll { overflow-x: auto; }
table.grid th.num, table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.grid tfoot td { font-weight: 600; border-bottom: none; }
/* A Delivery table's row headers (the first column) read as the body cells beside them, not as column headings. */
table.delivery-grid tbody th, table.delivery-grid tfoot th {
  color: inherit; font-size: inherit; font-weight: normal; text-transform: none; letter-spacing: normal;
}
table.delivery-grid tfoot th { font-weight: 600; border-bottom: none; }

/* Roles view (story 2055): what each role can do, read-only. The caption sits above the table, and a permission's
   row header is its label with the id the API checks under it. The role columns centre their Yes. */
table.roles-grid caption { caption-side: top; text-align: left; color: var(--muted); padding: 0 0 8px; }
table.roles-grid th.role, table.roles-grid td.role { text-align: center; }
table.roles-grid tbody th { color: inherit; font-size: inherit; font-weight: normal; text-transform: none; letter-spacing: normal; }
table.roles-grid code { display: block; color: var(--muted); font-size: 0.75rem; }
.btn.link { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; }

/* Users view (story 2056): everyone who has signed in, for an Admin. A row's first cell is the person's name, a row
   header that reads as the cells beside it. The role cell contains its screen-reader-only text (position), so that scrolls
   with the table instead of widening the page on a phone. The chips take colour pairs the state chips are held to at
   4.5:1 on both surfaces, a row's and a row's under the pointer (tests/smoke/dashboard-state-chip-contrast.spec.mjs):
   Enabled current's, Disabled invalid's, fallback dark's. They are not named state-*, which would have that spec look for
   them in the Fleet view. A user's audit record takes the pair of its outcome. */
table.users-grid tbody th { color: inherit; font-size: inherit; font-weight: normal; text-transform: none; letter-spacing: normal; }
table.users-grid td.user-role { position: relative; white-space: nowrap; }
.chip.user-enabled, .action-user-enable { background: color-mix(in srgb, var(--current) 22%, transparent); color: color-mix(in srgb, var(--current), white 7%); }
.chip.user-disabled, .action-user-disable { background: color-mix(in srgb, var(--invalid) 22%, transparent); color: var(--invalid); }
.chip.fallback { background: color-mix(in srgb, var(--dark) 25%, transparent); color: color-mix(in srgb, var(--dark), white 27%); }
/* The Disable or Re-enable dialog. Its title names a person, as written; its reason has a label; and a blank reason is
   said in invalid's colour, which keeps 4.5:1 on the dialog where --err does not. */
.user-access-modal h3 { text-transform: none; }
.modal-label { display: block; color: var(--muted); font-size: 0.8125rem; margin: 0 0 4px; }
.modal p.modal-problem { color: var(--invalid); margin: 6px 0 0; }

/* The Change role dialog (story 2057): the roles as a group of radio buttons, then what the chosen one can and cannot do.
   A row's two buttons sit side by side. The marks on a gained or lost permission are text, so they do not rest on colour. */
td.user-actions { white-space: nowrap; }
td.user-actions .btn + .btn { margin-left: 6px; }
.user-role-modal h3, .user-role-modal h4 { text-transform: none; }
.user-role-modal fieldset { border: 0; margin: 0 0 8px; padding: 0; }
.user-role-modal legend { color: var(--muted); font-size: 0.8125rem; padding: 0; margin-bottom: 4px; }
.role-choice { display: block; padding: 4px 0; cursor: pointer; }
.role-preview h4 { margin: 10px 0 4px; font-size: 0.875rem; }
.role-preview ul { margin: 0; padding-left: 20px; }
.role-preview .role-mark { font-weight: 600; }

/* Deleting (story 2053): the Deleted list under the Fleet table, and the Delete and Clear dialogs. The status chips take
   colour pairs held to 4.5:1 already: deleted is dark's, incomplete is invalid's. A reason can be long, so it wraps. */
.deleted-section { margin-top: 28px; }
.deleted-section h3 { margin: 0 0 4px; font-size: 1rem; }
.deleted-section h3:focus { outline: none; }
.deleted-section .note { margin: 0 0 10px; }
.chip.deletion-deleted { background: color-mix(in srgb, var(--dark) 25%, transparent); color: color-mix(in srgb, var(--dark), white 27%); }
.chip.deletion-incomplete { background: color-mix(in srgb, var(--invalid) 22%, transparent); color: var(--invalid); }
td.deleted-reason { word-break: break-word; min-width: 140px; }
td.deleted-actions { white-space: nowrap; }
.delete-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.delete-modal { width: min(560px, 92vw); max-height: 92vh; overflow-y: auto; }
.delete-modal h3 { text-transform: none; }
.modal input[type="text"] {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px; font: inherit;
}
.delete-reason-label { margin-top: 12px; }
.delete-list { margin: 0 0 10px; padding-left: 20px; font-size: 0.8125rem; }
.delete-left { margin: 12px 0 0; padding: 10px 12px; border: 1px solid var(--invalid); border-radius: 8px; }
.delete-left p { margin: 0 0 6px; }
.delete-status:empty { display: none; }

/* The Rollout page's release lines, notes and pull requests (design 2026-11-05). */
.ring-release { display: flex; flex-direction: column; gap: 4px; }
.ring-released { font-size: 0.75rem; color: var(--muted); }
/* A ring's pull request: the accent only when it is a link. One at an address that is not https is drawn as text, and
   must not look like a link. */
.ring-pr { font-size: 0.8125rem; overflow-wrap: anywhere; }
a.ring-pr { color: var(--accent); }
.ring-pr.none, .ring-notes.none { color: var(--muted); font-size: 0.75rem; }
.ring-notes summary { cursor: pointer; font-size: 0.8125rem; }
.release-notes { font-size: 0.8125rem; line-height: 1.45; max-width: 60ch; }
.release-notes h4 { margin: 10px 0 4px; font-size: 0.8125rem; }
.release-notes p { margin: 6px 0; }
.release-notes ul { margin: 4px 0; padding-left: 18px; }
/* A second-level bullet is a list inside the bullet before it, which indents it; one with no bullet before it stays at
   the top level, indented and marked (a circle, not a disc) as though it were. */
.release-notes li ul { margin: 2px 0; }
.release-notes > ul > li.sub { margin-left: 16px; list-style-type: circle; }
.release-notes code { font-size: 0.75rem; background: var(--surface-2); padding: 0 4px; border-radius: 4px; }
.canary-prs { margin-top: 24px; }
.canary-prs h3 { font-size: 1rem; margin: 0 0 8px; }
.canary-prs h4 { font-size: 0.875rem; margin: 16px 0 6px; color: var(--muted); }
/* A link in the tables of pull requests into canary. With no colour of its own it would be the browser's link blue,
   which cannot be read on the dark surface (under 2:1): it takes the accent, as a ring card's link does, and keeps
   "PR <id>" on one line. */
.canary-prs a { color: var(--accent); white-space: nowrap; }
.chip.pr-status { background: var(--surface-2); color: var(--text); white-space: nowrap; }
.no-state { color: var(--muted); }
