/* ===== Encabezado de página ===== */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 24px;
  margin-bottom: 24px;
}

.page-heading {
  min-width: 0;
}

.page-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.page-title-text {
  min-width: 0;
}

.page-title-text h1 {
  overflow-wrap: anywhere;
}

.page-title-text p {
  margin-top: 4px;
  color: var(--text-muted);
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
}

.back-link:hover {
  color: var(--brand-on-soft);
}

.back-link .icon {
  font-size: 18px;
}

.link {
  color: var(--brand-on-soft);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.link:hover {
  text-decoration: underline;
}

/* ===== Botones ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, filter 120ms ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--outline-strong);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-alt);
}

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

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-danger-ghost {
  background: var(--surface);
  border-color: var(--outline-strong);
  color: var(--danger-on-soft);
}

.btn-danger-ghost:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn-sm {
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.btn-sm .icon {
  font-size: 18px;
}

.btn-block {
  width: 100%;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}

.icon-button:hover:not(:disabled) {
  background: var(--surface-alt);
  color: var(--text);
}

.icon-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== Tarjetas ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-pad {
  padding: clamp(16px, 2.5vw, 24px);
}

.card-pad-tight {
  padding-top: 0;
  padding-bottom: 12px;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 16px clamp(16px, 2.5vw, 24px);
  border-bottom: 1px solid var(--outline);
}

.card-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 20px;
  align-items: start;
}

.form-card {
  max-width: 860px;
}

.note-block {
  margin-top: 16px;
  padding: 10px 14px;
  border-left: 3px solid var(--brand);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-alt);
  color: var(--text-muted);
}

.list-caption {
  color: var(--text-muted);
  font-weight: 600;
}

.portal-license-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* ===== Indicadores ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(46%, 200px), 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  display: grid;
  gap: 2px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

@media (hover: hover) {
  .stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
}

.stat-icon {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.tone-brand .stat-icon {
  background: var(--brand-soft);
  color: var(--brand-on-soft);
}

.tone-success .stat-icon {
  background: var(--success-soft);
  color: var(--success-on-soft);
}

.tone-warning .stat-icon {
  background: var(--warning-soft);
  color: var(--warning-on-soft);
}

.tone-danger .stat-icon {
  background: var(--danger-soft);
  color: var(--danger-on-soft);
}

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 20px;
  padding: clamp(18px, 3vw, 28px);
  border-radius: var(--radius-lg);
  background: var(--brand-gradient);
  color: #fff;
}

.hero p {
  opacity: 0.92;
}

.hero small {
  display: block;
  margin-bottom: 4px;
  opacity: 0.85;
}

.hero h1 {
  margin-bottom: 4px;
}

.hero .btn {
  background: rgb(255 255 255 / 16%);
  border-color: rgb(255 255 255 / 35%);
  color: #fff;
}

.hero .btn:hover {
  background: rgb(255 255 255 / 26%);
}

.health-bar {
  display: flex;
  gap: 3px;
  height: 12px;
  margin-top: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-alt);
}

.health-bar span {
  min-width: 3px;
  flex-basis: 0;
}

.health-active {
  background: var(--success);
}

.health-expiring {
  background: var(--warning);
}

.health-expired {
  background: var(--danger);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 3px;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--outline);
  text-align: center;
}

.mini-stats strong {
  display: block;
  font-size: 1.25rem;
}

.mini-stats span {
  color: var(--text-subtle);
  font-size: 0.8rem;
}

.mini-stats a:hover strong {
  color: var(--brand-on-soft);
}

/* ===== Avatar con iniciales: ancla visual para recorrer un listado ===== */
.avatar {
  --avatar: #0e7c8b;

  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--avatar) 15%, transparent);
  color: color-mix(in srgb, var(--avatar), var(--avatar-shade) 22%);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  flex-shrink: 0;
  user-select: none;
}

.avatar-lg {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  font-size: 1.05rem;
}

.avatar-tone-1 {
  --avatar: #2d7ff0;
}

.avatar-tone-2 {
  --avatar: #1fa971;
}

.avatar-tone-3 {
  --avatar: #d07a00;
}

.avatar-tone-4 {
  --avatar: #8a5cf6;
}

.avatar-tone-5 {
  --avatar: #d6457e;
}

/* ===== Listas de filas ===== */
.row-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row-list li + li {
  border-top: 1px solid var(--outline);
}

.row-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px clamp(16px, 2.5vw, 24px);
  min-height: 60px;
  transition: background-color 100ms ease;
}

.row-link > .icon {
  color: var(--text-subtle);
}

.row-list li:last-child .row-link {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

@media (hover: hover) {
  .row-link:hover {
    background: var(--row-hover);
  }
}

.row-link:active {
  background: var(--row-hover);
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-main strong {
  display: block;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-main small {
  display: block;
  overflow: hidden;
  color: var(--text-subtle);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.count-pill {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

/* ===== Tablas: si su contenedor es angosto se convierten en tarjetas compactas ===== */
.table-wrap {
  container: table-wrap / inline-size;
  overflow-x: auto;
}

.card > .table-wrap:last-child {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.dt {
  width: 100%;
  border-collapse: collapse;
  transition: opacity 150ms ease;
}

.dt.is-loading {
  opacity: 0.55;
}

.dt th {
  padding: 10px 16px;
  border-bottom: 1px solid var(--outline);
  background: color-mix(in srgb, var(--surface-alt) 55%, var(--surface));
  color: var(--text-subtle);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.dt td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--outline);
  vertical-align: middle;
}

.dt th:first-child,
.dt td:first-child {
  padding-left: clamp(16px, 2.2vw, 20px);
}

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

.dt-link {
  position: relative;
  transition: background-color 100ms ease;
}

.dt-link:active {
  background: var(--row-hover);
}

@media (hover: hover) {
  .dt-link:hover {
    background: var(--row-hover);
  }

  .dt-link:hover td:first-child {
    box-shadow: inset 3px 0 0 var(--brand);
  }

  .dt-link:hover .dt-go .icon {
    color: var(--brand-on-soft);
    transform: translateX(2px);
  }
}

.dt-primary {
  font-weight: 600;
  min-width: 180px;
}

.dt-primary a:not(.link) {
  overflow-wrap: anywhere;
}

/* Toda la fila es el enlace, sin perder el clic derecho ni "abrir en otra pestaña". */
.dt-link .dt-primary a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.dt-link .dt-primary a:focus-visible {
  outline: none;
}

.dt-link .dt-primary a:focus-visible::after {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.cell-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.cell-text {
  min-width: 0;
}

.dt-sub {
  display: block;
  color: var(--text-subtle);
  font-size: 0.82rem;
  font-weight: 400;
}

a.dt-sub.link {
  color: var(--brand-on-soft);
}

.dt-go {
  width: 40px;
  padding-right: 14px;
  padding-left: 0;
  text-align: right;
}

.dt td.dt-go {
  padding-left: 0;
}

.dt-go .icon {
  color: var(--text-subtle);
  transition: transform 120ms ease, color 120ms ease;
}

.dt-actions {
  position: relative;
  z-index: 1;
  text-align: right;
  white-space: nowrap;
}

.mono {
  font-family: var(--mono);
  font-size: 0.8rem;
  word-break: break-all;
}

.nowrap {
  white-space: nowrap;
}

@container table-wrap (max-width: 780px) {
  .dt thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .dt,
  .dt tbody {
    display: block;
    width: 100%;
  }

  .dt tr {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(45%, 130px), 1fr));
    gap: 10px 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--outline);
  }

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

  .dt td,
  .dt td:first-child,
  .dt tbody tr:last-child td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    overflow-wrap: anywhere;
  }

  .dt td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 1px;
    color: var(--text-subtle);
    font-size: 0.74rem;
    font-weight: 400;
  }

  .dt td.dt-primary {
    grid-column: 1 / -1;
    padding-right: 92px;
    font-size: 1rem;
  }

  .dt td.dt-status {
    position: absolute;
    top: 14px;
    right: 16px;
  }

  .dt td.dt-go {
    display: none;
  }

  .dt td.dt-actions {
    grid-column: 1 / -1;
    text-align: left;
    white-space: normal;
  }

  .dt td.dt-actions:empty {
    display: none;
  }

  .dt-link:hover td:first-child {
    box-shadow: none;
  }
}

/* ===== Datos dentro de una fila ===== */
.expiry {
  display: inline-block;
  white-space: nowrap;
}

.expiry-note {
  display: block;
  color: var(--text-subtle);
  font-size: 0.8rem;
  font-weight: 400;
}

.expiry-note.is-warning {
  color: var(--warning-on-soft);
  font-weight: 600;
}

.expiry-note.is-danger {
  color: var(--danger-on-soft);
  font-weight: 600;
}

.meter {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  min-width: 72px;
}

.meter-text {
  font-variant-numeric: tabular-nums;
}

.meter-bar {
  display: block;
  height: 5px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-alt);
}

.meter-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

/* Anchos y proporciones por clase: la política de seguridad no permite estilos en línea. */
.fill-0 {
  width: 0%;
}

.fill-5 {
  width: 5%;
}

.fill-10 {
  width: 10%;
}

.fill-15 {
  width: 15%;
}

.fill-20 {
  width: 20%;
}

.fill-25 {
  width: 25%;
}

.fill-30 {
  width: 30%;
}

.fill-35 {
  width: 35%;
}

.fill-40 {
  width: 40%;
}

.fill-45 {
  width: 45%;
}

.fill-50 {
  width: 50%;
}

.fill-55 {
  width: 55%;
}

.fill-60 {
  width: 60%;
}

.fill-65 {
  width: 65%;
}

.fill-70 {
  width: 70%;
}

.fill-75 {
  width: 75%;
}

.fill-80 {
  width: 80%;
}

.fill-85 {
  width: 85%;
}

.fill-90 {
  width: 90%;
}

.fill-95 {
  width: 95%;
}

.fill-100 {
  width: 100%;
}

.grow-1 {
  flex-grow: 1;
}

.grow-2 {
  flex-grow: 2;
}

.grow-3 {
  flex-grow: 3;
}

.grow-4 {
  flex-grow: 4;
}

.grow-5 {
  flex-grow: 5;
}

.grow-6 {
  flex-grow: 6;
}

.grow-7 {
  flex-grow: 7;
}

.grow-8 {
  flex-grow: 8;
}

.grow-9 {
  flex-grow: 9;
}

.grow-10 {
  flex-grow: 10;
}

.grow-11 {
  flex-grow: 11;
}

.grow-12 {
  flex-grow: 12;
}

.grow-13 {
  flex-grow: 13;
}

.grow-14 {
  flex-grow: 14;
}

.grow-15 {
  flex-grow: 15;
}

.grow-16 {
  flex-grow: 16;
}

.grow-17 {
  flex-grow: 17;
}

.grow-18 {
  flex-grow: 18;
}

.grow-19 {
  flex-grow: 19;
}

.grow-20 {
  flex-grow: 20;
}

.meter.is-high .meter-bar i {
  background: var(--warning);
}

.meter.is-full .meter-bar i {
  background: var(--danger);
}

.meter.is-full .meter-text {
  color: var(--danger-on-soft);
  font-weight: 600;
}

/* ===== Insignias ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success {
  background: var(--success-soft);
  color: var(--success-on-soft);
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning-on-soft);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger-on-soft);
}

.badge-info {
  background: var(--info-soft);
  color: var(--info-on-soft);
}

.badge-muted {
  background: var(--surface-alt);
  color: var(--text-muted);
}

/* ===== Barra de filtros ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 14px clamp(14px, 2.2vw, 20px);
}

.toolbar-controls {
  display: flex;
  flex: 1 1 460px;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.toolbar-grow {
  flex: 1 1 200px;
  min-width: 0;
}

.toolbar-end {
  max-width: 420px;
  margin-left: auto;
}

.list-progress {
  position: relative;
  height: 2px;
  overflow: hidden;
  background: var(--outline);
}

.list-progress.is-active::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 35%;
  border-radius: 999px;
  background: var(--brand);
  animation: list-progress 1.1s ease-in-out infinite;
}

@keyframes list-progress {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(300%);
  }
}

.chips {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--outline-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

@media (hover: hover) {
  .chip:hover {
    background: var(--surface-alt);
    color: var(--text);
  }
}

.chip.active {
  border-color: color-mix(in srgb, var(--brand) 50%, transparent);
  background: var(--brand-soft);
  color: var(--brand-on-soft);
}

.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-success {
  background: var(--success);
}

.dot-warning {
  background: var(--warning);
}

.dot-danger {
  background: var(--danger);
}

.dot-muted {
  background: var(--outline-strong);
}

.chip-count {
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  line-height: 20px;
  text-align: center;
}

.chip.active .chip-count {
  background: color-mix(in srgb, var(--brand) 20%, transparent);
  color: inherit;
}

.search-box {
  position: relative;
  min-width: 0;
}

.search-box > .icon {
  position: absolute;
  top: 50%;
  left: 12px;
  color: var(--text-subtle);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-box .input {
  padding-left: 40px;
}

.search-box:has(.search-clear) .input {
  padding-right: 40px;
}

.search-box input::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 6px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-subtle);
  cursor: pointer;
  transform: translateY(-50%);
}

.search-clear:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.search-clear .icon {
  font-size: 18px;
}

@media (max-width: 719.98px) {
  .toolbar {
    padding: 12px 16px;
  }

  /* Los filtros se deslizan de borde a borde; el desvanecido indica que hay más. */
  .chips {
    flex: 1 1 100%;
    margin-inline: -16px;
    padding-inline: 16px 28px;
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }

  .toolbar-controls {
    flex-basis: 100%;
    flex-wrap: wrap;
  }

  .toolbar-grow {
    flex: 1 1 0;
  }

  .toolbar-end {
    flex-basis: 100%;
    max-width: none;
    margin-left: 0;
  }
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px clamp(16px, 2.5vw, 20px);
  border-top: 1px solid var(--outline);
}

.pager-info {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.pager-info strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.pager-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pager-buttons .icon-button {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
}

.pager-page {
  min-width: 36px;
  height: 36px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.pager-page:hover:not(:disabled):not(.active) {
  background: var(--surface-alt);
  color: var(--text);
}

.pager-page.active {
  background: var(--brand-soft);
  color: var(--brand-on-soft);
}

.pager-gap {
  min-width: 20px;
  color: var(--text-subtle);
  text-align: center;
}

.pager-compact {
  display: none;
  padding: 0 8px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 719.98px) {
  .pager-page,
  .pager-gap {
    display: none;
  }

  .pager-compact {
    display: inline;
  }
}

/* ===== Desplegable ===== */
.select {
  position: relative;
  min-width: 0;
}

.select-compact {
  flex: 0 0 auto;
  width: 196px;
}

.select-wide {
  flex: 0 1 240px;
  min-width: 0;
}

.select-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px 8px 12px;
  border: 1px solid var(--outline-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.select-trigger:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--brand) 55%, var(--outline-strong));
}

.select-trigger:focus-visible,
.select.is-open .select-trigger {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
  outline: none;
}

.select-trigger.invalid {
  border-color: var(--danger);
}

.select-trigger:disabled {
  background: var(--surface-alt);
  color: var(--text-muted);
  cursor: not-allowed;
}

.select-trigger > .icon {
  color: var(--text-subtle);
}

.select-trigger > .icon:last-child {
  margin-left: auto;
  transition: transform 150ms ease;
}

.select.is-open .select-trigger > .icon:last-child {
  transform: rotate(180deg);
}

.select-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-value.is-placeholder {
  color: var(--text-subtle);
}

.select-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
}

.select-popup {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 240px;
  max-height: 340px;
  overflow: hidden;
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: select-popup-in 120ms ease;
}

.select-popup-up {
  top: auto;
  bottom: calc(100% + 6px);
}

.select-compact .select-popup,
.select-wide .select-popup {
  right: 0;
  left: auto;
}

@keyframes select-popup-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.select-search {
  position: relative;
  padding: 8px;
  border-bottom: 1px solid var(--outline);
}

.select-search > .icon {
  position: absolute;
  top: 50%;
  left: 18px;
  color: var(--text-subtle);
  font-size: 18px;
  transform: translateY(-50%);
  pointer-events: none;
}

.select-search-input {
  width: 100%;
  min-height: 38px;
  padding: 6px 10px 6px 36px;
  border: 1px solid var(--outline-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.select-search-input:focus {
  border-color: var(--brand);
  outline: none;
}

.select-options {
  flex: 1;
  min-height: 0;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.select-option:hover,
.select-option:focus-visible,
.select-option:focus {
  background: var(--surface-alt);
  outline: none;
}

.select-option.is-selected {
  background: var(--brand-soft);
  color: var(--brand-on-soft);
  font-weight: 600;
}

.select-option-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.select-option small {
  display: block;
  color: var(--text-subtle);
  font-size: 0.8rem;
  font-weight: 400;
}

.select-option .icon {
  font-size: 18px;
}

.select-note {
  padding: 12px 10px;
  color: var(--text-subtle);
  font-size: 0.875rem;
  text-align: center;
}

@media (max-width: 719.98px) {
  /* En móvil el desplegable es una hoja inferior: nunca se corta y es fácil de tocar. */
  .select-backdrop {
    background: rgb(6 15 18 / 50%);
    animation: fade-in 140ms ease;
  }

  .select-popup,
  .select-popup-up,
  .select-compact .select-popup,
  .select-wide .select-popup {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-height: 72dvh;
    padding-bottom: env(safe-area-inset-bottom);
    border-width: 1px 0 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: slide-up 180ms ease;
  }

  /* Con buscador ocupa más alto: el teclado cubre la parte de abajo. */
  .select-popup.has-search {
    top: 10dvh;
    max-height: none;
  }

  .select-option {
    min-height: 46px;
  }

  .select-search-input {
    min-height: 44px;
    font-size: 16px;
  }

  html:has(.select.is-open) {
    overflow: hidden;
  }

  /* En la barra de filtros, el selector compacto queda como un botón de icono. */
  .select-compact {
    width: 44px;
  }

  .select-compact .select-trigger {
    justify-content: center;
    padding: 8px;
  }

  .select-compact .select-trigger .select-value,
  .select-compact .select-trigger > .icon:last-child {
    display: none;
  }

  .select-wide {
    flex: 1 1 100%;
  }
}

/* Funciones que se ven pero no responden, como la consulta sin sesión iniciada. */
.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Formularios ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 16px;
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

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

.field-label {
  font-size: 0.875rem;
  font-weight: 600;
}

.field-hint {
  color: var(--text-subtle);
  font-size: 0.8rem;
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--outline-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input:hover:not(:disabled):not(:focus) {
  border-color: color-mix(in srgb, var(--brand) 55%, var(--outline-strong));
}

.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
  outline: none;
}

.input:disabled {
  background: var(--surface-alt);
  color: var(--text-muted);
}

.input::placeholder {
  color: var(--text-subtle);
}

textarea.input {
  min-height: 104px;
  font-family: var(--mono);
  font-size: 0.875rem;
  resize: vertical;
}

textarea.input.input-text {
  font-family: inherit;
  font-size: 1rem;
}

.input.invalid {
  border-color: var(--danger);
}

.validation-message {
  color: var(--danger-on-soft);
  font-size: 0.82rem;
}

/* Interruptor: las opciones de sí o no se leen mejor y son más fáciles de tocar. */
.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 24px;
  cursor: pointer;
}

.check input {
  position: relative;
  width: 40px;
  height: 24px;
  margin: 0;
  border-radius: 999px;
  background: var(--outline-strong);
  cursor: pointer;
  flex-shrink: 0;
  appearance: none;
  transition: background-color 150ms ease;
}

.check input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 30%);
  transition: transform 150ms ease;
}

.check input:checked {
  background: var(--brand-strong);
}

.check input:checked::before {
  transform: translateX(16px);
}

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

.check small {
  display: block;
  color: var(--text-subtle);
  font-size: 0.8rem;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--outline);
}

.form-section h2 {
  margin-bottom: -4px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

@media (max-width: 719.98px) {
  .form-actions .btn {
    flex: 1 1 140px;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1 1 auto;
  }
}

/* ===== Secciones que se expanden ===== */
details.advanced {
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  transition: border-color 120ms ease;
}

details.advanced[open] {
  border-color: var(--outline-strong);
}

details.advanced summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 10px 12px 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

details.advanced summary::-webkit-details-marker {
  display: none;
}

details.advanced summary::after {
  content: "expand_more";
  color: var(--text-subtle);
  font-family: "Material Icons";
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
  font-feature-settings: "liga";
  transition: transform 180ms ease;
}

details.advanced[open] summary::after {
  transform: rotate(180deg);
}

details.advanced summary:hover {
  background: var(--surface-alt);
}

details.advanced[open] summary {
  border-bottom: 1px solid var(--outline);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.advanced-body {
  padding: 16px 14px;
}

/* ===== Pares dato-valor ===== */
.kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(45%, 180px), 1fr));
  gap: 16px;
  margin: 0;
}

.kv dt {
  color: var(--text-subtle);
  font-size: 0.8rem;
}

.kv dd {
  margin: 2px 0 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.json-block {
  max-height: 260px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  font-family: var(--mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ===== Avisos ===== */
.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
}

.banner > span:not(.icon) {
  flex: 1 1 180px;
}

.hero + .banner {
  margin-bottom: 20px;
}

.banner-danger {
  background: var(--danger-soft);
  color: var(--danger-on-soft);
}

.banner-warning {
  background: var(--warning-soft);
  color: var(--warning-on-soft);
}

.banner-success {
  background: var(--success-soft);
  color: var(--success-on-soft);
}

.secret {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px dashed var(--outline-strong);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
}

.secret code {
  min-width: 0;
  flex: 1 1 200px;
  word-break: break-all;
  user-select: all;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 44px 20px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
}

.empty-state .btn {
  margin-top: 8px;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--text-subtle);
}

.empty-icon .icon {
  font-size: 28px;
}

/* ===== Carga ===== */
.spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--outline-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
  border-color: rgb(255 255 255 / 40%);
  border-top-color: #fff;
}

.skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
}

.skeleton {
  height: 18px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-alt) 25%, var(--outline) 50%, var(--surface-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}

.skeleton:nth-child(even) {
  width: 72%;
}

/* ===== Diálogos ===== */
dialog.modal {
  width: min(calc(100vw - 32px), 520px);
  max-width: none;
  max-height: calc(100dvh - 48px);
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  color: var(--text);
}

dialog.modal[open] {
  animation: dialog-in 160ms ease;
}

dialog.modal::backdrop {
  background: rgb(6 15 18 / 50%);
  animation: fade-in 140ms ease;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.modal-panel {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 14px 20px;
  border-bottom: 1px solid var(--outline);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
}

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

@media (max-width: 719.98px) {
  dialog.modal {
    width: 100%;
    max-height: 90dvh;
    margin: auto 0 0;
  }

  dialog.modal[open] {
    animation: slide-up 180ms ease;
  }

  .modal-panel {
    padding-bottom: env(safe-area-inset-bottom);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

/* ===== Notificaciones ===== */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(calc(100vw - 32px), 420px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--outline);
  box-shadow: var(--shadow-md);
  font-weight: 600;
  animation: slide-up 180ms ease;
}

.toast .icon {
  color: var(--success);
}

@media (max-width: 899.98px) and (pointer: coarse) {
  .toasts {
    right: 16px;
    bottom: calc(var(--bottom-nav-height) + 12px + env(safe-area-inset-bottom));
    left: 16px;
    max-width: none;
  }

  .portal ~ .toasts {
    bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

/* ===== Selector segmentado ===== */
.segmented {
  display: inline-flex;
  align-self: flex-start;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--surface-alt);
}

.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.segmented button.active {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--brand-on-soft);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }

  to {
    background-position: -200% 0;
  }
}
