/* Page layouts: top bar, admin shell, login, portal and the compact viewer bar. */

/* ---------- Brand (wordmark) ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  text-decoration: none;
}
/* remoteUI's logo (partials/logo.html): the colour SVG on a light bar, the white one on a dark bar. */
.brand {
  gap: var(--space-3);
}
.logo {
  display: var(--logo-light);
  width: auto;
}
.logo-dark {
  display: var(--logo-dark);
  width: auto;
}
.logo--bar {
  height: 28px;
}
.logo--wide {
  height: 40px;
}
.logo-white {
  display: var(--logo-on-accent-white);
  width: auto;
  height: 40px;
}
.mark-white {
  display: var(--logo-on-accent-white);
  width: auto;
  height: 32px;
}
.logo-white--colour,
.mark-white--colour {
  display: var(--logo-on-accent-colour);
}
.brand__text {
  color: var(--ink);
  font-size: var(--fs-section);
  font-weight: var(--weight-heavy);
  letter-spacing: var(--tracking-title);
}
.brand__accent {
  fill: var(--accent-text);
}
/* A company's mark in its users' top bar: the logo on a light plate (it was made for a light background, and the bar
   has the company's colour), or the initials with the bar's two colours swapped, like the avatar. */
.brand--company {
  gap: var(--space-2);
  min-width: 0;
}
.brand__logo {
  display: block;
  max-width: 120px;
  height: 28px;
  padding: 2px var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--surface);
  object-fit: contain;
}
.brand__mark {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  background: var(--brand-text, var(--accent));
  color: var(--brand, var(--on-accent));
  font-size: var(--fs-small);
  font-weight: var(--weight-bold);
}
.brand__name {
  overflow: hidden;
  font-weight: var(--weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Top bar (portal and every page outside administration) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--topbar-h);
  padding: 0 var(--space-8);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar__context {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: var(--fs-secondary);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar__context::before {
  content: "·";
  margin-right: var(--space-2);
  color: var(--subtle);
}
.topbar__spacer {
  flex: 1;
}
.topbar__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-item);
  color: var(--text);
  font-size: var(--fs-body);
  font-weight: var(--weight-semibold);
  text-decoration: none;
}
.topbar__link svg {
  width: 18px;
  height: 18px;
  color: var(--accent-text);
}
.topbar__link:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.account-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-2) 0 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text);
  font-size: var(--fs-secondary);
  cursor: pointer;
}
.account-btn:hover,
.account-btn[aria-expanded="true"] {
  background: var(--table-head);
}
.account-btn__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  line-height: 1.2;
  text-align: left;
}
.account-btn__name,
.account-btn__user {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-btn__user {
  color: var(--muted);
  font-size: var(--fs-small);
}
.account-btn__caret {
  width: 14px;
  height: 14px;
  color: var(--muted);
}
/* The redesign's account button (every bar but the viewer's, which keeps the one above). */
:root:not([data-viewer-tokens]) .account-btn {
  gap: var(--space-3);
  height: 46px;
  font-size: var(--fs-secondary);
}
:root:not([data-viewer-tokens]) .account-btn:hover,
:root:not([data-viewer-tokens]) .account-btn[aria-expanded="true"] {
  border-color: var(--border);
  background: var(--table-head);
}
:root:not([data-viewer-tokens]) .account-btn__text {
  line-height: 1.25;
}
:root:not([data-viewer-tokens]) .account-btn__name {
  color: var(--ink);
  font-weight: var(--weight-bold);
}
:root:not([data-viewer-tokens]) .account-btn__user {
  color: var(--muted);
  font-size: var(--fs-small);
}
:root:not([data-viewer-tokens]) .account-btn__caret {
  width: 16px;
  height: 16px;
}
@media (max-width: 640px) {
  .topbar {
    gap: var(--space-2);
    padding: 0 var(--space-4);
  }
  .account-btn__text,
  .topbar__link span {
    display: none;
  }
}

/* ---------- Generic page ---------- */
.page {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-8);
}
@media (max-width: 640px) {
  .page {
    padding: var(--space-6) var(--space-4);
  }
}
/* Page header: title, a description of one or two lines and the main action on the right. */
.page-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--section-gap);
}
@media (max-width: 640px) {
  .page-header {
    flex-wrap: wrap;
  }
  /* The main action goes under the title (the base rule below comes later: this one is more specific). */
  .page-header > .page-header__text {
    flex-basis: 100%;
  }
  .page-header h1 {
    font-size: var(--fs-title-sm);
  }
}
.page-header__text {
  flex: 1;
  min-width: 0;
}
.page-header h1 {
  color: var(--ink);
  font-size: var(--fs-title);
  font-weight: var(--weight-heavy);
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
}
.page-header__sub {
  max-width: 80ch;
  margin-top: var(--space-1);
  color: var(--muted);
  font-size: var(--fs-body);
  line-height: var(--leading-body);
}
.page-header > .btn {
  flex: none;
}
/* Cards one after another on a page keep their distance. */
.page > .card + .card,
.page > .card + section,
.page > section + .card {
  margin-top: var(--section-gap);
}
/* A state line in a section («Desactivado: se pueden abrir aplicaciones.», «Listo: la prueba…») keeps its distance
   from the fields after it (PB 2026-11-22). */
.form-section > p:not([class]):not(:last-child),
.form-section > p.muted:not(:last-child) {
  margin-bottom: var(--space-4);
}
/* The description under a section's title. */
.form-section__title + .field__hint,
.form-section__title + p.muted {
  display: block;
  margin: calc(-1 * var(--space-2)) 0 var(--space-4);
}

/* ---------- Admin shell ---------- */
.admin-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.admin-main {
  min-width: 0;
}
/* Left-aligned under the header, at most 1280 px (density pass, rule A). */
.admin-main .page {
  max-width: calc(var(--content-max-admin) + 2 * var(--space-8));
  margin: 0;
  padding: var(--space-6) var(--space-8) var(--space-8);
}

/* The sidebar, on the accent, with a circle of light in its lower-left corner like the sign-in panel. */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  height: 100vh;
  overflow: hidden;
  padding: var(--space-5) var(--space-3) var(--space-4);
  background: var(--accent);
  background-image: linear-gradient(160deg, var(--brand-grad-start), var(--accent) 52%, var(--brand-grad-end)); /* the logo's cyan → blue → violet (M-002) */
  color: var(--accent-base-tint);
}
.sidebar::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: -170px;
  bottom: -190px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--orb-1), var(--orb-2) 55%, var(--orb-3));
  opacity: 0.7;
  pointer-events: none;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-2) var(--space-2);
}
.sidebar__brand-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.sidebar__logo {
  align-self: flex-start;
  height: 32px; /* the white horizontal logo on the menu's blue, no tile around it */
  margin-bottom: var(--space-1);
}
.sidebar__sub {
  color: var(--accent-base-tint);
  font-size: var(--fs-small);
}
.sidebar__close {
  display: none;
}
.sidebar__sections {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  margin: 0 calc(-1 * var(--space-2));
  padding: 0 var(--space-2);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-base-hover) transparent;
}
.sidebar__label {
  padding: var(--space-3) var(--space-3) 2px; /* 15 sections fit in a 900 px high window (PB review 2026-11-22) */
  color: var(--accent-base-tint);
  font-size: var(--fs-small);
  font-weight: var(--weight-semibold);
}
.sidebar__label:first-child {
  padding-top: var(--space-1);
}
.sidebar__link {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--nav-item-h);
  padding: 0 var(--space-3);
  border-radius: var(--radius-item);
  color: var(--accent-base-tint);
  font-size: var(--fs-body);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-out);
}
.sidebar__link svg {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--accent-base-icon);
}
.sidebar__link:hover {
  background: var(--accent-base-hover);
  color: var(--on-accent);
}
.sidebar__link[aria-current="page"] {
  background: var(--nav-active-bg);
  color: var(--accent-base-text);
  font-weight: var(--weight-bold);
}
.sidebar__link[aria-current="page"] svg {
  color: var(--accent-base-text);
}
.sidebar :focus-visible {
  outline: 2px solid var(--on-accent);
  outline-offset: 2px;
}
.sidebar__back {
  border-top: 1px solid color-mix(in srgb, var(--on-accent) 18%, transparent);
  border-radius: 0 0 var(--radius-item) var(--radius-item);
  padding-top: var(--space-1);
}
.sidebar-backdrop {
  display: none;
}

/* The admin top bar: route, search of the sections and account. */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--topbar-h);
  padding: 0 var(--space-8);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.admin-topbar__menu {
  display: none;
}
/* The folded menu (narrow screens): only the white isotype, on the brand blue, next to «Menú». */
.admin-topbar__mark {
  display: none;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent);
  background-image: linear-gradient(160deg, var(--brand-grad-start), var(--accent) 52%, var(--brand-grad-end));
}
.admin-topbar__mark .mark-white {
  height: 30px;
}
.crumbs {
  display: flex;
  flex: 1;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  color: var(--muted);
  font-size: var(--fs-body);
  white-space: nowrap;
}
.crumbs__current {
  overflow: hidden;
  color: var(--ink);
  font-weight: var(--weight-bold);
  text-overflow: ellipsis;
}
.crumbs__sep {
  color: var(--subtle);
}
.admin-search {
  position: relative;
  width: min(340px, 34vw);
}
.admin-search__icon {
  position: absolute;
  top: 50%;
  left: var(--space-3);
  display: flex;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}
.admin-search__icon svg {
  width: 16px;
  height: 16px;
}
.admin-search__input {
  width: 100%;
  height: var(--search-h);
  padding: 0 var(--space-3) 0 36px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-control);
  background: var(--table-head);
  color: var(--text);
  font-size: var(--fs-body);
}
.admin-search__input::placeholder {
  color: var(--subtle);
}
.admin-search__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}
.admin-search__list,
.admin-search__empty {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: var(--z-menu);
  margin: 0;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  box-shadow: var(--shadow-menu);
  list-style: none;
}
.admin-search__empty {
  color: var(--muted);
  font-size: var(--fs-secondary);
}
.admin-search__option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-item);
  color: var(--text);
  font-size: var(--fs-body);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}
.admin-search__option small {
  color: var(--muted);
  font-size: var(--fs-small);
  font-weight: var(--weight-regular);
}
.admin-search__option[aria-selected="true"],
.admin-search__option:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}

@media (max-width: 960px) {
  .admin-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  /* The sidebar becomes a panel over the page, opened by the bar's «Menú» button. */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: var(--z-drawer);
    width: min(var(--sidebar-w), 86vw);
    box-shadow: var(--shadow-dialog);
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform var(--duration-base) var(--ease-out), visibility 0s linear var(--duration-base);
  }
  .sidebar.is-open {
    transform: none;
    visibility: visible;
    transition: transform var(--duration-base) var(--ease-out);
  }
  .sidebar__close {
    display: inline-flex;
    border-color: transparent;
    background: transparent;
    color: var(--on-accent);
  }
  .sidebar__close:hover {
    background: var(--accent-base-hover);
  }
  .admin-topbar__mark {
    display: inline-flex;
  }
  .sidebar-backdrop:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-drawer) - 1);
    display: block;
    background: var(--overlay);
  }
  .admin-topbar {
    gap: var(--space-2);
    padding: 0 var(--space-4);
  }
  .admin-topbar__menu {
    display: inline-flex;
    flex: none;
  }
  .admin-main .page {
    padding: var(--space-6) var(--space-4);
  }
}
@media (max-width: 640px) {
  .admin-search {
    width: auto;
    flex: 0 1 44px;
  }
  .admin-search:focus-within {
    position: absolute;
    left: var(--space-4);
    right: var(--space-4);
    z-index: var(--z-menu);
    flex: none;
  }
  .admin-search__input {
    padding-right: 0;
  }
  .admin-search__input:not(:focus)::placeholder {
    color: transparent;
  }
  .crumbs__group,
  .crumbs__sep {
    display: none;
  }
}

/* ---------- The sign-in family: a company's sign-in page, the e-mail link pages, «Acceso suspendido» ----------
 * The language of /login (login.css): the accent with its circles of light behind a white card, the product's font,
 * a 52 px main button. On a company's pages its tema.css sets the accent tokens, so its colour drives them. */
.auth {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  min-height: 100vh;
  padding: var(--space-8) var(--space-4) var(--space-6);
  overflow: hidden;
  background: var(--accent);
  color: var(--on-accent);
}
.auth::before,
.auth::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
}
.auth::before {
  top: -220px;
  right: -160px;
  width: 560px;
  height: 560px;
  background: radial-gradient(circle at 35% 35%, var(--orb-1), var(--orb-2) 55%, var(--orb-3));
  opacity: 0.85;
}
.auth::after {
  bottom: -200px;
  left: -140px;
  width: 440px;
  height: 440px;
  background: radial-gradient(circle at 40% 40%, var(--orb-4), transparent 70%);
  opacity: 0.8;
}
.auth > .auth__card {
  align-self: center;
  min-width: 0;
  max-width: 100%;
}
.auth {
  grid-template-columns: minmax(0, 1fr);
}
.auth__card {
  width: min(420px, 100%);
  padding: 40px var(--space-8) var(--space-8);
  border: 0;
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: var(--shadow-dialog);
  color: var(--text);
}
@media (max-width: 480px) {
  .auth__card {
    padding: var(--space-8) var(--space-5) var(--space-6);
  }
}
.auth__brand {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-4);
}
.auth__brand .brand {
  pointer-events: none;
}
/* The pages behind the e-mail links (companies F3). */
.auth__title {
  margin: 0 0 var(--space-2);
  color: var(--ink);
  font-size: var(--fs-title);
  font-weight: var(--weight-heavy);
  letter-spacing: var(--tracking-title);
  text-align: center;
}
.auth__sub {
  margin-bottom: var(--space-6);
  color: var(--muted);
  font-size: var(--fs-body);
  line-height: var(--leading-body);
  text-align: center;
}
.auth__submit,
.btn.company-auth__submit {
  width: 100%;
  height: 52px;
  margin-top: var(--space-2);
  border-color: transparent;
  border-radius: var(--radius-control);
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--fs-section);
  box-shadow: var(--shadow-btn);
}
.btn.company-auth__submit:hover:not(:disabled),
.btn.auth__submit:hover:not(:disabled) {
  border-color: transparent;
  background: var(--accent-strong);
}
.auth__footer {
  margin-top: var(--space-6);
  color: var(--accent-base-tint);
  font-size: var(--fs-small);
  text-align: center;
}
.auth__footer a {
  color: inherit;
}

/* ---------- A company's sign-in page (companies F2c) ----------
 * Row 1 is the administrator's preview notice (an empty span when there is none). */
.company-auth {
  grid-template-rows: auto 1fr auto;
  gap: var(--space-4);
}
.company-auth__preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  max-width: 40rem;
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-secondary);
}
.company-auth__preview > span {
  flex: 1 1 20rem;
}
.company-auth__preview svg {
  flex: none;
  width: 16px;
  height: 16px;
}
.auth > .company-auth__card {
  display: grid;
  gap: var(--space-4);
}
.company-auth__card .field {
  margin: 0;
}
.company-auth__logo {
  display: flex;
  justify-content: center;
}
.company-auth__logo img {
  max-width: 200px;
  max-height: 64px;
  object-fit: contain;
}
.company-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-card);
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--fs-section);
  font-weight: var(--weight-heavy);
}
.company-auth__name {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-title-sm);
  font-weight: var(--weight-heavy);
  letter-spacing: var(--tracking-title);
  text-align: center;
}
.company-auth__welcome {
  margin: 0;
  color: var(--muted);
  text-align: center;
  white-space: pre-line;
}
/* «Acceso suspendido» (companies F6): the company's brand, dimmed. */
.company-auth--suspended .company-auth__logo {
  filter: grayscale(1);
  opacity: 0.6;
}
.company-auth--suspended .company-auth__name {
  color: var(--muted);
  font-size: var(--fs-block);
}
.company-auth__suspended-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-section);
  font-weight: var(--weight-heavy);
}
.company-auth__suspended-text {
  margin: 0;
  text-align: center;
  white-space: pre-line;
}
.company-auth__forgot {
  justify-self: end;
  color: var(--accent-text);
  font-size: var(--fs-secondary);
  font-weight: var(--weight-semibold);
}
.company-auth__or {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--muted);
  font-size: var(--fs-secondary);
}
.company-auth__or::before,
.company-auth__or::after {
  flex: 1;
  height: 1px;
  background: var(--border);
  content: "";
}
.company-auth__ms {
  width: 100%;
  height: auto;
  min-height: var(--btn-h);
  flex-wrap: wrap;
  white-space: normal; /* «Continuar con Microsoft · Próximamente» wraps on a phone instead of widening the card */
}
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-control);
  background: var(--error-bg);
  color: var(--error-text);
  font-size: var(--fs-secondary);
  font-weight: var(--weight-semibold);
}
.auth .alert {
  margin-bottom: var(--space-4);
}
.alert--info {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.alert svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 2px;
}

/* The error pages (no encontrada, sin permiso, error del servidor): a card in the middle of the page. */
.error-page {
  max-width: 520px;
  margin: 10vh auto 0;
}

/* ---------- A company user's pages (companies F3) ----------
 * --brand and --brand-text come from the company's tema.css when it has a
 * colour (--brand-text is the text that reads better on it, brand.BestText);
 * without them every rule falls back to the theme.
 */
.company-branded .topbar {
  border-bottom-color: transparent;
  background: var(--brand, var(--surface));
  color: var(--brand-text, var(--text));
}
.company-branded .topbar .brand,
.company-branded .topbar .topbar__context,
.company-branded .topbar .topbar__context::before,
.company-branded .topbar .topbar__link,
.company-branded .topbar .account-btn__name,
.company-branded .topbar .account-btn__user,
.company-branded .topbar .account-btn__caret {
  color: inherit;
}
.company-branded .topbar .brand__accent {
  fill: currentColor;
}
.company-branded .topbar .account-btn {
  color: inherit;
}
.company-branded .topbar .account-btn:hover,
.company-branded .topbar .account-btn[aria-expanded="true"] {
  background: color-mix(in srgb, currentColor 14%, transparent);
}
/* The avatar on the company's colour: the two colours swapped. */
.company-branded .topbar .avatar {
  background: var(--brand-text, var(--accent));
  color: var(--brand, var(--on-accent));
}
/* The open menu is a panel of its own: the theme's text again. */
.company-branded .topbar .menu__panel {
  color: var(--text);
}
/* The company's colour is the accent of its pages (its tema.css sets the accent tokens): the panel, the
   application icons and the main buttons follow it with no rule of their own. */

/* «Cambiar contraseña» of a company user */
.account-form {
  max-width: 32rem;
}

/* ---------- Portal ---------- */
/* The welcome panel: the accent, two circles of light (the sign-in panel's), the greeting and the search. */
.welcome {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
  padding: var(--space-8) var(--space-10);
  overflow: hidden;
  border-radius: var(--radius-panel);
  background: var(--accent);
  background-image: linear-gradient(160deg, var(--brand-grad-start), var(--accent) 52%, var(--brand-grad-end)); /* the logo's cyan → blue → violet (M-002) */
  box-shadow: var(--shadow-panel);
  color: var(--on-accent);
}
.welcome::before,
.welcome::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
}
.welcome::before {
  top: -160px;
  right: -90px;
  width: 380px;
  height: 380px;
  background: radial-gradient(circle at 35% 35%, var(--orb-1), var(--orb-2) 55%, var(--orb-3));
  opacity: 0.85;
}
.welcome::after {
  bottom: -150px;
  left: 28%;
  width: 260px;
  height: 260px;
  background: radial-gradient(circle at 40% 40%, var(--orb-4), transparent 70%);
  opacity: 0.8;
}
.welcome__text {
  min-width: 0;
}
.welcome__title {
  color: var(--on-accent);
  font-size: var(--fs-hero);
  font-weight: var(--weight-heavy);
  letter-spacing: var(--tracking-hero);
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.welcome__sub {
  margin-top: var(--space-2);
  color: var(--accent-base-tint);
  font-size: var(--fs-block);
  font-weight: var(--weight-semibold);
}
.welcome__search {
  position: relative;
  flex: 0 1 340px;
  min-width: 0;
}
.welcome__search-icon {
  position: absolute;
  top: 50%;
  left: var(--space-4);
  display: flex;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}
.welcome__search-icon svg {
  width: 18px;
  height: 18px;
}
.welcome__input {
  width: 100%;
  height: var(--control-h);
  padding: 0 var(--space-4) 0 44px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-body);
  box-shadow: var(--shadow-btn);
}
.welcome__input::placeholder {
  color: var(--subtle);
}
.welcome__input:focus {
  outline: 2px solid var(--on-accent);
  outline-offset: 2px;
}
@media (max-width: 640px) {
  .welcome {
    padding: var(--space-6);
  }
  .welcome__title {
    font-size: var(--fs-title);
  }
  .welcome__search {
    flex-basis: 100%;
  }
}

/* «Tus aplicaciones» and the filters. */
.portal-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
}
.portal-head__title {
  color: var(--ink);
  font-size: var(--fs-section);
  font-weight: var(--weight-bold);
}

/* Todas / Favoritas / Recientes: a segmented control (tabs). */
.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
}
.segmented__item {
  height: 36px;
  padding: 0 var(--space-4);
  border: 0;
  border-radius: var(--radius-item);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-body);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
.segmented__item:hover {
  color: var(--text);
}
.segmented__item[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: var(--weight-bold);
}

/* Application cards. The «Abrir» link covers the whole card (::after), so clicking anywhere opens it as before;
   the star sits above it. */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--space-4);
}
@media (max-width: 400px) {
  .app-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
.app-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-app);
  background: var(--surface);
  color: var(--text);
  transition: transform var(--duration-base) var(--ease-out), box-shadow var(--duration-base) var(--ease-out),
    border-color var(--duration-base) var(--ease-out);
}
.app-card:not(.app-card--missing):hover,
.app-card:not(.app-card--missing):focus-within {
  border-color: var(--border-input);
  box-shadow: var(--shadow-lift);
  transform: translateY(-2px);
}
@media (prefers-reduced-motion: reduce) {
  .app-card:not(.app-card--missing):hover,
  .app-card:not(.app-card--missing):focus-within {
    transform: none;
  }
}
.app-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  align-self: stretch;
}
.app-card__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-card);
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--fs-section);
  font-weight: var(--weight-heavy);
}
.app-card__star {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: -6px 0 0 0; /* no negative right margin: it stuck out of the card by 6 px (PB 2026-11-22) */
  border: 0;
  border-radius: var(--radius-item);
  background: transparent;
  color: var(--subtle);
  cursor: pointer;
}
.app-card__star svg {
  width: 20px;
  height: 20px;
}
.app-card__star:hover {
  background: var(--table-head);
  color: var(--warning-dot);
}
.app-card__star[aria-pressed="true"] {
  color: var(--warning-dot);
}
.app-card__star[aria-pressed="true"] svg {
  fill: currentColor;
}
.app-card__name {
  margin: var(--space-1) 0 0;
  color: var(--ink);
  font-size: var(--fs-section);
  font-weight: var(--weight-bold);
  overflow-wrap: anywhere;
}
.app-card__open {
  margin-top: calc(-1 * var(--space-1));
}
.app-card__link {
  margin-top: auto;
}
.app-card__link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
.app-card__link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.app-card__badge {
  display: inline-flex;
}
.app-card__badge svg {
  width: 14px;
  height: 14px;
}
/* «¿Falta una aplicación?» */
.app-card--missing {
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  border: 2px dashed var(--border-input);
  background: transparent;
  text-align: center;
}
.app-card__missing-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--accent-text);
}
.app-card__missing-icon svg {
  width: 20px;
  height: 20px;
}
.app-card__missing-title {
  color: var(--ink);
  font-size: var(--fs-block);
  font-weight: var(--weight-bold);
}
.app-card__missing-text {
  color: var(--muted);
  font-size: var(--fs-secondary);
}
.portal-filter-empty {
  margin-top: var(--space-4);
  color: var(--muted);
  font-size: var(--fs-body);
}
.portal-footer {
  margin-top: var(--space-10);
  color: var(--muted);
  font-size: var(--fs-small);
  text-align: center;
}

/* ---------- Viewer bar (compact, max 40px) ----------
 * Loaded after web/style.css (the viewer canvas stylesheet), so these rules win
 * over its #bar defaults. The IDs (#bar, #status, #stats, #chkFrames) are part
 * of the viewer.js contract and must not change.
 */
/* The viewer keeps its look (its UX is a separate track): its account menu's section label in capitals, as before. */
[data-viewer-tokens] .menu__section-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
/* Its dialogs (the recording's password box, record.js; confirmations), fields and toasts as before the redesign. */
[data-viewer-tokens] .dialog__body {
  padding: var(--space-5) var(--space-5) var(--space-4);
}
[data-viewer-tokens] .dialog__title {
  font-weight: var(--weight-semibold);
}
[data-viewer-tokens] .dialog__message {
  font-size: var(--text-md);
  line-height: inherit;
}
[data-viewer-tokens] .dialog__actions {
  padding: var(--space-3) var(--space-5) var(--space-5);
}
[data-viewer-tokens] .field__label {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
[data-viewer-tokens] .field__hint {
  color: var(--color-text-subtle);
  font-size: var(--text-xs);
}
[data-viewer-tokens] .field__error,
[data-viewer-tokens] .field__warning {
  font-size: var(--text-xs);
  font-weight: inherit;
}
[data-viewer-tokens] .input,
[data-viewer-tokens] .select {
  border-radius: var(--radius-sm);
}
[data-viewer-tokens] .input:focus-visible,
[data-viewer-tokens] .select:focus-visible {
  outline: none;
}
[data-viewer-tokens] .toast {
  border-left-width: 3px;
}
/* App controls (upload, window frames, statistics, full screen) only make
   sense while the app is on screen: hidden while it opens, after a failure,
   when it is in another window or when the session ended. */
#bar.viewerbar:not([data-app-ready]) [data-app-control] {
  display: none !important; /* beats the upload button's own !important display */
}
#bar.viewerbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--viewer-bar-h);
  max-height: var(--viewer-bar-h);
  padding: 0 var(--space-2) 0 var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-topbar);
  color: var(--color-text);
  font-size: var(--text-sm);
  flex: none;
}
.viewerbar .brand svg {
  height: 16px;
}
.viewerbar .topbar__context {
  font-size: var(--text-sm);
  color: var(--color-text);
  font-weight: var(--weight-medium);
}
.viewerbar .spacer {
  flex: 1;
}
.viewerbar #status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}
.viewerbar #status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-subtle);
}
.viewerbar #status.ok {
  color: var(--color-success);
  border-color: var(--color-success);
}
.viewerbar #status.ok::before {
  background: var(--color-success);
}
.viewerbar #status.bad {
  color: var(--color-danger-text);
  border-color: var(--color-danger);
}
.viewerbar #status.bad::before {
  background: var(--color-danger);
}
.viewerbar .viewerbar__check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-muted);
  white-space: nowrap;
  cursor: pointer;
}
/* The «Pantalla» menu (D, screenmenu.js): a compact select in the bar. */
.viewerbar .viewerbar__screen {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.viewerbar .viewerbar__screen[hidden] { display: none; }
.select.select--sm {
  width: auto;
  height: 30px;
  font-size: var(--text-sm);
}
/* #stats stays in the bar (viewer.js writes it and anchors the upload button
   to it) but is shown through the info tooltip instead. */
.viewerbar #stats {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.viewerbar .btn--sm {
  height: 28px;
}
.viewerbar .btn--icon.btn--sm {
  width: 28px;
}
.viewerbar__sep {
  width: 1px;
  height: 20px;
  background: var(--color-divider);
}
.viewerbar__exit {
  gap: 6px;
}
/* Full screen takes every key, Alt+Tab included: the way out is always shown. */
.viewerbar__hint {
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--color-warning-soft);
  color: var(--color-text);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}
/* "Subir archivo": created by viewer.js with inline styles; restyle it as a
   design-system small button without touching viewer.js. */
#bar.viewerbar > label:has(> input[type="file"]) {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  height: 28px !important;
  margin: 0 !important;
  padding: 0 var(--space-3) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md) !important;
  background: var(--color-surface-2) !important;
  color: var(--color-text) !important;
  font-size: var(--text-sm) !important;
  font-weight: var(--weight-semibold) !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  transition: border-color var(--duration-fast) var(--ease-out);
}
#bar.viewerbar > label:has(> input[type="file"])::before {
  content: "";
  width: 14px;
  height: 14px;
  background: currentColor;
  -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' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12'/%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' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12'/%3E%3C/svg%3E") center / contain no-repeat;
}
#bar.viewerbar > label:has(> input[type="file"]):hover {
  border-color: var(--color-border-strong) !important;
}
#bar.viewerbar > label:has(> input[type="file"]):focus-within {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
.viewerbar .account-btn {
  height: 32px;
}
.viewerbar .account-btn__name {
  font-size: var(--text-sm);
}
.viewerbar .account-btn__user {
  font-size: 10px;
}
.viewerbar .avatar {
  width: 24px;
  height: 24px;
  font-size: 10px;
}
/* The app windows inside #stage use very high z-index values; isolate them so
   the account menu in the bar always stays on top. */
body.viewer #stage {
  isolation: isolate;
}

/* ---------- Session overlay (viewer/session.js): notices, reconnecting ----------
 * Covers the app area below the bar, so the bar (and "Salir") stays usable.
 */
.session-overlay {
  position: fixed;
  top: var(--viewer-bar-h);
  right: 0;
  bottom: 0;
  left: 0;
  z-index: calc(var(--z-topbar) - 1);
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background: var(--color-overlay);
  animation: overlay-in var(--duration-base) var(--ease-out);
}
@keyframes overlay-in {
  from {
    opacity: 0;
  }
}
.session-overlay__card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: min(460px, 100%);
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
}
.session-overlay__card--warning {
  border-top: 3px solid var(--color-warning);
}
.session-overlay__title {
  font-size: var(--text-lg);
}
.session-overlay__text {
  color: var(--color-text-muted);
  font-size: var(--text-md);
}
.session-overlay__code {
  font-size: var(--text-sm); /* for support: the reason code of a failed launch */
}
.session-overlay__spinner {
  width: 22px;
  height: 22px;
  color: var(--color-accent-text);
}
.session-overlay__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.session-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.session-list__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  background: var(--color-surface-sunken);
}
.session-list__text {
  flex: 1;
  min-width: 0;
  font-size: var(--text-md);
}

/* ---------- Print frames (viewer/print.js) ----------
 * Never display:none: a frame that is not rendered prints blank. HTML reports
 * use a zero-size frame; PDFs need a real-size frame (the browser's PDF viewer
 * does not start in a 0x0 frame), kept off-screen.
 */
.print-frame {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 0;
  height: 0;
  border: 0;
}
.print-frame--pdf {
  right: auto;
  bottom: auto;
  top: 0;
  left: -10000px;
  width: 800px;
  height: 600px;
}

/* ---------- Viewer stage and window frames follow the theme ----------
 * Overrides the fixed colors and zigzag pattern of web/style.css (which stays
 * untouched) with theme tokens and a very faint dot grid. The selectors are
 * more specific than style.css's, so no !important is needed.
 */
body.viewer {
  background: var(--color-stage);
}
body.viewer #stage {
  background: radial-gradient(var(--color-stage-pattern) 1px, transparent 1.5px) 0 0 / 22px 22px, var(--color-stage);
}
body.viewer .win {
  box-shadow: var(--shadow-window);
}
body.viewer .win .title {
  border-bottom: 1px solid var(--color-window-frame-border);
  background: var(--color-window-frame);
  color: var(--color-window-frame-text);
}
body.viewer .win .title .dot {
  background: var(--color-accent);
}
@media (max-width: 860px) {
  .viewerbar .viewerbar__check,
  .viewerbar .viewerbar__sep,
  .viewerbar__exit span {
    display: none;
  }
}

/* «Grabar secuencia» in the viewer's bar (capacity study; ?grabar=1, administrators only). */
.viewerbar .recbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-2);
  border-left: 1px solid var(--color-border);
}
.viewerbar .recbar__state {
  font-size: var(--text-xs);
  white-space: nowrap;
}
