:root {
  /* Acento GOC */
  --accent: #FF9600;
  --accent-dark: #e07f00;
  --accent-soft: #fff2e0;

  /* Categorías de campo (acento de 3px por columna) */
  --editable: #3b82f6;
  --required: #db2777;  /* rosa "importante": distinto del rojo de error (--err), que confundía */
  --group:    #f59e0b;
  --readonly: #9ca3af;

  /* Estado "cambios sin enviar" — violeta propio, para no confundirlo con el
     ámbar de --group ni con el naranja de marca (--accent). */
  --pending:  #7c3aed;

  /* Estado "borrador" (copia duplicada sin confirmar) — teal propio, distinto del ámbar de
     --group, del azul de --editable y del violeta de --pending. Antes usaba el naranja de marca
     en el lateral, que se confundía con el ámbar de "grupo" en la leyenda. Ahora tiñe la fila. */
  --draft: #0d9488;
  --draft-bg: #e9f6f3;
  --draft-bg-hover: #ddf0eb;

  /* Chrome */
  --sidebar-bg: #141414;
  --sidebar-active-bg: #3a2a0c;
  --sidebar-text: #9a9a9a;
  --content-bg: #f5f5f7;
  --card-bg: #ffffff;
  --border: #e6e6ea;
  --border-strong: #dcdce2;

  --ink: #1f2430;
  --muted: #6b7280;
  --ok: #1a7f37;
  --warn: #b45309;
  --err: #b91c1c;

  /* Escala de radios y sombras (tokens) para coherencia. Las píldoras (999px) y los contenedores
     especiales (modal 14px, auth-shell 20px) quedan fuera a propósito. */
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-pop: 0 8px 24px rgba(0,0,0,0.14);
  --shadow-modal: 0 16px 48px rgba(0,0,0,0.25);
}

* { box-sizing: border-box; }

.hidden { display: none !important; }

/* Foco de teclado VISIBLE en todo control interactivo. :focus-visible solo se muestra al navegar
   con teclado (no al hacer clic), así que no ensucia el uso con ratón. Antes solo los inputs/celdas
   tenían estilo de foco; botones, nav lateral, pestañas y menús quedaban sin señal. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
[contenteditable="true"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* Dentro del sidebar oscuro el naranja destaca sin offset que se pierda en el fondo. */
.sidebar button:focus-visible { outline-offset: -2px; }

body {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  color: var(--ink);
  background: var(--content-bg);
}

.ico {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------------- Estructura: sidebar + contenido ---------------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px; flex: none;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}

/* Marca en naranja GOC: mismo lenguaje que la pantalla de login, para que el sello identifique la
   herramienta en vez de leerse como una píldora gris neutra. Es identidad, no acción, y vive en el
   sidebar oscuro / aside de login, separado de las zonas de acción. */
.brand-badge {
  align-self: flex-start;
  background: var(--accent); color: #141414;
  font-weight: 700; font-size: 15px; letter-spacing: 0.5px;
  padding: 12px 18px; border-radius: 14px;
  margin: 4px 4px 22px;
}

.side-nav { display: flex; flex-direction: column; gap: 4px; }

.side-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: transparent; border: none;
  color: var(--sidebar-text);
  padding: 10px 12px; border-radius: var(--r-md);
  font-family: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer;
}
.side-item:hover { background: rgba(255,255,255,0.06); color: #dddddd; }
.side-item.active { background: var(--sidebar-active-bg); color: var(--accent); font-weight: 600; }
.side-item .ico { width: 18px; height: 18px; }

.side-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.08); display: flex; flex-direction: column; gap: 10px; }
.side-user { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.current-user { color: #e2e2e2; font-weight: 500; }
.side-item-sub { color: #8a8a8a; font-weight: 500; }

.mode-badge {
  align-self: flex-start;
  font-size: 10px; font-weight: 700; letter-spacing: 0.6px;
  background: #4a3a10; color: var(--accent);
  padding: 3px 9px; border-radius: 999px;
}

/* ---------------- Contenido ---------------- */

.content { flex: 1; min-width: 0; padding: 26px 30px 60px; }

.content-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.header-titles h1 { margin: 0; font-size: 22px; font-weight: 700; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.header-actions { display: flex; gap: 10px; flex: none; align-items: center; }

/* ---------------- Selector de cuenta activa ---------------- */
/* Selector de cuenta = CONTEXTO, no acción. Se calma a neutro (blanco + borde gris) para que la
   única pieza naranja dominante del header sea el botón Sincronizar y no compitan por la atención. */
.account-switcher {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 12px; margin-right: 4px;
  background: #fff; border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
}
.account-switcher.hidden { display: none; }
.account-ico { width: 20px; height: 20px; color: var(--muted); flex: none; }
.account-switcher-inner { display: flex; flex-direction: column; gap: 1px; }
.account-label { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.account-select {
  border: none; background: transparent; padding: 0; margin: 0;
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--ink);
  cursor: pointer; max-width: 240px;
}
.account-select:focus:not(:focus-visible) { outline: none; }
.account-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

/* ---------------- Botones ---------------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1.5px solid var(--border-strong);
  background: #fff; color: var(--ink);
  padding: 8px 15px; border-radius: var(--r-md);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap;  /* la etiqueta nunca se parte en varias líneas */
}
.btn:hover { background: #f2f2f5; }
.btn .ico { width: 15px; height: 15px; }

/* Primario SÓLIDO en reposo: es la acción dominante de cada pantalla, debe pesar más que el
   secundario (outline). Antes era blanco con texto naranja y solo se rellenaba al hover, así que
   parecía secundario. */
.btn-primary { border-color: var(--accent); color: #fff; background: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-primary:disabled { border-color: #f6cf97; color: #fff; background: #f6cf97; cursor: not-allowed; }

.btn-secondary { border-color: var(--border-strong); color: #3a3f4a; background: #fff; }
.btn-secondary:hover { background: #f2f2f5; }

/* Acción IRREVERSIBLE: envía los cambios a Meta (producción). Peso propio (sólido oscuro +
   sombra + negrita) para que no se pulse por inercia, coherente con "revisar antes de enviar". */
.btn-commit {
  border-color: var(--accent-dark); background: var(--accent-dark); color: #fff;
  padding: 9px 20px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(224,127,0,0.35);
}
.btn-commit:hover { background: #c96f00; border-color: #c96f00; color: #fff; }
.btn-commit:disabled { background: #f6cf97; border-color: #f6cf97; box-shadow: none; cursor: not-allowed; }

.btn-small { padding: 5px 11px; font-size: 12px; border-radius: var(--r-sm); }

/* Botón de drill-down (ver hijos): acento naranja con chevron a la derecha */
.btn-drill { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-soft); }
.btn-drill:hover { background: var(--accent); color: #fff; }
.btn-drill .ico { width: 13px; height: 13px; }

.btn-pending { position: relative; }
/* Violeta (--pending), no rojo: "cambios pendientes" es trabajo por revisar, no un error. Unifica
   con el resto de señales de pendiente (punto de fila, acentos). El rojo se reserva a errores. */
.count-badge {
  display: inline-block; min-width: 20px; padding: 1px 6px; margin-left: 2px;
  background: var(--pending); color: #fff; border-radius: 999px; font-size: 12px;
  font-weight: 700; text-align: center;
}
.count-badge.zero { background: #9ca3af; }

/* Papelera: icono rojo dentro de círculo rojo muy claro (como la tabla de leads) */
.btn-trash {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  border: none; background: #fdecec; color: #d33b3b; cursor: pointer;
}
.btn-trash:hover { background: #f9d5d5; }
.btn-trash .ico { width: 15px; height: 15px; }

/* Se conserva por compatibilidad, aunque el borrar usa .btn-trash */
.btn-danger { border-color: #e0a9a3; color: #c0392b; background: #fff; }
.btn-danger:hover { background: #c0392b; color: #fff; border-color: #c0392b; }

/* ---------------- Control segmentado (Campañas/Conjuntos/Anuncios) ---------------- */

.segmented { display: inline-flex; gap: 3px; background: #ececef; padding: 4px; border-radius: var(--r-md); margin-bottom: 14px; }
.seg-item {
  border: none; background: transparent; color: #5b6068;
  padding: 8px 20px; border-radius: var(--r-sm);
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.seg-item:hover { color: var(--ink); }
.seg-item.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.14); }

/* ---------------- Migas de pan (drill-down) ---------------- */

.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; font-size: 13px; }
.breadcrumb:empty { display: none; }
.crumb { padding: 2px 4px; color: var(--muted); }
.crumb-current { color: var(--ink); font-weight: 700; }
.crumb-link {
  border: none; background: none; font-family: inherit; font-size: 13px;
  color: var(--accent-dark); cursor: pointer; padding: 2px 4px; border-radius: var(--r-sm);
}
.crumb-link:hover { background: var(--accent-soft); text-decoration: underline; }
.crumb-sep { color: var(--border-strong); font-weight: 700; }

/* ---------------- Modal de sincronización selectiva ---------------- */

.sync-modes { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.sync-mode {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--r-md); cursor: pointer;
  transition: border-color .12s, background .12s;
}
.sync-mode:hover { border-color: var(--accent); background: var(--accent-soft); }
.sync-mode input { margin-top: 3px; accent-color: var(--accent); }
.sync-mode-text { display: flex; flex-direction: column; gap: 2px; }
.sync-mode-text b { font-size: 13px; }
.sync-mode-text small { font-size: 12px; color: var(--muted); }
.sync-replace {
  display: flex; align-items: flex-start; gap: 10px; margin-top: 14px;
  padding-top: 14px; border-top: 1px solid var(--border); cursor: pointer;
}
.sync-replace input { margin-top: 3px; accent-color: var(--warn); }
.sync-replace-text { display: flex; flex-direction: column; gap: 2px; }
.sync-replace-text b { font-size: 13px; }
.sync-replace-text small { font-size: 12px; color: var(--muted); }

.sync-filters {
  display: flex; flex-direction: column; gap: 10px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.sync-check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.sync-check input { margin-top: 3px; accent-color: var(--accent); }
.sync-check-text { display: flex; flex-direction: column; gap: 2px; }
.sync-check-text b { font-size: 13px; }
.sync-check-text small { font-size: 12px; color: var(--muted); }

.sync-picker { margin-top: 14px; border-top: 1px solid var(--border-strong); padding-top: 14px; }
.sync-picker-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sync-search {
  flex: 1; padding: 7px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); font-size: 13px; background: var(--bg); color: inherit;
}
.sync-status-filter {
  padding: 7px 8px; border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); font-size: 13px; background: var(--bg); color: inherit;
}
.sync-picker-subhead {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted); margin-bottom: 8px;
}
.sync-count { font-weight: 600; }
.sync-campaign-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 240px; overflow-y: auto;
}
.sync-campaign-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--r-sm); cursor: pointer;
}
.sync-campaign-item:hover { background: var(--accent-soft); }
.sync-campaign-item input { accent-color: var(--accent); }
.sync-camp-name { flex: 1; font-size: 13px; }

/* Selector multi "Copiar a…": misma lista que el picker de sync; para anuncios→conjuntos las filas
   van agrupadas por campaña con una cabecera pegajosa. */
.copy-multi-picker { margin-top: 6px; }
.copy-multi-group {
  position: sticky; top: 0; z-index: 1; background: var(--card-bg);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 8px 6px 4px;
}
.copy-multi-preview { margin-right: auto; font-weight: 600; font-size: 13px; color: var(--ink); }

/* ---------------- Leyenda ---------------- */

/* Leyenda plegable: recupera altura útil para la tabla; el estado (abierta/cerrada) se recuerda. */
.legend { margin-bottom: 12px; font-size: 12px; color: var(--muted); }
.legend-summary {
  cursor: pointer; font-weight: 600; color: var(--muted); list-style: none;
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 0; user-select: none;
}
.legend-summary::-webkit-details-marker { display: none; }
.legend-summary::before { content: "▸"; font-size: 10px; transition: transform 0.15s; }
.legend[open] .legend-summary::before { transform: rotate(90deg); }
.legend-items { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.kind-editable { background: var(--editable); }
.swatch.kind-required { background: var(--required); }
.swatch.kind-group    { background: var(--group); }
.swatch.kind-readonly { background: var(--readonly); }
.swatch.kind-draft    { background: var(--draft); }

/* ---------------- Duplicación en lote ---------------- */

.dup-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px; padding: 8px 12px;
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--r-md); font-size: 13px;
}
.dup-bar.hidden { display: none; }
.dup-bar-status { font-weight: 600; color: var(--accent-dark); }
.dup-scope { padding: 5px 9px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); font-size: 12px; }
/* Ancho FIJO (border-box) para que la columna fija de al lado pueda anclarse a left:36px exacto. */
.dup-check-col { width: 36px; min-width: 36px; max-width: 36px; padding-left: 8px; padding-right: 8px; text-align: center; }
.dup-check-col input { cursor: pointer; }

/* ---------------- Tabla ---------------- */

.table-container { overflow-x: auto; }
.hint { color: var(--muted); }

/* ---------------- Barra de filtros de Auditoría ----------------
   Dos filas: buscador (ancho) arriba con el contador; filtros abajo. Antes iba todo en un solo
   flex que envolvía mal al estrecharse. */
.audit-toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.audit-toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.audit-toolbar-search { align-items: center; }
.audit-search {
  flex: 1 1 240px; min-width: 200px; padding: 8px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font-size: 13px; background: var(--bg); color: inherit;
}
.audit-cap-note { margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.audit-filter {
  padding: 7px 8px; border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); font-size: 13px; background: var(--bg); color: inherit;
}
.audit-date {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
}
.audit-date input {
  padding: 6px 8px; border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); font-size: 13px; background: var(--bg); color: inherit;
}
.audit-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); cursor: pointer;
}
.audit-check input { accent-color: var(--accent); }
.audit-count { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; }

/* Badge de resultado en la tabla de auditoría */
.audit-result {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.audit-result-ok { background: #e7f5ec; color: #1c7a43; }
.audit-result-err { background: #fdeaea; color: #b3261e; }
table.grid tbody tr.audit-row-err td { background: #fef6f6; }

/* Fecha/ID: no envolver, cifras tabulares (mismas que Workspace, sin monoespaciada). */
.audit-grid .audit-when { white-space: nowrap; }

/* Detalles como chips legibles en vez de JSON crudo. La clave en gris, el valor en tinta. */
.audit-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.audit-chip {
  display: inline-flex; align-items: baseline; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  background: var(--content-bg); border: 1px solid var(--border);
  font-size: 12px; line-height: 1.5;
}
.audit-chip-k { color: var(--muted); font-weight: 600; }
.audit-chip-v { color: var(--ink); font-variant-numeric: tabular-nums; }
.audit-chip-empty { color: var(--muted); border-style: dashed; }

/* Estado vacío: una invitación a actuar, no solo un aviso. */
.empty-state { text-align: center; padding: 52px 20px; }
.empty-state h3 { margin: 0 0 6px; font-size: 16px; color: var(--ink); }
.empty-state p { margin: 0 auto 18px; font-size: 13px; color: var(--muted); max-width: 380px; line-height: 1.5; }

table.grid {
  border-collapse: separate; border-spacing: 0;
  width: 100%; background: var(--card-bg); font-size: 13px;
  border: 1.5px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
/* NOTA: la tabla NO lleva overflow:hidden. Si lo llevara, las columnas fijas (sticky) se anclarían
   a la propia tabla en vez de a #table-container (el contenedor con scroll horizontal) y no se
   quedarían fijas. El precio es que las esquinas redondeadas ya no recortan la cabecera (mínimo). */
table.grid th, table.grid td {
  padding: 9px 12px; text-align: left; vertical-align: top;
  max-width: 260px; overflow-wrap: anywhere;
  border-bottom: 1px solid #eeeef1;
}
table.grid thead th {
  position: sticky; top: 0;
  background: #f4f4f6; color: #6b7280;
  font-size: 11px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase;
  white-space: nowrap;
}
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover td { background: #fafafb; }

/* ---- Columnas fijas (sticky) ----
   Mantienen a la vista la casilla de selección, el identificador de la fila y la columna de
   Acciones al desplazarse en horizontal por la tabla ancha, para no perder de vista qué objeto se
   está editando cuando el copy queda a la derecha. */
.dup-check-col { position: sticky; left: 0; z-index: 1; background: var(--card-bg); }
table.grid td.sticky-col, table.grid th.sticky-col {
  position: sticky; left: 36px; z-index: 1; background: var(--card-bg);
  box-shadow: 6px 0 8px -6px rgba(0,0,0,0.10);
}
table.grid td.actions-cell, table.grid th.actions-col {
  position: sticky; right: 0; z-index: 1; background: var(--card-bg);
  box-shadow: -6px 0 8px -6px rgba(0,0,0,0.12);
}
/* Cabecera: las celdas fijas van por encima del resto de la cabecera (sticky top + left/right). */
table.grid thead th { z-index: 2; }
table.grid thead th.dup-check-col,
table.grid thead th.sticky-col,
table.grid thead th.actions-col { z-index: 3; background: #f4f4f6; }
/* Las celdas fijas deben tapar de forma opaca lo que scrollea por debajo, según el estado de fila. */
table.grid tbody tr:hover td.dup-check-col,
table.grid tbody tr:hover td.sticky-col,
table.grid tbody tr:hover td.actions-cell { background: #fafafb; }
table.grid tbody tr.row-duplicated td.dup-check-col,
table.grid tbody tr.row-duplicated td.sticky-col,
table.grid tbody tr.row-duplicated td.actions-cell { background: var(--draft-bg); }
table.grid tbody tr.row-duplicated:hover td.dup-check-col,
table.grid tbody tr.row-duplicated:hover td.sticky-col,
table.grid tbody tr.row-duplicated:hover td.actions-cell { background: var(--draft-bg-hover); }

/* Acento de categoría: borde izquierdo de 3px por columna (editable/obligatorio/grupo/no-tocar) */
th.kind-editable, td.kind-editable { border-left: 3px solid var(--editable); }
th.kind-required, td.kind-required { border-left: 3px solid var(--required); }
th.kind-group,    td.kind-group    { border-left: 3px solid var(--group); }
th.kind-readonly, td.kind-readonly { border-left: 3px solid var(--readonly); color: #555; }

/* Columnas de texto largo (titulares, copy, descripciones): el triple de anchas que el resto
   (tope general 260px → 780px) para que el texto se lea cómodo en vez de embutido en columnas
   estrechas. Con auto-layout el max-width no basta (el navegador estrecha las columnas para caber
   al 100%), así que se FUERZA el ancho con min-width; la tabla desborda a scroll horizontal si
   hace falta. El texto envuelve con normalidad dentro de ese ancho. */
table.grid th[data-field="titles"],       table.grid td[data-field="titles"],
table.grid th[data-field="bodies"],       table.grid td[data-field="bodies"],
table.grid th[data-field="primary_link"], table.grid td[data-field="primary_link"],
table.grid th[data-field="descriptions"], table.grid td[data-field="descriptions"] {
  min-width: 390px;
  max-width: 390px;
  white-space: normal;
}

/* Estado: cuando el objeto está sincronizado, la celda es un <select> con width:100%, que se
   deja estrechar sin límite y recorta "ACTIVE"/"PAUSED". Un min-width en la columna le da sitio
   para mostrar el texto entero (mismo motivo que las columnas de texto largo de arriba). */
table.grid th[data-field="status"], table.grid td[data-field="status"] { min-width: 124px; }

/* Columnas de datos (id, números, presupuestos, fechas): cifras tabulares de la propia Montserrat
   para que alineen en columna, sin cambiar de tipografía (nada de monoespaciada). */
.num-col { font-variant-numeric: tabular-nums; }

/* Celdas multivariante (títulos/cuerpos/descripciones con varias opciones): lista apilada con un
   índice numerado y separación fina, en vez del "|" plano. Ocupa lo mínimo: un índice pequeño y
   una línea divisoria por variante. */
.variant-list { display: flex; flex-direction: column; }
.variant-item { display: flex; gap: 8px; align-items: baseline; padding: 5px 0; }
.variant-item:first-child { padding-top: 0; }
.variant-item:last-child { padding-bottom: 0; }
.variant-item + .variant-item { border-top: 1px dashed var(--border); }
.variant-idx {
  flex: 0 0 auto; min-width: 17px; height: 17px; padding: 0 4px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--content-bg); border: 1px solid var(--border); border-radius: 5px;
  font-size: 10px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums;
}
/* La principal (feeds/default) destaca con el color de marca; las variantes quedan en gris. */
.variant-idx-main { background: var(--accent); border-color: var(--accent); color: #fff; }
.variant-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }

td[contenteditable="true"] { cursor: text; outline: none; }
/* Indicio en reposo de que la celda se puede editar: al pasar el ratón se tiñe suave y aparece un
   cursor de texto, para que no haya que enfocarla a ciegas para saber que es editable. */
table.grid td[contenteditable="true"]:hover { background: var(--accent-soft); }
td[contenteditable="true"]:focus { box-shadow: inset 0 0 0 2px var(--accent); }
td.dirty { font-weight: 600; }
td.invalid { box-shadow: inset 0 0 0 2px var(--err); }

/* Filas con cambios sin enviar: acento violeta (--pending) a la izquierda.
   Borradores (copias duplicadas sin confirmar): la FILA se tiñe de teal suave (--draft-bg), no un
   acento lateral, para percibirlo rápido sin confundirlo con el ámbar de "grupo". El prefijo
   completo table.grid tbody da especificidad para ganar al hover genérico; el hover del borrador
   mantiene el tinte (un punto más oscuro). Ambas señales conviven: un borrador con cambios sin
   enviar muestra el fondo teal + el acento violeta + el punto. */
tr.row-pending td:first-child { border-left: 3px solid var(--pending); }
table.grid tbody tr.row-duplicated td { background: var(--draft-bg); }
table.grid tbody tr.row-duplicated:hover td { background: var(--draft-bg-hover); }
.pending-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--pending); margin-right: 5px; }

/* Píldoras de estado / etiquetas cortas (estado ACTIVE/PAUSED, formato_aviso) */
.pill {
  display: inline-flex; align-items: center; white-space: nowrap;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
  background: #eef0f2; color: #5b6572;
}
.pill-active { background: #e7f6ec; color: var(--ok); }
.pill-paused { background: #eef0f2; color: #5b6572; }
.pill-format { background: var(--accent-soft); color: #b25e00; }

/* Widgets de celda (tipos de campo): desplegable enum, número, fecha/hora. */
.cell-select, .cell-input {
  width: 100%; box-sizing: border-box; font: inherit; color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 4px 6px; background: #fff;
}
.cell-select:focus, .cell-input:focus { outline: none; border-color: var(--accent); }
td.locked { color: var(--muted); background: #f7f7f9; cursor: not-allowed; }
.swatch.kind-pending { background: var(--pending); border-radius: 50%; }

.actions-cell { white-space: nowrap; vertical-align: middle; width: 1%; max-width: none; }
.actions-cell > * + * { margin-left: 8px; }

/* Menú "Acciones": se pinta en <body> con position:fixed para escapar del overflow:hidden de
   la tabla (si no, se recortaba). openActionsMenu le fija left/top según el botón ancla. */
.actions-menu {
  position: fixed; z-index: 300; min-width: 172px; padding: 6px;
  background: #fff; border: 1.5px solid var(--border-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
}
.actions-menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: none; border-radius: var(--r-sm); background: none;
  font-size: 13px; color: #3a3f4a; text-align: left; cursor: pointer;
}
.actions-menu-item:hover { background: #f2f2f5; }
.actions-menu-item .ico { width: 15px; height: 15px; }
.actions-menu-item.danger { color: #c0392b; }
.actions-menu-item.danger:hover { background: #f9d5d5; }

/* ---------------- Configuración ---------------- */

/* Dos grupos con eyebrow ("Conexión con Meta" / "Personas") para separar lo de solo lectura de las
   acciones sobre personas. El eyebrow reusa el estilo de cabecera de columna de la tabla. */
.config-section { margin-bottom: 34px; }
.config-eyebrow {
  margin: 0 0 14px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted);
}
/* Los dos paneles pequeños (info de conexión + cuentas conectadas) van lado a lado en ancho y se
   apilan al estrecharse; cada uno conserva su tamaño natural. */
.config-duo { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.config-duo > .config-panel { margin: 0; }

.config-panel { max-width: 560px; background: #fff; border: 1.5px solid var(--border); border-radius: var(--r-lg); padding: 20px 22px; box-shadow: var(--shadow-card); }
.config-panel h2 { margin-top: 0; font-size: 16px; }
.config-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #eee; }
.config-row:last-child { border-bottom: none; }
.config-row span { color: var(--muted); }
.config-help-sub { margin: 4px 0 12px; color: var(--muted); font-size: 12px; line-height: 1.45; }

/* Banner de modo: en REAL avisa de que se tocan cuentas reales de cliente (seguridad). */
.mode-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 14px; font-size: 13px;
}
.mode-banner-tag { font-weight: 700; padding: 2px 9px; border-radius: 999px; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
.mode-banner-text { flex: 1; line-height: 1.4; }
.mode-banner-mock { background: var(--content-bg); border: 1px solid var(--border); color: var(--muted); }
.mode-banner-mock .mode-banner-tag { background: #e6e6ea; color: #4b5563; }
.mode-banner-real { background: #fff8ec; border: 1px solid #f2d3a6; color: #7a4a00; }
.mode-banner-real .mode-banner-tag { background: var(--accent); color: #fff; }

/* Panel de cuentas conectadas (dentro de Configuración) */
#connected-accounts-panel { max-width: 620px; }
.ca-table { width: 100%; }
.ca-ok { color: var(--ok); font-weight: 600; white-space: nowrap; }
/* Un ÚNICO callout para el paso 2 (no comprobable por API), en vez de repetir el mismo aviso en
   cada fila de la tabla —donde acababa siendo ruido que se ignora—. */
.ca-callout {
  display: flex; flex-direction: column; gap: 4px;
  background: #fff8ec; border: 1px solid #f2d3a6; border-radius: var(--r-sm);
  padding: 10px 12px; margin-top: 14px; font-size: 13px; line-height: 1.45; color: #7a4a00;
}
.ca-callout-tag { font-weight: 700; color: var(--warn); }

/* "Cómo conectar una cuenta nueva": los dos pasos SON una secuencia obligatoria en orden, así que
   se presentan como tarjetas numeradas (el número comunica el orden, no decora). */
.connect-help { max-width: 720px; margin-top: 18px; }
.connect-steps {
  list-style: none; counter-reset: step; margin: 6px 0 4px; padding: 0;
  display: flex; flex-direction: column; gap: 10px;
}
.connect-steps > li {
  counter-increment: step; position: relative;
  padding: 12px 14px 12px 48px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--content-bg);
}
.connect-steps > li::before {
  content: counter(step); position: absolute; left: 12px; top: 12px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.connect-step-title { margin: 0 0 4px; font-size: 13px; font-weight: 700; color: var(--ink); }
.connect-step-tag {
  margin-left: 6px; padding: 1px 8px; border-radius: 999px; white-space: nowrap;
  background: #fff; border: 1px solid var(--border); color: var(--muted);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
}
.connect-path { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.connect-path b { color: var(--ink); }
.connect-path code {
  background: #fff; border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 1px 6px; font-size: 12px; color: var(--ink);
}

/* Columna de acciones de la tabla de usuarios: a su ancho, sin partir la etiqueta del botón. */
.users-actions-cell { white-space: nowrap; width: 1%; }

/* ---------------- Modales ---------------- */

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-overlay.hidden { display: none; }
.modal { background: #fff; border-radius: 14px; width: min(620px, 92vw); max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow-modal); }
.modal-header, .modal-footer { padding: 15px 20px; display: flex; align-items: center; justify-content: space-between; }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); gap: 10px; justify-content: flex-end; }
.modal-header h2 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-close { border: none; background: none; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-wide { width: min(760px, 94vw); }

/* ---- Editor de segmentación (targeting) ---- */
.tgt-name { font-size: 14px; margin-bottom: 10px; }
.tgt-warn { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; border-radius: var(--r-sm); padding: 8px 10px; font-size: 13px; margin-bottom: 12px; }
.tgt-section { border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 12px; }
.tgt-h3 { margin: 0 0 4px; font-size: 14px; font-weight: 700; }
.tgt-hint { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.tgt-sub { font-size: 12px; font-weight: 600; color: #3a3f4a; margin: 8px 0 4px; }
.tgt-inline { display: flex; gap: 14px; align-items: center; flex-wrap: nowrap; }
.tgt-inline.tgt-wrap { flex-wrap: wrap; }
.tgt-check, .tgt-toggle { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 500; cursor: pointer; }
.tgt-field { display: inline-flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 600; color: #3a3f4a; }
.tgt-num { width: 90px; padding: 7px 9px; border: 1.5px solid var(--border-strong); border-radius: var(--r-sm); font-size: 14px; font-family: inherit; }
.tgt-num:disabled { background: #f3f4f6; color: var(--muted); }

.tgt-search { position: relative; margin: 6px 0; flex: 1; }
.tgt-search-input { width: 100%; padding: 8px 10px; border: 1.5px solid var(--border-strong); border-radius: var(--r-sm); font-size: 14px; font-family: inherit; }
.tgt-search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tgt-results { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; background: #fff; border: 1px solid var(--border-strong); border-radius: var(--r-sm); box-shadow: var(--shadow-pop); max-height: 240px; overflow-y: auto; margin-top: 2px; }
.tgt-results.hidden { display: none; }
.tgt-result { padding: 8px 10px; font-size: 13px; cursor: pointer; }
.tgt-result:hover { background: var(--accent-soft); }
.tgt-result-msg { color: var(--muted); font-style: italic; cursor: default; }
.tgt-result-msg:hover { background: none; }

.tgt-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.tgt-empty { font-size: 12px; color: var(--muted); font-style: italic; }
.tgt-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); border: 1px solid var(--accent); color: #7a4a00; border-radius: 999px; padding: 3px 6px 3px 10px; font-size: 12.5px; }
.tgt-chip.chip-beh { background: #e0e7ff; border-color: #818cf8; color: #3730a3; }
.tgt-chip.chip-exc { background: #fee2e2; border-color: #f87171; color: #991b1b; }
.tgt-chip-x { border: none; background: none; cursor: pointer; font-size: 15px; line-height: 1; color: inherit; padding: 0 2px; }

.tgt-and { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; margin: 8px 0; }
.tgt-block { border: 1px dashed var(--border-strong); border-radius: var(--r-sm); padding: 8px 10px; }
.tgt-block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.tgt-or-label { font-size: 12px; font-weight: 700; color: #3a3f4a; }
.tgt-add-block { margin-top: 8px; }

.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.form-row input[type="text"], .form-row input[type="email"], .form-row input[type="password"],
.form-row select, .form-row textarea {
  width: 100%; padding: 9px 10px; border: 1.5px solid var(--border-strong); border-radius: var(--r-sm); font-size: 14px; font-family: inherit;
  color: var(--ink); background: #fff;
}
.form-row input[type="text"]:focus, .form-row input[type="email"]:focus, .form-row input[type="password"]:focus,
.form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-row .req { color: var(--err); }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 3px; }

.edit-section-title {
  margin: 18px 0 4px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted);
}

.radio-row { display: flex; gap: 16px; margin-bottom: 10px; }
.radio-row label { font-weight: 500; display: flex; align-items: center; gap: 6px; }

/* Lista de toggles Advantage+ (una fila con checkbox por cada feature que devuelva Meta). */
.feat-list { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.feat-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 13px; cursor: pointer; border-radius: var(--r-sm); }
.feat-row:hover { background: #f7f7f9; }
.feat-row input { margin: 0; }
/* Feature nueva de Meta sin etiqueta conocida: acento violeta para que salte a la vista. */
.feat-row.feat-new span { color: var(--pending); font-weight: 600; }

/* Editor de VARIAS opciones de texto por apartado (principal + extras que Meta rota). */
.text-list { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 6px; }
.tl-row { display: flex; align-items: flex-start; gap: 8px; }
.tl-row .tl-input { flex: 1; }
.tl-badge {
  flex: 0 0 auto; margin-top: 6px; padding: 1px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.tl-badge-main { background: color-mix(in srgb, var(--pending) 16%, #fff); color: var(--pending); }
.tl-badge-extra { background: #eef0f3; color: var(--muted); }
.tl-remove {
  flex: 0 0 auto; margin-top: 2px; width: 26px; height: 26px; line-height: 1;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: #fff;
  color: var(--muted); font-size: 16px; cursor: pointer;
}
.tl-remove:hover { color: #c0392b; border-color: #c0392b; }

/* Editor de variantes por emplazamiento (B2): una tarjeta por variante. */
.pl-card { border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px; margin-bottom: 12px; background: #fafbfc; }
.pl-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.pl-positions { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.pl-pos-lbl { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 500; }
#pl-add { margin-top: 4px; }

.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
/* Carrusel lateral: tira horizontal con scroll para no alargar el popup. Los tiles no
   encogen (flex-shrink:0) y miden ~45% del ancho, de modo que siempre se ven al menos dos
   —con un asomo de la siguiente— entre todas las opciones. */
.image-carousel { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding-bottom: 8px; scroll-snap-type: x proximity; }
.image-carousel .image-tile { flex: 0 0 45%; max-width: 180px; scroll-snap-align: start; }
.image-tile { border: 2px solid var(--border); border-radius: var(--r-md); padding: 10px; cursor: pointer; font-size: 12px; background: #fafbfc; text-align: center; }
.image-tile:hover { border-color: var(--accent); }
.image-tile.selected { border-color: var(--accent); background: var(--accent-soft); }
.image-tile .thumb { height: 60px; border-radius: var(--r-sm); background: #dbe2ea center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: #94a3b8; margin-bottom: 6px; }

/* Selector doble de imagen (visual ↔ ID) */
.media-sel { display: flex; flex-direction: column; gap: 8px; }
.media-sel-preview .media-preview { height: 120px; border-radius: var(--r-sm); border: 1px solid var(--border); background: #dbe2ea center/cover no-repeat; display: flex; align-items: center; justify-content: center; text-align: center; color: #64748b; font-size: 12px; padding: 8px; }
.media-sel-preview .media-preview.empty { background: #f1f5f9; border-style: dashed; }
.media-sel-preview .media-preview.no-thumb { background: #f8fafc; }
.media-sel-controls { display: flex; gap: 8px; align-items: center; }
.media-id-input { flex: 1; }
.media-gallery-toggle { white-space: nowrap; }
.media-sel-grid { margin-top: 4px; }
.media-sel-grid.hidden { display: none; }
.media-preview.media-video { position: relative; align-items: flex-start; justify-content: flex-start; }
.media-video-badge { background: rgba(15, 23, 42, 0.75); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }

/* Review cards */
.review-card { border: 1.5px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 12px; }
.review-card h3 { margin: 0 0 8px; font-size: 14px; }
.review-card .obj-type { color: var(--muted); font-weight: 400; font-size: 12px; }
.change-line { font-size: 13px; padding: 2px 0; }
.change-line .field { font-weight: 600; }
.change-line .arrow { color: var(--muted); margin: 0 6px; }
.problems { color: var(--err); font-size: 12px; margin-top: 6px; }
.card-status { font-size: 13px; font-weight: 600; padding: 4px 0; }
.status-ok { color: var(--ok); }
.status-conflicto { color: var(--warn); }
.status-rechazado { color: var(--err); }
.status-omitido { color: var(--muted); }
.status-error { color: var(--err); }
.review-card.disabled { opacity: 0.7; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1f2430; color: #fff; padding: 12px 20px; border-radius: var(--r-md); font-size: 14px; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,0.3); max-width: 80vw; }
.toast.hidden { display: none; }
.toast.toast-err { background: var(--err); }
.toast.toast-ok { background: var(--ok); }
.toast.toast-warn { background: #b26a00; }

/* Bandeja de envíos en 2º plano: pila de tarjetas abajo a la derecha. La de "enviando" lleva
   spinner; al terminar se vuelve confirmación/error con botón × (NO se autocierra: la cierra
   la compañera cuando quiere). */
.send-tray { position: fixed; bottom: 20px; right: 20px; z-index: 210; display: flex;
  flex-direction: column; gap: 10px; max-width: min(360px, 90vw); }
.send-card { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-md);
  background: #1f2430; color: #fff; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,0.3); }
.send-card .send-msg { flex: 1; }
.send-card.send-ok { background: var(--ok); }
.send-card.send-err { background: var(--err); }
.send-card.send-warn { background: var(--warn); }
.send-close { flex: none; background: transparent; border: 0; color: inherit; font-size: 20px;
  line-height: 1; cursor: pointer; padding: 0 2px; opacity: 0.85; }
.send-close:hover { opacity: 1; }

/* ---- Pantalla de autenticación (login / cambio de contraseña) ---- */
.auth-screen {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 28% 18%, #232323, #0d0d0d 72%);
  padding: 24px;
}
.auth-shell {
  display: grid; grid-template-columns: 1fr 1fr;
  width: 100%; max-width: 860px;
  background: #fff; border-radius: 20px; overflow: hidden;
  box-shadow: 0 24px 70px rgba(0,0,0,0.4);
}

/* Columna de marca (lado oscuro, mismo lenguaje que el sidebar) */
.auth-aside {
  position: relative; overflow: hidden;
  background: var(--sidebar-bg); color: #b8b8b8;
  padding: 44px 38px; display: flex; flex-direction: column;
}
.auth-aside::after {
  content: ""; position: absolute; right: -80px; top: -80px;
  width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,150,0,0.32), transparent 68%);
  pointer-events: none;
}
.auth-brand { display: inline-block; margin: 0 0 auto; }
.auth-aside-title { color: #fff; font-size: 24px; font-weight: 700; line-height: 1.25; margin: 28px 0 12px; }
.auth-aside-text { font-size: 14px; line-height: 1.55; margin: 0 0 22px; color: #a5a5a5; }
.auth-aside-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.auth-aside-list li { position: relative; padding-left: 24px; font-size: 13px; color: #d0d0d0; }
.auth-aside-list li::before {
  content: ""; position: absolute; left: 0; top: 3px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 4px var(--accent);
}

/* Columna del formulario */
.auth-main { padding: 48px 44px; display: flex; flex-direction: column; justify-content: center; }
.auth-panel h1 { margin: 0 0 6px; font-size: 24px; font-weight: 700; }
.auth-hint { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.auth-panel .form-row { margin-bottom: 16px; }
.auth-submit { width: 100%; justify-content: center; margin-top: 8px; padding: 11px 15px; font-size: 15px; }
.auth-error {
  background: #fdecec; color: var(--err); border: 1px solid #f5c2c2;
  border-radius: var(--r-sm); padding: 9px 11px; font-size: 13px; margin-bottom: 14px;
}

/* Campo de contraseña con botón de mostrar/ocultar */
.pw-field { position: relative; }
.pw-field input { padding-right: 42px; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: none; background: none;
  color: var(--muted); cursor: pointer; border-radius: var(--r-sm);
}
.pw-toggle:hover { color: var(--ink); background: #f2f2f5; }
.pw-toggle .ico { width: 18px; height: 18px; }
.pw-toggle .pw-eye-off { display: none; }
.pw-toggle.showing .pw-eye { display: none; }
.pw-toggle.showing .pw-eye-off { display: block; }

/* En pantallas estrechas: solo el formulario, sin la columna de marca */
@media (max-width: 720px) {
  .auth-shell { grid-template-columns: 1fr; max-width: 400px; }
  .auth-aside { display: none; }
  .auth-main { padding: 36px 28px; }
}

/* ---- Gestión de usuarios (solo admin) ---- */
.users-panel { max-width: 760px; }
.users-section-title { margin: 0 0 14px; font-size: 16px; }
.users-create {
  background: #fff; border: 1.5px solid var(--border); border-radius: var(--r-lg);
  padding: 18px 20px; margin-bottom: 20px; box-shadow: var(--shadow-card);
}
.users-create h2 { margin: 0 0 4px; font-size: 15px; }
.users-create-sub { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.users-create-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.users-create-row .form-row { margin: 0; flex: 1; min-width: 180px; }
.temp-pass-box {
  margin-top: 14px; background: var(--accent-soft); border: 1px solid #f2d3a6;
  border-radius: var(--r-md); padding: 12px 14px; font-size: 13px; line-height: 1.5;
}
.temp-pass-intro { margin: 0 0 4px; }
.temp-pass-warn { margin: 0 0 10px; color: #7a4a00; }
.temp-pass-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.temp-pass-code {
  background: #fff; border: 1px solid #f2d3a6; border-radius: var(--r-sm);
  padding: 4px 10px; font-weight: 700; font-size: 15px; letter-spacing: 1px; color: #b25e00;
}
.role-tag { display: inline-flex; white-space: nowrap; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.role-tag.role-admin { background: var(--accent-soft); color: #b25e00; }
.role-tag.role-companero { background: #eef0f2; color: #5b6572; }
.user-status { display: inline-flex; white-space: nowrap; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.user-status.status-active { background: #e7f6ec; color: var(--ok); }
.user-status.status-pending { background: var(--accent-soft); color: #b25e00; }
.user-status.status-blocked { background: #f9d5d5; color: #c0392b; }
tr.user-row-blocked td { background: #fcf3f3; color: #98a2ad; }
.user-you { font-size: 11px; color: #98a2ad; font-weight: 600; }

/* Popups del protocolo de adaptaciones al duplicar */
.adapt-list { margin: 8px 0; padding-left: 18px; }
.adapt-list li { margin-bottom: 8px; }
.adapt-list code { background: #eef0f2; padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.adapt-code {
  background: #141414; color: #e6e6ea; border-radius: var(--r-sm); padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  white-space: pre-wrap; word-break: break-word; user-select: all; margin: 6px 0 12px;
}
.page-perm-steps { margin: 8px 0; padding-left: 20px; }
.page-perm-steps li { margin-bottom: 6px; }
#page-perm-name { user-select: all; }

/* ---------------- Responsive del área de trabajo ----------------
   Es una herramienta de escritorio, pero en portátiles pequeños el header se apelotonaba y el
   sidebar comía ancho. Suelo razonable: a ancho medio dejamos respirar el header; en estrecho el
   sidebar se reduce a una tira de iconos. */
@media (max-width: 1024px) {
  .content { padding: 20px 16px 48px; }
  .header-actions { flex-wrap: wrap; justify-content: flex-end; }
  .account-select { max-width: 180px; }
}

@media (max-width: 760px) {
  .sidebar { width: 60px; padding: 14px 8px; align-items: center; }
  .sidebar .brand-badge,
  .sidebar .mode-badge,
  .side-item span,
  .side-user span { display: none; }
  .side-item { justify-content: center; padding: 10px; }
  .side-footer { align-items: center; }

  .content-header { flex-direction: column; align-items: stretch; }
  .header-actions { justify-content: flex-start; }
  .account-switcher { margin-right: 0; }
  .account-select { max-width: none; }
  .btn-pending { margin-left: auto; }
}

/* Indicador de carga: spinner + texto (reemplaza el "Cargando…" plano). */
.loader { display: flex; align-items: center; gap: 10px; padding: 18px 4px; color: var(--muted); font-size: 13px; }
.spinner {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Respeta a quien pide menos movimiento (accesibilidad): anula transiciones y animaciones. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
