.sel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: var(--space-4);
  margin: 0;
}

.tenant-select-v2 .tenant-item > form {
  margin: 0;
  height: 100%;
}

.sel-grid > .tenant-item { min-width: 0; }
.sel-grid > .tenant-item.is-urgente { grid-column: 1 / -1; }

.sel-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-4);
  padding-top: calc(var(--space-4) + 4px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  text-align: left;
  overflow: hidden;
  font-family: inherit;
  transition: transform .18s ease, box-shadow .18s ease;
}

.sel-card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 4px;
  background: var(--inst, var(--brand));
}

button.sel-card {
  cursor: pointer;
  appearance: none;
}

.sel-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(30, 20, 60, .1);
}

.sel-card--urgent {
  border-color: color-mix(in srgb, var(--urgent) 40%, transparent);
}

.sel-flag {
  position: absolute;
  top: 16px;
  right: 16px;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--urgent-soft);
  color: var(--urgent-ink);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .04em;
  display: inline-flex;
  align-items: center;
}

.sel-card__main {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding-right: 8.5rem;
}

.sel-card:not(.sel-card--urgent) .sel-card__main { padding-right: 0; }

.sel-logo {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--inst, var(--brand)) 35%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--brand);
  font-size: 1.6rem;
}

.sel-logo img {
  width: 78%;
  height: 78%;
  object-fit: contain;
}

.sel-card h3 {
  margin: 0 0 4px;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

.sel-sub {
  margin: 0;
  color: var(--text-soft);
  font-size: 1rem;
}

.sel-nit {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: .85rem;
}

.sel-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.sel-pill {
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  font-size: .8rem;
  font-weight: 700;
  background: var(--st-inactiva-bg);
  color: var(--st-inactiva);
}

.sel-pill.is-activa { background: var(--st-activa-bg); color: var(--st-activa); }
.sel-pill.is-inactiva { background: var(--st-inactiva-bg); color: var(--st-inactiva); }
.sel-pill.is-suspendida { background: var(--st-suspendida-bg); color: var(--st-suspendida); }
.sel-pill.is-trial { background: var(--st-trial-bg); color: var(--st-trial); }
.sel-pill.is-cancelada { background: var(--st-cancelada-bg); color: var(--st-cancelada); }

.sel-role {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
}

.sel-role select {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  font: inherit;
}

.sel-role select option {
  background: var(--surface);
  color: var(--text);
}

.sel-btn {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.sel-btn--urgent { background: var(--urgent); }

.tenant-select-v2 .tp-empty {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 20px;
}

.tenant-select-v2 .tp-empty h4 { color: var(--text); }
.tenant-select-v2 .tp-empty .text-muted,
.tenant-select-v2 .tp-empty p { color: var(--text-soft) !important; }

.tenant-select-v2 #tenantResetFilters {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--brand);
  background: var(--surface);
  color: var(--brand-strong);
  font-weight: 700;
}

.tenant-select-v2 .tp-aura-fab {
  border: 0;
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow);
}

.tenant-select-v2 .tp-aura-fab:hover {
  color: #fff;
  box-shadow: 0 14px 32px rgba(30, 20, 60, .16);
}

.tenant-select-v2 .tp-aura-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--text);
}

.tenant-select-v2 .tp-aura-head {
  border-bottom: 1px solid var(--line);
}

.tenant-select-v2 .tp-aura-head h2 { color: var(--text); }
.tenant-select-v2 .tp-aura-head p { color: var(--text-soft); }

.tenant-select-v2 .tp-aura-close {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.tenant-select-v2 .tp-aura-msg.is-bot {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
}

.tenant-select-v2 .tp-aura-msg.is-user {
  background: var(--brand);
  color: #fff;
}

.tenant-select-v2 .tp-aura-result {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  min-height: 44px;
}

.tenant-select-v2 .tp-aura-result small,
.tenant-select-v2 .tp-aura-note { color: var(--text-soft); }

.tenant-select-v2 .tp-aura-result img {
  object-fit: contain;
  background: #fff;
}

.tenant-select-v2 .tp-aura-chip {
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.tenant-select-v2 .tp-aura-chip:hover {
  border-color: var(--brand);
  color: var(--brand-strong);
  background: var(--brand-soft);
}

.tenant-select-v2 .tp-aura-composer {
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.tenant-select-v2 .tp-aura-composer input {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}

.tenant-select-v2 .tp-aura-composer input::placeholder { color: var(--text-soft); }

.tenant-select-v2 .tp-aura-composer input:focus {
  border-color: var(--brand);
  box-shadow: var(--focus);
}

.tenant-select-v2 .tp-aura-send {
  background: var(--brand);
  color: #fff;
}

.tenant-select-v2 :focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

@media (max-width: 700px) {
  .sel-grid { grid-template-columns: 1fr; }
  .sel-card__main { padding-right: 0; }
  .sel-flag { position: static; align-self: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  .sel-card { transition: none; }
  .sel-card:hover { transform: none; }
  .tenant-select-v2 .tp-aura-fab:hover { transform: none; }
}
