/* CONNECTIO · encabezado operativo v56
   Regla final y aislada: evita que estilos historicos separen o monten acciones. */

body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar.cx-header {
  display: grid !important;
  grid-template-columns: minmax(210px, auto) minmax(260px, 1fr) auto !important;
  grid-template-areas: "context search actions" !important;
  align-items: center !important;
  gap: 12px !important;
  width: 100% !important;
  min-height: 64px !important;
  padding: 9px 12px !important;
  overflow: visible !important;
  box-sizing: border-box !important;
}

body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .topbar-left {
  grid-area: context !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: 320px !important;
  margin: 0 !important;
  overflow: hidden !important;
}

body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .breadcrumb {
  min-width: 0 !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  text-overflow: ellipsis !important;
}

body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .topbar-search {
  grid-area: search !important;
  display: flex !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 520px !important;
  margin: 0 !important;
  justify-self: end !important;
}

body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .topbar-search input {
  width: 100% !important;
  min-width: 0 !important;
  height: 42px !important;
}

body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .topbar-actions {
  grid-area: actions !important;
  display: flex !important;
  flex-flow: row nowrap !important;
  align-items: center !important;
  justify-content: flex-end !important;
  justify-self: end !important;
  gap: 7px !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: visible !important;
}

body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .topbar-actions > *,
body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .topbar-actions > button {
  flex: 0 0 auto !important;
  min-width: 0 !important;
  max-width: none !important;
  height: 42px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}

body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .connectia-btn {
  width: 96px !important;
  padding-inline: 10px !important;
}

body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .theme-toggle-btn {
  width: 94px !important;
  padding-inline: 9px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .notification-btn {
  position: relative !important;
  width: 68px !important;
  padding-inline: 8px !important;
}

body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .profile-menu {
  position: relative !important;
  flex: 0 0 218px !important;
  width: 218px !important;
  min-width: 188px !important;
  max-width: 218px !important;
  height: 42px !important;
  overflow: visible !important;
}

body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .user-chip {
  display: grid !important;
  grid-template-columns: 28px minmax(0, 1fr) auto auto !important;
  align-items: center !important;
  gap: 7px !important;
  width: 100% !important;
  height: 42px !important;
  padding: 5px 9px !important;
  overflow: hidden !important;
}

body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .user-chip strong,
body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .user-chip small {
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

/* Zoom moderado o notebook: segunda fila deliberada, nunca controles sueltos. */
@media (min-width: 761px) and (max-width: 1180px) {
  body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar.cx-header {
    grid-template-columns: minmax(210px, auto) minmax(220px, 1fr) !important;
    grid-template-areas:
      "context search"
      "actions actions" !important;
    row-gap: 8px !important;
  }

  body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .topbar-actions {
    width: 100% !important;
    justify-content: flex-end !important;
    padding-top: 8px !important;
    border-top: 1px solid #d7e5f2 !important;
  }
}

/* Celular: contexto, busqueda y controles en bloques completos. */
@media (max-width: 760px) {
  body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar.cx-header {
    grid-template-columns: 1fr !important;
    grid-template-areas:
      "context"
      "search"
      "actions" !important;
    gap: 8px !important;
  }

  body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .topbar-left,
  body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .topbar-search {
    width: 100% !important;
    max-width: none !important;
    justify-self: stretch !important;
  }

  body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .topbar-actions {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    width: 100% !important;
    padding-top: 8px !important;
    border-top: 1px solid #d7e5f2 !important;
  }

  body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .connectia-btn,
  body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .theme-toggle-btn,
  body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .notification-btn {
    width: 100% !important;
  }

  body:not(.auth-locked):not(.dashboard-tv-active) .smart-topbar .profile-menu {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }
}

/* El encabezado operativo nunca forma parte de la portada publica. */
html body.auth-locked .smart-topbar.cx-header,
html body.auth-locked #smartTopbar {
  display: none !important;
}
