/* Operator control panel. One stylesheet, no JavaScript, no external requests. */

/* --- Tokens --- */

:root {
  color-scheme: dark;

  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --bg: #0f141b;
  --surface: #161d26;
  --surface-2: #1b2430;
  --surface-3: #212c3a;

  --border: #273241;
  --border-strong: #354356;

  --fg: #c3cedb;
  --fg-strong: #e8eef6;
  --fg-muted: #8b98a8;
  --fg-faint: #6a7686;

  --accent: #5aa2f0;
  --accent-bright: #85bcf7;
  --accent-bg: #14263c;
  --accent-border: #2b5480;

  --ok: #5cb87a;
  --ok-bg: #12261a;
  --ok-border: #2c5438;

  --warn: #d6a444;
  --warn-bg: #2a2113;
  --warn-border: #5a4620;

  --danger: #ef7078;
  --danger-bg: #2b1519;
  --danger-border: #5d2b32;

  --radius: 5px;
  --radius-lg: 7px;
}

/* --- Base --- */

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

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

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

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

h1,
h2,
h3 {
  color: var(--fg-strong);
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
}

h1 {
  font-size: 1.3rem;
}

h2 {
  font-size: 1.02rem;
}

h3 {
  font-size: 0.92rem;
}

p {
  margin: 0 0 0.6rem;
}

p:last-child {
  margin-bottom: 0;
}

code,
kbd,
samp,
pre,
.mono {
  font-family: var(--font-mono);
  font-size: 0.86em;
}

/* --- Utilities --- */

.muted {
  color: var(--fg-muted);
}

.faint {
  color: var(--fg-faint);
}

.nowrap {
  white-space: nowrap;
}

.strong {
  color: var(--fg-strong);
  font-weight: 600;
}

/* --- Top bar --- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  max-width: 1500px;
  margin: 0 auto;
  padding: 0.6rem 1.25rem;
}

.brand {
  color: var(--fg-strong);
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.brand-sub {
  color: var(--fg-muted);
  font-weight: 400;
}

.env-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-left: 0.5rem;
}

.nav-link {
  color: var(--fg-muted);
  padding: 0.28rem 0.6rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--fg-strong);
  background: var(--surface-2);
  text-decoration: none;
}

.nav-link.is-active {
  color: var(--fg-strong);
  background: var(--accent-bg);
  border-color: var(--accent-border);
}

.who {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.who-name {
  color: var(--fg-strong);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.role-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 999px;
  padding: 0.08rem 0.5rem;
  border: 1px solid var(--border-strong);
  color: var(--fg-muted);
  white-space: nowrap;
}

.role-operator {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-bg);
}

/* --- Page --- */

.page {
  max-width: 1500px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

.page-narrow {
  max-width: 26rem;
  padding-top: 3rem;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.page-head .lede {
  color: var(--fg-muted);
  margin: 0.25rem 0 0;
  max-width: 62ch;
}

.head-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.breadcrumb {
  color: var(--fg-muted);
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
}

/* --- Cards --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
}

.card-body {
  padding: 1rem;
}

.card-note {
  color: var(--fg-muted);
  font-size: 0.82rem;
  margin: 0;
}

/* --- Flashes and alerts --- */

.flashes {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.flash,
.alert {
  border: 1px solid var(--border-strong);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--fg);
  padding: 0.55rem 0.8rem;
  margin-bottom: 0.5rem;
}

.alert {
  margin-bottom: 1rem;
}

.flash:last-child {
  margin-bottom: 0;
}

.flash-ok,
.alert-ok {
  border-color: var(--ok-border);
  border-left-color: var(--ok);
  background: var(--ok-bg);
}

.flash-warn,
.alert-warn {
  border-color: var(--warn-border);
  border-left-color: var(--warn);
  background: var(--warn-bg);
}

.flash-error,
.alert-error {
  border-color: var(--danger-border);
  border-left-color: var(--danger);
  background: var(--danger-bg);
}

.alert-title {
  color: var(--fg-strong);
  font-weight: 600;
  margin: 0 0 0.35rem;
}

/* --- Tables --- */

.table-scroll {
  overflow-x: auto;
  border-top: 1px solid var(--border);
}

.card > .table-scroll:first-child {
  border-top: 0;
}

table.grid {
  width: 100%;
  min-width: 60rem;
  border-collapse: collapse;
  font-size: 0.84rem;
}

table.grid.grid-wide {
  min-width: 76rem;
}

table.grid th,
table.grid td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border);
}

table.grid thead th {
  background: var(--surface-2);
  color: var(--fg-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-strong);
  position: relative;
}

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

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

table.grid td.cell-actions {
  white-space: nowrap;
  text-align: right;
}

.cell-title {
  color: var(--fg-strong);
  font-weight: 600;
}

.cell-sub {
  display: block;
  color: var(--fg-faint);
  font-size: 0.76rem;
  margin-top: 0.15rem;
}

.cell-mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--fg-strong);
}

.cell-url {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--fg-muted);
  word-break: break-all;
  max-width: 30ch;
  display: inline-block;
}

.cell-value {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  max-width: 28ch;
  overflow-wrap: anywhere;
}

.row-fail {
  background: var(--danger-bg);
}

.row-fail:hover {
  background: #331a1e;
}

.row-fail td:first-child {
  box-shadow: inset 3px 0 0 var(--danger);
}

.row-muted td {
  color: var(--fg-faint);
}

/* --- Pills --- */

.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  border: 1px solid var(--border-strong);
  color: var(--fg-muted);
  background: var(--surface-3);
  white-space: nowrap;
}

.pill-ok {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: var(--ok-border);
}

.pill-warn {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.pill-danger {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.pill-info {
  color: var(--accent);
  background: var(--accent-bg);
  border-color: var(--accent-border);
}

/* --- Buttons --- */

.btn {
  display: inline-block;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--fg-strong);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.36rem 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover {
  background: var(--border);
  border-color: var(--fg-faint);
  color: var(--fg-strong);
  text-decoration: none;
}

.btn-primary {
  color: #08131f;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-bright);
  border-color: var(--accent-bright);
  color: #08131f;
}

.btn-danger {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

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

.btn-quiet {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--fg-muted);
}

.btn-quiet:hover {
  background: var(--surface-2);
  color: var(--fg-strong);
}

.btn-block {
  display: block;
  width: 100%;
  text-align: center;
}

.btn-sm {
  font-size: 0.76rem;
  padding: 0.24rem 0.6rem;
}

.inline-form {
  display: inline;
  margin: 0;
}

/* The Users page puts a backend picker inside a table row, next to its own
   submit button. The global rule above makes every select 100% wide, which in a
   table cell means one control per line and a row three times taller than it
   needs to be. Inline-block plus a bounded width keeps picker and button on one
   line, and the max-width stops a long backend name from widening the column. */
.inline-form select {
  display: inline-block;
  width: auto;
  min-width: 11rem;
  max-width: 18rem;
  vertical-align: middle;
  margin-right: 0.3rem;
}

/* Two forms in one cell — pick a backend and press Assign, then Delete — read as
   one run-on line without this. */
td.cell-actions .inline-form + .inline-form {
  margin-left: 0.35rem;
}

/* --- Forms --- */

.field {
  margin-bottom: 0.9rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field > label,
.field-label {
  display: block;
  color: var(--fg-strong);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.req {
  color: var(--danger);
  font-weight: 400;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 0.86rem;
  color: var(--fg-strong);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.42rem 0.6rem;
}

input.mono,
input[type="password"],
select.mono {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

input::placeholder {
  color: var(--fg-faint);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--fg-faint);
}

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

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
  margin: 0;
  flex: none;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}

.check label {
  color: var(--fg-strong);
  font-size: 0.85rem;
  font-weight: 500;
}

.hint {
  color: var(--fg-muted);
  font-size: 0.78rem;
  margin: 0.3rem 0 0;
  max-width: 68ch;
}

.err {
  color: var(--danger);
  font-size: 0.78rem;
  margin: 0.3rem 0 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.9rem;
}

.form-row {
  display: flex;
  gap: 0.7rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-row .field {
  margin-bottom: 0;
  flex: 1 1 13rem;
  min-width: 0;
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem 1rem;
  margin: 0 0 1.1rem;
  min-width: 0;
}

legend {
  color: var(--fg-strong);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 0.4rem;
}

fieldset.danger-zone {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

fieldset.danger-zone legend {
  color: var(--danger);
}

/* --- Secret reveal blocks --- */

.secret {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--fg-strong);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  margin: 0.5rem 0;
  overflow-wrap: anywhere;
  user-select: all;
}

.secret-lg {
  font-size: 1.05rem;
  letter-spacing: 0.03em;
}

.secret-uri {
  font-size: 0.78rem;
  color: var(--fg-muted);
}

/* --- Empty states --- */

.empty {
  padding: 2.25rem 1.25rem;
  text-align: center;
  color: var(--fg-muted);
}

.empty-title {
  color: var(--fg-strong);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.empty p {
  max-width: 52ch;
  margin: 0 auto 0.4rem;
}

/* --- Pager --- */

.pager {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
}

/* --- Auth pages --- */

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
}

.auth-head {
  margin-bottom: 1.1rem;
}

.auth-head .lede {
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin: 0.3rem 0 0;
}

.auth-foot {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.code-input {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  letter-spacing: 0.4em;
  text-align: center;
  padding: 0.55rem 0.6rem;
}

/* --- Narrow viewports (a half-screen laptop window) --- */

@media (max-width: 900px) {
  .topbar-row,
  .page {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }

  .who {
    margin-left: 0;
  }

  .page-head {
    align-items: flex-start;
  }
}

/* --- Single-page user routing --------------------------------------------- */

.users-head .lede {
  max-width: 78ch;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-table-card .card-head {
  background: var(--surface-2);
}

table.grid.users-grid {
  /* The sum of the column widths below, and no more. This said 104rem, left
     over from the seven-column Users table this grid started as; the five
     columns now declared add up to 74rem, so the surplus was 30rem of empty
     table that scrolled sideways on a 1440px screen and slid the sticky
     Actions column across the Status text. */
  min-width: 74rem;
  table-layout: fixed;
}

.users-grid th:nth-child(1),
.users-grid td:nth-child(1) {
  width: 12rem;
}

.users-grid th:nth-child(2),
.users-grid td:nth-child(2),
.users-grid th:nth-child(3),
.users-grid td:nth-child(3) {
  width: 13rem;
}

.users-grid th:nth-child(4),
.users-grid td:nth-child(4) {
  width: 21rem;
}

.users-grid th:nth-child(5),
.users-grid td:nth-child(5) {
  width: 20rem;
}

.users-grid th:nth-child(6),
.users-grid td:nth-child(6) {
  width: 14rem;
}

.users-grid th:last-child,
.users-grid td:last-child {
  width: 15rem;
}

.users-grid td {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.table-input {
  min-width: 0;
}

.table-input[readonly] {
  background: var(--bg);
  border-color: var(--border);
  color: var(--fg-muted);
  cursor: default;
}

.status-cell {
  overflow-wrap: anywhere;
}

.status-error,
.status-warning {
  display: block;
  max-width: 26ch;
  margin-top: 0.3rem;
  font-size: 0.74rem;
  line-height: 1.35;
}

.status-error {
  color: var(--danger);
}

.status-warning {
  color: var(--warn);
}

.actions-heading {
  text-align: right !important;
}

.route-actions {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: -1px 0 0 var(--border);
}

.users-grid tbody tr:hover .route-actions {
  background: var(--surface-2);
}

.users-grid .row-fail .route-actions {
  background: var(--danger-bg);
}

.primary-actions,
.secondary-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem;
  /* Fixed, and the same for both rows: the four buttons then form one block
     whose edges align down the column, and a row reading "Switch on" is the
     same shape as one reading "Switch off". */
  width: 12rem;
  margin-left: auto;
}

.secondary-actions {
  margin-top: 0.35rem;
}

/* Each button fills its cell, so the pair in a row meets in the middle instead
   of leaving a ragged gap that varies with the label. */
.primary-actions .btn,
.secondary-actions .btn {
  width: 100%;
  justify-content: center;
  text-align: center;
}

.credential-details {
  margin-top: 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 0.35rem 0.5rem;
}

.credential-details summary,
.service-key-tool > summary {
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 600;
}

.credential-details[open] summary {
  color: var(--fg-strong);
  margin-bottom: 0.45rem;
}

.credential-details p {
  color: var(--fg-muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.credential-details label {
  display: block;
  color: var(--fg-muted);
  font-size: 0.7rem;
  margin: 0.45rem 0 0.2rem;
}

.credential-details input {
  font-size: 0.76rem;
  padding: 0.3rem 0.45rem;
}

.user-create-grid {
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.service-key-tool > summary {
  list-style-position: inside;
  padding: 0.75rem 1rem;
  color: var(--fg-strong);
}

.service-key-tool[open] > summary {
  border-bottom: 1px solid var(--border);
}

.service-key-tool .form-row .btn {
  margin-bottom: 0;
}

@media (max-width: 900px) {
  table.grid.users-grid {
    /* Same five columns, same 74rem. This carried its own stale number. */
    min-width: 74rem;
  }

  .route-actions {
    position: static;
    box-shadow: none;
  }
}

/* --- The users search bar --------------------------------------------------- */

/* Shaped after Odoo's: one bordered box holding the facets already applied, the
   text box, and the menus that add more. No JavaScript — <details> is the menu. */

.searchbar {
  margin: 0 0 1rem;
}

.searchbar-box {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.35rem 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
}

.searchbar-box:focus-within {
  border-color: var(--accent-border);
}

.searchbar-facets {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex: 1 1 22rem;
  min-width: 0;
}

/* A facet reads as one object: the field on the left, the value on the right,
   and the × that drops it. */
.facet {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  background: var(--accent-bg);
  overflow: hidden;
  font-size: 0.82rem;
  max-width: 100%;
}

.facet-key {
  padding: 0.2rem 0.45rem;
  background: var(--accent-border);
  color: var(--fg-strong);
  font-weight: 600;
  white-space: nowrap;
}

.facet-value {
  padding: 0.2rem 0.45rem;
  color: var(--accent-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.facet-remove {
  display: flex;
  align-items: center;
  padding: 0 0.45rem;
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 1rem;
  line-height: 1;
}

.facet-remove:hover,
.facet-remove:focus-visible {
  background: var(--danger-bg);
  color: var(--danger);
}

.searchbar-input {
  flex: 1 1 12rem;
  min-width: 8rem;
  padding: 0.3rem 0.4rem;
  border: 0;
  background: transparent;
  color: var(--fg-strong);
  font: inherit;
  font-size: 0.9rem;
}

.searchbar-input:focus {
  outline: none;
}

.searchbar-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.search-menu {
  position: relative;
}

.search-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.32rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--fg);
  font-size: 0.85rem;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
}

/* The default triangle is replaced by one that points the way the panel opens. */
.search-menu-toggle::-webkit-details-marker {
  display: none;
}

.search-menu-toggle::after {
  content: "▾";
  color: var(--fg-faint);
  font-size: 0.75rem;
}

.search-menu[open] > .search-menu-toggle,
.search-menu-toggle:hover {
  border-color: var(--accent-border);
  color: var(--fg-strong);
}

.search-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.3rem);
  z-index: 20;
  min-width: 13rem;
  padding: 0.35rem;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.search-menu-head {
  margin: 0.15rem 0.5rem 0.35rem;
  color: var(--fg-faint);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.search-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.34rem 0.5rem;
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  font-size: 0.87rem;
}

.search-option:hover,
.search-option:focus-visible {
  background: var(--surface-2);
  color: var(--fg-strong);
}

.search-option.is-on {
  color: var(--accent-bright);
}

/* Reserved whether ticked or not, so the labels do not shift as they toggle. */
.search-tick {
  display: inline-block;
  width: 0.9rem;
  color: var(--accent);
}

/* --- Grouped rows ----------------------------------------------------------- */

.users-grid .group-row td {
  padding: 0.45rem 0.85rem;
  background: var(--surface-2);
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border);
  position: sticky;
  left: 0;
}

.group-name {
  color: var(--fg-strong);
  font-weight: 600;
  font-size: 0.9rem;
}

.group-count {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--fg-muted);
  font-size: 0.76rem;
}

/* --- Phones and narrow tablets ---------------------------------------------- */

/* Below this the users grid stops being a grid: 104rem of columns cannot be made
   to fit, and a horizontally scrolled table is unusable on a phone. Each row
   becomes a card whose cells carry their own heading, from data-label. */
@media (max-width: 820px) {
  .searchbar-tools {
    width: 100%;
    justify-content: flex-start;
  }

  .search-menu-panel {
    right: auto;
    left: 0;
  }

  .table-scroll {
    overflow-x: visible;
  }

  table.grid.users-grid {
    display: block;
    min-width: 0;
    table-layout: auto;
  }

  .users-grid thead {
    display: none;
  }

  .users-grid tbody {
    display: block;
  }

  .users-grid tbody tr {
    display: block;
    margin: 0.6rem 0.6rem 0;
    padding: 0.2rem 0.6rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
  }

  .users-grid tbody tr.row-fail {
    border-color: var(--danger-border);
  }

  /* Beats the nth-child widths above, which are meaningless once the cells are
     stacked. */
  .users-grid tbody td[data-label] {
    display: grid;
    grid-template-columns: 7rem minmax(0, 1fr);
    gap: 0.6rem;
    width: auto;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border);
  }

  .users-grid tbody tr td[data-label]:last-child {
    border-bottom: 0;
  }

  .users-grid tbody td[data-label]::before {
    content: attr(data-label);
    padding-top: 0.4rem;
    color: var(--fg-faint);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  /* The actions column is sticky on a wide table; stacked, there is nothing for
     it to stick to and the shadow reads as a stray line. */
  .users-grid tbody td.route-actions {
    position: static;
    box-shadow: none;
    background: transparent;
  }

  .users-grid .group-row {
    margin: 0.9rem 0.6rem 0;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .users-grid .group-row td {
    display: flex;
    align-items: center;
    border-radius: var(--radius);
    border-top: 0;
  }

  .users-grid .group-row td::before {
    content: none;
  }

  /* The stacked cell is a two-column grid — label, then value. Both button
     groups have to be told to sit in the value column: without this the second
     one flowed into the next grid cell, which is the 7rem label column, and
     Switch off and Remove landed under the word ACTIONS at a different width
     from the pair above them. */
  .primary-actions,
  .secondary-actions {
    grid-column: 2;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
    width: 100%;
    margin-left: 0;
  }

  .user-create-grid {
    grid-template-columns: 1fr;
  }
}

/* Narrow phones: the label column costs more than it explains once the value
   under it has to wrap anyway. */
@media (max-width: 520px) {
  .users-grid tbody td[data-label] {
    display: block;
    padding: 0.5rem 0;
  }

  .users-grid tbody td[data-label]::before {
    display: block;
    padding: 0 0 0.25rem;
  }

  .topbar-row {
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
  }

  .who {
    width: 100%;
    justify-content: space-between;
  }

  .page-head h1 {
    font-size: 1.35rem;
  }
}

/* ---------------------------------------------------------------------------
   Public legal pages

   /control/legal/privacy-policy(-de), delete-account(-de), imprint(-de). The
   only pages here read by someone who is not an operator, and the only
   long-form prose in the panel — so they get a measure, a heading rhythm, and
   navigation shaped as controls rather than as a row of run-together links.
   --------------------------------------------------------------------------- */

.page-legal {
  max-width: 44rem;
  padding: clamp(1.25rem, 0.5rem + 2.5vw, 2.75rem) clamp(1rem, 0.5rem + 2vw, 2rem) 4rem;
}

/* --- header: switcher, title, date ---------------------------------------- */

/* The language switcher is a segmented control, not two adjacent links: as
   plain text "English Deutsch" reads as one phrase, and no amount of gap fixes
   that. No script is available on these pages — the other language is a link to
   its own URL, and the current one is a span. */
.legal-langs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: 2.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.legal-lang {
  padding: 0.32rem 0.95rem;
  border-radius: 999px;
  font-size: 0.83rem;
  line-height: 1.4;
  color: var(--fg-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}

.legal-lang.is-current {
  background: var(--surface-3);
  color: var(--fg-strong);
}

a.legal-lang:hover,
a.legal-lang:focus-visible {
  background: var(--surface-2);
  color: var(--fg-strong);
}

.legal h1 {
  margin: 0;
  font-size: clamp(1.35rem, 1.05rem + 1.3vw, 1.75rem);
  line-height: 1.25;
  color: var(--fg-strong);
}

/* The "last updated" line opens the document block and doubles as the rule
   separating the title from the text. */
.legal-doc > .muted:first-child {
  margin: 0.7rem 0 0;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

/* --- body ------------------------------------------------------------------ */

.legal-doc h2 {
  margin: 2.5rem 0 0.75rem;
  font-size: 1.05rem;
  line-height: 1.35;
  color: var(--fg-strong);
}

.legal-doc p,
.legal-doc li {
  max-width: 68ch;
  line-height: 1.7;
  /* German compounds are long and the pages are read on phones. `hyphens`
     needs the element's language, which these pages now declare correctly. */
  overflow-wrap: break-word;
  hyphens: auto;
}

.legal-doc p {
  margin: 0 0 1rem;
}

.legal-doc ul {
  margin: 0 0 1.25rem;
  padding-left: 1.15rem;
}

.legal-doc li {
  margin-bottom: 0.4rem;
}

.legal-doc li::marker {
  color: var(--fg-faint);
}

/* Sub-labels like "On registration and sign-in": paragraphs that introduce a
   list rather than open a section. */
.legal-doc p.strong {
  margin: 1.25rem 0 0.5rem;
  color: var(--fg-strong);
}

.legal-address {
  margin: 0 0 1rem;
  line-height: 1.7;
}

.legal-doc a {
  overflow-wrap: anywhere;
}

.legal-doc table.grid {
  width: 100%;
  margin: 0.5rem 0 1.5rem;
}

.legal-doc table.grid th,
.legal-doc table.grid td {
  padding: 0.6rem 0.75rem;
  line-height: 1.55;
  vertical-align: top;
}

/* --- footer ---------------------------------------------------------------- */

/* The other legal documents in the same language. Bordered so each is visibly
   its own destination — as bare links they read as one run of words. */
.legal-siblings {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.legal-siblings a {
  padding: 0.55rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--fg);
  text-decoration: none;
  transition: border-color 0.12s ease, color 0.12s ease;
}

.legal-siblings a:hover,
.legal-siblings a:focus-visible {
  border-color: var(--border-strong);
  color: var(--fg-strong);
}

/* --- narrow screens -------------------------------------------------------- */

@media (max-width: 520px) {
  /* Both controls go full width and split evenly, so they stay comfortably
     tappable instead of shrinking to the width of their words. */
  .legal-langs {
    display: flex;
    width: 100%;
  }

  .legal-lang {
    flex: 1;
    text-align: center;
  }

  .legal-siblings a {
    flex: 1 1 100%;
    text-align: center;
  }

  .legal-doc table.grid th,
  .legal-doc table.grid td {
    padding: 0.5rem 0.6rem;
  }
}
