/*
 * RemoteUI components. Each block is self-contained and only uses tokens (tokens.css).
 * Naming: .component, .component--variant, .component__part.
 * The viewer shares the button, select, card and tooltip: its tokens keep their previous sizes (tokens.css).
 */

/* ---------- Button ----------
 * Principal (.btn--primary), secundario (.btn, the default), suave (.btn--soft), peligro (.btn--danger) and the
 * quiet icon button (.btn--ghost). Row actions in tables use .btn--sm (36 px). */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--btn-h);
  padding: 0 var(--btn-pad);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-control);
  background: var(--btn-bg);
  color: var(--text);
  font-size: var(--btn-fs);
  font-weight: var(--btn-weight);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}
.btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--table-head);
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn svg {
  width: var(--btn-icon);
  height: var(--btn-icon);
  flex: none;
}
.btn--primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-btn);
}
.btn--primary:hover:not(:disabled) {
  border-color: transparent;
  background: var(--accent-strong);
}
.btn--soft {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.btn--soft:hover:not(:disabled) {
  border-color: transparent;
  background: color-mix(in srgb, var(--accent-soft), var(--accent) 10%);
}
.btn--danger,
.btn--danger-ghost {
  border-color: var(--danger-border);
  background: var(--surface);
  color: var(--error-text);
}
.btn--danger:hover:not(:disabled),
.btn--danger-ghost:hover:not(:disabled) {
  border-color: var(--error-text);
  background: var(--error-bg);
}
.btn--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.btn--ghost:hover:not(:disabled) {
  border-color: transparent;
  background: var(--table-head);
  color: var(--text);
}
/* In the interior a ghost button with a label is a secondary action and looks like one; icon-only ones stay quiet
   (PB review 2026-11-22: «Restablecer valores por defecto» read as bare text). The viewer keeps its look. */
:root:not([data-viewer-tokens]) .btn--ghost:not(.btn--icon) {
  border-color: var(--border-input);
  background: var(--surface);
  color: var(--text);
}
:root:not([data-viewer-tokens]) .btn--ghost:not(.btn--icon):hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--table-head);
}
.btn--sm {
  height: var(--btn-h-sm);
  padding: 0 var(--space-3);
  border-radius: var(--radius-item);
  font-size: var(--btn-fs-sm);
}
/* On a phone a long label wraps inside its button instead of pushing it out of its row (Correo, PB 2026-11-22). */
@media (max-width: 640px) {
  :root:not([data-viewer-tokens]) .btn {
    max-width: 100%;
    height: auto;
    min-height: var(--btn-h);
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
    white-space: normal;
    text-align: center;
  }
  :root:not([data-viewer-tokens]) .btn--sm {
    min-height: var(--btn-h-sm);
    padding-top: var(--space-1);
    padding-bottom: var(--space-1);
  }
}
.btn--sm svg {
  width: var(--btn-icon-sm);
  height: var(--btn-icon-sm);
}
.btn--icon {
  width: var(--btn-h);
  padding: 0;
}
.btn--icon.btn--sm {
  width: var(--btn-h-sm);
}

/* ---------- Form field: label above, hint and error below ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-4);
}
.field__label {
  color: var(--text);
  font-size: var(--fs-secondary);
  font-weight: var(--weight-semibold);
}
.field__hint {
  color: var(--muted);
  font-size: var(--fs-secondary);
  line-height: var(--leading-normal);
}
.field__error {
  color: var(--error-text);
  font-size: var(--fs-secondary);
  font-weight: var(--weight-semibold);
}
/* A required field (core/validate.js markRequired): an asterisk after its label. The alternative text "" keeps it
 * out of screen readers, which say «obligatorio» from the control's required / aria-required. */
.field__label--required::after {
  content: " *";
  content: " *" / "";
  color: var(--error-text);
  font-weight: var(--weight-semibold);
}
.field__warning {
  color: var(--warning-text);
  font-size: var(--fs-secondary);
}
/* A paragraph of description keeps its distance from the fields under it. */
p.field__hint:not(:last-child),
p.field__warning:not(:last-child) {
  margin-bottom: var(--space-3);
}
/* A group of fields with a caption (Días, the steps of Base de datos): its caption above, no box of its own inside
 * the card (density pass, rule C). */
fieldset {
  min-width: 0;
  margin: 0 0 var(--form-gap);
  padding: 0;
  border: 0;
}
legend {
  margin-bottom: var(--space-2);
  padding: 0;
  color: var(--ink);
  font-size: var(--fs-secondary);
  font-weight: var(--weight-bold);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
/* A field and its action on one line: the field as wide as a value needs (density pass), the action beside it. */
.field-row.field-row--action {
  grid-template-columns: minmax(12rem, 24rem) auto;
  justify-content: start;
}
@media (max-width: 560px) {
  .field-row.field-row--action {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 560px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

/* ---------- Input / Select ---------- */
.input,
.select {
  width: 100%;
  height: var(--control-h);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-control);
  background: var(--input-bg);
  color: var(--text);
  font-size: var(--fs-body);
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.input::placeholder {
  color: var(--subtle);
}
.input:hover,
.select:hover {
  border-color: var(--border-strong);
}
.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input:focus-visible,
.select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.input:disabled,
.select:disabled {
  border-style: dashed;
  background: var(--table-head);
  color: var(--muted);
  cursor: not-allowed;
}
.input[aria-invalid="true"],
.select[aria-invalid="true"],
.picker:has(.picker__input[aria-invalid="true"]),
.is-invalid {
  border-color: var(--error-text) !important;
}
textarea.input {
  height: auto;
  min-height: 6rem;
  padding: var(--space-3);
  line-height: var(--leading-normal);
  resize: vertical;
}
.input--mono {
  font-family: var(--font-mono);
  font-size: var(--fs-secondary);
}
.select {
  appearance: none;
  padding-right: var(--space-8);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

/* ---------- Switch (.toggle) ----------
 * A real checkbox with role="switch" (the browser reports it checked or not), drawn 48 × 28. */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}
.toggle__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.toggle__track {
  position: relative;
  width: var(--switch-w);
  height: var(--switch-h);
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  transition: background-color var(--duration-base) var(--ease-out);
}
.toggle__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(var(--switch-h) - 6px);
  height: calc(var(--switch-h) - 6px);
  border-radius: 50%;
  background: var(--switch-knob);
  box-shadow: var(--shadow-knob);
  transition: transform var(--duration-base) var(--ease-out);
}
.toggle__input:checked + .toggle__track {
  background: var(--accent);
}
.toggle__input:checked + .toggle__track::after {
  transform: translateX(calc(var(--switch-w) - var(--switch-h)));
}
.toggle__input:focus-visible + .toggle__track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
/* A switch drawn without its track (B-008, PB 2026-11-24: «Aplicar a los grupos» showed no box at all): the checkbox
 * itself stays visible and usable instead of an invisible 1 px input. layout-audit fails on any such case. */
.toggle__input:not(:has(+ .toggle__track)) {
  position: static;
  opacity: 1;
  width: 18px;
  height: 18px;
  margin: 0;
  flex: none;
  accent-color: var(--accent);
}
.toggle__input:disabled + .toggle__track {
  opacity: 0.5;
  cursor: not-allowed;
}
.toggle__label {
  color: var(--text);
  font-size: var(--fs-body);
  font-weight: var(--weight-semibold);
}
/* A setting with a switch, in its two forms — one component, the same layout:
 *  - .setting: .setting__text (title, description, fields) and a bare .toggle;
 *  - label.toggle--row: the title is the switch's own label (any description follows the label).
 * The text is flexible on the left (min-width: 0, so it wraps instead of pushing), the switch a fixed 48 px on the
 * right. (PB 2026-11-22: a .toggle--row inside a .setting took the whole row and left the text 0 px wide.) */
.toggle--row {
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  width: 100%;
  min-width: 0;
  padding: 0;
}
.toggle--row .toggle__track,
.setting > .toggle .toggle__track {
  flex: 0 0 var(--switch-w);
}
.toggle--row .toggle__label {
  flex: 1 1 0;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: var(--fs-block);
  font-weight: var(--weight-bold);
}
/* A setting row and its description, one rule for the whole app (density pass): the description 4 px under its
 * title, the next row 16 px away. In a grid of rows (.company-checks, gap 16 px) the description pulls itself up. */
.toggle--row + .field__hint {
  display: block;
  margin: 4px 0 0;
  max-width: 70ch;
}
.company-checks > .toggle--row + .field__hint {
  margin-top: calc(4px - var(--form-gap));
}
.field:has(> .toggle--row) {
  gap: 4px;
  margin-bottom: 0;
}
/* A block of fields and its help, as one row of the grid: the help 4 px under the fields. */
.setting-block {
  display: grid;
  gap: 4px;
}
.setting-block > .company-grid .field {
  margin-bottom: 0;
}

/* ---------- Setting row: title, description (and its fields) on the left, the switch on the right ---------- */
.settings {
  display: flex;
  flex-direction: column;
}
.setting {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--form-gap) 0;
}
.setting + .setting {
  border-top: 1px solid var(--divider);
}
.setting:first-child {
  padding-top: 0;
}
.setting:last-child {
  padding-bottom: 0;
}
.setting__text {
  flex: 1 1 0;
  min-width: 0;
}
.setting__title {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-block);
  font-weight: var(--weight-bold);
}
.setting__desc {
  max-width: 70ch;
  margin: var(--space-1) 0 0;
  color: var(--muted);
  font-size: var(--fs-secondary);
  line-height: var(--leading-normal);
}
.setting__fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3) var(--space-4);
  margin-top: var(--space-4);
}
.setting__fields .field {
  flex: 1 1 12rem;
  max-width: 20rem;
  margin: 0;
}
.setting > .toggle {
  flex: 0 0 auto;
  width: auto;
  margin-top: 2px;
  padding: 0;
}
.setting > .btn {
  flex: none;
}
@media (max-width: 640px) {
  .setting {
    flex-wrap: wrap;
    gap: var(--space-4);
  }
  /* A row whose action is a button: the button goes under the text. */
  .setting:has(> .btn) > .setting__text {
    flex-basis: 100%;
  }
}

/* ---------- State: only what needs attention stands out (density pass, owner rule B) ----------
 * .state: a muted 8 px dot and normal text (correct, available, in service: the usual).
 * .state--warn / --error / --nodata: coloured text with a 14 px icon, no background.
 * .state--off: a hollow dot (stopped on purpose, not a problem).
 * A pill with a background (.chip) is left only for states that change behaviour: Retirado, Apagada, Inactiva.
 * The chip tones below (.chip.chip--success/--warning/--danger) read as these states too, so older markup follows. */
.state,
.chip.chip--success,
.chip.chip--warning,
.chip.chip--danger,
.chip.chip--nodata,
.chip.chip--accent {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  color: var(--text);
  font-size: inherit;
  font-weight: var(--weight-regular);
  line-height: var(--leading-tight);
  white-space: nowrap;
}
.state::before,
.chip.chip--success::before {
  content: "";
  flex: none;
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: color-mix(in srgb, var(--success-dot) 55%, var(--surface));
}
.state--off::before,
.chip.chip--off::before {
  background: none;
  box-shadow: inset 0 0 0 1.5px var(--border-strong);
}
/* Stopped on purpose, waiting, applying: a hollow dot and the usual text. */
.chip.chip--off {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--muted);
  font-size: inherit;
  font-weight: var(--weight-regular);
  white-space: normal;
}
.chip.chip--off::before {
  content: "";
  flex: none;
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
}
.table__name {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.group-head__meta,
.group-power {
  color: var(--muted);
  font-size: var(--fs-secondary);
}
.state--warn,
.state--error,
.state--nodata,
.chip.chip--warning,
.chip.chip--danger,
.chip.chip--nodata {
  font-weight: var(--weight-semibold);
}
.state--warn,
.chip.chip--warning {
  color: var(--warning-text);
}
.state--error,
.chip.chip--danger {
  color: var(--error-text);
}
.state--nodata,
.chip.chip--nodata {
  color: var(--muted);
}
.state--warn::before,
.state--error::before,
.state--nodata::before,
.chip.chip--warning::before,
.chip.chip--danger::before,
.chip.chip--nodata::before {
  content: "";
  flex: none;
  width: var(--icon-sm);
  height: var(--icon-sm);
  border-radius: 0;
  background: currentColor;
  -webkit-mask: var(--state-icon) center / contain no-repeat;
  mask: var(--state-icon) center / contain no-repeat;
}
.state--warn,
.chip.chip--warning {
  --state-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E");
}
.state--error,
.chip.chip--danger {
  --state-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m15 9-6 6M9 9l6 6'/%3E%3C/svg%3E");
}
.state--nodata,
.chip.chip--nodata {
  --state-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9' stroke-dasharray='3 3.2'/%3E%3Cpath d='M8.5 12h7'/%3E%3C/svg%3E");
}
/* The dot or icon the markup already carries is not doubled. */
.chip.chip--success > .dot,
.chip.chip--warning > .dot,
.chip.chip--danger > .dot,
.chip.chip--nodata > .dot,
.chip.chip--accent > .dot,
.chip.chip--success > svg,
.chip.chip--warning > svg,
.chip.chip--danger > svg,
.chip.chip--nodata > svg,
.chip.chip--accent > svg {
  display: none;
}
/* «Identidad verificada»: a 14 px shield beside the server's name; its words are for screen readers (.sr-only). */
.verified {
  display: inline-block;
  flex: none;
  width: var(--icon-sm);
  height: var(--icon-sm);
  margin-left: 6px;
  vertical-align: -2px;
  background: var(--success-text);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 4.5 6v6c0 4.5 3.2 7.8 7.5 9 4.3-1.2 7.5-4.5 7.5-9V6L12 3z'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 4.5 6v6c0 4.5 3.2 7.8 7.5 9 4.3-1.2 7.5-4.5 7.5-9V6L12 3z'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E") center / contain no-repeat;
}
.chip.chip--accent {
  color: var(--muted);
}
/* A cell of «Cells efímeras»: a section under a divider (rule C). */
.cell-block + .cell-block {
  margin-top: var(--form-gap);
  padding-top: var(--form-gap);
  border-top: 1px solid var(--divider);
}
/* A field and its button on one line, the field as wide as it needs (no full-width button). */
.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
}
.inline-form > .select,
.inline-form > .input,
.inline-form > .field {
  flex: 0 1 24rem;
  min-width: 12rem;
}
.inline-form > .btn {
  flex: none;
}
/* Metadata that used to be a neutral pill: secondary text, no box (rule B). */
.chip.chip--text {
  display: inline;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--muted);
  font-size: inherit;
  font-weight: var(--weight-regular);
  white-space: normal;
}
/* A company's record: its facts beside the state, as text. */
.record-meta {
  color: var(--muted);
  font-size: var(--fs-secondary);
}
/* Who may open an application, as text («Todos los usuarios» muted). */
.access-list {
  color: var(--text);
}
.access-list__all {
  color: var(--muted);
}

/* ---------- Status pill (.chip) ----------
 * Only for states that change behaviour (Retirado, Apagada, Inactiva): 22 px, 12/600 text on a neutral fill.
 * user/group/all keep the people picker's three kinds apart (removable tokens in a form). */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: var(--pill-h);
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--neutral-bg);
  color: var(--neutral-text);
  font-size: var(--fs-small);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  white-space: nowrap;
}
.chip svg {
  width: 14px;
  height: 14px;
  flex: none;
}
.chip:not([class*="chip--"]) {
  box-shadow: inset 0 0 0 1px var(--border);
}
.chip--group {
  background: var(--success-bg);
  color: var(--success-text);
}
.chip--all {
  background: var(--warning-bg);
  color: var(--warning-text);
}
.chip--user {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.chip__remove {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-right: -4px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 14px;
  line-height: 1;
  opacity: 0.7;
  cursor: pointer;
}
.chip__remove:hover {
  opacity: 1;
  color: var(--error-text);
}
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--neutral-dot);
}
.dot--success,
.dot--group {
  background: var(--success-dot);
}
.dot--warning,
.dot--all {
  background: var(--warning-dot);
}
.dot--danger {
  background: var(--error-dot);
}
.dot--user,
.dot--accent {
  background: var(--accent);
}

/* ---------- Card ---------- */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.card--pad {
  padding: var(--card-pad);
}
@media (max-width: 640px) {
  .card--pad {
    padding: var(--space-4);
  }
}
.card__title {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-section);
  font-weight: var(--weight-bold);
}
.card__sub {
  margin: var(--space-1) 0 0;
  color: var(--muted);
  font-size: var(--fs-secondary);
}

/* Key figures: an icon on the soft accent, the figure and its label. Two columns, then one, on a phone. */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--section-gap);
}
/* Two columns on a small tablet, one on a phone: a label never breaks into three lines (PB 2026-11-22). */
@media (max-width: 640px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
  }
}
@media (max-width: 480px) {
  .kpis {
    grid-template-columns: minmax(0, 1fr);
  }
}
.kpi {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  min-height: var(--kpi-h);
  padding: var(--space-3) var(--space-4);
}
.kpi__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: var(--kpi-icon);
  height: var(--kpi-icon);
  border-radius: var(--radius-control);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.kpi__icon svg {
  width: 16px;
  height: 16px;
}
.kpi__body {
  min-width: 0;
}
.kpi__value {
  color: var(--ink);
  font-size: var(--fs-figure);
  font-weight: var(--weight-heavy);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-title);
  line-height: 1.15;
}
.kpi__label {
  margin-top: 0;
  color: var(--muted);
  font-size: var(--fs-secondary);
}
@media (max-width: 640px) {
  .kpi {
    gap: var(--space-3);
    padding: var(--space-4);
  }
  .kpi__icon {
    width: 36px;
    height: 36px;
  }
}

/* Usage bar (CPU, sessions): 72 × 6. */
.meter {
  width: 72px;
  max-width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--divider);
}
.meter__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--duration-base) var(--ease-out);
}
.meter__fill--full {
  background: var(--error-dot);
}

/* Technical identifiers (versions, groups, image and instance IDs). */
/* An identifier never breaks («i-» / «04de…», PB 2026-11-22); commands (.copy-row) still wrap. */
.code,
.table code,
.template-block__name code,
.template-row code {
  white-space: nowrap;
}
/* Rule B: monospaced, in the secondary colour, without a background. */
.code,
.table code {
  display: inline;
  padding: 0;
  background: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
}

/* ---------- Table: inside a card, scrolling sideways within it when it does not fit ---------- */
.table-wrap {
  /* Positioned, so absolutely placed children (the .sr-only headers) stay inside its scroll instead of widening the
   * page on a phone. */
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.table-wrap + * {
  margin-top: var(--space-4);
}
/* A table inside a card is not a second box (density pass, rule C): no frame of its own, the card is the frame. */
.card .table-wrap {
  border: 0;
  border-radius: 0;
  background: none;
}
.table-card {
  overflow: hidden;
  padding: 0;
}
.table-card > .table-wrap {
  border: 0;
  border-radius: 0;
}
/* The strip of filters on top of a table (search, selector, «Exportar CSV»). */
.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--divider);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-body);
}
.table th,
.table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  vertical-align: top;
}
.table th:first-child,
.table td:first-child {
  padding-left: var(--space-5);
}
.table th:last-child,
.table td:last-child {
  padding-right: var(--space-5);
}
.table th {
  border-bottom: 1px solid var(--divider);
  background: var(--table-head);
  color: var(--muted);
  font-size: var(--fs-secondary);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}
.table tbody tr + tr td {
  border-top: 1px solid var(--divider);
}
.table tbody tr:hover td {
  background: var(--table-head);
}
/* On a phone the columns keep a readable width and the table scrolls inside its card (PB 2026-11-22: columns of a
   few characters in Empresas, Estado, Métricas, Cells and Auditoría). */
@media (max-width: 640px) {
  .company-link > span:last-child {
    min-width: 8rem; /* the company's name beside its badge */
  }
  .table td > .table__title {
    min-width: 10rem; /* a user's or an application's name (Usuarios, PB 2026-11-22) */
  }
  .table th,
  .table td {
    min-width: 10rem; /* its text keeps 120 px and more (Auditoría, PB 2026-11-22) */
  }
  .table th:first-child,
  .table td:first-child {
    min-width: 12rem;
  }
  .table th:has(> input[type="checkbox"]:only-child),
  .table td:has(> input[type="checkbox"]:only-child),
  .table td:has(> label > input[type="checkbox"]),
  .table th:has(> label > input[type="checkbox"]),
  .table td.table__actions,
  .table th:empty,
  .table td.num,
  .table th.num {
    min-width: 0;
  }
}
.table tr:has(.input, .select) > td {
  vertical-align: middle;
}
.table td.table__nowrap {
  white-space: nowrap;
}
.table td.table__actions {
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
}
.table td .btn--ghost:not(.btn--icon) {
  border-color: var(--border-input);
  background: var(--surface);
  color: var(--text);
}
.table td .btn--ghost:not(.btn--icon):hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--table-head);
}
.table td.table__actions .btn + .btn {
  margin-left: var(--space-2);
}
.table tr.is-disabled td:not(.table__actions) {
  opacity: 0.6;
}
.table__title {
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: var(--weight-bold);
}
.link-btn.table__title,
a.table__title {
  color: var(--accent-text);
  font-weight: var(--weight-bold);
  text-align: left;
}
.table__sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--fs-secondary);
  word-break: break-word;
}
.table__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--space-2);
}
/* Alone in its cell (a user's state), the pills line up with the text of the row (PB review 2026-11-22). */
.table td > .table__chips:first-child {
  margin-top: -2px;
}
/* A monospaced cell (an e-mail, an id) on the same line as the others. */
.table td.mono,
.table td > .mono:first-child {
  line-height: calc(var(--fs-body) * var(--leading-body));
}

/* ---------- Empty state: what is missing and what to do ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-10) var(--space-6);
  color: var(--muted);
  text-align: center;
}
.empty__icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-card);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.empty__icon svg {
  width: 24px;
  height: 24px;
}
.empty__title {
  color: var(--ink);
  font-size: var(--fs-block);
  font-weight: var(--weight-bold);
}
.empty__text {
  max-width: 440px;
  font-size: var(--fs-secondary);
  line-height: var(--leading-normal);
}

/* ---------- Dropdown menu ---------- */
.menu {
  position: relative;
}
.menu__panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: var(--z-menu);
  min-width: 300px;
  padding: var(--space-2);
  border: 1px solid var(--menu-border);
  border-radius: var(--radius-menu);
  background: var(--surface);
  box-shadow: var(--shadow-dialog);
  transform-origin: top right;
  animation: menu-in var(--duration-fast) var(--ease-out);
}
@keyframes menu-in {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(-4px);
  }
}
.menu__header {
  padding: var(--space-2) var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--divider);
  margin-bottom: var(--space-2);
}
.menu__name {
  color: var(--ink);
  font-weight: var(--weight-semibold);
}
:root:not([data-viewer-tokens]) .menu__name {
  font-weight: var(--weight-bold);
}
/* The interior's menus: nothing under 12 px (the viewer keeps its sizes). */
:root:not([data-viewer-tokens]) .menu__sub,
:root:not([data-viewer-tokens]) .menu__item-hint,
:root:not([data-viewer-tokens]) .menu__section-label {
  font-size: var(--fs-small);
}
.menu__sub {
  color: var(--muted);
  font-size: var(--text-sm);
}
.menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-menu-item);
  background: transparent;
  color: var(--text);
  font-size: var(--menu-fs);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu__item:disabled {
  color: var(--muted);
  cursor: not-allowed;
}
.menu__item:disabled:hover {
  background: transparent;
}
.menu__form {
  display: contents; /* the sign-out form is invisible: its button is the menu item */
}
.menu__item:hover,
.menu__item:focus-visible {
  background: var(--table-head);
  outline: none;
}
.menu__item svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}
.menu__item--danger,
.menu__item--danger svg {
  color: var(--error-text);
}
.menu__divider {
  height: 1px;
  margin: var(--space-2) 0;
  background: var(--divider);
}
.menu__section-label {
  padding: var(--space-1) var(--space-3);
  color: var(--subtle);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}

/* Radio items (one choice among several, e.g. the theme) */
.menu__item--radio .menu__item-text {
  flex: 1;
  min-width: 0;
}
.menu__item-hint {
  display: block;
  color: var(--muted);
  font-size: var(--text-xs);
}
.menu__check {
  display: inline-flex;
  visibility: hidden;
}
.menu__check svg {
  color: var(--accent-text);
}
.menu__item--radio[aria-checked="true"] .menu__check {
  visibility: visible;
}
.menu__item--radio[aria-checked="true"] .menu__item-text {
  font-weight: var(--weight-semibold);
}

/* ---------- Side panel (drawer) ---------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer);
  background: var(--overlay);
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out);
}
.drawer-backdrop.is-open {
  opacity: 1;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: calc(var(--z-drawer) + 1);
  display: flex;
  flex-direction: column;
  width: min(var(--drawer-w), 100vw);
  border-left: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-dialog);
  transform: translateX(100%);
  transition: transform var(--duration-base) var(--ease-out);
}
.drawer.is-open {
  transform: translateX(0);
}
.drawer__form {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}
.drawer__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--divider);
}
.drawer__title {
  flex: 1;
  color: var(--ink);
  font-size: var(--fs-section);
  font-weight: var(--weight-bold);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}
.drawer__footer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--divider);
  background: var(--surface);
}
.drawer__footer-note {
  flex: 1;
  color: var(--muted);
  font-size: var(--fs-small);
}

/* ---------- Dialog (confirmation) ---------- */
.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--menu-border);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-dialog);
}
.dialog[open] {
  animation: dialog-in var(--duration-base) var(--ease-out);
}
.dialog::backdrop {
  background: var(--overlay);
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}
.dialog__body {
  padding: var(--space-6) var(--space-6) var(--space-4);
}
.dialog__title {
  margin-bottom: var(--space-2);
  color: var(--ink);
  font-size: var(--fs-section);
  font-weight: var(--weight-bold);
}
/* A long address in a dialog's help (Crear usuarios de prueba) wraps inside it on a phone. */
.dialog .field__hint {
  overflow-wrap: anywhere;
}
.dialog__message {
  color: var(--muted);
  font-size: var(--fs-body);
  line-height: var(--leading-body);
}
/* What a choice affects (e.g. the live ephemeral servers before «Apagar y vaciar»). */
.dialog__list {
  margin: var(--space-3) 0 0;
  padding-left: var(--space-5);
  font-size: var(--fs-small);
  max-height: 12rem;
  overflow-y: auto;
}
.dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6) var(--space-6);
}

/* ---------- Toast ---------- */
.toasts {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 260px;
  max-width: min(420px, calc(100vw - 32px));
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--menu-border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-control);
  background: var(--surface);
  box-shadow: var(--shadow-menu);
  font-size: var(--fs-secondary);
  pointer-events: auto;
  animation: toast-in var(--duration-base) var(--ease-out);
}
.toast--success {
  border-left-color: var(--success-dot);
}
.toast--error {
  border-left-color: var(--error-dot);
}
.toast--warning {
  border-left-color: var(--warning-dot);
}
.toast__message {
  flex: 1;
  min-width: 0;
}
.toast__action {
  flex: none;
}
.toast__close {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-right: calc(var(--space-2) * -1);
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.toast__close:hover {
  background: var(--table-head);
  color: var(--text);
}
.toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- Avatar ---------- */
.avatar {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--fs-small);
  font-weight: var(--weight-bold);
}

/* ---------- Principal picker (users / groups) ---------- */
.picker {
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--table-head);
}
.picker:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.picker .chip-list:not(:empty) {
  margin-bottom: var(--space-2);
}
.picker__search {
  position: relative;
}
.picker__input {
  width: 100%;
  padding: 6px var(--space-1);
  border: 0;
  background: transparent;
  outline: none;
}
.picker__input::placeholder {
  color: var(--subtle);
}
.picker__results {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  z-index: 5;
  max-height: 240px;
  margin-top: 6px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-dialog);
}
.picker__results:empty {
  display: none;
}
.picker__item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  font-size: var(--fs-secondary);
  cursor: pointer;
}
.picker__item:hover {
  background: var(--table-head);
}
.picker__item--add {
  color: var(--accent-text);
}
.picker__type {
  margin-left: auto;
  color: var(--muted);
  font-size: var(--fs-small);
}

/* ---------- Form section (titled group of fields) ---------- */
.form-section + .form-section {
  margin-top: var(--space-2);
  padding-top: var(--space-5);
  border-top: 1px solid var(--divider);
}
.form-section__title {
  margin-bottom: var(--space-4);
  color: var(--ink);
  font-size: var(--fs-block);
  font-weight: var(--weight-bold);
}
.form-section > .field-row:last-child .field,
.form-section > .field:last-child {
  margin-bottom: 0;
}
.form-section > .field-row + .field__hint {
  display: block;
  margin-top: calc(var(--space-2) * -1);
}
.form-section__spaced {
  margin-top: var(--space-4);
}

/* ---------- Combobox (suggestions + free entry) ---------- */
.combobox {
  position: relative;
}
.combobox__input {
  padding-right: 40px;
}
.combobox__toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  display: grid;
  place-items: center;
  width: 36px;
  border: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.combobox__toggle:hover {
  color: var(--text);
}
.combobox__list {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  z-index: 5;
  max-height: 240px;
  overflow: auto;
  padding: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-dialog);
}
.combobox__option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--fs-secondary);
  cursor: pointer;
}
.combobox__option:hover,
.combobox__option[aria-selected="true"] {
  background: var(--table-head);
}
.combobox__value {
  font-weight: var(--weight-medium);
}
.combobox__meta {
  margin-left: auto;
  color: var(--muted);
  font-size: var(--fs-small);
  white-space: nowrap;
}
.combobox__empty {
  padding: var(--space-3);
  color: var(--muted);
  font-size: var(--fs-small);
}

/* ---------- Tooltip (shown on hover / keyboard focus of its trigger) ---------- */
.has-tooltip,
.viewerbar__info {
  position: relative;
}
.tooltip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: var(--z-menu);
  min-width: 200px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-menu);
  color: var(--text);
  font-size: var(--text-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-2px);
  transition: opacity var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out),
    visibility 0s linear var(--duration-fast);
  pointer-events: none;
}
.has-tooltip:hover > .tooltip,
.has-tooltip:focus-within > .tooltip,
.viewerbar__info:hover > .tooltip,
.viewerbar__info:focus-within > .tooltip {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}
.tooltip__title {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.tooltip__body {
  font-variant-numeric: tabular-nums;
}
.tooltip__body + .tooltip__title {
  margin-top: var(--space-2);
}

/* ---------- Spinner (inside buttons while an action is running) ---------- */
.spinner {
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.btn[aria-busy="true"]:disabled {
  opacity: 0.8;
  cursor: progress;
}

/* ---------- Swatch (theme sample color, see partials/swatch.html) ---------- */
.swatch {
  flex: none;
  color: var(--text);
}

/* ---------- Form actions row ---------- */
.form-actions {
  display: flex;
  flex-wrap: wrap; /* long labels go to the next line on a phone instead of leaving the card */
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--divider);
}
/* Actions beside the fields of a row (Inactividad, Modo mantenimiento): level with the inputs, no rule above. */
.field-row > .form-actions {
  align-self: start;
  margin-top: 26px;
  padding-top: 0;
  border-top: 0;
}
.form-actions__note {
  flex: 1;
  color: var(--muted);
  font-size: var(--fs-small);
}

/* ---------- Theme picker (Administración → Apariencia) ----------
 * Each preview carries data-theme="<id>", so that theme's own tokens paint it.
 */
.theme-picker {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.theme-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}
.theme-option {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--table-head);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.theme-option:hover {
  border-color: var(--border-strong);
}
.theme-option:has(.theme-option__input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.theme-option:has(.theme-option__input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.theme-option__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.theme-option__label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-secondary);
  font-weight: var(--weight-semibold);
}
.theme-option__current {
  margin-left: auto;
}
.theme-preview {
  display: flex;
  flex-direction: column;
  height: 120px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}
.theme-preview__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 22px;
  padding: 0 var(--space-2);
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
}
.theme-preview__logo {
  width: 36px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--text);
}
.theme-preview__avatar {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.theme-preview__body {
  flex: 1;
  padding: var(--space-3);
}
.theme-preview__card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.theme-preview__line {
  width: 80%;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--text);
}
.theme-preview__line--short {
  width: 50%;
  background: var(--muted);
}
.theme-preview__button {
  align-self: flex-end;
  width: 34px;
  height: 12px;
  border-radius: 3px;
  background: var(--accent);
}

/* ---------- Servers (Administración → Servidores) ---------- */
.dot--warning {
  background: var(--warning-text);
}
.dot--danger {
  background: var(--error-text);
}
.meter--sm {
  width: 96px;
}
.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.link-btn:hover {
  text-decoration: underline;
}
.link-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.group + .group {
  margin-top: var(--section-gap);
}
.group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-3);
}
.group-head__title {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-section);
  font-weight: var(--weight-bold);
}
.detail + .detail {
  margin-top: var(--space-6);
}
.detail h3 {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-body);
  font-weight: var(--weight-semibold);
}
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-1) var(--space-4);
  margin: var(--space-2) 0 0;
  font-size: var(--fs-secondary);
}
.facts dt {
  color: var(--muted);
}
.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.problem-list {
  margin: var(--space-3) 0 0;
  padding-left: var(--space-5);
  font-size: var(--fs-secondary);
}
.problem-list li + li {
  margin-top: var(--space-1);
}
.cpu-chart {
  margin: var(--space-4) 0 0;
}
.cpu-chart__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  font-size: var(--fs-small);
}
.cpu-chart__plot {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-2);
}
.cpu-chart__axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: var(--muted);
  font-size: var(--fs-small);
  line-height: 1;
  text-align: right;
}
.cpu-chart__svg {
  display: block;
  width: 100%;
  height: 72px;
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  background: var(--table-head);
}
.cpu-chart__grid {
  stroke: var(--divider);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  vector-effect: non-scaling-stroke;
}
.cpu-chart__area {
  fill: var(--accent-soft);
}
.cpu-chart__line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}
.dialog--wide {
  width: min(560px, calc(100vw - 32px));
}
.dialog__content > * + * {
  margin-top: var(--space-3);
}
.copy-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--table-head);
}
.copy-row__text {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-secondary);
  overflow-wrap: anywhere;
  user-select: all;
}
.pending {
  margin-bottom: var(--space-6);
  border-color: var(--warning-dot);
  background: var(--warning-bg);
}
.pending__title {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-body);
  font-weight: var(--weight-semibold);
}
.pending__list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.pending__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--fs-secondary);
}
.pending__item + .pending__item {
  margin-top: var(--space-2);
}
.servers-settings {
  margin-top: var(--space-8);
}
.servers-settings + .servers-settings {
  margin-top: var(--space-4);
}
.servers-settings .setting > .btn {
  flex: none;
}
.servers-releases__list:not(:empty) {
  margin-top: var(--space-4);
}
.group-head__actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
}
/* «Ver log del agente»: the end of the log, scrollable, never wrapped. */
.dialog--log {
  width: min(960px, calc(100vw - 32px));
}
.log-view {
  margin: 0;
  max-height: min(60vh, 520px);
  overflow: auto;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--table-head);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  line-height: 1.45;
  white-space: pre;
}
.limits-row + .limits-row {
  margin-top: var(--space-3);
}
.limits-row__title {
  margin: 0 0 var(--space-1);
  font-size: var(--fs-secondary);
  font-weight: var(--weight-semibold);
}
/* A subtitle after the actions or a field of its section («Última prueba de conexión», «Aplicaciones abiertas»)
   keeps its distance from them (PB 2026-11-22). */
.form-section > :not(.form-section__title):not(.field__hint) + h3.limits-row__title {
  margin-top: var(--space-5);
}
.drawer__actions {
  display: inline-flex;
  gap: var(--space-2);
}
/* One row of buttons (Escalado automático): «Cerrar» on the left, the panel's actions on the right; they wrap on a
   phone (owner decision 2026-11-22: a single footer). */
.drawer__footer--single {
  flex-wrap: wrap;
}
.drawer__footer--single > .drawer__actions {
  flex-wrap: wrap;
  margin-left: auto;
}

/* A group whose servers disagree on something users notice (pool modes). */
.group-note {
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--warning-bg);
  border-left: 4px solid var(--warning-dot);
  border-radius: var(--radius-control);
  background: var(--warning-bg);
  color: var(--text);
  font-size: var(--fs-small);
}

/* Server panel: the refresh note sits under the title, and the footer has two
   rows so nothing is cut at narrow widths: the actions (wrapping), then the
   dangerous one apart on the left and «Cerrar» on the right. */
.drawer__heading {
  flex: 1;
  min-width: 0;
}
.drawer__subtitle {
  margin: var(--space-1) 0 0;
  color: var(--muted);
  font-size: var(--fs-small);
}
.drawer__footer--stacked {
  flex-direction: column;
  align-items: stretch;
}
.drawer__footer--stacked .drawer__actions {
  flex-wrap: wrap;
}
.drawer__footer-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--divider);
}
.drawer__footer-end > :last-child {
  margin-left: auto;
}

/* Server panel: the dangerous actions (retire) at the end, apart from the rest. */
.danger-zone {
  padding: var(--space-4);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-control);
}
.card.danger-zone {
  padding: var(--space-6);
  border-radius: var(--radius-card);
}
@media (max-width: 640px) {
  .card.danger-zone {
    padding: var(--space-4);
  }
}
.danger-zone h3 {
  color: var(--error-text);
}
.danger-zone p {
  margin: 0 0 var(--space-3);
}

/* A notice for everyone on the page (maintenance announced). */
.notice-banner {
  margin: 0 0 var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--warning-bg);
  border-left: 4px solid var(--warning-dot);
  border-radius: var(--radius-control);
  background: var(--warning-bg);
  color: var(--text);
}

/* ---------- Infraestructura (phase 6) ---------- */
.infra-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-3);
}
.infra-form > .infra-tags,
.infra-form > .field__error,
.infra-form > .form-actions {
  grid-column: 1 / -1;
}
.infra-tags {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  border: 0;
}
.infra-tags .field {
  margin-bottom: 0;
}
.infra-tags > legend {
  padding: 0;
}
.check-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.check-list > li + li {
  margin-top: var(--space-2);
}
.check-list__mark--ok {
  color: var(--success-text);
}
.check-list__mark--fail {
  color: var(--error-text);
}
.infra-soon {
  opacity: 0.7;
}

/* ---------- Base de datos (companies F1) ---------- */
.db-form {
  display: grid;
  gap: var(--space-4);
}
.db-step {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.db-step > legend {
  padding: 0 var(--space-1);
}
.db-step > .field__hint,
.db-step > .form-actions,
.db-step > .toggle,
.db-step > .db-step__full {
  grid-column: 1 / -1;
}
.db-step > .form-actions {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.db-form > .field__error {
  margin: 0;
}
.db-cert {
  margin: 0;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--table-head);
}
.db-cert__hash {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  overflow-wrap: anywhere;
}
.db-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-2) var(--space-4);
  margin: var(--space-3) 0 0;
}
.db-facts > dt {
  color: var(--subtle);
}
.db-facts > dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.db-state--ok {
  color: var(--success-text);
}
.db-state--bad {
  color: var(--error-text);
}
.db-revert {
  margin-top: var(--space-4);
}
.db-revert > summary {
  cursor: pointer;
  color: var(--error-text);
}
@media (max-width: 40rem) {
  .db-facts {
    grid-template-columns: 1fr;
  }
}

/* ---------- Grupos de servidores (companies F2) ---------- */
.groups-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-3);
}
.groups-form > .groups-form__how,
.groups-form > .field__error,
.groups-form > .form-actions {
  grid-column: 1 / -1;
}
.groups-steps {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-5);
  color: var(--muted);
}
.groups-grid {
  margin-bottom: var(--space-4); /* the next card («Servidores plantilla») was touching it */
  display: grid;
  /* Wide enough for a card's actions to sit in a row (PB 2026-11-22: three cards of 400 px stacked them). */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 32rem), 1fr));
  gap: var(--space-4);
}
.group-card {
  display: grid;
  gap: var(--space-2);
  align-content: start;
}
.group-card--retired {
  opacity: 0.7;
}
.group-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.group-card__head > :first-child {
  flex: 1 1 14rem;
  min-width: 0;
}
.group-card__title {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-section);
  font-weight: var(--weight-bold);
}
.group-card__actions {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--space-1);
}
.group-card p {
  margin: 0;
}
.group-card__desc {
  color: var(--muted);
}
/* A definition list on one or two lines: «Servidores 1  Plazas libres 46 de 50 …» (density pass, rule C). */
.inline-facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-5);
  margin: 0;
  font-size: var(--fs-secondary);
}
.inline-facts > div {
  display: flex;
  flex: 0 0 auto; /* a fact goes to the next line whole instead of squeezing its value */
  gap: 6px;
  max-width: 100%;
}
.inline-facts dt {
  color: var(--muted);
}
.inline-facts dd {
  margin: 0;
  color: var(--text);
}
.group-card__servers {
  display: grid;
  gap: 2px;
  margin: var(--space-1) 0 0;
  padding: 0;
  list-style: none;
}
.group-card__server {
  color: var(--text);
  font-weight: var(--weight-semibold);
}
.group-card .form-actions {
  margin-top: 0;
  gap: var(--space-2);
}
/* The template: a section of the card under a divider, not a box. */
.template-block {
  display: grid;
  gap: var(--space-1);
  margin-top: var(--space-2);
  padding-top: var(--form-gap);
  border-top: 1px solid var(--divider);
}
.template-block__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.template-block__title {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: var(--weight-bold);
}
.template-block .muted,
.template-block .field__hint {
  font-size: var(--fs-secondary);
}
.template-row__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}
.template-row__actions {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--space-1);
}
/* Technical identifiers (instance, image, commit): monospaced, secondary colour, no background (rule B). */
:root:not([data-viewer-tokens]) .admin-main code:not(.copy-row code) {
  color: var(--muted);
  font-size: var(--fs-small);
}
.template-block__name {
  overflow-wrap: break-word;
}
.template-block__how summary {
  cursor: pointer;
  color: var(--muted);
}
/* A command inside its step's <li> (B-005: not an <li> of its own, which counted in the numbering). */
.template-block__cmd,
.template-block__alt {
  margin: var(--space-1) 0 var(--space-2);
}
.template-list {
  display: grid;
  gap: var(--space-3);
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
}
.template-row {
  display: grid;
  gap: var(--space-1);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.template-row .form-actions {
  margin-top: 0;
}
.publish-progress {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--table-head);
}
.publish-progress p {
  margin: 0;
}
.publish-steps,
.publish-log,
.image-list {
  margin: 0;
  padding-left: var(--space-5);
}
.publish-steps__item--done {
  color: var(--muted);
  text-decoration: line-through;
}
.publish-steps__item--now {
  font-weight: 600;
}
.publish-steps__item--fail {
  color: var(--error-text);
  font-weight: 600;
}
.publish-steps__item--todo {
  color: var(--muted);
}
.publish-log {
  color: var(--muted);
  font-size: var(--fs-small);
  overflow-wrap: anywhere;
}
.publish-log__fail {
  color: var(--error-text);
}
/* A failed publication in the group's card: in sight until it is retried or replaced. */
.publish-failed {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--danger-border);
  border-left: 4px solid var(--error-text);
  border-radius: var(--radius-sm);
  background: var(--error-bg);
  overflow-wrap: anywhere;
}
.publish-failed p {
  margin: 0;
}
.publish-failed__title strong {
  color: var(--error-text);
}
.publish-failed .form-actions {
  margin-top: 0;
}
.publish-failed__log summary {
  cursor: pointer;
}
/* The whole text of a failure: its line breaks kept, long lines wrapped instead of scrolled. */
.log-view--wrap {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.template-row__images summary {
  cursor: pointer;
}
.image-row {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-2) 0;
  overflow-wrap: anywhere;
}
.image-row .form-actions {
  margin-top: 0;
}

/* ---------- Empresas (companies F2) ---------- */
.companies-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--divider);
}
.companies-toolbar > .input {
  flex: 1 1 18rem;
}
.companies-toolbar > .select {
  flex: 0 1 14rem;
}
.companies-empty {
  margin: 0;
  padding: var(--space-4);
}
/* An empty list in a table's frame inside a card: the line alone, without a second frame (PB review 2026-11-22). */
.table-wrap:has(> p:only-child) {
  border: 0;
  background: transparent;
}
.table-wrap > p:only-child {
  padding-left: 0;
  padding-right: 0;
}
/* Empresas' card has no padding of its own: its empty line keeps the toolbar's margin (audit of 2026-11-25: the text
   touched the card's edge). */
.table-wrap > p.companies-empty:only-child {
  padding: var(--space-4) var(--card-pad);
}
.companies-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--divider);
  color: var(--muted);
  font-size: var(--fs-small);
}
.companies-pager__buttons {
  display: flex;
  gap: var(--space-2);
}
.company-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: inherit;
  text-decoration: none;
}
.company-link > span {
  display: grid;
}
/* B-014: the company's name has priority over the other columns (at 1366 px it wrapped into 107 px); a long name
   ends in «…» and shows whole on hover (its title). */
.companies-table td:first-child {
  width: 32%;
  min-width: 15rem;
  max-width: 26rem;
}
.companies-table .company-link {
  display: flex;
  max-width: 100%;
}
.companies-table .company-link > span {
  min-width: 0;
}
.companies-table .company-link .table__title,
.companies-table .company-link .table__sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The company's colour comes as --brand (CSSOM), with --brand-text, the text that reads better on it (brand.js
   bestText; a colour below 4.5:1 is saved with a warning); without a colour, the accent of the theme. */
.company-badge {
  --brand: var(--accent);
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--brand-text, var(--on-accent));
  font-size: var(--fs-small);
  font-weight: var(--weight-bold);
}
.company-badge--lg {
  width: 56px;
  height: 56px;
  font-size: var(--fs-block);
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  font-size: var(--fs-small);
}
.back-link svg {
  width: 16px;
  height: 16px;
}
.company-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.company-head__text {
  flex: 1 1 18rem;
}
.company-head h1 {
  margin: 0;
}
.company-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden; /* no vertical scroll mark beside the tabs (PB 2026-11-22) */
  scrollbar-width: thin;
  gap: var(--space-1);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: none;
  white-space: nowrap;
  margin-bottom: -1px;
  padding: var(--space-3) var(--space-3);
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: var(--fs-secondary);
  text-decoration: none;
}
.tab[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--accent-text);
  font-weight: var(--weight-semibold);
}
.tab[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.7;
}
/* «Próximamente»: secondary text, no box (rule B). */
.soon {
  display: inline-block;
  align-self: center;
  justify-self: start;
  width: max-content;
  margin-left: var(--space-1);
  padding: 0;
  background: none;
  color: var(--muted);
  font-size: var(--fs-small);
  font-weight: var(--weight-regular);
}
.company-form {
  display: grid;
  gap: var(--space-4);
}
.company-form > .form-section {
  margin: 0;
}
.company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: var(--space-3) var(--space-4);
}
.company-apps,
.company-sub {
  margin: var(--space-3) 0 0;
  padding: 0;
  border: 0;
}
.company-applist {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-2) 0;
  padding: 0;
  list-style: none;
}
.company-applist__label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.company-applist__warning {
  display: block;
  margin-left: var(--space-6);
  color: var(--muted);
}
.company-option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.company-option > span {
  display: grid;
  gap: var(--space-1);
}
.company-option--selected {
  border-color: var(--accent);
}
.company-option--soon,
.toggle--soon {
  opacity: 0.7;
}
/* A menu inside a scrolling table: placed next to its button over the page
 * (users.js sets top and left), so the table does not cut it. */
.menu__panel--fixed {
  position: fixed;
  right: auto;
}

/* «Solo algunos usuarios» (companies F3): the button of each application, and
 * a list that scrolls inside the dialog. */
.company-applist__item [data-limit] {
  margin-left: var(--space-2);
}
.limit-list {
  max-height: 18rem;
  margin-top: var(--space-2);
  overflow-y: auto;
}

/* Plataforma → Correo (companies F3): the address and the button of the test. */
.mail-test {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
}
.mail-test .field {
  flex: 1 1 18rem;
  margin: 0;
}

/* Users of a company (companies F3): the bar of the selected users. */
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--divider);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.import-results {
  display: grid;
  gap: var(--space-3);
}

/* Users of a company (companies F3): the choices of a new user. */
.company-options,
.check-group {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  border: 0;
}
.check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.company-checks {
  display: grid;
  gap: var(--form-gap);
  margin-top: var(--space-4);
}
.company-checks > .field,
.company-checks > fieldset {
  margin-bottom: 0;
}
/* «Tamaños permitidos»: a grid of 4 columns (2 on a phone) instead of one column of eight. */
.company-applist.company-applist--grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-2) var(--space-4);
}
@media (max-width: 640px) {
  .company-applist.company-applist--grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  /* The two modes in words take the whole row; the sizes go two by two. */
  .company-applist.company-applist--grid > li:nth-child(-n + 2) {
    grid-column: 1 / -1;
  }
}
.company-days {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.company-day {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}
.company-narrow {
  max-width: 18rem;
}
/* Estado (companies F6): the forms to inactivate and reactivate. */
.status-form {
  display: grid;
  gap: var(--space-4);
}
.status-mode {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  border: 0;
}
.status-mode > legend {
  margin-bottom: var(--space-2);
}
.status-history {
  margin-top: var(--space-5);
}
.status-mode .company-option:has(input:checked) {
  border-color: var(--accent);
}
.company-actions {
  justify-content: flex-end;
}
/* Appearance (F2c). The logo is shown inside a box of the badge's size; the colour of the swatches and of the
   preview comes as --swatch / --brand / --brand-text set through CSSOM, never as a style attribute. */
/* A logo keeps its proportions: the badge's height, up to about three times as wide. */
.company-logo {
  flex: none;
  width: auto;
  max-width: 120px;
  height: 36px;
  object-fit: contain;
}
.company-logo--md {
  max-width: 140px;
  height: 44px;
}
.company-logo--lg {
  max-width: 180px;
  height: 56px;
}
.company-badge--md {
  width: 44px;
  height: 44px;
}
.company-look {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: var(--space-4);
}
.company-look__fields {
  display: grid;
  gap: var(--space-3);
  align-content: start;
}
.company-upload {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}
.company-upload__text {
  display: grid;
  flex: 1 1 12rem;
  gap: var(--space-1);
}
.company-swatches,
.company-swatches__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.company-swatch {
  --swatch: var(--accent);
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid var(--surface);
  border-radius: var(--radius-sm);
  background: var(--swatch);
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
}
.company-swatch--theme {
  width: auto;
  padding: 0 var(--space-2);
  background: var(--table-head);
  color: var(--text);
  font-size: var(--fs-small);
  font-weight: var(--weight-semibold);
}
.company-swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--text);
}
.company-swatch:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.input.company-color {
  width: 8rem;
}
.company-preview {
  display: flex;
  justify-content: center;
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--table-head);
}
.company-preview__box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: min(260px, 100%);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.company-preview__logo {
  max-width: 140px;
  max-height: 40px;
  object-fit: contain;
}
.company-mark--sm {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  font-size: var(--fs-secondary);
}
.company-preview__welcome {
  color: var(--muted);
  font-size: var(--fs-small);
  text-align: center;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.company-preview__input {
  width: 100%;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.company-preview__button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--brand, var(--accent));
  color: var(--brand-text, var(--on-accent));
  font-size: var(--fs-small);
  font-weight: var(--weight-semibold);
}
.company-preview__footer {
  color: var(--muted);
  font-size: var(--fs-small);
}
.companies-public {
  margin-top: var(--space-4);
}
.companies-public__form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-3) 0 var(--space-2);
}
.companies-public__form .input {
  flex: 1 1 18rem;
  max-width: 28rem;
}

/* Conectados (companies F4): the title of the open applications' card, next
   to «Cerrar todas». */
.connected-title {
  flex: 1 1 auto;
  align-self: center;
  margin: 0;
  font-size: var(--fs-block);
}

/* Auditoría (companies F4): the custom period's dates, the line saying whose
   events are shown, and the retention note under the list. */
.audit-dates {
  display: inline-flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.audit-dates > .input {
  width: auto;
}
.audit-dates__label {
  color: var(--muted);
  font-size: var(--fs-small);
}
.audit-who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--divider);
}
.audit-note {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-small);
}

/* Mensajes (companies F5): the form (types, recipients, the user search),
   and the message itself as the portal, the viewer and the preview show it:
   the kind's colour, with the company's colour as its accent when the page
   has one (company-branded pages set --brand). */
.messages {
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* a wide history scrolls in its card, never the page */
  gap: var(--space-5);
}
.table td.msg-col {
  min-width: 15rem;
}
.msg-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
}
.msg-nowrap {
  white-space: nowrap;
}
.table td.msg-actions {
  vertical-align: top;
}
.msg-form {
  margin: 0;
}
.msg-kinds,
.msg-audience {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}
.msg-audience {
  flex-direction: column;
}
.msg-choice {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-body);
}
.msg-inline.select {
  width: auto;
  min-width: 12rem;
}
.msg-users {
  display: grid;
  gap: var(--space-2);
}
.msg-results {
  margin: 0;
  padding: var(--space-1);
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.msg-results > li.muted {
  padding: var(--space-2) var(--space-3);
}
.msg-result {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.msg-result:hover,
.msg-result:focus-visible {
  background: var(--table-head);
}
.msg-preview {
  max-width: 48rem;
}
.msg-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand, var(--accent));
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--text);
}
.msg-banner--warning {
  background: var(--warning-bg);
}
.msg-banner--urgent {
  border-color: var(--error-text);
  background: var(--error-bg);
}
.msg-banner__icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-pill);
  background: var(--brand, var(--accent));
  color: var(--brand-text, var(--on-accent));
  font-weight: var(--weight-bold);
}
.msg-banner--urgent .msg-banner__icon {
  background: var(--error-text);
  color: var(--on-accent);
}
.msg-banner__text {
  flex: 1 1 12rem; /* beside its icon even on a phone; the button wraps below */
  min-width: 0;
}
.msg-banner__title {
  display: block;
}
.msg-banner__body {
  margin: var(--space-1) 0 0;
  white-space: pre-line; /* the administrator's line breaks, as text */
  overflow-wrap: anywhere;
}
.msg-banner__btn {
  flex: none;
}
.portal-messages {
  display: grid;
  gap: var(--space-3);
  margin: 0 0 var(--space-5);
}
/* The notice of a scheduled inactivation (companies F6), above the messages. */
.portal-suspension {
  margin: 0 0 var(--space-3);
}
.msg-more {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}
/* A company message over an open application: under the viewer's bar,
   above the stage, without moving it. */
.viewer-messages {
  position: fixed;
  top: calc(var(--viewer-bar-h) + var(--space-3));
  left: 50%;
  z-index: var(--z-toast);
  display: grid;
  gap: var(--space-2);
  width: min(40rem, calc(100% - 2 * var(--space-4)));
  transform: translateX(-50%);
}
.viewer-messages[hidden] {
  display: none;
}
.viewer-messages .msg-banner {
  box-shadow: var(--shadow-dialog);
}
/* Conectados: «Enviar mensaje a los conectados» beside «Cerrar todas». */
.companies-toolbar > .connected-actions {
  margin: 0 0 0 auto;
  padding-top: 0;
  border-top: 0;
}

/* ---------- Estado (monitoring, admin) ---------- */
.form-section__subtitle {
  margin: var(--space-6) 0 var(--space-3);
  font-size: var(--fs-secondary);
}
/* The page header's summary line and the filter (density pass: one list, the problems first). */
.status-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: calc(-1 * var(--space-2)) 0 var(--space-4);
}
.status-summary {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-body);
  font-weight: var(--weight-semibold);
}
/* Segmented control: buttons with aria-pressed. */
.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--table-head);
}
.segmented__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: calc(var(--btn-h-sm) - 4px);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: calc(var(--radius-control) - 2px);
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-secondary);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}
.segmented__btn:hover {
  color: var(--text);
}
.segmented__btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--border);
}
.segmented__count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-regular);
}

/* The list: one card, an area per block with its heading, a row per check. */
.status-list {
  padding: 0;
}
.status-area + .status-area {
  border-top: 1px solid var(--divider);
}
.status-area__head {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--form-gap) var(--card-pad) var(--space-2);
}
.status-area__title {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-block);
  font-weight: var(--weight-bold);
}
.status-area__state {
  color: var(--muted);
  font-size: var(--fs-secondary);
}
.status-rows {
  margin: 0;
  padding: 0;
  list-style: none;
}
.status-row {
  display: grid;
  grid-template-columns: var(--icon-sm) minmax(12rem, 18rem) minmax(0, 1fr) 6rem var(--btn-h-sm);
  align-items: start;
  gap: var(--space-3);
  padding: var(--space-1) var(--card-pad);
  font-size: var(--fs-body);
}
.status-rows {
  padding-bottom: var(--space-2);
}
.status-row:hover,
.status-row:focus-within {
  background: color-mix(in srgb, var(--table-head) 60%, transparent);
}
.status-row > * {
  min-width: 0;
  padding-top: 5px;
}
.status-row > .status-row__action {
  padding-top: 0;
}
/* The state mark: a muted dot when it is fine, the coloured icon when it needs attention. */
.status-row__mark {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(var(--fs-body) * 1.5 + 10px);
  padding-top: 0 !important;
}
.status-row__mark > .state,
.status-row__mark > .chip {
  gap: 0;
  font-size: 0; /* the word is in the row's accessible text (.sr-only) */
}
.status-row__name {
  color: var(--text);
  font-weight: var(--weight-semibold);
}
.status-row__detail {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-4);
  color: var(--muted);
}
.status-row--quiet .status-row__name {
  color: var(--muted);
  font-weight: var(--weight-regular);
}
.status-row__when {
  color: var(--subtle);
  font-size: var(--fs-secondary);
  text-align: right;
  white-space: nowrap;
}
/* The row's «Comprobar»: on hover or focus of the row; always on a touch screen. */
.status-row__action {
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
}
.status-row:hover .status-row__action,
.status-row:focus-within .status-row__action {
  opacity: 1;
}
@media (hover: none) {
  .status-row__action {
    opacity: 1;
  }
}
/* One subject of a check: its name, value and state, and its own actions. */
.status-subject {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
  min-width: 0;
}
.status-subject__name {
  color: var(--text);
}
.status-subject__value {
  color: var(--muted);
}
/* A subject that needs attention: its value in the state's colour (the row's mark already says which state). */
.status-subject--warn .status-subject__value,
.status-subject--warn .status-subject__name {
  color: var(--warning-text);
  font-weight: var(--weight-semibold);
}
.status-subject--crit .status-subject__value,
.status-subject--crit .status-subject__name {
  color: var(--error-text);
  font-weight: var(--weight-semibold);
}
.status-subject--nodata .status-subject__value {
  color: var(--muted);
  font-style: italic;
}
.status-history-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.status-history-filter .field__label {
  margin: 0;
}
.status-history-filter .select {
  width: auto;
  min-width: 0;
  max-width: min(20rem, 100%);
}
.status-subject .btn {
  align-self: center;
}
.status-subjects {
  display: grid;
  gap: var(--space-1);
  width: 100%;
}
.status-more {
  width: 100%;
}
.status-more > summary {
  color: var(--accent-text);
  cursor: pointer;
}
.status-more[open] > summary {
  margin-bottom: var(--space-1);
}
/* The checks that do not apply here, folded under their area. */
.status-quiet {
  padding: var(--space-2) var(--card-pad) var(--space-3);
  border-top: 1px solid var(--divider);
  color: var(--muted);
  font-size: var(--fs-secondary);
}
.status-quiet > summary {
  cursor: pointer;
}
.status-quiet__list {
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
  columns: 2 18rem;
}
.status-empty {
  margin: 0;
  padding: var(--space-6) var(--card-pad);
  color: var(--muted);
}
@media (max-width: 900px) {
  .status-row {
    grid-template-columns: var(--icon-sm) minmax(0, 1fr) var(--btn-h-sm);
  }
  .status-row__detail {
    grid-column: 2 / -1;
  }
  .status-row__when {
    grid-column: 2 / -1;
    text-align: left;
  }
  .status-row > .status-row__action {
    grid-column: 3;
    grid-row: 1;
  }
}
.status-settings__summary {
  display: inline;
  cursor: pointer;
}
.status-config .input {
  width: 6.5em;
}
.status-config td {
  white-space: nowrap;
}
.status-config .field__error {
  white-space: normal;
}

/* ---------- Charts (core/chart.js; Administración → Métricas) ---------- */
.chart {
  margin: 0;
}
.chart__title {
  margin-bottom: var(--space-2);
  color: var(--ink);
  font-size: var(--fs-block);
  font-weight: var(--weight-bold);
}
/* Métricas (density pass): each chart in its own box, its title and «Ampliar» on top. */
.chart--box {
  min-width: 0;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.chart__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}
.chart__head .chart__title {
  min-width: 0;
}
.chart__expand {
  flex: none;
  margin-top: -6px;
}
.chart__frame {
  fill: none;
  stroke: var(--border);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.chart__key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-small);
  cursor: pointer;
}
.chart__key:hover {
  color: var(--text);
}
.chart__key[aria-pressed="false"] {
  color: var(--subtle);
  text-decoration: line-through;
}
.chart__swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.chart__area {
  position: relative;
}
.chart__svg {
  display: block;
  width: 100%;
  height: 200px;
  overflow: visible;
}
.chart__svg--tall {
  height: 360px;
}
.chart__grid {
  stroke: var(--divider);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.chart__axis {
  fill: var(--muted);
  font-size: var(--fs-small);
}
.chart__line {
  fill: none;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.chart__cursor {
  stroke: var(--border-strong);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.chart__hit {
  fill: transparent;
}
.chart__tip {
  position: absolute;
  top: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-size: var(--fs-small);
  pointer-events: none;
}
.chart__data {
  margin-top: var(--space-2);
  font-size: var(--fs-small);
}
.chart__line.chart-s1 { stroke: var(--accent); }
.chart__line.chart-s2 { stroke: var(--success-text); }
.chart__line.chart-s3 { stroke: var(--warning-text); }
.chart__line.chart-s4 { stroke: var(--error-text); }
.chart__line.chart-s5 { stroke: var(--success-text); }
.chart__line.chart-s6 { stroke: var(--accent-text); }
.chart__swatch.chart-s1 { background: var(--accent); }
.chart__swatch.chart-s2 { background: var(--success-text); }
.chart__swatch.chart-s3 { background: var(--warning-text); }
.chart__swatch.chart-s4 { background: var(--error-text); }
.chart__swatch.chart-s5 { background: var(--success-text); }
.chart__swatch.chart-s6 { background: var(--accent-text); }
.metrics-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr));
}
.metrics-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
  align-items: end;
}
.metrics-filters .field {
  margin: 0;
}
.metrics-toolbar {
  margin-bottom: var(--space-4);
}
.metrics-toolbar > .muted {
  margin-top: var(--space-2);
  font-size: var(--fs-secondary);
}
.metrics-charts + .card {
  margin-top: var(--section-gap);
}
/* A section's title with an icon button at its right («Ampliar»). */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.section-head > .form-section__title {
  margin-bottom: 0;
}
.section-head + .field__hint {
  margin-top: var(--space-1);
}

/* The large dialog: a chart or a table, bigger (90 % of the width, at most 1200 px). */
.dialog--large {
  width: min(1200px, 90vw);
  max-height: 90vh;
}
.dialog-large__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--card-pad);
  border-bottom: 1px solid var(--divider);
}
.dialog-large__head .dialog__title {
  flex: 1;
  margin: 0;
}
.dialog-large__tools {
  flex: none;
}
.dialog-large__body {
  max-height: calc(90vh - 72px);
  overflow: auto;
  padding: var(--space-4) var(--card-pad) var(--card-pad);
}
.dialog-large__body .chart__data {
  margin-top: var(--space-4);
}
.dialog-large__body .chart__data > summary {
  display: none;
}

/* ---------- Apariencia → Pantalla de acceso: the accent colour ---------- */
/* --ls-accent and --ls-on-accent come from loginscreen.js through CSSOM (no inline style). */
.login-accent {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}
.login-accent__picker {
  width: 44px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
.login-accent__hex {
  width: 13ch;
}
.login-accent__preview {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--ls-accent, var(--accent));
  color: var(--ls-on-accent, var(--on-accent));
  font-weight: var(--weight-bold);
}

/* ---------- Métricas → Por sesión ---------- */
#ms-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
#ms-table .ms-warn {
  color: var(--error-text);
  font-weight: 700;
}
#ms-table .ms-total th,
#ms-table .ms-total td {
  border-bottom-width: 2px;
  font-weight: 600;
}
.ms-csv__go {
  align-self: end;
}

/* ---------- Actualizar RemoteUI (gwupdatesadmin.go) ---------- */
.update-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.update-alert > p {
  flex: 1 1 16rem;
  margin: 0;
}
.update-version {
  margin: 0 0 var(--space-1);
  font-size: var(--fs-block);
  font-weight: var(--weight-semibold);
}
/* The install in progress: a section of the card under a divider, not a box (density pass, rule C). */
.update-progress {
  margin-top: var(--form-gap);
  padding-top: var(--form-gap);
  border-top: 1px solid var(--divider);
}
.update-progress__title {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-block);
}
.update-log {
  margin: var(--space-3) 0 0;
  padding-left: var(--space-5);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  overflow-wrap: anywhere;
}
.update-log:empty {
  display: none;
}
.update-history {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-secondary);
}
.update-history__at {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.update-history__bad {
  color: var(--error-text);
}
.update-when {
  display: grid;
  gap: var(--space-3);
  margin: var(--space-3) 0;
}
.update-when[hidden] {
  display: none;
}
.update-notes {
  margin: var(--space-3) 0;
}
.update-notes h4 {
  margin: var(--space-3) 0 var(--space-1);
  font-size: var(--fs-body);
}
.update-notes__body {
  margin: 0;
  white-space: pre-line;
  font-size: var(--fs-secondary);
}
/* ---------- «Más» (core/more.js): one icon button, the secondary actions in a menu ---------- */
.more {
  display: inline-flex;
  flex: none;
}
.more__panel {
  min-width: 220px;
  padding: var(--space-1);
}
.more__panel .menu__item {
  padding: 6px var(--space-3);
  font-size: var(--fs-body);
}
.more__panel .menu__divider {
  margin: var(--space-1) 0;
  background: var(--divider);
}
/* Row actions: on hover or focus of the row; always on a touch screen (density pass, rule C). */
.row-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
}
tr:hover .row-actions,
tr:focus-within .row-actions,
.row-actions:has([aria-expanded="true"]) {
  opacity: 1;
}
@media (hover: none) {
  .row-actions {
    opacity: 1;
  }
}
/* An empty list in a card with a table (no padding of its own): the line keeps the card's margin. */
.table-card .table-wrap > p:only-child,
.table-card > .companies-empty {
  padding: var(--space-4) var(--card-pad);
}
/* A row of fields and their action (Base de datos «Usuario de medición», Infraestructura «Añadir», the wizard): each
 * field as wide as its value needs, the button its own width (density pass: no full-width fields or buttons). */
.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
}
.form-row > .field,
.form-row > .input,
.form-row > .select {
  flex: 0 1 18rem;
  min-width: 10rem;
  margin: 0;
}
.form-row > .btn,
.form-row > .field:has(> .btn:only-child) {
  flex: none;
  min-width: 0;
}

.instance-burst,
.form-section__subtitle > [data-scale-chip] {
  margin-left: var(--space-2);
}
/* A neutral event of the audit: plain text (rule B: the usual is not a label, nor greyed out). */
.chip.chip--text.chip--plain {
  color: var(--text);
}
/* What follows a block of setting rows keeps the rows' distance (Cells: «Cuenta de AWS» after «Alta automática»). */
.company-checks + * {
  margin-top: var(--form-gap);
}

/* ---------- Calendars (F-002 phase 1: Plataforma → Calendarios) ---------- */
[data-slot="laboral"] { --edge: var(--slot-laboral-edge); --tint: var(--slot-laboral-tint); --sink: var(--slot-laboral-ink); }
[data-slot="noche"] { --edge: var(--slot-noche-edge); --tint: var(--slot-noche-tint); --sink: var(--slot-noche-ink); }
[data-slot="finde"] { --edge: var(--slot-finde-edge); --tint: var(--slot-finde-tint); --sink: var(--slot-finde-ink); }
[data-slot="festivo"] { --edge: var(--slot-festivo-edge); --tint: var(--slot-festivo-tint); --sink: var(--slot-festivo-ink); }
[data-cal="0"] { --calc: var(--cal-mark-0); }
[data-cal="1"] { --calc: var(--cal-mark-1); }
[data-cal="2"] { --calc: var(--cal-mark-2); }
[data-cal="3"] { --calc: var(--cal-mark-3); }
[data-cal="4"] { --calc: var(--cal-mark-4); }
[data-cal="5"] { --calc: var(--cal-mark-5); }
.cal-head-actions { margin-left: auto; }
.cal-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.cal-toolbar__title { min-width: 12ch; margin: 0 var(--space-3); font-size: var(--fs-section); }
.cal-toolbar__spacer { flex: 1; }
.cal-toolbar__cell { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--muted); font-size: var(--fs-secondary); }
.cal-toolbar__cell .select { width: auto; min-width: 220px; }
.cal-legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); margin-bottom: var(--space-3); }
.cal-legend__item { display: grid; gap: 2px; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-left: 4px solid var(--edge); border-radius: var(--radius-item); background: var(--surface); }
.cal-legend__name { color: var(--text); font-weight: var(--weight-bold); }
.cal-legend__meta { color: var(--muted); font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.cal-legend__empty { grid-column: 1 / -1; margin: 0; padding: var(--space-2) var(--space-3); border-radius: var(--radius-item); background: var(--neutral-bg); color: var(--neutral-text); font-size: var(--fs-secondary); }
.cal-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.cal-rail { display: grid; gap: var(--space-5); }
.cal-rail__title { margin: 0 0 var(--space-2); color: var(--muted); font-size: var(--fs-small); font-weight: var(--weight-semibold); }
.cal-rail__actions { display: grid; gap: var(--space-2); margin-top: var(--space-2); }
.cal-mini__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-1); font-weight: var(--weight-bold); }
.cal-mini__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; font-size: var(--fs-small); font-variant-numeric: tabular-nums; text-align: center; }
.cal-mini__dow { padding: 2px 0; color: var(--subtle); font-weight: var(--weight-semibold); }
.cal-mini__day { position: relative; height: 28px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; cursor: pointer; }
.cal-mini__day:hover { background: var(--neutral-bg); }
.cal-mini__day:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.cal-mini__day--out { color: var(--muted); }
.cal-mini__day--week { background: var(--accent-soft); }
.cal-mini__day--today { background: var(--accent); color: var(--on-accent); font-weight: var(--weight-bold); }
.cal-mini__day--holiday::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--slot-festivo-edge); }
.cal-mini__day--today.cal-mini__day--holiday::after { background: var(--on-accent); }
.cal-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.cal-list__item { display: grid; grid-template-columns: auto auto 1fr; align-items: start; gap: 2px var(--space-2); padding: 6px var(--space-2); border-radius: var(--radius-item); cursor: pointer; }
.cal-list__item:hover { background: var(--neutral-bg); }
.cal-list__item input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--calc); }
.cal-mark { width: 10px; height: 10px; margin-top: 5px; border-radius: 3px; background: var(--calc); }
.cal-list__name { min-width: 0; overflow-wrap: anywhere; }
.cal-list__default { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--accent-soft); color: var(--accent-text); font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.cal-list__sub { display: block; color: var(--muted); font-size: var(--text-xs); }
.cal-month { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
.cal-month__dows, .cal-month__row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-month__dows div { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); color: var(--muted); font-size: var(--fs-small); font-weight: var(--weight-semibold); }
.cal-day { display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 92px; padding: 6px 8px 8px; border: 0; border-right: 1px solid var(--divider); border-bottom: 1px solid var(--divider); background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.cal-month__row .cal-day:nth-child(7) { border-right: 0; }
.cal-day:hover { background: var(--neutral-bg); }
.cal-day:focus-visible { z-index: 1; outline: 2px solid var(--focus); outline-offset: -2px; }
.cal-day--out { background: var(--bg); }
.cal-day--out .cal-day__num { color: var(--muted); }
.cal-day__num { display: inline-grid; place-items: center; align-self: flex-start; min-width: 24px; height: 24px; border-radius: 12px; font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.cal-day--today .cal-day__num { background: var(--accent); color: var(--on-accent); }
.cal-day__name { color: var(--slot-festivo-ink); font-size: var(--text-xs); font-weight: var(--weight-semibold); line-height: 1.25; overflow-wrap: anywhere; }
.cal-day__name--exc { text-decoration: underline dashed var(--slot-festivo-edge); text-underline-offset: 3px; }
.cal-bars { display: grid; gap: 5px; margin-top: auto; }
.cal-bars__row { display: flex; align-items: center; gap: 5px; }
.cal-bars__cal { flex: none; width: 4px; height: 12px; border-radius: 2px; background: var(--calc); }
.cal-bars__bar { display: flex; flex: 1; gap: 1px; height: 8px; overflow: hidden; border-radius: 4px; }
.cal-bars__bar span { min-width: 2px; background: var(--edge); }
.cal-bars__bar--exc { outline: 1px dashed var(--slot-festivo-edge); outline-offset: 2px; }
.cal-tip { position: absolute; z-index: var(--z-menu); display: grid; gap: 2px; max-width: 340px; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-item); background: var(--surface); box-shadow: var(--shadow-menu); color: var(--text); font-size: var(--fs-small); pointer-events: none; }
.cal-tip span { color: var(--muted); }
.cal-hint { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin: 0 0 var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-item); background: var(--neutral-bg); color: var(--neutral-text); font-size: var(--fs-small); }
.cal-hint--dirty { background: var(--warning-bg); color: var(--warning-text); }
.cal-hint--dirty span { flex: 1; }
.cal-week { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
.cal-week__head, .cal-week__body { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); }
.cal-week__head { border-bottom: 1px solid var(--border); }
.cal-week__dh { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: var(--space-2); border-left: 1px solid var(--divider); }
.cal-week__dh span { color: var(--muted); font-size: var(--fs-small); }
.cal-week__dh b { font-size: var(--fs-section); font-variant-numeric: tabular-nums; }
.cal-week__dh--today { box-shadow: inset 0 -3px 0 var(--accent); }
.cal-week__dh--today b { color: var(--accent-text); }
.cal-week__scroll { height: 560px; overflow-y: auto; }
.cal-week__body { position: relative; height: 720px; }
.cal-week__hours { position: relative; }
.cal-week__hours span { position: absolute; right: 8px; color: var(--muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums; transform: translateY(-50%); }
.cal-col { position: relative; border-left: 1px solid var(--divider); background-image: linear-gradient(var(--divider) 1px, transparent 1px); background-size: 100% 30px; }
.cal-col--today { background-color: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
.cal-block { position: absolute; right: 4px; left: 4px; display: flex; flex-direction: column; padding: 4px 8px; overflow: clip; border-left: 4px solid var(--edge); border-radius: 6px; background: var(--tint); color: var(--sink); font-size: var(--fs-small); cursor: pointer; }
.cal-block:hover { box-shadow: var(--shadow-sm); }
/* The name and hours stay in view while the week scrolls (a block can start before the visible hours). */
.cal-block__label { position: sticky; top: 4px; display: flex; flex-direction: column; min-width: 0; }
.cal-block__label b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-block__label span { font-variant-numeric: tabular-nums; }
.cal-handle { position: absolute; right: 10px; left: 10px; z-index: 2; height: 12px; margin-top: -6px; padding: 0; border: 0; background: none; cursor: ns-resize; touch-action: none; }
.cal-handle::before { content: ""; position: absolute; top: 4px; left: 50%; width: 32px; height: 4px; margin-left: -16px; border-radius: 2px; background: var(--text); opacity: .22; transition: opacity var(--duration-fast) ease; }
.cal-col:hover .cal-handle::before, .cal-handle:focus-visible::before, .cal-handle[data-dragging]::before { opacity: .6; }
.cal-handle:focus-visible { border-radius: 4px; outline: 2px solid var(--focus); }
.cal-handle__tip { position: absolute; bottom: 14px; left: 50%; padding: 2px 8px; border-radius: 6px; background: var(--text); color: var(--surface); font-size: var(--text-xs); font-weight: var(--weight-bold); white-space: nowrap; pointer-events: none; transform: translateX(-50%); }
.cal-strip { display: flex; height: 28px; margin: var(--space-2) 0 4px; overflow: hidden; border-radius: 6px; }
.cal-strip span { display: grid; place-items: center; min-width: 0; overflow: hidden; background: var(--tint); box-shadow: inset 0 -3px 0 var(--edge); color: var(--sink); font-size: var(--text-xs); font-weight: var(--weight-bold); white-space: nowrap; }
.cal-strip-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.cal-seglist { display: grid; gap: var(--space-2); margin: var(--space-3) 0 var(--space-2); padding: 0; list-style: none; }
.cal-seglist li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: var(--space-2); padding: var(--space-2); border-left: 4px solid var(--edge); border-radius: var(--radius-item); background: var(--tint); color: var(--sink); }
.cal-seglist li[aria-disabled="true"] { opacity: .75; }
.cal-seglist__to { width: 112px; }
.cal-seglist__from, .cal-seglist__end { font-size: var(--fs-small); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cal-section { margin-top: var(--space-6); }
.cal-radios { display: grid; gap: var(--space-2); }
.cal-radio { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-item); cursor: pointer; }
.cal-radio:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 50%, var(--surface)); }
.cal-radio input { margin-top: 3px; accent-color: var(--accent); }
.cal-radio b { display: block; }
.cal-radio small { color: var(--muted); }
.cal-radio__fields { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin-top: var(--space-2); }
.cal-note { margin: var(--space-3) 0 0; padding: var(--space-3); border-radius: var(--radius-item); background: var(--neutral-bg); color: var(--neutral-text); font-size: var(--fs-secondary); }
.cal-form { display: grid; gap: var(--form-gap); }
.cal-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; gap: var(--space-2); }
.cal-hlist { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.cal-hlist li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: center; gap: var(--space-2); padding: 6px 0; border-bottom: 1px solid var(--divider); font-size: var(--fs-secondary); }
.cal-hlist__day { color: var(--muted); }
.cal-hlist__empty { color: var(--muted); }
.cell-slots { display: grid; gap: var(--space-2); }
.cell-slots__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.cell-slots__list li { display: grid; gap: 2px; padding: var(--space-2) var(--space-3); border-left: 4px solid var(--edge); border-radius: var(--radius-item); background: var(--tint); color: var(--sink); font-size: var(--fs-small); }
/* Below 1600 px the mini calendar and the list go above the month, so a day is wide enough for a holiday's name
   («Independencia de Cartagena») on two lines at 1366 px, nothing cut. */
@media (max-width: 1599px) {
  .cal-layout { grid-template-columns: minmax(0, 1fr); }
  .cal-rail { grid-template-columns: 236px minmax(0, 1fr); align-items: start; }
}
@media (max-width: 1100px) {
  .cal-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .cal-legend, .cell-slots__list, .cal-radio__fields, .cal-row, .cal-rail { grid-template-columns: minmax(0, 1fr); }
  .cal-toolbar__cell { flex: 1 1 100%; flex-wrap: wrap; }
  .cal-toolbar__cell .select { width: 100%; min-width: 0; }
  .cal-handle { right: 2px; left: 2px; }
  .cal-day { min-height: 64px; padding: 4px; }
  .cal-day__name { display: none; }
  .cal-week__head, .cal-week__body { grid-template-columns: 40px repeat(7, minmax(0, 1fr)); }
  .cal-block { padding: 2px 4px; }
  .cal-block__label span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cal-handle::before { transition: none; }
}

/* ---------- Calendars, phase 2: the legend always, and a cell's «Franjas» ---------- */
.cal-toolbar__none { color: var(--muted); font-size: var(--fs-secondary); }
.cal-legend__name { display: inline-flex; align-items: center; gap: var(--space-2); }
.cal-legend__swatch { width: 12px; height: 12px; flex: none; border-radius: 3px; background: var(--edge); }
.cell-slots-section { display: grid; gap: var(--space-3); margin-top: var(--space-5); }
.cell-slots-section > p { margin: 0; }
.cell-slots-form { display: grid; gap: var(--space-3); }
.cell-slots-table td, .cell-slots-table th { vertical-align: top; }
.cell-slots-table .select { min-width: 150px; }
.cell-slots-table .input--num { width: 72px; }
.cell-slot__name { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: var(--weight-bold); white-space: nowrap; }
.cell-slot__size { display: block; margin-top: 2px; color: var(--muted); font-size: var(--text-xs); }
.cell-slot__per { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.cell-slot-badge { display: inline-block; max-width: 220px; padding: 1px 8px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.cell-slot-badge--ok { background: var(--success-bg); color: var(--success-text); }
.cell-slot-badge--warn { background: var(--warning-bg); color: var(--warning-text); }
.cell-slot-badge--bad { background: var(--error-bg); color: var(--error-text); }
.cell-slot-now { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-5); align-items: center; padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border); border-left: 6px solid var(--edge, var(--border-strong)); border-radius: var(--radius-card); background: var(--surface); }
.cell-slot-now--off { display: block; border-left-color: var(--border-strong); }
.cell-slot-now--off p { margin: 0; }
.cell-slot-now__label { display: block; color: var(--muted); font-size: var(--fs-small); }
.cell-slot-now__slot { display: block; color: var(--text); font-size: var(--fs-section); font-weight: var(--weight-heavy); }
.cell-slot-now__facts { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); margin: 0; }
.cell-slot-now__facts dt { color: var(--muted); font-size: var(--fs-small); font-weight: var(--weight-semibold); }
.cell-slot-now__facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.cell-slot-quota { margin: var(--space-3) 0 0; padding: var(--space-3); border-radius: var(--radius-item); background: var(--success-bg); color: var(--success-text); font-size: var(--fs-secondary); }
.cell-slot-quota--warn { background: var(--warning-bg); color: var(--warning-text); }
.cell-slot-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-2) var(--space-4); margin: 0; font-size: var(--fs-secondary); }
.cell-slot-facts dt { color: var(--muted); }
.cell-slot-facts dd { margin: 0; }
@media (max-width: 640px) {
  .cell-slot-now { grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
  .cell-slot-facts { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Calendars, phase 3: a company's «Calendario de acceso» ---------- */
.co-access-modes { display: grid; gap: var(--space-2); }
.co-access-cal { display: grid; gap: var(--space-3); margin-top: var(--space-4); }
/* The hours of «Su horario de siempre», under the choices (audit of 2026-11-25: they were in another section). */
.co-hours { display: grid; gap: var(--space-2); margin-top: var(--space-4); }
.co-hours[hidden] { display: none; }
.co-access-cal .form-section__subtitle { margin: 0; }
.co-access-slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); }
.co-access-slot { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-left: 4px solid var(--edge); border-radius: var(--radius-item); font-weight: var(--weight-semibold); cursor: pointer; }
.co-access-slot input { width: 16px; height: 16px; accent-color: var(--accent); }
.co-access-week { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 4px var(--space-2); align-items: center; color: var(--muted); font-size: var(--text-xs); }
.co-access-week__bar { display: flex; height: 14px; overflow: hidden; border-radius: 4px; }
.co-access-week__bar span { min-width: 2px; background: var(--edge); }
.co-access-week__bar span[data-off] { background: repeating-linear-gradient(135deg, var(--neutral-bg) 0 4px, var(--surface) 4px 8px); box-shadow: inset 0 0 0 1px var(--border); }
.co-access-warning { margin: var(--space-4) 0 0; padding: var(--space-3); border-radius: var(--radius-item); background: var(--warning-bg); color: var(--warning-text); font-size: var(--fs-secondary); }
@media (max-width: 640px) {
  .co-access-slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* A company's «Al terminar el horario o la franja» (decision B). */
.co-access-end { display: grid; gap: var(--space-2); margin: var(--space-4) 0 0; padding: 0; border: 0; }
.co-access-end legend { margin-bottom: var(--space-2); padding: 0; }
.co-access-after { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-2); color: var(--muted); font-size: var(--fs-secondary); }
.co-access-after .input--num { width: 88px; }

/* Infraestructura › Dirección pública (docs/plan-dominio-smderp.md). */
.dom-form {
  display: grid;
  gap: var(--space-3);
  max-width: 48rem;
}
.dom-cert {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  border: 0;
}
.dom-cert > legend {
  padding: 0;
}
.dom-switches {
  display: grid;
  gap: var(--space-1);
  max-width: 48rem;
}
.dom-switches > .field__hint + .toggle {
  margin-top: var(--space-3);
}
.check-list__mark--warn {
  color: var(--warning-text);
}
.dom-status {
  display: grid;
  grid-template-columns: minmax(9rem, max-content) minmax(0, 1fr);
  gap: var(--space-1) var(--space-4);
  margin: 0;
}
.dom-status > dt {
  color: var(--muted);
}
.dom-status > dd {
  margin: 0;
  overflow-wrap: anywhere;
}
#dom-public-now {
  margin-top: var(--space-3);
}
