/* Dashboard: app shell and shared components, direction "Console". Tokens, buttons, flash,
   footer and theme toggle come from tokens.css. Selectors that list an older class name next
   to a new one (.button, .form__control, .badge, .data-table, .panel-card...) keep pages that
   haven't moved yet looking right; new markup uses the first name. */

/* ---------- App shell: left sidebar, content column ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-3);
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.sidebar__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: 0 var(--s-1);
}

.sidebar__tools {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.sidebar .sidebar__menu-button {
  display: none;
}

/* The nav scrolls on its own so the account footer stays in view */
.sidebar__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

/* Which server the page is about */
.scope {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
  padding: var(--s-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.scope:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.scope__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-2);
  background: var(--text);
  color: var(--surface);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.scope__text {
  display: grid;
  min-width: 0;
}

.scope__name {
  overflow: hidden;
  font-size: var(--fs-sm);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scope__meta {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.scope__chevron {
  flex: none;
  margin-left: auto;
  color: var(--text-3);
}

.nav-group {
  flex: none;
  display: grid;
  gap: 1px;
}

/* Group headings carry an accent bar and a rule above, so a heading never reads as another link. */
.nav-group__title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0 var(--s-2) var(--s-1);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-2);
}

.nav-group__title::before {
  content: "";
  flex: none;
  width: 3px;
  height: 0.95em;
  border-radius: 2px;
  background: var(--accent);
}

.nav-group + .nav-group {
  padding-top: var(--s-2);
  border-top: 1px solid var(--line);
}

.nav-group__list {
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 30px;
  padding: 0 var(--s-2);
  border-radius: var(--r-2);
  color: var(--text-2);
  text-decoration: none;
  font-size: var(--fs-sm);
}

.nav-link:hover {
  background: var(--surface-3);
  color: var(--text);
}

.nav-link[aria-current="page"],
.nav-link--current {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.nav-link__icon {
  flex: none;
  width: 14px;
  height: 14px;
  color: var(--text-3);
}

.nav-link__count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.nav-link--sub {
  min-height: 26px;
  padding-left: var(--s-4);
  font-size: var(--fs-xs);
}

.nav-link__dot {
  width: 6px;
  height: 6px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--text-3);
}

.nav-link__count + .nav-link__dot {
  margin-left: 0;
}

.nav-link__dot--warn {
  background: var(--warn);
}

.nav-link__dot--danger {
  background: var(--danger);
}

.nav-link__dot--ok {
  background: var(--ok);
}

.sidebar__foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-1) 0;
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
}

.sidebar__user {
  display: grid;
  min-width: 0;
  line-height: 1.25;
}

.sidebar__user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar__user-level {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.sidebar__signout {
  margin: 0 0 0 auto;
}

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  object-fit: cover;
}

.avatar--lg {
  width: 44px;
  height: 44px;
  font-size: var(--fs-lg);
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.main__content {
  flex: 1 0 auto;
  width: 100%;
  min-width: 0;
  padding: var(--s-5) var(--s-6) 120px;
}

/* Page width: plain forms read best in a column. Tables, rosters and setting
   pages (which keep their text to 60ch in the intro column) take the whole width */
.panel-page {
  max-width: 64rem;
}

.panel-page--wide,
.panel-page:has(.setting-block) {
  max-width: none;
}

.main .site-footer__inner {
  max-width: none;
  margin: 0;
  padding: var(--s-3) var(--s-6);
}

/* The Message Builder brings its own grid */
.main__content.builder {
  max-width: none;
  margin: 0;
  padding: var(--s-5) var(--s-6) var(--s-7);
}

/* The mobile menu opens with a CSS-only checkbox */
.sidebar__toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sidebar__toggle:focus-visible + .sidebar__top .sidebar__menu-button {
  box-shadow: var(--focus);
}

/* ---------- Page header ---------- */

.page-head,
.panel-page__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-3) var(--s-5);
  padding-bottom: var(--s-4);
  margin-bottom: var(--s-5);
  border-bottom: 1px solid var(--line);
}

.page-head__text {
  display: grid;
  gap: var(--s-1);
  min-width: 0;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.crumbs a {
  color: var(--text-3);
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--accent);
}

.crumbs li + li::before {
  content: "/";
  margin-right: var(--s-1);
  color: var(--line-strong);
}

.page-title,
.panel-page__title {
  margin: 0;
  font-size: var(--fs-2xl);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.page-lead,
.panel-page__lead {
  max-width: 68ch;
  margin: 0;
  color: var(--text-2);
}

.panel-page__head > * {
  flex-basis: 100%;
}

.panel-page__back {
  margin: 0;
  font-size: var(--fs-sm);
}

.panel-page__back a {
  color: var(--text-3);
  text-decoration: none;
}

.panel-page__back a::before {
  content: "\2190\00a0";
}

.panel-page__back a:hover {
  color: var(--accent);
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-4);
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.page-meta__item {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
}

.page-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.flash-stack {
  display: grid;
  gap: var(--s-2);
  margin-bottom: var(--s-5);
}

.flash-stack .flash + .flash {
  margin-top: 0;
}

.main__content > .flash {
  margin-bottom: var(--s-5);
}

/* ---------- Panels: ruled blocks ---------- */

.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
}

.panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
}

.panel__title {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.005em;
}

.panel__text {
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.panel__body {
  display: grid;
  gap: var(--s-4);
  padding: var(--s-4);
}

.panel__body--flush {
  padding: 0;
}

.panel__foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-3) var(--r-3);
}

.panel--danger,
.panel-card--danger {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
}

/* Vertical rhythm for a run of panels */
.panel-stack {
  display: grid;
  gap: var(--s-4);
}

/* Settings section: description on the left, controls on the right */
.setting-block {
  display: grid;
  grid-template-columns: minmax(0, 17rem) minmax(0, 1fr);
  gap: var(--s-4) var(--s-6);
  padding: var(--s-5) 0;
  border-top: 1px solid var(--line);
  scroll-margin-top: var(--s-4);
}

.setting-block:first-child,
.page-head + .setting-block,
.flash-stack + .setting-block {
  border-top: 0;
  padding-top: 0;
}

.setting-block__intro {
  display: grid;
  align-content: start;
  gap: var(--s-2);
}

.setting-block__title {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 600;
}

.setting-block__text {
  color: var(--text-2);
  font-size: var(--fs-sm);
  max-width: 60ch;
}

.setting-block__body {
  min-width: 0;
  display: grid;
  gap: var(--s-4);
  align-content: start;
}

.sub-title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 600;
}

.sub-text {
  font-size: var(--fs-sm);
  color: var(--text-2);
}

/* Older card markup: same surface as a panel, padded body */
.panel-card {
  display: grid;
  gap: var(--s-3);
  min-width: 0;
  margin: 0 0 var(--s-4);
  padding: var(--s-4) var(--s-5) var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--surface);
  scroll-margin-top: var(--s-4);
}

.panel-card > * {
  min-width: 0;
}

.panel-card--narrow {
  max-width: 30rem;
  margin: var(--s-7) auto;
  justify-items: start;
}

.panel-card__title {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.005em;
}

.panel-card__subtitle {
  margin: var(--s-3) 0 0;
  font-size: var(--fs-md);
  font-weight: 600;
}

.panel-card__text {
  margin: 0;
  max-width: 72ch;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.panel-card__text--muted {
  color: var(--text-3);
}

.panel-card__list {
  display: grid;
  gap: var(--s-1);
  margin: 0;
  padding-left: 20px;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.panel-card .panel-card {
  margin: 0;
  padding: var(--s-4) 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: none;
}

.panel-card .panel-card .panel-card__title {
  font-size: var(--fs-md);
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

/* ---------- Form controls ---------- */

.form {
  display: grid;
  gap: var(--s-4);
  margin: 0;
  min-width: 0;
}

.form--inline {
  margin-top: var(--s-1);
}

.form .btn,
.form .button {
  justify-self: start;
}

.field-grid,
.form__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: var(--s-3) var(--s-4);
  min-width: 0;
}

.field,
.form__field {
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
}

.field--wide {
  grid-column: 1 / -1;
}

.label,
.form__label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
}

.hint,
.form__hint {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.field__error {
  font-size: var(--fs-xs);
  color: var(--danger);
}

.input,
.select,
.textarea,
.form__control {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  margin: 0;
  padding: 0 var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background: var(--surface);
  color: var(--text);
  font: var(--fs-sm) / 1.3 var(--font-sans);
}

.input--mono {
  font-family: var(--font-mono);
}

.textarea,
textarea.form__control {
  padding: var(--s-2) var(--s-3);
  min-height: 72px;
  line-height: 1.45;
  resize: vertical;
}

.form__control--tall {
  min-height: 12rem;
}

.select,
select.form__control:not([multiple]) {
  appearance: none;
  padding-right: 28px;
  background-image: url("icons/chevron.svg");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

select.form__control[multiple] {
  padding: var(--s-1);
}

.input::placeholder,
.textarea::placeholder,
.form__control::placeholder {
  color: var(--text-3);
}

.input:hover,
.select:hover,
.textarea:hover,
.form__control:hover {
  border-color: var(--text-3);
}

.input:focus,
.select:focus,
.textarea:focus,
.form__control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input:disabled,
.select:disabled,
.textarea:disabled,
.form__control:disabled {
  background: var(--surface-2);
  color: var(--text-3);
  cursor: not-allowed;
}

.input[aria-invalid="true"],
.form__control[aria-invalid="true"] {
  border-color: var(--danger);
}

.input--search {
  padding-left: 32px;
  background-image: url("icons/search.svg");
  background-repeat: no-repeat;
  background-position: 11px center;
}

/* Text box, optional role picker, button on one line; stacks on phones */
.add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 14rem) auto;
  align-items: end;
  gap: var(--s-3);
}

.add-row--two {
  grid-template-columns: minmax(0, 1fr) auto;
}

/* Fieldset with a legend, no browser chrome */
.fieldset,
.form__group {
  display: grid;
  gap: var(--s-2);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.fieldset__legend,
.form__legend {
  margin-bottom: 6px;
  padding: 0;
  font-size: var(--fs-sm);
  font-weight: 500;
}

.form__group {
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
}

/* Checkbox and switch with a label */
.check,
.form__check {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-2);
  cursor: pointer;
}

.check strong,
.form__check strong {
  color: var(--text);
  font-weight: 600;
}

.check > input[type="checkbox"]:not(.switch):not(.toggle),
.check > input[type="radio"],
.form__check > input[type="checkbox"]:not(.switch):not(.toggle),
.form__check > input[type="radio"],
.choice-list__item > input {
  width: 15px;
  height: 15px;
  margin: 2px 0 0;
  flex: none;
  accent-color: var(--accent);
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: var(--s-2) var(--s-4);
}

.switch,
.toggle {
  appearance: none;
  position: relative;
  flex: none;
  width: 30px;
  height: 18px;
  margin: 1px 0 0;
  border-radius: 9px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background-color 0.15s;
}

.switch::after,
.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 25%);
  transition: transform 0.15s;
}

.switch:checked,
.toggle:checked {
  background: var(--accent);
}

.switch:checked::after,
.toggle:checked::after {
  transform: translateX(12px);
}

.switch:disabled,
.toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.switch:focus-visible,
.toggle:focus-visible {
  box-shadow: var(--focus);
  border-radius: 9px;
}

/* Scrolling list of checkboxes (servers, permissions) */
.choice-list {
  display: grid;
  gap: 1px;
  max-height: 18rem;
  margin: 0;
  padding: var(--s-1);
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background: var(--surface);
  overscroll-behavior: contain;
}

.choice-list > .form__label,
.choice-list > legend {
  padding: var(--s-1) var(--s-2);
}

.choice-list__item {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  padding: 6px var(--s-2);
  border-radius: var(--r-1);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.choice-list__item:hover {
  background: var(--surface-3);
}

/* Segmented control for filters */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background: var(--surface-2);
}

.segmented__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 var(--s-2);
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--text-2);
  font: 500 var(--fs-sm) var(--font-sans);
  text-decoration: none;
  cursor: pointer;
}

.segmented__item:hover {
  color: var(--text);
}

.segmented__item[aria-pressed="true"],
.segmented__item[aria-current="page"],
.segmented__item[aria-current="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--line-strong);
}

.segmented__input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.segmented__item:has(.segmented__input:checked) {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--line-strong);
}

.segmented__item:has(.segmented__input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.segmented__item:has(.segmented__input:disabled) {
  cursor: default;
}

.segmented__count {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* ---------- Role and channel pickers (built by site.js from select[data-picker]) ---------- */

.picker {
  position: relative;
  min-width: 0;
}

.picker__native {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.picker__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  width: 100%;
  min-height: 32px;
  padding: 3px 28px 3px var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background: var(--surface) url("icons/chevron.svg") no-repeat right 10px center;
  color: var(--text);
  font: var(--fs-sm) / 1.3 var(--font-sans);
  text-align: left;
  cursor: pointer;
}

.picker__toggle:hover {
  border-color: var(--text-3);
}

.picker__toggle:focus-visible,
.picker__toggle[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  border-radius: var(--r-2);
}

.picker__value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker__value--chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  padding: 1px 0;
  white-space: normal;
}

.picker__value--empty {
  color: var(--text-3);
}

.picker__panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  z-index: 20;
  padding: var(--s-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

.picker__search {
  width: 100%;
  min-height: 30px;
  margin-bottom: var(--s-1);
  padding: 0 var(--s-2) 0 30px;
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  background: var(--surface-2) url("icons/search.svg") no-repeat 9px center;
  color: var(--text);
  font: var(--fs-sm) var(--font-sans);
}

.picker__search:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: none;
}

.picker__list {
  max-height: 16rem;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  overscroll-behavior: contain;
}

.picker__option {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 30px;
  padding: 0 var(--s-2);
  border-radius: var(--r-1);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.picker__option--active {
  background: var(--surface-3);
}

.picker__option[aria-selected="true"] {
  color: var(--accent);
  font-weight: 500;
}

.picker__swatch {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--role-colour, var(--text-3));
}

.picker__label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker__tick {
  flex: none;
  width: 14px;
  height: 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-1);
  background: var(--surface);
}

.picker__option[aria-selected="true"] .picker__tick {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 2px var(--surface);
}

.picker__empty {
  margin: 0;
  padding: var(--s-2);
  color: var(--text-3);
  font-size: var(--fs-sm);
}

/* Opened upwards when there's no room below (site.js picks the side) */
.picker__panel--up {
  top: auto;
  bottom: calc(100% + 4px);
}

/* Grouped pickers: a source (server, group or organisation) first, then what's in it */
.picker__source {
  background: url("icons/chevron.svg") no-repeat right 8px center / 10px;
  padding-right: 24px;
}

.picker__source .picker__label {
  font-weight: 500;
}

.picker__count {
  flex: none;
  min-width: 20px;
  padding: 0 5px;
  border-radius: var(--r-1);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--fs-xs);
  line-height: 18px;
  text-align: center;
}

.picker__back {
  display: block;
  width: 100%;
  min-height: 28px;
  margin-bottom: var(--s-1);
  padding: 0 var(--s-2);
  overflow: hidden;
  border: 0;
  border-radius: var(--r-1);
  background: transparent;
  color: var(--text-2);
  font: 500 var(--fs-xs) var(--font-sans);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.picker__back[hidden] {
  display: none;
}

.picker__back:hover,
.picker__back:focus-visible {
  background: var(--surface-2);
  color: var(--text);
}

.picker__where {
  display: none;
  flex: none;
  max-width: 45%;
  overflow: hidden;
  color: var(--text-3);
  font-size: var(--fs-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker__list--everywhere .picker__where {
  display: block;
}

/* ---------- Chips and status pills (.badge* are the older names) ---------- */

.chip,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-height: 20px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  vertical-align: middle;
}

.chip--ok,
.badge--success {
  border-color: transparent;
  background: var(--ok-soft);
  color: var(--ok);
}

.chip--warn,
.badge--warning {
  border-color: transparent;
  background: var(--warn-soft);
  color: var(--warn);
}

.chip--danger,
.badge--danger {
  border-color: transparent;
  background: var(--danger-soft);
  color: var(--danger);
}

.chip--accent {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
}

.badge--muted {
  color: var(--text-3);
}

.chip--dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
}

/* Discord role chip; set --role from JS or a role-colour class, inline styles are blocked by the CSP */
.role {
  --role: var(--text-3);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-height: 22px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 400;
  white-space: nowrap;
}

.role::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--role);
  flex: none;
}

.role__remove {
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
  margin-right: -2px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.role__remove:hover {
  background: var(--surface-3);
  color: var(--text);
}

/* ---------- Tables (.data-table* are the older names) ---------- */

.table-wrap {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
}

.panel-card > .table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--r-2);
}

.table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.table th,
.data-table th {
  height: 32px;
  padding: 0 var(--s-3);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.table td,
.data-table td {
  padding: 7px var(--s-3);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table td {
  vertical-align: top;
}

.table tbody tr:last-child td,
.data-table tbody tr:last-child td,
.data-table tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover td,
.data-table tbody tr:hover td {
  background: var(--surface-2);
}

.table__num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.table__when,
.data-table__when {
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-2);
}

.table__sub,
.data-table__id {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.table-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border-top: 1px solid var(--line);
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* Narrow screens: each row becomes a labelled block (put data-label on each td) */
@media (max-width: 760px) {
  .table--stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .table--stack,
  .table--stack tbody,
  .table--stack tr,
  .table--stack td {
    display: block;
  }

  .table--stack tr {
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--line);
  }

  .table--stack tbody tr:last-child {
    border-bottom: 0;
  }

  /* The label floats in the left padding, so a value made of several nodes
     (text, links, a block sub-line) stays together in the right column */
  .table--stack td {
    display: flow-root;
    padding: 3px 0;
    border: 0;
    overflow-wrap: anywhere;
  }

  .table--stack td[data-label] {
    padding-left: calc(7.5rem + var(--s-2));
  }

  .table--stack td[data-label]::before {
    content: attr(data-label);
    float: left;
    width: 7.5rem;
    margin-left: calc(-7.5rem - var(--s-2));
    padding-top: 1px;
    color: var(--text-3);
    font-family: var(--font-sans);
    font-size: var(--fs-xs);
    font-weight: 400;
    white-space: normal;
  }

  .table--stack th[scope="row"] {
    display: block;
    padding: 0 0 var(--s-1);
    border: 0;
    background: transparent;
    white-space: normal;
  }

  .table--stack tbody tr:hover td {
    background: transparent;
  }

  .chip,
  .badge {
    white-space: normal;
  }
}

/* ---------- Lists ---------- */

.row-list,
.people-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
}

.row-list__item,
.people-list__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1) var(--s-3);
  min-height: var(--row-h);
  padding: 6px var(--s-3);
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
}

.row-list__item:first-child,
.people-list__item:first-child {
  border-top: 0;
}

.row-list__name,
.people-list__name {
  min-width: 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.row-list__meta,
.people-list__id {
  min-width: 0;
  color: var(--text-3);
  font-size: var(--fs-xs);
  overflow-wrap: anywhere;
}

.people-list__id {
  font-family: var(--font-mono);
}

.row-list__end {
  display: flex;
  gap: var(--s-2);
  margin-left: auto;
}

.row-list__end form,
.people-list__item form {
  margin: 0 0 0 auto;
}

.row-list__end form {
  margin: 0;
}

.empty {
  margin: 0;
  padding: var(--s-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-2);
  color: var(--text-3);
  font-size: var(--fs-sm);
}

.empty__title {
  display: block;
  margin-bottom: 2px;
  color: var(--text-2);
  font-weight: 600;
}

/* Key and value pairs */
.kv {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 6px var(--s-3);
  margin: 0;
  font-size: var(--fs-sm);
}

.kv dt {
  color: var(--text-3);
}

.kv dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

/* Status grid: one cell per check (server health, sweep status) */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  overflow: hidden;
}

.status-grid__item {
  display: grid;
  gap: 2px;
  min-width: 0;
  margin: 0 -1px -1px 0;
  padding: var(--s-3);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
}

.status-grid__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  font-weight: 500;
}

.status-grid__text {
  color: var(--text-2);
  font-size: var(--fs-xs);
  overflow-wrap: anywhere;
}

.status-grid__item--problem {
  background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface));
}

/* Number tiles (.stat-row* are the older names) */
.stats,
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  gap: 0;
  margin: 0 0 var(--s-5);
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  overflow: hidden;
}

.stats__item,
.stat-row__item {
  display: grid;
  gap: 2px;
  margin: 0 -1px -1px 0;
  padding: var(--s-3) var(--s-4);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stats__value,
.stat-row__value {
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stats__label,
.stat-row__label {
  color: var(--text-3);
  font-size: var(--fs-xs);
}

/* ---------- Disclosure rows (.protection* are the older names) ---------- */

.disclosure {
  border-top: 1px solid var(--line);
}

.disclosure:first-child {
  border-top: 0;
}

.disclosure__summary,
.protection__summary {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-3);
  min-height: 40px;
  padding: 6px var(--s-3);
  cursor: pointer;
  list-style: none;
  font-size: var(--fs-sm);
}

.disclosure__summary::-webkit-details-marker,
.protection__summary::-webkit-details-marker {
  display: none;
}

.disclosure__summary:hover,
.protection__summary:hover {
  background: var(--surface-2);
}

.disclosure__caret {
  width: 10px;
  height: 10px;
  color: var(--text-3);
  transition: transform 0.15s;
}

.disclosure[open] > .disclosure__summary .disclosure__caret {
  transform: rotate(90deg);
}

.disclosure__body,
.protection__body {
  display: grid;
  gap: var(--s-4);
  padding: var(--s-2) var(--s-4) var(--s-4) calc(var(--s-3) + 16px + var(--s-3));
}

/* Older protection markup: caret drawn in CSS */
.protection {
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
}

.protection + .protection {
  margin-top: -1px;
}

.protection__summary {
  grid-template-columns: minmax(0, 1fr) auto 10px;
}

.protection__summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: rotate(-45deg);
  transition: transform 0.15s;
}

.protection[open] > .protection__summary::after {
  transform: rotate(45deg);
}

.protection__name {
  font-weight: 500;
}

.protection__body {
  padding-left: var(--s-3);
}

.protection__help {
  margin: 0;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.protection-group + .protection-group {
  margin-top: var(--s-5);
}

.protection-group__title {
  margin: var(--s-4) 0 2px;
  font-size: var(--fs-md);
  font-weight: 600;
}

.protection-group__text {
  margin: 0 0 var(--s-3);
  color: var(--text-2);
  font-size: var(--fs-sm);
}

/* ---------- Expected against actual: read like a plan diff ---------- */

.ledger {
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  overflow: hidden;
  font-size: var(--fs-sm);
}

.ledger__group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-1) var(--s-2);
  padding: 6px var(--s-3);
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  font-size: var(--fs-xs);
  color: var(--text-2);
}

.ledger__group:first-child {
  border-top: 0;
}

.ledger__group strong {
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
}

/* One server, group or organisation inside a platform: its name and counts, then its rows */
.ledger__scope {
  border-top: 1px solid var(--line);
}

.ledger__scope-head {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-2);
  min-height: 34px;
  padding: 4px var(--s-3);
  cursor: pointer;
  list-style: none;
}

.ledger__scope-head::-webkit-details-marker {
  display: none;
}

.ledger__scope-head:hover {
  background: var(--surface-2);
}

.ledger__scope-head .disclosure__caret {
  width: 10px;
  height: 10px;
  color: var(--text-3);
  transition: transform 0.15s;
}

.ledger__scope[open] > .ledger__scope-head .disclosure__caret {
  transform: rotate(90deg);
}

.ledger__scope-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger__row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  border-top: 1px solid var(--line);
}

.ledger__sign {
  align-self: stretch;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-3);
  border-right: 1px solid var(--line);
}

.ledger__item {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 6px var(--s-3);
}

.ledger__target {
  overflow-wrap: anywhere;
}

.ledger__why {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.ledger__state {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding-right: var(--s-3);
}

.ledger__state form {
  margin: 0;
}

.ledger__row--missing {
  background: color-mix(in srgb, var(--warn-soft) 55%, transparent);
}

.ledger__row--missing .ledger__sign {
  color: var(--warn);
  background: var(--warn-soft);
}

/* Waiting on them (an invite, joining a server): not something to fix here, so it stays quiet. */
.ledger__row--waiting .ledger__sign {
  color: var(--text-2);
  background: var(--surface-2);
}

.ledger__row--extra {
  background: color-mix(in srgb, var(--danger-soft) 55%, transparent);
}

.ledger__row--extra .ledger__sign {
  color: var(--danger);
  background: var(--danger-soft);
}

.ledger-key {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1) var(--s-3);
  margin-top: var(--s-2);
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.ledger-key .mono {
  color: var(--text-2);
}

/* ---------- Toast (site's toast.js adds __text and __close) ---------- */

.toast {
  position: fixed;
  top: var(--s-4);
  right: var(--s-4);
  z-index: 61;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: max-content;
  max-width: min(26rem, calc(100vw - 2 * var(--s-4)));
  margin: 0;
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  color: var(--text);
  font-size: var(--fs-sm);
  animation: popup-in 0.2s ease-out;
}

.toast::before {
  content: "";
  flex: none;
  width: 16px;
  height: 16px;
  background: var(--ok);
  -webkit-mask: url("icons/check.svg") center / 16px no-repeat;
  mask: url("icons/check.svg") center / 16px no-repeat;
}

.toast--error::before {
  background: var(--danger);
  -webkit-mask-image: url("icons/alert.svg");
  mask-image: url("icons/alert.svg");
}

.toast__text {
  flex: 1;
  min-width: 0;
}

/* ---------- Forms sent in the background (live-forms.js) ---------- */

form.is-submitting button[type="submit"]:disabled,
form.is-submitting button:not([type]):disabled {
  cursor: progress;
}

form.is-submitting {
  cursor: progress;
}

.toast__close {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--r-1);
  background: transparent;
  color: var(--text-3);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.toast__close:hover {
  background: var(--surface-3);
  color: var(--text);
}

/* ---------- Save bar (built by save-bar.js) ---------- */

.save-bar {
  position: fixed;
  bottom: var(--s-4);
  left: calc(var(--sidebar-w) + var(--s-6));
  right: var(--s-6);
  z-index: 60;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-3);
  background: var(--text);
  color: var(--surface);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-sm);
  animation: popup-in 0.2s ease-out;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.save-bar__text {
  margin: 0;
  font-weight: 500;
}

.save-bar__error {
  flex-basis: 100%;
  order: 3;
  margin: 0;
  color: color-mix(in srgb, var(--danger) 55%, var(--surface));
  font-size: var(--fs-xs);
}

.save-bar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.save-bar__button {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 var(--s-3);
  border: 1px solid color-mix(in srgb, var(--surface) 30%, transparent);
  border-radius: var(--r-2);
  background: transparent;
  color: var(--surface);
  font: 500 var(--fs-xs) / 1 var(--font-sans);
  cursor: pointer;
}

.save-bar__button:hover {
  background: color-mix(in srgb, var(--surface) 12%, transparent);
}

.save-bar__button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.save-bar__button--save {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
}

.save-bar__button--save:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.save-bar.save-bar--nudge {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px var(--danger), var(--shadow-pop);
  animation: save-bar-nudge 0.4s ease;
}

.save-bar--saved {
  border-color: var(--ok);
  background: var(--ok);
  color: var(--surface);
}

.save-bar--saved .save-bar__actions {
  display: none;
}

.toast--leaving,
.save-bar--leaving {
  animation: popup-out 0.2s ease-in forwards;
}

@keyframes save-bar-nudge {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@keyframes popup-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes popup-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(8px); }
}

/* reduced motion: tokens.css turns animations off; toast.js and save-bar.js wait for animationend,
   so keep a near-instant fade that still fires it */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="normal"]) .toast--leaving,
  :root:not([data-motion="normal"]) .save-bar--leaving {
    animation: popup-fade 0.01s linear forwards !important;
  }
}

@keyframes popup-fade {
  to { opacity: 0; }
}

/* ---------- Older page pieces, restyled until each page moves ---------- */

.server-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
  gap: var(--s-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.server-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-3);
  height: 100%;
  min-height: 64px;
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

a.server-card:hover {
  border-color: var(--accent-line);
  color: inherit;
}

.server-card__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-2);
  object-fit: cover;
}

.server-card__icon--initial {
  background: var(--text);
  color: var(--surface);
  font-size: var(--fs-md);
  font-weight: 600;
}

.server-card__name {
  font-weight: 500;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.server-card__status {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 6px;
  border-radius: var(--r-1);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 500;
}

.server-card__status--watching {
  background: var(--ok-soft);
  color: var(--ok);
}

.server-card__status--paused {
  background: var(--warn-soft);
  color: var(--warn);
}

.server-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-4);
  align-items: start;
}

.server-layout__content {
  min-width: 0;
}

.section-nav {
  min-width: 0;
}

.section-nav__list {
  display: flex;
  flex-wrap: wrap;
  gap: 1px var(--s-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.section-nav__link {
  display: flex;
  align-items: center;
  min-height: 28px;
  padding: 0 var(--s-2);
  border-radius: var(--r-2);
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-decoration: none;
  white-space: nowrap;
}

.section-nav__link:hover {
  background: var(--surface-3);
  color: var(--text);
}

.section-nav__link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

@media (min-width: 72rem) {
  .server-layout {
    grid-template-columns: 12rem minmax(0, 1fr);
    gap: var(--s-6);
  }

  .server-layout .section-nav {
    position: sticky;
    top: var(--s-5);
  }

  .server-layout .section-nav__list {
    flex-direction: column;
    flex-wrap: nowrap;
  }
}

.people-nav {
  margin-bottom: var(--s-4);
}

.check-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
}

.check-list__item {
  display: grid;
  grid-template-columns: 5rem 10rem minmax(0, 1fr);
  gap: 2px var(--s-3);
  align-items: baseline;
  padding: var(--s-2) var(--s-3);
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
}

.check-list__item:first-child {
  border-top: 0;
}

.check-list__item .badge {
  justify-self: start;
}

.check-list__label {
  font-weight: 500;
}

.check-list__text {
  color: var(--text-2);
  overflow-wrap: anywhere;
}

@media (max-width: 40rem) {
  .check-list__item {
    grid-template-columns: 5rem minmax(0, 1fr);
  }

  .check-list__text {
    grid-column: 1 / -1;
  }
}

.people-health .check-list__item {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.people-health .check-list__label {
  min-width: 14rem;
}

.rule-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
}

.rule-list__item {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3);
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
}

.rule-list__item:first-child {
  border-top: 0;
}

.rule-list__item form {
  margin: 0 0 0 auto;
}

.rule-list__body {
  min-width: 0;
}

.rule-list__trigger {
  margin: 0 0 2px;
}

.rule-list__response {
  margin: 0;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr));
  gap: var(--s-3);
  align-items: end;
  margin-bottom: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--surface);
}

.filter-bar__actions {
  display: flex;
  gap: var(--s-2);
}

.log-detail__summary {
  cursor: pointer;
}

.log-detail__fields {
  display: grid;
  gap: var(--s-1);
  margin: var(--s-2) 0 var(--s-1);
}

.log-detail__fields dt {
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.log-detail__fields dd {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.access-group + .access-group {
  margin-top: var(--s-2);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
}

.active-servers {
  display: grid;
  gap: var(--s-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.active-server {
  padding: var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--surface);
}

.active-server__head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-3);
}

.active-server__name {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.active-server__meta {
  margin: 2px 0 0;
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.active-server__link {
  margin: var(--s-3) 0 0;
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}

.active-server__leave {
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
}

.active-server__leave-toggle {
  width: fit-content;
  color: var(--danger);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
}

.active-server__leave-form {
  max-width: 32rem;
  margin-top: var(--s-3);
}

@media (max-width: 40rem) {
  .active-server__head {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .active-server__invite {
    grid-column: 1 / -1;
  }
}

.unapproved {
  margin-top: var(--s-6);
}

.unapproved__toggle {
  width: fit-content;
  margin-bottom: var(--s-3);
  font-size: var(--fs-lg);
  font-weight: 600;
  cursor: pointer;
}

.custom-access {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.custom-access__details {
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: 0 var(--s-3);
  background: var(--surface);
}

.custom-access__item + .custom-access__item .custom-access__details {
  margin-top: -1px;
}

.custom-access__details[open] {
  padding-bottom: var(--s-3);
}

.custom-access__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px var(--s-3);
  padding: var(--s-2) 0;
  font-size: var(--fs-sm);
  cursor: pointer;
  list-style: none;
}

.custom-access__summary::-webkit-details-marker {
  display: none;
}

.custom-access__details[open] > .custom-access__summary .disclosure__caret {
  transform: rotate(90deg);
}

.custom-access__name {
  font-weight: 500;
}

.custom-access__meta {
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.custom-access__details .form + .form {
  margin-top: var(--s-3);
}

.locked-note {
  margin: 0;
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.locked-area[inert],
.protection__body[inert] > :not(.locked-note) {
  opacity: 0.6;
}

.log-route {
  display: grid;
  gap: var(--s-3);
  margin: 0;
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
}

.log-route__title {
  margin: 0;
  padding: 0;
  font-size: var(--fs-sm);
  font-weight: 600;
}

.log-route__hint {
  margin: 0;
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.log-route__list {
  display: grid;
  gap: var(--s-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.log-route__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 16rem);
  align-items: center;
  gap: var(--s-3);
  font-size: var(--fs-sm);
}

.log-route__type {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

@media (max-width: 640px) {
  .log-route__row {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
}

[data-pre] {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

dialog.panel-card {
  max-width: min(40rem, calc(100vw - 2rem));
  max-height: 85vh;
  overflow: auto;
  color: var(--text);
  box-shadow: var(--shadow-pop);
}

.removal-dialog {
  position: fixed;
  inset: 0;
  width: min(32rem, calc(100vw - 2rem));
  height: fit-content;
  margin: auto;
}

.removal-dialog:not([open]) {
  display: none;
}

.removal-dialog .segmented {
  justify-self: start;
}

.removal-dialog .fieldset {
  display: grid;
  gap: var(--s-2);
}

dialog.panel-card::backdrop {
  background: rgb(10 12 16 / 50%);
}

[data-field-row] {
  align-items: center;
  margin-bottom: var(--s-2);
}

/* ---------- Settings: dashboard style picker (src/dashboard/settings) ---------- */

.skin-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--s-3);
  margin: 0;
  padding: 0;
  border: 0;
}

.skin-option {
  position: relative;
  display: grid;
  gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--surface);
  cursor: pointer;
}

.skin-option:hover {
  border-color: var(--line-strong);
}

.skin-option:has(.skin-option__input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.skin-option:has(.skin-option__input:focus-visible) {
  box-shadow: var(--focus);
}

.skin-option__input {
  position: absolute;
  top: var(--s-3);
  right: var(--s-3);
  margin: 0;
  accent-color: var(--accent);
}

/* A tiny drawing of each style, in its own fixed colours so it reads the same under either */
.skin-option__preview {
  display: grid;
  align-content: start;
  gap: 6px;
  height: 84px;
  padding: 10px;
  border-radius: var(--r-2);
}

.skin-option__bar,
.skin-option__line {
  display: block;
  height: 8px;
  border-radius: 2px;
}

.skin-option__line {
  width: 70%;
  height: 6px;
}

.skin-option__line--short {
  width: 45%;
}

.skin-option__preview--psitota {
  grid-template-columns: 28% 1fr;
  background: #eef0f3;
  border: 1px solid #dfe2e7;
  border-radius: 3px;
}

.skin-option__preview--psitota .skin-option__bar {
  grid-row: span 3;
  height: 100%;
  background: #ffffff;
  border-right: 1px solid #dfe2e7;
  border-radius: 0;
}

.skin-option__preview--psitota .skin-option__line {
  background: #c4c9d1;
}

.skin-option__preview--psitota .skin-option__bar + .skin-option__line {
  background: #1f55e0;
}

.skin-option__preview--phoenix {
  background: #090b10;
  border: 1px solid #222835;
  border-radius: 10px;
}

.skin-option__preview--phoenix .skin-option__bar {
  height: 14px;
  margin: -10px -10px 4px;
  background: #11141b;
  border-bottom: 2px solid #6e88ff;
  border-radius: 10px 10px 0 0;
}

.skin-option__preview--phoenix .skin-option__line {
  background: #333b4d;
  border-radius: 999px;
}

.skin-option__preview--phoenix .skin-option__bar + .skin-option__line {
  background: #6e88ff;
}

.skin-option__text {
  display: grid;
  gap: 2px;
}

.skin-option__name {
  font-weight: 600;
}

.skin-option__hint {
  color: var(--text-2);
  font-size: var(--fs-sm);
}

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

@media (max-width: 1080px) {
  .main__content,
  .main__content.builder {
    padding-left: var(--s-5);
    padding-right: var(--s-5);
  }

  .main .site-footer__inner {
    padding: var(--s-3) var(--s-5);
  }

  .save-bar {
    left: calc(var(--sidebar-w) + var(--s-5));
    right: var(--s-5);
  }

  .setting-block {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-3);
  }
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    z-index: 25;
    height: auto;
    max-height: 100vh;
    padding: var(--s-2) var(--s-4);
    border-right: 0;
    border-bottom: 1px solid var(--line);
    gap: 0;
  }

  .sidebar .sidebar__menu-button {
    display: inline-flex;
  }

  .sidebar__body,
  .sidebar__foot {
    display: none;
  }

  .sidebar:has(.sidebar__toggle:checked) .sidebar__body {
    display: flex;
    padding: var(--s-3) 0 var(--s-2);
  }

  .sidebar:has(.sidebar__toggle:checked) .sidebar__foot {
    display: flex;
    margin-top: var(--s-2);
    padding-bottom: var(--s-2);
  }

  .main {
    min-height: 0;
  }

  .main__content,
  .main__content.builder {
    padding: var(--s-4) var(--s-4) 140px;
  }

  .main .site-footer__inner {
    padding: var(--s-3) var(--s-4);
  }

  .save-bar {
    left: var(--s-4);
    right: var(--s-4);
    bottom: var(--s-3);
  }

  .toast {
    top: 60px;
    right: var(--s-4);
    left: var(--s-4);
    width: auto;
    max-width: none;
  }

  .page-title,
  .panel-page__title {
    font-size: 1.375rem;
  }

  .panel-card {
    padding: var(--s-4);
  }
}

@media (max-width: 760px) {
  .add-row,
  .add-row--two {
    grid-template-columns: minmax(0, 1fr);
  }

  .add-row > .btn,
  .add-row > .button {
    justify-self: start;
  }

  .disclosure__body {
    padding-left: var(--s-3);
  }

  .ledger__row {
    grid-template-columns: 26px minmax(0, 1fr);
  }

  .ledger__state {
    grid-column: 2;
    padding: 0 var(--s-3) 6px;
  }
}

/* ---------- Section: server settings and servers list (src/dashboard/server, src/dashboard/servers) ---------- */

/* The settings form wraps the General and Protections blocks; keep their top rule */
.settings-form > .setting-block:first-child {
  border-top: 1px solid var(--line);
  padding-top: var(--s-5);
}

/* A flash stack holding only a toast (which floats) takes no room */
.flash-stack:not(:has(> .flash)) {
  margin-bottom: 0;
}

.setting-stack {
  display: grid;
  gap: var(--s-4);
  min-width: 0;
}

/* Protection groups: a ruled box of disclosure rows under a shaded head */
.prot-group {
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  min-width: 0;
}

.prot-group + .prot-group {
  margin-top: var(--s-3);
}

.prot-group__head {
  display: grid;
  gap: 2px;
  padding: var(--s-3);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--r-2) var(--r-2) 0 0;
}

.prot-group__head + .disclosure {
  border-top: 0;
}

.prot-group__title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 600;
}

.prot-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px var(--s-3);
  min-width: 0;
}

.prot-name strong {
  font-weight: 500;
}

.prot-name span {
  min-width: 0;
  color: var(--text-3);
  font-size: var(--fs-xs);
  overflow-wrap: anywhere;
}

.prot-off .prot-name strong {
  color: var(--text-3);
}

.disclosure__body[inert] > :not(.locked-note) {
  opacity: 0.6;
}

/* Autoresponder rules */
.rule {
  display: grid;
  gap: 4px;
  padding: var(--s-3);
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
}

.rule:first-child {
  border-top: 0;
}

.rule__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}

.rule__trigger {
  min-width: 0;
  overflow-wrap: anywhere;
}

.rule__remove {
  margin: 0 0 0 auto;
}

.rule__reply {
  margin: 0;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.grant-remove {
  margin: 0;
}

/* Servers list: unapproved servers fold away under the main grid */
.unapproved__details {
  overflow: hidden;
}

.unapproved__details > .disclosure__summary {
  min-height: 44px;
  padding: var(--s-2) var(--s-4);
}

.unapproved__details .prot-name strong {
  font-size: var(--fs-md);
  font-weight: 600;
}

.unapproved__body {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-4) var(--s-4);
  border-top: 1px solid var(--line);
}

.server-card .chip {
  justify-self: end;
}

/* Active servers: the leave row runs the full width of the panel's foot */
.active-server__leave {
  margin: var(--s-4) calc(-1 * var(--s-4)) calc(-1 * var(--s-4));
  padding-top: 0;
}

.active-server__leave > .disclosure__summary {
  padding: 6px var(--s-4);
  border-radius: 0 0 var(--r-3) var(--r-3);
}

.active-server__leave[open] > .disclosure__summary {
  border-radius: 0;
}

.active-server__leave-form {
  margin-top: 0;
}

.active-server__name .chip {
  margin-left: var(--s-1);
}

/* ========== Section: Developers (src/dashboard/developers) ========== */

.dev-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.dev-panel-head {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.dev-panel-head .panel__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}

.dev-sub {
  display: grid;
  gap: var(--s-3);
  min-width: 0;
}

.dev-sub + .dev-sub {
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
}

.dev-sub__head {
  display: grid;
  gap: 2px;
}

.dev-table-box {
  border: 1px solid var(--line);
  border-radius: var(--r-2);
}

.dev-empty {
  padding: var(--s-4);
}

.dev-inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  margin: 0;
  min-width: 0;
}

.dev-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-2);
}

.dev-actions .dev-inline-form {
  flex-wrap: nowrap;
}

.dev-days {
  width: 4.5rem;
  min-height: 26px;
  padding: 0 var(--s-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

/* Roster: filters and the account column */
.dev-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--s-3);
  margin: 0;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
}

.dev-filters .field {
  flex: 1 1 10rem;
}

.dev-filters .dev-filters__search {
  flex: 2 1 16rem;
}

.dev-filters__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
  padding: var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.dev {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
}

.dev__name {
  display: grid;
  min-width: 0;
  line-height: 1.3;
}

.dev__name a {
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.dev__name a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.dev__name span {
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.roster tr.is-past .dev__name a {
  color: var(--text-2);
}

.accounts {
  display: grid;
  gap: 1px;
  min-width: 0;
  font-size: var(--fs-xs);
}

.acct {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--text-2);
}

.acct__icon {
  flex: none;
  width: 12px;
  height: 12px;
  color: var(--text-3);
}

.acct__value,
.acct__id {
  font-family: var(--font-mono);
  white-space: nowrap;
}

.acct__id {
  color: var(--text-3);
}

.acct--none .acct__value {
  color: var(--text-3);
  font-family: var(--font-sans);
  font-style: italic;
}

/* Developer page: record and extra access on the side, ledger and timeline in the main column */
.dev-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-4);
  align-items: start;
}

.dev-page__side,
.dev-page__main {
  min-width: 0;
}

/* A developer's open findings sit in the narrower main column, so they use
   the stacked layout until that column is wide enough for six columns */
.dev-page__main {
  container: dev-main / inline-size;
}

@container dev-main (max-width: 60rem) {
  .findings-table--side thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .findings-table--side,
  .findings-table--side tbody,
  .findings-table--side tr {
    display: block;
  }

  .findings-table--side tr {
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--line);
  }

  .findings-table--side tbody tr:last-child {
    border-bottom: 0;
  }

  .findings-table--side td {
    display: flow-root;
    padding: 3px 0;
    border: 0;
    overflow-wrap: anywhere;
  }

  .findings-table--side td[data-label] {
    padding-left: calc(7.5rem + var(--s-2));
  }

  .findings-table--side td[data-label]::before {
    content: attr(data-label);
    float: left;
    width: 7.5rem;
    margin-left: calc(-7.5rem - var(--s-2));
    padding-top: 1px;
    color: var(--text-3);
    font-family: var(--font-sans);
    font-size: var(--fs-xs);
    font-weight: 400;
    white-space: normal;
  }

  .findings-table--side td:not([data-label]) {
    padding-top: var(--s-2);
  }

  .findings-table--side tbody tr:hover td {
    background: transparent;
  }

  .findings-table--side .dev-actions {
    justify-content: flex-start;
  }
}

@media (min-width: 1240px) {
  .dev-page {
    grid-template-columns: minmax(0, 1fr) minmax(20rem, 26rem);
  }

  .dev-page__main {
    grid-column: 1;
    grid-row: 1;
  }

  .dev-page__side {
    grid-column: 2;
    grid-row: 1;
  }
}

.dev-narrow {
  max-width: 52rem;
}

.dev-form .fieldset + .fieldset {
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
}

.dev-form__note {
  align-self: end;
}

/* Who a typed username turned out to be (site.js fills these in). */
.dev-form .field-grid + .field-grid,
.dev-form .lookup-note + .field-grid {
  margin-top: var(--s-3);
}

.lookup-note {
  margin-top: var(--s-1);
}

.lookup-note:empty {
  display: none;
}

.lookup-note[data-tone="ok"] {
  color: var(--ok);
}

.lookup-note[data-tone="warn"] {
  color: var(--warn);
}

.lookup-note__choice {
  margin-top: var(--s-1);
}

.dev-edit {
  border: 1px solid var(--line);
  border-radius: var(--r-2);
}

.dev-edit > .disclosure__summary {
  font-weight: 500;
}

.dev-edit__body {
  padding: var(--s-3);
  border-top: 1px solid var(--line);
}

.dev-grants {
  display: grid;
  gap: var(--s-2);
}

.grant {
  display: grid;
  gap: 4px;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  font-size: var(--fs-sm);
}

.grant__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}

.grant__target {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.grant__reason {
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.grant__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

.grant__meta {
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.dev-grant-form {
  display: grid;
  gap: var(--s-3);
  margin: 0;
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
}

.ledger__row--none .ledger__item {
  padding-top: 8px;
  padding-bottom: 8px;
}

/* Timeline: typed marks (round = written by someone, square = written by the roster) */
.composer {
  display: grid;
  gap: var(--s-3);
  margin: 0;
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface-2);
}

.composer__row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--s-3);
}

.composer__kind {
  flex: 1 1 11rem;
  max-width: 16rem;
}

.composer__title {
  flex: 2 1 12rem;
}

.timeline {
  position: relative;
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 7px;
  width: 1px;
  background: var(--line);
}

.tl {
  position: relative;
  display: grid;
  grid-template-columns: 15px minmax(0, 1fr);
  gap: var(--s-3);
  padding: var(--s-2) 0;
}

.tl__mark {
  position: relative;
  z-index: 1;
  width: 15px;
  height: 15px;
  margin-top: 2px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--line-strong);
  box-shadow: 0 0 0 1px var(--line-strong);
}

.tl--auto .tl__mark {
  border-radius: 3px;
  background: var(--surface-3);
  box-shadow: 0 0 0 1px var(--text-3);
}

.tl--discipline .tl__mark {
  background: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}

.tl--warn .tl__mark {
  background: var(--warn);
  box-shadow: 0 0 0 1px var(--warn);
}

.tl--good .tl__mark {
  background: var(--ok);
  box-shadow: 0 0 0 1px var(--ok);
}

.tl--removed .tl__mark {
  background: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}

.tl--removed .tl__heading {
  color: var(--danger);
}

.tl__body {
  display: grid;
  gap: 4px;
  min-width: 0;
  font-size: var(--fs-sm);
}

.tl__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px var(--s-2);
}

.tl__heading {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tl--auto .tl__heading {
  color: var(--text-2);
  font-weight: 500;
}

.tl__who {
  color: var(--text-2);
}

.tl__when {
  margin-left: auto;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.tl__note {
  padding: var(--s-2) var(--s-3);
  border-left: 2px solid var(--line);
  border-radius: 0 var(--r-1) var(--r-1) 0;
  background: var(--surface-2);
  color: var(--text);
  overflow-wrap: anywhere;
}

.tl__auto {
  color: var(--text-2);
  overflow-wrap: anywhere;
}

/* Access map: one-line edit rows for ranks, teams and targets */
.dev-item {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  scroll-margin-top: var(--s-4);
}

.dev-row-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  margin: 0;
  min-width: 0;
}

.dev-row-form > .input,
.dev-row-form > .select {
  width: auto;
}

.dev-row-form__name {
  flex: 1 1 10rem;
}

.dev-row-form__num {
  flex: 0 0 5rem;
  font-family: var(--font-mono);
}

.dev-row-form__grow {
  flex: 2 1 12rem;
}

.dev-row-form__level {
  flex: 1 1 10rem;
}

.dev-row-form--add {
  padding: var(--s-3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-2);
}

.dev-gives {
  display: grid;
  gap: var(--s-2);
  padding-left: var(--s-3);
  border-left: 2px solid var(--line);
}

.dev-gives__label {
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 500;
}

.dev-confirm-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--s-3);
  margin: 0;
}

.dev-confirm-form .field {
  flex: 1 1 16rem;
  max-width: 24rem;
}

@media (max-width: 760px) {
  .acct__value,
  .acct__id {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .roster td[data-label="Developer"] {
    padding-left: 0;
    padding-bottom: 6px;
  }

  .roster td[data-label="Developer"]::before {
    display: none;
  }

  .dev-actions {
    justify-content: flex-start;
  }

  .tl__when {
    width: 100%;
    margin-left: 0;
  }

  .composer__kind {
    max-width: none;
  }

  .dev-row-form > .input,
  .dev-row-form > .select {
    flex-basis: 100%;
  }

  .dev-row-form > .dev-row-form__num {
    flex: 0 0 6rem;
  }
}

/* ========== End of section: Developers ========== */

/* ========== Section: Network and Logs ========== */

/* Network: the number tiles sit straight above the first settings block */
.stat-row + .setting-block {
  border-top: 0;
  padding-top: 0;
}

/* A second group inside one settings block, such as Global Actions' command roles */
.network-subsection {
  display: grid;
  gap: var(--s-3);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
}

.custom-access__facts {
  margin: var(--s-1) 0 var(--s-3);
}

.linked-role-form,
.logs-clear {
  max-width: 40rem;
}

/* Logs: filters, table and paging share one panel */
.logs-panel .filter-bar {
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: var(--r-3) var(--r-3) 0 0;
  background: transparent;
}

.logs-panel > .table-wrap {
  border-radius: 0;
}

.logs-panel .table-foot {
  min-height: 44px;
}

.logs-panel + .logs-clear {
  margin-top: var(--s-5);
}

.log-table td:last-child {
  min-width: 14rem;
}

.log-table .log-detail__summary {
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .log-table td:last-child {
    min-width: 0;
  }
}

/* ========== End of section: Network and Logs ========== */

/* ========== Developer page: Network roles ========== */

.netroles {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  overflow: hidden;
}

.netroles__server {
  display: grid;
  gap: var(--s-2);
  padding: var(--s-3);
  border-top: 1px solid var(--line);
}

.netroles__server:first-child {
  border-top: 0;
}

.netroles__server--absent,
.netroles__server--unknown {
  background: var(--surface-2);
}

.netroles__server--absent .netroles__name,
.netroles__server--unknown .netroles__name {
  color: var(--text-3);
}

.netroles__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1) var(--s-2);
}

.netroles__name {
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.netroles__count {
  margin-left: auto;
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.netroles__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.netroles__role {
  padding-right: 2px;
}

.netroles__role--locked {
  padding-right: 6px;
  opacity: 0.75;
}

.netroles__tag {
  padding: 0 4px;
  border-radius: var(--r-1);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 0.6875rem;
  line-height: 16px;
}

.netroles__take {
  display: contents;
}

.netroles__x {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: var(--r-1);
  background: transparent;
  color: var(--text-3);
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1;
  cursor: pointer;
}

.netroles__x:hover,
.netroles__x:focus-visible {
  background: var(--danger-soft);
  color: var(--danger);
}

.netroles__give {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  margin: 0;
}

.netroles__pick {
  flex: 1 1 14rem;
  min-width: 0;
}

/* ---------- Access map grid ---------- */

.access-tabs {
  margin-bottom: var(--s-4);
}

/* The grid scrolls sideways inside its panel; the rank and team names stay in view. The form is a
   grid item, so it needs min-width: 0 or the table would widen the whole page. */
.matrix-form {
  min-width: 0;
}

.matrix-wrap {
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
}

.matrix {
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}

.matrix th,
.matrix td {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.matrix__corner,
.matrix__owner {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 11rem;
  max-width: 16rem;
  padding: 6px var(--s-3);
  border-right: 1px solid var(--line);
  text-align: left;
  font-weight: 500;
}

.matrix__name {
  display: block;
  overflow-wrap: anywhere;
}

.matrix__includes {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  margin-top: 2px;
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 400;
  cursor: pointer;
}

.matrix__group {
  padding: 6px var(--s-3);
  border-left: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.matrix__col {
  min-width: 4.5rem;
  max-width: 9rem;
  padding: 6px var(--s-2);
  border-left: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-align: center;
  vertical-align: bottom;
}

.matrix__col-label {
  display: block;
  overflow-wrap: anywhere;
}

.matrix__remove {
  margin-top: 2px;
  padding: 0 6px;
  border: 0;
  border-radius: var(--r-1);
  background: transparent;
  color: var(--text-3);
  font-size: var(--fs-sm);
  line-height: 1.4;
  cursor: pointer;
}

.matrix__remove:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Under a column's name: whether it's shared (given, never taken) or roster only, and remove */
.matrix__col-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin-top: 2px;
}

.matrix__col-tools .matrix__remove {
  margin-top: 0;
}

/* A team community records can be on, next to its name on the map */
.matrix__community {
  display: block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
}

.matrix__needs {
  color: var(--text-3);
}

.dev-row-form__check {
  flex: none;
  white-space: nowrap;
}

/* Who keeps a column's access: a small pill-shaped picker (a plain pill when it can't be changed).
   Current is the quiet default; Roster and Shared stand out, since they reach past the developers. */
.matrix__mode {
  max-width: 100%;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-3);
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
}

select.matrix__mode {
  appearance: none;
  padding-right: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2.5 4l2.5 2.5L7.5 4' fill='none' stroke='%23888' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  background-size: 9px;
  cursor: pointer;
}

select.matrix__mode:hover,
select.matrix__mode:focus-visible {
  border-color: var(--line-strong);
  color: var(--text-2);
}

select.matrix__mode:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.matrix__mode--roster,
select.matrix__mode--roster:hover,
select.matrix__mode--roster:focus-visible {
  border-color: var(--accent);
  background-color: var(--accent-soft);
  color: var(--accent);
}

.matrix__mode--shared,
select.matrix__mode--shared:hover,
select.matrix__mode--shared:focus-visible {
  border-color: var(--warn);
  background-color: var(--warn-soft);
  color: var(--warn);
}

.matrix-key .matrix__mode {
  display: inline-block;
}

/* "+" on a server, group or organisation: opens Add access already looking at it */
.matrix__add {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: var(--s-1);
  border-radius: var(--r-1);
  color: var(--text-3);
  font-size: var(--fs-sm);
  line-height: 1;
  text-decoration: none;
  vertical-align: middle;
}

.matrix__add:hover,
.matrix__add:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
}

.matrix__cell,
.matrix__count {
  border-left: 1px solid var(--line);
  text-align: center;
}

/* The grid's marks. Gives it: a solid box with a white tick. From the rank below: a dashed box,
   tinted, with a coloured tick, so it reads as set but plainly isn't this rank's own. Doesn't give
   it: an empty box. The key under the grid draws the same marks with .matrix__mark. */
.matrix__cell input,
.matrix__mark {
  display: block;
  flex: none;
  width: 18px;
  height: 18px;
  margin: 7px auto;
  border: 1.5px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
}

.matrix__cell input {
  appearance: none;
  cursor: pointer;
  transition: background-color 0.1s, border-color 0.1s;
}

.matrix__cell input:hover {
  border-color: var(--accent);
}

.matrix__cell input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.matrix__cell input:disabled {
  cursor: default;
}

.matrix__cell input:checked,
.matrix__mark--given {
  border-color: var(--accent);
  background: var(--accent) url("icons/tick.svg") no-repeat center / 12px;
}

.matrix__mark--included {
  position: relative;
  border-style: dashed;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.matrix__mark--included::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  mask: url("icons/tick.svg") no-repeat center / 12px;
}

.matrix__cell--included {
  cursor: help;
}

/* Ticked or unticked since the last save (site.js marks it) */
.matrix__cell--changed {
  background: var(--warn-soft) !important;
}

.matrix__cell--changed input {
  box-shadow: 0 0 0 2px var(--warn);
}

.matrix__mark--changed {
  border-color: var(--warn);
  background: var(--warn-soft);
}

/* The row and column under the pointer (site.js marks the column) */
.matrix tbody tr:not(.matrix__section):hover > td,
.matrix tbody tr:not(.matrix__section):hover > th,
.matrix .matrix__cell--col,
.matrix th.matrix__col--col {
  background: var(--surface-2);
}

.matrix-key {
  align-items: center;
}

.matrix-key > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.matrix-key .matrix__mark {
  width: 14px;
  height: 14px;
  margin: 0;
  background-size: 9px;
}

.matrix-key .matrix__mark--included::after {
  mask-size: 9px;
}

.matrix__section th {
  position: sticky;
  left: 0;
  padding: 4px var(--s-3);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.matrix tfoot th,
.matrix tfoot td {
  border-bottom: 0;
  background: var(--surface-2);
}

.matrix__count {
  padding: 6px var(--s-2);
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

.matrix__count--ok {
  color: var(--ok);
}

.matrix__count--off {
  color: var(--warn);
}

.matrix__save {
  margin-top: var(--s-3);
}

/* ---------- Settings page controls ---------- */

.pref-form {
  display: grid;
}

.pref-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: var(--s-2);
  margin: 0;
  padding: 0;
  border: 0;
}

.pref-swatch {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.pref-swatch:hover {
  border-color: var(--line-strong);
}

.pref-swatch:has(.pref-swatch__input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.pref-swatch:has(.pref-swatch__input:focus-visible) {
  box-shadow: var(--focus);
}

.pref-swatch__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Each swatch shows its light and dark shade side by side */
.pref-swatch__colour {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--swatch-light) 50%, var(--swatch-dark) 50%) no-repeat;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 12%);
}

.pref-swatch__colour--vertex-blue { --swatch-light: #1f55e0; --swatch-dark: #7d9cff; }
.pref-swatch__colour--rose { --swatch-light: #c2255c; --swatch-dark: #f783ac; }
.pref-swatch__colour--tangerine { --swatch-light: #c9480c; --swatch-dark: #ffa94d; }
.pref-swatch__colour--pine { --swatch-light: #2b7a3b; --swatch-dark: #69db7c; }
.pref-swatch__colour--amethyst { --swatch-light: #6741d9; --swatch-dark: #b197fc; }
.pref-swatch__colour--ocean { --swatch-light: #0b7285; --swatch-dark: #66d9e8; }
.pref-swatch__colour--graphite { --swatch-light: #495057; --swatch-dark: #ced4da; }

.pref-choices {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  justify-self: start;
  margin: 0;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface-2);
}

.pref-choices__item {
  position: relative;
}

.pref-choices__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pref-choices__label {
  display: block;
  padding: 5px var(--s-3);
  border-radius: var(--r-1);
  color: var(--text-2);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.pref-choices__label:hover {
  color: var(--text);
}

.pref-choices__input:checked + .pref-choices__label {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--line-strong);
}

.pref-choices__input:focus-visible + .pref-choices__label {
  box-shadow: var(--focus);
}

.pref-form__select {
  justify-self: start;
  width: auto;
  min-width: 14rem;
}

.pref-form__field {
  justify-self: start;
  width: min(100%, 20rem);
  margin-top: var(--s-3);
}

.pref-form__field .picker,
.pref-form__field .pref-form__select {
  width: 100%;
}

.pref-form__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line);
}

/* Phoenix's page sidebar; Psitota shows the same links in its own sidebar */
.page-nav {
  display: none;
}

/* Previews for text size and density. They show the picked option at its real size, so the root
   scale from the saved text size (prefs.css) is divided back out with --preview-root. */
.pref-preview {
  --preview-scale: 1;
  --preview-root: 1;
  max-width: 30rem;
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--surface);
}

.pref-preview--text {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  font-size: calc(var(--fs-md) * var(--preview-scale) / var(--preview-root));
}

.pref-preview__title {
  margin: 0;
  font-size: 1.15em;
  font-weight: 600;
}

.pref-preview__text {
  margin: 0;
  color: var(--text-2);
}

.pref-preview--text[data-value="small"] { --preview-scale: 0.9375; }
.pref-preview--text[data-value="large"] { --preview-scale: 1.125; }
.pref-preview--text[data-value="larger"] { --preview-scale: 1.25; }

:root[data-text-size="small"] .pref-preview { --preview-root: 0.9375; }
:root[data-text-size="large"] .pref-preview { --preview-root: 1.125; }
:root[data-text-size="larger"] .pref-preview { --preview-root: 1.25; }

.pref-preview--density {
  --preview-row: 36px;
  --preview-pad: 12px;
  display: grid;
  padding: 4px var(--preview-pad);
  font-size: calc(var(--fs-sm) / var(--preview-root));
}

.pref-preview__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--preview-row);
  margin: 0;
  border-top: 1px solid var(--line);
}

.pref-preview__row:first-child {
  border-top: 0;
}

.pref-preview__count {
  color: var(--text-3);
  font-family: var(--font-mono);
}

.pref-preview--density[data-value="compact"] { --preview-row: 30px; --preview-pad: 10px; }
.pref-preview--density[data-value="comfortable"] { --preview-row: 42px; --preview-pad: 14px; }

.mod-roster__accounts {
  width: 250px;
}

/* The icon sits outside the text, so an ID that wraps lines up under the username, not the icon. */
.roster .acct {
  position: relative;
  flex-wrap: wrap;
  column-gap: 6px;
  row-gap: 0;
  padding-left: 18px;
}

.roster .acct__icon {
  position: absolute;
  top: 0.2em;
  left: 0;
}

.mod-form {
  display: grid;
  gap: var(--s-4);
}

.mod-stack {
  display: grid;
  gap: var(--s-4);
}

/* Add forms that take several rows at once (repeat-rows.js) */
.dev-add-rows {
  display: grid;
  gap: var(--s-2);
  margin: 0;
}

.mod-new-row {
  display: grid;
  gap: var(--s-3);
  min-width: 0;
  margin: 0;
  padding: 0 0 var(--s-4);
  border: 0;
  border-bottom: 1px solid var(--line);
}

.mod-new-row .lookup-note:empty {
  display: none;
}

.mod-tier th {
  padding-top: var(--s-4);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: left;
}

/* The "this page is out of date" notice (update-notice.js), top middle */
.update-notice {
  position: fixed;
  top: var(--s-3);
  left: 50%;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  max-width: calc(100vw - 2 * var(--s-3));
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-3);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-sm);
  transform: translateX(-50%);
  animation: update-notice-in 0.2s ease-out;
}

.update-notice__button {
  padding: 4px var(--s-3);
  border: 0;
  border-radius: var(--r-2);
  background: var(--accent);
  color: var(--accent-fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.update-notice__close {
  border: 0;
  background: none;
  color: var(--text-3);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

@keyframes update-notice-in {
  from { opacity: 0; transform: translate(-50%, -6px); }
}

/* Room for a typical username on one line; a very long one is cut short rather than widening the table. */
.roster th:first-child,
.roster td:first-child {
  width: 230px;
  max-width: 230px;
}

.roster .dev__name a,
.roster .dev__name span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow-wrap: normal;
}

@media (max-width: 760px) {
  .roster th:first-child,
  .roster td:first-child {
    width: auto;
    max-width: none;
  }
}

.mod-roster__tools {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.mod-roster--editing .input,
.mod-roster--editing .select {
  width: 100%;
  min-height: 30px;
  font-size: var(--fs-sm);
}

.mod-roster--editing .dev__name {
  flex: 1;
  min-width: 0;
}

/* Editing needs room for its fields: below that the table scrolls sideways inside the panel
   rather than squeezing them into each other. The form is the panel's grid item, so it has to be
   allowed to shrink for the scroll to happen. */
.mod-roster__form {
  min-width: 0;
}

.mod-roster--editing {
  min-width: 800px;
}

.mod-roster--editing td .input,
.mod-roster--editing td .select {
  max-width: 100%;
}

.mod-roster__save {
  margin-top: var(--s-4);
}

.team-pick {
  gap: 6px;
  cursor: pointer;
}

.team-pick input {
  margin: 0;
  accent-color: var(--accent);
}

.chip-list > .team-pick:has(input:not(:checked)) span {
  color: var(--text-3);
  text-decoration: line-through;
}

.team-add[open] {
  flex-basis: 100%;
}

.team-add__toggle {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: 999px;
  color: var(--text-2);
  font-weight: 600;
  line-height: 1;
  list-style: none;
  cursor: pointer;
}

.team-add__toggle::-webkit-details-marker {
  display: none;
}

.team-add__toggle:hover,
.team-add[open] .team-add__toggle {
  border-style: solid;
  color: var(--accent);
}

.team-add__menu {
  display: grid;
  margin-top: 4px;
  gap: 4px;
  min-width: 190px;
  padding: var(--s-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface-2);
}

.mod-roster--editing td[data-label="Rank"] .select {
  min-width: 170px;
}

.mod-roster--editing td[data-label="Status"] .select {
  min-width: 115px;
}

.leave {
  position: relative;
  display: inline-flex;
  border-radius: 999px;
  cursor: help;
}

.leave:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.leave__card {
  position: absolute;
  z-index: 30;
  top: 50%;
  right: calc(100% + 8px);
  display: none;
  gap: 2px;
  min-width: max-content;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.2);
  color: var(--text);
  font-size: var(--fs-xs);
  transform: translateY(-50%);
}

.leave:hover .leave__card,
.leave:focus .leave__card {
  display: grid;
}

.leave-dates {
  display: none;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

td:has(option[value="loa"]:checked) .leave-dates,
.field-grid:has(select[name="status"] option[value="loa"]:checked) .leave-dates {
  display: grid;
}

/* Wide enough for the whole date and the calendar button at any text size, so the year is never cut off. */
.input[type="date"] {
  min-width: 11.5em;
  font-variant-numeric: tabular-nums;
}

.mod-roster--editing td[data-label="Status"] {
  min-width: 13em;
}

.mod-roster--editing td .input[type="date"] {
  width: 100%;
  min-width: 0;
}

.field-grid .leave-dates {
  grid-column: 1 / -1;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 0;
}

.chip--gold {
  border-color: transparent;
  color: var(--text);
  background: color-mix(in srgb, #d4a017 34%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #d4a017 60%, transparent);
}

.team-groups {
  display: grid;
  gap: var(--s-3);
}

.team-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.team-group__title {
  margin: 0 0 4px;
  padding: 0;
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.team-add__menu .team-group__title:not(:first-child) {
  margin-top: 6px;
}

/* Every row has room for a two-line rank name, so the rows line up at one height. */
.mod-rank {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.mod-roster:not(.mod-roster--editing) tbody tr:not(.mod-tier) td {
  height: 58px;
}

@media (max-width: 760px) {
  .mod-roster:not(.mod-roster--editing) tbody tr:not(.mod-tier) td {
    height: auto;
  }
}

.dev-row-form__colour input {
  width: 44px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background: var(--surface);
  cursor: pointer;
}

.flag-exempt {
  display: grid;
  gap: var(--s-3);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.flag-exempt__title {
  padding: 0;
  margin-bottom: var(--s-1);
}

.action-menu {
  position: relative;
}

.action-menu__toggle {
  list-style: none;
}

.action-menu__toggle::-webkit-details-marker {
  display: none;
}

.action-menu__toggle::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.action-menu__list {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 200px;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface-2);
}

.action-menu__item {
  display: block;
  padding: 6px var(--s-3);
  border-radius: var(--r-1);
  color: var(--text);
  font-size: var(--fs-sm);
  text-decoration: none;
}

.action-menu__item:hover,
.action-menu__item:focus-visible {
  background: var(--surface-3);
}

/* ---------- Trial Moderator Induction ---------- */

.induction__regions {
  flex-wrap: nowrap;
  margin: 0;
  min-width: 0;
  white-space: nowrap;
}

.induction__submit {
  margin-top: var(--s-3);
}

.induction {
  min-width: 0;
}

.induction__table td {
  vertical-align: middle;
}

.induction__table .input {
  width: 100%;
  min-width: 8em;
}

@media (max-width: 640px) {
  .induction__regions {
    flex-wrap: wrap;
  }
}

.induction__checks {
  flex-wrap: wrap;
  max-width: 16em;
}

.induction__checks .chip {
  white-space: normal;
}

.induction__check-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

.induction__missing {
  flex-basis: 100%;
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.induction__actions {
  margin-top: var(--s-3);
}

.induction__names,
.induction__announcement {
  width: 100%;
}

.induction__history {
  display: grid;
  gap: var(--s-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.induction__intake-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  margin: 0 0 var(--s-1);
}

.induction__regions-list {
  margin: 0;
  padding-left: var(--s-4);
  color: var(--text-2);
  font-size: var(--fs-sm);
}

/* ---------- Moderators overview ---------- */

.stat-table {
  width: 100%;
  max-width: 34rem;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.stat-table__caption {
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-2) var(--r-2) 0 0;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-align: center;
}

.stat-table th,
.stat-table td {
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line);
}

.stat-table th {
  font-weight: 600;
  text-align: left;
}

.stat-table th a {
  color: inherit;
}

.stat-table__value {
  width: 28%;
  font-family: var(--font-mono);
  text-align: center;
}

.stat-table__value--short {
  color: var(--warn);
}

.stat-table__sub th {
  padding-left: var(--s-4);
  color: var(--text-2);
  font-weight: 500;
}

.region-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--s-3);
}

.region-card {
  display: grid;
  gap: var(--s-2);
  align-content: start;
  padding: var(--s-3);
  border: 1px solid color-mix(in srgb, var(--team-colour, var(--line-strong)) 55%, var(--line));
  border-top: 4px solid var(--team-colour, var(--line-strong));
  border-radius: var(--r-2);
  background: color-mix(in srgb, var(--team-colour, var(--line-strong)) 8%, var(--surface));
}

.region-card__title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 700;
}

/* The whole top of the card opens the region on the roster. */
.region-card__link {
  display: block;
  margin: calc(var(--s-3) * -1) calc(var(--s-3) * -1) 0;
  padding: var(--s-3);
  border-radius: var(--r-1) var(--r-1) 0 0;
  color: inherit;
  font-weight: inherit;
  text-decoration: none;
}

.region-card__link:hover {
  background: color-mix(in srgb, var(--team-colour, var(--line-strong)) 16%, transparent);
}

.region-card__link:focus-visible {
  outline: 2px solid var(--team-colour, var(--accent));
  outline-offset: -2px;
}

.region-card .stat-table {
  max-width: none;
}

.region-card .stat-table th,
.region-card .stat-table td {
  border-color: color-mix(in srgb, var(--team-colour, var(--line-strong)) 35%, var(--line));
}

.region-card__lead {
  margin: 0;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.region-targets {
  margin-top: var(--s-4);
}

.region-targets__form {
  margin-top: var(--s-2);
}

.region-targets__toggle {
  list-style: none;
}

.region-targets__toggle::-webkit-details-marker {
  display: none;
}

/* ---------- Moderation access map ---------- */

.mod-access th[scope="col"] {
  vertical-align: bottom;
}

.mod-access__source,
.mod-access__target {
  display: block;
}

.mod-access__source {
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 500;
}

.table .mod-access__col {
  min-width: 8rem;
  max-width: 12rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

.mod-access__cell {
  text-align: center;
}

.mod-access-form {
  min-width: 0;
}

.mod-access__save {
  margin-top: var(--s-3);
}

.mod-access__tick {
  display: inline-flex;
  padding: var(--s-1);
  cursor: pointer;
}

.mod-access__first-team th,
.mod-access__first-team td {
  border-top: 2px solid var(--line-strong);
}

/* Role names carry their server, so the add form gives each picker the full width and lets long names wrap. */
.mod-access-add {
  grid-template-columns: 1fr;
}

.mod-access-add .picker__label {
  white-space: normal;
  overflow-wrap: anywhere;
}

/* The pinned scrollbar under a wide access map (site.js); the table's own one is hidden while it shows. */
.matrix-scroll {
  position: sticky;
  bottom: 0;
  z-index: 3;
  max-width: 100%;
  height: 16px;
  margin-top: -1px;
  overflow-x: scroll;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 0 0 var(--r-2) var(--r-2);
  background: var(--surface-2);
  scrollbar-color: var(--line-strong) transparent;
}

.matrix-scroll[hidden] {
  display: none;
}

.matrix-scroll__track {
  height: 1px;
}

.matrix-wrap--pinned {
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
  scrollbar-width: none;
}

.matrix-wrap--pinned::-webkit-scrollbar {
  display: none;
}

.panel__head:last-child {
  border-bottom: 0;
}

/* ---------- Debug mode: viewing as a demo access role (src/dashboard/demo.js) ---------- */

.sidebar__user-level--button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.sidebar__user-level--button:hover {
  color: var(--text);
}

.sidebar__user-level--button.is-demo {
  color: var(--warn);
  font-weight: 600;
}

.demo-dialog,
.demo-locked {
  position: fixed;
  inset: 0;
  width: min(34rem, calc(100vw - 2rem));
  height: fit-content;
  margin: auto;
}

.demo-dialog:not([open]),
.demo-locked:not([open]) {
  display: none;
}

.demo-dialog__form {
  display: grid;
  gap: var(--s-3);
}

.demo-dialog__group {
  display: grid;
  gap: var(--s-1);
}

.demo-x {
  display: block;
  margin: 0 auto;
  color: var(--danger);
}

.demo-locked {
  text-align: center;
}

.demo-locked .btn-row {
  justify-content: center;
}

.demo-locked__text,
.demo-denied__text {
  margin: var(--s-3) 0 var(--s-1);
  font-weight: 600;
}

.demo-locked__role,
.demo-denied__role {
  margin: 0 0 var(--s-3);
  color: var(--text-3);
  font-size: var(--fs-sm);
}

.demo-denied {
  position: relative;
  min-height: 60vh;
}

.demo-denied__page {
  opacity: 0.3;
  filter: grayscale(1);
  pointer-events: none;
  user-select: none;
}

.demo-denied__notice {
  position: absolute;
  top: 6rem;
  left: 50%;
  width: min(30rem, calc(100% - 2rem));
  padding: var(--s-5) var(--s-4);
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  text-align: center;
}

.is-demo-locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.input--found,
.input--found:focus {
  border-style: dashed;
  background: transparent;
  color: var(--text-2);
  box-shadow: none;
  cursor: default;
}

.active-server__temp {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
}

.active-server__temp-form {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.active-server__temp-form .select {
  width: auto;
  height: 32px;
  min-height: 0;
  padding-block: 0;
}

.active-server__temp-form + form {
  margin: 0;
}

.active-server__temp-text {
  margin: 0 auto 0 0;
  font-size: var(--fs-sm);
}
