/* Identity: sign-in, console and launcher, on the design system tokens. One part of app.css:
   scripts/build_css.py joins static/css/app/*.css in name order. */

:root {
  /* Brand: Identity blue. */
  --brand: #1d4ed8;
  --brand-hover: #1e40af;
  --brand-soft: #eff6ff;
  --brand-ink: #1e3a8a;
  --brand-border: #bfdbfe;
  --on-brand: #ffffff;

  /* Neutrals: a near-white canvas and white work surfaces. */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f5f7fa;
  --border: #e3e8ef;
  --border-strong: #d3dae5;
  --text: #0b1220;
  --text-muted: #56647b;

  /* The navigation rail: white like the cards, the app colour marks where you are. */
  --rail-bg: var(--surface);
  --rail-border: var(--border);
  --rail-text: var(--text);
  --rail-text-strong: var(--brand-ink);
  --rail-muted: var(--text-muted);
  --rail-hover: var(--surface-muted);
  --rail-active: var(--brand-soft);
  --rail-accent: var(--brand);
  --placeholder: #94a3b8;
  /* Checkbox and radio outlines need more contrast than a card edge. */
  --control-border: #94a3b8;

  /* Semantic, with 10 percent tints and a darker ink for text on the tint. */
  --success: #15803d;
  --success-soft: color-mix(in srgb, #15803d 10%, white);
  --success-ink: #14532d;
  --warning: #b45309;
  --warning-soft: color-mix(in srgb, #b45309 10%, white);
  --warning-ink: #78350f;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: color-mix(in srgb, #dc2626 10%, white);
  --danger-ink: #7f1d1d;

  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent);

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;

  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-menu: 0 10px 30px -10px rgba(15, 23, 42, 0.25);

  --navbar-height: 52px;
  /* Stacking order, lowest first. In-page menus and chart tips stay under the
     pinned navbar as the page scrolls; the navbar's own popovers sit inside it;
     the drawer and its backdrop cover it; toasts cover everything. Modals use
     the browser's top layer and need no number. */
  --z-dropdown: 30;
  --z-navbar: 40;
  --z-popover: 50;
  --z-backdrop: 55;
  --z-drawer: 60;
  --z-toast: 80;
  --gutter: 16px;
  --gap: 16px;
  --sidebar-width: 240px;
  /* IBM Plex: an engineered, institutional face with true tabular figures. */
  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono:
    "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Any rule with a `display` beats the browser's own `[hidden]`, so without
   this a hidden .alert (display: flex) is still drawn. */
[hidden] {
  display: none !important;
}

* {
  border-color: var(--border);
}

/* Anchor jumps and focus scrolling stop below the pinned navbar. */
html {
  scroll-padding-top: calc(var(--navbar-height) + 16px);
}

/* min-height, not height: a sticky navbar is held inside body, so a body
   capped at one viewport lets the bar scroll away once the page is taller. */
body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
/* A link inside running text is underlined, so colour is not the only thing marking it. */
:where(p, .hint, .auth-foot) a:not(.btn) {
  text-decoration: underline;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.011em;
}
h1 {
  font-size: 24px;
  line-height: 1.25;
}
h2 {
  font-size: 18px;
}
h3 {
  font-size: 16px;
}
p {
  margin: 0 0 0.75rem;
}
p:last-child {
  margin-bottom: 0;
}

code,
kbd,
.mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

/* --- Layout ------------------------------------------------------------- */

.shell {
  display: flex;
  min-height: calc(100vh - var(--navbar-height));
}

/* The navigation rail: full height on the left from 1024px, carrying the
   logo; below that it is the drawer (03-pages.css). */
.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--rail-bg);
  color: var(--rail-text);
  border-right: 1px solid var(--rail-border);
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: none;
  align-items: center;
  gap: 0.625rem;
  height: var(--navbar-height);
  padding: 0 1rem;
  border-bottom: 1px solid var(--rail-border);
}
.sidebar .brand-link,
.sidebar .brand-name {
  color: var(--text);
}
.sidebar .btn-ghost {
  color: var(--rail-text);
}
.sidebar .btn-ghost:hover {
  background: var(--rail-hover);
  color: var(--text);
}
/* The drawer controls only show where the sidebar is a drawer. The selectors
   name `.btn` too: `.btn` sets display further down and would win on order. */
.btn.nav-toggle,
.btn.nav-close,
.sidebar-backdrop {
  display: none;
}
.btn.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  line-height: 0;
}

/* The logo: the flat emblem in its own colour, filling the box, with nothing
   behind it (contract sections 4 and 8). The app name follows it and is cut
   with an ellipsis, never wrapped, when the bar runs out of room; the emblem
   keeps its full size. */
.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
}
.brand-mark .mark {
  width: 100%;
  height: 100%;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}
.brand-link:hover {
  text-decoration: none;
}
.brand-name {
  min-width: 0;
  overflow: hidden;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.875rem 0.625rem;
}
.nav-group {
  margin-bottom: 1.25rem;
}
.nav-group-label {
  padding: 0 0.625rem 0.375rem;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--rail-muted);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 38px;
  padding: 0.4375rem 0.625rem;
  border-radius: var(--radius);
  color: var(--rail-text);
  font-size: 14.5px;
  font-weight: 500;
  margin-bottom: 2px;
}
.nav-item:hover {
  background: var(--rail-hover);
  color: var(--text);
  text-decoration: none;
}
.nav-item:focus-visible {
  outline: 2px solid var(--rail-accent);
  outline-offset: -2px;
}
/* Where you are: the app colour behind the item and a bar at its edge. */
.nav-item.is-active {
  background: var(--rail-active);
  color: var(--rail-text-strong);
  font-weight: 600;
}
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -0.625rem;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--rail-accent);
}
.nav-item .icon {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  opacity: 0.75;
}
.nav-item.is-active .icon,
.nav-item:hover .icon {
  opacity: 1;
}
.nav-item .count {
  margin-left: auto;
  font-size: 0.6875rem;
  color: var(--text-muted);
  background: var(--surface-muted);
  border-radius: 999px;
  padding: 0.0625rem 0.4375rem;
}

.avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  /* Own the text metrics so inherited line-height can't pull the initials
     off centre. */
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
}
.avatar.lg {
  width: 44px;
  height: 44px;
  flex-basis: 44px;
  font-size: 0.875rem;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* The navbar spans the page beside the rail (the whole width below 1024px). */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: var(--navbar-height);
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: var(--z-navbar);
}
.topbar .spacer {
  flex: 1;
}

/* From 1024px the rail is fixed on the left, full height, and the navbar and
   page sit beside it. */
@media (min-width: 1024px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    height: 100vh;
    z-index: calc(var(--z-navbar) + 1);
  }
  .topbar,
  .shell {
    margin-left: var(--sidebar-width);
  }
  .topbar > .brand-link {
    display: none;
  }
  .sidebar .sidebar-brand {
    display: flex;
  }
}

/* Fluid on purpose: pages grow with the screen. Only prose, single form
   columns and dialogs carry a readability cap. */
.content {
  width: 100%;
  padding: var(--gutter);
}
@media (min-width: 640px) {
  :root {
    --gutter: 24px;
  }
  .content {
    padding-block: 24px;
  }
}
@media (min-width: 1280px) {
  :root {
    --gutter: 32px;
    --gap: 24px;
  }
  .content {
    padding-block: 32px;
  }
}
.prose {
  max-width: 72ch;
}

.page-head {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-head .spacer {
  flex: 1;
}
.page-head h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.page-actions form {
  margin: 0;
}
.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
  font-size: 13px;
  color: var(--text-muted);
}
.crumbs:empty {
  display: none;
}
.crumbs a {
  color: var(--text-muted);
}
.crumbs a:hover {
  color: var(--text);
}
.page-head p {
  color: var(--text-muted);
  margin: 0.25rem 0 0;
  max-width: 72ch;
}
/* --- Cards -------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.card-head {
  min-height: 52px;
  padding: 0.75rem 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.card-head .spacer {
  flex: 1;
}
/* The leading icon keeps its size, and the title block takes the rest of the
   line, so on a narrow card the action wraps under the title instead of the
   icon ending up alone on a line above it. */
.card-head > .icon {
  flex: none;
}
.card-head > div:not([class]),
.card-head > h2 {
  flex: 1 1 12rem;
  min-width: 0;
}
.card-head h2 {
  font-size: 14.5px;
  font-weight: 600;
}
.card-head p {
  color: var(--text-muted);
  font-size: 12.5px;
  margin: 0.0625rem 0 0;
}
.card-body {
  padding: 16px;
}
.card-body.tight {
  padding: 0.75rem 16px;
}
.card-foot {
  padding: 0.75rem 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.card-foot .spacer {
  flex: 1;
}

.grid {
  display: grid;
  gap: var(--gap);
}
.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
/* A form beside its supporting cards. The main column takes the larger share;
   `.even` splits it in half. Both stack below 1024px. */
.layout-split {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: var(--gap);
  align-items: start;
}
.layout-split.even {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* --- Stat tiles --------------------------------------------------------- */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 0.75rem 0.875rem;
}
.stat .label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.stat .value {
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin-top: 0.25rem;
  line-height: 1.1;
}
.stat .note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}
.stat.attention {
  border-color: var(--warning);
  background: var(--warning-soft);
}
.stat.attention .value {
  color: var(--warning);
}
.stat.critical {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.stat.critical .value {
  color: var(--danger);
}
.stat a {
  color: inherit;
}

/* --- Launcher tiles ----------------------------------------------------- */

.category-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1.75rem 0 0.75rem;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
.category-head:first-child {
  margin-top: 0;
}
/* Each launcher category is its own section, so its heading is always a first
   child and loses the margin above. The space goes between the sections. */
.launcher-group:not([hidden]) ~ .launcher-group {
  margin-top: 1.75rem;
}
.category-head .line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* --- Forms -------------------------------------------------------------- */

.field {
  margin-bottom: 1rem;
}
.field:last-child {
  margin-bottom: 0;
}
/* Fields in a grid are spaced by the grid gap. The grid itself then keeps the
   usual field spacing from whatever follows, which the last field in it would
   otherwise drop once the columns stack on a phone. */
.grid > .field {
  margin-bottom: 0;
}
.grid:has(> .field):not(:last-child) {
  margin-bottom: 1rem;
}
label,
.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 0.3125rem;
}
.hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3125rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="search"],
input[type="date"],
select,
textarea {
  width: 100%;
  min-height: 34px;
  padding: 0.375rem 0.625rem;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition:
    border-color 0.12s ease,
    box-shadow 0.12s ease;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
input[aria-invalid="true"],
.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--danger);
}

/* --- Checkbox and radio ---------------------------------------------------
   Drawn from scratch so every platform shows the same control. The input keeps
   its semantics, label and keyboard behaviour. */

input[type="checkbox"],
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  margin: 0;
  border: 1.5px solid var(--control-border);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition:
    background 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease;
}
input[type="radio"] {
  border-radius: 999px;
}

input[type="checkbox"]:hover:not(:disabled),
input[type="radio"]:hover:not(:disabled) {
  border-color: var(--brand);
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background: var(--brand);
  border-color: var(--brand);
}

/* The tick is a rotated rectangle with two borders, so it scales with the box
   and needs no image, no font and no extra element. */
input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1.5px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(43deg);
}
input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  inset: 3.5px;
  border-radius: 999px;
  background: #fff;
}
/* Half ticked: a "tick some" toggle over boxes of which only some are ticked. */
input[type="checkbox"]:indeterminate {
  background: var(--brand);
  border-color: var(--brand);
}
input[type="checkbox"]:indeterminate::after {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  top: 6.25px;
  height: 2px;
  border-radius: 1px;
  background: #fff;
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  box-shadow: var(--focus-ring);
  border-color: var(--brand);
}
input[type="checkbox"]:disabled,
input[type="radio"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* --- Select ---------------------------------------------------------------
   Styled here and enhanced into a listbox by static/js/enhance.js. Without the
   script this is still a working select. */

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2rem;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5625rem center;
  background-size: 16px;
}
select::-ms-expand {
  display: none;
}
/* No browser spinner on numbers: they differ on every platform; arrow keys still step. */
input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="color"] {
  padding: 0.1875rem;
  height: 36px;
}
textarea {
  resize: vertical;
  min-height: 72px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}
input::placeholder,
textarea::placeholder {
  color: var(--placeholder);
}
input[readonly],
input:disabled {
  background: var(--surface-muted);
  color: var(--text-muted);
}

.code-input {
  font-family: var(--font-mono);
  font-size: 1.5rem !important;
  letter-spacing: 0.32em;
  text-align: center;
  padding: 0.75rem !important;
}

.checkline {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.checkline input[type="checkbox"],
.checkline input[type="radio"] {
  margin-top: 0.125rem;
}
.checkline label {
  margin: 0;
  font-weight: 400;
  font-size: 0.8125rem;
}
.checkline strong {
  font-weight: 600;
}

.errorlist {
  list-style: none;
  margin: 0.3125rem 0 0;
  padding: 0;
  color: var(--danger);
  font-size: 0.75rem;
}
ul.errorlist li {
  margin-bottom: 0.125rem;
}

/* --- Buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4375rem;
  height: 34px;
  padding: 0 0.75rem;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: 0 1px 1px rgba(16, 24, 40, 0.04);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background 0.12s ease,
    border-color 0.12s ease,
    opacity 0.12s ease;
}
.btn:hover {
  background: var(--surface-muted);
  text-decoration: none;
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}
/* A busy button stays readable: it is disabled, but it is also the thing
   telling the person what is happening. */
.btn[aria-busy="true"] {
  opacity: 0.8;
  cursor: progress;
}
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}
.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

/* Deactivate: a secondary button whose words are in the danger colour (design system 12). */
/* A severe action that is not a deletion (sign out everywhere, reset factors,
   rotate a secret): red words, icon and edge, so it never passes for routine. */
.btn-danger-text {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border-strong));
}
.btn-danger-text:hover {
  color: var(--danger-hover);
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border-strong));
  background: var(--danger-soft);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
.btn-ghost:hover {
  background: var(--surface-muted);
}

.btn-block {
  width: 100%;
}
.btn-lg {
  height: 38px;
  padding: 0 1rem;
}
.btn-sm {
  height: 28px;
  padding: 0 0.5625rem;
  font-size: 12.5px;
  gap: 0.375rem;
}

/* --- Badges ------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  padding: 0.0625rem 0.4375rem;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.5;
  background: var(--surface-muted);
  color: var(--text-muted);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.brand {
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.badge.green {
  background: var(--success-soft);
  color: var(--success-ink);
}
.badge.amber {
  background: var(--warning-soft);
  color: var(--warning-ink);
}
.badge.red {
  background: var(--danger-soft);
  color: var(--danger-ink);
}
.badge .dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
}

/* --- Tables ------------------------------------------------------------- */

/* The wrapper scrolls sideways on small screens. Header cells stick under
   the navbar while the page scrolls; inside a height-capped wrapper they stick
   to its top instead. */
.table-wrap {
  overflow-x: auto;
}
table.data {
  width: 100%;
  min-width: 640px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
table.data th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td.num,
table.data th.num,
table.data td.right {
  font-variant-numeric: tabular-nums;
}
table.data td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:last-child td {
  border-bottom: none;
}
table.data tbody tr:hover {
  background: var(--surface-muted);
}
table.data td.right,
table.data th.right {
  text-align: right;
}
.cell-primary {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
/* A narrow table squeezes the name column first, which broke app and person
   names over two or three lines. The table scrolls sideways instead. */
table.data .cell-primary {
  min-width: 14rem;
}
.cell-primary strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
/* The secondary line under the name. The avatar and the app tile in the same
   cell are left out by name: at (0,1,1) this rule outweighs .tile-icon (0,1,0)
   and would otherwise take its grid centring and white glyph. */
.cell-primary span:where(:not(.avatar, .tile-icon)) {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Alerts -------------------------------------------------------------
   Inline, for permanent page states only. Passing feedback is a toast. */

.alert {
  display: flex;
  gap: 0.625rem;
  padding: 0.75rem 0.9375rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 14px;
  margin-bottom: 1rem;
}
.alert .icon {
  flex: 0 0 16px;
  margin-top: 1px;
}
.alert strong {
  display: block;
  font-weight: 600;
  margin-bottom: 0.125rem;
}
.alert.success {
  background: var(--success-soft);
  border-color: color-mix(in srgb, var(--success) 25%, white);
  color: var(--success-ink);
}
.alert.warning {
  background: var(--warning-soft);
  border-color: color-mix(in srgb, var(--warning) 25%, white);
  color: var(--warning-ink);
}
.alert.error {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 25%, white);
  color: var(--danger-ink);
}
.alert.info {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand-ink);
}
.alert a {
  color: inherit;
  text-decoration: underline;
}
/* Django messages, before toast.js turns them into toasts. Without script
   they stay here as a list. */
.toast-seed {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}
.toast-seed .alert {
  margin-bottom: 0.5rem;
}
.js .toast-seed {
  display: none;
}


/* The Save row of a long form (`.save-bar`, alone or on a `.card-foot`):
   it sticks to the bottom of the screen while the form scrolls, so Save is
   always in reach, and settles in place once the end of the form is on screen. */
.save-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  background: var(--surface);
  box-shadow: 0 -10px 24px -18px rgba(15, 23, 42, 0.35);
}
.save-bar .spacer {
  flex: 1;
}
.save-bar:not(.card-foot) {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
@media (max-width: 639px) {
  .save-bar > .small {
    flex-basis: 100%;
  }
}
/* --- Auth screens ------------------------------------------------------- */

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 2rem 1.25rem;
  background:
    radial-gradient(
      1000px 500px at 50% -12%,
      color-mix(in srgb, var(--brand) 8%, transparent),
      transparent 62%
    ),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
}
.auth-card.wide {
  max-width: 560px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.auth-brand .brand-mark {
  width: 48px;
  height: 48px;
  flex-basis: 48px;
}
/* The app name under the tile, pulled a little closer to it than the heading. */
.auth-app {
  margin-top: -0.25rem;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}
.auth-brand h1 {
  font-size: 20px;
  text-align: center;
}
.auth-brand p {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  margin: 0;
}

.auth-foot {
  margin-top: 1.25rem;
  padding-top: 1.125rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}
/* An address breaks at its hyphen otherwise ("no-" on one line, "reply@" on
   the next), which reads as two addresses. */
.auth-foot a[href^="mailto:"],
.auth-card a[href^="mailto:"] {
  white-space: nowrap;
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.125rem 0;
  color: var(--text-muted);
  font-size: 0.75rem;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.factor-tabs {
  display: flex;
  gap: 0.375rem;
  margin-bottom: 1.125rem;
  flex-wrap: wrap;
}
.factor-tab {
  flex: 1 1 auto;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
}
.factor-tab:hover {
  background: var(--surface-muted);
  text-decoration: none;
}
.factor-tab.is-active {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand-ink);
  font-weight: 600;
}

/* --- Recovery codes / secrets ------------------------------------------- */

.code-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  padding: 1rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.875rem;
}
.code-grid span {
  padding: 0.25rem 0.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  text-align: center;
}

.secret-box {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.6875rem 0.875rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  word-break: break-all;
}
.secret-box .value {
  flex: 1;
  min-width: 0;
}

.qr {
  display: grid;
  place-items: center;
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.qr img,
.qr svg {
  width: 190px;
  height: 190px;
  display: block;
}

/* --- Misc --------------------------------------------------------------- */

.muted {
  color: var(--text-muted);
}
.small {
  font-size: 0.75rem;
}
.tiny {
  font-size: 0.6875rem;
}
.strong {
  font-weight: 600;
}
.nowrap {
  white-space: nowrap;
}
.text-danger {
  color: var(--danger);
}
.text-warning {
  color: var(--warning);
}
.text-success {
  color: var(--success);
}
.mt-0 {
  margin-top: 0;
}
.mt-1 {
  margin-top: 0.5rem;
}
.mt-2 {
  margin-top: 1rem;
}
.mt-3 {
  margin-top: 1.5rem;
}
.mb-0 {
  margin-bottom: 0;
}
.mb-1 {
  margin-bottom: 0.5rem;
}
.mb-2 {
  margin-bottom: 1rem;
}
.mb-3 {
  margin-bottom: 1.5rem;
}

/* Empty state: the icon in a brand-soft circle, a title, one sentence and
   at most one action. */
.empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
}
.empty > .icon:first-child {
  box-sizing: content-box;
  width: 20px;
  height: 20px;
  padding: 10px;
  margin: 0 auto 0.75rem;
  display: block;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
}
.empty h3 {
  font-size: 16px;
  margin-bottom: 0.25rem;
  color: var(--text);
}
.empty p {
  max-width: 48ch;
  margin-inline: auto;
}
.empty .btn {
  margin-top: 1rem;
}
/* An empty table's message sits in a colspan cell of a table that is at least
   640px wide. On a phone that table scrolls sideways, so the message is held to
   the visible width and pinned to the left edge instead of centred off screen. */
table.data td[colspan] > .empty {
  position: sticky;
  left: 0;
  box-sizing: border-box;
  max-width: calc(100vw - 2 * var(--gutter));
}

/* Skeleton rows for lists loading in place. */
.skeleton {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: var(--surface-muted);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.55;
  }
}

.toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.toolbar .grow {
  flex: 1;
  min-width: 180px;
}
.toolbar select,
.toolbar input {
  font-size: 0.8125rem;
}

.meter {
  height: 5px;
  background: var(--surface-muted);
  border-radius: 999px;
  overflow: hidden;
}
.meter > i {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
}
.meter.warn > i {
  background: var(--warning);
}
.meter.bad > i {
  background: var(--danger);
}

.access-list {
  display: grid;
  gap: 0.5rem;
}
.access-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6875rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.access-row:hover {
  background: var(--surface-muted);
}
/* Status chips in a row share an app icon's footprint so a mixed list lines up. */
.access-row .tile-icon {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  flex: 0 0 32px;
}
.access-row .spacer {
  flex: 1;
}
label.access-row {
  cursor: pointer;
}
/* Nothing to restate: the control is the same everywhere by design. */
.access-row.disabled {
  opacity: 0.55;
}

/* The name and its explanation. `min-width: 0` because a flex item defaults to
   `min-width: auto`, which refuses to shrink below the longest word it holds:
   without it a long app name or a granted-by line pushes the badges off the
   card instead of wrapping. */
.access-text {
  min-width: 0;
  overflow-wrap: anywhere;
}
/* Badges stay on one line and keep their size; they are the row's status, and
   a wrapped "Common" over two lines reads as two things. */
.access-tags {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex: 0 0 auto;
}

/* --- An app and the role it starts people on ------------------------------
   The checkbox row, and under it the starting role for apps that have roles.
   The note gets `flex-basis: 100%` so it always has a line of its own; on a
   shared line the select's `width: 100%` squeezed it to one word per line.
   A two-track grid was tried and fails the same way: a spanning item inflates
   the label's max-content track. */
.access-item {
  display: grid;
  gap: 0.25rem;
}
.role-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.875rem;
  margin-left: 1.75rem;
  padding: 0.6875rem 0.875rem;
  border: 1px solid var(--border);
  border-left: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
}
/* Ticked above, live below: the role only means anything while the app is
   granted, so the pair share one state. */
.access-item:has(input[type="checkbox"]:checked) .role-row {
  border-color: var(--brand-border);
  border-left-color: var(--brand);
}
.role-label {
  flex: 1 0 100%;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0;
  cursor: pointer;
}
/* `flex` rather than `width`, so the basis outranks the `width: 100%` that
   every select on the site carries and the control stops at a readable size
   instead of eating the line. */
.role-row .cselect,
.role-row select {
  flex: 0 1 15rem;
  width: auto;
}
.role-note {
  flex: 1 0 100%;
  display: flex;
  align-items: flex-start;
  gap: 0.375rem;
  min-width: 0;
  margin: 0;
  font-size: 0.6875rem;
  line-height: 1.5;
  color: var(--text-muted);
  text-wrap: pretty;
}
.role-note svg {
  flex: 0 0 auto;
  margin-top: 0.1875rem;
  opacity: 0.7;
}
/* Already signed in, so the value is a record rather than a setting. A dashed
   outline and no fill say that before the sentence has to, and the control is
   disabled in the markup, so this only makes visible what is already true. */
.role-row.is-history .cselect-trigger,
.role-row.is-history select {
  background: transparent;
  border-style: dashed;
}

/* --- Responsive --------------------------------------------------------- */

/* Below 1024px the sidebar becomes a drawer over the page.

   Collapses use `minmax(0, 1fr)`, not a bare `1fr`: a bare track refuses to
   shrink below its content, and a card holding a sideways-scrolling chart
   would push the whole page wider than the phone. */
@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: var(--z-drawer);
    height: 100dvh;
    width: min(var(--sidebar-width), 84vw);
    transform: translateX(-100%);
    visibility: hidden;
    transition:
      transform 0.2s ease,
      visibility 0s linear 0.2s;
  }
  .sidebar-brand {
    display: flex;
  }
  .sidebar-brand .spacer {
    flex: 1;
  }
  body.nav-open .sidebar {
    transform: none;
    visibility: visible;
    box-shadow: var(--shadow-menu);
    transition: transform 0.2s ease;
  }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-backdrop);
    background: rgba(15, 23, 42, 0.45);
  }
  body.nav-open .sidebar-backdrop {
    display: block;
  }
  body.nav-open {
    overflow: hidden;
  }
  .btn.nav-toggle,
  .btn.nav-close {
    display: inline-flex;
  }
  .grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid.cols-3,
  .grid.cols-2,
  .layout-split,
  .layout-split.even {
    grid-template-columns: minmax(0, 1fr);
  }
  .card-head,
  .card-foot {
    flex-wrap: wrap;
  }
  .page-head .spacer {
    flex-basis: 100%;
    flex-grow: 0;
  }
}
@media (max-width: 639px) {
  .card-body {
    padding: 16px;
  }
  /* A row with an inline form (the recovery code box and its button) moves
     the form onto its own line rather than squeezing the label to one word. */
  .access-row {
    flex-wrap: wrap;
  }
  .access-row > form.row {
    margin-left: auto;
  }
  .grid.cols-4 {
    grid-template-columns: minmax(0, 1fr);
  }
  /* Phones: label over control, and the nesting indent gives way. */
  .role-row {
    margin-left: 0.75rem;
  }
  .role-label,
  .role-row .cselect,
  .role-row select {
    flex: 1 0 100%;
  }
  /* Filters stack: a row of four selects has nowhere to go on a phone. */
  .toolbar > *,
  .toolbar .grow,
  .toolbar .cselect,
  .toolbar select,
  .toolbar input {
    width: 100%;
    flex: 1 1 100%;
    min-width: 0;
  }
  .toolbar .btn {
    width: auto;
    flex: 1 1 auto;
  }
  .qr img,
  .qr svg {
    width: 160px;
    height: 160px;
  }
  /* 44px touch targets on phones. */
  .btn.btn-icon {
    width: 44px;
    height: 44px;
  }
  .btn {
    min-height: 40px;
  }
  .auth-page {
    padding: 1rem;
  }
  .auth-card {
    padding: 1.5rem 1.25rem;
  }
  .code-grid {
    grid-template-columns: 1fr;
  }
  .app-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* From 1280px tables fit their cards, so the wrapper stops scrolling and the
   header can stick under the navbar as the page scrolls. */
@media (min-width: 1280px) {
  .table-wrap {
    overflow-x: visible;
  }
  table.data th {
    top: var(--navbar-height);
  }
}

/* Print, recovery codes are the one thing here people legitimately print. */
@media print {
  .sidebar,
  .topbar,
  .btn,
  .no-print {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .card,
  .auth-card {
    box-shadow: none;
    border-color: #ccc;
  }
}

/* ---------------------------------------------------------------------------
   Custom select
   ---------------------------------------------------------------------------
   Paired with static/js/enhance.js. The native <select> stays in the form and
   is only hidden from view, so `.cselect-native` must not be display:none:
   that would take it out of the accessibility tree and, in some browsers, out
   of form validation reporting. Clipping it to a pixel is the standard way to
   keep an element real but invisible.
--------------------------------------------------------------------------- */

.cselect {
  position: relative;
  width: 100%;
}

.cselect-native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.cselect-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 36px;
  padding: 0.4375rem 0.6875rem;
  font: inherit;
  font-size: 14px;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    border-color 0.12s ease,
    box-shadow 0.12s ease;
}
.cselect-trigger:hover:not(:disabled) {
  border-color: var(--control-border);
}
.cselect-trigger:focus-visible,
.cselect.is-open .cselect-trigger {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
.cselect-trigger:disabled {
  background: var(--surface-muted);
  color: var(--text-muted);
  cursor: not-allowed;
}
.cselect-trigger.is-placeholder .cselect-label {
  color: var(--text-muted);
}

.cselect-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cselect-caret {
  display: flex;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}
.cselect.is-open .cselect-caret {
  transform: rotate(180deg);
}

.cselect-menu {
  position: absolute;
  z-index: var(--z-dropdown);
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  padding: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-menu);
  animation: cselect-in 0.12s ease;
}
.cselect.drop-up .cselect-menu {
  top: auto;
  bottom: calc(100% + 4px);
}

@keyframes cselect-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .cselect-menu,
  .skeleton {
    animation: none;
  }
  .cselect-caret,
  .sidebar,
  .app-tile,
  .app-tile .tile-go,
  .swatches label,
  .viz-tip {
    transition: none;
  }
}

.cselect-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4375rem 0.5625rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.cselect-option.is-active {
  background: var(--surface-muted);
}
.cselect-option.is-selected {
  color: var(--brand-ink);
  font-weight: 600;
}
.cselect-option.is-selected::after {
  content: "";
  margin-left: auto;
  width: 5px;
  height: 9px;
  border: solid var(--brand);
  border-width: 0 2px 2px 0;
  transform: rotate(43deg) translateY(-1px);
}
.cselect-option[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Compact variant for the filter toolbars, where a select sits beside inputs. */
.toolbar .cselect {
  width: auto;
  min-width: 150px;
}
.toolbar .cselect-trigger {
  font-size: 0.8125rem;
}

/* ---------------------------------------------------------------------------
   Application tiles
   The tile icon is the app's own mark on its brand colour: a flat rounded
   square (radius 22 percent), white glyph at about 60 percent, no effects.
--------------------------------------------------------------------------- */

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--gap);
}

.app-tile {
  --accent: var(--brand);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  overflow: hidden;
  transition: border-color 0.15s ease;
}
.app-tile:hover {
  text-decoration: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
.app-tile:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
}

.tile-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent, var(--brand));
}
/* An app's emblem carries its own colour and stands on its own, so the square
   only stays for a plain Lucide icon an administrator picked. */
.tile-icon:has(> .mark) {
  background: none;
}
.tile-icon .mark {
  width: 100%;
  height: 100%;
}

.app-tile .tile-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.app-tile .tile-head .tile-status {
  margin-left: auto;
}
.app-tile .tile-body {
  min-width: 0;
}
.app-tile strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
}
.app-tile .tile-body > span {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 0.1875rem;
  line-height: 1.45;
}

.app-tile .tile-go {
  display: flex;
  align-items: center;
  gap: 0.3125rem;
  margin-top: auto;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.15s ease;
}
.app-tile:hover .tile-go {
  color: var(--text);
}
/* An archived app: switched off, so its tile is greyed and opens its settings, not the app. */
.app-tile.is-archived {
  border-style: dashed;
}
.app-tile.is-archived .tile-icon,
.app-tile.is-archived .tile-body {
  filter: grayscale(1);
  opacity: 0.7;
}

/* The same tile, smaller, wherever an app is listed rather than launched. */
.tile-icon.md {
  width: 40px;
  height: 40px;
  flex-basis: 40px;
  border-radius: 9px;
}
.tile-icon.sm {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 7px;
}

/* ---------------------------------------------------------------------------
   Icon picker and colour swatches
--------------------------------------------------------------------------- */

.icon-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 0.375rem;
  max-height: 188px;
  overflow-y: auto;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
}
.icon-picker label {
  position: relative;
  margin: 0;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition:
    color 0.12s ease,
    border-color 0.12s ease,
    background 0.12s ease;
}
.icon-picker label:hover {
  color: var(--text);
  border-color: var(--control-border);
}
.icon-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}
.icon-picker label:has(input:checked) {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand-ink);
}
.icon-picker label:has(input:focus-visible) {
  box-shadow: var(--focus-ring);
}

.swatches {
  display: flex;
  gap: 0.4375rem;
  flex-wrap: wrap;
}
.swatches label {
  position: relative;
  margin: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
  transition: transform 0.12s ease;
}
.swatches label:hover {
  transform: scale(1.08);
}
.swatches input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}
.swatches label:has(input:checked) {
  transform: scale(1.08);
}
.swatches label:has(input:checked)::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 7px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(43deg);
}

/* --- Selectable rows -------------------------------------------------------
   An access row is a whole clickable target, so it gets the affordance of one
   rather than leaving a 17px checkbox as the only thing worth aiming at. */

.access-row:has(input[type="checkbox"]:checked) {
  border-color: var(--brand-border);
  background: var(--brand-soft);
}
.access-row:has(input[type="checkbox"]:focus-visible) {
  box-shadow: var(--focus-ring);
}
.access-row {
  transition:
    background 0.12s ease,
    border-color 0.12s ease;
}

/* --- Password reveal -------------------------------------------------------
   Paired with static/js/reveal.js, which wraps every password box and hangs the
   button inside it. The wrapper is the positioning context and nothing else, so
   the input keeps the width, padding and focus ring every other input has; only
   the right padding changes, to leave the button a lane of its own rather than
   letting a long password run underneath it.

   The selector is `.pw-field input`, not `input[type="password"]`, because the
   whole point of the control is that the type changes under it. */

.pw-field {
  position: relative;
  display: block;
}
.pw-field input {
  padding-right: 2.5rem;
}

.pw-toggle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  padding: 0;
  color: var(--text-muted);
  background: none;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 0.12s ease;
}
.pw-toggle:hover {
  color: var(--text);
}
.pw-toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  color: var(--text);
}
/* Pressed is a state somebody needs to see at a glance, since it is the
   difference between a password on screen and one that is not. */
.pw-toggle[aria-pressed="true"] {
  color: var(--brand);
}

/* Chrome and Edge grow their own reveal control on a password box, and Safari
   adds an autofill key. Left alone they sit beside this one, which is two
   buttons doing one job and a layout that shifts the moment a password manager
   fills the field. */
.pw-field input::-ms-reveal,
.pw-field input::-ms-clear {
  display: none;
}
.pw-field input::-webkit-credentials-auto-fill-button,
.pw-field input::-webkit-strong-password-auto-fill-button {
  margin-right: 1.75rem;
}

/* ---------------------------------------------------------------------------
   Watchtower: status, and the charts that explain it
   Charts are inline SVG drawn by the server; static/js/charts.js only adds
   the hover layer. Series colours live in apps/watchtower/charts.py, where
   their order was validated. The tokens here are chrome and status, and a
   status colour is never used for a series.
--------------------------------------------------------------------------- */

:root {
  --viz-grid: #eef2f6;
  --viz-axis: #cbd5e1;
  --viz-ink: #64748b;

  --status-up: var(--success);
  --status-up-soft: var(--success-soft);
  --status-degraded: var(--warning);
  --status-degraded-soft: var(--warning-soft);
  --status-down: var(--danger);
  --status-down-soft: var(--danger-soft);
  --status-idle: #94a3b8;
  --status-idle-soft: var(--surface-muted);
}

/* --- Status vocabulary --------------------------------------------------- */

/* One class per state, used by the dot, the chip and the strip alike, so a
   colour cannot mean one thing in a list and another in a chart. Every one of
   these ships with a text label beside it: status colour never carries the
   meaning on its own. */
.is-good {
  --tone: var(--status-up);
  --tone-soft: var(--status-up-soft);
}
.is-warn {
  --tone: var(--status-degraded);
  --tone-soft: var(--status-degraded-soft);
}
.is-bad {
  --tone: var(--status-down);
  --tone-soft: var(--status-down-soft);
}
.is-idle {
  --tone: var(--status-idle);
  --tone-soft: var(--status-idle-soft);
}
/* The idle grey is for dots and bars; as chip text it was 2.4:1 (WCAG AA needs 4.5:1). */
.status-chip.is-idle {
  color: var(--text-muted);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--tone, var(--status-idle));
  flex: 0 0 9px;
  position: relative;
}
/* A live problem gets one slow pulse. Reduced-motion turns it off: it is
   decoration, and the label beside it is what actually says it is broken. */
.status-dot.pulse::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  border: 2px solid var(--tone);
  opacity: 0.35;
  animation: viz-pulse 2.4s ease-out infinite;
}
@keyframes viz-pulse {
  0% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.25);
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .status-dot.pulse::after {
    animation: none;
  }
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.1875rem 0.5rem 0.1875rem 0.4375rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: var(--tone-soft, var(--surface-muted));
  color: var(--tone, var(--text-muted));
  border: 1px solid color-mix(in srgb, var(--tone, var(--border)) 22%, transparent);
  white-space: nowrap;
}

/* --- The headline banner ------------------------------------------------- */

.status-hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.125rem 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--tone) 28%, var(--border));
  background: var(--tone-soft);
}
.status-hero .status-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--tone);
}
.status-hero h2 {
  font-size: 1.0625rem;
  line-height: 1.3;
}
.status-hero p {
  margin: 0.1875rem 0 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
  max-width: 70ch;
}
.status-hero .spacer {
  flex: 1;
}
.status-hero .hero-figures {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  text-align: right;
}
.status-hero .hero-figure strong {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.status-hero .hero-figure > span {
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Stat tiles, extended ------------------------------------------------ */

.grid.cols-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.grid.cols-6 {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.stat .spark {
  margin-top: auto;
  padding-top: 0.5rem;
}
.stat .spark svg {
  display: block;
  width: 100%;
  height: 30px;
  overflow: visible;
}
.stat.good {
  border-color: color-mix(in srgb, var(--status-up) 32%, var(--border));
}
.stat.good .value {
  color: var(--status-up);
}
.stat-link {
  color: inherit;
  display: block;
}
.stat-link:hover {
  text-decoration: none;
}
.stat-link:hover .stat {
  border-color: var(--brand-border);
}

/* --- The filter row ------------------------------------------------------ */

/* One row, above everything it scopes. Ranges are presets, not a calendar:
   nobody fights a date grid to ask "how was today". */
.viz-filters {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.viz-filters .spacer {
  flex: 1;
}
/* Date range presets (design system 7): a grey track, the chosen one a white raised segment.
   Corners follow the other controls: 8px outside, 6px inside (2px padding between). */
.segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
}
.segmented a {
  padding: 0.3125rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.segmented a:hover {
  color: var(--text);
  text-decoration: none;
}
.segmented a.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}
.segmented a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* --- Charts -------------------------------------------------------------- */

.viz {
  position: relative;
}
.viz svg.chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
/* Below this width the coordinate space would scale the axis labels down to
   three or four pixels. The chart keeps its size and the card scrolls, which
   is what the data tables on this site already do. */
.viz-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 760px) {
  .viz-scroll > .viz {
    min-width: 560px;
  }
}

.chart .grid-line {
  stroke: var(--viz-grid);
  stroke-width: 1;
}
.chart .axis-line {
  stroke: var(--viz-axis);
  stroke-width: 1;
}
.chart text {
  font-family: var(--font-sans);
  font-size: 10px;
  fill: var(--viz-ink);
  font-variant-numeric: tabular-nums;
}
.chart .end-label {
  font-size: 11px;
  font-weight: 600;
  fill: var(--text);
  font-variant-numeric: normal;
}
.chart .series-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart .series-area {
  stroke: none;
  opacity: 0.12;
}
/* Failures: dashed as well as red, so colour is never the only difference. */
.chart .series-line.is-dashed {
  stroke-dasharray: 5 4;
}
/* The mean of the first series: a quiet reference line with its value. */
.chart .mean-line {
  stroke: var(--viz-ink);
  stroke-width: 1;
  stroke-dasharray: 2 4;
  opacity: 0.7;
}
.chart .mean-label {
  font-size: 10px;
  fill: var(--viz-ink);
}
/* The busiest point, marked and labelled where it is. */
.chart .peak-dot {
  fill: var(--surface);
  stroke: var(--brand);
  stroke-width: 2.5;
}
.chart .bar-value {
  font-size: 10.5px;
  font-weight: 600;
  fill: var(--text);
}
/* The takeaway under a chart: what to notice, in one line. */
.viz-caption {
  margin: 0.375rem 0 0;
  font-size: 12px;
  color: var(--text-muted);
}
/* A 2px ring in the surface colour, so an end dot stays legible where it
   crosses another line. */
.chart .series-dot {
  stroke: var(--surface);
  stroke-width: 2;
}
/* 4px rounded cap at the data end; the bar still starts flat on the baseline
   because the radius is smaller than the corner it would round away there. */
.chart .bar {
  rx: 4;
  opacity: 0.55;
}
/* The tallest column is drawn at full strength; the rest step back. */
.chart .bar.is-peak {
  opacity: 1;
}
.chart .band {
  fill: transparent;
}
.chart .band:hover,
.chart .band.is-active {
  fill: var(--text);
  fill-opacity: 0.035;
}
.chart .crosshair {
  stroke: var(--viz-axis);
  stroke-width: 1;
  pointer-events: none;
}
.chart .empty-note {
  font-size: 11px;
  fill: var(--text-muted);
}

.viz-legend {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.viz-legend .key {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
}
.viz-legend .key i {
  width: 12px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
  display: inline-block;
}
.viz-legend .key.is-dashed i {
  width: 14px;
  border-radius: 0;
  background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px);
}
.viz-legend .key.swatch i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

/* --- Tooltip ------------------------------------------------------------- */

.viz-tip {
  position: fixed;
  z-index: var(--z-dropdown);
  pointer-events: none;
  min-width: 132px;
  max-width: 240px;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-menu);
  font-size: 0.75rem;
  opacity: 0;
  transform: translateY(2px);
  transition:
    opacity 0.1s ease,
    transform 0.1s ease;
}
.viz-tip.is-visible {
  opacity: 1;
  transform: none;
}
.viz-tip .tip-title {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-bottom: 0.3125rem;
}
.viz-tip .tip-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.viz-tip .tip-row + .tip-row {
  margin-top: 0.1875rem;
}
/* A short stroke of the series colour, not a filled box: at tooltip density a
   block of colour is data-weight ink doing a label's job. */
.viz-tip .tip-key {
  width: 10px;
  height: 2px;
  border-radius: 999px;
  flex: 0 0 10px;
}
/* Value first here: the reader already has the series and wants the number. */
.viz-tip .tip-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.viz-tip .tip-name {
  color: var(--text-muted);
}
@media (prefers-reduced-motion: reduce) {
  .viz-tip {
    transition: none;
  }
}


/* --- Overview activity range ------------------------------------------- */

.range-custom {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.range-custom input[type="date"] {
  width: auto;
  min-width: 0;
}
.range-tiles {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.stat .delta {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.stat .delta.is-good {
  color: var(--success);
}
.stat .delta.is-danger {
  color: var(--danger);
}
/* --- Peak-hours heatmap -------------------------------------------------- */

/* Weekday down, hour across, each day's total at the end of its row. */
.heat {
  display: grid;
  grid-template-columns: 38px repeat(24, minmax(0, 1fr)) 76px;
  gap: 4px;
  align-items: center;
}
.heat .heat-hour,
.heat .heat-day {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.heat .heat-hour {
  text-align: center;
  padding-bottom: 0.25rem;
  white-space: nowrap;
}
.heat .heat-day {
  padding-right: 0.375rem;
  text-align: right;
  font-weight: 500;
}
.heat .heat-total-head {
  text-align: left;
  padding-left: 0.625rem;
}
.heat .cell {
  height: 26px;
  border-radius: 5px;
  background: var(--fill);
  transition: transform 0.08s ease;
}
.heat .cell.is-peak {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--warning);
  position: relative;
  z-index: 1;
}
.heat .cell:hover,
.heat .cell:focus-visible {
  transform: scale(1.15);
  outline: none;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand);
  position: relative;
  z-index: 2;
}
.heat-total {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding-left: 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.heat-total i {
  order: 2;
  display: block;
  height: 4px;
  min-width: 2px;
  border-radius: 999px;
  background: var(--brand);
  opacity: 0.6;
}
@media (prefers-reduced-motion: reduce) {
  .heat .cell {
    transition: none;
  }
}
@media (max-width: 1023px) {
  .heat-scroll {
    overflow-x: auto;
    padding-bottom: 0.25rem;
  }
  .heat {
    min-width: 700px;
  }
}
.heat-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-top: 1rem;
}
.heat-legend {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
}
.heat-legend i {
  width: 18px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  background: var(--fill);
}
.heat-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.heat-facts strong {
  color: var(--text);
}

/* --- Uptime strip -------------------------------------------------------- */

/* The status-page bar: one block per hour, worst-thing-wins. Blocks are 2px
   apart in the surface colour rather than outlined, so a run of good hours
   reads as one band and a bad hour interrupts it. */
.uptime-strip {
  display: flex;
  gap: 2px;
  align-items: stretch;
  height: 26px;
  min-width: 0;
}
.uptime-strip .block {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 2px;
  background: var(--tone, var(--status-idle));
  opacity: 0.9;
}
.uptime-strip .block.is-idle {
  background: var(--surface-muted);
}
.uptime-strip .block:hover {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--surface);
}
.uptime-caption {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.3125rem;
}

.app-health {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.app-health > header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.125rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}
.app-health > header .spacer {
  flex: 1;
}
/* On a phone the status chip and Details wrap under the name rather than
   squeezing the app name to a word per line. */
.app-health > header > div {
  flex: 1 1 10rem;
  min-width: 0;
}
.app-health > header h3 {
  font-size: 0.9375rem;
}
.app-health > header p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.app-health .body {
  padding: 0.875rem 1.125rem 1rem;
}

/* --- Ranked bars --------------------------------------------------------- */

/* Colour here follows the app, not the rank: a filter that drops one row must
   not repaint the others. The name beside each bar is the identity channel;
   the colour only repeats what the label already says. */
.rank-list {
  display: grid;
  gap: 0.6875rem;
}
.rank-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.75rem;
  align-items: baseline;
}
.rank-row .rank-label {
  display: flex;
  align-items: center;
  gap: 0.4375rem;
  font-size: 0.8125rem;
  min-width: 0;
}
.rank-row .rank-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rank-row .rank-value {
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.rank-row .rank-track {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}
.rank-row .rank-track > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent, var(--brand));
  min-width: 3px;
}
.rank-row .rank-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: var(--accent, var(--brand));
  flex: 0 0 9px;
}

/* --- Incident list ------------------------------------------------------- */

.incident-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0.9375rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--tone, var(--border));
  border-radius: var(--radius);
  background: var(--surface);
  /* In a narrow card the buttons drop to their own line rather than squeezing
     the title into three. The same row appears in a full-width card and in a
     side column, and the title is the part worth reading. */
  flex-wrap: wrap;
}
.incident-row .incident-body {
  min-width: 14rem;
  flex: 1 1 14rem;
}
.incident-row strong {
  display: block;
  font-weight: 600;
}
.incident-row .incident-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}
.incident-row .incident-actions {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}

/* --- Subscriptions ------------------------------------------------------- */

.sub-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.sub-row:has(input[name="scopes"]:checked) {
  border-color: var(--brand-border);
  background: var(--brand-soft);
}
.sub-row .sub-options {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  /* One line: wrapping stacked the two controls in a corner. It wraps again
     below 1024px. */
  flex-wrap: nowrap;
  justify-content: flex-end;
}
.sub-row .sub-options .cselect,
.sub-row .sub-options select {
  width: 232px;
  flex: 0 0 232px;
}
.sub-row .sub-options .checkline {
  flex: 0 0 auto;
}
/* Until the row is ticked its options are irrelevant, and dimming them says so
   without taking them out of reach the moment it is. */
/* 0.7, not lower: the controls stay usable, so their text must still meet 4.5:1 (0.45 failed axe). */
.sub-row:not(:has(input[name="scopes"]:checked)) .sub-options {
  opacity: 0.7;
}

/* --- Layout helpers ------------------------------------------------------ */

/* A form and its supporting column. The side column sticks once the main one
   is taller than the viewport, which is what makes a live preview useful on a
   long form rather than something you scroll away from. */
.sticky-side {
  position: sticky;
  top: calc(var(--navbar-height) + 1.25rem);
  align-self: start;
}
.layout-split.wide-main {
  grid-template-columns: minmax(0, 5fr) minmax(280px, 2fr);
}
.mt-4 {
  margin-top: 2rem;
}
.tabular {
  font-variant-numeric: tabular-nums;
}

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 1400px) {
  .grid.cols-6,
  .grid.cols-5 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 1100px) {
  .layout-split.wide-main {
    grid-template-columns: minmax(0, 3fr) minmax(240px, 2fr);
  }
}
@media (max-width: 1023px) {
  .grid.cols-5,
  .grid.cols-6 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .layout-split.wide-main {
    grid-template-columns: minmax(0, 1fr);
  }
  .sticky-side {
    position: static;
  }
  .status-hero {
    flex-wrap: wrap;
  }
  .status-hero .hero-figures {
    flex-basis: 100%;
    justify-content: flex-start;
    text-align: left;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
  }
  .sub-row {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .sub-row .sub-options {
    grid-column: 1 / -1;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .sub-row .sub-options .cselect,
  .sub-row .sub-options select {
    width: auto;
    flex: 1 1 200px;
  }
}
@media (max-width: 639px) {
  .grid.cols-5,
  .grid.cols-6 {
    grid-template-columns: minmax(0, 1fr);
  }
  .viz-filters .segmented {
    width: 100%;
    justify-content: space-between;
  }
  .viz-filters .segmented a {
    flex: 1;
    text-align: center;
  }
  .status-hero .hero-figures {
    gap: 1rem;
  }
}

/* ---------------------------------------------------------------------------
   Launcher: find an app
   The search box is a plain input with the icon and the key hint laid over
   it, so it stays a real search field for the browser and the screen reader.
--------------------------------------------------------------------------- */

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

.launcher-search {
  position: relative;
  flex: 0 1 300px;
  min-width: 220px;
}
.launcher-search > svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.launcher-search input[type="search"] {
  padding-left: 2.25rem;
  padding-right: 2.5rem;
}
.launcher-search kbd {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.25rem 0.4rem;
  color: var(--text-muted);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  pointer-events: none;
}
.launcher-search input:focus ~ kbd {
  opacity: 0;
}

@media (max-width: 639px) {
  .launcher-search {
    flex: 1 1 100%;
    min-width: 0;
  }
  .launcher-search kbd {
    display: none;
  }
}

/* =========================================================================
   Navbar right cluster: What's new, bell, all apps, account menu.
   Same order in every app (docs/design-system.md section 4). Each control
   works without script; shell.js and whats-new.js add the popovers.
   ========================================================================= */

.shell-cluster {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
.shell-bell,
.shell-news,
.shell-menu {
  position: relative;
}
.shell-btn {
  position: relative;
  color: var(--text-muted);
}
.shell-btn:hover {
  color: var(--text);
  background: var(--surface-muted);
}
.shell-btn[aria-expanded="true"] {
  color: var(--text);
  background: var(--surface-muted);
}
.shell-btn > .icon {
  flex: 0 0 auto;
}
/* The count sits on top of the bell, never in place of it. */
.bell-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
}
.news-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--brand);
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
}
/* Einstein, the chat assistant: a line drawing of a brain with a chat tail, the same in every
   Omni Healthcare app. At rest it is an outline in the header's text colour, like the other icons.
   It fills in skin colour and an aurora glows behind it on hover and keyboard focus, for widget.js's
   pulse (data-bhc-chat-buzz), while Einstein is open (aria-expanded) and while an answer is being
   written (data-bhc-chat-thinking), when the aurora moves faster and the brain breathes.
   data-bhc-chat-new shows a dot while an answer waits. With reduced motion the aurora stays still. */
.shell-assistant {
  --assistant-teal: #0891b2;
  position: relative;
  isolation: isolate;
  overflow: visible;
}
.shell-assistant .chat-brain-icon {
  position: relative;
  width: 22px;
  height: 22px;
  overflow: visible;
  color: currentColor;
  transition: color 0.4s ease;
}
.shell-assistant .chat-brain-icon path {
  stroke: none;
}
.shell-assistant .chat-brain-icon .brain-line {
  fill: currentColor;
}
.shell-assistant .chat-brain-icon .brain-fill {
  fill: #f5b5a3;
  fill-opacity: 0;
  transition: fill-opacity 0.4s ease;
}
.shell-assistant[data-bhc-chat-new]::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--assistant-teal);
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
}
.shell-assistant .chat-brain-aurora {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 53px;
  height: 47px;
  margin: -23.5px 0 0 -26.5px;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.45);
  transition: opacity 0.5s ease, transform 0.6s ease-in;
}
.shell-assistant .chat-brain-aurora i {
  position: absolute;
  border-radius: 50%;
  filter: blur(8px);
  opacity: 0.6;
  animation:
    assistant-aurora-hue 7.9s linear infinite,
    assistant-aurora-fade 7s ease-in-out infinite alternate,
    assistant-aurora-drift 17s ease-in-out infinite alternate;
  animation-play-state: paused;
}
.shell-assistant .chat-brain-aurora i:nth-child(1) { width: 62%; height: 44%; left: 0; top: 12%; --dx: 2px; --dy: 1.5px;
  animation-delay: 0s, 0s, 0s; animation-duration: 7.9s, 7s, 17s; }
.shell-assistant .chat-brain-aurora i:nth-child(2) { width: 57%; height: 47%; left: 21%; top: 2%; --dx: -1.5px; --dy: 2px;
  animation-delay: -1.32s, -2s, -5s; animation-duration: 7.9s, 9.3s, 21s; }
.shell-assistant .chat-brain-aurora i:nth-child(3) { width: 62%; height: 44%; right: 0; top: 14%; --dx: -2px; --dy: 1px;
  animation-delay: -2.63s, -5s, -9s; animation-duration: 7.9s, 8.4s, 19s; }
.shell-assistant .chat-brain-aurora i:nth-child(4) { width: 57%; height: 44%; right: 4%; bottom: 12%; --dx: -1.5px; --dy: -2px;
  animation-delay: -3.95s, -3s, -3s; animation-duration: 7.9s, 10.6s, 23s; }
.shell-assistant .chat-brain-aurora i:nth-child(5) { width: 62%; height: 44%; left: 19%; bottom: 3%; --dx: 2px; --dy: -1.5px;
  animation-delay: -5.27s, -6s, -12s; animation-duration: 7.9s, 11.7s, 18s; }
.shell-assistant .chat-brain-aurora i:nth-child(6) { width: 52%; height: 44%; left: 3%; bottom: 16%; --dx: 1.5px; --dy: -1px;
  animation-delay: -6.58s, -4s, -7s; animation-duration: 7.9s, 8.9s, 20s; }
.shell-assistant .chat-brain-aurora i:nth-child(7) { width: 57%; height: 55%; left: 21%; top: 23%; --dx: 0px; --dy: 0px; opacity: 0.5;
  animation-delay: -0.66s, -1s, 0s; animation-duration: 7.9s, 10s, 22s; }
.shell-assistant:hover .chat-brain-icon,
.shell-assistant:focus-visible .chat-brain-icon,
.shell-assistant[data-bhc-chat-buzz] .chat-brain-icon,
.shell-assistant[aria-expanded="true"] .chat-brain-icon,
.shell-assistant[data-bhc-chat-thinking] .chat-brain-icon {
  color: #8f4a3e;
  transition: color 1s ease;
}
.shell-assistant:hover .chat-brain-icon .brain-fill,
.shell-assistant:focus-visible .chat-brain-icon .brain-fill,
.shell-assistant[data-bhc-chat-buzz] .chat-brain-icon .brain-fill,
.shell-assistant[aria-expanded="true"] .chat-brain-icon .brain-fill,
.shell-assistant[data-bhc-chat-thinking] .chat-brain-icon .brain-fill {
  fill-opacity: 1;
  transition: fill-opacity 1s ease;
}
.shell-assistant:hover .chat-brain-aurora,
.shell-assistant:focus-visible .chat-brain-aurora,
.shell-assistant[data-bhc-chat-buzz] .chat-brain-aurora,
.shell-assistant[aria-expanded="true"] .chat-brain-aurora,
.shell-assistant[data-bhc-chat-thinking] .chat-brain-aurora {
  opacity: 1;
  transform: scale(1);
  transition: opacity 1.6s ease, transform 2.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.shell-assistant:hover .chat-brain-aurora i,
.shell-assistant:focus-visible .chat-brain-aurora i,
.shell-assistant[data-bhc-chat-buzz] .chat-brain-aurora i,
.shell-assistant[aria-expanded="true"] .chat-brain-aurora i,
.shell-assistant[data-bhc-chat-thinking] .chat-brain-aurora i {
  animation-play-state: running;
}
.shell-assistant[aria-expanded="true"]:not([data-bhc-chat-thinking]):not(:hover) .chat-brain-aurora {
  opacity: 0.8;
}
.shell-assistant[data-bhc-chat-thinking] .chat-brain-aurora i {
  animation-duration: 2.6s, 2.4s, 6s;
}
@keyframes assistant-aurora-hue {
  0% { background: #2ee6a6; }
  20% { background: #22d3ee; }
  40% { background: #4f7cff; }
  60% { background: #a46bff; }
  80% { background: #f472b6; }
  100% { background: #2ee6a6; }
}
@keyframes assistant-aurora-fade {
  from { opacity: 0.35; }
  to { opacity: 0.75; }
}
@keyframes assistant-aurora-drift {
  from { transform: translate(0, 0); }
  to { transform: translate(var(--dx), var(--dy)); }
}
@keyframes assistant-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
@media (prefers-reduced-motion: no-preference) {
  .shell-assistant[data-bhc-chat-thinking] .chat-brain-icon {
    animation: assistant-breathe 1.6s ease-in-out infinite;
  }
}
@media (prefers-reduced-motion: reduce) {
  .shell-assistant .chat-brain-aurora i {
    animation-play-state: paused !important;
  }
}
.shell-menu > summary {
  list-style: none;
  cursor: pointer;
}
.shell-menu > summary::-webkit-details-marker {
  display: none;
}
.account-trigger {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  height: 36px;
  padding: 0 0.3125rem 0 0.125rem;
  margin-left: 0.25rem;
  border-radius: 999px;
  color: var(--text-muted);
}
.account-trigger:hover,
.account-menu[open] > .account-trigger {
  background: var(--surface-muted);
  color: var(--text);
}
.account-trigger:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.account-trigger .avatar {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
}
.account-menu[open] .account-caret {
  transform: rotate(180deg);
}

.shell-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: var(--z-popover);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-menu);
}
.account-pop {
  width: 272px;
  padding: 0.375rem;
}
.account-who {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.625rem 0.625rem 0.75rem;
}
.account-who-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.account-who-text strong {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-who-text > span {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-tier {
  margin-top: 0.25rem;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  min-height: 36px;
  padding: 0.5rem 0.625rem;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover {
  background: var(--surface-muted);
  text-decoration: none;
}
.menu-item .icon {
  color: var(--text-muted);
}
.menu-item.is-danger,
.menu-item.is-danger .icon {
  color: var(--danger);
}
.menu-item.is-danger:hover {
  background: var(--danger-soft);
}
.menu-sep {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0.375rem 0;
}

/* The bell and What's new share one popover: 380px, its own scroll. */
.bell-pop,
.news-pop {
  width: 380px;
  max-width: calc(100vw - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bell-pop[hidden],
.news-pop[hidden] {
  display: none;
}
.pop-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.375rem 0.5rem 0.375rem 1rem;
  border-bottom: 1px solid var(--border);
}
.pop-head strong {
  font-size: 14px;
}
.pop-head .spacer {
  flex: 1;
}
.bell-list,
.news-list {
  max-height: 70vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.bell-empty {
  margin: 0;
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.bell-skeleton {
  display: grid;
  gap: 0.5rem;
  padding: 0.875rem 1rem 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.bell-skeleton .skeleton:first-child {
  width: 70%;
}
.bell-skeleton .skeleton:last-child {
  width: 40%;
  height: 10px;
}
.bell-item {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.6875rem 1rem 0.6875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  position: relative;
}
.bell-item:hover {
  background: var(--surface-muted);
  text-decoration: none;
}
.bell-item strong {
  font-size: 14px;
  font-weight: 500;
}
.bell-item.is-unread {
  background: var(--brand-soft);
}
.bell-item.is-unread strong {
  font-weight: 600;
}
.bell-item.is-unread::before {
  content: "";
  position: absolute;
  left: 0.5rem;
  top: 1.1rem;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--brand);
}
.bell-body {
  font-size: 13px;
  color: var(--text-muted);
}
.bell-meta {
  font-size: 12px;
  color: var(--text-muted);
}
.bell-foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  font-size: 14px;
  font-weight: 500;
}

.news-item {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
}
.news-item:last-child {
  border-bottom: 0;
}
.news-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  font-size: 12px;
  color: var(--text-muted);
}
.news-item h3 {
  font-size: 14px;
  margin-bottom: 0.125rem;
}
.news-item p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

@media (max-width: 1023px) {
  .topbar .brand-link {
    margin-left: 0.125rem;
  }
}
/* On a small phone the icons leave the name a letter or two, so the mark
   stands alone (its link keeps the name as its title). */
@media (max-width: 419px) {
  .topbar .brand-name {
    display: none;
  }
}
@media (max-width: 639px) {
  .topbar {
    gap: 2px;
  }
  .shell-cluster {
    gap: 0;
  }
  .account-trigger .account-caret {
    display: none;
  }
  /* Popovers become full-width sheets under the navbar. */
  .shell-pop.bell-pop,
  .shell-pop.news-pop,
  .shell-pop.account-pop {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    width: auto;
    max-width: none;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .bell-list,
  .news-list {
    max-height: calc(100dvh - var(--navbar-height) - 120px);
  }
}

/* =========================================================================
   Confirm dialog, for destructive actions (confirm.js).
   ========================================================================= */

dialog.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-menu);
}
dialog.modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}
.modal-body {
  padding: 20px;
}
.modal-body h2 {
  font-size: 18px;
  margin-bottom: 0.375rem;
}
.modal-body p {
  color: var(--text-muted);
  margin: 0;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.875rem 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
@media (max-width: 639px) {
  dialog.modal {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }
  dialog.modal:not([open]) {
    display: none;
  }
  .modal-body {
    flex: 1;
  }
  .modal-foot {
    border-radius: 0;
  }
  .modal-foot .btn {
    flex: 1;
  }
}

/* Error pages (404, 500). */
.error-code {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-ink);
}

/* =========================================================================
   Roles and the permission matrix.
   ========================================================================= */

.role-line {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}
.is-new-role {
  background: var(--warning-soft);
}
.badge.new {
  background: var(--warning-soft);
  /* Darker than --warning: the badge sits on the warning-soft row, where --warning is under 4.5:1. */
  color: #92400e;
  border-color: color-mix(in srgb, var(--warning) 25%, white);
}
.sync-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.matrix-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
table.matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  min-width: 720px;
}
table.matrix th,
table.matrix td {
  padding: 0.5rem 0.625rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.matrix thead th {
  background: var(--surface-muted);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}
table.matrix thead th:first-child,
table.matrix thead th:last-child {
  text-align: left;
}
table.matrix tbody th {
  min-width: 210px;
}
table.matrix td.cell {
  text-align: center;
  width: 76px;
}
table.matrix td.other {
  min-width: 180px;
}
table.matrix tr.matrix-group th {
  background: var(--surface-muted);
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  padding-top: 0.4375rem;
  padding-bottom: 0.4375rem;
}
table.matrix tbody tr:not(.matrix-group):hover {
  background: var(--surface-muted);
}
table.matrix tbody th {
  text-align: left;
  font-weight: 400;
}
.matrix-resource {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.matrix-resource strong {
  font-weight: 600;
}
.matrix-resource .desc {
  display: block;
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 400;
}
.matrix-none {
  /* Text, not decoration: the placeholder grey was 2.5:1, under WCAG AA's 4.5:1. */
  color: var(--text-muted);
  user-select: none;
}
.matrix-extra {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin: 0.125rem 0.75rem 0.125rem 0;
  white-space: nowrap;
}
input[type="checkbox"]:disabled:checked {
  opacity: 0.7;
}

.role-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.inbox-item {
  display: flex;
  gap: 0.875rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.inbox-item:hover {
  background: var(--surface-muted);
  text-decoration: none;
}
.inbox-item.is-unread {
  background: var(--brand-soft);
}
.inbox-item.is-unread strong {
  font-weight: 600;
}
.inbox-item .dot {
  width: 8px;
  height: 8px;
  margin-top: 0.4rem;
  flex: 0 0 8px;
  border-radius: 999px;
  background: transparent;
}
.inbox-item.is-unread .dot {
  background: var(--brand);
}

/* --- The Roles page: one card per role, Regency's layout ----------------- */
.roles-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin: 0 0 1rem;
}
.role-lock {
  display: inline-flex;
  color: var(--brand);
}
.role-warn {
  display: flex;
  align-items: flex-start;
  gap: 0.375rem;
  margin: 0.5rem 0 0;
  font-size: 12px;
  color: var(--warning-ink);
}
.role-warn .icon {
  flex: 0 0 auto;
  margin-top: 0.125rem;
  color: var(--warning);
}
.menu-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Who sees what: pages down the side, roles across the top. Fixed layout: the
   page column takes a third, the roles share the rest evenly, and the table
   only scrolls sideways once each role would get less than 140px. */
table.access-grid {
  min-width: calc(260px + var(--roles-width, 0px));
  table-layout: fixed;
}
table.access-grid col.page-col {
  width: 34%;
}
table.access-grid td {
  vertical-align: middle;
}
table.access-grid tr.matrix-group th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-muted);
}
table.access-grid thead th {
  text-align: left;
  vertical-align: bottom;
  min-width: 128px;
}
table.access-grid thead th a {
  color: var(--text);
}
table.access-grid thead th:first-child,
table.access-grid tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  min-width: 200px;
}
table.access-grid thead th:first-child {
  background: var(--surface-muted);
}
table.access-grid tbody tr:not(.matrix-group):hover th {
  background: var(--surface-muted);
}
table.access-grid tbody th .desc {
  display: block;
  font-size: 0.6875rem;
  color: var(--text-muted);
}
.grid-count {
  display: block;
  font-weight: 400;
  font-size: 11px;
}
.grid-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.grid-action {
  padding: 0.0625rem 0.4375rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.grid-action.is-view {
  background: var(--surface-muted);
  color: var(--text);
}

/* The editor: the matrix beside who holds the role. */
.matrix-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.25rem 0 0.5rem;
}
.matrix-col {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}
.matrix-resource {
  justify-content: flex-start;
}
.alert .btn,
.alert .btn:hover {
  color: var(--on-brand);
  text-decoration: none;
}
.alert .btn:not(.btn-primary) {
  color: var(--text);
}

/* Roles as check cards, each saying what it is for. */
.role-choices {
  flex: 1 0 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.375rem;
  margin: 0.25rem 0;
}
.role-choice {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}
.role-choice:hover {
  border-color: var(--brand-border);
}
.role-choice:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.role-choice:has(input:disabled) {
  cursor: default;
}
.role-choice input {
  margin-top: 0.1875rem;
  flex: 0 0 auto;
}
.role-choice-text {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}
.role-choice-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.role-choice:has(input:checked) .role-choice-name {
  color: var(--brand-ink);
}
.role-choice-desc {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}
.invite-role[hidden] {
  display: none;
}


/* A row of app chips that jump to each app's section (Roles & permissions,
   Access map); it stays under the navbar while the page scrolls. */
.app-jump {
  position: sticky;
  top: calc(var(--navbar-height) + 8px);
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow-card);
}
.app-jump a {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  padding: 0.3125rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
}
.app-jump a:hover {
  border-color: var(--brand-border);
  background: var(--brand-soft);
  text-decoration: none;
}
.app-jump i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent, var(--brand));
}
.app-jump span {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
/* Jumping to a section stops below the navbar and this bar. */
[id^="roles-"],
[id^="app-"] {
  scroll-margin-top: calc(var(--navbar-height) + 64px);
}
/* Inside a form (an app's settings page) the bar spaces itself from what follows. */
form > .app-jump {
  margin-bottom: var(--gap);
}
/* =========================================================================
   Access layout, shared with every app (docs/design-system.md section 12).
   The page header is a full-width band under the navbar with a rule below
   it; everything after it sits in the page body, one gap apart.
   ========================================================================= */

.content {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 0 var(--gutter) 24px;
}
@media (min-width: 640px) {
  .content {
    padding-block: 0 32px;
  }
}
/* Blocks are spaced by the gap above, so their own top and bottom margins
   would only double it. */
.content > :is(.card, .alert, .grid, .stack, .layout-split, .toolbar,
    .table-wrap, .note, form, section, .roles-toolbar, .viz-filters, .app-jump) {
  margin-block: 0;
}
.content > .crumbs {
  margin: 0 calc(-1 * var(--gutter)) calc(-1 * var(--gap));
  padding: 16px var(--gutter) 6px;
}
.content > .crumbs:empty {
  display: block;
  padding: 0;
  height: 0;
}
.content > .page-head {
  margin: 0 calc(-1 * var(--gutter)) 4px;
  padding: 6px var(--gutter) 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.content > .crumbs:empty + .page-head {
  padding-top: 20px;
}
/* A page with no header still starts clear of the navbar. */
.content > .crumbs:empty + :not(.page-head) {
  margin-top: 20px;
}
@media (min-width: 640px) {
  .content > .page-head {
    margin-bottom: 8px;
  }
  .content > .crumbs:empty + :not(.page-head) {
    margin-top: 24px;
  }
}
/* Actions sit beside the title from 768px, and under it below. */
@media (max-width: 767px) {
  .page-head .spacer {
    display: none;
  }
  .page-actions {
    flex-basis: 100%;
  }
}

/* The note under a page header: where accounts come from, and so on. */
.note {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
}
.note > .icon {
  flex: 0 0 auto;
  margin-top: 0.1875rem;
  color: var(--brand);
}
.note p {
  margin: 0;
}

/* Search and filters over a list. */

/* A table from 768px, the same rows stacked below it. */
/* `clip`, not `hidden`: it rounds the corners without making the card a
   scroll box, so a table header still sticks under the navbar. */
.list-card {
  overflow: clip;
}
table.data .row-actions {
  flex-wrap: nowrap;
}
/* Team members carries two buttons a row: they stack rather than push the
   table past the card, but only where the card is too narrow for both. */
table.data .row-actions.can-wrap {
  flex-wrap: wrap;
}
@media (min-width: 1280px) {
  table.data .row-actions.can-wrap {
    flex-wrap: nowrap;
  }
}

/* A person's apps (their page, Edit roles, Invite): an app's roles show only
   once it is ticked, so a long list of apps they do not have stays short. The
   fields stay in the form, so what is saved does not change. */
.access-item:has(> .access-row input[type="checkbox"]:not(:checked)) > .role-row {
  display: none;
}
.stacked {
  display: none;
  list-style: none;
  margin: 0;
  padding: 0;
}
.stacked > li {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}
.stacked > li:first-child {
  border-top: 0;
}
.stacked .row-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.stacked .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}
@media (max-width: 767px) {
  .list-card .table-wrap {
    display: none;
  }
  .list-card .stacked {
    display: block;
  }
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.375rem;
}
.row-actions form {
  margin: 0;
}
.row-actions .btn-edit {
  min-width: 5.25rem;
}
.stacked .row-actions {
  justify-content: flex-start;
}
.cell-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  max-width: 60ch;
}

/* The side drawer: every edit opens from the right. Rendered by the page
   when a person, role or group is open, so it works without the script;
   drawer.js adds Escape and keeps focus inside. */
.drawer {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer);
  display: flex;
  justify-content: flex-end;
}
.drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.drawer-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 36rem;
  height: 100%;
  margin: 0;
  background: var(--surface);
  box-shadow: var(--shadow-menu);
  outline: none;
}
.drawer-panel.is-wide {
  max-width: 56rem;
}
@media (min-width: 640px) {
  .drawer-panel {
    border-left: 1px solid var(--border);
  }
}
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.drawer-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.drawer-head p {
  margin: 0.125rem 0 0;
  font-size: 13px;
  color: var(--text-muted);
}
.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.drawer-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}
.drawer-foot .spacer {
  flex: 1;
}
@media (min-width: 640px) {
  .drawer-head,
  .drawer-body,
  .drawer-foot {
    padding-inline: 1.25rem;
  }
}
.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.drawer-section > .section-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.drawer-section > .section-label > span:last-child {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}
.drawer-section .hint,
.drawer-section .role-note {
  margin: 0;
}
.drawer .matrix-wrap {
  margin-inline: -1rem;
  border-inline: 0;
  border-radius: 0;
}
@media (min-width: 640px) {
  .drawer .matrix-wrap {
    margin-inline: -1.25rem;
  }
}
body:has(.drawer) {
  overflow: hidden;
}
/* In a drawer the choices wrap, several to a line, so an app with nine roles
   takes three short lines rather than nine. */
.drawer .role-choices {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  margin: 0;
  /* Inline it fills its row (`flex: 1 0 100%`); in the drawer's column that
     basis would be the panel's whole height. */
  flex: none;
  width: 100%;
}
.perm-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.perm-labels li {
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  font-size: 12px;
  color: var(--text-muted);
}
.member-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0;
  border-top: 1px solid var(--border);
}
.member-row:first-child {
  border-top: 0;
}
.member-row .who {
  flex: 1;
  min-width: 0;
}
.member-row .who strong,
.member-row .who span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member-row .who span {
  font-size: 12px;
  color: var(--text-muted);
}

/* Viewing as somebody (apps.auth.view_as): a warning pill before What's new. */
.view-as-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 2px 2px 10px;
  border: 1px solid var(--warning);
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning-ink);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.view-as-pill span { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 640px) { .view-as-pill span { display: none; } }

/* Loading splash (templates/_splash.html, static/js/splash.js): a light blur
   over the whole page with an ID badge that blinks while a key turns in the
   lock and the shackle springs open. No card behind it. Tokens only. */
.splash {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 16px;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  cursor: progress;
  background: color-mix(in srgb, var(--bg) 35%, transparent);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: opacity 0.15s ease-in, visibility 0s linear 0.15s;
}
.splash[data-shown] {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
  transition: opacity 0.12s ease-out;
}
.splash-scene {
  display: grid;
  justify-items: center;
  gap: 8px;
  max-width: 320px;
  text-align: center;
}
.splash-art {
  width: 160px;
  height: 120px;
  overflow: visible;
}
.splash-text {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.splash-hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}
.splash-badge {
  animation: splash-bob 2.4s ease-in-out infinite;
}
.splash-clip {
  fill: var(--brand-ink);
}
.splash-card-body {
  fill: var(--brand);
}
.splash-slot {
  fill: var(--brand-soft);
}
.splash-face {
  fill: var(--brand-soft);
}
.splash-eyes {
  fill: var(--brand-ink);
  transform-box: fill-box;
  transform-origin: center;
  animation: splash-blink 2.4s ease-in-out infinite;
}
.splash-smile {
  fill: none;
  stroke: var(--brand-ink);
  stroke-width: 2.5;
  stroke-linecap: round;
}
.splash-name {
  fill: color-mix(in srgb, var(--brand-soft) 75%, var(--brand));
}
.splash-lock {
  fill: var(--brand-soft);
  stroke: var(--brand);
  stroke-width: 2.5;
}
.splash-shackle {
  fill: none;
  stroke: var(--brand-ink);
  stroke-width: 6;
  stroke-linecap: round;
  animation: splash-unlock 2.4s ease-in-out infinite;
}
.splash-keyhole {
  fill: var(--brand-ink);
}
.splash-key {
  transform: translate(120px, 78px);
  animation: splash-turn 2.4s ease-in-out infinite;
}
.splash-key-stem {
  fill: none;
  stroke: var(--brand-ink);
  stroke-width: 3;
  stroke-linecap: round;
}
.splash-key-bow {
  fill: var(--surface);
  stroke: var(--brand-ink);
  stroke-width: 3;
}
@keyframes splash-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
@keyframes splash-blink {
  0%, 30%, 36%, 70%, 76%, 100% { transform: scaleY(1); }
  33%, 73% { transform: scaleY(0.1); }
}
@keyframes splash-turn {
  0%, 15% { transform: translate(120px, 78px) rotate(0deg); }
  40%, 80% { transform: translate(120px, 78px) rotate(90deg); }
  95%, 100% { transform: translate(120px, 78px) rotate(0deg); }
}
@keyframes splash-unlock {
  0%, 42% { transform: translateY(0); }
  50%, 76% { transform: translateY(-7px); }
  84%, 100% { transform: translateY(0); }
}
/* Reduced motion: the open lock and a smiling badge, still, with a plain fade. */
@media (prefers-reduced-motion: reduce) {
  .splash-badge,
  .splash-eyes,
  .splash-key,
  .splash-shackle {
    animation: none;
  }
  .splash-key {
    transform: translate(120px, 78px) rotate(90deg);
  }
  .splash-shackle {
    transform: translateY(-7px);
  }
}

/* A list table (`table.data.stack-sm`) becomes stacked cards below 768px
   (design system 12): the first cell across the top, the rest two to a line
   under their column names (`data-label`), the actions along the bottom. */
@media (max-width: 767px) {
  table.data.stack-sm {
    min-width: 0;
  }
  table.data.stack-sm thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  table.data.stack-sm tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.625rem 1rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
  }
  table.data.stack-sm tbody tr:last-child {
    border-bottom: 0;
  }
  table.data.stack-sm tbody td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    white-space: normal;
    text-align: left;
  }
  table.data.stack-sm tbody td:first-child,
  table.data.stack-sm tbody td:last-child:not([data-label]),
  table.data.stack-sm tbody td[colspan] {
    grid-column: 1 / -1;
  }
  table.data.stack-sm td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.125rem;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
  }
  table.data.stack-sm .row-actions {
    justify-content: flex-start;
  }
}

/* An app given with no role (role-guard.js, and the server): the box and a sentence in red. */
.access-item.needs-role > .role-row {
  border-color: var(--danger);
  border-left-color: var(--danger);
}
.role-error {
  flex: 1 0 100%;
  margin: 0.25rem 0 0;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--danger);
}
/* In the drawers a role's description is kept to two lines; the rest is in its title. */
.drawer .role-choice-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* =========================================================================
   Notification settings page (notification-settings.js): a card per kind,
   Email and In app switches on the right, under the text below 640px.
   ========================================================================= */

.notify-area {
  margin-bottom: 1.5rem;
}
.notify-area h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.notify-kind {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 16px 20px;
  margin-bottom: 0.5rem;
}
.notify-text {
  flex: 1;
  min-width: 0;
}
.notify-text p {
  margin: 0.125rem 0 0;
  font-size: 13px;
  color: var(--text-muted);
}
.notify-switches {
  display: flex;
  gap: 1.25rem;
}
.notify-switch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 56px;
}
.notify-channel {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}
.notify-save {
  margin-top: 1rem;
}
.js .notify-save {
  display: none;
}

/* A switch over a native checkbox, so it submits and reads as a switch without script. */
input[type="checkbox"].switch {
  width: 36px;
  height: 20px;
  border: 0;
  border-radius: 999px;
  background: var(--control-border);
}
input[type="checkbox"].switch::after,
input[type="checkbox"].switch:checked::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  transform: none;
  transition: transform 0.15s;
}
input[type="checkbox"].switch:checked {
  background: var(--brand);
}
input[type="checkbox"].switch:checked::after {
  transform: translateX(16px);
}
input[type="checkbox"].switch:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
input[type="checkbox"].switch:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 639px) {
  .notify-kind {
    flex-direction: column;
    align-items: stretch;
  }
  .notify-switch {
    flex-direction: row;
    align-items: center;
  }
}

/* =========================================================================
   Send a request dialog (request-dialog.js), on dialog.modal: 560px, a
   full-width sheet under 640px.
   ========================================================================= */

html:not(.js) [data-request-open] {
  display: none;
}
.request-dialog form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-height: inherit;
}
.request-dialog .modal-body {
  flex: 1;
  overflow-y: auto;
}
.request-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.request-head h2 {
  margin: 0;
}
.request-project {
  margin: 0.25rem 0 1rem;
  font-size: 13px;
  color: var(--text-muted);
}
.request-project strong {
  color: var(--text);
}
.request-project-skeleton {
  display: inline-block;
  width: 120px;
  vertical-align: middle;
}
.request-notice {
  margin-bottom: 1rem;
}
.request-kind {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0;
  border: 0;
}
.request-kind legend {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 0.375rem;
}
.request-kind label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.request-kind input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.request-kind label:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.request-kind label:has(input:focus-visible) {
  box-shadow: var(--focus-ring);
}
.request-error {
  margin: 0.3125rem 0 0;
  font-size: 12px;
  color: var(--danger);
}
.request-shot-preview {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.request-shot-preview img {
  max-width: 200px;
  max-height: 120px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  object-fit: contain;
}
.request-shot .hint code {
  word-break: break-all;
}
.request-done p {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}
.request-done .icon {
  color: var(--success);
}
/* =========================================================================
   Overview (templates/console/overview.html): the stat cards, the Activity
   card's chart panels and its grants table.
   ========================================================================= */

/* A stat tile's note is a line of text, never the callout `.note` box. */
.stat .note {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  font-size: 0.75rem;
  line-height: 1.45;
}

/* The cards reflow on the width they actually get beside the sidebar, not
   the window's, and every card in a row is the same height. */
.stat-board {
  container-type: inline-size;
}
.stat-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.stat-grid.is-four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
/* Service health uses the same cards: five for a manager, three for a member. */
.stat-grid.is-five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.stat-grid.is-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.stat-grid > .stat-link,
.stat-grid > .stat-link > .stat,
.stat-grid > .stat {
  height: 100%;
}
.stat-grid .stat .note {
  margin-top: auto;
  padding-top: 0.375rem;
}
@container (max-width: 1100px) {
  .stat-grid,
  .stat-grid.is-five {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .stat-grid.is-four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@container (max-width: 560px) {
  .stat-grid,
  .stat-grid.is-five {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat-grid.is-three {
    grid-template-columns: minmax(0, 1fr);
  }
}
@container (max-width: 340px) {
  .stat-grid,
  .stat-grid.is-five,
  .stat-grid.is-four {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- App cards ----------------------------------------------------------- */

/* App cards (Overview's Your apps and Applications, Roles & permissions):
   small cards side by side, as many to a line as the width allows, wrapping
   to one a line on a phone. */
.app-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.75rem;
}
.app-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: inherit;
  transition:
    border-color 0.12s ease,
    background 0.12s ease;
}
a.app-card:hover {
  text-decoration: none;
  border-color: var(--brand-border);
  background: var(--surface-muted);
}
.app-card-top {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.375rem;
}
.app-card-top .spacer {
  flex: 1;
}
.app-card strong {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  overflow-wrap: anywhere;
}
.app-card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: auto;
  padding-top: 0.5rem;
  font-weight: 500;
}
.app-card strong .icon {
  flex: 0 0 auto;
  color: var(--text-muted);
}
@media (prefers-reduced-motion: reduce) {
  .app-card {
    transition: none;
  }
}

/* --- Cards side by side end level ---------------------------------------- */

/* Your apps beside Requests and Busiest apps: both sides take the taller one's
   height; the last card on the right grows, and the "Showing 8 of 17" line
   sits at the foot of Your apps. */
.equal-split {
  align-items: stretch;
}
.equal-split > .card,
.equal-split > .stack > .card:last-child {
  display: flex;
  flex-direction: column;
}
.equal-split > .stack > .card:last-child {
  flex: 1;
}
.equal-split > .card > .card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
/* A flex column would otherwise widen to a chart's drawn width and push the
   page past the screen. */
.equal-split > .card,
.equal-split > .card > .card-body > * {
  min-width: 0;
}
.equal-split > .card > .card-body > .hint:last-child {
  margin-top: auto;
  padding-top: 1rem;
}

/* --- Activity ------------------------------------------------------------ */

.activity-split {
  align-items: stretch;
}
.activity-charts {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}
.viz-panel {
  min-width: 0;
  padding: 1rem 1.125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.viz-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}
.viz-panel-head h3 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
}
.viz-panel > .table-wrap {
  margin: 0 -1.125rem -1rem;
}
/* The table scrolls inside its panel, so a long list of apps never leaves
   the charts beside it floating over empty space. */
.grants-panel > .table-wrap {
  max-height: 600px;
  overflow-y: auto;
}
.grants-panel table.data th {
  top: 0;
}
/* Side by side, the panel is exactly as tall as the charts: `contain: size`
   keeps the table from setting the row's height, and it scrolls instead. */
@media (min-width: 1024px) {
  .activity-split > .grants-panel {
    display: flex;
    flex-direction: column;
  }
  .grants-panel > .table-wrap {
    flex: 1 1 0;
    max-height: none;
    contain: size;
  }
}
.grants-table th.num,
.grants-table td.num {
  text-align: right;
}
.holder-cell {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.625rem;
}
.holder-track {
  width: 56px;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}
.holder-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent, var(--brand));
}
@media (max-width: 639px) {
  .range-filters .range-custom {
    width: 100%;
  }
  .range-filters .range-custom input[type="date"] {
    flex: 1 1 0;
  }
  .range-filters .range-custom .btn {
    flex-basis: 100%;
    justify-content: center;
  }
  .holder-track {
    display: none;
  }
}

/* --- Your account (templates/auth/account.html) --------------------------- */

.account-id {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
}
.row-title {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}
.password-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.meter.mini {
  display: inline-block;
  width: 72px;
  height: 4px;
}

/* A card that fills the height beside it with content rather than white space
   (`.fill-card`, its list in `.fill-scroll`): side by side, the list takes
   exactly the room left and scrolls inside it; stacked, it is capped. */
.fill-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.fill-card > .card-body,
.fill-card > .fill-scroll {
  flex: 1 1 auto;
  min-height: 0;
}
.fill-scroll {
  max-height: 420px;
  overflow: auto;
}
.fill-scroll table.data th {
  top: 0;
}
@media (min-width: 1024px) {
  .equal-split .fill-scroll {
    flex: 1 1 0;
    max-height: none;
    min-height: 160px;
    contain: size;
  }
}

/* An empty state in a card stretched beside a taller one sits in its middle. */
.equal-split .fill-empty {
  margin: auto;
}
/* =========================================================================
   Service health (templates/console/watchtower.html): every watched app as a
   card, as many to a line as fit, each the height of the tallest beside it.
   ========================================================================= */

.watch-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1rem;
}
.watch-head h2 {
  font-size: 1.125rem;
  margin: 0 0 0.25rem;
}
.watch-head p {
  margin: 0;
  max-width: 72ch;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.watch-head .spacer {
  flex: 1;
}
.strip-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem 0.875rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.strip-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}
.strip-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--tone);
}
.strip-legend .is-idle {
  background: var(--surface-muted);
  box-shadow: inset 0 0 0 1px var(--border);
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: var(--gap);
}
.health-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border);
  border-top: 3px solid var(--tone, var(--border));
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.health-card > header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 0.875rem 0.625rem;
}
.health-card > header > div {
  flex: 1;
  min-width: 0;
}
.health-card > header h3 {
  margin: 0;
  font-size: 0.9375rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.health-card > header p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.health-services {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 0.375rem 0.375rem;
}
.health-service {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.5rem 0.5rem 0.5625rem;
  border-radius: var(--radius);
  color: inherit;
}
.health-service + .health-service {
  border-top: 1px solid var(--border);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
a.health-service:hover {
  text-decoration: none;
  background: var(--surface-muted);
}
.health-service-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  font-size: 0.8125rem;
}
.health-service-top strong {
  font-weight: 600;
  white-space: nowrap;
}
.health-kind {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.health-figures {
  display: flex;
  gap: 0.625rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.health-figures b {
  color: var(--text);
  font-weight: 600;
}
/* One app's page lays its services out side by side, as many as fit. */
.health-services.is-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 0.5rem;
  padding: 0;
}
.health-services.is-grid > .health-service {
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.health-services.is-grid > .health-service + .health-service {
  border-top: 1px solid var(--border);
  border-radius: var(--radius);
}
.health-service .uptime-strip {
  height: 14px;
  gap: 1px;
}
.health-error {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.6875rem;
  color: var(--danger);
}
.health-card > footer {
  display: flex;
  justify-content: flex-end;
  padding: 0.5rem 0.875rem;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 0.8125rem;
}
.health-card > footer a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 500;
}

/* Connections: every app's table shares one set of column widths, so the
   cards line up as you scroll down the page. */
table.conn-table {
  table-layout: fixed;
  min-width: 860px;
}
table.conn-table .c-name {
  width: 22%;
}
table.conn-table .c-host {
  width: 20%;
}
table.conn-table .c-num {
  width: 9%;
}
table.conn-table .c-rate {
  width: 10%;
}
table.conn-table .c-seen {
  width: 12%;
}
table.conn-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-health > header {
  padding: 0.875rem 16px;
}
/* =========================================================================
   One-line page subtitles and the info tip (any page): split from
   01-base.css to keep it small; it comes after it, so its rules still win.
   ========================================================================= */

/* Every page's subtitle is one line: a short sentence, with anything longer
   behind the info tip after it (.info-tip). A screen too narrow for the
   sentence ends it with an ellipsis rather than wrapping. */
.page-head > div:not([class]) {
  flex: 1 1 18rem;
  min-width: 0;
}
.page-head p,
.page-sub > span:first-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-head p.page-sub {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  overflow: visible;
}
.page-sub > span:first-child {
  min-width: 0;
}
/* A subtitle's tip opens under the whole header, from its left edge, so it
   stays on screen wherever the line ends. */
.page-head > div:not([class]) {
  position: relative;
}
.page-sub .info-tip {
  position: static;
}
.page-sub .info-tip-text {
  top: calc(100% + 6px);
  left: 0;
}

/* An info icon whose text shows on hover and on focus (a tap on a phone):
   pure CSS, so it works under the strict CSP, and the text stays in the page
   for screen readers. */
.info-tip {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  color: var(--text-muted);
  border-radius: 999px;
  cursor: help;
}
.info-tip:hover,
.info-tip:focus-visible {
  color: var(--brand);
  outline: none;
}
.info-tip:focus-visible {
  box-shadow: var(--focus-ring);
}
.info-tip-text {
  position: absolute;
  top: calc(100% + 8px);
  left: -12px;
  z-index: var(--z-popover);
  width: max-content;
  max-width: min(360px, 80vw);
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--surface);
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.5;
  white-space: normal;
  text-align: left;
  box-shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.25);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
  pointer-events: none;
}
/* For an icon near the right edge: the tip opens leftwards. */
.info-tip-text.tip-left {
  left: auto;
  right: -12px;
}
.info-tip:hover .info-tip-text,
.info-tip:focus .info-tip-text {
  opacity: 1;
  visibility: visible;
}
@media (prefers-reduced-motion: reduce) {
  .info-tip-text {
    transition: none;
  }
}
/* =========================================================================
   A person's page (templates/console/user_detail.html): the facts strip,
   sign-in attempts, second factors and the danger zone.
   ========================================================================= */

.person-id {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
}

/* The four facts a manager checks first, side by side. */
.person-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.fact {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.75rem 1rem;
  border-left: 1px solid var(--border);
}
.fact:first-child {
  border-left: 0;
}
.fact-label {
  font-size: 12px;
  color: var(--text-muted);
}
.fact strong {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 639px) {
  .person-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .fact:nth-child(odd) {
    border-left: 0;
  }
  .fact:nth-child(n + 3) {
    border-top: 1px solid var(--border);
  }
}

.label-with-tip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

/* A card body whose blocks are spaced evenly. */
.card-body.flow {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.card-body.flow > * {
  margin: 0;
}

.card.is-alert {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
}
.attempts {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
}
.attempts.is-locked {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
  background: var(--danger-soft);
}
.attempts strong {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}
.attempts form {
  margin: 0;
  flex: none;
}

.disclosure > summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
}
.disclosure > summary:hover {
  color: var(--text);
}

/* A short list of name and value, one line each. */
.factor-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.factor-list > li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4375rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.factor-list > li:last-child {
  border-bottom: 0;
}
.factor-list > li > span:last-child:not(.badge) {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12.5px;
}

.danger-card .card-head > .icon {
  color: var(--danger);
}

/* The audit tail in a narrow column: what happened and when on one line, then
   who, which app and from where as small labelled chips. */
.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.event-list > li {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.625rem 16px;
  border-bottom: 1px solid var(--border);
}
.event-list > li:last-child {
  border-bottom: 0;
}
.event-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}
.event-top strong {
  font-size: 13px;
  font-weight: 600;
}
.event-top time {
  flex: none;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.event-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  max-width: 100%;
  padding: 0.0625rem 0.4375rem;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-meta > span.mono {
  font-family: var(--font-mono);
}
.event-meta .icon {
  flex: none;
  opacity: 0.8;
}
/* =========================================================================
   The pager, one row under every list (templates/console/_pagination.html,
   design system 7): "Showing 1–50 from 300" on the left; first, previous,
   the page box "of N", next and last in the middle; rows per page on the
   right.
   ========================================================================= */

.pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.75rem 16px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text-muted);
}
.card-body > .pager {
  margin: 1rem -16px -16px;
}
.pager-count {
  font-variant-numeric: tabular-nums;
}

.pager-pages {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.pager-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  cursor: pointer;
}
a.pager-arrow:hover,
button.pager-arrow:hover {
  background: var(--surface-muted);
  text-decoration: none;
}
.pager-arrow.is-disabled {
  color: var(--placeholder);
  cursor: default;
}
.pager-arrow:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--brand);
}

.pager-box {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0.25rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pager-box input[type="number"] {
  width: 3rem;
  min-height: 30px;
  height: 30px;
  padding: 0 0.375rem;
  font-size: 13.5px;
  text-align: center;
  -moz-appearance: textfield;
}
.pager-box input::-webkit-inner-spin-button,
.pager-box input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pager-sizes {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 0.5rem;
  margin: 0;
  font-weight: 400;
  white-space: nowrap;
}
.pager-sizes select {
  width: auto;
  min-height: 30px;
  height: 30px;
  padding: 0 1.75rem 0 0.625rem;
  font-size: 13.5px;
}

@media (max-width: 767px) {
  .pager {
    grid-template-columns: 1fr auto;
    grid-template-areas: "count sizes" "pages pages";
  }
  .pager-count {
    grid-area: count;
  }
  .pager-sizes {
    grid-area: sizes;
  }
  .pager-pages {
    grid-area: pages;
    justify-self: center;
  }
  .pager-arrow {
    width: 40px;
    height: 40px;
  }
}
