/* Variables globales: colores, radios, sombras y ancho maximo. */
:root {
    --accent: #2658ec;
    --accent-strong: #1f47c4;
    --ink: #111827;
    --muted: #64748b;
    --line: #dbe3ef;
    --panel: #ffffff;
    --surface: #f4f7fb;
    --surface-strong: #eaf0ff;
    --green: #0f8f67;
    --amber: #b66708;
    --rose: #c2415d;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.10);
    --radius: 8px;
    --container: 1180px;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;
    --accent-soft-bg: #eef2fb;
    --accent-soft-text: #3450c9;
    --rose-soft-bg: #fdeef1;
    --rose-soft-text: #b03a54;

    /* Paleta asignable a los tipos de proyecto. Cada color trae el fondo del
       chip, su texto y un fondo algo mas saturado para el icono de la tarjeta. */
    --c-blue-bg: #eef2fb;   --c-blue-text: #3450c9;   --c-blue-icon-bg: #eaf0ff;
    --c-indigo-bg: #eeebfa; --c-indigo-text: #4436b8; --c-indigo-icon-bg: #e9e5f9;
    --c-cyan-bg: #e6f3fa;   --c-cyan-text: #0e6f8c;   --c-cyan-icon-bg: #dcedf7;
    --c-teal-bg: #e4f5f1;   --c-teal-text: #0f7d70;   --c-teal-icon-bg: #d8f1eb;
    --c-green-bg: #e7f8f1;  --c-green-text: #0f8f67;  --c-green-icon-bg: #d9f8eb;
    --c-amber-bg: #fff3df;  --c-amber-text: #b66708;  --c-amber-icon-bg: #fff0df;
    --c-orange-bg: #fdeee3; --c-orange-text: #b1560f; --c-orange-icon-bg: #fce5d6;
    --c-rose-bg: #fff0f4;   --c-rose-text: #c2415d;   --c-rose-icon-bg: #ffe3ef;
    --c-purple-bg: #f6eafa; --c-purple-text: #8a3ea3; --c-purple-icon-bg: #f1e2f7;
    --c-gray-bg: #e2e8f0;   --c-gray-text: #55616f;   --c-gray-icon-bg: #e6ebf2;

    /* Tono fijo de los chips de subgrupo, que no llevan color propio. */
    --chip-neutral-bg: #eef1f6;
    --chip-neutral-text: #4a5568;
}

/* Reset basico compartido por toda la pagina. */
* {
  box-sizing: border-box;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #eef3ff 0%, var(--surface) 34%, #f8fafc 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

/* Layout general y cabecera base. */
header {
  align-items: flex-start;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: var(--container);
  padding: 36px 32px 10px;
  width: 100%;
}

.header-content {
  min-width: 0;
}

h1 {
  margin: 0;
  max-width: 820px;
  font-size: 42px;
  line-height: 1.06;
}

.home-link {
  color: inherit;
  text-decoration: none;
}

.home-link:hover {
  color: var(--accent);
}

.description {
  margin: 14px 0 0;
  max-width: 680px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

button,
.button-link {
  align-items: center;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  justify-content: center;
  line-height: 20px;
  min-height: 42px;
  padding: 10px 16px;
  text-decoration: none;
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
  white-space: nowrap;
}

/* Area de administracion: texto mas ligero (elegancia/minimalismo) */
.roles-panel button,
.roles-panel .button-link,
.modal-panel button,
.modal-panel .button-link {
  font-weight: 500;
}

.roles-panel label,
.modal-panel label {
  font-weight: 500;
}

button:hover:not(:disabled),
.button-link:hover {
  background: var(--accent-strong);
  box-shadow: 0 10px 24px rgba(38, 88, 236, 0.22);
  transform: translateY(-1px);
}

button:focus-visible,
.button-link:focus-visible,
.home-link:focus-visible,
.admin-menu summary:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(38, 88, 236, 0.30);
  outline-offset: 3px;
}

button:disabled {
  background: #d8dee8;
  color: #7b8798;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.secondary {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(219, 227, 239, 0.95);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.secondary:hover {
  background: #ffffff;
  border-color: rgba(38, 88, 236, 0.42);
  color: var(--accent);
}

.light {
  background: #eef2f7;
  color: var(--ink);
}

.light:hover:not(:disabled) {
  background: #e2e8f0;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.10);
}

.danger {
  background: #c2415d;
}

.danger:hover:not(:disabled) {
  background: #a9344c;
  box-shadow: 0 10px 24px rgba(194, 65, 93, 0.20);
}

/* Contenedor principal de la app autenticada. */
.page-shell {
  margin: 0 auto;
  max-width: none;
  padding: 36px 0 50px;
  width: min(var(--container), calc(100% - 48px));
}

/* Barra de usuario logueado y boton de cerrar sesion. */
.user-bar {
  align-items: center;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 28px;
  width: 100%;
}

.user-info {
  align-items: center;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(219, 227, 239, 0.9);
  border-radius: 999px;
  display: flex;
  font-size: 0.86rem;
  gap: 10px;
  padding: 6px 6px 6px 12px;
}

.user-avatar {
  align-items: center;
  background: #0065a8;
  border-radius: 50%;
  color: #ffffff;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 0.8rem;
  font-weight: 800;
  height: 28px;
  justify-content: center;
  object-fit: cover;
  width: 28px;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}

.user-name {
  color: var(--ink);
  font-weight: 700;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-email {
  color: var(--muted);
  font-size: 0.74rem;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-form {
  margin: 0;
}

.admin-menu {
  position: relative;
}

.admin-menu summary {
  align-items: center;
  background: #eef2f7;
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 500;
  list-style: none;
  min-height: 30px;
  padding: 6px 14px;
  user-select: none;
}

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

.admin-menu summary::after {
  content: "▾";
  font-size: 0.7rem;
  margin-left: 8px;
}

.admin-menu[open] summary,
.admin-menu summary:hover {
  background: #e2e8f0;
}

.admin-menu-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
  min-width: 190px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
}

.admin-menu-panel a {
  border-radius: 6px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 500;
  padding: 9px 10px;
  text-decoration: none;
  white-space: nowrap;
}

.admin-menu-panel a:hover,
.admin-menu-panel a:focus-visible {
  background: var(--surface-strong);
  color: var(--accent);
  outline: none;
}

.logout-btn {
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  margin-left: 6px;
  min-height: 0;
  padding: 6px 14px;
  transition: background 180ms ease;
}

.logout-btn:hover:not(:disabled) {
  background: var(--accent);
  box-shadow: none;
  transform: none;
}

/* Cabecera superior con titulo y accesos principales. */
.topbar {
  align-items: center;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin: 0 0 48px;
  max-width: none;
  padding: 0;
  width: 100%;
}

.topbar .header-content {
  min-width: 0;
}

.topbar h1 {
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.02;
  max-width: 820px;
  text-wrap: balance;
}


.topbar .description {
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
  margin: 16px 0 0;
  max-width: 720px;
}

main {
  box-sizing: border-box;
  margin: 0 auto;
  max-width: var(--container);
  padding: 26px 32px 50px;
  width: 100%;
}

.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
  min-height: 150px;
  padding: 22px;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.section:hover {
  border-color: rgba(38, 88, 236, 0.40);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.section h2 {
  margin: 0 0 12px;
  font-size: 18px;
  line-height: 1.25;
}

.section h3 {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

/* Home: pestanas Data / IA y tarjetas de recursos. */
.content-shell {
  min-height: 360px;
}

.tabs-card {
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(219, 227, 239, 0.9);
  border-radius: var(--radius);
  box-shadow: 0 12px 35px rgba(15, 23, 42, 0.08);
  padding: 8px;
}

.tabs {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tab-button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  min-height: 48px;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.tabs .tab-button:hover {
  background: #f1f5f9;
  box-shadow: none;
  color: var(--ink);
  transform: none;
}

.tabs .tab-button[aria-selected="true"]:hover {
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(38, 88, 236, 0.26);
  color: #ffffff;
  transform: none;
}

.tab-button[aria-selected="true"] {
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(38, 88, 236, 0.26);
  color: #ffffff;
}

.content {
  margin-top: 48px;
}

.tab-panel[hidden] {
  display: none;
}

.content .section {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  margin-top: 48px;
  min-height: 0;
  padding: 0;
  transition: none;
}

.content .section:first-child {
  margin-top: 0;
}

.content .section:hover {
  border-color: transparent;
  box-shadow: none;
  transform: none;
}

.section-header {
  align-items: end;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-header h2 {
  font-size: 1.08rem;
  line-height: 1.2;
  margin: 0;
}

.section-note {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
  margin: 0;
  text-align: right;
}

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

.resource-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
  color: var(--ink);
  display: flex;
  min-height: 168px;
  padding: 20px;
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.resource-card:hover {
  border-color: rgba(38, 88, 236, 0.45);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.resource-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 18px;
  justify-content: space-between;
  min-width: 0;
}

.resource-top {
  align-items: flex-start;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  min-width: 0;
}

.resource-top h3 {
  color: var(--ink);
  font-size: 1.02rem;
  line-height: 1.35;
  margin: 0;
  overflow-wrap: anywhere;
}

.tag {
  background: var(--surface-strong);
  border-radius: 999px;
  color: var(--accent-strong);
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  padding: 5px 8px;
  white-space: nowrap;
}

.resource-footer {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.88rem;
  gap: 14px;
  justify-content: space-between;
  line-height: 1.2;
}

.open-indicator {
  background: var(--ink);
  border-radius: 50%;
  color: #ffffff;
  display: inline-grid;
  flex: 0 0 auto;
  height: 32px;
  place-items: center;
  transition: background 180ms ease, transform 180ms ease;
  width: 32px;
}

.resource-card:hover .open-indicator {
  background: var(--accent);
  transform: translateX(2px);
}

/* Pie de pagina. */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 64px;
  padding-top: 48px;
  text-align: center;
}

.site-footer p {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  margin: 0;
}

/* Pantallas de roles y usuarios: paneles, toolbar y filtros. */
.roles-panel {
  background: transparent;
  margin-top: 6px;
  padding-top: 0;
}

.roles-panel h2 {
  margin: 0;
  font-size: 22px;
  font-weight: var(--fw-semibold);
  line-height: 1.2;
}

.roles-toolbar {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 16px;
}

.roles-toolbar p {
  color: var(--muted);
  margin: 6px 0 0;
}

.toolbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.role-controls {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(240px, 1fr) minmax(220px, 320px);
  margin-bottom: 18px;
}

.search-field {
  margin: 0;
}

.search-field > span:not(.control-shell),
.search-field .field-label {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: var(--fw-medium);
  margin-bottom: 6px;
}

.ui-icon {
  align-items: center;
  color: currentColor;
  display: inline-flex;
  flex: 0 0 auto;
  height: 18px;
  justify-content: center;
  width: 18px;
}

.ui-icon svg {
  display: block;
  height: 100%;
  width: 100%;
}

.control-shell {
  align-items: center;
  background: #ffffff;
  border: 1px solid #d8e1ef;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
  color: #536583;
  display: flex;
  gap: 12px;
  min-height: 56px;
  padding: 0 14px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.control-shell:focus-within {
  border-color: rgba(38, 88, 236, 0.46);
  box-shadow: 0 0 0 3px rgba(38, 88, 236, 0.12);
}

.control-shell input[type="text"],
.control-shell select {
  background: transparent;
  border: 0;
  border-radius: 0;
  color: #19233a;
  font-size: 14px;
  font-weight: var(--fw-medium);
  min-height: 0;
  padding: 0;
}

.control-shell input[type="text"] {
  font-weight: 600;
}

.control-shell input[type="text"]::placeholder {
  color: #6c7893;
  opacity: 1;
}

.control-shell input:focus-visible,
.control-shell select:focus-visible {
  outline: none;
}

.search-field--icon .field-label {
  height: 1px;
  margin: 0;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.roles-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.accesses-panel {
  margin-top: 42px;
}

.single-control {
  grid-template-columns: minmax(240px, 1fr);
}

.access-controls {
  gap: 14px;
  grid-template-columns: minmax(320px, 1.55fr) repeat(3, minmax(210px, 1fr));
  margin-bottom: 24px;
}

.accesses-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(370px, 1fr));
}

.access-card {
  background: var(--panel);
  border: 1px solid #dbe4f2;
  border-radius: var(--radius);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 290px;
  min-width: 0;
  padding: 22px;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.access-card:hover {
  border-color: rgba(38, 88, 236, 0.30);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.11);
  transform: translateY(-2px);
}

.access-card[hidden] {
  display: none;
}

.access-card-header {
  align-items: flex-start;
  display: grid;
  gap: 18px;
  grid-template-columns: 48px minmax(0, 1fr);
  min-width: 0;
}

.access-card-icon {
  align-items: center;
  border-radius: 12px;
  display: inline-flex;
  height: 48px;
  justify-content: center;
  width: 48px;
}

.access-card-icon .ui-icon {
  height: 28px;
  width: 28px;
}

.access-card-title {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.access-card h3 {
  color: var(--ink);
  font-size: 1rem;
  font-weight: var(--fw-semibold);
  line-height: 1.28;
  margin: 0;
  overflow-wrap: anywhere;
}

.access-card-eyebrow {
  color: #647089;
  font-size: 0.76rem;
  font-weight: var(--fw-medium);
}

.access-card-main {
  align-content: start;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.access-card-description {
  align-items: flex-start;
  color: #8a97b0;
  display: grid;
  gap: 14px;
  grid-template-columns: 18px minmax(0, 1fr);
}

.access-card-description .ui-icon {
  margin-top: 3px;
}

.access-card-description p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
  margin: 0;
  overflow-wrap: anywhere;
}

.access-card-actions {
  align-items: center;
  display: contents;
  flex: 0 0 auto;
}

.access-card-actions button {
  font-size: 13px;
  min-height: 40px;
  padding: 8px 14px;
}

.access-card-footer {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(116px, 1.2fr) minmax(92px, 1fr) minmax(96px, 1fr);
  margin-top: auto;
  padding-top: 16px;
}

.access-card-link-wrap {
  min-width: 0;
}

.access-card-link {
  align-items: center;
  background: var(--accent);
  border-radius: 6px;
  color: #ffffff;
  display: inline-flex;
  gap: 9px;
  font-size: 13px;
  font-weight: 500;
  justify-content: center;
  min-height: 40px;
  overflow-wrap: anywhere;
  padding: 8px 12px;
  text-decoration: none;
  white-space: nowrap;
  width: 100%;
}

.access-card-link:hover {
  background: var(--accent-strong);
  color: #ffffff;
  text-decoration: none;
}

.action-button {
  align-items: center;
  border: 1px solid #d9e1ee;
  border-radius: 6px;
  display: inline-flex;
  font-weight: var(--fw-semibold);
  gap: 8px;
  justify-content: center;
  min-width: 0;
  white-space: nowrap;
}

.access-card-footer .action-button {
  width: 100%;
}

.action-button.light {
  background: #ffffff;
  color: var(--ink);
}

.action-button.light:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #cbd5e1;
  box-shadow: none;
  color: var(--ink);
}

.action-button.subtle-danger {
  background: var(--rose-soft-bg);
  border-color: #f3d7dd;
  color: var(--rose-soft-text);
}

.action-button.subtle-danger:hover:not(:disabled) {
  background: var(--rose);
  border-color: var(--rose);
  box-shadow: none;
  color: #ffffff;
}

.access-field-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 12px;
}

.access-field-pill {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 4px;
  padding: 8px 10px;
}

.access-field-pill span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: var(--fw-medium);
  text-transform: uppercase;
}

.access-field-pill strong {
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: var(--fw-semibold);
  overflow-wrap: anywhere;
}

.access-field-pill strong.is-empty {
  color: var(--muted);
  font-style: italic;
}

.access-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.access-meta-chip {
  background: var(--accent-soft-bg);
  border-radius: 999px;
  color: var(--accent-soft-text);
  font-size: 0.72rem;
  font-weight: var(--fw-medium);
  line-height: 1;
  padding: 7px 9px;
}

.access-details {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}

.access-details summary {
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: var(--fw-semibold);
}

.access-card-muted {
  color: var(--muted);
}

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

/* Tarjetas de roles y chips de accesos. */
.role-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding: 18px;
  overflow: hidden;
}

.role-card[hidden] {
  display: none;
}

.role-card-top {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.role-card-title {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-width: 0;
}

.role-card-title h3 {
  font-size: 18px;
  font-weight: var(--fw-semibold);
  line-height: 1.25;
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-count-group {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.permission-count {
  background: var(--accent-soft-bg);
  border: 1px solid #d7e1ff;
  border-radius: 999px;
  color: var(--accent-soft-text);
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: var(--fw-medium);
  line-height: 1;
  padding: 7px 9px;
  white-space: nowrap;
}

.permission-count.user-count {
  background: var(--c-amber-bg);
  border-color: #f5dcae;
  color: var(--c-amber-text);
}

.role-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: var(--fw-medium);
}

.permission-list {
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  padding-top: 14px;
}

.permission-chip {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #263241;
  display: inline-block;
  font-size: 13px;
  font-weight: var(--fw-medium);
  line-height: 1.2;
  max-width: 210px;
  min-height: 32px;
  overflow: hidden;
  padding: 8px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.permission-chip.is-extra {
  display: none;
}

.permissions-expanded .permission-chip.is-extra {
  display: inline-block;
}

.show-more-permissions {
  background: #eef2f7;
  color: var(--ink);
  min-height: 32px;
  padding: 6px 10px;
}

.show-more-permissions:hover:not(:disabled) {
  background: #e2e8f0;
  box-shadow: none;
}

.role-card-actions {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 14px;
}

.role-card-actions .open-delete-item:disabled {
  background: #eef1f6;
  border-color: var(--line);
  color: #9aa5b4;
  cursor: not-allowed;
}

.compact-actions {
  margin-top: 0;
  padding-top: 12px;
}

.subtle-danger {
  background: #fff0f4;
  border: 1px solid #f6cdd8;
  color: var(--rose);
}

.subtle-danger:hover:not(:disabled) {
  background: #c2415d;
  color: #ffffff;
}

.role-card-empty {
  color: var(--muted);
  margin: 0;
}

.role-empty-state {
  background: #ffffff;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

/* Listado de usuarios y acciones de rol. */
.users-list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.user-row {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 72px;
  padding: 14px 16px;
}

.user-row + .user-row {
  border-top: 1px solid var(--line);
}

.user-row[hidden] {
  display: none;
}

.user-row:hover {
  background: #f8fafc;
}

.user-row-main {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 1fr) max-content;
  min-width: 0;
}

.user-row-email {
  font-weight: var(--fw-semibold);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Tabla legacy de campos, conservada por compatibilidad visual. */
.role-header {
  align-items: center;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 60px;
  padding-right: 12px;
}

.role-header form {
  padding-right: 12px;
}

.role-id {
  background: transparent;
  font-weight: 500;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 14px 18px;
}

.table-wrap {
  overflow-x: auto;
  width: 100%;
}

.field-table {
  border-collapse: collapse;
  min-width: 680px;
  width: 100%;
}

.field-table thead {
  background: #f8fafc;
}

.field-table th,
.field-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  text-align: left;
  vertical-align: middle;
}

.field-table th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

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

.field-table tbody tr:hover {
  background: #f8fafc;
}

.field-table td:first-child,
.field-table th:first-child {
  font-weight: 500;
}

/* Pildoras y chips reutilizables. */
code {
  background: #eef2f7;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #263241;
  display: inline-block;
  max-width: 100%;
  padding: 3px 7px;
  white-space: pre-wrap;
  word-break: break-word;
}

.value-pill {
  background: var(--accent-soft-bg);
  border: 1px solid #d7e1ff;
  border-radius: 999px;
  color: var(--accent-soft-text);
  display: inline-flex;
  font-weight: var(--fw-medium);
  justify-self: start;
  max-width: 100%;
  padding: 5px 10px;
  overflow-wrap: anywhere;
  width: fit-content;
}

.access-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
}

.access-chip {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #263241;
  display: inline-flex;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.25;
  max-width: 100%;
  min-height: 34px;
  padding: 7px 11px;
  overflow-wrap: anywhere;
}

.empty-state {
  color: var(--muted);
  margin: 0;
}

/* Modales: crear, editar, anadir accesos y confirmar borrado. */
.modal {
  background: rgba(17, 24, 39, 0.48);
  display: none;
  inset: 0;
  overflow-y: auto;
  padding: 32px;
  position: fixed;
  z-index: 10;
}

.modal.open {
  display: block;
}

.modal.confirm-modal.open,
.modal.centered-modal.open {
  align-items: center;
  display: flex;
  justify-content: center;
}

.modal-panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(219, 227, 239, 0.95);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.20);
  margin-left: auto;
  max-height: calc(100vh - 64px);
  max-width: 820px;
  overflow-y: auto;
  padding: 24px;
}

.confirm-panel {
  margin: 0;
  max-width: 520px;
  width: min(520px, 100%);
}

.centered-modal .modal-panel {
  margin: 0;
  width: min(820px, 100%);
}

.modal-header {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: var(--fw-semibold);
}

.modal-header p {
  color: var(--muted);
  margin: 6px 0 0;
}

/* Formularios dentro de modales. */
.field {
  margin-bottom: 18px;
}

label {
  color: #263241;
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}

.field-label-row {
  align-items: center;
  display: flex;
  gap: 7px;
  margin-bottom: 8px;
  min-width: 0;
}

.field-label-row label {
  margin-bottom: 0;
  min-width: 0;
}

.required-mark {
  color: var(--rose);
  font-weight: var(--fw-semibold);
}

.field-help {
  align-items: center;
  background: #ffffff;
  border: 1px solid #cfd8e5;
  border-radius: 50%;
  color: #506584;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: var(--fw-semibold);
  height: 20px;
  justify-content: center;
  line-height: 1;
  min-height: 0;
  padding: 0;
  position: relative;
  width: 20px;
}

.field-help:hover:not(:disabled) {
  background: var(--surface-strong);
  box-shadow: none;
  color: var(--accent-strong);
  transform: none;
}

.field-help-tooltip {
  background: #111827;
  border-radius: 6px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
  color: #ffffff;
  font-size: 12px;
  font-weight: var(--fw-medium);
  line-height: 1.35;
  max-width: min(360px, calc(100vw - 24px));
  opacity: 0;
  padding: 9px 10px;
  pointer-events: none;
  position: absolute;
  text-align: left;
  transform: translateY(4px);
  transition: opacity 140ms ease, transform 140ms ease;
  visibility: hidden;
  width: max-content;
  z-index: 60;
}

.field-help-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

input[type="text"],
select,
textarea {
  background: #ffffff;
  border: 1px solid #cfd8e5;
  border-radius: 6px;
  box-sizing: border-box;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  width: 100%;
}

input[type="text"],
select {
  min-height: 42px;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input[type="text"]:disabled {
  background: #eef2f7;
  color: #7b8798;
}

input[type="text"][readonly] {
  background: #eef2f7;
  color: #64748b;
  cursor: not-allowed;
}

.access-fixed-fields {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 14px;
}

.access-fixed-fields .field {
  margin-bottom: 0;
}

.id-row {
  align-items: end;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr auto;
}

.auto-id {
  align-items: center;
  background: var(--surface-strong);
  border-radius: 999px;
  color: var(--accent-strong);
  display: flex;
  gap: 8px;
  margin-bottom: 2px;
  padding: 9px 12px;
  white-space: nowrap;
}

.field-row {
  align-items: end;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(92px, auto) 190px minmax(220px, 1fr) auto;
  margin-bottom: 12px;
  padding: 12px;
}

.user-role-field-row {
  grid-template-columns: minmax(140px, auto) minmax(220px, 1fr);
}

.row-number {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  display: flex;
  font-size: 14px;
  font-weight: var(--fw-medium);
  min-height: 42px;
  padding: 10px 12px;
}

.form-actions {
  border-top: 1px solid var(--line);
  display: flex;
  gap: 12px;
  padding-top: 18px;
}

/* Cuadricula de checkboxes para elegir los accesos de un rol. */
.access-checklist {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.access-checklist-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.access-checklist-toolbar .search-field {
  flex: 1 1 220px;
}

.access-checklist-toolbar .control-shell {
  min-height: 42px;
}

.access-checklist-actions {
  display: flex;
  gap: 8px;
}

.access-checklist-count {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: var(--fw-medium);
  white-space: nowrap;
}

.access-checklist-groups {
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}

.access-check-group {
  border: 0;
  margin: 0 0 14px;
  padding: 0;
}

.access-check-group:last-child {
  margin-bottom: 0;
}

.access-check-group legend {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  padding: 0;
  text-transform: uppercase;
}

.access-check-group.is-hidden {
  display: none;
}

.access-check-item {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  gap: 10px;
  margin-bottom: 6px;
  padding: 9px 12px;
}

.access-check-item.is-hidden {
  display: none;
}

.access-check-item input[type="checkbox"] {
  flex: 0 0 auto;
  height: 16px;
  width: 16px;
}

.access-checklist-empty {
  color: var(--muted);
  margin: 0;
}

/* Mensajes de exito y error. */
.status {
  border-radius: var(--radius);
  font-weight: 700;
  margin: 0 0 16px;
  padding: 12px 14px;
}

.success {
  background: #e7f8f1;
  border: 1px solid #bfe9d9;
  color: var(--green);
}

.error {
  background: #fff0f4;
  border: 1px solid #f6cdd8;
  color: var(--rose);
}

.logout-form {
  margin: 0;
}

.logout-form button:not(.logout-btn) {
  height: 42px;
}

/* Pantalla de login con Google. */
.login-screen {
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: none;
  min-height: 100vh;
  padding: 36px 24px;
  width: 100%;
}

.login-card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(219, 227, 239, 0.9);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  padding: 36px 32px 32px;
  text-align: left;
  width: min(440px, 100%);
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin: 0 0 10px;
  text-transform: uppercase;
}

.login-card h1 {
  font-size: clamp(1.6rem, 3vw, 2rem);
  line-height: 1.12;
  margin: 8px 0 0;
}

.subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 14px 0 26px;
}

.google-signin-wrap {
  display: flex;
  justify-content: center;
}

.google-signin-btn {
  align-items: center;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 6px;
  color: #3c4043;
  display: inline-flex;
  font-family: "Google Sans", Roboto, Arial, sans-serif;
  font-size: 14px;
  font-weight: 500;
  gap: 12px;
  height: 44px;
  justify-content: center;
  letter-spacing: 0.15px;
  min-width: 240px;
  padding: 0 18px;
  text-decoration: none;
  transition: box-shadow 180ms ease, background 180ms ease, border-color 180ms ease;
}

.google-signin-btn:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.302), 0 1px 2px rgba(60, 64, 67, 0.149);
  transform: none;
}

.google-signin-btn:focus-visible {
  border-color: #4285f4;
  box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.3);
  outline: none;
}

.google-signin-btn:active {
  background: #f1f3f4;
}

.google-signin-btn svg {
  flex: 0 0 auto;
}

.login-error {
  background: #fff0f4;
  border: 1px solid #f6cdd8;
  border-radius: var(--radius);
  color: var(--rose);
  font-size: 0.88rem;
  line-height: 1.45;
  margin: 18px 0 0;
  padding: 12px 14px;
}

.login-error:empty {
  display: none;
}

.login-footer {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 36px;
  text-align: center;
}

.login-footer p {
  margin: 0;
}

/* Ajustes responsive generales. */
@media (max-width: 900px) {
  header {
    display: block;
  }
}

@media (max-width: 760px) {
  header {
    padding: 22px 18px 8px;
  }

  h1 {
    font-size: 30px;
  }

  main {
    padding: 18px;
  }

  .id-row,
  .field-row {
    grid-template-columns: 1fr;
  }

  .roles-toolbar,
  .panel-header,
  .role-header {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions {
    flex-direction: column;
  }

  .role-controls,
  .roles-grid,
  .accesses-grid,
  .access-fixed-fields {
    grid-template-columns: 1fr;
  }

  .role-card-title,
  .role-card-actions,
  .access-card-actions,
  .user-row-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .access-card-footer {
    grid-template-columns: 1fr;
  }

  .user-row,
  .user-row-main {
    grid-template-columns: 1fr;
  }

  .user-row-actions {
    justify-content: stretch;
  }

  .role-card-title h3,
  .permission-chip {
    max-width: 100%;
  }

  .role-header {
    padding-right: 0;
  }

  .role-header button {
    margin: 0 12px 12px;
  }

  .role-header form {
    padding: 0 12px 12px;
  }

  .modal {
    padding: 16px;
  }

  .modal-panel {
    max-height: calc(100vh - 32px);
  }

  .form-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 760px) {
  .page-shell {
    padding: 24px 0 40px;
    width: min(var(--container), calc(100% - 32px));
  }

  .user-info {
    align-items: stretch;
    border-radius: var(--radius);
    flex-direction: column;
    width: 100%;
  }

  .admin-menu summary,
  .logout-btn {
    justify-content: center;
    width: 100%;
  }

  .admin-menu-panel {
    position: static;
    margin-top: 8px;
    width: 100%;
  }

  .user-bar {
    justify-content: stretch;
  }

  .logout-btn {
    margin-left: 0;
    width: 100%;
  }

  .topbar {
    margin-bottom: 32px;
  }

  .content {
    margin-top: 32px;
  }

  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-note {
    text-align: left;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

}

.resource-card--wip {
    background: #f1f5f9;
    border: 1px dashed #c8d3de;
    box-shadow: none;
    cursor: default;
    pointer-events: none;
}

.resource-card--wip:hover {
    transform: none;
    border-color: #c8d3de;
    box-shadow: none;
}

.resource-card--wip h3 {
    color: #94a3b8;
}

.resource-card--wip .resource-footer {
    color: #94a3b8;
}


.tag {
    flex: 0 0 auto;
    padding: 5px 8px;
    border-radius: 999px;
    color: var(--accent-strong);
    background: var(--surface-strong);
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.resource-card--wip {
    background: #f1f5f9;
    border: 1px dashed #c8d3de;
    box-shadow: none;
    cursor: default;
    pointer-events: none;
}

.summary-panel {
  align-items: flex-start;
  display: flex;
  flex: 0 0 378px;
  justify-content: flex-end;
}

.summary-inner {
  width: 100%;
}

.summary-eyebrow {
  color: #506584;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin: 0 0 10px;
  text-transform: uppercase;
}

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

.summary-item {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(207, 216, 229, 0.95);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
  display: grid;
  min-height: 88px;
  min-width: 0;
  padding: 14px;
}

.summary-number {
  color: var(--ink);
  display: block;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.summary-label {
  color: #506584;
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.35;
  margin-top: 6px;
}

@media (max-width: 980px) {
  .summary-panel {
    flex: 0 1 auto;
    justify-content: flex-start;
    width: 100%;
  }
}

@media (max-width: 420px) {
  .summary-items {
    grid-template-columns: 1fr;
  }
}

.home-breadcrumb {
  align-items: center;
  color: var(--accent);
  display: inline-flex;
  font-size: 0.76rem;
  font-weight: var(--fw-medium);
  gap: 6px;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.home-breadcrumb svg {
  fill: currentColor;
  height: 15px;
  width: 15px;
}

.home-breadcrumb:hover {
  color: var(--accent-strong);
}

/* Utilidad de accesibilidad: texto solo para lectores de pantalla. */
.sr-only {
  border: 0;
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/* Paleta de los tipos de proyecto. El color se asigna desde Gestionar
   proyectos y se aplica al chip de admin, a la etiqueta de la portada y al
   icono de la tarjeta. */
.access-meta-chip.blue,
.tag.blue { background: var(--c-blue-bg); color: var(--c-blue-text); }
.access-card-icon.blue { background: var(--c-blue-icon-bg); color: var(--c-blue-text); }

.access-meta-chip.indigo,
.tag.indigo { background: var(--c-indigo-bg); color: var(--c-indigo-text); }
.access-card-icon.indigo { background: var(--c-indigo-icon-bg); color: var(--c-indigo-text); }

.access-meta-chip.cyan,
.tag.cyan { background: var(--c-cyan-bg); color: var(--c-cyan-text); }
.access-card-icon.cyan { background: var(--c-cyan-icon-bg); color: var(--c-cyan-text); }

.access-meta-chip.teal,
.tag.teal { background: var(--c-teal-bg); color: var(--c-teal-text); }
.access-card-icon.teal { background: var(--c-teal-icon-bg); color: var(--c-teal-text); }

.access-meta-chip.green,
.tag.green { background: var(--c-green-bg); color: var(--c-green-text); }
.access-card-icon.green { background: var(--c-green-icon-bg); color: var(--c-green-text); }

.access-meta-chip.amber,
.tag.amber { background: var(--c-amber-bg); color: var(--c-amber-text); }
.access-card-icon.amber { background: var(--c-amber-icon-bg); color: var(--c-amber-text); }

.access-meta-chip.orange,
.tag.orange { background: var(--c-orange-bg); color: var(--c-orange-text); }
.access-card-icon.orange { background: var(--c-orange-icon-bg); color: var(--c-orange-text); }

.access-meta-chip.rose,
.tag.rose { background: var(--c-rose-bg); color: var(--c-rose-text); }
.access-card-icon.rose { background: var(--c-rose-icon-bg); color: var(--c-rose-text); }

.access-meta-chip.purple,
.tag.purple { background: var(--c-purple-bg); color: var(--c-purple-text); }
.access-card-icon.purple { background: var(--c-purple-icon-bg); color: var(--c-purple-text); }

.access-meta-chip.gray,
.tag.gray { background: var(--c-gray-bg); color: var(--c-gray-text); }
.access-card-icon.gray { background: var(--c-gray-icon-bg); color: var(--c-gray-text); }

/* Tono neutro: chips de subgrupo y etiquetas de proyectos en desarrollo. */
.access-meta-chip.neutral,
.tag.neutral {
  background: var(--chip-neutral-bg);
  color: var(--chip-neutral-text);
}

/* Modal de subgrupos y tipos. */
.taxonomy-panel {
  width: min(960px, 100%);
}

/* Guardar cambios queda en la esquina opuesta a Cerrar, no pegado a el. */
.taxonomy-form-actions {
  justify-content: space-between;
}

.modal-tabs {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
}

.modal-tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: var(--fw-semibold);
  min-height: 0;
  padding: 10px 14px;
}

/* Neutraliza el hover generico de button, igual que hacen las tabs de la home. */
.modal-tabs .modal-tab:hover:not(:disabled) {
  background: transparent;
  box-shadow: none;
  color: var(--ink);
  transform: none;
}

.modal-tabs .modal-tab[aria-selected="true"] {
  background: transparent;
  border-bottom-color: var(--accent);
  box-shadow: none;
  color: var(--accent);
  transform: none;
}

.modal-tab-panel[hidden] {
  display: none;
}

.taxonomy-group-title {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.04em;
  margin: 18px 0 8px;
  text-transform: uppercase;
}

.taxonomy-row {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  margin-bottom: 8px;
  padding: 10px 12px;
}

.taxonomy-row--new {
  background: var(--accent-soft-bg);
  border-color: #d7e1ff;
  grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1.4fr) auto;
}

/* Fila de subgrupo: nombre+descripcion arriba a todo lo ancho (hasta el
   borde de "Borrar"); icono+checkbox+contador+Borrar debajo. Las celdas se
   colocan a mano para que la descripcion pueda invadir la columna del lado,
   algo que el auto-placement no permite sin ambigueadad. */
.taxonomy-row--subgroup {
  grid-template-rows: auto auto;
}

.taxonomy-row--subgroup .taxonomy-order {
  grid-column: 1;
  grid-row: 1 / 3;
}

.taxonomy-row--subgroup .taxonomy-row-title {
  grid-column: 2 / -1;
  grid-row: 1;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.taxonomy-row--subgroup .taxonomy-row-form {
  grid-column: 2;
  grid-row: 2;
}

.taxonomy-row--subgroup .taxonomy-row-side {
  align-self: start;
  grid-column: 3;
  grid-row: 2;
}

/* El nombre y la descripcion del subgrupo comparten linea: 30/70. Los
   flex-basis descuentan la mitad del gap para sumar exactamente el 100%. */
.taxonomy-row-title input[name="subgrupo_nombre"] {
  flex: 0 1 calc(30% - 5px);
  min-width: 0;
}

.taxonomy-row-title input[name="subgrupo_descripcion"] {
  flex: 1 1 calc(70% - 5px);
  min-width: 0;
}

.taxonomy-order {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.taxonomy-order-btn {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  font-size: 10px;
  height: 22px;
  justify-content: center;
  line-height: 1;
  min-height: 0;
  padding: 0;
  width: 26px;
}

.taxonomy-order-btn:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #cbd5e1;
  box-shadow: none;
  color: var(--ink);
  transform: none;
}

.taxonomy-order-btn:disabled {
  cursor: default;
  opacity: 0.35;
}

.taxonomy-row-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.taxonomy-row-form input[type="text"] {
  flex: 1 1 150px;
  min-width: 0;
}

.taxonomy-row-form select {
  flex: 0 0 auto;
}

.taxonomy-row-side {
  align-items: center;
  display: flex;
  gap: 10px;
}

.taxonomy-usage {
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.taxonomy-flag {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: var(--fw-medium);
  gap: 6px;
  margin: 0;
  white-space: nowrap;
}

/* Selector de color: radios nativos con una muestra visible. */
.color-picker {
  border: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
}

.color-swatch {
  cursor: pointer;
  display: inline-flex;
  margin: 0;
  position: relative;
}

.color-swatch input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.color-dot {
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 999px;
  height: 20px;
  width: 20px;
}

.color-swatch input:checked + .color-dot,
.color-swatch input:focus-visible + .color-dot {
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--accent);
}

.color-dot.blue { background: var(--c-blue-icon-bg); border-color: var(--c-blue-text); }
.color-dot.indigo { background: var(--c-indigo-icon-bg); border-color: var(--c-indigo-text); }
.color-dot.cyan { background: var(--c-cyan-icon-bg); border-color: var(--c-cyan-text); }
.color-dot.teal { background: var(--c-teal-icon-bg); border-color: var(--c-teal-text); }
.color-dot.green { background: var(--c-green-icon-bg); border-color: var(--c-green-text); }
.color-dot.amber { background: var(--c-amber-icon-bg); border-color: var(--c-amber-text); }
.color-dot.orange { background: var(--c-orange-icon-bg); border-color: var(--c-orange-text); }
.color-dot.rose { background: var(--c-rose-icon-bg); border-color: var(--c-rose-text); }
.color-dot.purple { background: var(--c-purple-icon-bg); border-color: var(--c-purple-text); }
.color-dot.gray { background: var(--c-gray-icon-bg); border-color: var(--c-gray-text); }

@media (max-width: 760px) {
  .taxonomy-row,
  .taxonomy-row--new {
    grid-template-columns: 1fr;
  }

  .taxonomy-row-side {
    justify-content: space-between;
  }
}
